[Webkit-unassigned] [Bug 149338] [ES6] Arrow function created before super() causes TDZ, should it?

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Oct 5 08:19:57 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=149338

--- Comment #11 from GSkachkov <gskachkov at gmail.com> ---
Comment on attachment 262397
  --> https://bugs.webkit.org/attachment.cgi?id=262397
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=262397&action=review

I've uploaded new patch. It is as previous just Draft, but it look more 'mature' for me. Patch covers only 'Function' case in BytecodeGenerator, because creating of lexical_env already implemented in it. If new patch more or less ok in approach to store 'this' I'll try to implement  lexical_env for 'Program' & 'Eval' case

>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:485
>> +            RefPtr<RegisterID> parentScope = m_lexicalEnvironmentRegister
> 
> We have a byte code variable m_topMostScope that does what you're doing here, but I think this logic is wrong.
> Consider this program:
> constructor() {
>     if (c) {
>          let x = 20;
>          function captureX() { }
>          if (c) {
>             let x = 20;
>             function captureX() { return x; }
>             let arr = (blah) => blah;
>          }
>     }
> }
> 
> The "arr" won't be created with the parent scope that contains the "this".
> 
> I think you just want a resolveScope followed by a getFromScope.

Done

>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:2949
>> +        emitPutToScope(scopeRegister(), thisVar, thisRegister(), ThrowIfNotFound, NotInitialization);
> 
> I think special casing "this" as a new thing both in terms of a resolve type
> and in terms of a variable on JSScope is the wrong way to go about implementing this feature.
> 
> Here is one suggestion on how to solve this differently:
> Anytime a function has an arrow function nested inside of it,
> the parent function should create a lexical environment. Once this parent
> function also creates the "this" variable, it should place it inside
> the lexical environment it created. (This solves the problem in this code which keeps putting
> the "this" into the activation every time an arrow function is created
> even if "this" hasn't changed). Any time you make a call to super()
> and you have a nested arrow function, you update the "this" inside
> the lexical environment. Child functions that read from "this" can
> just do so the normal way: resolveScope() then getFromScope().
> 
> The parent function that has the "this" inside the lexical environment
> should just do what it normally does for lexical environments. The "this"
> identifier should have a slot inside the symbol table, etc. I think this
> would take away almost all this special case code for "this". Then, the "thisNode",
> when inside an arrow function, should be smart and load the "this" from
> the lexical environment using resolveScope() then getFromScope(). I believe
> this suggested solution will cause "this" inside an environment to just work
> for the most part.

Done. New patch is smaller than previous :-)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151005/70774995/attachment.html>


More information about the webkit-unassigned mailing list