| 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 3117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3128 ASSERT(!HasStackOverflow()); | 3128 ASSERT(!HasStackOverflow()); |
| 3129 ASSERT(current_block() != NULL); | 3129 ASSERT(current_block() != NULL); |
| 3130 ASSERT(current_block()->HasPredecessor()); | 3130 ASSERT(current_block()->HasPredecessor()); |
| 3131 Variable* variable = expr->var(); | 3131 Variable* variable = expr->var(); |
| 3132 if (variable->mode() == Variable::LET) { | 3132 if (variable->mode() == Variable::LET) { |
| 3133 return Bailout("reference to let variable"); | 3133 return Bailout("reference to let variable"); |
| 3134 } | 3134 } |
| 3135 switch (variable->location()) { | 3135 switch (variable->location()) { |
| 3136 case Variable::UNALLOCATED: { | 3136 case Variable::UNALLOCATED: { |
| 3137 LookupResult lookup; | 3137 LookupResult lookup; |
| 3138 GlobalPropertyAccess type = LookupGlobalProperty(variable, &lookup, false)
; | 3138 GlobalPropertyAccess type = |
| 3139 LookupGlobalProperty(variable, &lookup, false); |
| 3139 | 3140 |
| 3140 if (type == kUseCell && | 3141 if (type == kUseCell && |
| 3141 info()->global_object()->IsAccessCheckNeeded()) { | 3142 info()->global_object()->IsAccessCheckNeeded()) { |
| 3142 type = kUseGeneric; | 3143 type = kUseGeneric; |
| 3143 } | 3144 } |
| 3144 | 3145 |
| 3145 if (type == kUseCell) { | 3146 if (type == kUseCell) { |
| 3146 Handle<GlobalObject> global(info()->global_object()); | 3147 Handle<GlobalObject> global(info()->global_object()); |
| 3147 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); | 3148 Handle<JSGlobalPropertyCell> cell(global->GetPropertyCell(&lookup)); |
| 3148 bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly(); | 3149 bool check_hole = !lookup.IsDontDelete() || lookup.IsReadOnly(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3165 case Variable::PARAMETER: | 3166 case Variable::PARAMETER: |
| 3166 case Variable::LOCAL: { | 3167 case Variable::LOCAL: { |
| 3167 HValue* value = environment()->Lookup(variable); | 3168 HValue* value = environment()->Lookup(variable); |
| 3168 if (variable->mode() == Variable::CONST && | 3169 if (variable->mode() == Variable::CONST && |
| 3169 value == graph()->GetConstantHole()) { | 3170 value == graph()->GetConstantHole()) { |
| 3170 return Bailout("reference to uninitialized const variable"); | 3171 return Bailout("reference to uninitialized const variable"); |
| 3171 } | 3172 } |
| 3172 return ast_context()->ReturnValue(value); | 3173 return ast_context()->ReturnValue(value); |
| 3173 } | 3174 } |
| 3174 | 3175 |
| 3175 case Variable::CONTEXT:{ | 3176 case Variable::CONTEXT: { |
| 3176 if (variable->mode() == Variable::CONST) { | 3177 if (variable->mode() == Variable::CONST) { |
| 3177 return Bailout("reference to const context slot"); | 3178 return Bailout("reference to const context slot"); |
| 3178 } | 3179 } |
| 3179 HValue* context = BuildContextChainWalk(variable); | 3180 HValue* context = BuildContextChainWalk(variable); |
| 3180 HLoadContextSlot* instr = | 3181 HLoadContextSlot* instr = |
| 3181 new(zone()) HLoadContextSlot(context, variable->index()); | 3182 new(zone()) HLoadContextSlot(context, variable->index()); |
| 3182 return ast_context()->ReturnInstruction(instr, expr->id()); | 3183 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 3183 } | 3184 } |
| 3184 | 3185 |
| 3185 case Variable::LOOKUP: | 3186 case Variable::LOOKUP: |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3627 // Bail out if we try to mutate a parameter value in a function | 3628 // Bail out if we try to mutate a parameter value in a function |
| 3628 // using the arguments object. We do not (yet) correctly handle the | 3629 // using the arguments object. We do not (yet) correctly handle the |
| 3629 // arguments property of the function. | 3630 // arguments property of the function. |
| 3630 if (info()->scope()->arguments() != NULL) { | 3631 if (info()->scope()->arguments() != NULL) { |
| 3631 // Parameters will be allocated to context slots. We have no | 3632 // Parameters will be allocated to context slots. We have no |
| 3632 // direct way to detect that the variable is a parameter so we do | 3633 // direct way to detect that the variable is a parameter so we do |
| 3633 // a linear search of the parameter variables. | 3634 // a linear search of the parameter variables. |
| 3634 int count = info()->scope()->num_parameters(); | 3635 int count = info()->scope()->num_parameters(); |
| 3635 for (int i = 0; i < count; ++i) { | 3636 for (int i = 0; i < count; ++i) { |
| 3636 if (var == info()->scope()->parameter(i)) { | 3637 if (var == info()->scope()->parameter(i)) { |
| 3637 Bailout("assignment to parameter, function uses arguments object")
; | 3638 Bailout( |
| 3639 "assignment to parameter, function uses arguments object"); |
| 3638 } | 3640 } |
| 3639 } | 3641 } |
| 3640 } | 3642 } |
| 3641 | 3643 |
| 3642 HValue* context = BuildContextChainWalk(var); | 3644 HValue* context = BuildContextChainWalk(var); |
| 3643 HStoreContextSlot* instr = | 3645 HStoreContextSlot* instr = |
| 3644 new(zone()) HStoreContextSlot(context, var->index(), Top()); | 3646 new(zone()) HStoreContextSlot(context, var->index(), Top()); |
| 3645 AddInstruction(instr); | 3647 AddInstruction(instr); |
| 3646 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); | 3648 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); |
| 3647 break; | 3649 break; |
| (...skipping 3166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6814 } | 6816 } |
| 6815 } | 6817 } |
| 6816 | 6818 |
| 6817 #ifdef DEBUG | 6819 #ifdef DEBUG |
| 6818 if (graph_ != NULL) graph_->Verify(); | 6820 if (graph_ != NULL) graph_->Verify(); |
| 6819 if (allocator_ != NULL) allocator_->Verify(); | 6821 if (allocator_ != NULL) allocator_->Verify(); |
| 6820 #endif | 6822 #endif |
| 6821 } | 6823 } |
| 6822 | 6824 |
| 6823 } } // namespace v8::internal | 6825 } } // namespace v8::internal |
| OLD | NEW |