OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/diamond.h" | 7 #include "src/compiler/diamond.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 switch (node->opcode()) { | 125 switch (node->opcode()) { |
126 case IrOpcode::kInt64Constant: { | 126 case IrOpcode::kInt64Constant: { |
127 int64_t value = OpParameter<int64_t>(node); | 127 int64_t value = OpParameter<int64_t>(node); |
128 Node* low_node = graph()->NewNode( | 128 Node* low_node = graph()->NewNode( |
129 common()->Int32Constant(static_cast<int32_t>(value & 0xFFFFFFFF))); | 129 common()->Int32Constant(static_cast<int32_t>(value & 0xFFFFFFFF))); |
130 Node* high_node = graph()->NewNode( | 130 Node* high_node = graph()->NewNode( |
131 common()->Int32Constant(static_cast<int32_t>(value >> 32))); | 131 common()->Int32Constant(static_cast<int32_t>(value >> 32))); |
132 ReplaceNode(node, low_node, high_node); | 132 ReplaceNode(node, low_node, high_node); |
133 break; | 133 break; |
134 } | 134 } |
135 case IrOpcode::kLoad: { | 135 case IrOpcode::kLoad: |
136 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); | 136 case IrOpcode::kUnalignedLoad: { |
| 137 MachineRepresentation rep; |
| 138 if (node->opcode() == IrOpcode::kLoad) { |
| 139 rep = LoadRepresentationOf(node->op()).representation(); |
| 140 } else { |
| 141 DCHECK(node->opcode() == IrOpcode::kUnalignedLoad); |
| 142 rep = UnalignedLoadRepresentationOf(node->op()).representation(); |
| 143 } |
137 | 144 |
138 if (load_rep.representation() == MachineRepresentation::kWord64) { | 145 if (rep == MachineRepresentation::kWord64) { |
139 Node* base = node->InputAt(0); | 146 Node* base = node->InputAt(0); |
140 Node* index = node->InputAt(1); | 147 Node* index = node->InputAt(1); |
141 Node* index_low; | 148 Node* index_low; |
142 Node* index_high; | 149 Node* index_high; |
143 GetIndexNodes(index, index_low, index_high); | 150 GetIndexNodes(index, index_low, index_high); |
144 const Operator* load_op = machine()->Load(MachineType::Int32()); | 151 const Operator* load_op; |
| 152 |
| 153 if (node->opcode() == IrOpcode::kLoad) { |
| 154 load_op = machine()->Load(MachineType::Int32()); |
| 155 } else { |
| 156 DCHECK(node->opcode() == IrOpcode::kUnalignedLoad); |
| 157 load_op = machine()->UnalignedLoad(MachineType::Int32()); |
| 158 } |
| 159 |
145 Node* high_node; | 160 Node* high_node; |
146 if (node->InputCount() > 2) { | 161 if (node->InputCount() > 2) { |
147 Node* effect_high = node->InputAt(2); | 162 Node* effect_high = node->InputAt(2); |
148 Node* control_high = node->InputAt(3); | 163 Node* control_high = node->InputAt(3); |
149 high_node = graph()->NewNode(load_op, base, index_high, effect_high, | 164 high_node = graph()->NewNode(load_op, base, index_high, effect_high, |
150 control_high); | 165 control_high); |
151 // change the effect change from old_node --> old_effect to | 166 // change the effect change from old_node --> old_effect to |
152 // old_node --> high_node --> old_effect. | 167 // old_node --> high_node --> old_effect. |
153 node->ReplaceInput(2, high_node); | 168 node->ReplaceInput(2, high_node); |
154 } else { | 169 } else { |
155 high_node = graph()->NewNode(load_op, base, index_high); | 170 high_node = graph()->NewNode(load_op, base, index_high); |
156 } | 171 } |
157 node->ReplaceInput(1, index_low); | 172 node->ReplaceInput(1, index_low); |
158 NodeProperties::ChangeOp(node, load_op); | 173 NodeProperties::ChangeOp(node, load_op); |
159 ReplaceNode(node, node, high_node); | 174 ReplaceNode(node, node, high_node); |
160 } else { | 175 } else { |
161 DefaultLowering(node); | 176 DefaultLowering(node); |
162 } | 177 } |
163 break; | 178 break; |
164 } | 179 } |
165 case IrOpcode::kStore: { | 180 case IrOpcode::kStore: |
166 StoreRepresentation store_rep = StoreRepresentationOf(node->op()); | 181 case IrOpcode::kUnalignedStore: { |
167 if (store_rep.representation() == MachineRepresentation::kWord64) { | 182 MachineRepresentation rep; |
| 183 if (node->opcode() == IrOpcode::kStore) { |
| 184 rep = StoreRepresentationOf(node->op()).representation(); |
| 185 } else { |
| 186 DCHECK(node->opcode() == IrOpcode::kUnalignedStore); |
| 187 rep = UnalignedStoreRepresentationOf(node->op()); |
| 188 } |
| 189 |
| 190 if (rep == MachineRepresentation::kWord64) { |
168 // We change the original store node to store the low word, and create | 191 // We change the original store node to store the low word, and create |
169 // a new store node to store the high word. The effect and control edges | 192 // a new store node to store the high word. The effect and control edges |
170 // are copied from the original store to the new store node, the effect | 193 // are copied from the original store to the new store node, the effect |
171 // edge of the original store is redirected to the new store. | 194 // edge of the original store is redirected to the new store. |
172 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); | |
173 | |
174 Node* base = node->InputAt(0); | 195 Node* base = node->InputAt(0); |
175 Node* index = node->InputAt(1); | 196 Node* index = node->InputAt(1); |
176 Node* index_low; | 197 Node* index_low; |
177 Node* index_high; | 198 Node* index_high; |
178 GetIndexNodes(index, index_low, index_high); | 199 GetIndexNodes(index, index_low, index_high); |
179 Node* value = node->InputAt(2); | 200 Node* value = node->InputAt(2); |
180 DCHECK(HasReplacementLow(value)); | 201 DCHECK(HasReplacementLow(value)); |
181 DCHECK(HasReplacementHigh(value)); | 202 DCHECK(HasReplacementHigh(value)); |
182 | 203 |
183 const Operator* store_op = machine()->Store(StoreRepresentation( | 204 const Operator* store_op; |
184 MachineRepresentation::kWord32, write_barrier_kind)); | 205 if (node->opcode() == IrOpcode::kStore) { |
| 206 WriteBarrierKind write_barrier_kind = |
| 207 StoreRepresentationOf(node->op()).write_barrier_kind(); |
| 208 store_op = machine()->Store(StoreRepresentation( |
| 209 MachineRepresentation::kWord32, write_barrier_kind)); |
| 210 } else { |
| 211 DCHECK(node->opcode() == IrOpcode::kUnalignedStore); |
| 212 store_op = machine()->UnalignedStore(MachineRepresentation::kWord32); |
| 213 } |
185 | 214 |
186 Node* high_node; | 215 Node* high_node; |
187 if (node->InputCount() > 3) { | 216 if (node->InputCount() > 3) { |
188 Node* effect_high = node->InputAt(3); | 217 Node* effect_high = node->InputAt(3); |
189 Node* control_high = node->InputAt(4); | 218 Node* control_high = node->InputAt(4); |
190 high_node = graph()->NewNode(store_op, base, index_high, | 219 high_node = graph()->NewNode(store_op, base, index_high, |
191 GetReplacementHigh(value), effect_high, | 220 GetReplacementHigh(value), effect_high, |
192 control_high); | 221 control_high); |
193 node->ReplaceInput(3, high_node); | 222 node->ReplaceInput(3, high_node); |
194 | 223 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 common()->Phi(MachineRepresentation::kWord32, value_count), | 866 common()->Phi(MachineRepresentation::kWord32, value_count), |
838 value_count + 1, inputs_low, false), | 867 value_count + 1, inputs_low, false), |
839 graph()->NewNode( | 868 graph()->NewNode( |
840 common()->Phi(MachineRepresentation::kWord32, value_count), | 869 common()->Phi(MachineRepresentation::kWord32, value_count), |
841 value_count + 1, inputs_high, false)); | 870 value_count + 1, inputs_high, false)); |
842 } | 871 } |
843 } | 872 } |
844 } // namespace compiler | 873 } // namespace compiler |
845 } // namespace internal | 874 } // namespace internal |
846 } // namespace v8 | 875 } // namespace v8 |
OLD | NEW |