Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2887053003: MIPS[64]: Reland of `Fix unaligned arguments storage in Wasm-to-interpreter entry` (Closed)
Patch Set: Address code review remarks 2 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index bb984253017de9addbbc353615b0fb36e91b669a..d2a119f463bba81d15b0662e0f050b15e8cd908d 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,26 +2825,23 @@ 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(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(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,
+ graph()->NewNode(GetSafeStoreOperator(offset, param_rep), arg_buffer,
Int32Constant(offset), param, *effect_, *control_);
offset += 1 << ElementSizeLog2Of(param_rep);
}
@@ -3031,6 +3029,18 @@ void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
TrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position);
}
+const Operator* WasmGraphBuilder::GetSafeStoreOperator(int offset,
+ wasm::ValueType type) {
+ int alignment = offset % (1 << ElementSizeLog2Of(type));
+ if (alignment == 0 || jsgraph()->machine()->UnalignedStoreSupported(
+ MachineType::TypeForRepresentation(type), 0)) {
+ StoreRepresentation rep(type, WriteBarrierKind::kNoWriteBarrier);
+ return jsgraph()->machine()->Store(rep);
+ }
+ UnalignedStoreRepresentation rep(type);
+ return jsgraph()->machine()->UnalignedStore(rep);
+}
+
Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
Node* index, uint32_t offset,
uint32_t alignment,
@@ -3841,7 +3851,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;
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698