| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // was just added before, so we search backwards. | 286 // was just added before, so we search backwards. |
| 287 for (int i = unresolved_.length(); i-- > 0;) { | 287 for (int i = unresolved_.length(); i-- > 0;) { |
| 288 if (unresolved_[i] == var) { | 288 if (unresolved_[i] == var) { |
| 289 unresolved_.Remove(i); | 289 unresolved_.Remove(i); |
| 290 return; | 290 return; |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 | 295 |
| 296 VariableProxy* Scope::NewTemporary(Handle<String> name) { | 296 Variable* Scope::NewTemporary(Handle<String> name) { |
| 297 Variable* var = new Variable(this, name, Variable::TEMPORARY, true, | 297 Variable* var = |
| 298 Variable::NORMAL); | 298 new Variable(this, name, Variable::TEMPORARY, true, Variable::NORMAL); |
| 299 VariableProxy* tmp = new VariableProxy(name, false, false); | |
| 300 tmp->BindTo(var); | |
| 301 temps_.Add(var); | 299 temps_.Add(var); |
| 302 return tmp; | 300 return var; |
| 303 } | 301 } |
| 304 | 302 |
| 305 | 303 |
| 306 void Scope::AddDeclaration(Declaration* declaration) { | 304 void Scope::AddDeclaration(Declaration* declaration) { |
| 307 decls_.Add(declaration); | 305 decls_.Add(declaration); |
| 308 } | 306 } |
| 309 | 307 |
| 310 | 308 |
| 311 void Scope::SetIllegalRedeclaration(Expression* expression) { | 309 void Scope::SetIllegalRedeclaration(Expression* expression) { |
| 312 // Only set the illegal redeclaration expression the | 310 // Only set the illegal redeclaration expression the |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 for (int i = 0; i < params_.length(); i++) { | 854 for (int i = 0; i < params_.length(); i++) { |
| 857 Variable* var = params_[i]; | 855 Variable* var = params_[i]; |
| 858 ASSERT(var->scope() == this); | 856 ASSERT(var->scope() == this); |
| 859 if (MustAllocate(var)) { | 857 if (MustAllocate(var)) { |
| 860 if (MustAllocateInContext(var)) { | 858 if (MustAllocateInContext(var)) { |
| 861 // It is ok to set this only now, because arguments is a local | 859 // It is ok to set this only now, because arguments is a local |
| 862 // variable that is allocated after the parameters have been | 860 // variable that is allocated after the parameters have been |
| 863 // allocated. | 861 // allocated. |
| 864 arguments_shadow_->is_accessed_from_inner_scope_ = true; | 862 arguments_shadow_->is_accessed_from_inner_scope_ = true; |
| 865 } | 863 } |
| 866 var->rewrite_ = | 864 Property* rewrite = |
| 867 new Property(new VariableProxy(arguments_shadow_), | 865 new Property(new VariableProxy(arguments_shadow_), |
| 868 new Literal(Handle<Object>(Smi::FromInt(i))), | 866 new Literal(Handle<Object>(Smi::FromInt(i))), |
| 869 RelocInfo::kNoPosition, | 867 RelocInfo::kNoPosition, |
| 870 Property::SYNTHETIC); | 868 Property::SYNTHETIC); |
| 869 rewrite->set_is_arguments_access(true); |
| 870 var->rewrite_ = rewrite; |
| 871 } | 871 } |
| 872 } | 872 } |
| 873 | 873 |
| 874 } else { | 874 } else { |
| 875 // The arguments object is not used, so we can access parameters directly. | 875 // The arguments object is not used, so we can access parameters directly. |
| 876 // The same parameter may occur multiple times in the parameters_ list. | 876 // The same parameter may occur multiple times in the parameters_ list. |
| 877 // If it does, and if it is not copied into the context object, it must | 877 // If it does, and if it is not copied into the context object, it must |
| 878 // receive the highest parameter index for that parameter; thus iteration | 878 // receive the highest parameter index for that parameter; thus iteration |
| 879 // order is relevant! | 879 // order is relevant! |
| 880 for (int i = 0; i < params_.length(); i++) { | 880 for (int i = 0; i < params_.length(); i++) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && | 975 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && |
| 976 !must_have_local_context) { | 976 !must_have_local_context) { |
| 977 num_heap_slots_ = 0; | 977 num_heap_slots_ = 0; |
| 978 } | 978 } |
| 979 | 979 |
| 980 // Allocation done. | 980 // Allocation done. |
| 981 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); | 981 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); |
| 982 } | 982 } |
| 983 | 983 |
| 984 } } // namespace v8::internal | 984 } } // namespace v8::internal |
| OLD | NEW |