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

Side by Side Diff: src/ast.cc

Issue 7655017: Improve memory usage of receiver type feedback. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: ReceiverTypeList -> SmallMapList Created 9 years, 4 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 | Annotate | Revision Log
« src/ast.h ('K') | « src/ast.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 : Expression(isolate), 132 : Expression(isolate),
133 op_(op), 133 op_(op),
134 target_(target), 134 target_(target),
135 value_(value), 135 value_(value),
136 pos_(pos), 136 pos_(pos),
137 binary_operation_(NULL), 137 binary_operation_(NULL),
138 compound_load_id_(kNoNumber), 138 compound_load_id_(kNoNumber),
139 assignment_id_(GetNextId(isolate)), 139 assignment_id_(GetNextId(isolate)),
140 block_start_(false), 140 block_start_(false),
141 block_end_(false), 141 block_end_(false),
142 is_monomorphic_(false), 142 is_monomorphic_(false) {
143 receiver_types_(NULL) {
144 ASSERT(Token::IsAssignmentOp(op)); 143 ASSERT(Token::IsAssignmentOp(op));
145 if (is_compound()) { 144 if (is_compound()) {
146 binary_operation_ = 145 binary_operation_ =
147 new(isolate->zone()) BinaryOperation(isolate, 146 new(isolate->zone()) BinaryOperation(isolate,
148 binary_op(), 147 binary_op(),
149 target, 148 target,
150 value, 149 value,
151 pos + 1); 150 pos + 1);
152 compound_load_id_ = GetNextId(isolate); 151 compound_load_id_ = GetNextId(isolate);
153 } 152 }
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 return expression()->IsInlineable(); 644 return expression()->IsInlineable();
646 } 645 }
647 646
648 647
649 // ---------------------------------------------------------------------------- 648 // ----------------------------------------------------------------------------
650 // Recording of type feedback 649 // Recording of type feedback
651 650
652 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 651 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
653 // Record type feedback from the oracle in the AST. 652 // Record type feedback from the oracle in the AST.
654 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this); 653 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this);
654 receiver_types_.Clear();
655 if (key()->IsPropertyName()) { 655 if (key()->IsPropertyName()) {
656 if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_ArrayLength)) { 656 if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_ArrayLength)) {
657 is_array_length_ = true; 657 is_array_length_ = true;
658 } else if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_StringLength)) { 658 } else if (oracle->LoadIsBuiltin(this, Builtins::kLoadIC_StringLength)) {
659 is_string_length_ = true; 659 is_string_length_ = true;
660 } else if (oracle->LoadIsBuiltin(this, 660 } else if (oracle->LoadIsBuiltin(this,
661 Builtins::kLoadIC_FunctionPrototype)) { 661 Builtins::kLoadIC_FunctionPrototype)) {
662 is_function_prototype_ = true; 662 is_function_prototype_ = true;
663 } else { 663 } else {
664 Literal* lit_key = key()->AsLiteral(); 664 Literal* lit_key = key()->AsLiteral();
665 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); 665 ASSERT(lit_key != NULL && lit_key->handle()->IsString());
666 Handle<String> name = Handle<String>::cast(lit_key->handle()); 666 Handle<String> name = Handle<String>::cast(lit_key->handle());
667 ZoneMapList* types = oracle->LoadReceiverTypes(this, name); 667 oracle->LoadReceiverTypes(this, name, &receiver_types_);
668 receiver_types_ = types;
669 } 668 }
670 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { 669 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) {
671 is_string_access_ = true; 670 is_string_access_ = true;
672 } else if (is_monomorphic_) { 671 } else if (is_monomorphic_) {
673 monomorphic_receiver_type_ = oracle->LoadMonomorphicReceiverType(this); 672 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this));
674 } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) { 673 } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) {
675 receiver_types_ = new ZoneMapList(kMaxKeyedPolymorphism); 674 receiver_types_.Reserve(kMaxKeyedPolymorphism);
676 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); 675 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
677 } 676 }
678 } 677 }
679 678
680 679
681 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 680 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
682 Property* prop = target()->AsProperty(); 681 Property* prop = target()->AsProperty();
683 ASSERT(prop != NULL); 682 ASSERT(prop != NULL);
684 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); 683 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this);
684 receiver_types_.Clear();
685 if (prop->key()->IsPropertyName()) { 685 if (prop->key()->IsPropertyName()) {
686 Literal* lit_key = prop->key()->AsLiteral(); 686 Literal* lit_key = prop->key()->AsLiteral();
687 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); 687 ASSERT(lit_key != NULL && lit_key->handle()->IsString());
688 Handle<String> name = Handle<String>::cast(lit_key->handle()); 688 Handle<String> name = Handle<String>::cast(lit_key->handle());
689 ZoneMapList* types = oracle->StoreReceiverTypes(this, name); 689 oracle->StoreReceiverTypes(this, name, &receiver_types_);
690 receiver_types_ = types;
691 } else if (is_monomorphic_) { 690 } else if (is_monomorphic_) {
692 // Record receiver type for monomorphic keyed stores. 691 // Record receiver type for monomorphic keyed stores.
693 monomorphic_receiver_type_ = oracle->StoreMonomorphicReceiverType(this); 692 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this));
694 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { 693 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) {
695 receiver_types_ = new ZoneMapList(kMaxKeyedPolymorphism); 694 receiver_types_.Reserve(kMaxKeyedPolymorphism);
696 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); 695 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
697 } 696 }
698 } 697 }
699 698
700 699
701 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 700 void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
702 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this); 701 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(this);
702 receiver_types_.Clear();
703 if (is_monomorphic_) { 703 if (is_monomorphic_) {
704 // Record receiver type for monomorphic keyed stores. 704 // Record receiver type for monomorphic keyed stores.
705 monomorphic_receiver_type_ = oracle->StoreMonomorphicReceiverType(this); 705 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(this));
706 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) { 706 } else if (oracle->StoreIsMegamorphicWithTypeInfo(this)) {
707 receiver_types_ = new ZoneMapList(kMaxKeyedPolymorphism); 707 receiver_types_.Reserve(kMaxKeyedPolymorphism);
708 oracle->CollectKeyedReceiverTypes(this->id(), receiver_types_); 708 oracle->CollectKeyedReceiverTypes(this->id(), &receiver_types_);
709 } 709 }
710 } 710 }
711 711
712 712
713 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 713 void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
714 TypeInfo info = oracle->SwitchType(this); 714 TypeInfo info = oracle->SwitchType(this);
715 if (info.IsSmi()) { 715 if (info.IsSmi()) {
716 compare_type_ = SMI_ONLY; 716 compare_type_ = SMI_ONLY;
717 } else if (info.IsNonPrimitive()) { 717 } else if (info.IsNonPrimitive()) {
718 compare_type_ = OBJECT_ONLY; 718 compare_type_ = OBJECT_ONLY;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 782
783 783
784 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle, 784 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle,
785 CallKind call_kind) { 785 CallKind call_kind) {
786 Property* property = expression()->AsProperty(); 786 Property* property = expression()->AsProperty();
787 ASSERT(property != NULL); 787 ASSERT(property != NULL);
788 // Specialize for the receiver types seen at runtime. 788 // Specialize for the receiver types seen at runtime.
789 Literal* key = property->key()->AsLiteral(); 789 Literal* key = property->key()->AsLiteral();
790 ASSERT(key != NULL && key->handle()->IsString()); 790 ASSERT(key != NULL && key->handle()->IsString());
791 Handle<String> name = Handle<String>::cast(key->handle()); 791 Handle<String> name = Handle<String>::cast(key->handle());
792 receiver_types_ = oracle->CallReceiverTypes(this, name, call_kind); 792 receiver_types_.Clear();
793 oracle->CallReceiverTypes(this, name, call_kind, &receiver_types_);
793 #ifdef DEBUG 794 #ifdef DEBUG
794 if (FLAG_enable_slow_asserts) { 795 if (FLAG_enable_slow_asserts) {
795 if (receiver_types_ != NULL) { 796 int length = receiver_types_.length();
796 int length = receiver_types_->length(); 797 for (int i = 0; i < length; i++) {
797 for (int i = 0; i < length; i++) { 798 Handle<Map> map = receiver_types_.at(i);
798 Handle<Map> map = receiver_types_->at(i); 799 ASSERT(!map.is_null() && *map != NULL);
799 ASSERT(!map.is_null() && *map != NULL);
800 }
801 } 800 }
802 } 801 }
803 #endif 802 #endif
804 is_monomorphic_ = oracle->CallIsMonomorphic(this); 803 is_monomorphic_ = oracle->CallIsMonomorphic(this);
805 check_type_ = oracle->GetCallCheckType(this); 804 check_type_ = oracle->GetCallCheckType(this);
806 if (is_monomorphic_) { 805 if (is_monomorphic_) {
807 Handle<Map> map; 806 Handle<Map> map;
808 if (receiver_types_ != NULL && receiver_types_->length() > 0) { 807 if (receiver_types_.length() > 0) {
809 ASSERT(check_type_ == RECEIVER_MAP_CHECK); 808 ASSERT(check_type_ == RECEIVER_MAP_CHECK);
810 map = receiver_types_->at(0); 809 map = receiver_types_.at(0);
811 } else { 810 } else {
812 ASSERT(check_type_ != RECEIVER_MAP_CHECK); 811 ASSERT(check_type_ != RECEIVER_MAP_CHECK);
813 holder_ = Handle<JSObject>( 812 holder_ = Handle<JSObject>(
814 oracle->GetPrototypeForPrimitiveCheck(check_type_)); 813 oracle->GetPrototypeForPrimitiveCheck(check_type_));
815 map = Handle<Map>(holder_->map()); 814 map = Handle<Map>(holder_->map());
816 } 815 }
817 is_monomorphic_ = ComputeTarget(map, name); 816 is_monomorphic_ = ComputeTarget(map, name);
818 } 817 }
819 } 818 }
820 819
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 int pos) 1206 int pos)
1208 : label_(label), 1207 : label_(label),
1209 statements_(statements), 1208 statements_(statements),
1210 position_(pos), 1209 position_(pos),
1211 compare_type_(NONE), 1210 compare_type_(NONE),
1212 compare_id_(AstNode::GetNextId(isolate)), 1211 compare_id_(AstNode::GetNextId(isolate)),
1213 entry_id_(AstNode::GetNextId(isolate)) { 1212 entry_id_(AstNode::GetNextId(isolate)) {
1214 } 1213 }
1215 1214
1216 } } // namespace v8::internal 1215 } } // namespace v8::internal
OLDNEW
« src/ast.h ('K') | « src/ast.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698