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

Unified Diff: src/bootstrapper.cc

Issue 13192004: arrange to create prototypes for generators (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Explicitly add constructor properties in generator.js Created 7 years, 8 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
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index f57a1f6fd8fb69cbb3ac633382283fa7e6556486..1b116cdce0c36043733689af83bab62f02eb9284 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1321,6 +1321,46 @@ void Genesis::InitializeExperimentalGlobal() {
Builtins::kIllegal, true);
}
}
+
+ if (FLAG_harmony_generators) {
+ // Create generator meta-objects and install them on the builtins object.
+ Handle<JSObject> builtins(native_context()->builtins());
+ Handle<JSObject> generator_object_prototype =
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
+ Handle<JSFunction> generator_function_prototype =
+ InstallFunction(builtins, "GeneratorFunctionPrototype",
+ JS_FUNCTION_TYPE, JSFunction::kHeaderSize,
+ generator_object_prototype, Builtins::kIllegal,
+ false);
+ InstallFunction(builtins, "GeneratorFunction",
+ JS_FUNCTION_TYPE, JSFunction::kSize,
+ generator_function_prototype, Builtins::kIllegal,
+ false);
+
+ // Create maps for generator functions and their prototypes. Store those
+ // maps in the native context.
+ Handle<Map> function_map(native_context()->function_map());
+ Handle<Map> generator_function_map = factory()->CopyMap(function_map);
+ generator_function_map->set_prototype(*generator_function_prototype);
+ native_context()->set_generator_function_map(*generator_function_map);
+
+ Handle<Map> strict_mode_function_map(
+ native_context()->strict_mode_function_map());
+ Handle<Map> strict_mode_generator_function_map = factory()->CopyMap(
+ strict_mode_function_map);
+ strict_mode_generator_function_map->set_prototype(
+ *generator_function_prototype);
+ native_context()->set_strict_mode_generator_function_map(
+ *strict_mode_generator_function_map);
+
+ Handle<Map> object_map(native_context()->object_function()->initial_map());
+ Handle<Map> generator_object_prototype_map = factory()->CopyMap(
+ object_map, 0);
+ generator_object_prototype_map->set_prototype(
+ *generator_object_prototype);
+ native_context()->set_generator_object_prototype_map(
+ *generator_object_prototype_map);
+ }
}
@@ -1933,6 +1973,11 @@ bool Genesis::InstallExperimentalNatives() {
"native typedarray.js") == 0) {
if (!CompileExperimentalBuiltin(isolate(), i)) return false;
}
+ if (FLAG_harmony_generators &&
+ strcmp(ExperimentalNatives::GetScriptName(i).start(),
+ "native generator.js") == 0) {
+ if (!CompileExperimentalBuiltin(isolate(), i)) return false;
+ }
}
InstallExperimentalNativeFunctions();
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/code-stubs.h » ('j') | src/generator.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698