OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 #include "src/api-natives.h" | 6 #include "src/api-natives.h" |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule); | 300 InstallFunc(isolate, wasm_object, "verifyModule", VerifyModule); |
301 InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction); | 301 InstallFunc(isolate, wasm_object, "verifyFunction", VerifyFunction); |
302 InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule); | 302 InstallFunc(isolate, wasm_object, "instantiateModule", InstantiateModule); |
303 InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm", | 303 InstallFunc(isolate, wasm_object, "instantiateModuleFromAsm", |
304 InstantiateModuleFromAsm); | 304 InstantiateModuleFromAsm); |
305 } | 305 } |
306 | 306 |
307 | 307 |
308 void WasmJs::InstallWasmFunctionMap(Isolate* isolate, Handle<Context> context) { | 308 void WasmJs::InstallWasmFunctionMap(Isolate* isolate, Handle<Context> context) { |
309 if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) { | 309 if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) { |
310 Handle<Map> wasm_function_map = isolate->factory()->NewMap( | 310 // TODO(titzer): Move this to bootstrapper.cc?? |
311 JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize); | 311 // TODO(titzer): Also make one for strict mode functions? |
312 wasm_function_map->set_is_callable(); | 312 Handle<Map> prev_map = Handle<Map>(context->sloppy_function_map(), isolate); |
313 context->set_wasm_function_map(*wasm_function_map); | 313 |
| 314 InstanceType instance_type = prev_map->instance_type(); |
| 315 int internal_fields = JSObject::GetInternalFieldCount(*prev_map); |
| 316 CHECK_EQ(0, internal_fields); |
| 317 int pre_allocated = |
| 318 prev_map->GetInObjectProperties() - prev_map->unused_property_fields(); |
| 319 int instance_size; |
| 320 int in_object_properties; |
| 321 JSFunction::CalculateInstanceSizeHelper(instance_type, internal_fields + 1, |
| 322 0, &instance_size, |
| 323 &in_object_properties); |
| 324 |
| 325 int unused_property_fields = in_object_properties - pre_allocated; |
| 326 Handle<Map> map = Map::CopyInitialMap( |
| 327 prev_map, instance_size, in_object_properties, unused_property_fields); |
| 328 |
| 329 context->set_wasm_function_map(*map); |
314 } | 330 } |
315 } | 331 } |
316 | 332 |
317 } // namespace internal | 333 } // namespace internal |
318 } // namespace v8 | 334 } // namespace v8 |
OLD | NEW |