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 3064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 if (!FLAG_wasm_trap_handler || !kTrapHandlerSupported) { | 3075 if (!FLAG_wasm_trap_handler || !kTrapHandlerSupported) { |
3076 BoundsCheckMem(memtype, index, offset, position); | 3076 BoundsCheckMem(memtype, index, offset, position); |
3077 } | 3077 } |
3078 bool aligned = static_cast<int>(alignment) >= | 3078 bool aligned = static_cast<int>(alignment) >= |
3079 ElementSizeLog2Of(memtype.representation()); | 3079 ElementSizeLog2Of(memtype.representation()); |
3080 | 3080 |
3081 if (aligned || | 3081 if (aligned || |
3082 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { | 3082 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { |
3083 if (FLAG_wasm_trap_handler && kTrapHandlerSupported) { | 3083 if (FLAG_wasm_trap_handler && kTrapHandlerSupported) { |
3084 DCHECK(FLAG_wasm_guard_pages); | 3084 DCHECK(FLAG_wasm_guard_pages); |
3085 Node* context = HeapConstant(module_->instance->context); | |
3086 Node* position_node = jsgraph()->Int32Constant(position); | 3085 Node* position_node = jsgraph()->Int32Constant(position); |
3087 load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype), | 3086 load = graph()->NewNode(jsgraph()->machine()->ProtectedLoad(memtype), |
3088 MemBuffer(offset), index, context, position_node, | 3087 MemBuffer(offset), index, position_node, *effect_, |
3089 *effect_, *control_); | 3088 *control_); |
3090 } else { | 3089 } else { |
3091 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), | 3090 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), |
3092 MemBuffer(offset), index, *effect_, *control_); | 3091 MemBuffer(offset), index, *effect_, *control_); |
3093 } | 3092 } |
3094 } else { | 3093 } else { |
3095 // TODO(eholk): Support unaligned loads with trap handlers. | 3094 // TODO(eholk): Support unaligned loads with trap handlers. |
3096 DCHECK(!FLAG_wasm_trap_handler || !kTrapHandlerSupported); | 3095 DCHECK(!FLAG_wasm_trap_handler || !kTrapHandlerSupported); |
3097 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), | 3096 load = graph()->NewNode(jsgraph()->machine()->UnalignedLoad(memtype), |
3098 MemBuffer(offset), index, *effect_, *control_); | 3097 MemBuffer(offset), index, *effect_, *control_); |
3099 } | 3098 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3135 bool aligned = static_cast<int>(alignment) >= | 3134 bool aligned = static_cast<int>(alignment) >= |
3136 ElementSizeLog2Of(memtype.representation()); | 3135 ElementSizeLog2Of(memtype.representation()); |
3137 | 3136 |
3138 #if defined(V8_TARGET_BIG_ENDIAN) | 3137 #if defined(V8_TARGET_BIG_ENDIAN) |
3139 val = BuildChangeEndianness(val, memtype); | 3138 val = BuildChangeEndianness(val, memtype); |
3140 #endif | 3139 #endif |
3141 | 3140 |
3142 if (aligned || | 3141 if (aligned || |
3143 jsgraph()->machine()->UnalignedStoreSupported(memtype, alignment)) { | 3142 jsgraph()->machine()->UnalignedStoreSupported(memtype, alignment)) { |
3144 if (FLAG_wasm_trap_handler && kTrapHandlerSupported) { | 3143 if (FLAG_wasm_trap_handler && kTrapHandlerSupported) { |
3145 Node* context = HeapConstant(module_->instance->context); | |
3146 Node* position_node = jsgraph()->Int32Constant(position); | 3144 Node* position_node = jsgraph()->Int32Constant(position); |
3147 store = graph()->NewNode( | 3145 store = graph()->NewNode( |
3148 jsgraph()->machine()->ProtectedStore(memtype.representation()), | 3146 jsgraph()->machine()->ProtectedStore(memtype.representation()), |
3149 MemBuffer(offset), index, val, context, position_node, *effect_, | 3147 MemBuffer(offset), index, val, position_node, *effect_, *control_); |
3150 *control_); | |
3151 } else { | 3148 } else { |
3152 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); | 3149 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); |
3153 store = | 3150 store = |
3154 graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset), | 3151 graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset), |
3155 index, val, *effect_, *control_); | 3152 index, val, *effect_, *control_); |
3156 } | 3153 } |
3157 } else { | 3154 } else { |
3158 // TODO(eholk): Support unaligned stores with trap handlers. | 3155 // TODO(eholk): Support unaligned stores with trap handlers. |
3159 DCHECK(!FLAG_wasm_trap_handler || !kTrapHandlerSupported); | 3156 DCHECK(!FLAG_wasm_trap_handler || !kTrapHandlerSupported); |
3160 UnalignedStoreRepresentation rep(memtype.representation()); | 3157 UnalignedStoreRepresentation rep(memtype.representation()); |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3693 Smi::FromInt(instruction.instr_offset)); | 3690 Smi::FromInt(instruction.instr_offset)); |
3694 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset, | 3691 fn_protected->set(Code::kTrapDataSize * i + Code::kTrapLandingOffset, |
3695 Smi::FromInt(instruction.landing_offset)); | 3692 Smi::FromInt(instruction.landing_offset)); |
3696 } | 3693 } |
3697 return fn_protected; | 3694 return fn_protected; |
3698 } | 3695 } |
3699 | 3696 |
3700 } // namespace compiler | 3697 } // namespace compiler |
3701 } // namespace internal | 3698 } // namespace internal |
3702 } // namespace v8 | 3699 } // namespace v8 |
OLD | NEW |