OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ast.h" | 5 #include "src/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 #include "src/builtins.h" | 8 #include "src/builtins.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 CaseClause::CaseClause(Zone* zone, Expression* label, | 991 CaseClause::CaseClause(Zone* zone, Expression* label, |
992 ZoneList<Statement*>* statements, int pos) | 992 ZoneList<Statement*>* statements, int pos) |
993 : Expression(zone, pos), | 993 : Expression(zone, pos), |
994 label_(label), | 994 label_(label), |
995 statements_(statements), | 995 statements_(statements), |
996 compare_type_(Type::None(zone)) {} | 996 compare_type_(Type::None(zone)) {} |
997 | 997 |
998 | 998 |
999 #define REGULAR_NODE(NodeType) \ | 999 #define REGULAR_NODE(NodeType) \ |
1000 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1000 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1001 increase_node_count(); \ |
1001 } | 1002 } |
1002 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1003 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
1003 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1004 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1005 increase_node_count(); \ |
1004 add_slot_node(node); \ | 1006 add_slot_node(node); \ |
1005 } | 1007 } |
1006 #define DONT_OPTIMIZE_NODE(NodeType) \ | 1008 #define DONT_OPTIMIZE_NODE(NodeType) \ |
1007 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1009 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1010 increase_node_count(); \ |
1008 set_dont_crankshaft_reason(k##NodeType); \ | 1011 set_dont_crankshaft_reason(k##NodeType); \ |
1009 add_flag(kDontSelfOptimize); \ | 1012 add_flag(kDontSelfOptimize); \ |
1010 } | 1013 } |
1011 #define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1014 #define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
1012 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1015 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1016 increase_node_count(); \ |
1013 add_slot_node(node); \ | 1017 add_slot_node(node); \ |
1014 set_dont_crankshaft_reason(k##NodeType); \ | 1018 set_dont_crankshaft_reason(k##NodeType); \ |
1015 add_flag(kDontSelfOptimize); \ | 1019 add_flag(kDontSelfOptimize); \ |
1016 } | 1020 } |
1017 #define DONT_TURBOFAN_NODE(NodeType) \ | 1021 #define DONT_TURBOFAN_NODE(NodeType) \ |
1018 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1022 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1023 increase_node_count(); \ |
1019 set_dont_crankshaft_reason(k##NodeType); \ | 1024 set_dont_crankshaft_reason(k##NodeType); \ |
1020 set_dont_turbofan_reason(k##NodeType); \ | 1025 set_dont_turbofan_reason(k##NodeType); \ |
1021 add_flag(kDontSelfOptimize); \ | 1026 add_flag(kDontSelfOptimize); \ |
1022 } | 1027 } |
1023 #define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1028 #define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
1024 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1029 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1030 increase_node_count(); \ |
1025 add_slot_node(node); \ | 1031 add_slot_node(node); \ |
1026 set_dont_crankshaft_reason(k##NodeType); \ | 1032 set_dont_crankshaft_reason(k##NodeType); \ |
1027 set_dont_turbofan_reason(k##NodeType); \ | 1033 set_dont_turbofan_reason(k##NodeType); \ |
1028 add_flag(kDontSelfOptimize); \ | 1034 add_flag(kDontSelfOptimize); \ |
1029 } | 1035 } |
1030 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ | 1036 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ |
1031 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1037 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1038 increase_node_count(); \ |
1032 add_flag(kDontSelfOptimize); \ | 1039 add_flag(kDontSelfOptimize); \ |
1033 } | 1040 } |
1034 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1041 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
1035 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1042 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1043 increase_node_count(); \ |
1036 add_slot_node(node); \ | 1044 add_slot_node(node); \ |
1037 add_flag(kDontSelfOptimize); \ | 1045 add_flag(kDontSelfOptimize); \ |
1038 } | 1046 } |
1039 #define DONT_CACHE_NODE(NodeType) \ | 1047 #define DONT_CACHE_NODE(NodeType) \ |
1040 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1048 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1049 increase_node_count(); \ |
1041 set_dont_crankshaft_reason(k##NodeType); \ | 1050 set_dont_crankshaft_reason(k##NodeType); \ |
1042 add_flag(kDontSelfOptimize); \ | 1051 add_flag(kDontSelfOptimize); \ |
1043 add_flag(kDontCache); \ | 1052 add_flag(kDontCache); \ |
1044 } | 1053 } |
1045 | 1054 |
1046 REGULAR_NODE(VariableDeclaration) | 1055 REGULAR_NODE(VariableDeclaration) |
1047 REGULAR_NODE(FunctionDeclaration) | 1056 REGULAR_NODE(FunctionDeclaration) |
1048 REGULAR_NODE(Block) | 1057 REGULAR_NODE(Block) |
1049 REGULAR_NODE(ExpressionStatement) | 1058 REGULAR_NODE(ExpressionStatement) |
1050 REGULAR_NODE(EmptyStatement) | 1059 REGULAR_NODE(EmptyStatement) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 DONT_SELFOPTIMIZE_NODE(DoWhileStatement) | 1113 DONT_SELFOPTIMIZE_NODE(DoWhileStatement) |
1105 DONT_SELFOPTIMIZE_NODE(WhileStatement) | 1114 DONT_SELFOPTIMIZE_NODE(WhileStatement) |
1106 DONT_SELFOPTIMIZE_NODE(ForStatement) | 1115 DONT_SELFOPTIMIZE_NODE(ForStatement) |
1107 | 1116 |
1108 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement) | 1117 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement) |
1109 | 1118 |
1110 DONT_CACHE_NODE(ModuleLiteral) | 1119 DONT_CACHE_NODE(ModuleLiteral) |
1111 | 1120 |
1112 | 1121 |
1113 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { | 1122 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { |
| 1123 increase_node_count(); |
1114 add_slot_node(node); | 1124 add_slot_node(node); |
1115 if (node->is_jsruntime()) { | 1125 if (node->is_jsruntime()) { |
1116 // Don't try to optimize JS runtime calls because we bailout on them. | 1126 // Don't try to optimize JS runtime calls because we bailout on them. |
1117 set_dont_crankshaft_reason(kCallToAJavaScriptRuntimeFunction); | 1127 set_dont_crankshaft_reason(kCallToAJavaScriptRuntimeFunction); |
1118 } | 1128 } |
1119 } | 1129 } |
1120 | 1130 |
1121 #undef REGULAR_NODE | 1131 #undef REGULAR_NODE |
1122 #undef DONT_OPTIMIZE_NODE | 1132 #undef DONT_OPTIMIZE_NODE |
1123 #undef DONT_SELFOPTIMIZE_NODE | 1133 #undef DONT_SELFOPTIMIZE_NODE |
(...skipping 10 matching lines...) Expand all Loading... |
1134 // static | 1144 // static |
1135 bool Literal::Match(void* literal1, void* literal2) { | 1145 bool Literal::Match(void* literal1, void* literal2) { |
1136 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1146 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1137 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1147 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1138 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1148 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
1139 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1149 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1140 } | 1150 } |
1141 | 1151 |
1142 | 1152 |
1143 } } // namespace v8::internal | 1153 } } // namespace v8::internal |
OLD | NEW |