OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 | 10 |
(...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2765 } | 2765 } |
2766 | 2766 |
2767 | 2767 |
2768 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, | 2768 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, |
2769 Node* index, uint32_t offset, | 2769 Node* index, uint32_t offset, |
2770 uint32_t alignment, | 2770 uint32_t alignment, |
2771 wasm::WasmCodePosition position) { | 2771 wasm::WasmCodePosition position) { |
2772 Node* load; | 2772 Node* load; |
2773 | 2773 |
2774 // WASM semantics throw on OOB. Introduce explicit bounds check. | 2774 // WASM semantics throw on OOB. Introduce explicit bounds check. |
2775 BoundsCheckMem(memtype, index, offset, position); | 2775 if (!FLAG_wasm_trap_handler) { |
| 2776 BoundsCheckMem(memtype, index, offset, position); |
| 2777 } |
2776 bool aligned = static_cast<int>(alignment) >= | 2778 bool aligned = static_cast<int>(alignment) >= |
2777 ElementSizeLog2Of(memtype.representation()); | 2779 ElementSizeLog2Of(memtype.representation()); |
2778 | 2780 |
2779 if (aligned || | 2781 if (aligned || |
2780 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { | 2782 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { |
2781 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), | 2783 if (FLAG_wasm_trap_handler) { |
2782 MemBuffer(offset), index, *effect_, *control_); | 2784 Node* context = HeapConstant(module_->instance->context); |
| 2785 Node* position_node = jsgraph()->Int32Constant(position); |
| 2786 load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype), |
| 2787 MemBuffer(offset), index, context, position_node, |
| 2788 *effect_, *control_); |
| 2789 } else { |
| 2790 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), |
| 2791 MemBuffer(offset), index, *effect_, *control_); |
| 2792 } |
2783 } else { | 2793 } else { |
| 2794 DCHECK(!FLAG_wasm_trap_handler); |
2784 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), | 2795 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), |
2785 MemBuffer(offset), index, *effect_, *control_); | 2796 MemBuffer(offset), index, *effect_, *control_); |
2786 } | 2797 } |
2787 | 2798 |
2788 *effect_ = load; | 2799 *effect_ = load; |
2789 | 2800 |
2790 #if defined(V8_TARGET_BIG_ENDIAN) | 2801 #if defined(V8_TARGET_BIG_ENDIAN) |
2791 load = BuildChangeEndianness(load, memtype, type); | 2802 load = BuildChangeEndianness(load, memtype, type); |
2792 #endif | 2803 #endif |
2793 | 2804 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3270 function_->code_start_offset), | 3281 function_->code_start_offset), |
3271 compile_ms); | 3282 compile_ms); |
3272 } | 3283 } |
3273 | 3284 |
3274 return code; | 3285 return code; |
3275 } | 3286 } |
3276 | 3287 |
3277 } // namespace compiler | 3288 } // namespace compiler |
3278 } // namespace internal | 3289 } // namespace internal |
3279 } // namespace v8 | 3290 } // namespace v8 |
OLD | NEW |