| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); | 192 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); |
| 193 } | 193 } |
| 194 DCHECK_LT(index, kMaxFunctions); // limited for testing. | 194 DCHECK_LT(index, kMaxFunctions); // limited for testing. |
| 195 return index; | 195 return index; |
| 196 } | 196 } |
| 197 | 197 |
| 198 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { | 198 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { |
| 199 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 199 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 200 *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 200 *v8::Local<v8::Function>::Cast(CompileRun(source)))); |
| 201 uint32_t index = AddFunction(sig, Handle<Code>::null()); | 201 uint32_t index = AddFunction(sig, Handle<Code>::null()); |
| 202 Handle<Code> code = CompileWasmToJSWrapper( | 202 Handle<Code> code = |
| 203 isolate_, jsfunc, sig, index, Handle<String>::null(), | 203 CompileWasmToJSWrapper(isolate_, jsfunc, sig, index, |
| 204 Handle<String>::null(), module->origin); | 204 Handle<String>::null(), Handle<String>::null()); |
| 205 instance->function_code[index] = code; | 205 instance->function_code[index] = code; |
| 206 return index; | 206 return index; |
| 207 } | 207 } |
| 208 | 208 |
| 209 Handle<JSFunction> WrapCode(uint32_t index) { | 209 Handle<JSFunction> WrapCode(uint32_t index) { |
| 210 // Wrap the code so it can be called as a JS function. | 210 // Wrap the code so it can be called as a JS function. |
| 211 Handle<WasmInstanceObject> instance_obj(0, isolate_); | 211 Handle<WasmInstanceObject> instance_obj(0, isolate_); |
| 212 Handle<Code> code = instance->function_code[index]; | 212 Handle<Code> code = instance->function_code[index]; |
| 213 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); | 213 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); |
| 214 Handle<Code> ret_code = | 214 Handle<Code> ret_code = |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 void RunWasm_##name(WasmExecutionMode execution_mode) | 797 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 798 | 798 |
| 799 #define WASM_EXEC_COMPILED_TEST(name) \ | 799 #define WASM_EXEC_COMPILED_TEST(name) \ |
| 800 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 800 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 801 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 801 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 802 void RunWasm_##name(WasmExecutionMode execution_mode) | 802 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 803 | 803 |
| 804 } // namespace | 804 } // namespace |
| 805 | 805 |
| 806 #endif | 806 #endif |
| OLD | NEW |