| 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 11013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11024 int inlined_frame_index) | 11024 int inlined_frame_index) |
| 11025 : isolate_(isolate), | 11025 : isolate_(isolate), |
| 11026 frame_(frame), | 11026 frame_(frame), |
| 11027 inlined_frame_index_(inlined_frame_index), | 11027 inlined_frame_index_(inlined_frame_index), |
| 11028 function_(JSFunction::cast(frame->function())), | 11028 function_(JSFunction::cast(frame->function())), |
| 11029 context_(Context::cast(frame->context())), | 11029 context_(Context::cast(frame->context())), |
| 11030 local_done_(false), | 11030 local_done_(false), |
| 11031 at_local_(false) { | 11031 at_local_(false) { |
| 11032 | 11032 |
| 11033 // Check whether the first scope is actually a local scope. | 11033 // Check whether the first scope is actually a local scope. |
| 11034 if (context_->IsGlobalContext()) { | 11034 // If there is a stack slot for .result then this local scope has been |
| 11035 // If there is a stack slot for .result then this local scope has been | 11035 // created for evaluating top level code and it is not a real local scope. |
| 11036 // created for evaluating top level code and it is not a real local scope. | 11036 // Checking for the existence of .result seems fragile, but the scope info |
| 11037 // Checking for the existence of .result seems fragile, but the scope info | 11037 // saved with the code object does not otherwise have that information. |
| 11038 // saved with the code object does not otherwise have that information. | 11038 int index = function_->shared()->scope_info()-> |
| 11039 int index = function_->shared()->scope_info()-> | 11039 StackSlotIndex(isolate_->heap()->result_symbol()); |
| 11040 StackSlotIndex(isolate_->heap()->result_symbol()); | 11040 if (index >= 0) { |
| 11041 at_local_ = index < 0; | 11041 local_done_ = true; |
| 11042 } else if (context_->IsFunctionContext()) { | 11042 } else if (context_->IsGlobalContext() || |
| 11043 context_->IsFunctionContext()) { |
| 11043 at_local_ = true; | 11044 at_local_ = true; |
| 11044 } else if (context_->closure() != *function_) { | 11045 } else if (context_->closure() != *function_) { |
| 11045 // The context_ is a block or with or catch block from the outer function. | 11046 // The context_ is a block or with or catch block from the outer function. |
| 11046 ASSERT(context_->IsWithContext() || | 11047 ASSERT(context_->IsWithContext() || |
| 11047 context_->IsCatchContext() || | 11048 context_->IsCatchContext() || |
| 11048 context_->IsBlockContext()); | 11049 context_->IsBlockContext()); |
| 11049 at_local_ = true; | 11050 at_local_ = true; |
| 11050 } | 11051 } |
| 11051 } | 11052 } |
| 11052 | 11053 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11079 | 11080 |
| 11080 // If passing the local scope indicate that the current scope is now the | 11081 // If passing the local scope indicate that the current scope is now the |
| 11081 // local scope. | 11082 // local scope. |
| 11082 if (!local_done_ && | 11083 if (!local_done_ && |
| 11083 (context_->IsGlobalContext() || context_->IsFunctionContext())) { | 11084 (context_->IsGlobalContext() || context_->IsFunctionContext())) { |
| 11084 at_local_ = true; | 11085 at_local_ = true; |
| 11085 } | 11086 } |
| 11086 } | 11087 } |
| 11087 | 11088 |
| 11088 // Return the type of the current scope. | 11089 // Return the type of the current scope. |
| 11089 int Type() { | 11090 ScopeType Type() { |
| 11090 if (at_local_) { | 11091 if (at_local_) { |
| 11091 return ScopeTypeLocal; | 11092 return ScopeTypeLocal; |
| 11092 } | 11093 } |
| 11093 if (context_->IsGlobalContext()) { | 11094 if (context_->IsGlobalContext()) { |
| 11094 ASSERT(context_->global()->IsGlobalObject()); | 11095 ASSERT(context_->global()->IsGlobalObject()); |
| 11095 return ScopeTypeGlobal; | 11096 return ScopeTypeGlobal; |
| 11096 } | 11097 } |
| 11097 if (context_->IsFunctionContext()) { | 11098 if (context_->IsFunctionContext()) { |
| 11098 return ScopeTypeClosure; | 11099 return ScopeTypeClosure; |
| 11099 } | 11100 } |
| (...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13224 } else { | 13225 } else { |
| 13225 // Handle last resort GC and make sure to allow future allocations | 13226 // Handle last resort GC and make sure to allow future allocations |
| 13226 // to grow the heap without causing GCs (if possible). | 13227 // to grow the heap without causing GCs (if possible). |
| 13227 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13228 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13228 isolate->heap()->CollectAllGarbage(false); | 13229 isolate->heap()->CollectAllGarbage(false); |
| 13229 } | 13230 } |
| 13230 } | 13231 } |
| 13231 | 13232 |
| 13232 | 13233 |
| 13233 } } // namespace v8::internal | 13234 } } // namespace v8::internal |
| OLD | NEW |