OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 ASSERT(op() != Token::EQ); | 742 ASSERT(op() != Token::EQ); |
743 ASSERT(op() != Token::NE); | 743 ASSERT(op() != Token::NE); |
744 ASSERT(op() != Token::EQ_STRICT); | 744 ASSERT(op() != Token::EQ_STRICT); |
745 ASSERT(op() != Token::NE_STRICT); | 745 ASSERT(op() != Token::NE_STRICT); |
746 ASSERT(op() != Token::INSTANCEOF); | 746 ASSERT(op() != Token::INSTANCEOF); |
747 ASSERT(op() != Token::IN); | 747 ASSERT(op() != Token::IN); |
748 return !left()->IsPrimitive() || !right()->IsPrimitive(); | 748 return !left()->IsPrimitive() || !right()->IsPrimitive(); |
749 } | 749 } |
750 | 750 |
751 | 751 |
752 static inline void MarkIfNotLive(Expression* expr, List<AstNode*>* stack) { | |
753 if (!expr->is_live()) { | |
754 expr->mark_as_live(); | |
755 stack->Add(expr); | |
756 } | |
757 } | |
758 | |
759 | |
760 // Overloaded functions for marking children of live code as live. | |
761 void VariableProxy::ProcessNonLiveChildren( | |
762 List<AstNode*>* stack, | |
763 ZoneList<Expression*>* body_definitions, | |
764 int variable_count) { | |
765 // A reference to a stack-allocated variable depends on all the | |
766 // definitions reaching it. | |
767 BitVector* defs = reaching_definitions(); | |
768 if (defs != NULL) { | |
769 ASSERT(var()->IsStackAllocated()); | |
770 // The first variable_count definitions are the initial parameter and | |
771 // local declarations. | |
772 for (int i = variable_count; i < defs->length(); i++) { | |
773 if (defs->Contains(i)) { | |
774 MarkIfNotLive(body_definitions->at(i - variable_count), stack); | |
775 } | |
776 } | |
777 } | |
778 } | |
779 | |
780 | |
781 void Literal::ProcessNonLiveChildren(List<AstNode*>* stack, | |
782 ZoneList<Expression*>* body_definitions, | |
783 int variable_count) { | |
784 // Leaf node, no children. | |
785 } | |
786 | |
787 | |
788 void Assignment::ProcessNonLiveChildren( | |
789 List<AstNode*>* stack, | |
790 ZoneList<Expression*>* body_definitions, | |
791 int variable_count) { | |
792 Property* prop = target()->AsProperty(); | |
793 VariableProxy* proxy = target()->AsVariableProxy(); | |
794 | |
795 if (prop != NULL) { | |
796 if (!prop->key()->IsPropertyName()) MarkIfNotLive(prop->key(), stack); | |
797 MarkIfNotLive(prop->obj(), stack); | |
798 } else if (proxy == NULL) { | |
799 // Must be a reference error. | |
800 ASSERT(!target()->IsValidLeftHandSide()); | |
801 MarkIfNotLive(target(), stack); | |
802 } else if (is_compound()) { | |
803 // A variable assignment so lhs is an operand to the operation. | |
804 MarkIfNotLive(target(), stack); | |
805 } | |
806 MarkIfNotLive(value(), stack); | |
807 } | |
808 | |
809 | |
810 void Property::ProcessNonLiveChildren(List<AstNode*>* stack, | |
811 ZoneList<Expression*>* body_definitions, | |
812 int variable_count) { | |
813 if (!key()->IsPropertyName()) MarkIfNotLive(key(), stack); | |
814 MarkIfNotLive(obj(), stack); | |
815 } | |
816 | |
817 | |
818 void Call::ProcessNonLiveChildren(List<AstNode*>* stack, | |
819 ZoneList<Expression*>* body_definitions, | |
820 int variable_count) { | |
821 ZoneList<Expression*>* args = arguments(); | |
822 for (int i = args->length() - 1; i >= 0; i--) { | |
823 MarkIfNotLive(args->at(i), stack); | |
824 } | |
825 MarkIfNotLive(expression(), stack); | |
826 } | |
827 | |
828 | |
829 void UnaryOperation::ProcessNonLiveChildren( | |
830 List<AstNode*>* stack, | |
831 ZoneList<Expression*>* body_definitions, | |
832 int variable_count) { | |
833 MarkIfNotLive(expression(), stack); | |
834 } | |
835 | |
836 | |
837 void CountOperation::ProcessNonLiveChildren( | |
838 List<AstNode*>* stack, | |
839 ZoneList<Expression*>* body_definitions, | |
840 int variable_count) { | |
841 MarkIfNotLive(expression(), stack); | |
842 } | |
843 | |
844 | |
845 void BinaryOperation::ProcessNonLiveChildren( | |
846 List<AstNode*>* stack, | |
847 ZoneList<Expression*>* body_definitions, | |
848 int variable_count) { | |
849 MarkIfNotLive(right(), stack); | |
850 MarkIfNotLive(left(), stack); | |
851 } | |
852 | |
853 | |
854 void CompareOperation::ProcessNonLiveChildren( | |
855 List<AstNode*>* stack, | |
856 ZoneList<Expression*>* body_definitions, | |
857 int variable_count) { | |
858 MarkIfNotLive(right(), stack); | |
859 MarkIfNotLive(left(), stack); | |
860 } | |
861 | |
862 | |
863 // Implementation of a copy visitor. The visitor create a deep copy | 752 // Implementation of a copy visitor. The visitor create a deep copy |
864 // of ast nodes. Nodes that do not require a deep copy are copied | 753 // of ast nodes. Nodes that do not require a deep copy are copied |
865 // with the default copy constructor. | 754 // with the default copy constructor. |
866 | 755 |
867 AstNode::AstNode(AstNode* other) : num_(kNoNumber) { | 756 AstNode::AstNode(AstNode* other) : num_(kNoNumber) { |
868 // AST node number should be unique. Assert that we only copy AstNodes | 757 // AST node number should be unique. Assert that we only copy AstNodes |
869 // before node numbers are assigned. | 758 // before node numbers are assigned. |
870 ASSERT(other->num_ == kNoNumber); | 759 ASSERT(other->num_ == kNoNumber); |
871 } | 760 } |
872 | 761 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 SetStackOverflow(); | 1126 SetStackOverflow(); |
1238 } | 1127 } |
1239 | 1128 |
1240 | 1129 |
1241 void CopyAstVisitor::VisitDeclaration(Declaration* decl) { | 1130 void CopyAstVisitor::VisitDeclaration(Declaration* decl) { |
1242 UNREACHABLE(); | 1131 UNREACHABLE(); |
1243 } | 1132 } |
1244 | 1133 |
1245 | 1134 |
1246 } } // namespace v8::internal | 1135 } } // namespace v8::internal |
OLD | NEW |