OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) { | 1105 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) { |
1106 for (int i = 0; i < exprs->length(); ++i) { | 1106 for (int i = 0; i < exprs->length(); ++i) { |
1107 VisitForValue(exprs->at(i)); | 1107 VisitForValue(exprs->at(i)); |
1108 } | 1108 } |
1109 } | 1109 } |
1110 | 1110 |
1111 | 1111 |
1112 void AstGraphBuilder::VisitForValue(Expression* expr) { | 1112 void AstGraphBuilder::VisitForValue(Expression* expr) { |
1113 AstValueContext for_value(this); | 1113 AstValueContext for_value(this); |
1114 if (!CheckStackOverflow()) { | 1114 if (!CheckStackOverflow()) { |
1115 expr->Accept(this); | 1115 AstVisitor<AstGraphBuilder>::Visit(expr); |
1116 } else { | 1116 } else { |
1117 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); | 1117 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); |
1118 } | 1118 } |
1119 } | 1119 } |
1120 | 1120 |
1121 | 1121 |
1122 void AstGraphBuilder::VisitForEffect(Expression* expr) { | 1122 void AstGraphBuilder::VisitForEffect(Expression* expr) { |
1123 AstEffectContext for_effect(this); | 1123 AstEffectContext for_effect(this); |
1124 if (!CheckStackOverflow()) { | 1124 if (!CheckStackOverflow()) { |
1125 expr->Accept(this); | 1125 AstVisitor<AstGraphBuilder>::Visit(expr); |
1126 } else { | 1126 } else { |
1127 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); | 1127 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); |
1128 } | 1128 } |
1129 } | 1129 } |
1130 | 1130 |
1131 | 1131 |
1132 void AstGraphBuilder::VisitForTest(Expression* expr) { | 1132 void AstGraphBuilder::VisitForTest(Expression* expr) { |
1133 AstTestContext for_condition(this, expr->test_id()); | 1133 AstTestContext for_condition(this, expr->test_id()); |
1134 if (!CheckStackOverflow()) { | 1134 if (!CheckStackOverflow()) { |
1135 expr->Accept(this); | 1135 AstVisitor<AstGraphBuilder>::Visit(expr); |
1136 } else { | 1136 } else { |
1137 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); | 1137 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); |
1138 } | 1138 } |
1139 } | 1139 } |
1140 | 1140 |
1141 | 1141 |
1142 void AstGraphBuilder::Visit(Expression* expr) { | 1142 void AstGraphBuilder::Visit(Expression* expr) { |
1143 // Reuses enclosing AstContext. | 1143 // Reuses enclosing AstContext. |
1144 if (!CheckStackOverflow()) { | 1144 if (!CheckStackOverflow()) { |
1145 expr->Accept(this); | 1145 AstVisitor<AstGraphBuilder>::Visit(expr); |
1146 } else { | 1146 } else { |
1147 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); | 1147 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); |
1148 } | 1148 } |
1149 } | 1149 } |
1150 | 1150 |
1151 | 1151 |
1152 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { | 1152 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { |
1153 Variable* variable = decl->proxy()->var(); | 1153 Variable* variable = decl->proxy()->var(); |
1154 VariableMode mode = decl->mode(); | 1154 VariableMode mode = decl->mode(); |
1155 bool hole_init = mode == CONST || mode == LET; | 1155 bool hole_init = mode == CONST || mode == LET; |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2975 | 2975 |
2976 | 2976 |
2977 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { | 2977 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { |
2978 // Handled entirely in VisitSwitch. | 2978 // Handled entirely in VisitSwitch. |
2979 UNREACHABLE(); | 2979 UNREACHABLE(); |
2980 } | 2980 } |
2981 | 2981 |
2982 | 2982 |
2983 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { | 2983 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { |
2984 DCHECK(globals()->empty()); | 2984 DCHECK(globals()->empty()); |
2985 AstVisitor::VisitDeclarations(declarations); | 2985 AstVisitor<AstGraphBuilder>::VisitDeclarations(declarations); |
2986 if (globals()->empty()) return; | 2986 if (globals()->empty()) return; |
2987 int array_index = 0; | 2987 int array_index = 0; |
2988 Handle<TypeFeedbackVector> feedback_vector( | 2988 Handle<TypeFeedbackVector> feedback_vector( |
2989 info()->closure()->feedback_vector()); | 2989 info()->closure()->feedback_vector()); |
2990 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( | 2990 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( |
2991 static_cast<int>(globals()->size()), TENURED); | 2991 static_cast<int>(globals()->size()), TENURED); |
2992 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); | 2992 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); |
2993 int encoded_flags = info()->GetDeclareGlobalsFlags(); | 2993 int encoded_flags = info()->GetDeclareGlobalsFlags(); |
2994 Node* flags = jsgraph()->Constant(encoded_flags); | 2994 Node* flags = jsgraph()->Constant(encoded_flags); |
2995 Node* pairs = jsgraph()->Constant(data); | 2995 Node* pairs = jsgraph()->Constant(data); |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4416 // Phi does not exist yet, introduce one. | 4416 // Phi does not exist yet, introduce one. |
4417 value = NewPhi(inputs, value, control); | 4417 value = NewPhi(inputs, value, control); |
4418 value->ReplaceInput(inputs - 1, other); | 4418 value->ReplaceInput(inputs - 1, other); |
4419 } | 4419 } |
4420 return value; | 4420 return value; |
4421 } | 4421 } |
4422 | 4422 |
4423 } // namespace compiler | 4423 } // namespace compiler |
4424 } // namespace internal | 4424 } // namespace internal |
4425 } // namespace v8 | 4425 } // namespace v8 |
OLD | NEW |