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

Side by Side Diff: src/ast.cc

Issue 137403009: Adding a type vector to replace type cells. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Smarter vector allocation and refactoring. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 // Recording of type feedback 587 // Recording of type feedback
588 588
589 // TODO(rossberg): all RecordTypeFeedback functions should disappear 589 // TODO(rossberg): all RecordTypeFeedback functions should disappear
590 // once we use the common type field in the AST consistently. 590 // once we use the common type field in the AST consistently.
591 591
592 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { 592 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
593 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); 593 to_boolean_types_ = oracle->ToBooleanTypes(test_id());
594 } 594 }
595 595
596 596
597 int Call::ConsumeFeedbackSlots(Isolate* isolate, int current_slot) {
598 CallType call_type = GetCallType(isolate);
599 int slots = 0;
600 if (call_type == LOOKUP_SLOT_CALL || call_type == OTHER_CALL) {
601 // Call only uses a slot in some cases.
602 slots++;
603 first_feedback_slot_ = current_slot;
604 }
605
606 return current_slot + slots;
607 }
608
609
597 Call::CallType Call::GetCallType(Isolate* isolate) const { 610 Call::CallType Call::GetCallType(Isolate* isolate) const {
598 VariableProxy* proxy = expression()->AsVariableProxy(); 611 VariableProxy* proxy = expression()->AsVariableProxy();
599 if (proxy != NULL) { 612 if (proxy != NULL) {
600 if (proxy->var()->is_possibly_eval(isolate)) { 613 if (proxy->var()->is_possibly_eval(isolate)) {
601 return POSSIBLY_EVAL_CALL; 614 return POSSIBLY_EVAL_CALL;
602 } else if (proxy->var()->IsUnallocated()) { 615 } else if (proxy->var()->IsUnallocated()) {
603 return GLOBAL_CALL; 616 return GLOBAL_CALL;
604 } else if (proxy->var()->IsLookupSlot()) { 617 } else if (proxy->var()->IsLookupSlot()) {
605 return LOOKUP_SLOT_CALL; 618 return LOOKUP_SLOT_CALL;
606 } 619 }
607 } 620 }
608
609 Property* property = expression()->AsProperty(); 621 Property* property = expression()->AsProperty();
610 return property != NULL ? PROPERTY_CALL : OTHER_CALL; 622 return property != NULL ? PROPERTY_CALL : OTHER_CALL;
611 } 623 }
612 624
613 625
614 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { 626 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) {
615 // If there is an interceptor, we can't compute the target for a direct call. 627 // If there is an interceptor, we can't compute the target for a direct call.
616 if (type->has_named_interceptor()) return false; 628 if (type->has_named_interceptor()) return false;
617 629
618 if (check_type_ == RECEIVER_MAP_CHECK) { 630 if (check_type_ == RECEIVER_MAP_CHECK) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 case BOOLEAN_CHECK: 717 case BOOLEAN_CHECK:
706 function = native_context->boolean_function(); 718 function = native_context->boolean_function();
707 break; 719 break;
708 } 720 }
709 ASSERT(function != NULL); 721 ASSERT(function != NULL);
710 return Handle<JSObject>(JSObject::cast(function->instance_prototype())); 722 return Handle<JSObject>(JSObject::cast(function->instance_prototype()));
711 } 723 }
712 724
713 725
714 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 726 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
715 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId()); 727 if (CallFeedbackSlot() >= 0) {
Benedikt Meurer 2014/01/24 11:29:54 != kInvalidFeedbackSlot
mvstanton 2014/01/30 15:13:41 Done.
716 Property* property = expression()->AsProperty(); 728 // We stored feedback in the type vector.
717 if (property == NULL) { 729 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackSlot());
718 // Function call. Specialize for monomorphic calls. 730 ASSERT(expression()->AsProperty() == NULL);
719 if (is_monomorphic_) target_ = oracle->GetCallTarget(CallFeedbackId()); 731 if (is_monomorphic_) target_ = oracle->GetCallTarget(CallFeedbackSlot());
720 } else if (property->key()->IsPropertyName()) { 732 } else {
721 // Method call. Specialize for the receiver types seen at runtime. 733 // We stored feedback in an IC.
722 Literal* key = property->key()->AsLiteral(); 734 is_monomorphic_ = oracle->CallIsMonomorphic(CallFeedbackId());
723 ASSERT(key != NULL && key->value()->IsString()); 735 Property* property = expression()->AsProperty();
724 Handle<String> name = Handle<String>::cast(key->value()); 736 if (property != NULL) {
725 check_type_ = oracle->GetCallCheckType(CallFeedbackId()); 737 if (property->key()->IsPropertyName()) {
726 receiver_types_.Clear(); 738 // Method call. Specialize for the receiver types seen at runtime.
727 if (check_type_ == RECEIVER_MAP_CHECK) { 739 Literal* key = property->key()->AsLiteral();
728 oracle->CallReceiverTypes(CallFeedbackId(), 740 ASSERT(key != NULL && key->value()->IsString());
729 name, arguments()->length(), &receiver_types_); 741 Handle<String> name = Handle<String>::cast(key->value());
730 is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0; 742 check_type_ = oracle->GetCallCheckType(CallFeedbackId());
731 } else { 743 receiver_types_.Clear();
732 holder_ = GetPrototypeForPrimitiveCheck(check_type_, oracle->isolate()); 744 if (check_type_ == RECEIVER_MAP_CHECK) {
733 receiver_types_.Add(handle(holder_->map()), oracle->zone()); 745 oracle->CallReceiverTypes(CallFeedbackId(),
734 } 746 name, arguments()->length(),
747 &receiver_types_);
748 is_monomorphic_ = is_monomorphic_ && receiver_types_.length() > 0;
749 } else {
750 holder_ = GetPrototypeForPrimitiveCheck(check_type_,
751 oracle->isolate());
752 receiver_types_.Add(handle(holder_->map()), oracle->zone());
753 }
735 #ifdef ENABLE_SLOW_ASSERTS 754 #ifdef ENABLE_SLOW_ASSERTS
736 if (FLAG_enable_slow_asserts) { 755 if (FLAG_enable_slow_asserts) {
737 int length = receiver_types_.length(); 756 int length = receiver_types_.length();
738 for (int i = 0; i < length; i++) { 757 for (int i = 0; i < length; i++) {
739 Handle<Map> map = receiver_types_.at(i); 758 Handle<Map> map = receiver_types_.at(i);
740 ASSERT(!map.is_null() && *map != NULL); 759 ASSERT(!map.is_null() && *map != NULL);
760 }
761 }
762 #endif
763 if (is_monomorphic_) {
764 Handle<Map> map = receiver_types_.first();
765 is_monomorphic_ = ComputeTarget(map, name);
766 }
767 } else {
768 if (is_monomorphic_) {
769 keyed_array_call_is_holey_ =
770 oracle->KeyedArrayCallIsHoley(CallFeedbackId());
771 }
741 } 772 }
742 } 773 }
743 #endif
744 if (is_monomorphic_) {
745 Handle<Map> map = receiver_types_.first();
746 is_monomorphic_ = ComputeTarget(map, name);
747 }
748 } else {
749 if (is_monomorphic_) {
750 keyed_array_call_is_holey_ =
751 oracle->KeyedArrayCallIsHoley(CallFeedbackId());
752 }
753 } 774 }
754 } 775 }
755 776
756 777
757 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 778 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
758 allocation_site_ = 779 allocation_site_ =
759 oracle->GetCallNewAllocationSite(CallNewFeedbackId()); 780 oracle->GetCallNewAllocationSite(CallNewFeedbackSlot());
760 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackId()); 781 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackSlot());
761 if (is_monomorphic_) { 782 if (is_monomorphic_) {
762 target_ = oracle->GetCallNewTarget(CallNewFeedbackId()); 783 target_ = oracle->GetCallNewTarget(CallNewFeedbackSlot());
763 if (!allocation_site_.is_null()) { 784 if (!allocation_site_.is_null()) {
764 elements_kind_ = allocation_site_->GetElementsKind(); 785 elements_kind_ = allocation_site_->GetElementsKind();
765 } 786 }
766 } 787 }
767 } 788 }
768 789
769 790
770 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { 791 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
771 TypeFeedbackId id = key()->LiteralFeedbackId(); 792 TypeFeedbackId id = key()->LiteralFeedbackId();
772 SmallMapList maps; 793 SmallMapList maps;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 statements_(statements), 1175 statements_(statements),
1155 compare_type_(Type::None(zone)), 1176 compare_type_(Type::None(zone)),
1156 compare_id_(AstNode::GetNextId(zone)), 1177 compare_id_(AstNode::GetNextId(zone)),
1157 entry_id_(AstNode::GetNextId(zone)) { 1178 entry_id_(AstNode::GetNextId(zone)) {
1158 } 1179 }
1159 1180
1160 1181
1161 #define REGULAR_NODE(NodeType) \ 1182 #define REGULAR_NODE(NodeType) \
1162 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1183 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1163 increase_node_count(); \ 1184 increase_node_count(); \
1185 increase_feedback_slots(NodeType::MinimumFeedbackSlots(), \
1186 NodeType::MaximumFeedbackSlots()); \
1164 } 1187 }
1165 #define DONT_OPTIMIZE_NODE(NodeType) \ 1188 #define DONT_OPTIMIZE_NODE(NodeType) \
1166 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1189 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1167 increase_node_count(); \ 1190 increase_node_count(); \
1191 increase_feedback_slots(NodeType::MinimumFeedbackSlots(), \
1192 NodeType::MaximumFeedbackSlots()); \
1168 set_dont_optimize_reason(k##NodeType); \ 1193 set_dont_optimize_reason(k##NodeType); \
1169 add_flag(kDontInline); \ 1194 add_flag(kDontInline); \
1170 add_flag(kDontSelfOptimize); \ 1195 add_flag(kDontSelfOptimize); \
1171 } 1196 }
1172 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ 1197 #define DONT_SELFOPTIMIZE_NODE(NodeType) \
1173 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1198 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1174 increase_node_count(); \ 1199 increase_node_count(); \
1200 increase_feedback_slots(NodeType::MinimumFeedbackSlots(), \
1201 NodeType::MaximumFeedbackSlots()); \
1175 add_flag(kDontSelfOptimize); \ 1202 add_flag(kDontSelfOptimize); \
1176 } 1203 }
1177 #define DONT_CACHE_NODE(NodeType) \ 1204 #define DONT_CACHE_NODE(NodeType) \
1178 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1205 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1179 increase_node_count(); \ 1206 increase_node_count(); \
1180 set_dont_optimize_reason(k##NodeType); \ 1207 increase_feedback_slots(NodeType::MinimumFeedbackSlots(), \
1208 NodeType::MaximumFeedbackSlots()); \
1181 add_flag(kDontInline); \ 1209 add_flag(kDontInline); \
1182 add_flag(kDontSelfOptimize); \ 1210 add_flag(kDontSelfOptimize); \
1183 add_flag(kDontCache); \ 1211 add_flag(kDontCache); \
1184 } 1212 }
1185 1213
1186 REGULAR_NODE(VariableDeclaration) 1214 REGULAR_NODE(VariableDeclaration)
1187 REGULAR_NODE(FunctionDeclaration) 1215 REGULAR_NODE(FunctionDeclaration)
1188 REGULAR_NODE(Block) 1216 REGULAR_NODE(Block)
1189 REGULAR_NODE(ExpressionStatement) 1217 REGULAR_NODE(ExpressionStatement)
1190 REGULAR_NODE(EmptyStatement) 1218 REGULAR_NODE(EmptyStatement)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 DONT_SELFOPTIMIZE_NODE(DoWhileStatement) 1262 DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
1235 DONT_SELFOPTIMIZE_NODE(WhileStatement) 1263 DONT_SELFOPTIMIZE_NODE(WhileStatement)
1236 DONT_SELFOPTIMIZE_NODE(ForStatement) 1264 DONT_SELFOPTIMIZE_NODE(ForStatement)
1237 DONT_SELFOPTIMIZE_NODE(ForInStatement) 1265 DONT_SELFOPTIMIZE_NODE(ForInStatement)
1238 DONT_SELFOPTIMIZE_NODE(ForOfStatement) 1266 DONT_SELFOPTIMIZE_NODE(ForOfStatement)
1239 1267
1240 DONT_CACHE_NODE(ModuleLiteral) 1268 DONT_CACHE_NODE(ModuleLiteral)
1241 1269
1242 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { 1270 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
1243 increase_node_count(); 1271 increase_node_count();
1272 increase_feedback_slots(CallRuntime::MinimumFeedbackSlots(),
1273 CallRuntime::MaximumFeedbackSlots());
1244 if (node->is_jsruntime()) { 1274 if (node->is_jsruntime()) {
1245 // Don't try to inline JS runtime calls because we don't (currently) even 1275 // Don't try to inline JS runtime calls because we don't (currently) even
1246 // optimize them. 1276 // optimize them.
1247 add_flag(kDontInline); 1277 add_flag(kDontInline);
1248 } else if (node->function()->intrinsic_type == Runtime::INLINE && 1278 } else if (node->function()->intrinsic_type == Runtime::INLINE &&
1249 (node->name()->IsOneByteEqualTo( 1279 (node->name()->IsOneByteEqualTo(
1250 STATIC_ASCII_VECTOR("_ArgumentsLength")) || 1280 STATIC_ASCII_VECTOR("_ArgumentsLength")) ||
1251 node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) { 1281 node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) {
1252 // Don't inline the %_ArgumentsLength or %_Arguments because their 1282 // Don't inline the %_ArgumentsLength or %_Arguments because their
1253 // implementation will not work. There is no stack frame to get them 1283 // implementation will not work. There is no stack frame to get them
(...skipping 19 matching lines...) Expand all
1273 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); 1303 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value());
1274 str = arr; 1304 str = arr;
1275 } else { 1305 } else {
1276 str = DoubleToCString(value_->Number(), buffer); 1306 str = DoubleToCString(value_->Number(), buffer);
1277 } 1307 }
1278 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); 1308 return isolate_->factory()->NewStringFromAscii(CStrVector(str));
1279 } 1309 }
1280 1310
1281 1311
1282 } } // namespace v8::internal 1312 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698