| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 Handle<String>::null(), Handle<String>::null()); | 201 Handle<String>::null(), Handle<String>::null()); |
| 202 instance->function_code[index] = code; | 202 instance->function_code[index] = code; |
| 203 return index; | 203 return index; |
| 204 } | 204 } |
| 205 | 205 |
| 206 Handle<JSFunction> WrapCode(uint32_t index) { | 206 Handle<JSFunction> WrapCode(uint32_t index) { |
| 207 // Wrap the code so it can be called as a JS function. | 207 // Wrap the code so it can be called as a JS function. |
| 208 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); | 208 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); |
| 209 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); | 209 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); |
| 210 Handle<Code> code = instance->function_code[index]; | 210 Handle<Code> code = instance->function_code[index]; |
| 211 WasmJs::InstallWasmFunctionMap(isolate_, isolate_->native_context()); | 211 WasmJs::InstallWasmFunctionMapIfNeeded(isolate_, |
| 212 isolate_->native_context()); |
| 212 Handle<Code> ret_code = | 213 Handle<Code> ret_code = |
| 213 compiler::CompileJSToWasmWrapper(isolate_, this, code, index); | 214 compiler::CompileJSToWasmWrapper(isolate_, this, code, index); |
| 214 FunctionSig* funcSig = this->module->functions[index].sig; | 215 FunctionSig* funcSig = this->module->functions[index].sig; |
| 215 Handle<ByteArray> exportedSig = isolate_->factory()->NewByteArray( | 216 Handle<ByteArray> exportedSig = isolate_->factory()->NewByteArray( |
| 216 static_cast<int>(funcSig->parameter_count() + funcSig->return_count()), | 217 static_cast<int>(funcSig->parameter_count() + funcSig->return_count()), |
| 217 TENURED); | 218 TENURED); |
| 218 exportedSig->copy_in(0, reinterpret_cast<const byte*>(funcSig->raw_data()), | 219 exportedSig->copy_in(0, reinterpret_cast<const byte*>(funcSig->raw_data()), |
| 219 exportedSig->length()); | 220 exportedSig->length()); |
| 220 Handle<JSFunction> ret = WrapExportCodeAsJSFunction( | 221 Handle<JSFunction> ret = WrapExportCodeAsJSFunction( |
| 221 isolate_, ret_code, name, | 222 isolate_, ret_code, name, |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 // interpreter. | 776 // interpreter. |
| 776 #define WASM_EXEC_TEST(name) \ | 777 #define WASM_EXEC_TEST(name) \ |
| 777 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 778 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 778 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 779 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 779 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 780 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
| 780 void RunWasm_##name(WasmExecutionMode execution_mode) | 781 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 781 | 782 |
| 782 } // namespace | 783 } // namespace |
| 783 | 784 |
| 784 #endif | 785 #endif |
| OLD | NEW |