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