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" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 if (thrower->error()) return Handle<JSObject>::null(); | 61 if (thrower->error()) return Handle<JSObject>::null(); |
62 | 62 |
63 // Although we decoded the module for some pre-validation, run the bytes | 63 // Although we decoded the module for some pre-validation, run the bytes |
64 // again through the normal pipeline. | 64 // again through the normal pipeline. |
65 MaybeHandle<JSObject> module_object = CreateModuleObjectFromBytes( | 65 MaybeHandle<JSObject> module_object = CreateModuleObjectFromBytes( |
66 isolate, module->module_start, module->module_end, thrower, | 66 isolate, module->module_start, module->module_end, thrower, |
67 ModuleOrigin::kWasmOrigin); | 67 ModuleOrigin::kWasmOrigin); |
68 if (module_object.is_null()) return Handle<JSObject>::null(); | 68 if (module_object.is_null()) return Handle<JSObject>::null(); |
69 return WasmModule::Instantiate(isolate, module_object.ToHandleChecked(), | 69 MaybeHandle<JSObject> maybe_instance = WasmModule::Instantiate( |
70 Handle<JSReceiver>::null(), | 70 isolate, module_object.ToHandleChecked(), Handle<JSReceiver>::null(), |
71 Handle<JSArrayBuffer>::null()) | 71 Handle<JSArrayBuffer>::null()); |
72 .ToHandleChecked(); | 72 Handle<JSObject> instance; |
| 73 if (!maybe_instance.ToHandle(&instance)) { |
| 74 return Handle<JSObject>::null(); |
| 75 } |
| 76 return instance; |
73 } | 77 } |
74 | 78 |
75 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 79 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
76 const byte* module_end, ModuleOrigin origin) { | 80 const byte* module_end, ModuleOrigin origin) { |
77 HandleScope scope(isolate); | 81 HandleScope scope(isolate); |
78 Zone zone(isolate->allocator()); | 82 Zone zone(isolate->allocator()); |
79 | 83 |
80 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); | 84 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); |
81 std::unique_ptr<const WasmModule> module(DecodeWasmModuleForTesting( | 85 std::unique_ptr<const WasmModule> module(DecodeWasmModuleForTesting( |
82 isolate, &zone, &thrower, module_start, module_end, origin)); | 86 isolate, &zone, &thrower, module_start, module_end, origin)); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 void SetupIsolateForWasmModule(Isolate* isolate) { | 207 void SetupIsolateForWasmModule(Isolate* isolate) { |
204 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); | 208 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); |
205 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), | 209 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), |
206 isolate->native_context()); | 210 isolate->native_context()); |
207 } | 211 } |
208 | 212 |
209 } // namespace testing | 213 } // namespace testing |
210 } // namespace wasm | 214 } // namespace wasm |
211 } // namespace internal | 215 } // namespace internal |
212 } // namespace v8 | 216 } // namespace v8 |
OLD | NEW |