| 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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 Reduction ChangeLowering::ChangeFloat64ToTagged(Node* value, Node* control) { | 153 Reduction ChangeLowering::ChangeFloat64ToTagged(Node* value, Node* control) { |
| 154 return Replace(AllocateHeapNumberWithValue(value, control)); | 154 return Replace(AllocateHeapNumberWithValue(value, control)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) { | 158 Reduction ChangeLowering::ChangeInt32ToTagged(Node* value, Node* control) { |
| 159 if (machine()->Is64() || | 159 if (machine()->Is64() || |
| 160 NodeProperties::GetBounds(value).upper->Is(Type::SignedSmall())) { | 160 NodeProperties::GetType(value)->Is(Type::SignedSmall())) { |
| 161 return Replace(ChangeInt32ToSmi(value)); | 161 return Replace(ChangeInt32ToSmi(value)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), value, value); | 164 Node* add = graph()->NewNode(machine()->Int32AddWithOverflow(), value, value); |
| 165 | 165 |
| 166 Node* ovf = graph()->NewNode(common()->Projection(1), add); | 166 Node* ovf = graph()->NewNode(common()->Projection(1), add); |
| 167 Node* branch = | 167 Node* branch = |
| 168 graph()->NewNode(common()->Branch(BranchHint::kFalse), ovf, control); | 168 graph()->NewNode(common()->Branch(BranchHint::kFalse), ovf, control); |
| 169 | 169 |
| 170 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 170 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 171 Node* vtrue = | 171 Node* vtrue = |
| 172 AllocateHeapNumberWithValue(ChangeInt32ToFloat64(value), if_true); | 172 AllocateHeapNumberWithValue(ChangeInt32ToFloat64(value), if_true); |
| 173 | 173 |
| 174 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 174 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 175 Node* vfalse = graph()->NewNode(common()->Projection(0), add); | 175 Node* vfalse = graph()->NewNode(common()->Projection(0), add); |
| 176 | 176 |
| 177 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 177 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 178 Node* phi = | 178 Node* phi = |
| 179 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge); | 179 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge); |
| 180 | 180 |
| 181 return Replace(phi); | 181 return Replace(phi); |
| 182 } | 182 } |
| 183 | 183 |
| 184 | 184 |
| 185 Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control, | 185 Reduction ChangeLowering::ChangeTaggedToUI32(Node* value, Node* control, |
| 186 Signedness signedness) { | 186 Signedness signedness) { |
| 187 if (NodeProperties::GetBounds(value).upper->Is(Type::TaggedSigned())) { | 187 if (NodeProperties::GetType(value)->Is(Type::TaggedSigned())) { |
| 188 return Replace(ChangeSmiToInt32(value)); | 188 return Replace(ChangeSmiToInt32(value)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 const MachineType type = (signedness == kSigned) ? kMachInt32 : kMachUint32; | 191 const MachineType type = (signedness == kSigned) ? kMachInt32 : kMachUint32; |
| 192 const Operator* op = (signedness == kSigned) | 192 const Operator* op = (signedness == kSigned) |
| 193 ? machine()->ChangeFloat64ToInt32() | 193 ? machine()->ChangeFloat64ToInt32() |
| 194 : machine()->ChangeFloat64ToUint32(); | 194 : machine()->ChangeFloat64ToUint32(); |
| 195 | 195 |
| 196 if (NodeProperties::GetBounds(value).upper->Is(Type::TaggedPointer())) { | 196 if (NodeProperties::GetType(value)->Is(Type::TaggedPointer())) { |
| 197 return Replace(graph()->NewNode(op, LoadHeapNumberValue(value, control))); | 197 return Replace(graph()->NewNode(op, LoadHeapNumberValue(value, control))); |
| 198 } | 198 } |
| 199 | 199 |
| 200 Node* check = TestNotSmi(value); | 200 Node* check = TestNotSmi(value); |
| 201 Node* branch = | 201 Node* branch = |
| 202 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 202 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
| 203 | 203 |
| 204 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 204 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 205 Node* vtrue = graph()->NewNode(op, LoadHeapNumberValue(value, if_true)); | 205 Node* vtrue = graph()->NewNode(op, LoadHeapNumberValue(value, if_true)); |
| 206 | 206 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 305 |
| 306 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 306 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 307 Node* phi = | 307 Node* phi = |
| 308 graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); | 308 graph()->NewNode(common()->Phi(kMachFloat64, 2), vtrue, vfalse, merge); |
| 309 | 309 |
| 310 return Replace(phi); | 310 return Replace(phi); |
| 311 } | 311 } |
| 312 | 312 |
| 313 | 313 |
| 314 Reduction ChangeLowering::ChangeUint32ToTagged(Node* value, Node* control) { | 314 Reduction ChangeLowering::ChangeUint32ToTagged(Node* value, Node* control) { |
| 315 if (NodeProperties::GetBounds(value).upper->Is(Type::UnsignedSmall())) { | 315 if (NodeProperties::GetType(value)->Is(Type::UnsignedSmall())) { |
| 316 return Replace(ChangeUint32ToSmi(value)); | 316 return Replace(ChangeUint32ToSmi(value)); |
| 317 } | 317 } |
| 318 | 318 |
| 319 Node* check = graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, | 319 Node* check = graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, |
| 320 SmiMaxValueConstant()); | 320 SmiMaxValueConstant()); |
| 321 Node* branch = | 321 Node* branch = |
| 322 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 322 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
| 323 | 323 |
| 324 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 324 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 325 Node* vtrue = ChangeUint32ToSmi(value); | 325 Node* vtrue = ChangeUint32ToSmi(value); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 | 349 |
| 350 MachineOperatorBuilder* ChangeLowering::machine() const { | 350 MachineOperatorBuilder* ChangeLowering::machine() const { |
| 351 return jsgraph()->machine(); | 351 return jsgraph()->machine(); |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace compiler | 354 } // namespace compiler |
| 355 } // namespace internal | 355 } // namespace internal |
| 356 } // namespace v8 | 356 } // namespace v8 |
| OLD | NEW |