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

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

Issue 2705293011: MIPS[64]: Fix unaligned arguments storage in Wasm-to-interpreter entry (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | 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 da04b3d410d54c659e4a77ae63b22026ac3ac1d8..812e66d67c5ca17e8acca99e6e518766cdfb389c 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -2976,21 +2976,50 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64;
MachineRepresentation param_rep =
is_i64_as_two_params ? wasm::kWasmI32 : 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_);
+
+ int alignment = offset % (1 << ElementSizeLog2Of(param_rep));
titzer 2017/02/23 20:44:46 What about just aligning all arguments to 64-bits?
ivica.bogosavljevic 2017/02/24 09:37:56 Pfiffig!
+ bool offset_aligned = (alignment == 0);
+
+ if (offset_aligned ||
+ jsgraph()->machine()->UnalignedStoreSupported(
+ MachineType::TypeForRepresentation(param_rep), 0)) {
+ StoreRepresentation store_rep(param_rep,
+ WriteBarrierKind::kNoWriteBarrier);
+ *effect_ =
+ graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer,
+ Int32Constant(offset), param, *effect_, *control_);
+ } else {
+ UnalignedStoreRepresentation store_rep(param_rep);
+ *effect_ = graph()->NewNode(
+ jsgraph()->machine()->UnalignedStore(store_rep), arg_buffer,
+ Int32Constant(offset), param, *effect_, *control_);
+ }
+
offset += 1 << ElementSizeLog2Of(param_rep);
+
// TODO(clemensh): Respect endianess here. Might need to swap upper and
// lower word.
if (is_i64_as_two_params) {
// Also store the upper half.
param = Param(param_index++);
- StoreRepresentation store_rep(wasm::kWasmI32,
- WriteBarrierKind::kNoWriteBarrier);
- *effect_ =
- graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer,
- Int32Constant(offset), param, *effect_, *control_);
+
+ alignment = offset % (1 << ElementSizeLog2Of(wasm::kWasmI32));
+ offset_aligned = (alignment == 0);
+
+ if (offset_aligned ||
+ jsgraph()->machine()->UnalignedStoreSupported(
+ MachineType::TypeForRepresentation(wasm::kWasmI32), 0)) {
+ StoreRepresentation store_rep(wasm::kWasmI32,
+ WriteBarrierKind::kNoWriteBarrier);
+ *effect_ =
+ graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer,
+ Int32Constant(offset), param, *effect_, *control_);
+ } else {
+ UnalignedStoreRepresentation store_rep(wasm::kWasmI32);
+ *effect_ = graph()->NewNode(
+ jsgraph()->machine()->UnalignedStore(store_rep), arg_buffer,
+ Int32Constant(offset), param, *effect_, *control_);
+ }
offset += 1 << ElementSizeLog2Of(wasm::kWasmI32);
}
}
@@ -3894,7 +3923,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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698