| 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 #ifndef V8_WASM_MODULE_RUNNER_H_ | 5 #ifndef V8_WASM_MODULE_RUNNER_H_ |
| 6 #define V8_WASM_MODULE_RUNNER_H_ | 6 #define V8_WASM_MODULE_RUNNER_H_ |
| 7 | 7 |
| 8 #include "src/handles.h" | 8 #include "src/handles.h" |
| 9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| 11 #include "src/wasm/wasm-interpreter.h" | 11 #include "src/wasm/wasm-interpreter.h" |
| 12 #include "src/wasm/wasm-module.h" | 12 #include "src/wasm/wasm-module.h" |
| 13 #include "src/wasm/wasm-objects.h" |
| 13 #include "src/wasm/wasm-result.h" | 14 #include "src/wasm/wasm-result.h" |
| 14 #include "src/zone/zone.h" | 15 #include "src/zone/zone.h" |
| 15 | 16 |
| 16 namespace v8 { | 17 namespace v8 { |
| 17 namespace internal { | 18 namespace internal { |
| 18 namespace wasm { | 19 namespace wasm { |
| 19 namespace testing { | 20 namespace testing { |
| 20 | 21 |
| 21 // Decodes the given encoded module. | 22 // Decodes the given encoded module. |
| 22 const WasmModule* DecodeWasmModuleForTesting( | 23 const WasmModule* DecodeWasmModuleForTesting( |
| 23 Isolate* isolate, ErrorThrower* thrower, const byte* module_start, | 24 Isolate* isolate, ErrorThrower* thrower, const byte* module_start, |
| 24 const byte* module_end, ModuleOrigin origin, bool verify_functions = false); | 25 const byte* module_end, ModuleOrigin origin, bool verify_functions = false); |
| 25 | 26 |
| 26 // Instantiates a module without any imports and exports. | 27 // Instantiates a module without any imports and exports. |
| 27 const Handle<JSObject> InstantiateModuleForTesting(Isolate* isolate, | 28 const Handle<WasmInstanceObject> InstantiateModuleForTesting( |
| 28 ErrorThrower* thrower, | 29 Isolate* isolate, ErrorThrower* thrower, const WasmModule* module); |
| 29 const WasmModule* module); | |
| 30 | 30 |
| 31 int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, | 31 int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance, |
| 32 ErrorThrower* thrower, const char* name, | 32 ErrorThrower* thrower, const char* name, |
| 33 int argc, Handle<Object> argv[], | 33 int argc, Handle<Object> argv[], |
| 34 ModuleOrigin origin); | 34 ModuleOrigin origin); |
| 35 | 35 |
| 36 // Decode, verify, and run the function labeled "main" in the | 36 // Decode, verify, and run the function labeled "main" in the |
| 37 // given encoded module. The module should have no imports. | 37 // given encoded module. The module should have no imports. |
| 38 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 38 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
| 39 const byte* module_end, ModuleOrigin origin); | 39 const byte* module_end, ModuleOrigin origin); |
| 40 | 40 |
| 41 // Interprets the given module, starting at the function specified by | 41 // Interprets the given module, starting at the function specified by |
| 42 // {function_index}. The return type of the function has to be int32. The module | 42 // {function_index}. The return type of the function has to be int32. The module |
| 43 // should not have any imports or exports | 43 // should not have any imports or exports |
| 44 int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower, | 44 int32_t InterpretWasmModule(Isolate* isolate, ErrorThrower* thrower, |
| 45 const WasmModule* module, int function_index, | 45 const WasmModule* module, int function_index, |
| 46 WasmVal* args, bool* may_produced_nan); | 46 WasmVal* args, bool* may_produced_nan); |
| 47 | 47 |
| 48 // Compiles WasmModule bytes and return an instance of the compiled module. | 48 // Compiles WasmModule bytes and return an instance of the compiled module. |
| 49 const Handle<JSObject> CompileInstantiateWasmModuleForTesting( | 49 const Handle<WasmInstanceObject> CompileInstantiateWasmModuleForTesting( |
| 50 Isolate* isolate, ErrorThrower* thrower, const byte* module_start, | 50 Isolate* isolate, ErrorThrower* thrower, const byte* module_start, |
| 51 const byte* module_end, ModuleOrigin origin); | 51 const byte* module_end, ModuleOrigin origin); |
| 52 | 52 |
| 53 // Runs the module instance with arguments. | 53 // Runs the module instance with arguments. |
| 54 int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance, | 54 int32_t RunWasmModuleForTesting(Isolate* isolate, Handle<JSObject> instance, |
| 55 int argc, Handle<Object> argv[], | 55 int argc, Handle<Object> argv[], |
| 56 ModuleOrigin origin); | 56 ModuleOrigin origin); |
| 57 // Install function map, module symbol for testing | 57 // Install function map, module symbol for testing |
| 58 void SetupIsolateForWasmModule(Isolate* isolate); | 58 void SetupIsolateForWasmModule(Isolate* isolate); |
| 59 } // namespace testing | 59 } // namespace testing |
| 60 } // namespace wasm | 60 } // namespace wasm |
| 61 } // namespace internal | 61 } // namespace internal |
| 62 } // namespace v8 | 62 } // namespace v8 |
| 63 | 63 |
| 64 #endif // V8_WASM_MODULE_RUNNER_H_ | 64 #endif // V8_WASM_MODULE_RUNNER_H_ |
| OLD | NEW |