| OLD | NEW | 
|      1 // Copyright 2012 the V8 project authors. All rights reserved. |      1 // Copyright 2012 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 10748 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  10759     receiver = |  10759     receiver = | 
|  10760         isolate->factory()->ToObject(receiver, calling_frames_native_context); |  10760         isolate->factory()->ToObject(receiver, calling_frames_native_context); | 
|  10761   } |  10761   } | 
|  10762   details->set(kFrameDetailsReceiverIndex, *receiver); |  10762   details->set(kFrameDetailsReceiverIndex, *receiver); | 
|  10763  |  10763  | 
|  10764   ASSERT_EQ(details_size, details_index); |  10764   ASSERT_EQ(details_size, details_index); | 
|  10765   return *isolate->factory()->NewJSArrayWithElements(details); |  10765   return *isolate->factory()->NewJSArrayWithElements(details); | 
|  10766 } |  10766 } | 
|  10767  |  10767  | 
|  10768  |  10768  | 
|  10769 // Copy all the context locals into an object used to materialize a scope. |  | 
|  10770 static bool CopyContextLocalsToScopeObject( |  | 
|  10771     Isolate* isolate, |  | 
|  10772     Handle<ScopeInfo> scope_info, |  | 
|  10773     Handle<Context> context, |  | 
|  10774     Handle<JSObject> scope_object) { |  | 
|  10775   // Fill all context locals to the context extension. |  | 
|  10776   for (int i = 0; i < scope_info->ContextLocalCount(); i++) { |  | 
|  10777     VariableMode mode; |  | 
|  10778     InitializationFlag init_flag; |  | 
|  10779     int context_index = scope_info->ContextSlotIndex( |  | 
|  10780         scope_info->ContextLocalName(i), &mode, &init_flag); |  | 
|  10781  |  | 
|  10782     RETURN_IF_EMPTY_HANDLE_VALUE( |  | 
|  10783         isolate, |  | 
|  10784         SetProperty(isolate, |  | 
|  10785                     scope_object, |  | 
|  10786                     Handle<String>(scope_info->ContextLocalName(i)), |  | 
|  10787                     Handle<Object>(context->get(context_index), isolate), |  | 
|  10788                     NONE, |  | 
|  10789                     kNonStrictMode), |  | 
|  10790         false); |  | 
|  10791   } |  | 
|  10792  |  | 
|  10793   return true; |  | 
|  10794 } |  | 
|  10795  |  | 
|  10796  |  | 
|  10797 // Create a plain JSObject which materializes the local scope for the specified |  10769 // Create a plain JSObject which materializes the local scope for the specified | 
|  10798 // frame. |  10770 // frame. | 
|  10799 static Handle<JSObject> MaterializeLocalScopeWithFrameInspector( |  10771 static Handle<JSObject> MaterializeLocalScopeWithFrameInspector( | 
|  10800     Isolate* isolate, |  10772     Isolate* isolate, | 
|  10801     JavaScriptFrame* frame, |  10773     JavaScriptFrame* frame, | 
|  10802     FrameInspector* frame_inspector) { |  10774     FrameInspector* frame_inspector) { | 
|  10803   Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction())); |  10775   Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction())); | 
|  10804   Handle<SharedFunctionInfo> shared(function->shared()); |  10776   Handle<SharedFunctionInfo> shared(function->shared()); | 
|  10805   Handle<ScopeInfo> scope_info(shared->scope_info()); |  10777   Handle<ScopeInfo> scope_info(shared->scope_info()); | 
|  10806  |  10778  | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  10836                     Handle<Object>(frame_inspector->GetExpression(i)), |  10808                     Handle<Object>(frame_inspector->GetExpression(i)), | 
|  10837                     NONE, |  10809                     NONE, | 
|  10838                     kNonStrictMode), |  10810                     kNonStrictMode), | 
|  10839         Handle<JSObject>()); |  10811         Handle<JSObject>()); | 
|  10840   } |  10812   } | 
|  10841  |  10813  | 
|  10842   if (scope_info->HasContext()) { |  10814   if (scope_info->HasContext()) { | 
|  10843     // Third fill all context locals. |  10815     // Third fill all context locals. | 
|  10844     Handle<Context> frame_context(Context::cast(frame->context())); |  10816     Handle<Context> frame_context(Context::cast(frame->context())); | 
|  10845     Handle<Context> function_context(frame_context->declaration_context()); |  10817     Handle<Context> function_context(frame_context->declaration_context()); | 
|  10846     if (!CopyContextLocalsToScopeObject( |  10818     if (!scope_info->CopyContextLocalsToScopeObject( | 
|  10847             isolate, scope_info, function_context, local_scope)) { |  10819             isolate, function_context, local_scope)) { | 
|  10848       return Handle<JSObject>(); |  10820       return Handle<JSObject>(); | 
|  10849     } |  10821     } | 
|  10850  |  10822  | 
|  10851     // Finally copy any properties from the function context extension. |  10823     // Finally copy any properties from the function context extension. | 
|  10852     // These will be variables introduced by eval. |  10824     // These will be variables introduced by eval. | 
|  10853     if (function_context->closure() == *function) { |  10825     if (function_context->closure() == *function) { | 
|  10854       if (function_context->has_extension() && |  10826       if (function_context->has_extension() && | 
|  10855           !function_context->IsNativeContext()) { |  10827           !function_context->IsNativeContext()) { | 
|  10856         Handle<JSObject> ext(JSObject::cast(function_context->extension())); |  10828         Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 
|  10857         bool threw = false; |  10829         bool threw = false; | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  10989  |  10961  | 
|  10990   Handle<SharedFunctionInfo> shared(context->closure()->shared()); |  10962   Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 
|  10991   Handle<ScopeInfo> scope_info(shared->scope_info()); |  10963   Handle<ScopeInfo> scope_info(shared->scope_info()); | 
|  10992  |  10964  | 
|  10993   // Allocate and initialize a JSObject with all the content of this function |  10965   // Allocate and initialize a JSObject with all the content of this function | 
|  10994   // closure. |  10966   // closure. | 
|  10995   Handle<JSObject> closure_scope = |  10967   Handle<JSObject> closure_scope = | 
|  10996       isolate->factory()->NewJSObject(isolate->object_function()); |  10968       isolate->factory()->NewJSObject(isolate->object_function()); | 
|  10997  |  10969  | 
|  10998   // Fill all context locals to the context extension. |  10970   // Fill all context locals to the context extension. | 
|  10999   if (!CopyContextLocalsToScopeObject( |  10971   if (!scope_info->CopyContextLocalsToScopeObject( | 
|  11000           isolate, scope_info, context, closure_scope)) { |  10972           isolate, context, closure_scope)) { | 
|  11001     return Handle<JSObject>(); |  10973     return Handle<JSObject>(); | 
|  11002   } |  10974   } | 
|  11003  |  10975  | 
|  11004   // Finally copy any properties from the function context extension. This will |  10976   // Finally copy any properties from the function context extension. This will | 
|  11005   // be variables introduced by eval. |  10977   // be variables introduced by eval. | 
|  11006   if (context->has_extension()) { |  10978   if (context->has_extension()) { | 
|  11007     Handle<JSObject> ext(JSObject::cast(context->extension())); |  10979     Handle<JSObject> ext(JSObject::cast(context->extension())); | 
|  11008     bool threw = false; |  10980     bool threw = false; | 
|  11009     Handle<FixedArray> keys = |  10981     Handle<FixedArray> keys = | 
|  11010         GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); |  10982         GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS, &threw); | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  11109     Handle<Context> context) { |  11081     Handle<Context> context) { | 
|  11110   ASSERT(context->IsBlockContext()); |  11082   ASSERT(context->IsBlockContext()); | 
|  11111   Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |  11083   Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 
|  11112  |  11084  | 
|  11113   // Allocate and initialize a JSObject with all the arguments, stack locals |  11085   // Allocate and initialize a JSObject with all the arguments, stack locals | 
|  11114   // heap locals and extension properties of the debugged function. |  11086   // heap locals and extension properties of the debugged function. | 
|  11115   Handle<JSObject> block_scope = |  11087   Handle<JSObject> block_scope = | 
|  11116       isolate->factory()->NewJSObject(isolate->object_function()); |  11088       isolate->factory()->NewJSObject(isolate->object_function()); | 
|  11117  |  11089  | 
|  11118   // Fill all context locals. |  11090   // Fill all context locals. | 
|  11119   if (!CopyContextLocalsToScopeObject( |  11091   if (!scope_info->CopyContextLocalsToScopeObject( | 
|  11120           isolate, scope_info, context, block_scope)) { |  11092           isolate, context, block_scope)) { | 
|  11121     return Handle<JSObject>(); |  11093     return Handle<JSObject>(); | 
|  11122   } |  11094   } | 
|  11123  |  11095  | 
|  11124   return block_scope; |  11096   return block_scope; | 
|  11125 } |  11097 } | 
|  11126  |  11098  | 
|  11127  |  11099  | 
|  11128 // Create a plain JSObject which materializes the module scope for the specified |  11100 // Create a plain JSObject which materializes the module scope for the specified | 
|  11129 // module context. |  11101 // module context. | 
|  11130 static Handle<JSObject> MaterializeModuleScope( |  11102 static Handle<JSObject> MaterializeModuleScope( | 
|  11131     Isolate* isolate, |  11103     Isolate* isolate, | 
|  11132     Handle<Context> context) { |  11104     Handle<Context> context) { | 
|  11133   ASSERT(context->IsModuleContext()); |  11105   ASSERT(context->IsModuleContext()); | 
|  11134   Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); |  11106   Handle<ScopeInfo> scope_info(ScopeInfo::cast(context->extension())); | 
|  11135  |  11107  | 
|  11136   // Allocate and initialize a JSObject with all the members of the debugged |  11108   // Allocate and initialize a JSObject with all the members of the debugged | 
|  11137   // module. |  11109   // module. | 
|  11138   Handle<JSObject> module_scope = |  11110   Handle<JSObject> module_scope = | 
|  11139       isolate->factory()->NewJSObject(isolate->object_function()); |  11111       isolate->factory()->NewJSObject(isolate->object_function()); | 
|  11140  |  11112  | 
|  11141   // Fill all context locals. |  11113   // Fill all context locals. | 
|  11142   if (!CopyContextLocalsToScopeObject( |  11114   if (!scope_info->CopyContextLocalsToScopeObject( | 
|  11143           isolate, scope_info, context, module_scope)) { |  11115           isolate, context, module_scope)) { | 
|  11144     return Handle<JSObject>(); |  11116     return Handle<JSObject>(); | 
|  11145   } |  11117   } | 
|  11146  |  11118  | 
|  11147   return module_scope; |  11119   return module_scope; | 
|  11148 } |  11120 } | 
|  11149  |  11121  | 
|  11150  |  11122  | 
|  11151 // Iterate over the actual scopes visible from a stack frame or from a closure. |  11123 // Iterate over the actual scopes visible from a stack frame or from a closure. | 
|  11152 // The iteration proceeds from the innermost visible nested scope outwards. |  11124 // The iteration proceeds from the innermost visible nested scope outwards. | 
|  11153 // All scopes are backed by an actual context except the local scope, |  11125 // All scopes are backed by an actual context except the local scope, | 
| (...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  13533     // Handle last resort GC and make sure to allow future allocations |  13505     // Handle last resort GC and make sure to allow future allocations | 
|  13534     // to grow the heap without causing GCs (if possible). |  13506     // to grow the heap without causing GCs (if possible). | 
|  13535     isolate->counters()->gc_last_resort_from_js()->Increment(); |  13507     isolate->counters()->gc_last_resort_from_js()->Increment(); | 
|  13536     isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |  13508     isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 
|  13537                                        "Runtime::PerformGC"); |  13509                                        "Runtime::PerformGC"); | 
|  13538   } |  13510   } | 
|  13539 } |  13511 } | 
|  13540  |  13512  | 
|  13541  |  13513  | 
|  13542 } }  // namespace v8::internal |  13514 } }  // namespace v8::internal | 
| OLD | NEW |