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

Side by Side Diff: src/compiler/effect-control-linearizer.cc

Issue 2646763003: [turbofan] Optimize typeof o === "object" checks. (Closed)
Patch Set: Address comment. Created 3 years, 11 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
OLDNEW
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/effect-control-linearizer.h" 5 #include "src/compiler/effect-control-linearizer.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/access-builder.h" 8 #include "src/compiler/access-builder.h"
9 #include "src/compiler/compiler-source-position-table.h" 9 #include "src/compiler/compiler-source-position-table.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 break; 710 break;
711 case IrOpcode::kTruncateTaggedToWord32: 711 case IrOpcode::kTruncateTaggedToWord32:
712 result = LowerTruncateTaggedToWord32(node); 712 result = LowerTruncateTaggedToWord32(node);
713 break; 713 break;
714 case IrOpcode::kCheckedTruncateTaggedToWord32: 714 case IrOpcode::kCheckedTruncateTaggedToWord32:
715 result = LowerCheckedTruncateTaggedToWord32(node, frame_state); 715 result = LowerCheckedTruncateTaggedToWord32(node, frame_state);
716 break; 716 break;
717 case IrOpcode::kObjectIsCallable: 717 case IrOpcode::kObjectIsCallable:
718 result = LowerObjectIsCallable(node); 718 result = LowerObjectIsCallable(node);
719 break; 719 break;
720 case IrOpcode::kObjectIsNonCallable:
721 result = LowerObjectIsNonCallable(node);
722 break;
720 case IrOpcode::kObjectIsNumber: 723 case IrOpcode::kObjectIsNumber:
721 result = LowerObjectIsNumber(node); 724 result = LowerObjectIsNumber(node);
722 break; 725 break;
723 case IrOpcode::kObjectIsReceiver: 726 case IrOpcode::kObjectIsReceiver:
724 result = LowerObjectIsReceiver(node); 727 result = LowerObjectIsReceiver(node);
725 break; 728 break;
726 case IrOpcode::kObjectIsSmi: 729 case IrOpcode::kObjectIsSmi:
727 result = LowerObjectIsSmi(node); 730 result = LowerObjectIsSmi(node);
728 break; 731 break;
729 case IrOpcode::kObjectIsString: 732 case IrOpcode::kObjectIsString:
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 (1 << Map::kIsUndetectable)))); 1684 (1 << Map::kIsUndetectable))));
1682 __ Goto(&done, vfalse); 1685 __ Goto(&done, vfalse);
1683 1686
1684 __ Bind(&if_smi); 1687 __ Bind(&if_smi);
1685 __ Goto(&done, __ Int32Constant(0)); 1688 __ Goto(&done, __ Int32Constant(0));
1686 1689
1687 __ Bind(&done); 1690 __ Bind(&done);
1688 return done.PhiAt(0); 1691 return done.PhiAt(0);
1689 } 1692 }
1690 1693
1694 Node* EffectControlLinearizer::LowerObjectIsNonCallable(Node* node) {
1695 Node* value = node->InputAt(0);
1696
1697 auto if_primitive = __ MakeDeferredLabel<2>();
1698 auto done = __ MakeLabel<2>(MachineRepresentation::kBit);
1699
1700 Node* check0 = ObjectIsSmi(value);
1701 __ GotoIf(check0, &if_primitive);
1702
1703 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value);
1704 Node* value_instance_type =
1705 __ LoadField(AccessBuilder::ForMapInstanceType(), value_map);
1706 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
1707 Node* check1 = __ Uint32LessThanOrEqual(
1708 __ Uint32Constant(FIRST_JS_RECEIVER_TYPE), value_instance_type);
1709 __ GotoUnless(check1, &if_primitive);
1710
1711 Node* value_bit_field =
1712 __ LoadField(AccessBuilder::ForMapBitField(), value_map);
1713 Node* check2 = __ Word32Equal(
1714 __ Int32Constant(0),
1715 __ Word32And(value_bit_field, __ Int32Constant(1 << Map::kIsCallable)));
1716 __ Goto(&done, check2);
1717
1718 __ Bind(&if_primitive);
1719 __ Goto(&done, __ Int32Constant(0));
1720
1721 __ Bind(&done);
1722 return done.PhiAt(0);
1723 }
1724
1691 Node* EffectControlLinearizer::LowerObjectIsNumber(Node* node) { 1725 Node* EffectControlLinearizer::LowerObjectIsNumber(Node* node) {
1692 Node* value = node->InputAt(0); 1726 Node* value = node->InputAt(0);
1693 1727
1694 auto if_smi = __ MakeLabel<1>(); 1728 auto if_smi = __ MakeLabel<1>();
1695 auto done = __ MakeLabel<2>(MachineRepresentation::kBit); 1729 auto done = __ MakeLabel<2>(MachineRepresentation::kBit);
1696 1730
1697 __ GotoIf(ObjectIsSmi(value), &if_smi); 1731 __ GotoIf(ObjectIsSmi(value), &if_smi);
1698 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value); 1732 Node* value_map = __ LoadField(AccessBuilder::ForMap(), value);
1699 __ Goto(&done, __ WordEqual(value_map, __ HeapNumberMapConstant())); 1733 __ Goto(&done, __ WordEqual(value_map, __ HeapNumberMapConstant()));
1700 1734
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 return isolate()->factory(); 2749 return isolate()->factory();
2716 } 2750 }
2717 2751
2718 Isolate* EffectControlLinearizer::isolate() const { 2752 Isolate* EffectControlLinearizer::isolate() const {
2719 return jsgraph()->isolate(); 2753 return jsgraph()->isolate();
2720 } 2754 }
2721 2755
2722 } // namespace compiler 2756 } // namespace compiler
2723 } // namespace internal 2757 } // namespace internal
2724 } // namespace v8 2758 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698