| 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 | 1003 |
| 1004 #define REGULAR_NODE(NodeType) \ | 1004 #define REGULAR_NODE(NodeType) \ |
| 1005 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1005 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1006 } | 1006 } |
| 1007 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1007 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1008 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1008 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1009 add_slot_node(node); \ | 1009 add_slot_node(node); \ |
| 1010 } | 1010 } |
| 1011 #define DONT_OPTIMIZE_NODE(NodeType) \ | 1011 #define DONT_OPTIMIZE_NODE(NodeType) \ |
| 1012 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1012 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1013 set_dont_crankshaft_reason(k##NodeType); \ | |
| 1014 add_flag(kDontSelfOptimize); \ | |
| 1015 } | 1013 } |
| 1016 #define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1014 #define DONT_OPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1017 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1015 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1018 add_slot_node(node); \ | 1016 add_slot_node(node); \ |
| 1019 set_dont_crankshaft_reason(k##NodeType); \ | |
| 1020 add_flag(kDontSelfOptimize); \ | |
| 1021 } | 1017 } |
| 1022 #define DONT_TURBOFAN_NODE(NodeType) \ | 1018 #define DONT_TURBOFAN_NODE(NodeType) \ |
| 1023 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1019 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1024 set_dont_crankshaft_reason(k##NodeType); \ | |
| 1025 set_dont_turbofan_reason(k##NodeType); \ | |
| 1026 add_flag(kDontSelfOptimize); \ | |
| 1027 } | 1020 } |
| 1028 #define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1021 #define DONT_TURBOFAN_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1029 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1022 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1030 add_slot_node(node); \ | 1023 add_slot_node(node); \ |
| 1031 set_dont_crankshaft_reason(k##NodeType); \ | |
| 1032 set_dont_turbofan_reason(k##NodeType); \ | |
| 1033 add_flag(kDontSelfOptimize); \ | |
| 1034 } | 1024 } |
| 1035 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ | 1025 #define DONT_SELFOPTIMIZE_NODE(NodeType) \ |
| 1036 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1026 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1037 add_flag(kDontSelfOptimize); \ | |
| 1038 } | 1027 } |
| 1039 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ | 1028 #define DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ |
| 1040 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1029 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1041 add_slot_node(node); \ | 1030 add_slot_node(node); \ |
| 1042 add_flag(kDontSelfOptimize); \ | |
| 1043 } | 1031 } |
| 1044 #define DONT_CACHE_NODE(NodeType) \ | 1032 #define DONT_CACHE_NODE(NodeType) \ |
| 1045 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1033 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1046 set_dont_crankshaft_reason(k##NodeType); \ | |
| 1047 add_flag(kDontSelfOptimize); \ | |
| 1048 add_flag(kDontCache); \ | |
| 1049 } | 1034 } |
| 1050 | 1035 |
| 1051 REGULAR_NODE(VariableDeclaration) | 1036 REGULAR_NODE(VariableDeclaration) |
| 1052 REGULAR_NODE(FunctionDeclaration) | 1037 REGULAR_NODE(FunctionDeclaration) |
| 1053 REGULAR_NODE(Block) | 1038 REGULAR_NODE(Block) |
| 1054 REGULAR_NODE(ExpressionStatement) | 1039 REGULAR_NODE(ExpressionStatement) |
| 1055 REGULAR_NODE(EmptyStatement) | 1040 REGULAR_NODE(EmptyStatement) |
| 1056 REGULAR_NODE(IfStatement) | 1041 REGULAR_NODE(IfStatement) |
| 1057 REGULAR_NODE(ContinueStatement) | 1042 REGULAR_NODE(ContinueStatement) |
| 1058 REGULAR_NODE(BreakStatement) | 1043 REGULAR_NODE(BreakStatement) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 DONT_SELFOPTIMIZE_NODE(WhileStatement) | 1095 DONT_SELFOPTIMIZE_NODE(WhileStatement) |
| 1111 DONT_SELFOPTIMIZE_NODE(ForStatement) | 1096 DONT_SELFOPTIMIZE_NODE(ForStatement) |
| 1112 | 1097 |
| 1113 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement) | 1098 DONT_SELFOPTIMIZE_NODE_WITH_FEEDBACK_SLOTS(ForInStatement) |
| 1114 | 1099 |
| 1115 DONT_CACHE_NODE(ModuleLiteral) | 1100 DONT_CACHE_NODE(ModuleLiteral) |
| 1116 | 1101 |
| 1117 | 1102 |
| 1118 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { | 1103 void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) { |
| 1119 add_slot_node(node); | 1104 add_slot_node(node); |
| 1120 if (node->is_jsruntime()) { | |
| 1121 // Don't try to optimize JS runtime calls because we bailout on them. | |
| 1122 set_dont_crankshaft_reason(kCallToAJavaScriptRuntimeFunction); | |
| 1123 } | |
| 1124 } | 1105 } |
| 1125 | 1106 |
| 1126 #undef REGULAR_NODE | 1107 #undef REGULAR_NODE |
| 1127 #undef DONT_OPTIMIZE_NODE | 1108 #undef DONT_OPTIMIZE_NODE |
| 1128 #undef DONT_SELFOPTIMIZE_NODE | 1109 #undef DONT_SELFOPTIMIZE_NODE |
| 1129 #undef DONT_CACHE_NODE | 1110 #undef DONT_CACHE_NODE |
| 1130 | 1111 |
| 1131 | 1112 |
| 1132 uint32_t Literal::Hash() { | 1113 uint32_t Literal::Hash() { |
| 1133 return raw_value()->IsString() | 1114 return raw_value()->IsString() |
| 1134 ? raw_value()->AsString()->hash() | 1115 ? raw_value()->AsString()->hash() |
| 1135 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); | 1116 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); |
| 1136 } | 1117 } |
| 1137 | 1118 |
| 1138 | 1119 |
| 1139 // static | 1120 // static |
| 1140 bool Literal::Match(void* literal1, void* literal2) { | 1121 bool Literal::Match(void* literal1, void* literal2) { |
| 1141 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1122 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 1142 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1123 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 1143 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1124 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
| 1144 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1125 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 1145 } | 1126 } |
| 1146 | 1127 |
| 1147 | 1128 |
| 1148 } } // namespace v8::internal | 1129 } } // namespace v8::internal |
| OLD | NEW |