<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#c66">Comment # 66</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:utatane.tea@gmail.com" title="Yusuke Suzuki <utatane.tea@gmail.com>"> <span class="fn">Yusuke Suzuki</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=277702&action=diff" name="attach_277702" title="Patch">attachment 277702</a> <a href="attachment.cgi?id=277702&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=277702&action=review">https://bugs.webkit.org/attachment.cgi?id=277702&action=review</a>
Second round. I'll look into the parser changes next :)
<span class="quote">> Source/JavaScriptCore/builtins/AsyncFunctionPrototype.js:30
> + let value = @undefined;</span >
Let's insert
if (typeof state !== 'number')
throw new @TypeError("|this| should be an async function");
test here.
<span class="quote">>>> Source/JavaScriptCore/parser/Keywords.table:11
>>> +await AWAIT
>>
>> Are async and await keywords? I think they are contextual keywords, correct?
>
> A number of versions ago, they were treated as contextual keywords (and tokenized as IDENTs) --- but they are checked in so many contexts, that it seems worthwhile to internalize them and tokenize them separately from identifiers --- It may be a close call, but I think when the flag is enabled, it makes more sense to do this.
>
> Contexts where `async` is potentially a keyword include any PrimaryExpression, any AssignmentExpression, and any StatementListItem (including in module code) --- nearly anywhere a BindingIdentifier is expected.
>
> For `await`, it might make a bit more sense to use `matchContextualKeyword`, though, you're right.
>
> Thanks for taking a look at this, I appreciate it Yusuke :)</span >
I have some concerns about adding "async" and "await" into this keyword category.
Currently, Keywords.table only holds keywords. Adding (strictly speaking)non-keyword words into this table seems confusing to readers.
For example, "eval", "arguments" are handled like keywords under the strict mode, but it is not included in this table.
"async" is so widely accepted word. So "async" is frequently used as a variable, a method name, a parameter etc.
If we don't include "async" in IDENT, once we use "IDENT" in the current parser, we easily miss "async" word, and it will break many pages.
Seeing <a href="http://tc39.github.io/ecmascript-asyncawait/#identifier-static-semantics-early-errors">http://tc39.github.io/ecmascript-asyncawait/#identifier-static-semantics-early-errors</a>, "await" can be introduced into the keywords.
But this handling does not include "async". I think it is better that "async" is handled in IDENT at least.
<span class="quote">> Source/JavaScriptCore/parser/Parser.cpp:2130
> + AllowAwaitOverride allowAwait(this, !isAsyncFunctionParseMode(mode));</span >
Nice. We can use SetForScope here :)
<span class="quote">> Source/JavaScriptCore/runtime/CodeCache.cpp:156
> source, name.string(), SourceCodeKey::FunctionType, </span >
We need to add RuntimeFlats into SourceCodeKey.
<span class="quote">> Source/JavaScriptCore/runtime/CodeCache.cpp:200
> + if (isAsyncFunctionParseMode(metadata->parseMode()))</span >
Let's add generator and arrow function cases here.
<span class="quote">> Source/JavaScriptCore/runtime/JSGlobalObject.cpp:490
> + putDirectWithoutTransition(vm, vm.propertyNames->AsyncFunction, asyncFunctionConstructor, DontEnum);</span >
AsyncFunction constructor is not exposed as a global variable. (It is the same to the GeneratorFunction constructor).
For example,
Object constructor,
<a href="https://tc39.github.io/ecma262/#sec-object-constructor">https://tc39.github.io/ecma262/#sec-object-constructor</a>
"... and the initial value of the Object property of the global object."
Array constructor
<a href="https://tc39.github.io/ecma262/#sec-array-constructor">https://tc39.github.io/ecma262/#sec-array-constructor</a>
"... and the initial value of the Array property of the global object."
But, GeneratorFunction constructor and AsyncFunction constructor do not have such statements.
<span class="quote">> Source/JavaScriptCore/tests/es6/async_arrow_functions_lexical_this_binding.js:27
> +shouldBeAsync("barley", () => e.y("ley"));</span >
Let's move these tests to tests/stress directory. es6 is used for kangax's compat-table tests.</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>