Index: src/bootstrapper.cc |
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
index bd228352721af48b312261da81d55c6c07bcb758..e4c6bfe92b238af9bcf6d10bd8cd79ad4c55a20e 100644 |
--- a/src/bootstrapper.cc |
+++ b/src/bootstrapper.cc |
@@ -163,6 +163,7 @@ class Genesis BASE_EMBEDDED { |
void CreateStrictModeFunctionMaps(Handle<JSFunction> empty); |
void CreateIteratorMaps(Handle<JSFunction> empty); |
+ void CreateAsyncFunctionMaps(Handle<JSFunction> empty); |
void CreateJSProxyMaps(); |
// Make the "arguments" and "caller" properties throw a TypeError on access. |
@@ -805,6 +806,32 @@ void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) { |
*generator_object_prototype_map); |
} |
+void Genesis::CreateAsyncFunctionMaps(Handle<JSFunction> empty) { |
+ // %AsyncFunctionPrototype% intrinsic |
+ Handle<JSObject> async_function_prototype = |
+ factory()->NewJSObject(isolate()->object_function(), TENURED); |
+ SetObjectPrototype(async_function_prototype, empty); |
+ |
+ JSObject::AddProperty(async_function_prototype, |
+ factory()->to_string_tag_symbol(), |
+ factory()->NewStringFromAsciiChecked("AsyncFunction"), |
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
+ |
+ Handle<Map> strict_function_map( |
+ native_context()->strict_function_without_prototype_map()); |
+ Handle<Map> sloppy_async_function_map = |
+ Map::Copy(strict_function_map, "SloppyAsyncFunction"); |
+ sloppy_async_function_map->set_is_constructor(false); |
+ Map::SetPrototype(sloppy_async_function_map, async_function_prototype); |
+ native_context()->set_sloppy_async_function_map(*sloppy_async_function_map); |
+ |
+ Handle<Map> strict_async_function_map = |
+ Map::Copy(strict_function_map, "StrictAsyncFunction"); |
+ strict_async_function_map->set_is_constructor(false); |
+ Map::SetPrototype(strict_async_function_map, async_function_prototype); |
+ native_context()->set_strict_async_function_map(*strict_async_function_map); |
+} |
+ |
void Genesis::CreateJSProxyMaps() { |
// Allocate the different maps for all Proxy types. |
// Next to the default proxy, we need maps indicating callable and |
@@ -2409,6 +2436,45 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, |
script_is_embedder_debug_script, attribs); |
script_map->AppendDescriptor(&d); |
} |
+ |
+ { |
+ PrototypeIterator iter(native_context->sloppy_async_function_map()); |
+ Handle<JSObject> async_function_prototype(iter.GetCurrent<JSObject>()); |
+ |
+ static const bool kUseStrictFunctionMap = true; |
+ Handle<JSFunction> async_function_constructor = InstallFunction( |
+ container, "AsyncFunction", JS_FUNCTION_TYPE, JSFunction::kSize, |
+ async_function_prototype, Builtins::kAsyncFunctionConstructor, |
+ kUseStrictFunctionMap); |
+ async_function_constructor->set_prototype_or_initial_map( |
+ native_context->sloppy_async_function_map()); |
+ async_function_constructor->shared()->DontAdaptArguments(); |
+ async_function_constructor->shared()->set_construct_stub( |
+ *isolate->builtins()->GeneratorFunctionConstructor()); |
+ async_function_constructor->shared()->set_length(1); |
+ InstallWithIntrinsicDefaultProto(isolate, async_function_constructor, |
+ Context::ASYNC_FUNCTION_FUNCTION_INDEX); |
+ |
+ JSObject::AddProperty( |
+ async_function_prototype, factory->constructor_string(), |
+ async_function_constructor, |
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY)); |
+ |
+ JSObject::SetOwnPropertyIgnoreAttributes( |
Dan Ehrenberg
2016/05/06 16:19:25
JSFunction::SetPrototype?
caitp (gmail)
2016/05/06 18:45:26
Done.
|
+ async_function_constructor, factory->prototype_string(), |
+ async_function_prototype, |
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY | DONT_DELETE)) |
+ .Check(); |
+ |
+ Handle<JSFunction> async_function_next = |
+ SimpleInstallFunction(container, "AsyncFunctionNext", |
+ Builtins::kAsyncFunctionNext, 2, false); |
+ Handle<JSFunction> async_function_throw = |
+ SimpleInstallFunction(container, "AsyncFunctionThrow", |
+ Builtins::kAsyncFunctionThrow, 2, false); |
+ async_function_next->shared()->set_native(true); |
+ async_function_throw->shared()->set_native(true); |
+ } |
} |
} |
@@ -2501,8 +2567,6 @@ void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
SimpleInstallFunction(atomics_object, factory->InternalizeUtf8String("load"), |
Builtins::kAtomicsLoad, 2, true); |
- SimpleInstallFunction(atomics_object, factory->InternalizeUtf8String("store"), |
- Builtins::kAtomicsStore, 3, true); |
Dan Ehrenberg
2016/05/06 16:19:25
Looks like a bad rebase conflict resolution
caitp (gmail)
2016/05/06 18:45:26
I'm not sure, I haven't rebased over that new comm
|
} |
@@ -3019,7 +3083,8 @@ bool Genesis::InstallExperimentalNatives() { |
static const char* harmony_exponentiation_operator_natives[] = {nullptr}; |
static const char* harmony_string_padding_natives[] = { |
"native harmony-string-padding.js", nullptr}; |
- static const char* harmony_async_await_natives[] = {nullptr}; |
+ static const char* harmony_async_await_natives[] = { |
+ "native harmony-async-await.js", nullptr}; |
for (int i = ExperimentalNatives::GetDebuggerCount(); |
i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
@@ -3614,6 +3679,7 @@ Genesis::Genesis(Isolate* isolate, |
Handle<JSFunction> empty_function = CreateEmptyFunction(isolate); |
CreateStrictModeFunctionMaps(empty_function); |
CreateIteratorMaps(empty_function); |
+ CreateAsyncFunctionMaps(empty_function); |
Handle<JSGlobalObject> global_object = |
CreateNewGlobals(global_proxy_template, global_proxy); |
HookUpGlobalProxy(global_object, global_proxy); |