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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 2142233003: Templatize AstVisitor with its subclass (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
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 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) { 1065 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) {
1066 for (int i = 0; i < exprs->length(); ++i) { 1066 for (int i = 0; i < exprs->length(); ++i) {
1067 VisitForValue(exprs->at(i)); 1067 VisitForValue(exprs->at(i));
1068 } 1068 }
1069 } 1069 }
1070 1070
1071 1071
1072 void AstGraphBuilder::VisitForValue(Expression* expr) { 1072 void AstGraphBuilder::VisitForValue(Expression* expr) {
1073 AstValueContext for_value(this); 1073 AstValueContext for_value(this);
1074 if (!CheckStackOverflow()) { 1074 if (!CheckStackOverflow()) {
1075 expr->Accept(this); 1075 AstVisitor<AstGraphBuilder>::Visit(expr);
1076 } else { 1076 } else {
1077 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); 1077 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
1078 } 1078 }
1079 } 1079 }
1080 1080
1081 1081
1082 void AstGraphBuilder::VisitForEffect(Expression* expr) { 1082 void AstGraphBuilder::VisitForEffect(Expression* expr) {
1083 AstEffectContext for_effect(this); 1083 AstEffectContext for_effect(this);
1084 if (!CheckStackOverflow()) { 1084 if (!CheckStackOverflow()) {
1085 expr->Accept(this); 1085 AstVisitor<AstGraphBuilder>::Visit(expr);
1086 } else { 1086 } else {
1087 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); 1087 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
1088 } 1088 }
1089 } 1089 }
1090 1090
1091 1091
1092 void AstGraphBuilder::VisitForTest(Expression* expr) { 1092 void AstGraphBuilder::VisitForTest(Expression* expr) {
1093 AstTestContext for_condition(this, expr->test_id()); 1093 AstTestContext for_condition(this, expr->test_id());
1094 if (!CheckStackOverflow()) { 1094 if (!CheckStackOverflow()) {
1095 expr->Accept(this); 1095 AstVisitor<AstGraphBuilder>::Visit(expr);
1096 } else { 1096 } else {
1097 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); 1097 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
1098 } 1098 }
1099 } 1099 }
1100 1100
1101 1101
1102 void AstGraphBuilder::Visit(Expression* expr) { 1102 void AstGraphBuilder::Visit(Expression* expr) {
1103 // Reuses enclosing AstContext. 1103 // Reuses enclosing AstContext.
1104 if (!CheckStackOverflow()) { 1104 if (!CheckStackOverflow()) {
1105 expr->Accept(this); 1105 AstVisitor<AstGraphBuilder>::Visit(expr);
1106 } else { 1106 } else {
1107 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); 1107 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant());
1108 } 1108 }
1109 } 1109 }
1110 1110
1111 1111
1112 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { 1112 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) {
1113 Variable* variable = decl->proxy()->var(); 1113 Variable* variable = decl->proxy()->var();
1114 VariableMode mode = decl->mode(); 1114 VariableMode mode = decl->mode();
1115 bool hole_init = mode == CONST || mode == LET; 1115 bool hole_init = mode == CONST || mode == LET;
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 2931
2932 2932
2933 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { 2933 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) {
2934 // Handled entirely in VisitSwitch. 2934 // Handled entirely in VisitSwitch.
2935 UNREACHABLE(); 2935 UNREACHABLE();
2936 } 2936 }
2937 2937
2938 2938
2939 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { 2939 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
2940 DCHECK(globals()->empty()); 2940 DCHECK(globals()->empty());
2941 AstVisitor::VisitDeclarations(declarations); 2941 AstVisitor<AstGraphBuilder>::VisitDeclarations(declarations);
2942 if (globals()->empty()) return; 2942 if (globals()->empty()) return;
2943 int array_index = 0; 2943 int array_index = 0;
2944 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( 2944 Handle<FixedArray> data = isolate()->factory()->NewFixedArray(
2945 static_cast<int>(globals()->size()), TENURED); 2945 static_cast<int>(globals()->size()), TENURED);
2946 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); 2946 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj);
2947 int encoded_flags = info()->GetDeclareGlobalsFlags(); 2947 int encoded_flags = info()->GetDeclareGlobalsFlags();
2948 Node* flags = jsgraph()->Constant(encoded_flags); 2948 Node* flags = jsgraph()->Constant(encoded_flags);
2949 Node* pairs = jsgraph()->Constant(data); 2949 Node* pairs = jsgraph()->Constant(data);
2950 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals); 2950 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals);
2951 Node* call = NewNode(op, pairs, flags); 2951 Node* call = NewNode(op, pairs, flags);
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
4369 // Phi does not exist yet, introduce one. 4369 // Phi does not exist yet, introduce one.
4370 value = NewPhi(inputs, value, control); 4370 value = NewPhi(inputs, value, control);
4371 value->ReplaceInput(inputs - 1, other); 4371 value->ReplaceInput(inputs - 1, other);
4372 } 4372 }
4373 return value; 4373 return value;
4374 } 4374 }
4375 4375
4376 } // namespace compiler 4376 } // namespace compiler
4377 } // namespace internal 4377 } // namespace internal
4378 } // namespace v8 4378 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698