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 <setjmp.h> | 8 #include <setjmp.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0, false, false}); | 198 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0, false, false}); |
199 if (name) { | 199 if (name) { |
200 Vector<const byte> name_vec = Vector<const byte>::cast(CStrVector(name)); | 200 Vector<const byte> name_vec = Vector<const byte>::cast(CStrVector(name)); |
201 module_.functions.back().name_offset = AddBytes(name_vec); | 201 module_.functions.back().name_offset = AddBytes(name_vec); |
202 module_.functions.back().name_length = name_vec.length(); | 202 module_.functions.back().name_length = name_vec.length(); |
203 } | 203 } |
204 instance->function_code.push_back(code); | 204 instance->function_code.push_back(code); |
205 if (interpreter_) { | 205 if (interpreter_) { |
206 const WasmFunction* function = &module->functions.back(); | 206 const WasmFunction* function = &module->functions.back(); |
207 int interpreter_index = interpreter_->AddFunctionForTesting(function); | 207 int interpreter_index = interpreter_->AddFunctionForTesting(function); |
208 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); | 208 CHECK_EQ(index, interpreter_index); |
209 } | 209 } |
210 DCHECK_LT(index, kMaxFunctions); // limited for testing. | 210 DCHECK_LT(index, kMaxFunctions); // limited for testing. |
211 return index; | 211 return index; |
212 } | 212 } |
213 | 213 |
214 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { | 214 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { |
215 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 215 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
216 *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 216 *v8::Local<v8::Function>::Cast(CompileRun(source)))); |
217 uint32_t index = AddFunction(sig, Handle<Code>::null(), nullptr); | 217 uint32_t index = AddFunction(sig, Handle<Code>::null(), nullptr); |
218 Handle<Code> code = CompileWasmToJSWrapper( | 218 Handle<Code> code = CompileWasmToJSWrapper( |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 // Deopt data holds <WeakCell<wasm_instance>, func_index>. | 622 // Deopt data holds <WeakCell<wasm_instance>, func_index>. |
623 DCHECK(code->deoptimization_data() == nullptr || | 623 DCHECK(code->deoptimization_data() == nullptr || |
624 code->deoptimization_data()->length() == 0); | 624 code->deoptimization_data()->length() == 0); |
625 Handle<FixedArray> deopt_data = | 625 Handle<FixedArray> deopt_data = |
626 isolate()->factory()->NewFixedArray(2, TENURED); | 626 isolate()->factory()->NewFixedArray(2, TENURED); |
627 Handle<Object> weak_instance = | 627 Handle<Object> weak_instance = |
628 isolate()->factory()->NewWeakCell(testing_module_->instance_object()); | 628 isolate()->factory()->NewWeakCell(testing_module_->instance_object()); |
629 deopt_data->set(0, *weak_instance); | 629 deopt_data->set(0, *weak_instance); |
630 deopt_data->set(1, Smi::FromInt(static_cast<int>(function_index()))); | 630 deopt_data->set(1, Smi::FromInt(static_cast<int>(function_index()))); |
631 deopt_data->set_length(2); | |
632 code->set_deoptimization_data(*deopt_data); | 631 code->set_deoptimization_data(*deopt_data); |
633 | 632 |
634 #ifdef ENABLE_DISASSEMBLER | 633 #ifdef ENABLE_DISASSEMBLER |
635 if (FLAG_print_opt_code) { | 634 if (FLAG_print_opt_code) { |
636 OFStream os(stdout); | 635 OFStream os(stdout); |
637 code->Disassemble("wasm code", os); | 636 code->Disassemble("wasm code", os); |
638 } | 637 } |
639 #endif | 638 #endif |
640 | 639 |
641 return code; | 640 return code; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 void RunWasm_##name(WasmExecutionMode execution_mode) | 835 void RunWasm_##name(WasmExecutionMode execution_mode) |
837 | 836 |
838 #define WASM_EXEC_COMPILED_TEST(name) \ | 837 #define WASM_EXEC_COMPILED_TEST(name) \ |
839 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 838 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
840 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 839 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
841 void RunWasm_##name(WasmExecutionMode execution_mode) | 840 void RunWasm_##name(WasmExecutionMode execution_mode) |
842 | 841 |
843 } // namespace | 842 } // namespace |
844 | 843 |
845 #endif | 844 #endif |
OLD | NEW |