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

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2301833004: [wasm] Trap handling: ProtectedLoad instruction (Closed)
Patch Set: Manual Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 38
39 // TODO(titzer): pull WASM_64 up to a common header. 39 // TODO(titzer): pull WASM_64 up to a common header.
40 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64 40 #if !V8_TARGET_ARCH_32_BIT || V8_TARGET_ARCH_X64
41 #define WASM_64 1 41 #define WASM_64 1
42 #else 42 #else
43 #define WASM_64 0 43 #define WASM_64 0
44 #endif 44 #endif
45 45
46 namespace v8 { 46 namespace v8 {
47 namespace internal { 47 namespace internal {
48
48 namespace compiler { 49 namespace compiler {
49 50
50 namespace { 51 namespace {
51 const Operator* UnsupportedOpcode(wasm::WasmOpcode opcode) { 52 const Operator* UnsupportedOpcode(wasm::WasmOpcode opcode) {
52 V8_Fatal(__FILE__, __LINE__, "Unsupported opcode #%d:%s", opcode, 53 V8_Fatal(__FILE__, __LINE__, "Unsupported opcode #%d:%s", opcode,
53 wasm::WasmOpcodes::OpcodeName(opcode)); 54 wasm::WasmOpcodes::OpcodeName(opcode));
54 return nullptr; 55 return nullptr;
55 } 56 }
56 57
57 void MergeControlToEnd(JSGraph* jsgraph, Node* node) { 58 void MergeControlToEnd(JSGraph* jsgraph, Node* node) {
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 } 2753 }
2753 2754
2754 2755
2755 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, 2756 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
2756 Node* index, uint32_t offset, 2757 Node* index, uint32_t offset,
2757 uint32_t alignment, 2758 uint32_t alignment,
2758 wasm::WasmCodePosition position) { 2759 wasm::WasmCodePosition position) {
2759 Node* load; 2760 Node* load;
2760 2761
2761 // WASM semantics throw on OOB. Introduce explicit bounds check. 2762 // WASM semantics throw on OOB. Introduce explicit bounds check.
2762 BoundsCheckMem(memtype, index, offset, position); 2763 if (!FLAG_wasm_trap_handler) {
2764 BoundsCheckMem(memtype, index, offset, position);
2765 }
2763 bool aligned = static_cast<int>(alignment) >= 2766 bool aligned = static_cast<int>(alignment) >=
2764 ElementSizeLog2Of(memtype.representation()); 2767 ElementSizeLog2Of(memtype.representation());
2765 2768
2766 if (aligned || 2769 if (aligned ||
2767 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { 2770 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) {
2768 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), 2771 if (!FLAG_wasm_trap_handler) {
titzer 2016/09/08 17:06:35 Flip sense of if?
Eric Holk 2016/09/08 21:11:56 Done.
2769 MemBuffer(offset), index, *effect_, *control_); 2772 load = graph()->NewNode(jsgraph()->machine()->Load(memtype),
2773 MemBuffer(offset), index, *effect_, *control_);
2774 } else {
2775 Node* context = HeapConstant(module_->instance->context);
2776 Node* position_node = jsgraph()->Int32Constant(position);
2777 load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype),
2778 MemBuffer(offset), index, context, position_node,
2779 *effect_, *control_);
2780 }
2770 } else { 2781 } else {
2782 DCHECK(!FLAG_wasm_trap_handler);
2771 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), 2783 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype),
2772 MemBuffer(offset), index, *effect_, *control_); 2784 MemBuffer(offset), index, *effect_, *control_);
2773 } 2785 }
2774 2786
2775 *effect_ = load; 2787 *effect_ = load;
2776 2788
2777 #if defined(V8_TARGET_BIG_ENDIAN) 2789 #if defined(V8_TARGET_BIG_ENDIAN)
2778 load = BuildChangeEndianness(load, memtype, type); 2790 load = BuildChangeEndianness(load, memtype, type);
2779 #endif 2791 #endif
2780 2792
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
3249 function_->code_start_offset), 3261 function_->code_start_offset),
3250 compile_ms); 3262 compile_ms);
3251 } 3263 }
3252 3264
3253 return code; 3265 return code;
3254 } 3266 }
3255 3267
3256 } // namespace compiler 3268 } // namespace compiler
3257 } // namespace internal 3269 } // namespace internal
3258 } // namespace v8 3270 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698