<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - [JSC] implement async functions proposal"
href="https://bugs.webkit.org/show_bug.cgi?id=156147#c78">Comment # 78</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - [JSC] implement async functions proposal"
href="https://bugs.webkit.org/show_bug.cgi?id=156147">bug 156147</a>
from <span class="vcard"><a class="email" href="mailto:caitp@igalia.com" title="Caitlin Potter (:caitp) <caitp@igalia.com>"> <span class="fn">Caitlin Potter (:caitp)</span></a>
</span></b>
<pre>Comment on <span class="bz_obsolete"><a href="attachment.cgi?id=277938&action=diff" name="attach_277938" title="Patch">attachment 277938</a> <a href="attachment.cgi?id=277938&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=277938&action=review">https://bugs.webkit.org/attachment.cgi?id=277938&action=review</a>
<span class="quote">>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:245
>> + bool containsArrowOrEvalButNotInArrowBlock = ((functionNode->usesArrowFunction() && functionNode->doAnyInnerArrowFunctionsUseAnyFeature()) || functionNode->usesEval()) && (!m_codeBlock->isArrowFunction() && !m_codeBlock->isAsyncArrowFunction());
>
> Can we change this to the new `isArrowFunction()` including ArrowFunction / AsyncArrowFunction?
> Or is there any obstacles?</span >
I was considering adding a `isAnyArrowFunction()`, just in case there were things that needed to distinguish between the two --- but I could try making `IsArrowFunction()` cover both cases, and add `IsSyncArrowFunction()` to cover just non-async cases if it's needed
<span class="quote">>>>> Source/JavaScriptCore/parser/Parser.cpp:1796
>>>> + result = parseAsyncFunctionDeclaration(context);
>>>
>>> These code is largely the same to the FUNCTION case. So extracting this to some function is recommended.
>>
>> Sorry, can you clarify what you mean here?
>>
>> I'm not sure if you're referring to this entire case statement, or the inside of `parseAsyncFunctionDeclaration` (which could share some code with parseFunctionDeclaration maybe), or what
>
> Ah, sorry. I mean this case statement. (This case clause and FUNCTION cases are function statement special cases, right?)</span >
So would you envision something like
```
case FUNCTION:
const bool isAsync = false;
result = parseFunctionDeclarationStatement(context, isAsync);
break;
case IDENT:
if ( /* ... is `async` conditional keyword */ ) {
next();
const bool isAsync = true;
result = parseFunctionDeclarationStatement(context, isAsync);
break;
}
/* fall through to expression-or-label-statement handling */
```
--- something like that, so that the duplicated parts are only generated once?
<span class="quote">>> Source/JavaScriptCore/parser/Parser.cpp:3602
>> + }
>
> Is this safe for `async get value() { }`?</span >
Added an edit which makes this safe (as far as I can tell)
<span class="quote">>> Source/JavaScriptCore/runtime/CodeCache.cpp:226
>> + break;
>
> Could you extract this to static function?</span >
Done</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>