Reviewers: jochen,
Description:
Fix Map/Set creation via the API with nosnap build
The Map and Set maps get overwritten when collection.js executes, so in
a nosnap build we have to wait until it runs before we grab the maps.
To facilitate that, store the functions in the native context as well.
Please review this at https://codereview.chromium.org/1161363002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+12, -2 lines):
M src/bootstrapper.cc
M src/contexts.h
M test/cctest/test-api.cc
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index
3a26e40b4ba666e13345225bbe914379c267110f..b50519fbd687f87c4b92443f43595a8750f22b39
100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1225,14 +1225,14 @@ void Genesis::InitializeGlobal(Handle<GlobalObject>
global_object,
Handle<JSFunction> js_map_fun = InstallFunction(
global, "Map", JS_MAP_TYPE, JSMap::kSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
- native_context()->set_js_map_map(js_map_fun->initial_map());
+ native_context()->set_js_map_fun(*js_map_fun);
}
{ // -- S e t
Handle<JSFunction> js_set_fun = InstallFunction(
global, "Set", JS_SET_TYPE, JSSet::kSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
- native_context()->set_js_set_map(js_set_fun->initial_map());
+ native_context()->set_js_set_fun(*js_set_fun);
}
{ // Set up the iterator result object
@@ -2801,6 +2801,10 @@ bool Genesis::ConfigureGlobalObjects(
JSArray::cast(native_context()->array_function()->prototype()));
native_context()->set_array_buffer_map(
native_context()->array_buffer_fun()->initial_map());
+ native_context()->set_js_map_map(
+ native_context()->js_map_fun()->initial_map());
+ native_context()->set_js_set_map(
+ native_context()->js_set_fun()->initial_map());
return true;
}
Index: src/contexts.h
diff --git a/src/contexts.h b/src/contexts.h
index
51869e8dc61cb3b1bf4c3936e01f4210e27737ce..670f5a7c0ef693329eb1116a4df742965b39b145
100644
--- a/src/contexts.h
+++ b/src/contexts.h
@@ -187,7 +187,9 @@ enum BindingFlags {
V(STRONG_GENERATOR_FUNCTION_MAP_INDEX, Map,
strong_generator_function_map) \
V(GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX, Map,
generator_object_prototype_map) \
V(ITERATOR_RESULT_MAP_INDEX, Map,
iterator_result_map) \
+ V(JS_MAP_FUN_INDEX, JSFunction,
js_map_fun) \
V(JS_MAP_MAP_INDEX, Map,
js_map_map) \
+ V(JS_SET_FUN_INDEX, JSFunction,
js_set_fun) \
V(JS_SET_MAP_INDEX, Map,
js_set_map) \
V(MAP_FROM_ARRAY_INDEX, JSFunction,
map_from_array) \
V(SET_FROM_ARRAY_INDEX, JSFunction,
set_from_array) \
@@ -431,7 +433,9 @@ class Context: public FixedArray {
STRONG_GENERATOR_FUNCTION_MAP_INDEX,
GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX,
ITERATOR_RESULT_MAP_INDEX,
+ JS_MAP_FUN_INDEX,
JS_MAP_MAP_INDEX,
+ JS_SET_FUN_INDEX,
JS_SET_MAP_INDEX,
MAP_FROM_ARRAY_INDEX,
SET_FROM_ARRAY_INDEX,
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
ff7797baaf141955b192f2124ab917e4e12e28b8..93ed66b2180fa6ab8410a2de300ee36aca9e27cb
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21376,6 +21376,7 @@ TEST(Map) {
v8::Local<v8::Map> map = v8::Map::New(isolate);
CHECK(map->IsObject());
CHECK(map->IsMap());
+ CHECK(map->GetPrototype()->StrictEquals(CompileRun("Map.prototype")));
CHECK_EQ(0, map->Size());
v8::Local<v8::Value> val = CompileRun("new Map([[1, 2], [3, 4]])");
@@ -21407,6 +21408,7 @@ TEST(Set) {
v8::Local<v8::Set> set = v8::Set::New(isolate);
CHECK(set->IsObject());
CHECK(set->IsSet());
+ CHECK(set->GetPrototype()->StrictEquals(CompileRun("Set.prototype")));
CHECK_EQ(0, set->Size());
v8::Local<v8::Value> val = CompileRun("new Set([1, 2])");
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.