OLD | NEW |
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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // Recording of type feedback | 586 // Recording of type feedback |
587 | 587 |
588 // TODO(rossberg): all RecordTypeFeedback functions should disappear | 588 // TODO(rossberg): all RecordTypeFeedback functions should disappear |
589 // once we use the common type field in the AST consistently. | 589 // once we use the common type field in the AST consistently. |
590 | 590 |
591 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 591 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
592 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); | 592 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); |
593 } | 593 } |
594 | 594 |
595 | 595 |
| 596 int Call::ComputeFeedbackSlotCount(Isolate* isolate) { |
| 597 CallType call_type = GetCallType(isolate); |
| 598 if (call_type == LOOKUP_SLOT_CALL || call_type == OTHER_CALL) { |
| 599 // Call only uses a slot in some cases. |
| 600 return 1; |
| 601 } |
| 602 |
| 603 return 0; |
| 604 } |
| 605 |
| 606 |
596 Call::CallType Call::GetCallType(Isolate* isolate) const { | 607 Call::CallType Call::GetCallType(Isolate* isolate) const { |
597 VariableProxy* proxy = expression()->AsVariableProxy(); | 608 VariableProxy* proxy = expression()->AsVariableProxy(); |
598 if (proxy != NULL) { | 609 if (proxy != NULL) { |
599 if (proxy->var()->is_possibly_eval(isolate)) { | 610 if (proxy->var()->is_possibly_eval(isolate)) { |
600 return POSSIBLY_EVAL_CALL; | 611 return POSSIBLY_EVAL_CALL; |
601 } else if (proxy->var()->IsUnallocated()) { | 612 } else if (proxy->var()->IsUnallocated()) { |
602 return GLOBAL_CALL; | 613 return GLOBAL_CALL; |
603 } else if (proxy->var()->IsLookupSlot()) { | 614 } else if (proxy->var()->IsLookupSlot()) { |
604 return LOOKUP_SLOT_CALL; | 615 return LOOKUP_SLOT_CALL; |
605 } | 616 } |
(...skipping 20 matching lines...) Expand all Loading... |
626 target_ = candidate; | 637 target_ = candidate; |
627 return true; | 638 return true; |
628 } | 639 } |
629 } | 640 } |
630 return false; | 641 return false; |
631 } | 642 } |
632 | 643 |
633 | 644 |
634 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 645 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
635 allocation_site_ = | 646 allocation_site_ = |
636 oracle->GetCallNewAllocationSite(CallNewFeedbackId()); | 647 oracle->GetCallNewAllocationSite(CallNewFeedbackSlot()); |
637 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackId()); | 648 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackSlot()); |
638 if (is_monomorphic_) { | 649 if (is_monomorphic_) { |
639 target_ = oracle->GetCallNewTarget(CallNewFeedbackId()); | 650 target_ = oracle->GetCallNewTarget(CallNewFeedbackSlot()); |
640 if (!allocation_site_.is_null()) { | 651 if (!allocation_site_.is_null()) { |
641 elements_kind_ = allocation_site_->GetElementsKind(); | 652 elements_kind_ = allocation_site_->GetElementsKind(); |
642 } | 653 } |
643 } | 654 } |
644 } | 655 } |
645 | 656 |
646 | 657 |
647 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 658 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
648 TypeFeedbackId id = key()->LiteralFeedbackId(); | 659 TypeFeedbackId id = key()->LiteralFeedbackId(); |
649 SmallMapList maps; | 660 SmallMapList maps; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 compare_type_(Type::None(zone)), | 1043 compare_type_(Type::None(zone)), |
1033 compare_id_(AstNode::GetNextId(zone)), | 1044 compare_id_(AstNode::GetNextId(zone)), |
1034 entry_id_(AstNode::GetNextId(zone)) { | 1045 entry_id_(AstNode::GetNextId(zone)) { |
1035 } | 1046 } |
1036 | 1047 |
1037 | 1048 |
1038 #define REGULAR_NODE(NodeType) \ | 1049 #define REGULAR_NODE(NodeType) \ |
1039 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1050 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
1040 increase_node_count(); \ | 1051 increase_node_count(); \ |
1041 } | 1052 } |
| 1053 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1054 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1055 increase_node_count(); \ |
| 1056 add_slot_node(node); \ |
| 1057 } |
1042 #define DONT_OPTIMIZE_NODE(NodeType) \ | 1058 #define DONT_OPTIMIZE_NODE(NodeType) \ |
1043 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1059 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
1044 increase_node_count(); \ | 1060 increase_node_count(); \ |
1045 set_dont_optimize_reason(k##NodeType); \ | 1061 set_dont_optimize_reason(k##NodeType); \ |
1046 add_flag(kDontInline); \ | 1062 add_flag(kDontInline); \ |
1047 add_flag(kDontSelfOptimize); \ | 1063 add_flag(kDontSelfOptimize); \ |
1048 } | 1064 } |
1049 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ | 1065 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ |
1050 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1066 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
1051 increase_node_count(); \ | 1067 increase_node_count(); \ |
1052 add_flag(kDontSelfOptimize); \ | 1068 add_flag(kDontSelfOptimize); \ |
1053 } | 1069 } |
| 1070 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1071 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1072 increase_node_count(); \ |
| 1073 add_slot_node(node); \ |
| 1074 add_flag(kDontSelfOptimize); \ |
| 1075 } |
1054 #define DONT_CACHE_NODE(NodeType) \ | 1076 #define DONT_CACHE_NODE(NodeType) \ |
1055 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1077 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
1056 increase_node_count(); \ | 1078 increase_node_count(); \ |
1057 set_dont_optimize_reason(k##NodeType); \ | 1079 set_dont_optimize_reason(k##NodeType); \ |
1058 add_flag(kDontInline); \ | 1080 add_flag(kDontInline); \ |
1059 add_flag(kDontSelfOptimize); \ | 1081 add_flag(kDontSelfOptimize); \ |
1060 add_flag(kDontCache); \ | 1082 add_flag(kDontCache); \ |
1061 } | 1083 } |
1062 | 1084 |
1063 REGULAR_NODE(VariableDeclaration) | 1085 REGULAR_NODE(VariableDeclaration) |
(...skipping 14 matching lines...) Expand all Loading... |
1078 REGULAR_NODE(RegExpLiteral) | 1100 REGULAR_NODE(RegExpLiteral) |
1079 REGULAR_NODE(FunctionLiteral) | 1101 REGULAR_NODE(FunctionLiteral) |
1080 REGULAR_NODE(Assignment) | 1102 REGULAR_NODE(Assignment) |
1081 REGULAR_NODE(Throw) | 1103 REGULAR_NODE(Throw) |
1082 REGULAR_NODE(Property) | 1104 REGULAR_NODE(Property) |
1083 REGULAR_NODE(UnaryOperation) | 1105 REGULAR_NODE(UnaryOperation) |
1084 REGULAR_NODE(CountOperation) | 1106 REGULAR_NODE(CountOperation) |
1085 REGULAR_NODE(BinaryOperation) | 1107 REGULAR_NODE(BinaryOperation) |
1086 REGULAR_NODE(CompareOperation) | 1108 REGULAR_NODE(CompareOperation) |
1087 REGULAR_NODE(ThisFunction) | 1109 REGULAR_NODE(ThisFunction) |
1088 REGULAR_NODE(Call) | 1110 REGULAR_NODE_WITH_FEEDBACK_SLOTS(Call) |
1089 REGULAR_NODE(CallNew) | 1111 REGULAR_NODE_WITH_FEEDBACK_SLOTS(CallNew) |
1090 // In theory, for VariableProxy we'd have to add: | 1112 // In theory, for VariableProxy we'd have to add: |
1091 // if (node->var()->IsLookupSlot()) add_flag(kDontInline); | 1113 // if (node->var()->IsLookupSlot()) add_flag(kDontInline); |
1092 // But node->var() is usually not bound yet at VariableProxy creation time, and | 1114 // But node->var() is usually not bound yet at VariableProxy creation time, and |
1093 // LOOKUP variables only result from constructs that cannot be inlined anyway. | 1115 // LOOKUP variables only result from constructs that cannot be inlined anyway. |
1094 REGULAR_NODE(VariableProxy) | 1116 REGULAR_NODE(VariableProxy) |
1095 | 1117 |
1096 // We currently do not optimize any modules. | 1118 // We currently do not optimize any modules. |
1097 DONT_OPTIMIZE_NODE(ModuleDeclaration) | 1119 DONT_OPTIMIZE_NODE(ModuleDeclaration) |
1098 DONT_OPTIMIZE_NODE(ImportDeclaration) | 1120 DONT_OPTIMIZE_NODE(ImportDeclaration) |
1099 DONT_OPTIMIZE_NODE(ExportDeclaration) | 1121 DONT_OPTIMIZE_NODE(ExportDeclaration) |
1100 DONT_OPTIMIZE_NODE(ModuleVariable) | 1122 DONT_OPTIMIZE_NODE(ModuleVariable) |
1101 DONT_OPTIMIZE_NODE(ModulePath) | 1123 DONT_OPTIMIZE_NODE(ModulePath) |
1102 DONT_OPTIMIZE_NODE(ModuleUrl) | 1124 DONT_OPTIMIZE_NODE(ModuleUrl) |
1103 DONT_OPTIMIZE_NODE(ModuleStatement) | 1125 DONT_OPTIMIZE_NODE(ModuleStatement) |
1104 DONT_OPTIMIZE_NODE(Yield) | 1126 DONT_OPTIMIZE_NODE(Yield) |
1105 DONT_OPTIMIZE_NODE(WithStatement) | 1127 DONT_OPTIMIZE_NODE(WithStatement) |
1106 DONT_OPTIMIZE_NODE(TryCatchStatement) | 1128 DONT_OPTIMIZE_NODE(TryCatchStatement) |
1107 DONT_OPTIMIZE_NODE(TryFinallyStatement) | 1129 DONT_OPTIMIZE_NODE(TryFinallyStatement) |
1108 DONT_OPTIMIZE_NODE(DebuggerStatement) | 1130 DONT_OPTIMIZE_NODE(DebuggerStatement) |
1109 DONT_OPTIMIZE_NODE(NativeFunctionLiteral) | 1131 DONT_OPTIMIZE_NODE(NativeFunctionLiteral) |
1110 | 1132 |
1111 DONT_SELFOPTIMIZE_NODE(DoWhileStatement) | 1133 DONT_SELFOPTIMIZE_NODE(DoWhileStatement) |
1112 DONT_SELFOPTIMIZE_NODE(WhileStatement) | 1134 DONT_SELFOPTIMIZE_NODE(WhileStatement) |
1113 DONT_SELFOPTIMIZE_NODE(ForStatement) | 1135 DONT_SELFOPTIMIZE_NODE(ForStatement) |
1114 DONT_SELFOPTIMIZE_NODE(ForInStatement) | 1136 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement) |
1115 DONT_SELFOPTIMIZE_NODE(ForOfStatement) | 1137 DONT_SELFOPTIMIZE_NODE(ForOfStatement) |
1116 | 1138 |
1117 DONT_CACHE_NODE(ModuleLiteral) | 1139 DONT_CACHE_NODE(ModuleLiteral) |
1118 | 1140 |
| 1141 |
1119 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { | 1142 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { |
1120 increase_node_count(); | 1143 increase_node_count(); |
1121 if (node->is_jsruntime()) { | 1144 if (node->is_jsruntime()) { |
1122 // Don't try to inline JS runtime calls because we don't (currently) even | 1145 // Don't try to inline JS runtime calls because we don't (currently) even |
1123 // optimize them. | 1146 // optimize them. |
1124 add_flag(kDontInline); | 1147 add_flag(kDontInline); |
1125 } else if (node->function()->intrinsic_type == Runtime::INLINE && | 1148 } else if (node->function()->intrinsic_type == Runtime::INLINE && |
1126 (node->name()->IsOneByteEqualTo( | 1149 (node->name()->IsOneByteEqualTo( |
1127 STATIC_ASCII_VECTOR("_ArgumentsLength")) || | 1150 STATIC_ASCII_VECTOR("_ArgumentsLength")) || |
1128 node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) { | 1151 node->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_Arguments")))) { |
(...skipping 21 matching lines...) Expand all Loading... |
1150 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); | 1173 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
1151 str = arr; | 1174 str = arr; |
1152 } else { | 1175 } else { |
1153 str = DoubleToCString(value_->Number(), buffer); | 1176 str = DoubleToCString(value_->Number(), buffer); |
1154 } | 1177 } |
1155 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); | 1178 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); |
1156 } | 1179 } |
1157 | 1180 |
1158 | 1181 |
1159 } } // namespace v8::internal | 1182 } } // namespace v8::internal |
OLD | NEW |