| 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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 } | 1178 } |
| 1179 break; | 1179 break; |
| 1180 case VariableLocation::LOOKUP: { | 1180 case VariableLocation::LOOKUP: { |
| 1181 DCHECK(!hole_init); | 1181 DCHECK(!hole_init); |
| 1182 Node* name = jsgraph()->Constant(variable->name()); | 1182 Node* name = jsgraph()->Constant(variable->name()); |
| 1183 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareEvalVar); | 1183 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareEvalVar); |
| 1184 Node* store = NewNode(op, name); | 1184 Node* store = NewNode(op, name); |
| 1185 PrepareFrameState(store, decl->proxy()->id()); | 1185 PrepareFrameState(store, decl->proxy()->id()); |
| 1186 break; | 1186 break; |
| 1187 } | 1187 } |
| 1188 case VariableLocation::MODULE: |
| 1189 UNREACHABLE(); |
| 1188 } | 1190 } |
| 1189 } | 1191 } |
| 1190 | 1192 |
| 1191 | 1193 |
| 1192 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1194 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 1193 Variable* variable = decl->proxy()->var(); | 1195 Variable* variable = decl->proxy()->var(); |
| 1194 switch (variable->location()) { | 1196 switch (variable->location()) { |
| 1195 case VariableLocation::GLOBAL: | 1197 case VariableLocation::GLOBAL: |
| 1196 case VariableLocation::UNALLOCATED: { | 1198 case VariableLocation::UNALLOCATED: { |
| 1197 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 1199 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1221 case VariableLocation::LOOKUP: { | 1223 case VariableLocation::LOOKUP: { |
| 1222 VisitForValue(decl->fun()); | 1224 VisitForValue(decl->fun()); |
| 1223 Node* value = environment()->Pop(); | 1225 Node* value = environment()->Pop(); |
| 1224 Node* name = jsgraph()->Constant(variable->name()); | 1226 Node* name = jsgraph()->Constant(variable->name()); |
| 1225 const Operator* op = | 1227 const Operator* op = |
| 1226 javascript()->CallRuntime(Runtime::kDeclareEvalFunction); | 1228 javascript()->CallRuntime(Runtime::kDeclareEvalFunction); |
| 1227 Node* store = NewNode(op, name, value); | 1229 Node* store = NewNode(op, name, value); |
| 1228 PrepareFrameState(store, decl->proxy()->id()); | 1230 PrepareFrameState(store, decl->proxy()->id()); |
| 1229 break; | 1231 break; |
| 1230 } | 1232 } |
| 1233 case VariableLocation::MODULE: |
| 1234 UNREACHABLE(); |
| 1231 } | 1235 } |
| 1232 } | 1236 } |
| 1233 | 1237 |
| 1234 | 1238 |
| 1235 void AstGraphBuilder::VisitBlock(Block* stmt) { | 1239 void AstGraphBuilder::VisitBlock(Block* stmt) { |
| 1236 BlockBuilder block(this); | 1240 BlockBuilder block(this); |
| 1237 ControlScopeForBreakable scope(this, stmt, &block); | 1241 ControlScopeForBreakable scope(this, stmt, &block); |
| 1238 if (stmt->labels() != nullptr) block.BeginBlock(); | 1242 if (stmt->labels() != nullptr) block.BeginBlock(); |
| 1239 if (stmt->scope() == nullptr) { | 1243 if (stmt->scope() == nullptr) { |
| 1240 // Visit statements in the same scope, no declarations. | 1244 // Visit statements in the same scope, no declarations. |
| (...skipping 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3438 // Dynamic lookup of context variable (anywhere in the chain). | 3442 // Dynamic lookup of context variable (anywhere in the chain). |
| 3439 Handle<String> name = variable->name(); | 3443 Handle<String> name = variable->name(); |
| 3440 if (Node* node = TryLoadDynamicVariable(variable, name, bailout_id, | 3444 if (Node* node = TryLoadDynamicVariable(variable, name, bailout_id, |
| 3441 feedback, combine, typeof_mode)) { | 3445 feedback, combine, typeof_mode)) { |
| 3442 return node; | 3446 return node; |
| 3443 } | 3447 } |
| 3444 Node* value = BuildDynamicLoad(name, typeof_mode); | 3448 Node* value = BuildDynamicLoad(name, typeof_mode); |
| 3445 PrepareFrameState(value, bailout_id, combine); | 3449 PrepareFrameState(value, bailout_id, combine); |
| 3446 return value; | 3450 return value; |
| 3447 } | 3451 } |
| 3452 case VariableLocation::MODULE: |
| 3453 UNREACHABLE(); |
| 3448 } | 3454 } |
| 3449 UNREACHABLE(); | 3455 UNREACHABLE(); |
| 3450 return nullptr; | 3456 return nullptr; |
| 3451 } | 3457 } |
| 3452 | 3458 |
| 3453 | 3459 |
| 3454 Node* AstGraphBuilder::BuildVariableDelete(Variable* variable, | 3460 Node* AstGraphBuilder::BuildVariableDelete(Variable* variable, |
| 3455 BailoutId bailout_id, | 3461 BailoutId bailout_id, |
| 3456 OutputFrameStateCombine combine) { | 3462 OutputFrameStateCombine combine) { |
| 3457 switch (variable->location()) { | 3463 switch (variable->location()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3473 } | 3479 } |
| 3474 case VariableLocation::LOOKUP: { | 3480 case VariableLocation::LOOKUP: { |
| 3475 // Dynamic lookup of context variable (anywhere in the chain). | 3481 // Dynamic lookup of context variable (anywhere in the chain). |
| 3476 Node* name = jsgraph()->Constant(variable->name()); | 3482 Node* name = jsgraph()->Constant(variable->name()); |
| 3477 const Operator* op = | 3483 const Operator* op = |
| 3478 javascript()->CallRuntime(Runtime::kDeleteLookupSlot); | 3484 javascript()->CallRuntime(Runtime::kDeleteLookupSlot); |
| 3479 Node* result = NewNode(op, name); | 3485 Node* result = NewNode(op, name); |
| 3480 PrepareFrameState(result, bailout_id, combine); | 3486 PrepareFrameState(result, bailout_id, combine); |
| 3481 return result; | 3487 return result; |
| 3482 } | 3488 } |
| 3489 case VariableLocation::MODULE: |
| 3490 UNREACHABLE(); |
| 3483 } | 3491 } |
| 3484 UNREACHABLE(); | 3492 UNREACHABLE(); |
| 3485 return nullptr; | 3493 return nullptr; |
| 3486 } | 3494 } |
| 3487 | 3495 |
| 3488 Node* AstGraphBuilder::BuildVariableAssignment( | 3496 Node* AstGraphBuilder::BuildVariableAssignment( |
| 3489 Variable* variable, Node* value, Token::Value op, | 3497 Variable* variable, Node* value, Token::Value op, |
| 3490 const VectorSlotPair& feedback, BailoutId bailout_id, | 3498 const VectorSlotPair& feedback, BailoutId bailout_id, |
| 3491 OutputFrameStateCombine combine) { | 3499 OutputFrameStateCombine combine) { |
| 3492 Node* the_hole = jsgraph()->TheHoleConstant(); | 3500 Node* the_hole = jsgraph()->TheHoleConstant(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3583 const Operator* op = javascript()->StoreContext(depth, variable->index()); | 3591 const Operator* op = javascript()->StoreContext(depth, variable->index()); |
| 3584 return NewNode(op, current_context(), value); | 3592 return NewNode(op, current_context(), value); |
| 3585 } | 3593 } |
| 3586 case VariableLocation::LOOKUP: { | 3594 case VariableLocation::LOOKUP: { |
| 3587 // Dynamic lookup of context variable (anywhere in the chain). | 3595 // Dynamic lookup of context variable (anywhere in the chain). |
| 3588 Handle<Name> name = variable->name(); | 3596 Handle<Name> name = variable->name(); |
| 3589 Node* store = BuildDynamicStore(name, value); | 3597 Node* store = BuildDynamicStore(name, value); |
| 3590 PrepareFrameState(store, bailout_id, combine); | 3598 PrepareFrameState(store, bailout_id, combine); |
| 3591 return store; | 3599 return store; |
| 3592 } | 3600 } |
| 3601 case VariableLocation::MODULE: |
| 3602 UNREACHABLE(); |
| 3593 } | 3603 } |
| 3594 UNREACHABLE(); | 3604 UNREACHABLE(); |
| 3595 return nullptr; | 3605 return nullptr; |
| 3596 } | 3606 } |
| 3597 | 3607 |
| 3598 | 3608 |
| 3599 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, | 3609 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, |
| 3600 const VectorSlotPair& feedback) { | 3610 const VectorSlotPair& feedback) { |
| 3601 const Operator* op = javascript()->LoadProperty(feedback); | 3611 const Operator* op = javascript()->LoadProperty(feedback); |
| 3602 Node* node = NewNode(op, object, key, GetFunctionClosure()); | 3612 Node* node = NewNode(op, object, key, GetFunctionClosure()); |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4390 // Phi does not exist yet, introduce one. | 4400 // Phi does not exist yet, introduce one. |
| 4391 value = NewPhi(inputs, value, control); | 4401 value = NewPhi(inputs, value, control); |
| 4392 value->ReplaceInput(inputs - 1, other); | 4402 value->ReplaceInput(inputs - 1, other); |
| 4393 } | 4403 } |
| 4394 return value; | 4404 return value; |
| 4395 } | 4405 } |
| 4396 | 4406 |
| 4397 } // namespace compiler | 4407 } // namespace compiler |
| 4398 } // namespace internal | 4408 } // namespace internal |
| 4399 } // namespace v8 | 4409 } // namespace v8 |
| OLD | NEW |