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 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 ASSERT(args.length() == 4); | 1225 ASSERT(args.length() == 4); |
1226 | 1226 |
1227 CONVERT_ARG_CHECKED(Context, context, 0); | 1227 CONVERT_ARG_CHECKED(Context, context, 0); |
1228 Handle<String> name(String::cast(args[1])); | 1228 Handle<String> name(String::cast(args[1])); |
1229 PropertyAttributes mode = static_cast<PropertyAttributes>(args.smi_at(2)); | 1229 PropertyAttributes mode = static_cast<PropertyAttributes>(args.smi_at(2)); |
1230 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE); | 1230 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE); |
1231 Handle<Object> initial_value(args[3], isolate); | 1231 Handle<Object> initial_value(args[3], isolate); |
1232 | 1232 |
1233 // Declarations are always done in the function context. | 1233 // Declarations are always done in the function context. |
1234 context = Handle<Context>(context->fcontext()); | 1234 context = Handle<Context>(context->fcontext()); |
| 1235 ASSERT(context->IsFunctionContext()); |
1235 | 1236 |
1236 int index; | 1237 int index; |
1237 PropertyAttributes attributes; | 1238 PropertyAttributes attributes; |
1238 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; | 1239 ContextLookupFlags flags = DONT_FOLLOW_CHAINS; |
1239 Handle<Object> holder = | 1240 Handle<Object> holder = |
1240 context->Lookup(name, flags, &index, &attributes); | 1241 context->Lookup(name, flags, &index, &attributes); |
1241 | 1242 |
1242 if (attributes != ABSENT) { | 1243 if (attributes != ABSENT) { |
1243 // The name was declared before; check for conflicting | 1244 // The name was declared before; check for conflicting |
1244 // re-declarations: This is similar to the code in parser.cc in | 1245 // re-declarations: This is similar to the code in parser.cc in |
(...skipping 8975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10220 // If there is a stack slot for .result then this local scope has been | 10221 // If there is a stack slot for .result then this local scope has been |
10221 // created for evaluating top level code and it is not a real local scope. | 10222 // created for evaluating top level code and it is not a real local scope. |
10222 // Checking for the existence of .result seems fragile, but the scope info | 10223 // Checking for the existence of .result seems fragile, but the scope info |
10223 // saved with the code object does not otherwise have that information. | 10224 // saved with the code object does not otherwise have that information. |
10224 int index = function_->shared()->scope_info()-> | 10225 int index = function_->shared()->scope_info()-> |
10225 StackSlotIndex(isolate_->heap()->result_symbol()); | 10226 StackSlotIndex(isolate_->heap()->result_symbol()); |
10226 at_local_ = index < 0; | 10227 at_local_ = index < 0; |
10227 } else if (context_->IsFunctionContext()) { | 10228 } else if (context_->IsFunctionContext()) { |
10228 at_local_ = true; | 10229 at_local_ = true; |
10229 } else if (context_->closure() != *function_) { | 10230 } else if (context_->closure() != *function_) { |
10230 // The context_ is a with block from the outer function. | 10231 // The context_ is a with or catch block from the outer function. |
10231 ASSERT(context_->has_extension()); | 10232 ASSERT(context_->IsWithContext() || context_->IsCatchContext()); |
10232 at_local_ = true; | 10233 at_local_ = true; |
10233 } | 10234 } |
10234 } | 10235 } |
10235 | 10236 |
10236 // More scopes? | 10237 // More scopes? |
10237 bool Done() { return context_.is_null(); } | 10238 bool Done() { return context_.is_null(); } |
10238 | 10239 |
10239 // Move to the next scope. | 10240 // Move to the next scope. |
10240 void Next() { | 10241 void Next() { |
10241 // If at a local scope mark the local scope as passed. | 10242 // If at a local scope mark the local scope as passed. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10273 if (at_local_) { | 10274 if (at_local_) { |
10274 return ScopeTypeLocal; | 10275 return ScopeTypeLocal; |
10275 } | 10276 } |
10276 if (context_->IsGlobalContext()) { | 10277 if (context_->IsGlobalContext()) { |
10277 ASSERT(context_->global()->IsGlobalObject()); | 10278 ASSERT(context_->global()->IsGlobalObject()); |
10278 return ScopeTypeGlobal; | 10279 return ScopeTypeGlobal; |
10279 } | 10280 } |
10280 if (context_->IsFunctionContext()) { | 10281 if (context_->IsFunctionContext()) { |
10281 return ScopeTypeClosure; | 10282 return ScopeTypeClosure; |
10282 } | 10283 } |
10283 ASSERT(context_->has_extension()); | |
10284 if (context_->IsCatchContext()) { | 10284 if (context_->IsCatchContext()) { |
10285 return ScopeTypeCatch; | 10285 return ScopeTypeCatch; |
10286 } | 10286 } |
| 10287 ASSERT(context_->IsWithContext()); |
10287 return ScopeTypeWith; | 10288 return ScopeTypeWith; |
10288 } | 10289 } |
10289 | 10290 |
10290 // Return the JavaScript object with the content of the current scope. | 10291 // Return the JavaScript object with the content of the current scope. |
10291 Handle<JSObject> ScopeObject() { | 10292 Handle<JSObject> ScopeObject() { |
10292 switch (Type()) { | 10293 switch (Type()) { |
10293 case ScopeIterator::ScopeTypeGlobal: | 10294 case ScopeIterator::ScopeTypeGlobal: |
10294 return Handle<JSObject>(CurrentContext()->global()); | 10295 return Handle<JSObject>(CurrentContext()->global()); |
10295 case ScopeIterator::ScopeTypeLocal: | 10296 case ScopeIterator::ScopeTypeLocal: |
10296 // Materialize the content of the local scope into a JSObject. | 10297 // Materialize the content of the local scope into a JSObject. |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12340 } else { | 12341 } else { |
12341 // Handle last resort GC and make sure to allow future allocations | 12342 // Handle last resort GC and make sure to allow future allocations |
12342 // to grow the heap without causing GCs (if possible). | 12343 // to grow the heap without causing GCs (if possible). |
12343 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12344 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12344 isolate->heap()->CollectAllGarbage(false); | 12345 isolate->heap()->CollectAllGarbage(false); |
12345 } | 12346 } |
12346 } | 12347 } |
12347 | 12348 |
12348 | 12349 |
12349 } } // namespace v8::internal | 12350 } } // namespace v8::internal |
OLD | NEW |