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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3839 int count = info()->scope()->num_parameters(); | 3835 int count = info()->scope()->num_parameters(); |
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 = new(zone()) HStoreContextSlot( |
3850 new(zone()) HStoreContextSlot(context, var->index(), Top()); | 3846 context, var, HStoreContextSlot::kAssign, 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); |
| 4021 HStoreContextSlot::Mode mode = (expr->op() == Token::ASSIGN) |
| 4022 ? HStoreContextSlot::kAssign : HStoreContextSlot::kInitialize; |
4032 HStoreContextSlot* instr = | 4023 HStoreContextSlot* instr = |
4033 new(zone()) HStoreContextSlot(context, var->index(), Top()); | 4024 new(zone()) HStoreContextSlot(context, var, mode, Top()); |
4034 AddInstruction(instr); | 4025 AddInstruction(instr); |
4035 if (instr->HasObservableSideEffects()) { | 4026 if (instr->HasObservableSideEffects()) { |
4036 AddSimulate(expr->AssignmentId()); | 4027 AddSimulate(expr->AssignmentId()); |
4037 } | 4028 } |
4038 return ast_context()->ReturnValue(Pop()); | 4029 return ast_context()->ReturnValue(Pop()); |
4039 } | 4030 } |
4040 | 4031 |
4041 case Variable::LOOKUP: | 4032 case Variable::LOOKUP: |
4042 return Bailout("assignment to LOOKUP variable"); | 4033 return Bailout("assignment to LOOKUP variable"); |
4043 } | 4034 } |
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5632 // linear search of the parameter list. | 5623 // linear search of the parameter list. |
5633 int count = info()->scope()->num_parameters(); | 5624 int count = info()->scope()->num_parameters(); |
5634 for (int i = 0; i < count; ++i) { | 5625 for (int i = 0; i < count; ++i) { |
5635 if (var == info()->scope()->parameter(i)) { | 5626 if (var == info()->scope()->parameter(i)) { |
5636 return Bailout("assignment to parameter in arguments object"); | 5627 return Bailout("assignment to parameter in arguments object"); |
5637 } | 5628 } |
5638 } | 5629 } |
5639 } | 5630 } |
5640 | 5631 |
5641 HValue* context = BuildContextChainWalk(var); | 5632 HValue* context = BuildContextChainWalk(var); |
5642 HStoreContextSlot* instr = | 5633 HStoreContextSlot* instr = new(zone()) HStoreContextSlot( |
5643 new(zone()) HStoreContextSlot(context, var->index(), after); | 5634 context, var, HStoreContextSlot::kAssign, after); |
5644 AddInstruction(instr); | 5635 AddInstruction(instr); |
5645 if (instr->HasObservableSideEffects()) { | 5636 if (instr->HasObservableSideEffects()) { |
5646 AddSimulate(expr->AssignmentId()); | 5637 AddSimulate(expr->AssignmentId()); |
5647 } | 5638 } |
5648 break; | 5639 break; |
5649 } | 5640 } |
5650 | 5641 |
5651 case Variable::LOOKUP: | 5642 case Variable::LOOKUP: |
5652 return Bailout("lookup variable in count operation"); | 5643 return Bailout("lookup variable in count operation"); |
5653 } | 5644 } |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6225 if (binding_needs_init || function != NULL) { | 6216 if (binding_needs_init || function != NULL) { |
6226 HValue* value = NULL; | 6217 HValue* value = NULL; |
6227 if (function != NULL) { | 6218 if (function != NULL) { |
6228 VisitForValue(function); | 6219 VisitForValue(function); |
6229 value = Pop(); | 6220 value = Pop(); |
6230 } else { | 6221 } else { |
6231 value = graph()->GetConstantHole(); | 6222 value = graph()->GetConstantHole(); |
6232 } | 6223 } |
6233 if (var->IsContextSlot()) { | 6224 if (var->IsContextSlot()) { |
6234 HValue* context = environment()->LookupContext(); | 6225 HValue* context = environment()->LookupContext(); |
6235 HStoreContextSlot* store = | 6226 HStoreContextSlot* store = new HStoreContextSlot( |
6236 new HStoreContextSlot(context, var->index(), value); | 6227 context, var, HStoreContextSlot::kInitialize, value); |
6237 AddInstruction(store); | 6228 AddInstruction(store); |
6238 if (store->HasObservableSideEffects()) AddSimulate(proxy->id()); | 6229 if (store->HasObservableSideEffects()) AddSimulate(proxy->id()); |
6239 } else { | 6230 } else { |
6240 environment()->Bind(var, value); | 6231 environment()->Bind(var, value); |
6241 } | 6232 } |
6242 } | 6233 } |
6243 break; | 6234 break; |
6244 case Variable::LOOKUP: | 6235 case Variable::LOOKUP: |
6245 return Bailout("unsupported lookup slot in declaration"); | 6236 return Bailout("unsupported lookup slot in declaration"); |
6246 } | 6237 } |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7248 } | 7239 } |
7249 } | 7240 } |
7250 | 7241 |
7251 #ifdef DEBUG | 7242 #ifdef DEBUG |
7252 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7243 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
7253 if (allocator_ != NULL) allocator_->Verify(); | 7244 if (allocator_ != NULL) allocator_->Verify(); |
7254 #endif | 7245 #endif |
7255 } | 7246 } |
7256 | 7247 |
7257 } } // namespace v8::internal | 7248 } } // namespace v8::internal |
OLD | NEW |