Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: src/compiler/change-lowering.cc

Issue 1872143002: [turbofan] Improve lowering of ObjectIs<Type> somewhat. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/address-map.h" 7 #include "src/address-map.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 614
615 Node* ChangeLowering::LoadMapInstanceType(Node* map) { 615 Node* ChangeLowering::LoadMapInstanceType(Node* map) {
616 return graph()->NewNode( 616 return graph()->NewNode(
617 machine()->Load(MachineType::Uint8()), map, 617 machine()->Load(MachineType::Uint8()), map,
618 jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag), 618 jsgraph()->IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag),
619 graph()->start(), graph()->start()); 619 graph()->start(), graph()->start());
620 } 620 }
621 621
622 Reduction ChangeLowering::ObjectIsNumber(Node* node) { 622 Reduction ChangeLowering::ObjectIsNumber(Node* node) {
623 Node* input = NodeProperties::GetValueInput(node, 0); 623 Node* input = NodeProperties::GetValueInput(node, 0);
624 // TODO(bmeurer): Optimize somewhat based on input type. 624 Type* input_type = NodeProperties::GetType(input);
625 Node* check = IsSmi(input); 625 if (input_type->Is(Type::TaggedPointer())) {
626 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); 626 node->ReplaceInput(0, LoadHeapObjectMap(input, graph()->start()));
627 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 627 node->AppendInput(
628 Node* vtrue = jsgraph()->Int32Constant(1); 628 graph()->zone(),
629 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 629 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map()));
630 Node* vfalse = graph()->NewNode( 630 NodeProperties::ChangeOp(node, machine()->WordEqual());
631 machine()->WordEqual(), LoadHeapObjectMap(input, if_false), 631 } else {
632 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map())); 632 Node* check = IsSmi(input);
633 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); 633 Node* branch =
634 node->ReplaceInput(0, vtrue); 634 graph()->NewNode(common()->Branch(), check, graph()->start());
635 node->AppendInput(graph()->zone(), vfalse); 635 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
636 node->AppendInput(graph()->zone(), control); 636 Node* vtrue = jsgraph()->Int32Constant(1);
637 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); 637 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
638 Node* vfalse = graph()->NewNode(
639 machine()->WordEqual(), LoadHeapObjectMap(input, if_false),
640 jsgraph()->HeapConstant(isolate()->factory()->heap_number_map()));
641 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
642 node->ReplaceInput(0, vtrue);
643 node->AppendInput(graph()->zone(), vfalse);
644 node->AppendInput(graph()->zone(), control);
645 NodeProperties::ChangeOp(node,
646 common()->Phi(MachineRepresentation::kBit, 2));
647 }
638 return Changed(node); 648 return Changed(node);
639 } 649 }
640 650
641 Reduction ChangeLowering::ObjectIsReceiver(Node* node) { 651 Reduction ChangeLowering::ObjectIsReceiver(Node* node) {
652 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
642 Node* input = NodeProperties::GetValueInput(node, 0); 653 Node* input = NodeProperties::GetValueInput(node, 0);
643 // TODO(bmeurer): Optimize somewhat based on input type. 654 Type* input_type = NodeProperties::GetType(input);
644 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); 655 if (input_type->Is(Type::TaggedPointer())) {
645 Node* check = IsSmi(input); 656 node->ReplaceInput(0, jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE));
646 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); 657 node->AppendInput(graph()->zone(), LoadMapInstanceType(LoadHeapObjectMap(
647 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 658 input, graph()->start())));
648 Node* vtrue = jsgraph()->Int32Constant(0); 659 NodeProperties::ChangeOp(node, machine()->Uint32LessThanOrEqual());
649 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 660 } else {
650 Node* vfalse = 661 Node* check = IsSmi(input);
651 graph()->NewNode(machine()->Uint32LessThanOrEqual(), 662 Node* branch =
652 jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE), 663 graph()->NewNode(common()->Branch(), check, graph()->start());
653 LoadMapInstanceType(LoadHeapObjectMap(input, if_false))); 664 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
654 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); 665 Node* vtrue = jsgraph()->Int32Constant(0);
655 node->ReplaceInput(0, vtrue); 666 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
656 node->AppendInput(graph()->zone(), vfalse); 667 Node* vfalse = graph()->NewNode(
657 node->AppendInput(graph()->zone(), control); 668 machine()->Uint32LessThanOrEqual(),
658 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); 669 jsgraph()->Uint32Constant(FIRST_JS_RECEIVER_TYPE),
670 LoadMapInstanceType(LoadHeapObjectMap(input, if_false)));
671 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
672 node->ReplaceInput(0, vtrue);
673 node->AppendInput(graph()->zone(), vfalse);
674 node->AppendInput(graph()->zone(), control);
675 NodeProperties::ChangeOp(node,
676 common()->Phi(MachineRepresentation::kBit, 2));
677 }
659 return Changed(node); 678 return Changed(node);
660 } 679 }
661 680
662 Reduction ChangeLowering::ObjectIsUndetectable(Node* node) { 681 Reduction ChangeLowering::ObjectIsUndetectable(Node* node) {
663 Node* input = NodeProperties::GetValueInput(node, 0); 682 Node* input = NodeProperties::GetValueInput(node, 0);
664 // TODO(bmeurer): Optimize somewhat based on input type. 683 Type* input_type = NodeProperties::GetType(input);
665 Node* check = IsSmi(input); 684 if (input_type->Is(Type::TaggedPointer())) {
666 Node* branch = graph()->NewNode(common()->Branch(), check, graph()->start()); 685 node->ReplaceInput(
667 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 686 0, graph()->NewNode(
668 Node* vtrue = jsgraph()->Int32Constant(0); 687 machine()->Word32Equal(),
669 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 688 graph()->NewNode(
670 Node* vfalse = graph()->NewNode( 689 machine()->Word32And(),
671 machine()->Word32Equal(), 690 jsgraph()->Uint32Constant(1 << Map::kIsUndetectable),
672 graph()->NewNode( 691 LoadMapBitField(LoadHeapObjectMap(input, graph()->start()))),
673 machine()->Word32Equal(), 692 jsgraph()->Int32Constant(0)));
674 graph()->NewNode(machine()->Word32And(), 693 node->AppendInput(graph()->zone(), jsgraph()->Int32Constant(0));
675 jsgraph()->Uint32Constant(1 << Map::kIsUndetectable), 694 NodeProperties::ChangeOp(node, machine()->Word32Equal());
676 LoadMapBitField(LoadHeapObjectMap(input, if_false))), 695 } else {
677 jsgraph()->Int32Constant(0)), 696 Node* check = IsSmi(input);
678 jsgraph()->Int32Constant(0)); 697 Node* branch =
679 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false); 698 graph()->NewNode(common()->Branch(), check, graph()->start());
680 node->ReplaceInput(0, vtrue); 699 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
681 node->AppendInput(graph()->zone(), vfalse); 700 Node* vtrue = jsgraph()->Int32Constant(0);
682 node->AppendInput(graph()->zone(), control); 701 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
683 NodeProperties::ChangeOp(node, common()->Phi(MachineRepresentation::kBit, 2)); 702 Node* vfalse = graph()->NewNode(
703 machine()->Word32Equal(),
704 graph()->NewNode(
705 machine()->Word32Equal(),
706 graph()->NewNode(
707 machine()->Word32And(),
708 jsgraph()->Uint32Constant(1 << Map::kIsUndetectable),
709 LoadMapBitField(LoadHeapObjectMap(input, if_false))),
710 jsgraph()->Int32Constant(0)),
711 jsgraph()->Int32Constant(0));
712 Node* control = graph()->NewNode(common()->Merge(2), if_true, if_false);
713 node->ReplaceInput(0, vtrue);
714 node->AppendInput(graph()->zone(), vfalse);
715 node->AppendInput(graph()->zone(), control);
716 NodeProperties::ChangeOp(node,
717 common()->Phi(MachineRepresentation::kBit, 2));
718 }
684 return Changed(node); 719 return Changed(node);
685 } 720 }
686 721
687 Reduction ChangeLowering::ObjectIsSmi(Node* node) { 722 Reduction ChangeLowering::ObjectIsSmi(Node* node) {
688 node->ReplaceInput(0, 723 node->ReplaceInput(0,
689 graph()->NewNode(machine()->WordAnd(), node->InputAt(0), 724 graph()->NewNode(machine()->WordAnd(), node->InputAt(0),
690 jsgraph()->IntPtrConstant(kSmiTagMask))); 725 jsgraph()->IntPtrConstant(kSmiTagMask)));
691 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag)); 726 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
692 NodeProperties::ChangeOp(node, machine()->WordEqual()); 727 NodeProperties::ChangeOp(node, machine()->WordEqual());
693 return Changed(node); 728 return Changed(node);
(...skipping 10 matching lines...) Expand all
704 } 739 }
705 740
706 741
707 MachineOperatorBuilder* ChangeLowering::machine() const { 742 MachineOperatorBuilder* ChangeLowering::machine() const {
708 return jsgraph()->machine(); 743 return jsgraph()->machine();
709 } 744 }
710 745
711 } // namespace compiler 746 } // namespace compiler
712 } // namespace internal 747 } // namespace internal
713 } // namespace v8 748 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698