OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 5393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5404 return context; | 5404 return context; |
5405 } | 5405 } |
5406 | 5406 |
5407 | 5407 |
5408 void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 5408 void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
5409 DCHECK(!HasStackOverflow()); | 5409 DCHECK(!HasStackOverflow()); |
5410 DCHECK(current_block() != NULL); | 5410 DCHECK(current_block() != NULL); |
5411 DCHECK(current_block()->HasPredecessor()); | 5411 DCHECK(current_block()->HasPredecessor()); |
5412 Variable* variable = expr->var(); | 5412 Variable* variable = expr->var(); |
5413 switch (variable->location()) { | 5413 switch (variable->location()) { |
5414 case Variable::UNALLOCATED: { | 5414 case VariableLocation::GLOBAL: |
| 5415 case VariableLocation::UNALLOCATED: { |
5415 if (IsLexicalVariableMode(variable->mode())) { | 5416 if (IsLexicalVariableMode(variable->mode())) { |
5416 // TODO(rossberg): should this be an DCHECK? | 5417 // TODO(rossberg): should this be an DCHECK? |
5417 return Bailout(kReferenceToGlobalLexicalVariable); | 5418 return Bailout(kReferenceToGlobalLexicalVariable); |
5418 } | 5419 } |
5419 // Handle known global constants like 'undefined' specially to avoid a | 5420 // Handle known global constants like 'undefined' specially to avoid a |
5420 // load from a global cell for them. | 5421 // load from a global cell for them. |
5421 Handle<Object> constant_value = | 5422 Handle<Object> constant_value = |
5422 isolate()->factory()->GlobalConstantFor(variable->name()); | 5423 isolate()->factory()->GlobalConstantFor(variable->name()); |
5423 if (!constant_value.is_null()) { | 5424 if (!constant_value.is_null()) { |
5424 HConstant* instr = New<HConstant>(constant_value); | 5425 HConstant* instr = New<HConstant>(constant_value); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5510 HLoadGlobalGeneric* instr = | 5511 HLoadGlobalGeneric* instr = |
5511 New<HLoadGlobalGeneric>(global_object, | 5512 New<HLoadGlobalGeneric>(global_object, |
5512 variable->name(), | 5513 variable->name(), |
5513 ast_context()->is_for_typeof()); | 5514 ast_context()->is_for_typeof()); |
5514 instr->SetVectorAndSlot(handle(current_feedback_vector(), isolate()), | 5515 instr->SetVectorAndSlot(handle(current_feedback_vector(), isolate()), |
5515 expr->VariableFeedbackSlot()); | 5516 expr->VariableFeedbackSlot()); |
5516 return ast_context()->ReturnInstruction(instr, expr->id()); | 5517 return ast_context()->ReturnInstruction(instr, expr->id()); |
5517 } | 5518 } |
5518 } | 5519 } |
5519 | 5520 |
5520 case Variable::PARAMETER: | 5521 case VariableLocation::PARAMETER: |
5521 case Variable::LOCAL: { | 5522 case VariableLocation::LOCAL: { |
5522 HValue* value = LookupAndMakeLive(variable); | 5523 HValue* value = LookupAndMakeLive(variable); |
5523 if (value == graph()->GetConstantHole()) { | 5524 if (value == graph()->GetConstantHole()) { |
5524 DCHECK(IsDeclaredVariableMode(variable->mode()) && | 5525 DCHECK(IsDeclaredVariableMode(variable->mode()) && |
5525 variable->mode() != VAR); | 5526 variable->mode() != VAR); |
5526 return Bailout(kReferenceToUninitializedVariable); | 5527 return Bailout(kReferenceToUninitializedVariable); |
5527 } | 5528 } |
5528 return ast_context()->ReturnValue(value); | 5529 return ast_context()->ReturnValue(value); |
5529 } | 5530 } |
5530 | 5531 |
5531 case Variable::CONTEXT: { | 5532 case VariableLocation::CONTEXT: { |
5532 HValue* context = BuildContextChainWalk(variable); | 5533 HValue* context = BuildContextChainWalk(variable); |
5533 HLoadContextSlot::Mode mode; | 5534 HLoadContextSlot::Mode mode; |
5534 switch (variable->mode()) { | 5535 switch (variable->mode()) { |
5535 case LET: | 5536 case LET: |
5536 case CONST: | 5537 case CONST: |
5537 mode = HLoadContextSlot::kCheckDeoptimize; | 5538 mode = HLoadContextSlot::kCheckDeoptimize; |
5538 break; | 5539 break; |
5539 case CONST_LEGACY: | 5540 case CONST_LEGACY: |
5540 mode = HLoadContextSlot::kCheckReturnUndefined; | 5541 mode = HLoadContextSlot::kCheckReturnUndefined; |
5541 break; | 5542 break; |
5542 default: | 5543 default: |
5543 mode = HLoadContextSlot::kNoCheck; | 5544 mode = HLoadContextSlot::kNoCheck; |
5544 break; | 5545 break; |
5545 } | 5546 } |
5546 HLoadContextSlot* instr = | 5547 HLoadContextSlot* instr = |
5547 new(zone()) HLoadContextSlot(context, variable->index(), mode); | 5548 new(zone()) HLoadContextSlot(context, variable->index(), mode); |
5548 return ast_context()->ReturnInstruction(instr, expr->id()); | 5549 return ast_context()->ReturnInstruction(instr, expr->id()); |
5549 } | 5550 } |
5550 | 5551 |
5551 case Variable::LOOKUP: | 5552 case VariableLocation::LOOKUP: |
5552 return Bailout(kReferenceToAVariableWhichRequiresDynamicLookup); | 5553 return Bailout(kReferenceToAVariableWhichRequiresDynamicLookup); |
5553 } | 5554 } |
5554 } | 5555 } |
5555 | 5556 |
5556 | 5557 |
5557 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { | 5558 void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { |
5558 DCHECK(!HasStackOverflow()); | 5559 DCHECK(!HasStackOverflow()); |
5559 DCHECK(current_block() != NULL); | 5560 DCHECK(current_block() != NULL); |
5560 DCHECK(current_block()->HasPredecessor()); | 5561 DCHECK(current_block()->HasPredecessor()); |
5561 HConstant* instr = New<HConstant>(expr->value()); | 5562 HConstant* instr = New<HConstant>(expr->value()); |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6752 | 6753 |
6753 if (proxy != NULL) { | 6754 if (proxy != NULL) { |
6754 Variable* var = proxy->var(); | 6755 Variable* var = proxy->var(); |
6755 if (var->mode() == LET) { | 6756 if (var->mode() == LET) { |
6756 return Bailout(kUnsupportedLetCompoundAssignment); | 6757 return Bailout(kUnsupportedLetCompoundAssignment); |
6757 } | 6758 } |
6758 | 6759 |
6759 CHECK_ALIVE(VisitForValue(operation)); | 6760 CHECK_ALIVE(VisitForValue(operation)); |
6760 | 6761 |
6761 switch (var->location()) { | 6762 switch (var->location()) { |
6762 case Variable::UNALLOCATED: | 6763 case VariableLocation::GLOBAL: |
| 6764 case VariableLocation::UNALLOCATED: |
6763 HandleGlobalVariableAssignment(var, | 6765 HandleGlobalVariableAssignment(var, |
6764 Top(), | 6766 Top(), |
6765 expr->AssignmentId()); | 6767 expr->AssignmentId()); |
6766 break; | 6768 break; |
6767 | 6769 |
6768 case Variable::PARAMETER: | 6770 case VariableLocation::PARAMETER: |
6769 case Variable::LOCAL: | 6771 case VariableLocation::LOCAL: |
6770 if (var->mode() == CONST_LEGACY) { | 6772 if (var->mode() == CONST_LEGACY) { |
6771 return Bailout(kUnsupportedConstCompoundAssignment); | 6773 return Bailout(kUnsupportedConstCompoundAssignment); |
6772 } | 6774 } |
6773 if (var->mode() == CONST) { | 6775 if (var->mode() == CONST) { |
6774 return Bailout(kNonInitializerAssignmentToConst); | 6776 return Bailout(kNonInitializerAssignmentToConst); |
6775 } | 6777 } |
6776 BindIfLive(var, Top()); | 6778 BindIfLive(var, Top()); |
6777 break; | 6779 break; |
6778 | 6780 |
6779 case Variable::CONTEXT: { | 6781 case VariableLocation::CONTEXT: { |
6780 // Bail out if we try to mutate a parameter value in a function | 6782 // Bail out if we try to mutate a parameter value in a function |
6781 // using the arguments object. We do not (yet) correctly handle the | 6783 // using the arguments object. We do not (yet) correctly handle the |
6782 // arguments property of the function. | 6784 // arguments property of the function. |
6783 if (current_info()->scope()->arguments() != NULL) { | 6785 if (current_info()->scope()->arguments() != NULL) { |
6784 // Parameters will be allocated to context slots. We have no | 6786 // Parameters will be allocated to context slots. We have no |
6785 // direct way to detect that the variable is a parameter so we do | 6787 // direct way to detect that the variable is a parameter so we do |
6786 // a linear search of the parameter variables. | 6788 // a linear search of the parameter variables. |
6787 int count = current_info()->scope()->num_parameters(); | 6789 int count = current_info()->scope()->num_parameters(); |
6788 for (int i = 0; i < count; ++i) { | 6790 for (int i = 0; i < count; ++i) { |
6789 if (var == current_info()->scope()->parameter(i)) { | 6791 if (var == current_info()->scope()->parameter(i)) { |
(...skipping 18 matching lines...) Expand all Loading... |
6808 | 6810 |
6809 HValue* context = BuildContextChainWalk(var); | 6811 HValue* context = BuildContextChainWalk(var); |
6810 HStoreContextSlot* instr = Add<HStoreContextSlot>( | 6812 HStoreContextSlot* instr = Add<HStoreContextSlot>( |
6811 context, var->index(), mode, Top()); | 6813 context, var->index(), mode, Top()); |
6812 if (instr->HasObservableSideEffects()) { | 6814 if (instr->HasObservableSideEffects()) { |
6813 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); | 6815 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); |
6814 } | 6816 } |
6815 break; | 6817 break; |
6816 } | 6818 } |
6817 | 6819 |
6818 case Variable::LOOKUP: | 6820 case VariableLocation::LOOKUP: |
6819 return Bailout(kCompoundAssignmentToLookupSlot); | 6821 return Bailout(kCompoundAssignmentToLookupSlot); |
6820 } | 6822 } |
6821 return ast_context()->ReturnValue(Pop()); | 6823 return ast_context()->ReturnValue(Pop()); |
6822 | 6824 |
6823 } else if (prop != NULL) { | 6825 } else if (prop != NULL) { |
6824 CHECK_ALIVE(VisitForValue(prop->obj())); | 6826 CHECK_ALIVE(VisitForValue(prop->obj())); |
6825 HValue* object = Top(); | 6827 HValue* object = Top(); |
6826 HValue* key = NULL; | 6828 HValue* key = NULL; |
6827 if (!prop->key()->IsPropertyName() || prop->IsStringAccess()) { | 6829 if (!prop->key()->IsPropertyName() || prop->IsStringAccess()) { |
6828 CHECK_ALIVE(VisitForValue(prop->key())); | 6830 CHECK_ALIVE(VisitForValue(prop->key())); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6878 // variables (e.g. initialization inside a loop). | 6880 // variables (e.g. initialization inside a loop). |
6879 HValue* old_value = environment()->Lookup(var); | 6881 HValue* old_value = environment()->Lookup(var); |
6880 Add<HUseConst>(old_value); | 6882 Add<HUseConst>(old_value); |
6881 } | 6883 } |
6882 } | 6884 } |
6883 | 6885 |
6884 if (proxy->IsArguments()) return Bailout(kAssignmentToArguments); | 6886 if (proxy->IsArguments()) return Bailout(kAssignmentToArguments); |
6885 | 6887 |
6886 // Handle the assignment. | 6888 // Handle the assignment. |
6887 switch (var->location()) { | 6889 switch (var->location()) { |
6888 case Variable::UNALLOCATED: | 6890 case VariableLocation::GLOBAL: |
| 6891 case VariableLocation::UNALLOCATED: |
6889 CHECK_ALIVE(VisitForValue(expr->value())); | 6892 CHECK_ALIVE(VisitForValue(expr->value())); |
6890 HandleGlobalVariableAssignment(var, | 6893 HandleGlobalVariableAssignment(var, |
6891 Top(), | 6894 Top(), |
6892 expr->AssignmentId()); | 6895 expr->AssignmentId()); |
6893 return ast_context()->ReturnValue(Pop()); | 6896 return ast_context()->ReturnValue(Pop()); |
6894 | 6897 |
6895 case Variable::PARAMETER: | 6898 case VariableLocation::PARAMETER: |
6896 case Variable::LOCAL: { | 6899 case VariableLocation::LOCAL: { |
6897 // Perform an initialization check for let declared variables | 6900 // Perform an initialization check for let declared variables |
6898 // or parameters. | 6901 // or parameters. |
6899 if (var->mode() == LET && expr->op() == Token::ASSIGN) { | 6902 if (var->mode() == LET && expr->op() == Token::ASSIGN) { |
6900 HValue* env_value = environment()->Lookup(var); | 6903 HValue* env_value = environment()->Lookup(var); |
6901 if (env_value == graph()->GetConstantHole()) { | 6904 if (env_value == graph()->GetConstantHole()) { |
6902 return Bailout(kAssignmentToLetVariableBeforeInitialization); | 6905 return Bailout(kAssignmentToLetVariableBeforeInitialization); |
6903 } | 6906 } |
6904 } | 6907 } |
6905 // We do not allow the arguments object to occur in a context where it | 6908 // We do not allow the arguments object to occur in a context where it |
6906 // may escape, but assignments to stack-allocated locals are | 6909 // may escape, but assignments to stack-allocated locals are |
6907 // permitted. | 6910 // permitted. |
6908 CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED)); | 6911 CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED)); |
6909 HValue* value = Pop(); | 6912 HValue* value = Pop(); |
6910 BindIfLive(var, value); | 6913 BindIfLive(var, value); |
6911 return ast_context()->ReturnValue(value); | 6914 return ast_context()->ReturnValue(value); |
6912 } | 6915 } |
6913 | 6916 |
6914 case Variable::CONTEXT: { | 6917 case VariableLocation::CONTEXT: { |
6915 // Bail out if we try to mutate a parameter value in a function using | 6918 // Bail out if we try to mutate a parameter value in a function using |
6916 // the arguments object. We do not (yet) correctly handle the | 6919 // the arguments object. We do not (yet) correctly handle the |
6917 // arguments property of the function. | 6920 // arguments property of the function. |
6918 if (current_info()->scope()->arguments() != NULL) { | 6921 if (current_info()->scope()->arguments() != NULL) { |
6919 // Parameters will rewrite to context slots. We have no direct way | 6922 // Parameters will rewrite to context slots. We have no direct way |
6920 // to detect that the variable is a parameter. | 6923 // to detect that the variable is a parameter. |
6921 int count = current_info()->scope()->num_parameters(); | 6924 int count = current_info()->scope()->num_parameters(); |
6922 for (int i = 0; i < count; ++i) { | 6925 for (int i = 0; i < count; ++i) { |
6923 if (var == current_info()->scope()->parameter(i)) { | 6926 if (var == current_info()->scope()->parameter(i)) { |
6924 return Bailout(kAssignmentToParameterInArgumentsObject); | 6927 return Bailout(kAssignmentToParameterInArgumentsObject); |
(...skipping 29 matching lines...) Expand all Loading... |
6954 | 6957 |
6955 HValue* context = BuildContextChainWalk(var); | 6958 HValue* context = BuildContextChainWalk(var); |
6956 HStoreContextSlot* instr = Add<HStoreContextSlot>( | 6959 HStoreContextSlot* instr = Add<HStoreContextSlot>( |
6957 context, var->index(), mode, Top()); | 6960 context, var->index(), mode, Top()); |
6958 if (instr->HasObservableSideEffects()) { | 6961 if (instr->HasObservableSideEffects()) { |
6959 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); | 6962 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); |
6960 } | 6963 } |
6961 return ast_context()->ReturnValue(Pop()); | 6964 return ast_context()->ReturnValue(Pop()); |
6962 } | 6965 } |
6963 | 6966 |
6964 case Variable::LOOKUP: | 6967 case VariableLocation::LOOKUP: |
6965 return Bailout(kAssignmentToLOOKUPVariable); | 6968 return Bailout(kAssignmentToLOOKUPVariable); |
6966 } | 6969 } |
6967 } else { | 6970 } else { |
6968 return Bailout(kInvalidLeftHandSideInAssignment); | 6971 return Bailout(kInvalidLeftHandSideInAssignment); |
6969 } | 6972 } |
6970 } | 6973 } |
6971 | 6974 |
6972 | 6975 |
6973 void HOptimizedGraphBuilder::VisitYield(Yield* expr) { | 6976 void HOptimizedGraphBuilder::VisitYield(Yield* expr) { |
6974 // Generators are not optimized, so we should never get here. | 6977 // Generators are not optimized, so we should never get here. |
(...skipping 3236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10211 HValue* key = Pop(); | 10214 HValue* key = Pop(); |
10212 HValue* obj = Pop(); | 10215 HValue* obj = Pop(); |
10213 HValue* function = AddLoadJSBuiltin(Builtins::DELETE); | 10216 HValue* function = AddLoadJSBuiltin(Builtins::DELETE); |
10214 Add<HPushArguments>(obj, key, Add<HConstant>(function_language_mode())); | 10217 Add<HPushArguments>(obj, key, Add<HConstant>(function_language_mode())); |
10215 // TODO(olivf) InvokeFunction produces a check for the parameter count, | 10218 // TODO(olivf) InvokeFunction produces a check for the parameter count, |
10216 // even though we are certain to pass the correct number of arguments here. | 10219 // even though we are certain to pass the correct number of arguments here. |
10217 HInstruction* instr = New<HInvokeFunction>(function, 3); | 10220 HInstruction* instr = New<HInvokeFunction>(function, 3); |
10218 return ast_context()->ReturnInstruction(instr, expr->id()); | 10221 return ast_context()->ReturnInstruction(instr, expr->id()); |
10219 } else if (proxy != NULL) { | 10222 } else if (proxy != NULL) { |
10220 Variable* var = proxy->var(); | 10223 Variable* var = proxy->var(); |
10221 if (var->IsUnallocated()) { | 10224 if (var->IsUnallocatedOrGlobalSlot()) { |
10222 Bailout(kDeleteWithGlobalVariable); | 10225 Bailout(kDeleteWithGlobalVariable); |
10223 } else if (var->IsStackAllocated() || var->IsContextSlot()) { | 10226 } else if (var->IsStackAllocated() || var->IsContextSlot()) { |
10224 // Result of deleting non-global variables is false. 'this' is not really | 10227 // Result of deleting non-global variables is false. 'this' is not really |
10225 // a variable, though we implement it as one. The subexpression does not | 10228 // a variable, though we implement it as one. The subexpression does not |
10226 // have side effects. | 10229 // have side effects. |
10227 HValue* value = var->HasThisName(isolate()) ? graph()->GetConstantTrue() | 10230 HValue* value = var->HasThisName(isolate()) ? graph()->GetConstantTrue() |
10228 : graph()->GetConstantFalse(); | 10231 : graph()->GetConstantFalse(); |
10229 return ast_context()->ReturnValue(value); | 10232 return ast_context()->ReturnValue(value); |
10230 } else { | 10233 } else { |
10231 Bailout(kDeleteWithNonGlobalVariable); | 10234 Bailout(kDeleteWithNonGlobalVariable); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10397 } | 10400 } |
10398 // Argument of the count operation is a variable, not a property. | 10401 // Argument of the count operation is a variable, not a property. |
10399 DCHECK(prop == NULL); | 10402 DCHECK(prop == NULL); |
10400 CHECK_ALIVE(VisitForValue(target)); | 10403 CHECK_ALIVE(VisitForValue(target)); |
10401 | 10404 |
10402 after = BuildIncrement(returns_original_input, expr); | 10405 after = BuildIncrement(returns_original_input, expr); |
10403 input = returns_original_input ? Top() : Pop(); | 10406 input = returns_original_input ? Top() : Pop(); |
10404 Push(after); | 10407 Push(after); |
10405 | 10408 |
10406 switch (var->location()) { | 10409 switch (var->location()) { |
10407 case Variable::UNALLOCATED: | 10410 case VariableLocation::GLOBAL: |
| 10411 case VariableLocation::UNALLOCATED: |
10408 HandleGlobalVariableAssignment(var, | 10412 HandleGlobalVariableAssignment(var, |
10409 after, | 10413 after, |
10410 expr->AssignmentId()); | 10414 expr->AssignmentId()); |
10411 break; | 10415 break; |
10412 | 10416 |
10413 case Variable::PARAMETER: | 10417 case VariableLocation::PARAMETER: |
10414 case Variable::LOCAL: | 10418 case VariableLocation::LOCAL: |
10415 BindIfLive(var, after); | 10419 BindIfLive(var, after); |
10416 break; | 10420 break; |
10417 | 10421 |
10418 case Variable::CONTEXT: { | 10422 case VariableLocation::CONTEXT: { |
10419 // Bail out if we try to mutate a parameter value in a function | 10423 // Bail out if we try to mutate a parameter value in a function |
10420 // using the arguments object. We do not (yet) correctly handle the | 10424 // using the arguments object. We do not (yet) correctly handle the |
10421 // arguments property of the function. | 10425 // arguments property of the function. |
10422 if (current_info()->scope()->arguments() != NULL) { | 10426 if (current_info()->scope()->arguments() != NULL) { |
10423 // Parameters will rewrite to context slots. We have no direct | 10427 // Parameters will rewrite to context slots. We have no direct |
10424 // way to detect that the variable is a parameter so we use a | 10428 // way to detect that the variable is a parameter so we use a |
10425 // linear search of the parameter list. | 10429 // linear search of the parameter list. |
10426 int count = current_info()->scope()->num_parameters(); | 10430 int count = current_info()->scope()->num_parameters(); |
10427 for (int i = 0; i < count; ++i) { | 10431 for (int i = 0; i < count; ++i) { |
10428 if (var == current_info()->scope()->parameter(i)) { | 10432 if (var == current_info()->scope()->parameter(i)) { |
10429 return Bailout(kAssignmentToParameterInArgumentsObject); | 10433 return Bailout(kAssignmentToParameterInArgumentsObject); |
10430 } | 10434 } |
10431 } | 10435 } |
10432 } | 10436 } |
10433 | 10437 |
10434 HValue* context = BuildContextChainWalk(var); | 10438 HValue* context = BuildContextChainWalk(var); |
10435 HStoreContextSlot::Mode mode = IsLexicalVariableMode(var->mode()) | 10439 HStoreContextSlot::Mode mode = IsLexicalVariableMode(var->mode()) |
10436 ? HStoreContextSlot::kCheckDeoptimize : HStoreContextSlot::kNoCheck; | 10440 ? HStoreContextSlot::kCheckDeoptimize : HStoreContextSlot::kNoCheck; |
10437 HStoreContextSlot* instr = Add<HStoreContextSlot>(context, var->index(), | 10441 HStoreContextSlot* instr = Add<HStoreContextSlot>(context, var->index(), |
10438 mode, after); | 10442 mode, after); |
10439 if (instr->HasObservableSideEffects()) { | 10443 if (instr->HasObservableSideEffects()) { |
10440 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); | 10444 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); |
10441 } | 10445 } |
10442 break; | 10446 break; |
10443 } | 10447 } |
10444 | 10448 |
10445 case Variable::LOOKUP: | 10449 case VariableLocation::LOOKUP: |
10446 return Bailout(kLookupVariableInCountOperation); | 10450 return Bailout(kLookupVariableInCountOperation); |
10447 } | 10451 } |
10448 | 10452 |
10449 Drop(returns_original_input ? 2 : 1); | 10453 Drop(returns_original_input ? 2 : 1); |
10450 return ast_context()->ReturnValue(expr->is_postfix() ? input : after); | 10454 return ast_context()->ReturnValue(expr->is_postfix() ? input : after); |
10451 } | 10455 } |
10452 | 10456 |
10453 // Argument of the count operation is a property. | 10457 // Argument of the count operation is a property. |
10454 DCHECK(prop != NULL); | 10458 DCHECK(prop != NULL); |
10455 if (returns_original_input) Push(graph()->GetConstantUndefined()); | 10459 if (returns_original_input) Push(graph()->GetConstantUndefined()); |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11657 } | 11661 } |
11658 | 11662 |
11659 | 11663 |
11660 void HOptimizedGraphBuilder::VisitVariableDeclaration( | 11664 void HOptimizedGraphBuilder::VisitVariableDeclaration( |
11661 VariableDeclaration* declaration) { | 11665 VariableDeclaration* declaration) { |
11662 VariableProxy* proxy = declaration->proxy(); | 11666 VariableProxy* proxy = declaration->proxy(); |
11663 VariableMode mode = declaration->mode(); | 11667 VariableMode mode = declaration->mode(); |
11664 Variable* variable = proxy->var(); | 11668 Variable* variable = proxy->var(); |
11665 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; | 11669 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; |
11666 switch (variable->location()) { | 11670 switch (variable->location()) { |
11667 case Variable::UNALLOCATED: | 11671 case VariableLocation::GLOBAL: |
| 11672 case VariableLocation::UNALLOCATED: |
11668 globals_.Add(variable->name(), zone()); | 11673 globals_.Add(variable->name(), zone()); |
11669 globals_.Add(variable->binding_needs_init() | 11674 globals_.Add(variable->binding_needs_init() |
11670 ? isolate()->factory()->the_hole_value() | 11675 ? isolate()->factory()->the_hole_value() |
11671 : isolate()->factory()->undefined_value(), zone()); | 11676 : isolate()->factory()->undefined_value(), zone()); |
11672 return; | 11677 return; |
11673 case Variable::PARAMETER: | 11678 case VariableLocation::PARAMETER: |
11674 case Variable::LOCAL: | 11679 case VariableLocation::LOCAL: |
11675 if (hole_init) { | 11680 if (hole_init) { |
11676 HValue* value = graph()->GetConstantHole(); | 11681 HValue* value = graph()->GetConstantHole(); |
11677 environment()->Bind(variable, value); | 11682 environment()->Bind(variable, value); |
11678 } | 11683 } |
11679 break; | 11684 break; |
11680 case Variable::CONTEXT: | 11685 case VariableLocation::CONTEXT: |
11681 if (hole_init) { | 11686 if (hole_init) { |
11682 HValue* value = graph()->GetConstantHole(); | 11687 HValue* value = graph()->GetConstantHole(); |
11683 HValue* context = environment()->context(); | 11688 HValue* context = environment()->context(); |
11684 HStoreContextSlot* store = Add<HStoreContextSlot>( | 11689 HStoreContextSlot* store = Add<HStoreContextSlot>( |
11685 context, variable->index(), HStoreContextSlot::kNoCheck, value); | 11690 context, variable->index(), HStoreContextSlot::kNoCheck, value); |
11686 if (store->HasObservableSideEffects()) { | 11691 if (store->HasObservableSideEffects()) { |
11687 Add<HSimulate>(proxy->id(), REMOVABLE_SIMULATE); | 11692 Add<HSimulate>(proxy->id(), REMOVABLE_SIMULATE); |
11688 } | 11693 } |
11689 } | 11694 } |
11690 break; | 11695 break; |
11691 case Variable::LOOKUP: | 11696 case VariableLocation::LOOKUP: |
11692 return Bailout(kUnsupportedLookupSlotInDeclaration); | 11697 return Bailout(kUnsupportedLookupSlotInDeclaration); |
11693 } | 11698 } |
11694 } | 11699 } |
11695 | 11700 |
11696 | 11701 |
11697 void HOptimizedGraphBuilder::VisitFunctionDeclaration( | 11702 void HOptimizedGraphBuilder::VisitFunctionDeclaration( |
11698 FunctionDeclaration* declaration) { | 11703 FunctionDeclaration* declaration) { |
11699 VariableProxy* proxy = declaration->proxy(); | 11704 VariableProxy* proxy = declaration->proxy(); |
11700 Variable* variable = proxy->var(); | 11705 Variable* variable = proxy->var(); |
11701 switch (variable->location()) { | 11706 switch (variable->location()) { |
11702 case Variable::UNALLOCATED: { | 11707 case VariableLocation::GLOBAL: |
| 11708 case VariableLocation::UNALLOCATED: { |
11703 globals_.Add(variable->name(), zone()); | 11709 globals_.Add(variable->name(), zone()); |
11704 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 11710 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
11705 declaration->fun(), current_info()->script(), top_info()); | 11711 declaration->fun(), current_info()->script(), top_info()); |
11706 // Check for stack-overflow exception. | 11712 // Check for stack-overflow exception. |
11707 if (function.is_null()) return SetStackOverflow(); | 11713 if (function.is_null()) return SetStackOverflow(); |
11708 globals_.Add(function, zone()); | 11714 globals_.Add(function, zone()); |
11709 return; | 11715 return; |
11710 } | 11716 } |
11711 case Variable::PARAMETER: | 11717 case VariableLocation::PARAMETER: |
11712 case Variable::LOCAL: { | 11718 case VariableLocation::LOCAL: { |
11713 CHECK_ALIVE(VisitForValue(declaration->fun())); | 11719 CHECK_ALIVE(VisitForValue(declaration->fun())); |
11714 HValue* value = Pop(); | 11720 HValue* value = Pop(); |
11715 BindIfLive(variable, value); | 11721 BindIfLive(variable, value); |
11716 break; | 11722 break; |
11717 } | 11723 } |
11718 case Variable::CONTEXT: { | 11724 case VariableLocation::CONTEXT: { |
11719 CHECK_ALIVE(VisitForValue(declaration->fun())); | 11725 CHECK_ALIVE(VisitForValue(declaration->fun())); |
11720 HValue* value = Pop(); | 11726 HValue* value = Pop(); |
11721 HValue* context = environment()->context(); | 11727 HValue* context = environment()->context(); |
11722 HStoreContextSlot* store = Add<HStoreContextSlot>( | 11728 HStoreContextSlot* store = Add<HStoreContextSlot>( |
11723 context, variable->index(), HStoreContextSlot::kNoCheck, value); | 11729 context, variable->index(), HStoreContextSlot::kNoCheck, value); |
11724 if (store->HasObservableSideEffects()) { | 11730 if (store->HasObservableSideEffects()) { |
11725 Add<HSimulate>(proxy->id(), REMOVABLE_SIMULATE); | 11731 Add<HSimulate>(proxy->id(), REMOVABLE_SIMULATE); |
11726 } | 11732 } |
11727 break; | 11733 break; |
11728 } | 11734 } |
11729 case Variable::LOOKUP: | 11735 case VariableLocation::LOOKUP: |
11730 return Bailout(kUnsupportedLookupSlotInDeclaration); | 11736 return Bailout(kUnsupportedLookupSlotInDeclaration); |
11731 } | 11737 } |
11732 } | 11738 } |
11733 | 11739 |
11734 | 11740 |
11735 void HOptimizedGraphBuilder::VisitImportDeclaration( | 11741 void HOptimizedGraphBuilder::VisitImportDeclaration( |
11736 ImportDeclaration* declaration) { | 11742 ImportDeclaration* declaration) { |
11737 UNREACHABLE(); | 11743 UNREACHABLE(); |
11738 } | 11744 } |
11739 | 11745 |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13239 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13245 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13240 } | 13246 } |
13241 | 13247 |
13242 #ifdef DEBUG | 13248 #ifdef DEBUG |
13243 graph_->Verify(false); // No full verify. | 13249 graph_->Verify(false); // No full verify. |
13244 #endif | 13250 #endif |
13245 } | 13251 } |
13246 | 13252 |
13247 } // namespace internal | 13253 } // namespace internal |
13248 } // namespace v8 | 13254 } // namespace v8 |
OLD | NEW |