| Index: src/compiler/wasm-compiler.cc
|
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
|
| index c4bde203fa71de431a8f4c0d7382348b3928504e..e68e8dc2632459fceb0a3d9c707c930e1b0dff18 100644
|
| --- a/src/compiler/wasm-compiler.cc
|
| +++ b/src/compiler/wasm-compiler.cc
|
| @@ -2266,9 +2266,9 @@ 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,
|
| + uint32_t alignment) {
|
| Node* load;
|
|
|
| if (module_ && module_->asm_js()) {
|
| @@ -2280,8 +2280,15 @@ 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_);
|
| + bool aligned = alignment >= ElementSizeLog2Of(memtype.representation());
|
| + 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 +2309,9 @@ 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, uint32_t alignment,
|
| + Node* val) {
|
| Node* store;
|
| if (module_ && module_->asm_js()) {
|
| // asm.js semantics use CheckedStore (i.e. ignore OOB writes).
|
| @@ -2316,10 +2323,21 @@ 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_);
|
| + bool aligned = alignment >= ElementSizeLog2Of(memtype.representation());
|
| + 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;
|
|
|