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 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } | 1110 } |
1111 break; | 1111 break; |
1112 case VariableLocation::LOOKUP: { | 1112 case VariableLocation::LOOKUP: { |
1113 DCHECK(!variable->binding_needs_init()); | 1113 DCHECK(!variable->binding_needs_init()); |
1114 Node* name = jsgraph()->Constant(variable->name()); | 1114 Node* name = jsgraph()->Constant(variable->name()); |
1115 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareEvalVar); | 1115 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareEvalVar); |
1116 Node* store = NewNode(op, name); | 1116 Node* store = NewNode(op, name); |
1117 PrepareFrameState(store, decl->proxy()->id()); | 1117 PrepareFrameState(store, decl->proxy()->id()); |
1118 break; | 1118 break; |
1119 } | 1119 } |
| 1120 case VariableLocation::MODULE: |
| 1121 UNREACHABLE(); |
1120 } | 1122 } |
1121 } | 1123 } |
1122 | 1124 |
1123 | 1125 |
1124 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1126 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
1125 Variable* variable = decl->proxy()->var(); | 1127 Variable* variable = decl->proxy()->var(); |
1126 switch (variable->location()) { | 1128 switch (variable->location()) { |
1127 case VariableLocation::GLOBAL: | 1129 case VariableLocation::GLOBAL: |
1128 case VariableLocation::UNALLOCATED: { | 1130 case VariableLocation::UNALLOCATED: { |
1129 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 1131 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
(...skipping 23 matching lines...) Expand all Loading... |
1153 case VariableLocation::LOOKUP: { | 1155 case VariableLocation::LOOKUP: { |
1154 VisitForValue(decl->fun()); | 1156 VisitForValue(decl->fun()); |
1155 Node* value = environment()->Pop(); | 1157 Node* value = environment()->Pop(); |
1156 Node* name = jsgraph()->Constant(variable->name()); | 1158 Node* name = jsgraph()->Constant(variable->name()); |
1157 const Operator* op = | 1159 const Operator* op = |
1158 javascript()->CallRuntime(Runtime::kDeclareEvalFunction); | 1160 javascript()->CallRuntime(Runtime::kDeclareEvalFunction); |
1159 Node* store = NewNode(op, name, value); | 1161 Node* store = NewNode(op, name, value); |
1160 PrepareFrameState(store, decl->proxy()->id()); | 1162 PrepareFrameState(store, decl->proxy()->id()); |
1161 break; | 1163 break; |
1162 } | 1164 } |
| 1165 case VariableLocation::MODULE: |
| 1166 UNREACHABLE(); |
1163 } | 1167 } |
1164 } | 1168 } |
1165 | 1169 |
1166 | 1170 |
1167 void AstGraphBuilder::VisitBlock(Block* stmt) { | 1171 void AstGraphBuilder::VisitBlock(Block* stmt) { |
1168 BlockBuilder block(this); | 1172 BlockBuilder block(this); |
1169 ControlScopeForBreakable scope(this, stmt, &block); | 1173 ControlScopeForBreakable scope(this, stmt, &block); |
1170 if (stmt->labels() != nullptr) block.BeginBlock(); | 1174 if (stmt->labels() != nullptr) block.BeginBlock(); |
1171 if (stmt->scope() == nullptr) { | 1175 if (stmt->scope() == nullptr) { |
1172 // Visit statements in the same scope, no declarations. | 1176 // Visit statements in the same scope, no declarations. |
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3367 // Dynamic lookup of context variable (anywhere in the chain). | 3371 // Dynamic lookup of context variable (anywhere in the chain). |
3368 Handle<String> name = variable->name(); | 3372 Handle<String> name = variable->name(); |
3369 if (Node* node = TryLoadDynamicVariable(variable, name, bailout_id, | 3373 if (Node* node = TryLoadDynamicVariable(variable, name, bailout_id, |
3370 feedback, combine, typeof_mode)) { | 3374 feedback, combine, typeof_mode)) { |
3371 return node; | 3375 return node; |
3372 } | 3376 } |
3373 Node* value = BuildDynamicLoad(name, typeof_mode); | 3377 Node* value = BuildDynamicLoad(name, typeof_mode); |
3374 PrepareFrameState(value, bailout_id, combine); | 3378 PrepareFrameState(value, bailout_id, combine); |
3375 return value; | 3379 return value; |
3376 } | 3380 } |
| 3381 case VariableLocation::MODULE: |
| 3382 UNREACHABLE(); |
3377 } | 3383 } |
3378 UNREACHABLE(); | 3384 UNREACHABLE(); |
3379 return nullptr; | 3385 return nullptr; |
3380 } | 3386 } |
3381 | 3387 |
3382 | 3388 |
3383 Node* AstGraphBuilder::BuildVariableDelete(Variable* variable, | 3389 Node* AstGraphBuilder::BuildVariableDelete(Variable* variable, |
3384 BailoutId bailout_id, | 3390 BailoutId bailout_id, |
3385 OutputFrameStateCombine combine) { | 3391 OutputFrameStateCombine combine) { |
3386 switch (variable->location()) { | 3392 switch (variable->location()) { |
(...skipping 15 matching lines...) Expand all Loading... |
3402 } | 3408 } |
3403 case VariableLocation::LOOKUP: { | 3409 case VariableLocation::LOOKUP: { |
3404 // Dynamic lookup of context variable (anywhere in the chain). | 3410 // Dynamic lookup of context variable (anywhere in the chain). |
3405 Node* name = jsgraph()->Constant(variable->name()); | 3411 Node* name = jsgraph()->Constant(variable->name()); |
3406 const Operator* op = | 3412 const Operator* op = |
3407 javascript()->CallRuntime(Runtime::kDeleteLookupSlot); | 3413 javascript()->CallRuntime(Runtime::kDeleteLookupSlot); |
3408 Node* result = NewNode(op, name); | 3414 Node* result = NewNode(op, name); |
3409 PrepareFrameState(result, bailout_id, combine); | 3415 PrepareFrameState(result, bailout_id, combine); |
3410 return result; | 3416 return result; |
3411 } | 3417 } |
| 3418 case VariableLocation::MODULE: |
| 3419 UNREACHABLE(); |
3412 } | 3420 } |
3413 UNREACHABLE(); | 3421 UNREACHABLE(); |
3414 return nullptr; | 3422 return nullptr; |
3415 } | 3423 } |
3416 | 3424 |
3417 Node* AstGraphBuilder::BuildVariableAssignment( | 3425 Node* AstGraphBuilder::BuildVariableAssignment( |
3418 Variable* variable, Node* value, Token::Value op, | 3426 Variable* variable, Node* value, Token::Value op, |
3419 const VectorSlotPair& feedback, BailoutId bailout_id, | 3427 const VectorSlotPair& feedback, BailoutId bailout_id, |
3420 OutputFrameStateCombine combine) { | 3428 OutputFrameStateCombine combine) { |
3421 Node* the_hole = jsgraph()->TheHoleConstant(); | 3429 Node* the_hole = jsgraph()->TheHoleConstant(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 const Operator* op = javascript()->StoreContext(depth, variable->index()); | 3515 const Operator* op = javascript()->StoreContext(depth, variable->index()); |
3508 return NewNode(op, current_context(), value); | 3516 return NewNode(op, current_context(), value); |
3509 } | 3517 } |
3510 case VariableLocation::LOOKUP: { | 3518 case VariableLocation::LOOKUP: { |
3511 // Dynamic lookup of context variable (anywhere in the chain). | 3519 // Dynamic lookup of context variable (anywhere in the chain). |
3512 Handle<Name> name = variable->name(); | 3520 Handle<Name> name = variable->name(); |
3513 Node* store = BuildDynamicStore(name, value); | 3521 Node* store = BuildDynamicStore(name, value); |
3514 PrepareFrameState(store, bailout_id, combine); | 3522 PrepareFrameState(store, bailout_id, combine); |
3515 return store; | 3523 return store; |
3516 } | 3524 } |
| 3525 case VariableLocation::MODULE: |
| 3526 UNREACHABLE(); |
3517 } | 3527 } |
3518 UNREACHABLE(); | 3528 UNREACHABLE(); |
3519 return nullptr; | 3529 return nullptr; |
3520 } | 3530 } |
3521 | 3531 |
3522 | 3532 |
3523 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, | 3533 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, |
3524 const VectorSlotPair& feedback) { | 3534 const VectorSlotPair& feedback) { |
3525 const Operator* op = javascript()->LoadProperty(feedback); | 3535 const Operator* op = javascript()->LoadProperty(feedback); |
3526 Node* node = NewNode(op, object, key, GetFunctionClosure()); | 3536 Node* node = NewNode(op, object, key, GetFunctionClosure()); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4311 // Phi does not exist yet, introduce one. | 4321 // Phi does not exist yet, introduce one. |
4312 value = NewPhi(inputs, value, control); | 4322 value = NewPhi(inputs, value, control); |
4313 value->ReplaceInput(inputs - 1, other); | 4323 value->ReplaceInput(inputs - 1, other); |
4314 } | 4324 } |
4315 return value; | 4325 return value; |
4316 } | 4326 } |
4317 | 4327 |
4318 } // namespace compiler | 4328 } // namespace compiler |
4319 } // namespace internal | 4329 } // namespace internal |
4320 } // namespace v8 | 4330 } // namespace v8 |
OLD | NEW |