| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ModuleOrigin origin) { | 95 ModuleOrigin origin) { |
| 96 ErrorThrower thrower(isolate, "RunWasmModule"); | 96 ErrorThrower thrower(isolate, "RunWasmModule"); |
| 97 const char* f_name = origin == ModuleOrigin::kAsmJsOrigin ? "caller" : "main"; | 97 const char* f_name = origin == ModuleOrigin::kAsmJsOrigin ? "caller" : "main"; |
| 98 return CallWasmFunctionForTesting(isolate, instance, &thrower, f_name, argc, | 98 return CallWasmFunctionForTesting(isolate, instance, &thrower, f_name, argc, |
| 99 argv, origin); | 99 argv, origin); |
| 100 } | 100 } |
| 101 | 101 |
| 102 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 102 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
| 103 const byte* module_end, ModuleOrigin origin) { | 103 const byte* module_end, ModuleOrigin origin) { |
| 104 HandleScope scope(isolate); | 104 HandleScope scope(isolate); |
| 105 Zone zone(isolate->allocator()); | 105 Zone zone(isolate->allocator(), ZONE_NAME); |
| 106 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); | 106 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); |
| 107 Handle<JSObject> instance = CompileInstantiateWasmModuleForTesting( | 107 Handle<JSObject> instance = CompileInstantiateWasmModuleForTesting( |
| 108 isolate, &thrower, &zone, module_start, module_end, origin); | 108 isolate, &thrower, &zone, module_start, module_end, origin); |
| 109 if (instance.is_null()) { | 109 if (instance.is_null()) { |
| 110 return -1; | 110 return -1; |
| 111 } | 111 } |
| 112 return RunWasmModuleForTesting(isolate, instance, 0, nullptr, origin); | 112 return RunWasmModuleForTesting(isolate, instance, 0, nullptr, origin); |
| 113 } | 113 } |
| 114 | 114 |
| 115 int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower, | 115 int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower, |
| 116 const WasmModule* module, int function_index, | 116 const WasmModule* module, int function_index, |
| 117 WasmVal* args) { | 117 WasmVal* args) { |
| 118 CHECK(module != nullptr); | 118 CHECK(module != nullptr); |
| 119 | 119 |
| 120 Zone zone(isolate->allocator()); | 120 Zone zone(isolate->allocator(), ZONE_NAME); |
| 121 v8::internal::HandleScope scope(isolate); | 121 v8::internal::HandleScope scope(isolate); |
| 122 | 122 |
| 123 if (module->import_table.size() > 0) { | 123 if (module->import_table.size() > 0) { |
| 124 thrower->CompileError("Not supported: module has imports."); | 124 thrower->CompileError("Not supported: module has imports."); |
| 125 } | 125 } |
| 126 if (module->export_table.size() == 0) { | 126 if (module->export_table.size() == 0) { |
| 127 thrower->CompileError("Not supported: module has no exports."); | 127 thrower->CompileError("Not supported: module has no exports."); |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (thrower->error()) return -1; | 130 if (thrower->error()) return -1; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 void SetupIsolateForWasmModule(Isolate* isolate) { | 222 void SetupIsolateForWasmModule(Isolate* isolate) { |
| 223 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); | 223 WasmJs::InstallWasmMapsIfNeeded(isolate, isolate->native_context()); |
| 224 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), | 224 WasmJs::InstallWasmModuleSymbolIfNeeded(isolate, isolate->global_object(), |
| 225 isolate->native_context()); | 225 isolate->native_context()); |
| 226 } | 226 } |
| 227 } // namespace testing | 227 } // namespace testing |
| 228 } // namespace wasm | 228 } // namespace wasm |
| 229 } // namespace internal | 229 } // namespace internal |
| 230 } // namespace v8 | 230 } // namespace v8 |
| OLD | NEW |