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

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

Issue 1779713009: Implement optional turbofan UnalignedLoad and UnalignedStore operators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix failures in cctest/test-run-wasm-64/Run_Wasm_LoadStoreI64_sx due to missing implementation of U… Created 4 years, 9 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
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;

Powered by Google App Engine
This is Rietveld 408576698