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

Side by Side Diff: src/ast.cc

Issue 679943004: Remove AstConstructionVisitor/AstNullVisitor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « src/ast.h ('k') | src/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 }
1002 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1003 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1004 }
1005 #define DONT_OPTIMIZE_NODE(NodeType) \
1006 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1007 }
1008 #define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1009 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1010 }
1011 #define DONT_TURBOFAN_NODE(NodeType) \
1012 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1013 }
1014 #define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1015 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1016 }
1017 #define DONT_SELFOPTIMIZE_NODE(NodeType) \
1018 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1019 }
1020 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1021 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1022 }
1023 #define DONT_CACHE_NODE(NodeType) \
1024 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1025 }
1026
1027 REGULAR_NODE(VariableDeclaration)
1028 REGULAR_NODE(FunctionDeclaration)
1029 REGULAR_NODE(Block)
1030 REGULAR_NODE(ExpressionStatement)
1031 REGULAR_NODE(EmptyStatement)
1032 REGULAR_NODE(IfStatement)
1033 REGULAR_NODE(ContinueStatement)
1034 REGULAR_NODE(BreakStatement)
1035 REGULAR_NODE(ReturnStatement)
1036 REGULAR_NODE(SwitchStatement)
1037 REGULAR_NODE(CaseClause)
1038 REGULAR_NODE(Conditional)
1039 REGULAR_NODE(Literal)
1040 REGULAR_NODE(ArrayLiteral)
1041 REGULAR_NODE(ObjectLiteral)
1042 REGULAR_NODE(RegExpLiteral)
1043 REGULAR_NODE(FunctionLiteral)
1044 REGULAR_NODE(Assignment)
1045 REGULAR_NODE(Throw)
1046 REGULAR_NODE(UnaryOperation)
1047 REGULAR_NODE(CountOperation)
1048 REGULAR_NODE(BinaryOperation)
1049 REGULAR_NODE(CompareOperation)
1050 REGULAR_NODE(ThisFunction)
1051
1052 REGULAR_NODE_WITH_FEEDBACK_SLOTS(Call)
1053 REGULAR_NODE_WITH_FEEDBACK_SLOTS(CallNew)
1054 REGULAR_NODE_WITH_FEEDBACK_SLOTS(Property)
1055 // In theory, for VariableProxy we'd have to add:
1056 // if (node->var()->IsLookupSlot())
1057 // set_dont_optimize_reason(kReferenceToAVariableWhichRequiresDynamicLookup);
1058 // But node->var() is usually not bound yet at VariableProxy creation time, and
1059 // LOOKUP variables only result from constructs that cannot be inlined anyway.
1060 REGULAR_NODE_WITH_FEEDBACK_SLOTS(VariableProxy)
1061
1062 // We currently do not optimize any modules.
1063 DONT_OPTIMIZE_NODE(ModuleDeclaration)
1064 DONT_OPTIMIZE_NODE(ImportDeclaration)
1065 DONT_OPTIMIZE_NODE(ExportDeclaration)
1066 DONT_OPTIMIZE_NODE(ModuleVariable)
1067 DONT_OPTIMIZE_NODE(ModulePath)
1068 DONT_OPTIMIZE_NODE(ModuleUrl)
1069 DONT_OPTIMIZE_NODE(ModuleStatement)
1070 DONT_OPTIMIZE_NODE(WithStatement)
1071 DONT_OPTIMIZE_NODE(DebuggerStatement)
1072 DONT_OPTIMIZE_NODE(NativeFunctionLiteral)
1073
1074 DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(Yield)
1075
1076 // TODO(turbofan): Remove the dont_turbofan_reason once this list is empty.
1077 // This list must be kept in sync with Pipeline::GenerateCode.
1078 DONT_TURBOFAN_NODE(ForOfStatement)
1079 DONT_TURBOFAN_NODE(TryCatchStatement)
1080 DONT_TURBOFAN_NODE(TryFinallyStatement)
1081 DONT_TURBOFAN_NODE(ClassLiteral)
1082
1083 DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(SuperReference)
1084
1085 DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
1086 DONT_SELFOPTIMIZE_NODE(WhileStatement)
1087 DONT_SELFOPTIMIZE_NODE(ForStatement)
1088
1089 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement)
1090
1091 DONT_CACHE_NODE(ModuleLiteral)
1092
1093
1094 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
1095 }
1096
1097 #undef REGULAR_NODE
1098 #undef DONT_OPTIMIZE_NODE
1099 #undef DONT_SELFOPTIMIZE_NODE
1100 #undef DONT_CACHE_NODE
1101
1102
1103 uint32_t Literal::Hash() { 999 uint32_t Literal::Hash() {
1104 return raw_value()->IsString() 1000 return raw_value()->IsString()
1105 ? raw_value()->AsString()->hash() 1001 ? raw_value()->AsString()->hash()
1106 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); 1002 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber()));
1107 } 1003 }
1108 1004
1109 1005
1110 // static 1006 // static
1111 bool Literal::Match(void* literal1, void* literal2) { 1007 bool Literal::Match(void* literal1, void* literal2) {
1112 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1008 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1113 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1009 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1114 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || 1010 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) ||
1115 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1011 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1116 } 1012 }
1117 1013
1118 1014
1119 } } // namespace v8::internal 1015 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698