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/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 276 |
277 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { | 277 Reduction JSIntrinsicLowering::ReduceMathSqrt(Node* node) { |
278 return Change(node, machine()->Float64Sqrt()); | 278 return Change(node, machine()->Float64Sqrt()); |
279 } | 279 } |
280 | 280 |
281 | 281 |
282 Reduction JSIntrinsicLowering::ReduceSeqStringGetChar( | 282 Reduction JSIntrinsicLowering::ReduceSeqStringGetChar( |
283 Node* node, String::Encoding encoding) { | 283 Node* node, String::Encoding encoding) { |
284 Node* effect = NodeProperties::GetEffectInput(node); | 284 Node* effect = NodeProperties::GetEffectInput(node); |
285 Node* control = NodeProperties::GetControlInput(node); | 285 Node* control = NodeProperties::GetControlInput(node); |
| 286 RelaxControls(node); |
286 node->ReplaceInput(2, effect); | 287 node->ReplaceInput(2, effect); |
287 node->ReplaceInput(3, control); | 288 node->ReplaceInput(3, control); |
288 node->TrimInputCount(4); | 289 node->TrimInputCount(4); |
289 NodeProperties::ChangeOp( | 290 NodeProperties::ChangeOp( |
290 node, | 291 node, |
291 simplified()->LoadElement(AccessBuilder::ForSeqStringChar(encoding))); | 292 simplified()->LoadElement(AccessBuilder::ForSeqStringChar(encoding))); |
292 RelaxControls(node); | |
293 return Changed(node); | 293 return Changed(node); |
294 } | 294 } |
295 | 295 |
296 | 296 |
297 Reduction JSIntrinsicLowering::ReduceSeqStringSetChar( | 297 Reduction JSIntrinsicLowering::ReduceSeqStringSetChar( |
298 Node* node, String::Encoding encoding) { | 298 Node* node, String::Encoding encoding) { |
299 // Note: The intrinsic has a strange argument order, so we need to reshuffle. | 299 // Note: The intrinsic has a strange argument order, so we need to reshuffle. |
300 Node* index = NodeProperties::GetValueInput(node, 0); | 300 Node* index = NodeProperties::GetValueInput(node, 0); |
301 Node* chr = NodeProperties::GetValueInput(node, 1); | 301 Node* chr = NodeProperties::GetValueInput(node, 1); |
302 Node* string = NodeProperties::GetValueInput(node, 2); | 302 Node* string = NodeProperties::GetValueInput(node, 2); |
303 Node* effect = NodeProperties::GetEffectInput(node); | 303 Node* effect = NodeProperties::GetEffectInput(node); |
304 Node* control = NodeProperties::GetControlInput(node); | 304 Node* control = NodeProperties::GetControlInput(node); |
| 305 ReplaceWithValue(node, string, node); |
| 306 NodeProperties::RemoveType(node); |
305 node->ReplaceInput(0, string); | 307 node->ReplaceInput(0, string); |
306 node->ReplaceInput(1, index); | 308 node->ReplaceInput(1, index); |
307 node->ReplaceInput(2, chr); | 309 node->ReplaceInput(2, chr); |
308 node->ReplaceInput(3, effect); | 310 node->ReplaceInput(3, effect); |
309 node->ReplaceInput(4, control); | 311 node->ReplaceInput(4, control); |
310 node->TrimInputCount(5); | 312 node->TrimInputCount(5); |
311 NodeProperties::ChangeOp( | 313 NodeProperties::ChangeOp( |
312 node, | 314 node, |
313 simplified()->StoreElement(AccessBuilder::ForSeqStringChar(encoding))); | 315 simplified()->StoreElement(AccessBuilder::ForSeqStringChar(encoding))); |
314 NodeProperties::RemoveType(node); | |
315 ReplaceWithValue(node, string, node); | |
316 return Changed(node); | 316 return Changed(node); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { | 320 Reduction JSIntrinsicLowering::ReduceStringGetLength(Node* node) { |
321 Node* value = NodeProperties::GetValueInput(node, 0); | 321 Node* value = NodeProperties::GetValueInput(node, 0); |
322 Node* effect = NodeProperties::GetEffectInput(node); | 322 Node* effect = NodeProperties::GetEffectInput(node); |
323 Node* control = NodeProperties::GetControlInput(node); | 323 Node* control = NodeProperties::GetControlInput(node); |
324 return Change(node, simplified()->LoadField( | 324 return Change(node, simplified()->LoadField( |
325 AccessBuilder::ForStringLength(graph()->zone())), | 325 AccessBuilder::ForStringLength(graph()->zone())), |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 NodeProperties::ChangeOp( | 545 NodeProperties::ChangeOp( |
546 node, | 546 node, |
547 javascript()->CallFunction(params.arity(), NO_CALL_FUNCTION_FLAGS, STRICT, | 547 javascript()->CallFunction(params.arity(), NO_CALL_FUNCTION_FLAGS, STRICT, |
548 VectorSlotPair(), ALLOW_TAIL_CALLS)); | 548 VectorSlotPair(), ALLOW_TAIL_CALLS)); |
549 return Changed(node); | 549 return Changed(node); |
550 } | 550 } |
551 | 551 |
552 | 552 |
553 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 553 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
554 Node* b) { | 554 Node* b) { |
| 555 RelaxControls(node); |
555 node->ReplaceInput(0, a); | 556 node->ReplaceInput(0, a); |
556 node->ReplaceInput(1, b); | 557 node->ReplaceInput(1, b); |
557 node->TrimInputCount(2); | 558 node->TrimInputCount(2); |
558 NodeProperties::ChangeOp(node, op); | 559 NodeProperties::ChangeOp(node, op); |
559 RelaxControls(node); | |
560 return Changed(node); | 560 return Changed(node); |
561 } | 561 } |
562 | 562 |
563 | 563 |
564 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 564 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
565 Node* b, Node* c) { | 565 Node* b, Node* c) { |
| 566 RelaxControls(node); |
566 node->ReplaceInput(0, a); | 567 node->ReplaceInput(0, a); |
567 node->ReplaceInput(1, b); | 568 node->ReplaceInput(1, b); |
568 node->ReplaceInput(2, c); | 569 node->ReplaceInput(2, c); |
569 node->TrimInputCount(3); | 570 node->TrimInputCount(3); |
570 NodeProperties::ChangeOp(node, op); | 571 NodeProperties::ChangeOp(node, op); |
571 RelaxControls(node); | |
572 return Changed(node); | 572 return Changed(node); |
573 } | 573 } |
574 | 574 |
575 | 575 |
576 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 576 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
577 Node* b, Node* c, Node* d) { | 577 Node* b, Node* c, Node* d) { |
| 578 RelaxControls(node); |
578 node->ReplaceInput(0, a); | 579 node->ReplaceInput(0, a); |
579 node->ReplaceInput(1, b); | 580 node->ReplaceInput(1, b); |
580 node->ReplaceInput(2, c); | 581 node->ReplaceInput(2, c); |
581 node->ReplaceInput(3, d); | 582 node->ReplaceInput(3, d); |
582 node->TrimInputCount(4); | 583 node->TrimInputCount(4); |
583 NodeProperties::ChangeOp(node, op); | 584 NodeProperties::ChangeOp(node, op); |
584 RelaxControls(node); | |
585 return Changed(node); | 585 return Changed(node); |
586 } | 586 } |
587 | 587 |
588 | 588 |
589 Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) { | 589 Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) { |
590 ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect); | 590 ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect); |
591 return Changed(node); | 591 return Changed(node); |
592 } | 592 } |
593 | 593 |
594 | 594 |
595 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } | 595 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } |
596 | 596 |
597 | 597 |
598 CommonOperatorBuilder* JSIntrinsicLowering::common() const { | 598 CommonOperatorBuilder* JSIntrinsicLowering::common() const { |
599 return jsgraph()->common(); | 599 return jsgraph()->common(); |
600 } | 600 } |
601 | 601 |
602 JSOperatorBuilder* JSIntrinsicLowering::javascript() const { | 602 JSOperatorBuilder* JSIntrinsicLowering::javascript() const { |
603 return jsgraph_->javascript(); | 603 return jsgraph_->javascript(); |
604 } | 604 } |
605 | 605 |
606 | 606 |
607 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 607 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
608 return jsgraph()->machine(); | 608 return jsgraph()->machine(); |
609 } | 609 } |
610 | 610 |
611 } // namespace compiler | 611 } // namespace compiler |
612 } // namespace internal | 612 } // namespace internal |
613 } // namespace v8 | 613 } // namespace v8 |
OLD | NEW |