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

Unified Diff: src/wasm/wasm-js.cc

Issue 1778863002: [wasm] Create a proper map for functions created from WASM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « src/objects.cc ('k') | test/mjsunit/wasm/function-prototype.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index e4eddc44be6cf08c6e335785b1c2e91d1950c928..d690329bcd4ec12c568713afc96402656e19b911 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -307,10 +307,26 @@ void WasmJs::Install(Isolate* isolate, Handle<JSGlobalObject> global) {
void WasmJs::InstallWasmFunctionMap(Isolate* isolate, Handle<Context> context) {
if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) {
- Handle<Map> wasm_function_map = isolate->factory()->NewMap(
- JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize);
- wasm_function_map->set_is_callable();
- context->set_wasm_function_map(*wasm_function_map);
+ // TODO(titzer): Move this to bootstrapper.cc??
+ // TODO(titzer): Also make one for strict mode functions?
+ Handle<Map> prev_map = Handle<Map>(context->sloppy_function_map(), isolate);
+
+ InstanceType instance_type = prev_map->instance_type();
+ int internal_fields = JSObject::GetInternalFieldCount(*prev_map);
+ CHECK_EQ(0, internal_fields);
+ int pre_allocated =
+ prev_map->GetInObjectProperties() - prev_map->unused_property_fields();
+ int instance_size;
+ int in_object_properties;
+ JSFunction::CalculateInstanceSizeHelper(instance_type, internal_fields + 1,
+ 0, &instance_size,
+ &in_object_properties);
+
+ int unused_property_fields = in_object_properties - pre_allocated;
+ Handle<Map> map = Map::CopyInitialMap(
+ prev_map, instance_size, in_object_properties, unused_property_fields);
+
+ context->set_wasm_function_map(*map);
}
}
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/wasm/function-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698