| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::InstallWasmFunctionMap(isolate_, isolate_->native_context()); |
| 212 Handle<Code> ret_code = | 212 Handle<Code> ret_code = |
| 213 compiler::CompileJSToWasmWrapper(isolate_, this, code, index); | 213 compiler::CompileJSToWasmWrapper(isolate_, this, code, index); |
| 214 FunctionSig* funcSig = this->module->functions[index].sig; |
| 215 Handle<ByteArray> exportedSig = isolate_->factory()->NewByteArray( |
| 216 static_cast<int>(funcSig->parameter_count() + funcSig->return_count()), |
| 217 TENURED); |
| 218 exportedSig->copy_in(0, reinterpret_cast<const byte*>(funcSig->raw_data()), |
| 219 exportedSig->length()); |
| 214 Handle<JSFunction> ret = WrapExportCodeAsJSFunction( | 220 Handle<JSFunction> ret = WrapExportCodeAsJSFunction( |
| 215 isolate_, ret_code, name, | 221 isolate_, ret_code, name, |
| 216 static_cast<int>(this->module->functions[index].sig->parameter_count()), | 222 static_cast<int>(this->module->functions[index].sig->parameter_count()), |
| 217 module_object); | 223 exportedSig, module_object); |
| 218 return ret; | 224 return ret; |
| 219 } | 225 } |
| 220 | 226 |
| 221 void SetFunctionCode(uint32_t index, Handle<Code> code) { | 227 void SetFunctionCode(uint32_t index, Handle<Code> code) { |
| 222 instance->function_code[index] = code; | 228 instance->function_code[index] = code; |
| 223 } | 229 } |
| 224 | 230 |
| 225 void AddIndirectFunctionTable(uint16_t* functions, uint32_t table_size) { | 231 void AddIndirectFunctionTable(uint16_t* functions, uint32_t table_size) { |
| 226 module_.function_tables.push_back( | 232 module_.function_tables.push_back( |
| 227 {table_size, table_size, std::vector<uint16_t>()}); | 233 {table_size, table_size, std::vector<uint16_t>()}); |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 // interpreter. | 774 // interpreter. |
| 769 #define WASM_EXEC_TEST(name) \ | 775 #define WASM_EXEC_TEST(name) \ |
| 770 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 776 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 771 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 777 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 772 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 778 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
| 773 void RunWasm_##name(WasmExecutionMode execution_mode) | 779 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 774 | 780 |
| 775 } // namespace | 781 } // namespace |
| 776 | 782 |
| 777 #endif | 783 #endif |
| OLD | NEW |