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

Side by Side Diff: src/ast.cc

Issue 660083005: AstNumberingVisitor does the work of AstConstructionVisitor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 // 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 989
990 990
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) \
1000 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1001 increase_node_count(); \
1002 }
1003 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1004 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1005 increase_node_count(); \
1006 add_slot_node(node); \
1007 }
1008 #define DONT_OPTIMIZE_NODE(NodeType) \
1009 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1010 increase_node_count(); \
1011 set_dont_crankshaft_reason(k##NodeType); \
1012 add_flag(kDontSelfOptimize); \
1013 }
1014 #define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1015 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1016 increase_node_count(); \
1017 add_slot_node(node); \
1018 set_dont_crankshaft_reason(k##NodeType); \
1019 add_flag(kDontSelfOptimize); \
1020 }
1021 #define DONT_TURBOFAN_NODE(NodeType) \
1022 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1023 increase_node_count(); \
1024 set_dont_crankshaft_reason(k##NodeType); \
1025 set_dont_turbofan_reason(k##NodeType); \
1026 add_flag(kDontSelfOptimize); \
1027 }
1028 #define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1029 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1030 increase_node_count(); \
1031 add_slot_node(node); \
1032 set_dont_crankshaft_reason(k##NodeType); \
1033 set_dont_turbofan_reason(k##NodeType); \
1034 add_flag(kDontSelfOptimize); \
1035 }
1036 #define DONT_SELFOPTIMIZE_NODE(NodeType) \
1037 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1038 increase_node_count(); \
1039 add_flag(kDontSelfOptimize); \
1040 }
1041 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1042 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1043 increase_node_count(); \
1044 add_slot_node(node); \
1045 add_flag(kDontSelfOptimize); \
1046 }
1047 #define DONT_CACHE_NODE(NodeType) \
1048 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1049 increase_node_count(); \
1050 set_dont_crankshaft_reason(k##NodeType); \
1051 add_flag(kDontSelfOptimize); \
1052 add_flag(kDontCache); \
1053 }
1054
1055 REGULAR_NODE(VariableDeclaration)
1056 REGULAR_NODE(FunctionDeclaration)
1057 REGULAR_NODE(Block)
1058 REGULAR_NODE(ExpressionStatement)
1059 REGULAR_NODE(EmptyStatement)
1060 REGULAR_NODE(IfStatement)
1061 REGULAR_NODE(ContinueStatement)
1062 REGULAR_NODE(BreakStatement)
1063 REGULAR_NODE(ReturnStatement)
1064 REGULAR_NODE(SwitchStatement)
1065 REGULAR_NODE(CaseClause)
1066 REGULAR_NODE(Conditional)
1067 REGULAR_NODE(Literal)
1068 REGULAR_NODE(ArrayLiteral)
1069 REGULAR_NODE(ObjectLiteral)
1070 REGULAR_NODE(RegExpLiteral)
1071 REGULAR_NODE(FunctionLiteral)
1072 REGULAR_NODE(Assignment)
1073 REGULAR_NODE(Throw)
1074 REGULAR_NODE(UnaryOperation)
1075 REGULAR_NODE(CountOperation)
1076 REGULAR_NODE(BinaryOperation)
1077 REGULAR_NODE(CompareOperation)
1078 REGULAR_NODE(ThisFunction)
1079
1080 REGULAR_NODE_WITH_FEEDBACK_SLOTS(Call)
1081 REGULAR_NODE_WITH_FEEDBACK_SLOTS(CallNew)
1082 REGULAR_NODE_WITH_FEEDBACK_SLOTS(Property)
1083 // In theory, for VariableProxy we'd have to add:
1084 // if (node->var()->IsLookupSlot())
1085 // set_dont_optimize_reason(kReferenceToAVariableWhichRequiresDynamicLookup);
1086 // But node->var() is usually not bound yet at VariableProxy creation time, and
1087 // LOOKUP variables only result from constructs that cannot be inlined anyway.
1088 REGULAR_NODE_WITH_FEEDBACK_SLOTS(VariableProxy)
1089
1090 // We currently do not optimize any modules.
1091 DONT_OPTIMIZE_NODE(ModuleDeclaration)
1092 DONT_OPTIMIZE_NODE(ImportDeclaration)
1093 DONT_OPTIMIZE_NODE(ExportDeclaration)
1094 DONT_OPTIMIZE_NODE(ModuleVariable)
1095 DONT_OPTIMIZE_NODE(ModulePath)
1096 DONT_OPTIMIZE_NODE(ModuleUrl)
1097 DONT_OPTIMIZE_NODE(ModuleStatement)
1098 DONT_OPTIMIZE_NODE(WithStatement)
1099 DONT_OPTIMIZE_NODE(DebuggerStatement)
1100 DONT_OPTIMIZE_NODE(NativeFunctionLiteral)
1101
1102 DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(Yield)
1103
1104 // TODO(turbofan): Remove the dont_turbofan_reason once this list is empty.
1105 // This list must be kept in sync with Pipeline::GenerateCode.
1106 DONT_TURBOFAN_NODE(ForOfStatement)
1107 DONT_TURBOFAN_NODE(TryCatchStatement)
1108 DONT_TURBOFAN_NODE(TryFinallyStatement)
1109 DONT_TURBOFAN_NODE(ClassLiteral)
1110
1111 DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(SuperReference)
1112
1113 DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
1114 DONT_SELFOPTIMIZE_NODE(WhileStatement)
1115 DONT_SELFOPTIMIZE_NODE(ForStatement)
1116
1117 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement)
1118
1119 DONT_CACHE_NODE(ModuleLiteral)
1120
1121
1122 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
1123 increase_node_count();
1124 add_slot_node(node);
1125 if (node->is_jsruntime()) {
1126 // Don't try to optimize JS runtime calls because we bailout on them.
1127 set_dont_crankshaft_reason(kCallToAJavaScriptRuntimeFunction);
1128 }
1129 }
1130
1131 #undef REGULAR_NODE
1132 #undef DONT_OPTIMIZE_NODE
1133 #undef DONT_SELFOPTIMIZE_NODE
1134 #undef DONT_CACHE_NODE
1135
1136
1137 uint32_t Literal::Hash() { 999 uint32_t Literal::Hash() {
1138 return raw_value()->IsString() 1000 return raw_value()->IsString()
1139 ? raw_value()->AsString()->hash() 1001 ? raw_value()->AsString()->hash()
1140 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); 1002 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber()));
1141 } 1003 }
1142 1004
1143 1005
1144 // static 1006 // static
1145 bool Literal::Match(void* literal1, void* literal2) { 1007 bool Literal::Match(void* literal1, void* literal2) {
1146 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1008 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1147 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1009 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1148 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || 1010 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) ||
1149 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1011 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1150 } 1012 }
1151 1013
1152 1014
1153 } } // namespace v8::internal 1015 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/ast-numbering.h » ('j') | src/ast-numbering.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698