| 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 <unordered_map> | 5 #include <unordered_map> |
| 6 | 6 |
| 7 #include "src/assembler-inl.h" | 7 #include "src/assembler-inl.h" |
| 8 #include "src/assert-scope.h" | 8 #include "src/assert-scope.h" |
| 9 #include "src/compiler/wasm-compiler.h" | 9 #include "src/compiler/wasm-compiler.h" |
| 10 #include "src/debug/debug-scopes.h" | 10 #include "src/debug/debug-scopes.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 FunctionSig* sig = module()->functions[func_index].sig; | 171 FunctionSig* sig = module()->functions[func_index].sig; |
| 172 DCHECK_GE(kMaxInt, sig->parameter_count()); | 172 DCHECK_GE(kMaxInt, sig->parameter_count()); |
| 173 int num_params = static_cast<int>(sig->parameter_count()); | 173 int num_params = static_cast<int>(sig->parameter_count()); |
| 174 ScopedVector<WasmVal> wasm_args(num_params); | 174 ScopedVector<WasmVal> wasm_args(num_params); |
| 175 uint8_t* arg_buf_ptr = arg_buffer; | 175 uint8_t* arg_buf_ptr = arg_buffer; |
| 176 for (int i = 0; i < num_params; ++i) { | 176 for (int i = 0; i < num_params; ++i) { |
| 177 uint32_t param_size = 1 << ElementSizeLog2Of(sig->GetParam(i)); | 177 uint32_t param_size = 1 << ElementSizeLog2Of(sig->GetParam(i)); |
| 178 #define CASE_ARG_TYPE(type, ctype) \ | 178 #define CASE_ARG_TYPE(type, ctype) \ |
| 179 case type: \ | 179 case type: \ |
| 180 DCHECK_EQ(param_size, sizeof(ctype)); \ | 180 DCHECK_EQ(param_size, sizeof(ctype)); \ |
| 181 wasm_args[i] = WasmVal(ReadUnalignedValue<ctype>(arg_buf_ptr)); \ | 181 wasm_args[i] = WasmVal(*reinterpret_cast<ctype*>(arg_buf_ptr)); \ |
| 182 break; | 182 break; |
| 183 switch (sig->GetParam(i)) { | 183 switch (sig->GetParam(i)) { |
| 184 CASE_ARG_TYPE(kWasmI32, uint32_t) | 184 CASE_ARG_TYPE(kWasmI32, uint32_t) |
| 185 CASE_ARG_TYPE(kWasmI64, uint64_t) | 185 CASE_ARG_TYPE(kWasmI64, uint64_t) |
| 186 CASE_ARG_TYPE(kWasmF32, float) | 186 CASE_ARG_TYPE(kWasmF32, float) |
| 187 CASE_ARG_TYPE(kWasmF64, double) | 187 CASE_ARG_TYPE(kWasmF64, double) |
| 188 #undef CASE_ARG_TYPE | 188 #undef CASE_ARG_TYPE |
| 189 default: | 189 default: |
| 190 UNREACHABLE(); | 190 UNREACHABLE(); |
| 191 } | 191 } |
| 192 arg_buf_ptr += param_size; | 192 arg_buf_ptr += RoundUpToMultipleOfPowOf2(param_size, 8); |
| 193 } | 193 } |
| 194 | 194 |
| 195 uint32_t activation_id = StartActivation(frame_pointer); | 195 uint32_t activation_id = StartActivation(frame_pointer); |
| 196 | 196 |
| 197 WasmInterpreter::Thread* thread = interpreter_.GetThread(0); | 197 WasmInterpreter::Thread* thread = interpreter_.GetThread(0); |
| 198 thread->InitFrame(&module()->functions[func_index], wasm_args.start()); | 198 thread->InitFrame(&module()->functions[func_index], wasm_args.start()); |
| 199 bool finished = false; | 199 bool finished = false; |
| 200 while (!finished) { | 200 while (!finished) { |
| 201 // TODO(clemensh): Add occasional StackChecks. | 201 // TODO(clemensh): Add occasional StackChecks. |
| 202 WasmInterpreter::State state = ContinueExecution(thread); | 202 WasmInterpreter::State state = ContinueExecution(thread); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 233 | 233 |
| 234 // Copy back the return value | 234 // Copy back the return value |
| 235 DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); | 235 DCHECK_GE(kV8MaxWasmFunctionReturns, sig->return_count()); |
| 236 // TODO(wasm): Handle multi-value returns. | 236 // TODO(wasm): Handle multi-value returns. |
| 237 DCHECK_EQ(1, kV8MaxWasmFunctionReturns); | 237 DCHECK_EQ(1, kV8MaxWasmFunctionReturns); |
| 238 if (sig->return_count()) { | 238 if (sig->return_count()) { |
| 239 WasmVal ret_val = thread->GetReturnValue(0); | 239 WasmVal ret_val = thread->GetReturnValue(0); |
| 240 #define CASE_RET_TYPE(type, ctype) \ | 240 #define CASE_RET_TYPE(type, ctype) \ |
| 241 case type: \ | 241 case type: \ |
| 242 DCHECK_EQ(1 << ElementSizeLog2Of(sig->GetReturn(0)), sizeof(ctype)); \ | 242 DCHECK_EQ(1 << ElementSizeLog2Of(sig->GetReturn(0)), sizeof(ctype)); \ |
| 243 WriteUnalignedValue<ctype>(arg_buffer, ret_val.to<ctype>()); \ | 243 *reinterpret_cast<ctype*>(arg_buffer) = ret_val.to<ctype>(); \ |
| 244 break; | 244 break; |
| 245 switch (sig->GetReturn(0)) { | 245 switch (sig->GetReturn(0)) { |
| 246 CASE_RET_TYPE(kWasmI32, uint32_t) | 246 CASE_RET_TYPE(kWasmI32, uint32_t) |
| 247 CASE_RET_TYPE(kWasmI64, uint64_t) | 247 CASE_RET_TYPE(kWasmI64, uint64_t) |
| 248 CASE_RET_TYPE(kWasmF32, float) | 248 CASE_RET_TYPE(kWasmF32, float) |
| 249 CASE_RET_TYPE(kWasmF64, double) | 249 CASE_RET_TYPE(kWasmF64, double) |
| 250 #undef CASE_RET_TYPE | 250 #undef CASE_RET_TYPE |
| 251 default: | 251 default: |
| 252 UNREACHABLE(); | 252 UNREACHABLE(); |
| 253 } | 253 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 } | 692 } |
| 693 | 693 |
| 694 // static | 694 // static |
| 695 Handle<JSArray> WasmDebugInfo::GetScopeDetails(Handle<WasmDebugInfo> debug_info, | 695 Handle<JSArray> WasmDebugInfo::GetScopeDetails(Handle<WasmDebugInfo> debug_info, |
| 696 Address frame_pointer, | 696 Address frame_pointer, |
| 697 int frame_index) { | 697 int frame_index) { |
| 698 InterpreterHandle* interp_handle = GetInterpreterHandle(*debug_info); | 698 InterpreterHandle* interp_handle = GetInterpreterHandle(*debug_info); |
| 699 Handle<WasmInstanceObject> instance(debug_info->wasm_instance()); | 699 Handle<WasmInstanceObject> instance(debug_info->wasm_instance()); |
| 700 return interp_handle->GetScopeDetails(frame_pointer, frame_index, instance); | 700 return interp_handle->GetScopeDetails(frame_pointer, frame_index, instance); |
| 701 } | 701 } |
| OLD | NEW |