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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "src/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 | 9 |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 *compiled_module_->module_wrapper()) | 936 *compiled_module_->module_wrapper()) |
937 ->get(); | 937 ->get(); |
938 | 938 |
939 //-------------------------------------------------------------------------- | 939 //-------------------------------------------------------------------------- |
940 // Allocate the instance object. | 940 // Allocate the instance object. |
941 //-------------------------------------------------------------------------- | 941 //-------------------------------------------------------------------------- |
942 Handle<Map> map = factory->NewMap( | 942 Handle<Map> map = factory->NewMap( |
943 JS_OBJECT_TYPE, | 943 JS_OBJECT_TYPE, |
944 JSObject::kHeaderSize + kWasmInstanceInternalFieldCount * kPointerSize); | 944 JSObject::kHeaderSize + kWasmInstanceInternalFieldCount * kPointerSize); |
945 Handle<JSObject> instance = factory->NewJSObjectFromMap(map, TENURED); | 945 Handle<JSObject> instance = factory->NewJSObjectFromMap(map, TENURED); |
946 instance->SetInternalField(kWasmMemObject, *factory->undefined_value()); | 946 instance->SetInternalField(kWasmMemObject, |
| 947 isolate_->heap()->undefined_value()); |
947 | 948 |
948 //-------------------------------------------------------------------------- | 949 //-------------------------------------------------------------------------- |
949 // Set up the globals for the new instance. | 950 // Set up the globals for the new instance. |
950 //-------------------------------------------------------------------------- | 951 //-------------------------------------------------------------------------- |
951 MaybeHandle<JSArrayBuffer> old_globals; | 952 MaybeHandle<JSArrayBuffer> old_globals; |
952 MaybeHandle<JSArrayBuffer> globals; | 953 MaybeHandle<JSArrayBuffer> globals; |
953 uint32_t globals_size = module_->globals_size; | 954 uint32_t globals_size = module_->globals_size; |
954 if (globals_size > 0) { | 955 if (globals_size > 0) { |
955 Handle<JSArrayBuffer> global_buffer = | 956 Handle<JSArrayBuffer> global_buffer = |
956 NewArrayBuffer(isolate_, globals_size); | 957 NewArrayBuffer(isolate_, globals_size); |
957 globals = global_buffer; | 958 globals = global_buffer; |
958 if (globals.is_null()) { | 959 if (globals.is_null()) { |
959 thrower_->RangeError("Out of memory: wasm globals"); | 960 thrower_->RangeError("Out of memory: wasm globals"); |
960 return nothing; | 961 return nothing; |
961 } | 962 } |
962 Address old_address = owner.is_null() | 963 Address old_address = owner.is_null() |
963 ? nullptr | 964 ? nullptr |
964 : GetGlobalStartAddressFromCodeTemplate( | 965 : GetGlobalStartAddressFromCodeTemplate( |
965 *factory->undefined_value(), | 966 isolate_->heap()->undefined_value(), |
966 JSObject::cast(*owner.ToHandleChecked())); | 967 JSObject::cast(*owner.ToHandleChecked())); |
967 RelocateGlobals(code_table, old_address, | 968 RelocateGlobals(code_table, old_address, |
968 static_cast<Address>(global_buffer->backing_store())); | 969 static_cast<Address>(global_buffer->backing_store())); |
969 instance->SetInternalField(kWasmGlobalsArrayBuffer, *global_buffer); | 970 instance->SetInternalField(kWasmGlobalsArrayBuffer, *global_buffer); |
970 } | 971 } |
971 | 972 |
972 //-------------------------------------------------------------------------- | 973 //-------------------------------------------------------------------------- |
973 // Process the imports for the module. | 974 // Process the imports for the module. |
974 //-------------------------------------------------------------------------- | 975 //-------------------------------------------------------------------------- |
975 int num_imported_functions = ProcessImports(globals, code_table, instance); | 976 int num_imported_functions = ProcessImports(globals, code_table, instance); |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 CHECK_NOT_NULL(result.val); | 2090 CHECK_NOT_NULL(result.val); |
2090 module = const_cast<WasmModule*>(result.val); | 2091 module = const_cast<WasmModule*>(result.val); |
2091 } | 2092 } |
2092 | 2093 |
2093 Handle<WasmModuleWrapper> module_wrapper = | 2094 Handle<WasmModuleWrapper> module_wrapper = |
2094 WasmModuleWrapper::New(isolate, module); | 2095 WasmModuleWrapper::New(isolate, module); |
2095 | 2096 |
2096 compiled_module->set_module_wrapper(module_wrapper); | 2097 compiled_module->set_module_wrapper(module_wrapper); |
2097 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); | 2098 DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module)); |
2098 } | 2099 } |
OLD | NEW |