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

Unified Diff: src/bootstrapper.cc

Issue 913073003: [es6] implement Reflect.apply() & Reflect.construct() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 10 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/runtime.js » ('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 eb2269c15ecf6292d86e553157b532a33d5894ab..624a6c2b2d83a623687d54f55ab613956e570289 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1664,6 +1664,7 @@ EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
+EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
void Genesis::InstallNativeFunctions_harmony_proxies() {
@@ -1696,6 +1697,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_reflect)
void Genesis::InitializeGlobal_harmony_regexps() {
Handle<JSObject> builtins(native_context()->builtins());
@@ -2086,6 +2088,36 @@ bool Genesis::InstallNatives() {
*generator_object_prototype_map);
}
+ // Install references to functions of the Reflect object
+ {
+ Handle<JSFunction> apply =
+ InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE,
+ JSObject::kHeaderSize, MaybeHandle<JSObject>(),
+ Builtins::kReflectApply);
+ Handle<JSFunction> construct =
+ InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE,
+ JSObject::kHeaderSize, MaybeHandle<JSObject>(),
+ Builtins::kReflectConstruct);
+ if (FLAG_vector_ics) {
+ // Apply embeds an IC, so we need a type vector of size 1 in the shared
+ // function info.
+ FeedbackVectorSpec spec(0, 1);
+ spec.SetKind(0, Code::CALL_IC);
+ Handle<TypeFeedbackVector> feedback_vector =
+ factory()->NewTypeFeedbackVector(spec);
+ apply->shared()->set_feedback_vector(*feedback_vector);
+
+ feedback_vector = factory()->NewTypeFeedbackVector(spec);
+ construct->shared()->set_feedback_vector(*feedback_vector);
+ }
+
+ apply->shared()->set_internal_formal_parameter_count(3);
+ apply->shared()->set_length(3);
+
+ construct->shared()->set_internal_formal_parameter_count(3);
+ construct->shared()->set_length(2);
+ }
+
if (FLAG_disable_native_files) {
PrintF("Warning: Running without installed natives!\n");
return true;
@@ -2286,6 +2318,8 @@ bool Genesis::InstallExperimentalNatives() {
static const char* harmony_unicode_regexps_natives[] = {NULL};
static const char* harmony_computed_property_names_natives[] = {NULL};
static const char* harmony_rest_parameters_natives[] = {NULL};
+ static const char* harmony_reflect_natives[] = {"native harmony-reflect.js",
+ NULL};
for (int i = ExperimentalNatives::GetDebuggerCount();
i < ExperimentalNatives::GetBuiltinsCount(); i++) {
@@ -2891,6 +2925,19 @@ Genesis::Genesis(Isolate* isolate,
isolate->counters()->contexts_created_from_scratch()->Increment();
}
+ if (FLAG_harmony_reflect) {
+ // TODO(caitp): this should not be here, there's got to be a better way.
+ // Shouldn't InitializeExperimentalGlobal() happen before
arv (Not doing code reviews) 2015/03/04 09:45:01 Dmitry fixed this I believe.
caitp (gmail) 2015/03/04 13:24:14 Fix hasn't landed yet, but yes it will be changed
+ // InitializeExperimentalNatives()?
+ Handle<JSGlobalObject> global(JSGlobalObject::cast(
+ native_context()->global_object()));
+ Handle<String> reflect_string =
+ factory()->NewStringFromStaticChars("Reflect");
+ Handle<Object> reflect =
+ factory()->NewJSObject(isolate->object_function(), TENURED);
+ JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM);
+ }
+
// Install experimental natives.
if (!InstallExperimentalNatives()) return;
InitializeExperimentalGlobal();
« no previous file with comments | « BUILD.gn ('k') | src/builtins.h » ('j') | src/runtime.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698