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 27 matching lines...) Expand all Loading... | |
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 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2744 } | 2745 } |
2745 } | 2746 } |
2746 | 2747 |
2747 Node* cond = graph()->NewNode(jsgraph()->machine()->Uint32LessThan(), index, | 2748 Node* cond = graph()->NewNode(jsgraph()->machine()->Uint32LessThan(), index, |
2748 jsgraph()->RelocatableInt32Constant( | 2749 jsgraph()->RelocatableInt32Constant( |
2749 static_cast<uint32_t>(effective_size), | 2750 static_cast<uint32_t>(effective_size), |
2750 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 2751 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
2751 trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position); | 2752 trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond, position); |
2752 } | 2753 } |
2753 | 2754 |
2754 | |
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.
| |
2755 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, | 2755 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, |
2756 Node* index, uint32_t offset, | 2756 Node* index, uint32_t offset, |
2757 uint32_t alignment, | 2757 uint32_t alignment, |
2758 wasm::WasmCodePosition position) { | 2758 wasm::WasmCodePosition position) { |
2759 Node* load; | 2759 Node* load; |
2760 | 2760 |
2761 // WASM semantics throw on OOB. Introduce explicit bounds check. | 2761 // WASM semantics throw on OOB. Introduce explicit bounds check. |
2762 BoundsCheckMem(memtype, index, offset, position); | 2762 if (!FLAG_wasm_trap_handler) { |
2763 BoundsCheckMem(memtype, index, offset, position); | |
2764 } | |
2763 bool aligned = static_cast<int>(alignment) >= | 2765 bool aligned = static_cast<int>(alignment) >= |
2764 ElementSizeLog2Of(memtype.representation()); | 2766 ElementSizeLog2Of(memtype.representation()); |
2765 | 2767 |
2766 if (aligned || | 2768 if (aligned || |
2767 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { | 2769 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { |
2768 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), | 2770 if (!FLAG_wasm_trap_handler) { |
2769 MemBuffer(offset), index, *effect_, *control_); | 2771 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), |
2772 MemBuffer(offset), index, *effect_, *control_); | |
2773 } else { | |
2774 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
| |
2775 auto position_node = jsgraph()->Int32Constant(position); | |
2776 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*.
| |
2777 MemBuffer(offset), index, context, position_node, | |
2778 *effect_, *control_); | |
2779 } | |
2770 } else { | 2780 } else { |
2781 DCHECK(!FLAG_wasm_trap_handler); | |
2771 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), | 2782 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), |
2772 MemBuffer(offset), index, *effect_, *control_); | 2783 MemBuffer(offset), index, *effect_, *control_); |
2773 } | 2784 } |
2774 | 2785 |
2775 *effect_ = load; | 2786 *effect_ = load; |
2776 | 2787 |
2777 #if defined(V8_TARGET_BIG_ENDIAN) | 2788 #if defined(V8_TARGET_BIG_ENDIAN) |
2778 load = BuildChangeEndianness(load, memtype, type); | 2789 load = BuildChangeEndianness(load, memtype, type); |
2779 #endif | 2790 #endif |
2780 | 2791 |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3249 function_->code_start_offset), | 3260 function_->code_start_offset), |
3250 compile_ms); | 3261 compile_ms); |
3251 } | 3262 } |
3252 | 3263 |
3253 return code; | 3264 return code; |
3254 } | 3265 } |
3255 | 3266 |
3256 } // namespace compiler | 3267 } // namespace compiler |
3257 } // namespace internal | 3268 } // namespace internal |
3258 } // namespace v8 | 3269 } // namespace v8 |
OLD | NEW |