| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "src/base/utils/random-number-generator.h" | 13 #include "src/base/utils/random-number-generator.h" |
| 14 #include "src/zone/accounting-allocator.h" | 14 #include "src/zone/accounting-allocator.h" |
| 15 | 15 |
| 16 #include "src/compiler/graph-visualizer.h" | 16 #include "src/compiler/graph-visualizer.h" |
| 17 #include "src/compiler/int64-lowering.h" | 17 #include "src/compiler/int64-lowering.h" |
| 18 #include "src/compiler/js-graph.h" | 18 #include "src/compiler/js-graph.h" |
| 19 #include "src/compiler/node.h" | 19 #include "src/compiler/node.h" |
| 20 #include "src/compiler/pipeline.h" | 20 #include "src/compiler/pipeline.h" |
| 21 #include "src/compiler/wasm-compiler.h" | 21 #include "src/compiler/wasm-compiler.h" |
| 22 #include "src/compiler/zone-stats.h" | 22 #include "src/compiler/zone-stats.h" |
| 23 #include "src/wasm/ast-decoder.h" | 23 #include "src/wasm/ast-decoder.h" |
| 24 #include "src/wasm/wasm-interpreter.h" | 24 #include "src/wasm/wasm-interpreter.h" |
| 25 #include "src/wasm/wasm-js.h" | 25 #include "src/wasm/wasm-js.h" |
| 26 #include "src/wasm/wasm-macro-gen.h" | 26 #include "src/wasm/wasm-macro-gen.h" |
| 27 #include "src/wasm/wasm-module.h" | 27 #include "src/wasm/wasm-module.h" |
| 28 #include "src/wasm/wasm-objects.h" |
| 28 #include "src/wasm/wasm-opcodes.h" | 29 #include "src/wasm/wasm-opcodes.h" |
| 29 | 30 |
| 30 #include "src/zone/zone.h" | 31 #include "src/zone/zone.h" |
| 31 | 32 |
| 32 #include "test/cctest/cctest.h" | 33 #include "test/cctest/cctest.h" |
| 33 #include "test/cctest/compiler/call-tester.h" | 34 #include "test/cctest/compiler/call-tester.h" |
| 34 #include "test/cctest/compiler/graph-builder-tester.h" | 35 #include "test/cctest/compiler/graph-builder-tester.h" |
| 35 | 36 |
| 36 static const uint32_t kMaxFunctions = 10; | 37 static const uint32_t kMaxFunctions = 10; |
| 37 | 38 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 Handle<Code> code = | 200 Handle<Code> code = |
| 200 CompileWasmToJSWrapper(isolate_, jsfunc, sig, index, | 201 CompileWasmToJSWrapper(isolate_, jsfunc, sig, index, |
| 201 Handle<String>::null(), Handle<String>::null()); | 202 Handle<String>::null(), Handle<String>::null()); |
| 202 instance->function_code[index] = code; | 203 instance->function_code[index] = code; |
| 203 return index; | 204 return index; |
| 204 } | 205 } |
| 205 | 206 |
| 206 Handle<JSFunction> WrapCode(uint32_t index) { | 207 Handle<JSFunction> WrapCode(uint32_t index) { |
| 207 // Wrap the code so it can be called as a JS function. | 208 // Wrap the code so it can be called as a JS function. |
| 208 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); | 209 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); |
| 209 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); | 210 Handle<WasmInstanceObject> instance_obj(0, isolate_); |
| 210 Handle<Code> code = instance->function_code[index]; | 211 Handle<Code> code = instance->function_code[index]; |
| 211 WasmJs::InstallWasmMapsIfNeeded(isolate_, isolate_->native_context()); | 212 WasmJs::InstallWasmMapsIfNeeded(isolate_, 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 Handle<JSFunction> ret = WrapExportCodeAsJSFunction( | 215 Handle<JSFunction> ret = WasmExportedFunction::New( |
| 215 isolate_, ret_code, name, this->module->functions[index].sig, | 216 isolate_, instance_obj, name, ret_code, |
| 216 static_cast<int>(index), module_object); | 217 static_cast<int>(this->module->functions[index].sig->parameter_count()), |
| 218 static_cast<int>(index)); |
| 217 return ret; | 219 return ret; |
| 218 } | 220 } |
| 219 | 221 |
| 220 void SetFunctionCode(uint32_t index, Handle<Code> code) { | 222 void SetFunctionCode(uint32_t index, Handle<Code> code) { |
| 221 instance->function_code[index] = code; | 223 instance->function_code[index] = code; |
| 222 } | 224 } |
| 223 | 225 |
| 224 void AddIndirectFunctionTable(uint16_t* function_indexes, | 226 void AddIndirectFunctionTable(uint16_t* function_indexes, |
| 225 uint32_t table_size) { | 227 uint32_t table_size) { |
| 226 module_.function_tables.push_back({table_size, table_size, true, | 228 module_.function_tables.push_back({table_size, table_size, true, |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 // interpreter. | 791 // interpreter. |
| 790 #define WASM_EXEC_TEST(name) \ | 792 #define WASM_EXEC_TEST(name) \ |
| 791 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 793 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 792 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 794 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 793 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 795 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
| 794 void RunWasm_##name(WasmExecutionMode execution_mode) | 796 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 795 | 797 |
| 796 } // namespace | 798 } // namespace |
| 797 | 799 |
| 798 #endif | 800 #endif |
| OLD | NEW |