| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 3267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3278 if (value == graph()->GetConstantHole()) { | 3278 if (value == graph()->GetConstantHole()) { |
| 3279 ASSERT(variable->mode() == CONST || | 3279 ASSERT(variable->mode() == CONST || |
| 3280 variable->mode() == CONST_HARMONY || | 3280 variable->mode() == CONST_HARMONY || |
| 3281 variable->mode() == LET); | 3281 variable->mode() == LET); |
| 3282 return Bailout("reference to uninitialized variable"); | 3282 return Bailout("reference to uninitialized variable"); |
| 3283 } | 3283 } |
| 3284 return ast_context()->ReturnValue(value); | 3284 return ast_context()->ReturnValue(value); |
| 3285 } | 3285 } |
| 3286 | 3286 |
| 3287 case Variable::CONTEXT: { | 3287 case Variable::CONTEXT: { |
| 3288 if (variable->mode() == LET || variable->mode() == CONST_HARMONY) { | |
| 3289 return Bailout("reference to harmony declared context slot"); | |
| 3290 } | |
| 3291 if (variable->mode() == CONST) { | 3288 if (variable->mode() == CONST) { |
| 3292 return Bailout("reference to const context slot"); | 3289 return Bailout("reference to const context slot"); |
| 3293 } | 3290 } |
| 3294 HValue* context = BuildContextChainWalk(variable); | 3291 HValue* context = BuildContextChainWalk(variable); |
| 3295 HLoadContextSlot* instr = | 3292 HLoadContextSlot* instr = new(zone()) HLoadContextSlot(context, variable); |
| 3296 new(zone()) HLoadContextSlot(context, variable->index()); | |
| 3297 return ast_context()->ReturnInstruction(instr, expr->id()); | 3293 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 3298 } | 3294 } |
| 3299 | 3295 |
| 3300 case Variable::LOOKUP: | 3296 case Variable::LOOKUP: |
| 3301 return Bailout("reference to a variable which requires dynamic lookup"); | 3297 return Bailout("reference to a variable which requires dynamic lookup"); |
| 3302 } | 3298 } |
| 3303 } | 3299 } |
| 3304 | 3300 |
| 3305 | 3301 |
| 3306 void HGraphBuilder::VisitLiteral(Literal* expr) { | 3302 void HGraphBuilder::VisitLiteral(Literal* expr) { |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3840 for (int i = 0; i < count; ++i) { | 3836 for (int i = 0; i < count; ++i) { |
| 3841 if (var == info()->scope()->parameter(i)) { | 3837 if (var == info()->scope()->parameter(i)) { |
| 3842 Bailout( | 3838 Bailout( |
| 3843 "assignment to parameter, function uses arguments object"); | 3839 "assignment to parameter, function uses arguments object"); |
| 3844 } | 3840 } |
| 3845 } | 3841 } |
| 3846 } | 3842 } |
| 3847 | 3843 |
| 3848 HValue* context = BuildContextChainWalk(var); | 3844 HValue* context = BuildContextChainWalk(var); |
| 3849 HStoreContextSlot* instr = | 3845 HStoreContextSlot* instr = |
| 3850 new(zone()) HStoreContextSlot(context, var->index(), Top()); | 3846 new(zone()) HStoreContextSlot(context, var, Top()); |
| 3851 AddInstruction(instr); | 3847 AddInstruction(instr); |
| 3852 if (instr->HasObservableSideEffects()) { | 3848 if (instr->HasObservableSideEffects()) { |
| 3853 AddSimulate(expr->AssignmentId()); | 3849 AddSimulate(expr->AssignmentId()); |
| 3854 } | 3850 } |
| 3855 break; | 3851 break; |
| 3856 } | 3852 } |
| 3857 | 3853 |
| 3858 case Variable::LOOKUP: | 3854 case Variable::LOOKUP: |
| 3859 return Bailout("compound assignment to lookup slot"); | 3855 return Bailout("compound assignment to lookup slot"); |
| 3860 } | 3856 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 if (expr->op() != Token::INIT_CONST) { | 3956 if (expr->op() != Token::INIT_CONST) { |
| 3961 return Bailout("non-initializer assignment to const"); | 3957 return Bailout("non-initializer assignment to const"); |
| 3962 } | 3958 } |
| 3963 if (!var->IsStackAllocated()) { | 3959 if (!var->IsStackAllocated()) { |
| 3964 return Bailout("assignment to const context slot"); | 3960 return Bailout("assignment to const context slot"); |
| 3965 } | 3961 } |
| 3966 // We insert a use of the old value to detect unsupported uses of const | 3962 // We insert a use of the old value to detect unsupported uses of const |
| 3967 // variables (e.g. initialization inside a loop). | 3963 // variables (e.g. initialization inside a loop). |
| 3968 HValue* old_value = environment()->Lookup(var); | 3964 HValue* old_value = environment()->Lookup(var); |
| 3969 AddInstruction(new HUseConst(old_value)); | 3965 AddInstruction(new HUseConst(old_value)); |
| 3970 } else if (var->mode() == LET) { | |
| 3971 if (!var->IsStackAllocated()) { | |
| 3972 return Bailout("assignment to let context slot"); | |
| 3973 } | |
| 3974 } else if (var->mode() == CONST_HARMONY) { | 3966 } else if (var->mode() == CONST_HARMONY) { |
| 3975 if (expr->op() != Token::INIT_CONST_HARMONY) { | 3967 if (expr->op() != Token::INIT_CONST_HARMONY) { |
| 3976 return Bailout("non-initializer assignment to const"); | 3968 return Bailout("non-initializer assignment to const"); |
| 3977 } | 3969 } |
| 3978 if (!var->IsStackAllocated()) { | |
| 3979 return Bailout("assignment to const context slot"); | |
| 3980 } | |
| 3981 } | 3970 } |
| 3982 | 3971 |
| 3983 if (proxy->IsArguments()) return Bailout("assignment to arguments"); | 3972 if (proxy->IsArguments()) return Bailout("assignment to arguments"); |
| 3984 | 3973 |
| 3985 // Handle the assignment. | 3974 // Handle the assignment. |
| 3986 switch (var->location()) { | 3975 switch (var->location()) { |
| 3987 case Variable::UNALLOCATED: | 3976 case Variable::UNALLOCATED: |
| 3988 CHECK_ALIVE(VisitForValue(expr->value())); | 3977 CHECK_ALIVE(VisitForValue(expr->value())); |
| 3989 HandleGlobalVariableAssignment(var, | 3978 HandleGlobalVariableAssignment(var, |
| 3990 Top(), | 3979 Top(), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4022 int count = info()->scope()->num_parameters(); | 4011 int count = info()->scope()->num_parameters(); |
| 4023 for (int i = 0; i < count; ++i) { | 4012 for (int i = 0; i < count; ++i) { |
| 4024 if (var == info()->scope()->parameter(i)) { | 4013 if (var == info()->scope()->parameter(i)) { |
| 4025 return Bailout("assignment to parameter in arguments object"); | 4014 return Bailout("assignment to parameter in arguments object"); |
| 4026 } | 4015 } |
| 4027 } | 4016 } |
| 4028 } | 4017 } |
| 4029 | 4018 |
| 4030 CHECK_ALIVE(VisitForValue(expr->value())); | 4019 CHECK_ALIVE(VisitForValue(expr->value())); |
| 4031 HValue* context = BuildContextChainWalk(var); | 4020 HValue* context = BuildContextChainWalk(var); |
| 4032 HStoreContextSlot* instr = | 4021 HStoreContextSlot* instr; |
| 4033 new(zone()) HStoreContextSlot(context, var->index(), Top()); | 4022 if (expr->op() == Token::ASSIGN) { |
| 4023 instr = new(zone()) HStoreContextSlot(context, var, Top()); |
| 4024 } else { |
| 4025 ASSERT(expr->op() == Token::INIT_VAR || |
| 4026 expr->op() == Token::INIT_LET || |
| 4027 expr->op() == Token::INIT_CONST_HARMONY); |
| 4028 instr = new(zone()) HStoreContextSlot( |
| 4029 context, var->index(), HStoreContextSlot::kAssign, Top()); |
| 4030 } |
| 4034 AddInstruction(instr); | 4031 AddInstruction(instr); |
| 4035 if (instr->HasObservableSideEffects()) { | 4032 if (instr->HasObservableSideEffects()) { |
| 4036 AddSimulate(expr->AssignmentId()); | 4033 AddSimulate(expr->AssignmentId()); |
| 4037 } | 4034 } |
| 4038 return ast_context()->ReturnValue(Pop()); | 4035 return ast_context()->ReturnValue(Pop()); |
| 4039 } | 4036 } |
| 4040 | 4037 |
| 4041 case Variable::LOOKUP: | 4038 case Variable::LOOKUP: |
| 4042 return Bailout("assignment to LOOKUP variable"); | 4039 return Bailout("assignment to LOOKUP variable"); |
| 4043 } | 4040 } |
| (...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5633 int count = info()->scope()->num_parameters(); | 5630 int count = info()->scope()->num_parameters(); |
| 5634 for (int i = 0; i < count; ++i) { | 5631 for (int i = 0; i < count; ++i) { |
| 5635 if (var == info()->scope()->parameter(i)) { | 5632 if (var == info()->scope()->parameter(i)) { |
| 5636 return Bailout("assignment to parameter in arguments object"); | 5633 return Bailout("assignment to parameter in arguments object"); |
| 5637 } | 5634 } |
| 5638 } | 5635 } |
| 5639 } | 5636 } |
| 5640 | 5637 |
| 5641 HValue* context = BuildContextChainWalk(var); | 5638 HValue* context = BuildContextChainWalk(var); |
| 5642 HStoreContextSlot* instr = | 5639 HStoreContextSlot* instr = |
| 5643 new(zone()) HStoreContextSlot(context, var->index(), after); | 5640 new(zone()) HStoreContextSlot(context, var, after); |
| 5644 AddInstruction(instr); | 5641 AddInstruction(instr); |
| 5645 if (instr->HasObservableSideEffects()) { | 5642 if (instr->HasObservableSideEffects()) { |
| 5646 AddSimulate(expr->AssignmentId()); | 5643 AddSimulate(expr->AssignmentId()); |
| 5647 } | 5644 } |
| 5648 break; | 5645 break; |
| 5649 } | 5646 } |
| 5650 | 5647 |
| 5651 case Variable::LOOKUP: | 5648 case Variable::LOOKUP: |
| 5652 return Bailout("lookup variable in count operation"); | 5649 return Bailout("lookup variable in count operation"); |
| 5653 } | 5650 } |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6225 if (binding_needs_init || function != NULL) { | 6222 if (binding_needs_init || function != NULL) { |
| 6226 HValue* value = NULL; | 6223 HValue* value = NULL; |
| 6227 if (function != NULL) { | 6224 if (function != NULL) { |
| 6228 VisitForValue(function); | 6225 VisitForValue(function); |
| 6229 value = Pop(); | 6226 value = Pop(); |
| 6230 } else { | 6227 } else { |
| 6231 value = graph()->GetConstantHole(); | 6228 value = graph()->GetConstantHole(); |
| 6232 } | 6229 } |
| 6233 if (var->IsContextSlot()) { | 6230 if (var->IsContextSlot()) { |
| 6234 HValue* context = environment()->LookupContext(); | 6231 HValue* context = environment()->LookupContext(); |
| 6235 HStoreContextSlot* store = | 6232 HStoreContextSlot* store = new HStoreContextSlot( |
| 6236 new HStoreContextSlot(context, var->index(), value); | 6233 context, var->index(), HStoreContextSlot::kAssign, value); |
| 6237 AddInstruction(store); | 6234 AddInstruction(store); |
| 6238 if (store->HasObservableSideEffects()) AddSimulate(proxy->id()); | 6235 if (store->HasObservableSideEffects()) AddSimulate(proxy->id()); |
| 6239 } else { | 6236 } else { |
| 6240 environment()->Bind(var, value); | 6237 environment()->Bind(var, value); |
| 6241 } | 6238 } |
| 6242 } | 6239 } |
| 6243 break; | 6240 break; |
| 6244 case Variable::LOOKUP: | 6241 case Variable::LOOKUP: |
| 6245 return Bailout("unsupported lookup slot in declaration"); | 6242 return Bailout("unsupported lookup slot in declaration"); |
| 6246 } | 6243 } |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7248 } | 7245 } |
| 7249 } | 7246 } |
| 7250 | 7247 |
| 7251 #ifdef DEBUG | 7248 #ifdef DEBUG |
| 7252 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7249 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 7253 if (allocator_ != NULL) allocator_->Verify(); | 7250 if (allocator_ != NULL) allocator_->Verify(); |
| 7254 #endif | 7251 #endif |
| 7255 } | 7252 } |
| 7256 | 7253 |
| 7257 } } // namespace v8::internal | 7254 } } // namespace v8::internal |
| OLD | NEW |