| 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 #include "src/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
| 6 #include "src/assert-scope.h" | 6 #include "src/assert-scope.h" |
| 7 #include "src/compiler/wasm-compiler.h" | 7 #include "src/compiler/wasm-compiler.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool Execute(uint32_t func_index, uint8_t* arg_buffer) { | 128 bool Execute(uint32_t func_index, uint8_t* arg_buffer) { |
| 129 DCHECK_GE(module()->functions.size(), func_index); | 129 DCHECK_GE(module()->functions.size(), func_index); |
| 130 FunctionSig* sig = module()->functions[func_index].sig; | 130 FunctionSig* sig = module()->functions[func_index].sig; |
| 131 DCHECK_GE(kMaxInt, sig->parameter_count()); | 131 DCHECK_GE(kMaxInt, sig->parameter_count()); |
| 132 int num_params = static_cast<int>(sig->parameter_count()); | 132 int num_params = static_cast<int>(sig->parameter_count()); |
| 133 ScopedVector<WasmVal> wasm_args(num_params); | 133 ScopedVector<WasmVal> wasm_args(num_params); |
| 134 uint8_t* arg_buf_ptr = arg_buffer; | 134 uint8_t* arg_buf_ptr = arg_buffer; |
| 135 for (int i = 0; i < num_params; ++i) { | 135 for (int i = 0; i < num_params; ++i) { |
| 136 int param_size = 1 << ElementSizeLog2Of(sig->GetParam(i)); | 136 uint32_t param_size = 1 << ElementSizeLog2Of(sig->GetParam(i)); |
| 137 #define CASE_ARG_TYPE(type, ctype) \ | 137 #define CASE_ARG_TYPE(type, ctype) \ |
| 138 case type: \ | 138 case type: \ |
| 139 DCHECK_EQ(param_size, sizeof(ctype)); \ | 139 DCHECK_EQ(param_size, sizeof(ctype)); \ |
| 140 wasm_args[i] = WasmVal(*reinterpret_cast<ctype*>(arg_buf_ptr)); \ | 140 wasm_args[i] = WasmVal(ReadUnalignedValue<ctype>(arg_buf_ptr)); \ |
| 141 break; | 141 break; |
| 142 switch (sig->GetParam(i)) { | 142 switch (sig->GetParam(i)) { |
| 143 CASE_ARG_TYPE(kWasmI32, uint32_t) | 143 CASE_ARG_TYPE(kWasmI32, uint32_t) |
| 144 CASE_ARG_TYPE(kWasmI64, uint64_t) | 144 CASE_ARG_TYPE(kWasmI64, uint64_t) |
| 145 CASE_ARG_TYPE(kWasmF32, float) | 145 CASE_ARG_TYPE(kWasmF32, float) |
| 146 CASE_ARG_TYPE(kWasmF64, double) | 146 CASE_ARG_TYPE(kWasmF64, double) |
| 147 #undef CASE_ARG_TYPE | 147 #undef CASE_ARG_TYPE |
| 148 default: | 148 default: |
| 149 UNREACHABLE(); | 149 UNREACHABLE(); |
| 150 } | 150 } |
| 151 arg_buf_ptr += RoundUpToMultipleOfPowOf2(param_size, 8); | 151 arg_buf_ptr += param_size; |
| 152 } | 152 } |
| 153 | 153 |
| 154 WasmInterpreter::Thread* thread = interpreter_.GetThread(0); | 154 WasmInterpreter::Thread* thread = interpreter_.GetThread(0); |
| 155 // We do not support reentering an already running interpreter at the moment | 155 // We do not support reentering an already running interpreter at the moment |
| 156 // (like INTERPRETER -> JS -> WASM -> INTERPRETER). | 156 // (like INTERPRETER -> JS -> WASM -> INTERPRETER). |
| 157 DCHECK(thread->state() == WasmInterpreter::STOPPED || | 157 DCHECK(thread->state() == WasmInterpreter::STOPPED || |
| 158 thread->state() == WasmInterpreter::FINISHED || | 158 thread->state() == WasmInterpreter::FINISHED || |
| 159 thread->state() == WasmInterpreter::TRAPPED); | 159 thread->state() == WasmInterpreter::TRAPPED); |
| 160 thread->Reset(); | 160 thread->Reset(); |
| 161 thread->InitFrame(&module()->functions[func_index], wasm_args.start()); | 161 thread->InitFrame(&module()->functions[func_index], wasm_args.start()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 190 | 190 |
| 191 // Copy back the return value | 191 // Copy back the return value |
| 192 DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); | 192 DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); |
| 193 // TODO(wasm): Handle multi-value returns. | 193 // TODO(wasm): Handle multi-value returns. |
| 194 DCHECK_EQ(1, kV8MaxWasmFunctionReturns); | 194 DCHECK_EQ(1, kV8MaxWasmFunctionReturns); |
| 195 if (sig->return_count()) { | 195 if (sig->return_count()) { |
| 196 WasmVal ret_val = thread->GetReturnValue(0); | 196 WasmVal ret_val = thread->GetReturnValue(0); |
| 197 #define CASE_RET_TYPE(type, ctype) \ | 197 #define CASE_RET_TYPE(type, ctype) \ |
| 198 case type: \ | 198 case type: \ |
| 199 DCHECK_EQ(1 << ElementSizeLog2Of(sig->GetReturn(0)), sizeof(ctype)); \ | 199 DCHECK_EQ(1 << ElementSizeLog2Of(sig->GetReturn(0)), sizeof(ctype)); \ |
| 200 *reinterpret_cast<ctype*>(arg_buffer) = ret_val.to<ctype>(); \ | 200 WriteUnalignedValue<ctype>(arg_buffer, ret_val.to<ctype>()); \ |
| 201 break; | 201 break; |
| 202 switch (sig->GetReturn(0)) { | 202 switch (sig->GetReturn(0)) { |
| 203 CASE_RET_TYPE(kWasmI32, uint32_t) | 203 CASE_RET_TYPE(kWasmI32, uint32_t) |
| 204 CASE_RET_TYPE(kWasmI64, uint64_t) | 204 CASE_RET_TYPE(kWasmI64, uint64_t) |
| 205 CASE_RET_TYPE(kWasmF32, float) | 205 CASE_RET_TYPE(kWasmF32, float) |
| 206 CASE_RET_TYPE(kWasmF64, double) | 206 CASE_RET_TYPE(kWasmF64, double) |
| 207 #undef CASE_RET_TYPE | 207 #undef CASE_RET_TYPE |
| 208 default: | 208 default: |
| 209 UNREACHABLE(); | 209 UNREACHABLE(); |
| 210 } | 210 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame( | 495 std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame( |
| 496 Address frame_pointer, int idx) { | 496 Address frame_pointer, int idx) { |
| 497 return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx); | 497 return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx); |
| 498 } | 498 } |
| 499 | 499 |
| 500 uint64_t WasmDebugInfo::NumInterpretedCalls() { | 500 uint64_t WasmDebugInfo::NumInterpretedCalls() { |
| 501 auto handle = GetInterpreterHandleOrNull(this); | 501 auto handle = GetInterpreterHandleOrNull(this); |
| 502 return handle ? handle->NumInterpretedCalls() : 0; | 502 return handle ? handle->NumInterpretedCalls() : 0; |
| 503 } | 503 } |
| OLD | NEW |