| 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/compilation-info.h" | 8 #include "src/compilation-info.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/compiler/ast-loop-assignment-analyzer.h" | 10 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 VisitNoStackOverflowCheck(expr); | 1076 VisitNoStackOverflowCheck(expr); |
| 1077 } else { | 1077 } else { |
| 1078 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); | 1078 ast_context()->ProduceValue(expr, jsgraph()->UndefinedConstant()); |
| 1079 } | 1079 } |
| 1080 } | 1080 } |
| 1081 | 1081 |
| 1082 | 1082 |
| 1083 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { | 1083 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { |
| 1084 Variable* variable = decl->proxy()->var(); | 1084 Variable* variable = decl->proxy()->var(); |
| 1085 switch (variable->location()) { | 1085 switch (variable->location()) { |
| 1086 case VariableLocation::GLOBAL: | |
| 1087 case VariableLocation::UNALLOCATED: { | 1086 case VariableLocation::UNALLOCATED: { |
| 1088 DCHECK(!variable->binding_needs_init()); | 1087 DCHECK(!variable->binding_needs_init()); |
| 1089 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 1088 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
| 1090 DCHECK(!slot.IsInvalid()); | 1089 DCHECK(!slot.IsInvalid()); |
| 1091 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | 1090 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); |
| 1092 globals()->push_back(isolate()->factory()->undefined_value()); | 1091 globals()->push_back(isolate()->factory()->undefined_value()); |
| 1093 break; | 1092 break; |
| 1094 } | 1093 } |
| 1095 case VariableLocation::PARAMETER: | 1094 case VariableLocation::PARAMETER: |
| 1096 case VariableLocation::LOCAL: | 1095 case VariableLocation::LOCAL: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1116 } | 1115 } |
| 1117 case VariableLocation::MODULE: | 1116 case VariableLocation::MODULE: |
| 1118 UNREACHABLE(); | 1117 UNREACHABLE(); |
| 1119 } | 1118 } |
| 1120 } | 1119 } |
| 1121 | 1120 |
| 1122 | 1121 |
| 1123 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 1122 void AstGraphBuilder::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 1124 Variable* variable = decl->proxy()->var(); | 1123 Variable* variable = decl->proxy()->var(); |
| 1125 switch (variable->location()) { | 1124 switch (variable->location()) { |
| 1126 case VariableLocation::GLOBAL: | |
| 1127 case VariableLocation::UNALLOCATED: { | 1125 case VariableLocation::UNALLOCATED: { |
| 1128 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 1126 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
| 1129 decl->fun(), info()->script(), info()); | 1127 decl->fun(), info()->script(), info()); |
| 1130 // Check for stack-overflow exception. | 1128 // Check for stack-overflow exception. |
| 1131 if (function.is_null()) return SetStackOverflow(); | 1129 if (function.is_null()) return SetStackOverflow(); |
| 1132 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); | 1130 FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
| 1133 DCHECK(!slot.IsInvalid()); | 1131 DCHECK(!slot.IsInvalid()); |
| 1134 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); | 1132 globals()->push_back(handle(Smi::FromInt(slot.ToInt()), isolate())); |
| 1135 globals()->push_back(function); | 1133 globals()->push_back(function); |
| 1136 break; | 1134 break; |
| (...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 } | 3321 } |
| 3324 | 3322 |
| 3325 | 3323 |
| 3326 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, | 3324 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, |
| 3327 BailoutId bailout_id, | 3325 BailoutId bailout_id, |
| 3328 const VectorSlotPair& feedback, | 3326 const VectorSlotPair& feedback, |
| 3329 OutputFrameStateCombine combine, | 3327 OutputFrameStateCombine combine, |
| 3330 TypeofMode typeof_mode) { | 3328 TypeofMode typeof_mode) { |
| 3331 Node* the_hole = jsgraph()->TheHoleConstant(); | 3329 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 3332 switch (variable->location()) { | 3330 switch (variable->location()) { |
| 3333 case VariableLocation::GLOBAL: | |
| 3334 case VariableLocation::UNALLOCATED: { | 3331 case VariableLocation::UNALLOCATED: { |
| 3335 // Global var, const, or let variable. | 3332 // Global var, const, or let variable. |
| 3336 Handle<Name> name = variable->name(); | 3333 Handle<Name> name = variable->name(); |
| 3337 if (Node* node = TryLoadGlobalConstant(name)) return node; | 3334 if (Node* node = TryLoadGlobalConstant(name)) return node; |
| 3338 Node* value = BuildGlobalLoad(name, feedback, typeof_mode); | 3335 Node* value = BuildGlobalLoad(name, feedback, typeof_mode); |
| 3339 PrepareFrameState(value, bailout_id, combine); | 3336 PrepareFrameState(value, bailout_id, combine); |
| 3340 return value; | 3337 return value; |
| 3341 } | 3338 } |
| 3342 case VariableLocation::PARAMETER: | 3339 case VariableLocation::PARAMETER: |
| 3343 case VariableLocation::LOCAL: { | 3340 case VariableLocation::LOCAL: { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 } | 3382 } |
| 3386 UNREACHABLE(); | 3383 UNREACHABLE(); |
| 3387 return nullptr; | 3384 return nullptr; |
| 3388 } | 3385 } |
| 3389 | 3386 |
| 3390 | 3387 |
| 3391 Node* AstGraphBuilder::BuildVariableDelete(Variable* variable, | 3388 Node* AstGraphBuilder::BuildVariableDelete(Variable* variable, |
| 3392 BailoutId bailout_id, | 3389 BailoutId bailout_id, |
| 3393 OutputFrameStateCombine combine) { | 3390 OutputFrameStateCombine combine) { |
| 3394 switch (variable->location()) { | 3391 switch (variable->location()) { |
| 3395 case VariableLocation::GLOBAL: | |
| 3396 case VariableLocation::UNALLOCATED: { | 3392 case VariableLocation::UNALLOCATED: { |
| 3397 // Global var, const, or let variable. | 3393 // Global var, const, or let variable. |
| 3398 Node* global = BuildLoadGlobalObject(); | 3394 Node* global = BuildLoadGlobalObject(); |
| 3399 Node* name = jsgraph()->Constant(variable->name()); | 3395 Node* name = jsgraph()->Constant(variable->name()); |
| 3400 const Operator* op = javascript()->DeleteProperty(language_mode()); | 3396 const Operator* op = javascript()->DeleteProperty(language_mode()); |
| 3401 Node* result = NewNode(op, global, name); | 3397 Node* result = NewNode(op, global, name); |
| 3402 PrepareFrameState(result, bailout_id, combine); | 3398 PrepareFrameState(result, bailout_id, combine); |
| 3403 return result; | 3399 return result; |
| 3404 } | 3400 } |
| 3405 case VariableLocation::PARAMETER: | 3401 case VariableLocation::PARAMETER: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3424 return nullptr; | 3420 return nullptr; |
| 3425 } | 3421 } |
| 3426 | 3422 |
| 3427 Node* AstGraphBuilder::BuildVariableAssignment( | 3423 Node* AstGraphBuilder::BuildVariableAssignment( |
| 3428 Variable* variable, Node* value, Token::Value op, | 3424 Variable* variable, Node* value, Token::Value op, |
| 3429 const VectorSlotPair& feedback, BailoutId bailout_id, | 3425 const VectorSlotPair& feedback, BailoutId bailout_id, |
| 3430 OutputFrameStateCombine combine) { | 3426 OutputFrameStateCombine combine) { |
| 3431 Node* the_hole = jsgraph()->TheHoleConstant(); | 3427 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 3432 VariableMode mode = variable->mode(); | 3428 VariableMode mode = variable->mode(); |
| 3433 switch (variable->location()) { | 3429 switch (variable->location()) { |
| 3434 case VariableLocation::GLOBAL: | |
| 3435 case VariableLocation::UNALLOCATED: { | 3430 case VariableLocation::UNALLOCATED: { |
| 3436 // Global var, const, or let variable. | 3431 // Global var, const, or let variable. |
| 3437 Handle<Name> name = variable->name(); | 3432 Handle<Name> name = variable->name(); |
| 3438 Node* store = BuildGlobalStore(name, value, feedback); | 3433 Node* store = BuildGlobalStore(name, value, feedback); |
| 3439 PrepareFrameState(store, bailout_id, combine); | 3434 PrepareFrameState(store, bailout_id, combine); |
| 3440 return store; | 3435 return store; |
| 3441 } | 3436 } |
| 3442 case VariableLocation::PARAMETER: | 3437 case VariableLocation::PARAMETER: |
| 3443 case VariableLocation::LOCAL: | 3438 case VariableLocation::LOCAL: |
| 3444 // Local var, const, or let variable. | 3439 // Local var, const, or let variable. |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4337 // Phi does not exist yet, introduce one. | 4332 // Phi does not exist yet, introduce one. |
| 4338 value = NewPhi(inputs, value, control); | 4333 value = NewPhi(inputs, value, control); |
| 4339 value->ReplaceInput(inputs - 1, other); | 4334 value->ReplaceInput(inputs - 1, other); |
| 4340 } | 4335 } |
| 4341 return value; | 4336 return value; |
| 4342 } | 4337 } |
| 4343 | 4338 |
| 4344 } // namespace compiler | 4339 } // namespace compiler |
| 4345 } // namespace internal | 4340 } // namespace internal |
| 4346 } // namespace v8 | 4341 } // namespace v8 |
| OLD | NEW |