 Chromium Code Reviews
 Chromium Code Reviews Issue 2301833004:
  [wasm] Trap handling: ProtectedLoad instruction  (Closed)
    
  
    Issue 2301833004:
  [wasm] Trap handling: ProtectedLoad instruction  (Closed) 
  | Index: src/compiler/wasm-compiler.cc | 
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc | 
| index 35e78b6aa2a617ad7241d5e2b33e10419e8dc920..b023b3d23ecc68f136c48a236a24d6da416f20e7 100644 | 
| --- a/src/compiler/wasm-compiler.cc | 
| +++ b/src/compiler/wasm-compiler.cc | 
| @@ -45,6 +45,7 @@ | 
| namespace v8 { | 
| namespace internal { | 
| + | 
| namespace compiler { | 
| namespace { | 
| @@ -2751,7 +2752,6 @@ void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index, | 
| trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position); | 
| } | 
| - | 
| 
Mircea Trofin
2016/09/02 04:05:45
We want to keep this space here. Did "git cl uploa
 
Eric Holk
2016/09/02 20:05:32
Done.
 | 
| Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, | 
| Node* index, uint32_t offset, | 
| uint32_t alignment, | 
| @@ -2759,15 +2759,26 @@ Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, | 
| Node* load; | 
| // WASM semantics throw on OOB. Introduce explicit bounds check. | 
| - BoundsCheckMem(memtype, index, offset, position); | 
| + if (!FLAG_wasm_trap_handler) { | 
| + BoundsCheckMem(memtype, index, offset, position); | 
| + } | 
| bool aligned = static_cast<int>(alignment) >= | 
| ElementSizeLog2Of(memtype.representation()); | 
| if (aligned || | 
| jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { | 
| - load = graph()->NewNode(jsgraph()->machine()->Load(memtype), | 
| - MemBuffer(offset), index, *effect_, *control_); | 
| + if (!FLAG_wasm_trap_handler) { | 
| + load = graph()->NewNode(jsgraph()->machine()->Load(memtype), | 
| + MemBuffer(offset), index, *effect_, *control_); | 
| + } else { | 
| + auto* context = HeapConstant(module_->instance->context); | 
| 
Mircea Trofin
2016/09/02 04:05:45
HeapConstant* instead of auto. AFAIK, auto would h
 
Eric Holk
2016/09/02 20:05:32
Done. It was actually Node* instead of HeapConstan
 | 
| + auto position_node = jsgraph()->Int32Constant(position); | 
| + load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype), | 
| 
Mircea Trofin
2016/09/02 04:05:45
What's position_node's type? (i.e. please no auto)
 
Eric Holk
2016/09/02 20:05:32
Done. This was also Node*.
 | 
| + MemBuffer(offset), index, context, position_node, | 
| + *effect_, *control_); | 
| + } | 
| } else { | 
| + DCHECK(!FLAG_wasm_trap_handler); | 
| load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), | 
| MemBuffer(offset), index, *effect_, *control_); | 
| } |