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/js-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 142 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
143 Revisit(graph()->end()); | 143 Revisit(graph()->end()); |
144 | 144 |
145 node->TrimInputCount(0); | 145 node->TrimInputCount(0); |
146 NodeProperties::ChangeOp(node, common()->Dead()); | 146 NodeProperties::ChangeOp(node, common()->Dead()); |
147 return Changed(node); | 147 return Changed(node); |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { | 151 Reduction JSIntrinsicLowering::ReduceDoubleHi(Node* node) { |
| 152 // Tell the compiler to assume number input. |
| 153 Node* renamed = graph()->NewNode(common()->Guard(Type::Number()), |
| 154 node->InputAt(0), graph()->start()); |
| 155 node->ReplaceInput(0, renamed); |
152 return Change(node, machine()->Float64ExtractHighWord32()); | 156 return Change(node, machine()->Float64ExtractHighWord32()); |
153 } | 157 } |
154 | 158 |
155 | 159 |
156 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { | 160 Reduction JSIntrinsicLowering::ReduceDoubleLo(Node* node) { |
| 161 // Tell the compiler to assume number input. |
| 162 Node* renamed = graph()->NewNode(common()->Guard(Type::Number()), |
| 163 node->InputAt(0), graph()->start()); |
| 164 node->ReplaceInput(0, renamed); |
157 return Change(node, machine()->Float64ExtractLowWord32()); | 165 return Change(node, machine()->Float64ExtractLowWord32()); |
158 } | 166 } |
159 | 167 |
160 | 168 |
161 Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) { | 169 Reduction JSIntrinsicLowering::ReduceIncrementStatsCounter(Node* node) { |
162 if (!FLAG_native_code_counters) return ChangeToUndefined(node); | 170 if (!FLAG_native_code_counters) return ChangeToUndefined(node); |
163 HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0)); | 171 HeapObjectMatcher m(NodeProperties::GetValueInput(node, 0)); |
164 if (!m.HasValue() || !m.Value()->IsString()) { | 172 if (!m.HasValue() || !m.Value()->IsString()) { |
165 return ChangeToUndefined(node); | 173 return ChangeToUndefined(node); |
166 } | 174 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 245 } |
238 | 246 |
239 | 247 |
240 Reduction JSIntrinsicLowering::ReduceMathFloor(Node* node) { | 248 Reduction JSIntrinsicLowering::ReduceMathFloor(Node* node) { |
241 if (!machine()->Float64RoundDown().IsSupported()) return NoChange(); | 249 if (!machine()->Float64RoundDown().IsSupported()) return NoChange(); |
242 return Change(node, machine()->Float64RoundDown().op()); | 250 return Change(node, machine()->Float64RoundDown().op()); |
243 } | 251 } |
244 | 252 |
245 | 253 |
246 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { | 254 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { |
| 255 // Tell the compiler to assume number input. |
| 256 Node* renamed = graph()->NewNode(common()->Guard(Type::Number()), |
| 257 node->InputAt(0), graph()->start()); |
| 258 node->ReplaceInput(0, renamed); |
247 return Change(node, machine()->Float64Sqrt()); | 259 return Change(node, machine()->Float64Sqrt()); |
248 } | 260 } |
249 | 261 |
250 | 262 |
251 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { | 263 Reduction JSIntrinsicLowering::ReduceValueOf(Node* node) { |
252 // if (%_IsSmi(value)) { | 264 // if (%_IsSmi(value)) { |
253 // return value; | 265 // return value; |
254 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { | 266 // } else if (%_GetInstanceType(%_GetMap(value)) == JS_VALUE_TYPE) { |
255 // return %_GetValue(value); | 267 // return %_GetValue(value); |
256 // } else { | 268 // } else { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 ReplaceWithValue(node, value); | 409 ReplaceWithValue(node, value); |
398 return Replace(value); | 410 return Replace(value); |
399 } | 411 } |
400 | 412 |
401 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); | 413 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); |
402 Node* branch = | 414 Node* branch = |
403 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); | 415 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control); |
404 | 416 |
405 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 417 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
406 Node* etrue = effect; | 418 Node* etrue = effect; |
407 Node* vtrue = value; | 419 Node* vtrue = |
| 420 graph()->NewNode(common()->Guard(type_cache_.kSmi), value, if_true); |
408 | 421 |
409 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 422 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
410 Node* efalse = effect; | 423 Node* efalse = effect; |
411 Node* vfalse; | 424 Node* vfalse; |
412 { | 425 { |
413 vfalse = efalse = | 426 vfalse = efalse = |
414 graph()->NewNode(javascript()->CallRuntime(Runtime::kToInteger), value, | 427 graph()->NewNode(javascript()->CallRuntime(Runtime::kToInteger), value, |
415 context, frame_state, efalse, if_false); | 428 context, frame_state, efalse, if_false); |
| 429 // TODO(jarin) Intersect the type with integers? |
| 430 NodeProperties::SetType(vfalse, NodeProperties::GetType(node)); |
| 431 |
416 if_false = graph()->NewNode(common()->IfSuccess(), vfalse); | 432 if_false = graph()->NewNode(common()->IfSuccess(), vfalse); |
417 } | 433 } |
418 | 434 |
419 control = graph()->NewNode(common()->Merge(2), if_true, if_false); | 435 control = graph()->NewNode(common()->Merge(2), if_true, if_false); |
420 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); | 436 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control); |
421 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), | 437 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
422 vtrue, vfalse, control); | 438 vtrue, vfalse, control); |
| 439 |
423 // TODO(bmeurer, mstarzinger): Rewire IfException inputs to {vfalse}. | 440 // TODO(bmeurer, mstarzinger): Rewire IfException inputs to {vfalse}. |
424 ReplaceWithValue(node, value, effect, control); | 441 ReplaceWithValue(node, value, effect, control); |
425 return Changed(value); | 442 return Changed(value); |
426 } | 443 } |
427 | 444 |
428 | 445 |
429 Reduction JSIntrinsicLowering::ReduceToName(Node* node) { | 446 Reduction JSIntrinsicLowering::ReduceToName(Node* node) { |
430 NodeProperties::ChangeOp(node, javascript()->ToName()); | 447 NodeProperties::ChangeOp(node, javascript()->ToName()); |
431 return Changed(node); | 448 return Changed(node); |
432 } | 449 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 } | 620 } |
604 | 621 |
605 | 622 |
606 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 623 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
607 return jsgraph()->simplified(); | 624 return jsgraph()->simplified(); |
608 } | 625 } |
609 | 626 |
610 } // namespace compiler | 627 } // namespace compiler |
611 } // namespace internal | 628 } // namespace internal |
612 } // namespace v8 | 629 } // namespace v8 |
OLD | NEW |