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