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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 FunctionSig* sig = module()->functions[func_index].sig; | 82 FunctionSig* sig = module()->functions[func_index].sig; |
83 DCHECK_GE(kMaxInt, sig->parameter_count()); | 83 DCHECK_GE(kMaxInt, sig->parameter_count()); |
84 int num_params = static_cast<int>(sig->parameter_count()); | 84 int num_params = static_cast<int>(sig->parameter_count()); |
85 ScopedVector<WasmVal> wasm_args(num_params); | 85 ScopedVector<WasmVal> wasm_args(num_params); |
86 uint8_t* arg_buf_ptr = arg_buffer; | 86 uint8_t* arg_buf_ptr = arg_buffer; |
87 for (int i = 0; i < num_params; ++i) { | 87 for (int i = 0; i < num_params; ++i) { |
88 uint32_t param_size = 1 << ElementSizeLog2Of(sig->GetParam(i)); | 88 uint32_t param_size = 1 << ElementSizeLog2Of(sig->GetParam(i)); |
89 #define CASE_ARG_TYPE(type, ctype) \ | 89 #define CASE_ARG_TYPE(type, ctype) \ |
90 case type: \ | 90 case type: \ |
91 DCHECK_EQ(param_size, sizeof(ctype)); \ | 91 DCHECK_EQ(param_size, sizeof(ctype)); \ |
92 wasm_args[i] = WasmVal(*reinterpret_cast<ctype*>(arg_buf_ptr)); \ | 92 wasm_args[i] = WasmVal(ReadUnalignedValue<ctype>(arg_buf_ptr)); \ |
93 break; | 93 break; |
94 switch (sig->GetParam(i)) { | 94 switch (sig->GetParam(i)) { |
95 CASE_ARG_TYPE(kWasmI32, uint32_t) | 95 CASE_ARG_TYPE(kWasmI32, uint32_t) |
96 CASE_ARG_TYPE(kWasmI64, uint64_t) | 96 CASE_ARG_TYPE(kWasmI64, uint64_t) |
97 CASE_ARG_TYPE(kWasmF32, float) | 97 CASE_ARG_TYPE(kWasmF32, float) |
98 CASE_ARG_TYPE(kWasmF64, double) | 98 CASE_ARG_TYPE(kWasmF64, double) |
99 #undef CASE_ARG_TYPE | 99 #undef CASE_ARG_TYPE |
100 default: | 100 default: |
101 UNREACHABLE(); | 101 UNREACHABLE(); |
102 } | 102 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 // Copy back the return value | 137 // Copy back the return value |
138 DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); | 138 DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); |
139 // TODO(wasm): Handle multi-value returns. | 139 // TODO(wasm): Handle multi-value returns. |
140 DCHECK_EQ(1, kV8MaxWasmFunctionReturns); | 140 DCHECK_EQ(1, kV8MaxWasmFunctionReturns); |
141 if (sig->return_count()) { | 141 if (sig->return_count()) { |
142 WasmVal ret_val = thread->GetReturnValue(0); | 142 WasmVal ret_val = thread->GetReturnValue(0); |
143 #define CASE_RET_TYPE(type, ctype) \ | 143 #define CASE_RET_TYPE(type, ctype) \ |
144 case type: \ | 144 case type: \ |
145 DCHECK_EQ(1 << ElementSizeLog2Of(sig->GetReturn(0)), sizeof(ctype)); \ | 145 DCHECK_EQ(1 << ElementSizeLog2Of(sig->GetReturn(0)), sizeof(ctype)); \ |
146 *reinterpret_cast<ctype*>(arg_buffer) = ret_val.to<ctype>(); \ | 146 WriteUnalignedValue<ctype>(arg_buffer, ret_val.to<ctype>()); \ |
147 break; | 147 break; |
148 switch (sig->GetReturn(0)) { | 148 switch (sig->GetReturn(0)) { |
149 CASE_RET_TYPE(kWasmI32, uint32_t) | 149 CASE_RET_TYPE(kWasmI32, uint32_t) |
150 CASE_RET_TYPE(kWasmI64, uint64_t) | 150 CASE_RET_TYPE(kWasmI64, uint64_t) |
151 CASE_RET_TYPE(kWasmF32, float) | 151 CASE_RET_TYPE(kWasmF32, float) |
152 CASE_RET_TYPE(kWasmF64, double) | 152 CASE_RET_TYPE(kWasmF64, double) |
153 #undef CASE_RET_TYPE | 153 #undef CASE_RET_TYPE |
154 default: | 154 default: |
155 UNREACHABLE(); | 155 UNREACHABLE(); |
156 } | 156 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame( | 439 std::unique_ptr<wasm::InterpretedFrame> WasmDebugInfo::GetInterpretedFrame( |
440 Address frame_pointer, int idx) { | 440 Address frame_pointer, int idx) { |
441 return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx); | 441 return GetInterpreterHandle(this)->GetInterpretedFrame(frame_pointer, idx); |
442 } | 442 } |
443 | 443 |
444 uint64_t WasmDebugInfo::NumInterpretedCalls() { | 444 uint64_t WasmDebugInfo::NumInterpretedCalls() { |
445 auto handle = GetInterpreterHandleOrNull(this); | 445 auto handle = GetInterpreterHandleOrNull(this); |
446 return handle ? handle->NumInterpretedCalls() : 0; | 446 return handle ? handle->NumInterpretedCalls() : 0; |
447 } | 447 } |
OLD | NEW |