[Webkit-unassigned] [Bug 156147] [JSC] implement async functions proposal

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun May 1 09:04:00 PDT 2016


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

--- Comment #66 from Yusuke Suzuki <utatane.tea at gmail.com> ---
Comment on attachment 277702
  --> https://bugs.webkit.org/attachment.cgi?id=277702
Patch

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

Second round. I'll look into the parser changes next :)

> Source/JavaScriptCore/builtins/AsyncFunctionPrototype.js:30
> +    let value = @undefined;

Let's insert

if (typeof state !== 'number')
    throw new @TypeError("|this| should be an async function");

test here.

>>> 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 :)

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 http://tc39.github.io/ecmascript-asyncawait/#identifier-static-semantics-early-errors, "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.

> Source/JavaScriptCore/parser/Parser.cpp:2130
> +            AllowAwaitOverride allowAwait(this, !isAsyncFunctionParseMode(mode));

Nice. We can use SetForScope here :)

> Source/JavaScriptCore/runtime/CodeCache.cpp:156
>          source, name.string(), SourceCodeKey::FunctionType, 

We need to add RuntimeFlats into SourceCodeKey.

> Source/JavaScriptCore/runtime/CodeCache.cpp:200
> +    if (isAsyncFunctionParseMode(metadata->parseMode()))

Let's add generator and arrow function cases here.

> Source/JavaScriptCore/runtime/JSGlobalObject.cpp:490
> +        putDirectWithoutTransition(vm, vm.propertyNames->AsyncFunction, asyncFunctionConstructor, DontEnum);

AsyncFunction constructor is not exposed as a global variable. (It is the same to the GeneratorFunction constructor).
For example,

Object constructor,
https://tc39.github.io/ecma262/#sec-object-constructor
"... and the initial value of the Object property of the global object."

Array constructor
https://tc39.github.io/ecma262/#sec-array-constructor
"... and the initial value of the Array property of the global object."

But, GeneratorFunction constructor and AsyncFunction constructor do not have such statements.

> Source/JavaScriptCore/tests/es6/async_arrow_functions_lexical_this_binding.js:27
> +shouldBeAsync("barley", () => e.y("ley"));

Let's move these tests to tests/stress directory. es6 is used for kangax's compat-table tests.

-- 
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/20160501/2e1f1e9b/attachment-0001.html>


More information about the webkit-unassigned mailing list