| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); | 654 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); |
| 655 Handle<String> name = Handle<String>::cast(lit_key->handle()); | 655 Handle<String> name = Handle<String>::cast(lit_key->handle()); |
| 656 ZoneMapList* types = oracle->LoadReceiverTypes(this, name); | 656 ZoneMapList* types = oracle->LoadReceiverTypes(this, name); |
| 657 receiver_types_ = types; | 657 receiver_types_ = types; |
| 658 } | 658 } |
| 659 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { | 659 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { |
| 660 is_string_access_ = true; | 660 is_string_access_ = true; |
| 661 } else if (is_monomorphic_) { | 661 } else if (is_monomorphic_) { |
| 662 monomorphic_receiver_type_ = oracle->LoadMonomorphicReceiverType(this); | 662 monomorphic_receiver_type_ = oracle->LoadMonomorphicReceiverType(this); |
| 663 } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) { | 663 } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) { |
| 664 receiver_types_ = new ZoneMapList(kMaxKeyedPolymorphism); | 664 receiver_types_ = ZoneMapList::New(ZONE, kMaxKeyedPolymorphism); |
| 665 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); | 665 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 | 668 |
| 669 | 669 |
| 670 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 670 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 671 Property* prop = target()->AsProperty(); | 671 Property* prop = target()->AsProperty(); |
| 672 ASSERT(prop != NULL); | 672 ASSERT(prop != NULL); |
| 673 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); | 673 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); |
| 674 if (prop->key()->IsPropertyName()) { | 674 if (prop->key()->IsPropertyName()) { |
| 675 Literal* lit_key = prop->key()->AsLiteral(); | 675 Literal* lit_key = prop->key()->AsLiteral(); |
| 676 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); | 676 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); |
| 677 Handle<String> name = Handle<String>::cast(lit_key->handle()); | 677 Handle<String> name = Handle<String>::cast(lit_key->handle()); |
| 678 ZoneMapList* types = oracle->StoreReceiverTypes(this, name); | 678 ZoneMapList* types = oracle->StoreReceiverTypes(this, name); |
| 679 receiver_types_ = types; | 679 receiver_types_ = types; |
| 680 } else if (is_monomorphic_) { | 680 } else if (is_monomorphic_) { |
| 681 // Record receiver type for monomorphic keyed stores. | 681 // Record receiver type for monomorphic keyed stores. |
| 682 monomorphic_receiver_type_ = oracle->StoreMonomorphicReceiverType(this); | 682 monomorphic_receiver_type_ = oracle->StoreMonomorphicReceiverType(this); |
| 683 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { | 683 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { |
| 684 receiver_types_ = new ZoneMapList(kMaxKeyedPolymorphism); | 684 receiver_types_ = ZoneMapList::New(ZONE, kMaxKeyedPolymorphism); |
| 685 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); | 685 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 | 688 |
| 689 | 689 |
| 690 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 690 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 691 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); | 691 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); |
| 692 if (is_monomorphic_) { | 692 if (is_monomorphic_) { |
| 693 // Record receiver type for monomorphic keyed stores. | 693 // Record receiver type for monomorphic keyed stores. |
| 694 monomorphic_receiver_type_ = oracle->StoreMonomorphicReceiverType(this); | 694 monomorphic_receiver_type_ = oracle->StoreMonomorphicReceiverType(this); |
| 695 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { | 695 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { |
| 696 receiver_types_ = new ZoneMapList(kMaxKeyedPolymorphism); | 696 receiver_types_ = ZoneMapList::New(ZONE, kMaxKeyedPolymorphism); |
| 697 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); | 697 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); |
| 698 } | 698 } |
| 699 } | 699 } |
| 700 | 700 |
| 701 | 701 |
| 702 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 702 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 703 TypeInfo info = oracle->SwitchType(this); | 703 TypeInfo info = oracle->SwitchType(this); |
| 704 if (info.IsSmi()) { | 704 if (info.IsSmi()) { |
| 705 compare_type_ = SMI_ONLY; | 705 compare_type_ = SMI_ONLY; |
| 706 } else if (info.IsNonPrimitive()) { | 706 } else if (info.IsNonPrimitive()) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 } | 987 } |
| 988 | 988 |
| 989 | 989 |
| 990 // Convert regular expression trees to a simple sexp representation. | 990 // Convert regular expression trees to a simple sexp representation. |
| 991 // This representation should be different from the input grammar | 991 // This representation should be different from the input grammar |
| 992 // in as many cases as possible, to make it more difficult for incorrect | 992 // in as many cases as possible, to make it more difficult for incorrect |
| 993 // parses to look as correct ones which is likely if the input and | 993 // parses to look as correct ones which is likely if the input and |
| 994 // output formats are alike. | 994 // output formats are alike. |
| 995 class RegExpUnparser: public RegExpVisitor { | 995 class RegExpUnparser: public RegExpVisitor { |
| 996 public: | 996 public: |
| 997 RegExpUnparser(); | 997 explicit RegExpUnparser(Zone* zone); |
| 998 void VisitCharacterRange(CharacterRange that); | 998 void VisitCharacterRange(CharacterRange that); |
| 999 SmartPointer<const char> ToString() { return stream_.ToCString(); } | 999 SmartPointer<const char> ToString() { return stream_.ToCString(); } |
| 1000 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); | 1000 #define MAKE_CASE(Name) virtual void* Visit##Name(RegExp##Name*, void* data); |
| 1001 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 1001 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
| 1002 #undef MAKE_CASE | 1002 #undef MAKE_CASE |
| 1003 private: | 1003 private: |
| 1004 StringStream* stream() { return &stream_; } | 1004 StringStream* stream() { return &stream_; } |
| 1005 Zone* zone_; |
| 1005 HeapStringAllocator alloc_; | 1006 HeapStringAllocator alloc_; |
| 1006 StringStream stream_; | 1007 StringStream stream_; |
| 1007 }; | 1008 }; |
| 1008 | 1009 |
| 1009 | 1010 |
| 1010 RegExpUnparser::RegExpUnparser() : stream_(&alloc_) { | 1011 RegExpUnparser::RegExpUnparser(Zone* zone) : zone_(zone), stream_(&alloc_) { |
| 1011 } | 1012 } |
| 1012 | 1013 |
| 1013 | 1014 |
| 1014 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { | 1015 void* RegExpUnparser::VisitDisjunction(RegExpDisjunction* that, void* data) { |
| 1015 stream()->Add("(|"); | 1016 stream()->Add("(|"); |
| 1016 for (int i = 0; i < that->alternatives()->length(); i++) { | 1017 for (int i = 0; i < that->alternatives()->length(); i++) { |
| 1017 stream()->Add(" "); | 1018 stream()->Add(" "); |
| 1018 that->alternatives()->at(i)->Accept(this, data); | 1019 that->alternatives()->at(i)->Accept(this, data); |
| 1019 } | 1020 } |
| 1020 stream()->Add(")"); | 1021 stream()->Add(")"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1040 } | 1041 } |
| 1041 } | 1042 } |
| 1042 | 1043 |
| 1043 | 1044 |
| 1044 | 1045 |
| 1045 void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, | 1046 void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that, |
| 1046 void* data) { | 1047 void* data) { |
| 1047 if (that->is_negated()) | 1048 if (that->is_negated()) |
| 1048 stream()->Add("^"); | 1049 stream()->Add("^"); |
| 1049 stream()->Add("["); | 1050 stream()->Add("["); |
| 1050 for (int i = 0; i < that->ranges()->length(); i++) { | 1051 for (int i = 0; i < that->ranges(zone_)->length(); i++) { |
| 1051 if (i > 0) stream()->Add(" "); | 1052 if (i > 0) stream()->Add(" "); |
| 1052 VisitCharacterRange(that->ranges()->at(i)); | 1053 VisitCharacterRange(that->ranges(zone_)->at(i)); |
| 1053 } | 1054 } |
| 1054 stream()->Add("]"); | 1055 stream()->Add("]"); |
| 1055 return NULL; | 1056 return NULL; |
| 1056 } | 1057 } |
| 1057 | 1058 |
| 1058 | 1059 |
| 1059 void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { | 1060 void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) { |
| 1060 switch (that->type()) { | 1061 switch (that->type()) { |
| 1061 case RegExpAssertion::START_OF_INPUT: | 1062 case RegExpAssertion::START_OF_INPUT: |
| 1062 stream()->Add("@^i"); | 1063 stream()->Add("@^i"); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 } | 1146 } |
| 1146 | 1147 |
| 1147 | 1148 |
| 1148 void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { | 1149 void* RegExpUnparser::VisitEmpty(RegExpEmpty* that, void* data) { |
| 1149 stream()->Put('%'); | 1150 stream()->Put('%'); |
| 1150 return NULL; | 1151 return NULL; |
| 1151 } | 1152 } |
| 1152 | 1153 |
| 1153 | 1154 |
| 1154 SmartPointer<const char> RegExpTree::ToString() { | 1155 SmartPointer<const char> RegExpTree::ToString() { |
| 1155 RegExpUnparser unparser; | 1156 RegExpUnparser unparser(ZONE); |
| 1156 Accept(&unparser, NULL); | 1157 Accept(&unparser, NULL); |
| 1157 return unparser.ToString(); | 1158 return unparser.ToString(); |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 | 1161 |
| 1161 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) | 1162 RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) |
| 1162 : alternatives_(alternatives) { | 1163 : alternatives_(alternatives) { |
| 1163 ASSERT(alternatives->length() > 1); | 1164 ASSERT(alternatives->length() > 1); |
| 1164 RegExpTree* first_alternative = alternatives->at(0); | 1165 RegExpTree* first_alternative = alternatives->at(0); |
| 1165 min_match_ = first_alternative->min_match(); | 1166 min_match_ = first_alternative->min_match(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1195 int pos) | 1196 int pos) |
| 1196 : label_(label), | 1197 : label_(label), |
| 1197 statements_(statements), | 1198 statements_(statements), |
| 1198 position_(pos), | 1199 position_(pos), |
| 1199 compare_type_(NONE), | 1200 compare_type_(NONE), |
| 1200 compare_id_(AstNode::GetNextId()), | 1201 compare_id_(AstNode::GetNextId()), |
| 1201 entry_id_(AstNode::GetNextId()) { | 1202 entry_id_(AstNode::GetNextId()) { |
| 1202 } | 1203 } |
| 1203 | 1204 |
| 1204 } } // namespace v8::internal | 1205 } } // namespace v8::internal |
| OLD | NEW |