<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Arrow function syntax. Emit loading&amp;putting this/super only if they are used in arrow function"
   href="https://bugs.webkit.org/show_bug.cgi?id=153981#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ES6] Arrow function syntax. Emit loading&amp;putting this/super only if they are used in arrow function"
   href="https://bugs.webkit.org/show_bug.cgi?id=153981">bug 153981</a>
              from <span class="vcard"><a class="email" href="mailto:sbarati&#64;apple.com" title="Saam Barati &lt;sbarati&#64;apple.com&gt;"> <span class="fn">Saam Barati</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=271327&amp;action=diff" name="attach_271327" title="Patch">attachment 271327</a> <a href="attachment.cgi?id=271327&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=271327&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=271327&amp;action=review</a>

LGTM, just a few design suggestions and renaming suggestions.
Have you run perf numbers?

<span class="quote">&gt; Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h:132
&gt; +    bool isInnerArrowFunctionUseArguments() { return m_arrowFunctionCodeFeatures &amp; ArgumentsArrowFunctionFeature; }
&gt; +    bool isInnerArrowFunctionUseSuperCall() { return m_arrowFunctionCodeFeatures &amp; SuperCallArrowFunctionFeature; }
&gt; +    bool isInnerArrowFunctionUseSuperProperty() { return m_arrowFunctionCodeFeatures &amp; SuperPropertyArrowFunctionFeature; }
&gt; +    bool isInnerArrowFunctionUseEval() { return m_arrowFunctionCodeFeatures &amp; EvalArrowFunctionFeature; }
&gt; +    bool isInnerArrowFunctionUseThis() { return m_arrowFunctionCodeFeatures &amp; ThisArrowFunctionFeature; }
&gt; +    bool isInnerArrowFunctionUseNewTarget() { return m_arrowFunctionCodeFeatures &amp; NewTargetArrowFunctionFeature; }</span >

I would name these like &quot;doAnyInnerArrowFunctionsX&quot;
i.e:
isInnerArrowFunctionUseArguments =&gt; doAnyInnerArrowFunctionsUseArguments

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:4051
&gt; +bool BytecodeGenerator::isNewTargetUsedInArrowFunction()
&gt; +{
&gt; +    return m_codeBlock-&gt;isInnerArrowFunctionUseNewTarget() || m_codeBlock-&gt;isInnerArrowFunctionUseSuperCall();
&gt; +}</span >

Is &quot;new.target&quot; not allowed in eval?

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:648
&gt; +        void emitPutThisToArrowFunctionContextScope(bool = false);</span >

Style: give this bool a name, like &quot;shouldAlwaysPut&quot; or something.

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h:724
&gt; +        bool isThisUsedInArrowFunction();
&gt; +        bool isNewTargetUsedInArrowFunction();
&gt; +        bool isSuperUsedInArrowFunction();
&gt; +        bool isArgumentsUsedInArrowFunction();</span >

nit:  I would name these with &quot;Inner&quot; before &quot;In&quot;
like:
&quot;isThisUsedInInnerArrowFunction&quot;

<span class="quote">&gt; Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp:764
&gt; +            generator.emitPutThisToArrowFunctionContextScope(true);</span >

Style: We usually write code like this by assigning the boolean as a local variable and passing the local variable to the function:
```
bool forcePutToScope = true;
generator.emitPutThisToArrowFunctionContextScope(forcePutToScope);
```

<span class="quote">&gt; Source/JavaScriptCore/parser/Parser.cpp:2067
&gt; +            if (functionBodyType != StandardFunctionBodyBlock)
&gt; +                closestParentNonArrowFunctionNonLexicalScope()-&gt;setInnerArrowFunctionUseSuperCall();</span >

An alternative to repeatedly doing a scope search here is to just propagate this information
when we pop the scope. That's usually how we propagate information upwards. Look at popScopeInternal.
Also, instead of &quot;functionBodyType != StandardFunctionBodyBlock&quot;, I think the code is easier to read
with affirmative conditions, like &quot;bodyType == ArrowExpr || bodyType == ArrowBlock&quot;

<span class="quote">&gt; Source/JavaScriptCore/parser/Parser.cpp:3644
&gt; +            if (m_vm-&gt;propertyNames-&gt;eval == *ident)
&gt; +                closestParentNonArrowFunctionNonLexicalScope()-&gt;setInnerArrowFunctionUseEval();
&gt; +            else if (m_vm-&gt;propertyNames-&gt;arguments == *ident)
&gt; +                closestParentNonArrowFunctionNonLexicalScope()-&gt;setInnerArrowFunctionUseArgumetns();</span >

If you go with the popScopeInternalApproach, this can be determined then as well when we're already iterating over all used variables.

<span class="quote">&gt; Source/JavaScriptCore/parser/ParserModes.h:164
&gt; +typedef uint16_t ArrowFunctionCodeFeatures;</span >

this can be uint8_t

<span class="quote">&gt; Source/JavaScriptCore/parser/SourceProviderCacheItem.h:47
&gt; +    unsigned innerArrowFunctionFeatures;</span >

Why not ArrowFunctionCodeFeatures instead of unsigned?

<span class="quote">&gt; Source/JavaScriptCore/parser/SourceProviderCacheItem.h:92
&gt; +    unsigned innerArrowFunctionFeatures : 31;</span >

ditto.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>