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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 case VariableLocation::CONTEXT: | 1127 case VariableLocation::CONTEXT: |
1128 if (hole_init) { | 1128 if (hole_init) { |
1129 Node* value = jsgraph()->TheHoleConstant(); | 1129 Node* value = jsgraph()->TheHoleConstant(); |
1130 const Operator* op = javascript()->StoreContext(0, variable->index()); | 1130 const Operator* op = javascript()->StoreContext(0, variable->index()); |
1131 NewNode(op, current_context(), value); | 1131 NewNode(op, current_context(), value); |
1132 } | 1132 } |
1133 break; | 1133 break; |
1134 case VariableLocation::LOOKUP: { | 1134 case VariableLocation::LOOKUP: { |
1135 DCHECK(!hole_init); | 1135 DCHECK(!hole_init); |
1136 Node* name = jsgraph()->Constant(variable->name()); | 1136 Node* name = jsgraph()->Constant(variable->name()); |
1137 Node* value = jsgraph()->ZeroConstant(); // Indicates no initial value. | 1137 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareEvalVar); |
1138 Node* attr = | 1138 Node* store = NewNode(op, name); |
1139 jsgraph()->Constant(variable->DeclarationPropertyAttributes()); | |
1140 const Operator* op = | |
1141 javascript()->CallRuntime(Runtime::kDeclareLookupSlot); | |
1142 Node* store = NewNode(op, name, value, attr); | |
1143 PrepareFrameState(store, decl->proxy()->id()); | 1139 PrepareFrameState(store, decl->proxy()->id()); |
1144 break; | 1140 break; |
1145 } | 1141 } |
1146 } | 1142 } |
1147 } | 1143 } |
1148 | 1144 |
1149 | 1145 |
1150 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1146 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
1151 Variable* variable = decl->proxy()->var(); | 1147 Variable* variable = decl->proxy()->var(); |
1152 switch (variable->location()) { | 1148 switch (variable->location()) { |
(...skipping 18 matching lines...) Expand all Loading... |
1171 VisitForValue(decl->fun()); | 1167 VisitForValue(decl->fun()); |
1172 Node* value = environment()->Pop(); | 1168 Node* value = environment()->Pop(); |
1173 const Operator* op = javascript()->StoreContext(0, variable->index()); | 1169 const Operator* op = javascript()->StoreContext(0, variable->index()); |
1174 NewNode(op, current_context(), value); | 1170 NewNode(op, current_context(), value); |
1175 break; | 1171 break; |
1176 } | 1172 } |
1177 case VariableLocation::LOOKUP: { | 1173 case VariableLocation::LOOKUP: { |
1178 VisitForValue(decl->fun()); | 1174 VisitForValue(decl->fun()); |
1179 Node* value = environment()->Pop(); | 1175 Node* value = environment()->Pop(); |
1180 Node* name = jsgraph()->Constant(variable->name()); | 1176 Node* name = jsgraph()->Constant(variable->name()); |
1181 Node* attr = | |
1182 jsgraph()->Constant(variable->DeclarationPropertyAttributes()); | |
1183 const Operator* op = | 1177 const Operator* op = |
1184 javascript()->CallRuntime(Runtime::kDeclareLookupSlot); | 1178 javascript()->CallRuntime(Runtime::kDeclareEvalFunction); |
1185 Node* store = NewNode(op, name, value, attr); | 1179 Node* store = NewNode(op, name, value); |
1186 PrepareFrameState(store, decl->proxy()->id()); | 1180 PrepareFrameState(store, decl->proxy()->id()); |
1187 break; | 1181 break; |
1188 } | 1182 } |
1189 } | 1183 } |
1190 } | 1184 } |
1191 | 1185 |
1192 | 1186 |
1193 void AstGraphBuilder::VisitImportDeclaration(ImportDeclaration* decl) { | 1187 void AstGraphBuilder::VisitImportDeclaration(ImportDeclaration* decl) { |
1194 UNREACHABLE(); | 1188 UNREACHABLE(); |
1195 } | 1189 } |
(...skipping 3169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4365 // Phi does not exist yet, introduce one. | 4359 // Phi does not exist yet, introduce one. |
4366 value = NewPhi(inputs, value, control); | 4360 value = NewPhi(inputs, value, control); |
4367 value->ReplaceInput(inputs - 1, other); | 4361 value->ReplaceInput(inputs - 1, other); |
4368 } | 4362 } |
4369 return value; | 4363 return value; |
4370 } | 4364 } |
4371 | 4365 |
4372 } // namespace compiler | 4366 } // namespace compiler |
4373 } // namespace internal | 4367 } // namespace internal |
4374 } // namespace v8 | 4368 } // namespace v8 |
OLD | NEW |