OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
(...skipping 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2968 : graph()->NewNode(jsgraph()->machine()->StackSlot( | 2968 : graph()->NewNode(jsgraph()->machine()->StackSlot( |
2969 std::max(args_size_bytes, return_size_bytes))); | 2969 std::max(args_size_bytes, return_size_bytes))); |
2970 | 2970 |
2971 // Now store all our arguments to the buffer. | 2971 // Now store all our arguments to the buffer. |
2972 int param_index = 0; | 2972 int param_index = 0; |
2973 int offset = 0; | 2973 int offset = 0; |
2974 for (int i = 0; i < wasm_count; i++) { | 2974 for (int i = 0; i < wasm_count; i++) { |
2975 Node* param = Param(param_index++); | 2975 Node* param = Param(param_index++); |
2976 bool is_i64_as_two_params = | 2976 bool is_i64_as_two_params = |
2977 jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64; | 2977 jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64; |
2978 MachineRepresentation param_rep = | |
2979 is_i64_as_two_params ? wasm::kWasmI32 : sig->GetParam(i); | |
2980 StoreRepresentation store_rep(param_rep, WriteBarrierKind::kNoWriteBarrier); | |
2981 *effect_ = | |
2982 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | |
2983 Int32Constant(offset), param, *effect_, *control_); | |
2984 | 2978 |
2985 if (is_i64_as_two_params) { | 2979 if (is_i64_as_two_params) { |
2986 offset += 1 << ElementSizeLog2Of(wasm::kWasmI32); | |
2987 } else { | |
2988 offset += RoundUpToMultipleOfPowOf2(1 << ElementSizeLog2Of(param_rep), 8); | |
2989 } | |
2990 | |
2991 // TODO(clemensh): Respect endianess here. Might need to swap upper and | |
2992 // lower word. | |
2993 if (is_i64_as_two_params) { | |
2994 // Also store the upper half. | |
2995 param = Param(param_index++); | |
2996 StoreRepresentation store_rep(wasm::kWasmI32, | 2980 StoreRepresentation store_rep(wasm::kWasmI32, |
2997 WriteBarrierKind::kNoWriteBarrier); | 2981 WriteBarrierKind::kNoWriteBarrier); |
2998 *effect_ = | 2982 *effect_ = |
2999 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | 2983 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, |
| 2984 Int32Constant(offset + kInt64LowerHalfMemoryOffset), |
| 2985 param, *effect_, *control_); |
| 2986 |
| 2987 param = Param(param_index++); |
| 2988 *effect_ = |
| 2989 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, |
| 2990 Int32Constant(offset + kInt64UpperHalfMemoryOffset), |
| 2991 param, *effect_, *control_); |
| 2992 offset += 8; |
| 2993 |
| 2994 } else { |
| 2995 MachineRepresentation param_rep = sig->GetParam(i); |
| 2996 StoreRepresentation store_rep(param_rep, |
| 2997 WriteBarrierKind::kNoWriteBarrier); |
| 2998 *effect_ = |
| 2999 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, |
3000 Int32Constant(offset), param, *effect_, *control_); | 3000 Int32Constant(offset), param, *effect_, *control_); |
3001 offset += 1 << ElementSizeLog2Of(wasm::kWasmI32); | 3001 offset += RoundUpToMultipleOfPowOf2(1 << ElementSizeLog2Of(param_rep), 8); |
3002 } | 3002 } |
3003 | 3003 |
3004 DCHECK(IsAligned(offset, 8)); | 3004 DCHECK(IsAligned(offset, 8)); |
3005 } | 3005 } |
3006 DCHECK_EQ(param_count, param_index); | 3006 DCHECK_EQ(param_count, param_index); |
3007 DCHECK_EQ(args_size_bytes, offset); | 3007 DCHECK_EQ(args_size_bytes, offset); |
3008 | 3008 |
3009 // We are passing the raw arg_buffer here. To the GC and other parts, it looks | 3009 // We are passing the raw arg_buffer here. To the GC and other parts, it looks |
3010 // like a Smi (lowest bit not set). In the runtime function however, don't | 3010 // like a Smi (lowest bit not set). In the runtime function however, don't |
3011 // call Smi::value on it, but just cast it to a byte pointer. | 3011 // call Smi::value on it, but just cast it to a byte pointer. |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4163 function_->code_end_offset - function_->code_start_offset, | 4163 function_->code_end_offset - function_->code_start_offset, |
4164 codegen_ms); | 4164 codegen_ms); |
4165 } | 4165 } |
4166 | 4166 |
4167 return code; | 4167 return code; |
4168 } | 4168 } |
4169 | 4169 |
4170 } // namespace compiler | 4170 } // namespace compiler |
4171 } // namespace internal | 4171 } // namespace internal |
4172 } // namespace v8 | 4172 } // namespace v8 |
OLD | NEW |