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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 switch (node->opcode()) { | 100 switch (node->opcode()) { |
101 case IrOpcode::kInt64Constant: { | 101 case IrOpcode::kInt64Constant: { |
102 int64_t value = OpParameter<int64_t>(node); | 102 int64_t value = OpParameter<int64_t>(node); |
103 Node* low_node = graph()->NewNode( | 103 Node* low_node = graph()->NewNode( |
104 common()->Int32Constant(static_cast<int32_t>(value & 0xFFFFFFFF))); | 104 common()->Int32Constant(static_cast<int32_t>(value & 0xFFFFFFFF))); |
105 Node* high_node = graph()->NewNode( | 105 Node* high_node = graph()->NewNode( |
106 common()->Int32Constant(static_cast<int32_t>(value >> 32))); | 106 common()->Int32Constant(static_cast<int32_t>(value >> 32))); |
107 ReplaceNode(node, low_node, high_node); | 107 ReplaceNode(node, low_node, high_node); |
108 break; | 108 break; |
109 } | 109 } |
110 case IrOpcode::kLoad: { | 110 case IrOpcode::kLoad: |
111 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); | 111 case IrOpcode::kUnalignedLoad: { |
| 112 MachineRepresentation rep; |
| 113 if (node->opcode() == IrOpcode::kLoad) { |
| 114 rep = LoadRepresentationOf(node->op()).representation(); |
| 115 } else { |
| 116 DCHECK(node->opcode() == IrOpcode::kUnalignedLoad); |
| 117 rep = UnalignedLoadRepresentationOf(node->op()).representation(); |
| 118 } |
112 | 119 |
113 if (load_rep.representation() == MachineRepresentation::kWord64) { | 120 if (rep == MachineRepresentation::kWord64) { |
114 Node* base = node->InputAt(0); | 121 Node* base = node->InputAt(0); |
115 Node* index = node->InputAt(1); | 122 Node* index = node->InputAt(1); |
116 Node* index_high = | 123 Node* index_high = |
117 graph()->NewNode(machine()->Int32Add(), index, | 124 graph()->NewNode(machine()->Int32Add(), index, |
118 graph()->NewNode(common()->Int32Constant(4))); | 125 graph()->NewNode(common()->Int32Constant(4))); |
119 | 126 |
120 const Operator* load_op = machine()->Load(MachineType::Int32()); | 127 const Operator* load_op; |
| 128 if (node->opcode() == IrOpcode::kLoad) { |
| 129 load_op = machine()->Load(MachineType::Int32()); |
| 130 } else { |
| 131 DCHECK(node->opcode() == IrOpcode::kUnalignedLoad); |
| 132 load_op = machine()->UnalignedLoad(MachineType::Int32()).op(); |
| 133 } |
| 134 |
121 Node* high_node; | 135 Node* high_node; |
122 if (node->InputCount() > 2) { | 136 if (node->InputCount() > 2) { |
123 Node* effect_high = node->InputAt(2); | 137 Node* effect_high = node->InputAt(2); |
124 Node* control_high = node->InputAt(3); | 138 Node* control_high = node->InputAt(3); |
125 high_node = graph()->NewNode(load_op, base, index_high, effect_high, | 139 high_node = graph()->NewNode(load_op, base, index_high, effect_high, |
126 control_high); | 140 control_high); |
127 // change the effect change from old_node --> old_effect to | 141 // change the effect change from old_node --> old_effect to |
128 // old_node --> high_node --> old_effect. | 142 // old_node --> high_node --> old_effect. |
129 node->ReplaceInput(2, high_node); | 143 node->ReplaceInput(2, high_node); |
130 } else { | 144 } else { |
131 high_node = graph()->NewNode(load_op, base, index_high); | 145 high_node = graph()->NewNode(load_op, base, index_high); |
132 } | 146 } |
133 NodeProperties::ChangeOp(node, load_op); | 147 NodeProperties::ChangeOp(node, load_op); |
134 ReplaceNode(node, node, high_node); | 148 ReplaceNode(node, node, high_node); |
135 } else { | 149 } else { |
136 DefaultLowering(node); | 150 DefaultLowering(node); |
137 } | 151 } |
138 break; | 152 break; |
139 } | 153 } |
140 case IrOpcode::kStore: { | 154 case IrOpcode::kStore: |
141 StoreRepresentation store_rep = StoreRepresentationOf(node->op()); | 155 case IrOpcode::kUnalignedStore: { |
142 if (store_rep.representation() == MachineRepresentation::kWord64) { | 156 MachineRepresentation rep; |
| 157 if (node->opcode() == IrOpcode::kStore) { |
| 158 rep = StoreRepresentationOf(node->op()).representation(); |
| 159 } else { |
| 160 DCHECK(node->opcode() == IrOpcode::kUnalignedStore); |
| 161 rep = UnalignedStoreRepresentationOf(node->op()); |
| 162 } |
| 163 |
| 164 if (rep == MachineRepresentation::kWord64) { |
143 // We change the original store node to store the low word, and create | 165 // We change the original store node to store the low word, and create |
144 // a new store node to store the high word. The effect and control edges | 166 // a new store node to store the high word. The effect and control edges |
145 // are copied from the original store to the new store node, the effect | 167 // are copied from the original store to the new store node, the effect |
146 // edge of the original store is redirected to the new store. | 168 // edge of the original store is redirected to the new store. |
147 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); | |
148 | |
149 Node* base = node->InputAt(0); | 169 Node* base = node->InputAt(0); |
150 Node* index = node->InputAt(1); | 170 Node* index = node->InputAt(1); |
151 Node* index_high = | 171 Node* index_high = |
152 graph()->NewNode(machine()->Int32Add(), index, | 172 graph()->NewNode(machine()->Int32Add(), index, |
153 graph()->NewNode(common()->Int32Constant(4))); | 173 graph()->NewNode(common()->Int32Constant(4))); |
154 | 174 |
155 Node* value = node->InputAt(2); | 175 Node* value = node->InputAt(2); |
156 DCHECK(HasReplacementLow(value)); | 176 DCHECK(HasReplacementLow(value)); |
157 DCHECK(HasReplacementHigh(value)); | 177 DCHECK(HasReplacementHigh(value)); |
158 | 178 |
159 const Operator* store_op = machine()->Store(StoreRepresentation( | 179 const Operator* store_op; |
160 MachineRepresentation::kWord32, write_barrier_kind)); | 180 if (node->opcode() == IrOpcode::kStore) { |
| 181 WriteBarrierKind write_barrier_kind = |
| 182 StoreRepresentationOf(node->op()).write_barrier_kind(); |
| 183 store_op = machine()->Store(StoreRepresentation( |
| 184 MachineRepresentation::kWord32, write_barrier_kind)); |
| 185 } else { |
| 186 DCHECK(node->opcode() == IrOpcode::kUnalignedStore); |
| 187 store_op = |
| 188 machine()->UnalignedStore(MachineRepresentation::kWord32).op(); |
| 189 } |
161 | 190 |
162 Node* high_node; | 191 Node* high_node; |
163 if (node->InputCount() > 3) { | 192 if (node->InputCount() > 3) { |
164 Node* effect_high = node->InputAt(3); | 193 Node* effect_high = node->InputAt(3); |
165 Node* control_high = node->InputAt(4); | 194 Node* control_high = node->InputAt(4); |
166 high_node = graph()->NewNode(store_op, base, index_high, | 195 high_node = graph()->NewNode(store_op, base, index_high, |
167 GetReplacementHigh(value), effect_high, | 196 GetReplacementHigh(value), effect_high, |
168 control_high); | 197 control_high); |
169 node->ReplaceInput(3, high_node); | 198 node->ReplaceInput(3, high_node); |
170 | 199 |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 common()->Phi(MachineRepresentation::kWord32, value_count), | 847 common()->Phi(MachineRepresentation::kWord32, value_count), |
819 value_count + 1, inputs_low, false), | 848 value_count + 1, inputs_low, false), |
820 graph()->NewNode( | 849 graph()->NewNode( |
821 common()->Phi(MachineRepresentation::kWord32, value_count), | 850 common()->Phi(MachineRepresentation::kWord32, value_count), |
822 value_count + 1, inputs_high, false)); | 851 value_count + 1, inputs_high, false)); |
823 } | 852 } |
824 } | 853 } |
825 } // namespace compiler | 854 } // namespace compiler |
826 } // namespace internal | 855 } // namespace internal |
827 } // namespace v8 | 856 } // namespace v8 |
OLD | NEW |