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