| Index: src/compiler/wasm-compiler.cc
|
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
|
| index c4bde203fa71de431a8f4c0d7382348b3928504e..8aaa8b55fa97f58162508389c03462a3772226e6 100644
|
| --- a/src/compiler/wasm-compiler.cc
|
| +++ b/src/compiler/wasm-compiler.cc
|
| @@ -2266,9 +2266,8 @@ void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
|
| trap_->AddTrapIfFalse(kTrapMemOutOfBounds, cond);
|
| }
|
|
|
| -
|
| Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
|
| - Node* index, uint32_t offset) {
|
| + Node* index, uint32_t offset, bool aligned) {
|
| Node* load;
|
|
|
| if (module_ && module_->asm_js()) {
|
| @@ -2280,8 +2279,14 @@ Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
|
| } else {
|
| // WASM semantics throw on OOB. Introduce explicit bounds check.
|
| BoundsCheckMem(memtype, index, offset);
|
| - load = graph()->NewNode(jsgraph()->machine()->Load(memtype),
|
| - MemBuffer(offset), index, *effect_, *control_);
|
| + if (aligned ||
|
| + !jsgraph()->machine()->UnalignedLoad(memtype).IsSupported()) {
|
| + load = graph()->NewNode(jsgraph()->machine()->Load(memtype),
|
| + MemBuffer(offset), index, *effect_, *control_);
|
| + } else {
|
| + load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype).op(),
|
| + MemBuffer(offset), index, *effect_, *control_);
|
| + }
|
| }
|
|
|
| *effect_ = load;
|
| @@ -2302,9 +2307,8 @@ Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
|
| return load;
|
| }
|
|
|
| -
|
| Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index,
|
| - uint32_t offset, Node* val) {
|
| + uint32_t offset, bool aligned, Node* val) {
|
| Node* store;
|
| if (module_ && module_->asm_js()) {
|
| // asm.js semantics use CheckedStore (i.e. ignore OOB writes).
|
| @@ -2316,10 +2320,20 @@ Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index,
|
| } else {
|
| // WASM semantics throw on OOB. Introduce explicit bounds check.
|
| BoundsCheckMem(memtype, index, offset);
|
| - StoreRepresentation rep(memtype.representation(), kNoWriteBarrier);
|
| - store =
|
| - graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset),
|
| - index, val, *effect_, *control_);
|
| + if (aligned ||
|
| + !jsgraph()
|
| + ->machine()
|
| + ->UnalignedStore(memtype.representation())
|
| + .IsSupported()) {
|
| + StoreRepresentation rep(memtype.representation(), kNoWriteBarrier);
|
| + store =
|
| + graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset),
|
| + index, val, *effect_, *control_);
|
| + } else {
|
| + store = graph()->NewNode(
|
| + jsgraph()->machine()->UnalignedStore(memtype.representation()).op(),
|
| + MemBuffer(offset), index, val, *effect_, *control_);
|
| + }
|
| }
|
| *effect_ = store;
|
| return store;
|
|
|