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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 isolate_, jsfunc, sig, index, Handle<String>::null(), | 217 isolate_, jsfunc, sig, index, Handle<String>::null(), |
217 Handle<String>::null(), module->origin); | 218 Handle<String>::null(), module->origin); |
218 instance->function_code[index] = code; | 219 instance->function_code[index] = code; |
219 return index; | 220 return index; |
220 } | 221 } |
221 | 222 |
222 Handle<JSFunction> WrapCode(uint32_t index) { | 223 Handle<JSFunction> WrapCode(uint32_t index) { |
223 // Wrap the code so it can be called as a JS function. | 224 // Wrap the code so it can be called as a JS function. |
224 Handle<WasmInstanceObject> instance_obj(0, isolate_); | 225 Handle<WasmInstanceObject> instance_obj(0, isolate_); |
225 Handle<Code> code = instance->function_code[index]; | 226 Handle<Code> code = instance->function_code[index]; |
226 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); | |
227 Handle<Code> ret_code = | 227 Handle<Code> ret_code = |
228 compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); | 228 compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); |
229 Handle<JSFunction> ret = WasmExportedFunction::New( | 229 Handle<JSFunction> ret = WasmExportedFunction::New( |
230 isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index), | 230 isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index), |
231 static_cast<int>(this->module->functions[index].sig->parameter_count()), | 231 static_cast<int>(this->module->functions[index].sig->parameter_count()), |
232 ret_code); | 232 ret_code); |
233 return ret; | 233 return ret; |
234 } | 234 } |
235 | 235 |
236 void SetFunctionCode(uint32_t index, Handle<Code> code) { | 236 void SetFunctionCode(uint32_t index, Handle<Code> code) { |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 void RunWasm_##name(WasmExecutionMode execution_mode) | 800 void RunWasm_##name(WasmExecutionMode execution_mode) |
801 | 801 |
802 #define WASM_EXEC_COMPILED_TEST(name) \ | 802 #define WASM_EXEC_COMPILED_TEST(name) \ |
803 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 803 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
804 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 804 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
805 void RunWasm_##name(WasmExecutionMode execution_mode) | 805 void RunWasm_##name(WasmExecutionMode execution_mode) |
806 | 806 |
807 } // namespace | 807 } // namespace |
808 | 808 |
809 #endif | 809 #endif |
OLD | NEW |