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 uint32_t index = AddFunction(sig, Handle<Code>::null()); | 201 uint32_t index = AddFunction(sig, Handle<Code>::null()); |
202 Handle<Code> code = | 202 Handle<Code> code = |
203 CompileWasmToJSWrapper(isolate_, jsfunc, sig, index, | 203 CompileWasmToJSWrapper(isolate_, jsfunc, sig, index, |
204 Handle<String>::null(), Handle<String>::null()); | 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<String> name = isolate_->factory()->NewStringFromStaticChars("main"); | |
212 Handle<WasmInstanceObject> instance_obj(0, isolate_); | 211 Handle<WasmInstanceObject> instance_obj(0, isolate_); |
213 Handle<Code> code = instance->function_code[index]; | 212 Handle<Code> code = instance->function_code[index]; |
214 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); | 213 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); |
215 Handle<Code> ret_code = | 214 Handle<Code> ret_code = |
216 compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); | 215 compiler::CompileJSToWasmWrapper(isolate_, &module_, code, index); |
217 Handle<JSFunction> ret = WasmExportedFunction::New( | 216 Handle<JSFunction> ret = WasmExportedFunction::New( |
218 isolate_, instance_obj, name, ret_code, | 217 isolate_, instance_obj, MaybeHandle<String>(), static_cast<int>(index), |
219 static_cast<int>(this->module->functions[index].sig->parameter_count()), | 218 static_cast<int>(this->module->functions[index].sig->parameter_count()), |
220 static_cast<int>(index)); | 219 ret_code); |
221 return ret; | 220 return ret; |
222 } | 221 } |
223 | 222 |
224 void SetFunctionCode(uint32_t index, Handle<Code> code) { | 223 void SetFunctionCode(uint32_t index, Handle<Code> code) { |
225 instance->function_code[index] = code; | 224 instance->function_code[index] = code; |
226 } | 225 } |
227 | 226 |
228 void AddIndirectFunctionTable(uint16_t* function_indexes, | 227 void AddIndirectFunctionTable(uint16_t* function_indexes, |
229 uint32_t table_size) { | 228 uint32_t table_size) { |
230 module_.function_tables.push_back({table_size, table_size, true, | 229 module_.function_tables.push_back({table_size, table_size, true, |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 void RunWasm_##name(WasmExecutionMode execution_mode) | 797 void RunWasm_##name(WasmExecutionMode execution_mode) |
799 | 798 |
800 #define WASM_EXEC_COMPILED_TEST(name) \ | 799 #define WASM_EXEC_COMPILED_TEST(name) \ |
801 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 800 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
802 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 801 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
803 void RunWasm_##name(WasmExecutionMode execution_mode) | 802 void RunWasm_##name(WasmExecutionMode execution_mode) |
804 | 803 |
805 } // namespace | 804 } // namespace |
806 | 805 |
807 #endif | 806 #endif |
OLD | NEW |