| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "test/common/wasm/wasm-module-runner.h" | 5 #include "test/common/wasm/wasm-module-runner.h" |
| 6 | 6 |
| 7 #include "src/handles.h" | 7 #include "src/handles.h" |
| 8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 #include "src/property-descriptor.h" | 10 #include "src/property-descriptor.h" |
| 11 #include "src/wasm/module-decoder.h" | 11 #include "src/wasm/module-decoder.h" |
| 12 #include "src/wasm/wasm-interpreter.h" | 12 #include "src/wasm/wasm-interpreter.h" |
| 13 #include "src/wasm/wasm-js.h" | 13 #include "src/wasm/wasm-js.h" |
| 14 #include "src/wasm/wasm-module.h" | 14 #include "src/wasm/wasm-module.h" |
| 15 #include "src/wasm/wasm-objects.h" |
| 15 #include "src/wasm/wasm-result.h" | 16 #include "src/wasm/wasm-result.h" |
| 16 | 17 |
| 17 namespace v8 { | 18 namespace v8 { |
| 18 namespace internal { | 19 namespace internal { |
| 19 namespace wasm { | 20 namespace wasm { |
| 20 namespace testing { | 21 namespace testing { |
| 21 | 22 |
| 22 uint32_t GetMinModuleMemSize(const WasmModule* module) { | 23 uint32_t GetMinModuleMemSize(const WasmModule* module) { |
| 23 return WasmModule::kPageSize * module->min_mem_pages; | 24 return WasmModule::kPageSize * module->min_mem_pages; |
| 24 } | 25 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 53 | 54 |
| 54 if (module->import_table.size() > 0) { | 55 if (module->import_table.size() > 0) { |
| 55 thrower->CompileError("Not supported: module has imports."); | 56 thrower->CompileError("Not supported: module has imports."); |
| 56 } | 57 } |
| 57 | 58 |
| 58 if (thrower->error()) return Handle<JSObject>::null(); | 59 if (thrower->error()) return Handle<JSObject>::null(); |
| 59 | 60 |
| 60 // Although we decoded the module for some pre-validation, run the bytes | 61 // Although we decoded the module for some pre-validation, run the bytes |
| 61 // again through the normal pipeline. | 62 // again through the normal pipeline. |
| 62 // TODO(wasm): Use {module} instead of decoding the module bytes again. | 63 // TODO(wasm): Use {module} instead of decoding the module bytes again. |
| 63 MaybeHandle<JSObject> module_object = CreateModuleObjectFromBytes( | 64 MaybeHandle<WasmModuleObject> module_object = CreateModuleObjectFromBytes( |
| 64 isolate, module->module_start, module->module_end, thrower, | 65 isolate, module->module_start, module->module_end, thrower, |
| 65 ModuleOrigin::kWasmOrigin, Handle<Script>::null(), nullptr, nullptr); | 66 ModuleOrigin::kWasmOrigin, Handle<Script>::null(), nullptr, nullptr); |
| 66 if (module_object.is_null()) { | 67 if (module_object.is_null()) { |
| 67 thrower->CompileError("Module pre-validation failed."); | 68 thrower->CompileError("Module pre-validation failed."); |
| 68 return Handle<JSObject>::null(); | 69 return Handle<JSObject>::null(); |
| 69 } | 70 } |
| 70 MaybeHandle<JSObject> maybe_instance = WasmModule::Instantiate( | 71 MaybeHandle<JSObject> maybe_instance = WasmModule::Instantiate( |
| 71 isolate, thrower, module_object.ToHandleChecked(), | 72 isolate, thrower, module_object.ToHandleChecked(), |
| 72 Handle<JSReceiver>::null(), Handle<JSArrayBuffer>::null()); | 73 Handle<JSReceiver>::null(), Handle<JSArrayBuffer>::null()); |
| 73 Handle<JSObject> instance; | 74 Handle<JSObject> instance; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 222 |
| 222 void SetupIsolateForWasmModule(Isolate* isolate) { | 223 void SetupIsolateForWasmModule(Isolate* isolate) { |
| 223 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); | 224 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); |
| 224 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), | 225 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), |
| 225 isolate->native_context()); | 226 isolate->native_context()); |
| 226 } | 227 } |
| 227 } // namespace testing | 228 } // namespace testing |
| 228 } // namespace wasm | 229 } // namespace wasm |
| 229 } // namespace internal | 230 } // namespace internal |
| 230 } // namespace v8 | 231 } // namespace v8 |
| OLD | NEW |