| Index: src/compiler/wasm-compiler.cc
|
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
|
| index bb984253017de9addbbc353615b0fb36e91b669a..27d8537144496da7b25b152f49cd38b7622c72e3 100644
|
| --- a/src/compiler/wasm-compiler.cc
|
| +++ b/src/compiler/wasm-compiler.cc
|
| @@ -2811,10 +2811,11 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
|
| sig->return_count() == 0 ? 0 : 1 << ElementSizeLog2Of(sig->GetReturn(0));
|
|
|
| // Get a stack slot for the arguments.
|
| - Node* arg_buffer = args_size_bytes == 0 && return_size_bytes == 0
|
| - ? jsgraph()->IntPtrConstant(0)
|
| - : graph()->NewNode(jsgraph()->machine()->StackSlot(
|
| - std::max(args_size_bytes, return_size_bytes)));
|
| + Node* arg_buffer =
|
| + args_size_bytes == 0 && return_size_bytes == 0
|
| + ? jsgraph()->IntPtrConstant(0)
|
| + : graph()->NewNode(jsgraph()->machine()->StackSlot(
|
| + std::max(args_size_bytes, return_size_bytes), 8));
|
|
|
| // Now store all our arguments to the buffer.
|
| int param_index = 0;
|
| @@ -2824,27 +2825,28 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
|
| Node* param = Param(param_index++);
|
| if (Int64Lowering::IsI64AsTwoParameters(jsgraph()->machine(),
|
| sig->GetParam(i))) {
|
| - StoreRepresentation store_rep(wasm::kWasmI32,
|
| - WriteBarrierKind::kNoWriteBarrier);
|
| - *effect_ =
|
| - graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer,
|
| - Int32Constant(offset + kInt64LowerHalfMemoryOffset),
|
| - param, *effect_, *control_);
|
| + int lower_half_offset = offset + kInt64LowerHalfMemoryOffset;
|
| + int upper_half_offset = offset + kInt64UpperHalfMemoryOffset;
|
| +
|
| + *effect_ = graph()->NewNode(
|
| + GetSafeStoreOperator(jsgraph()->machine(), lower_half_offset,
|
| + wasm::kWasmI32),
|
| + arg_buffer, Int32Constant(lower_half_offset), param, *effect_,
|
| + *control_);
|
|
|
| param = Param(param_index++);
|
| - *effect_ =
|
| - graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer,
|
| - Int32Constant(offset + kInt64UpperHalfMemoryOffset),
|
| - param, *effect_, *control_);
|
| + *effect_ = graph()->NewNode(
|
| + GetSafeStoreOperator(jsgraph()->machine(), upper_half_offset,
|
| + wasm::kWasmI32),
|
| + arg_buffer, Int32Constant(upper_half_offset), param, *effect_,
|
| + *control_);
|
| offset += 8;
|
|
|
| } else {
|
| MachineRepresentation param_rep = sig->GetParam(i);
|
| - StoreRepresentation store_rep(param_rep,
|
| - WriteBarrierKind::kNoWriteBarrier);
|
| - *effect_ =
|
| - graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer,
|
| - Int32Constant(offset), param, *effect_, *control_);
|
| + *effect_ = graph()->NewNode(
|
| + GetSafeStoreOperator(jsgraph()->machine(), offset, param_rep),
|
| + arg_buffer, Int32Constant(offset), param, *effect_, *control_);
|
| offset += 1 << ElementSizeLog2Of(param_rep);
|
| }
|
| }
|
| @@ -3031,6 +3033,18 @@ void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
|
| TrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position);
|
| }
|
|
|
| +const Operator* WasmGraphBuilder::GetSafeStoreOperator(
|
| + MachineOperatorBuilder* machine, int offset, wasm::ValueType type) {
|
| + int alignment = offset % (1 << ElementSizeLog2Of(type));
|
| + if (alignment == 0 || machine->UnalignedStoreSupported(
|
| + MachineType::TypeForRepresentation(type), 0)) {
|
| + StoreRepresentation rep(type, WriteBarrierKind::kNoWriteBarrier);
|
| + return machine->Store(rep);
|
| + }
|
| + UnalignedStoreRepresentation rep(type);
|
| + return machine->UnalignedStore(rep);
|
| +}
|
| +
|
| Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
|
| Node* index, uint32_t offset,
|
| uint32_t alignment,
|
| @@ -3841,7 +3855,10 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index,
|
| Zone zone(isolate->allocator(), ZONE_NAME);
|
| Graph graph(&zone);
|
| CommonOperatorBuilder common(&zone);
|
| - MachineOperatorBuilder machine(&zone);
|
| + MachineOperatorBuilder machine(
|
| + &zone, MachineType::PointerRepresentation(),
|
| + InstructionSelector::SupportedMachineOperatorFlags(),
|
| + InstructionSelector::AlignmentRequirements());
|
| JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
|
|
|
| Node* control = nullptr;
|
|
|