Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: src/bootstrapper.cc

Issue 1895603002: [esnext] prototype runtime implementation for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@AsyncFunction
Patch Set: remove weird arrow-generator thing Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | src/builtins.h » ('j') | src/compiler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index bd228352721af48b312261da81d55c6c07bcb758..51b5bc836f51a97e2ab55535d91a099fdc46e338 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,42 @@ 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));
+
+ JSFunction::SetPrototype(async_function_constructor,
+ async_function_prototype);
+
+ 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);
+ }
}
}
@@ -3019,7 +3082,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 +3678,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);
« no previous file with comments | « BUILD.gn ('k') | src/builtins.h » ('j') | src/compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698