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 WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
7 | 7 |
8 #include <setjmp.h> | 8 #include <setjmp.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 execution_mode_(mode), | 78 execution_mode_(mode), |
79 instance_(&module_), | 79 instance_(&module_), |
80 isolate_(CcTest::InitIsolateOnce()), | 80 isolate_(CcTest::InitIsolateOnce()), |
81 global_offset(0), | 81 global_offset(0), |
82 interpreter_(mode == kExecuteInterpreted | 82 interpreter_(mode == kExecuteInterpreted |
83 ? new WasmInterpreter( | 83 ? new WasmInterpreter( |
84 ModuleBytesEnv(&module_, &instance_, | 84 ModuleBytesEnv(&module_, &instance_, |
85 Vector<const byte>::empty()), | 85 Vector<const byte>::empty()), |
86 zone->allocator()) | 86 zone->allocator()) |
87 : nullptr) { | 87 : nullptr) { |
| 88 WasmJs::Install(isolate_); |
88 instance->module = &module_; | 89 instance->module = &module_; |
89 instance->globals_start = global_data; | 90 instance->globals_start = global_data; |
90 module_.globals_size = kMaxGlobalsSize; | 91 module_.globals_size = kMaxGlobalsSize; |
91 instance->mem_start = nullptr; | 92 instance->mem_start = nullptr; |
92 instance->mem_size = 0; | 93 instance->mem_size = 0; |
93 memset(global_data, 0, sizeof(global_data)); | 94 memset(global_data, 0, sizeof(global_data)); |
94 instance_object_ = InitInstanceObject(); | 95 instance_object_ = InitInstanceObject(); |
95 } | 96 } |
96 | 97 |
97 ~TestingModule() { | 98 ~TestingModule() { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 isolate_, jsfunc, sig, index, Handle<String>::null(), | 213 isolate_, jsfunc, sig, index, Handle<String>::null(), |
213 Handle<String>::null(), module->origin); | 214 Handle<String>::null(), module->origin); |
214 instance->function_code[index] = code; | 215 instance->function_code[index] = code; |
215 return index; | 216 return index; |
216 } | 217 } |
217 | 218 |
218 Handle<JSFunction> WrapCode(uint32_t index) { | 219 Handle<JSFunction> WrapCode(uint32_t index) { |
219 // Wrap the code so it can be called as a JS function. | 220 // Wrap the code so it can be called as a JS function. |
220 Handle<WasmInstanceObject> instance_obj(0, isolate_); | 221 Handle<WasmInstanceObject> instance_obj(0, isolate_); |
221 Handle<Code> code = instance->function_code[index]; | 222 Handle<Code> code = instance->function_code[index]; |
222 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); | |
223 Handle<Code> ret_code = | 223 Handle<Code> ret_code = |
224 compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); | 224 compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); |
225 Handle<JSFunction> ret = WasmExportedFunction::New( | 225 Handle<JSFunction> ret = WasmExportedFunction::New( |
226 isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index), | 226 isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index), |
227 static_cast<int>(this->module->functions[index].sig->parameter_count()), | 227 static_cast<int>(this->module->functions[index].sig->parameter_count()), |
228 ret_code); | 228 ret_code); |
229 return ret; | 229 return ret; |
230 } | 230 } |
231 | 231 |
232 void SetFunctionCode(uint32_t index, Handle<Code> code) { | 232 void SetFunctionCode(uint32_t index, Handle<Code> code) { |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 void RunWasm_##name(WasmExecutionMode execution_mode) | 796 void RunWasm_##name(WasmExecutionMode execution_mode) |
797 | 797 |
798 #define WASM_EXEC_COMPILED_TEST(name) \ | 798 #define WASM_EXEC_COMPILED_TEST(name) \ |
799 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 799 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
800 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 800 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
801 void RunWasm_##name(WasmExecutionMode execution_mode) | 801 void RunWasm_##name(WasmExecutionMode execution_mode) |
802 | 802 |
803 } // namespace | 803 } // namespace |
804 | 804 |
805 #endif | 805 #endif |
OLD | NEW |