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 7865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7876 | 7876 |
7877 | 7877 |
7878 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 7878 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { |
7879 HandleScope scope(isolate); | 7879 HandleScope scope(isolate); |
7880 ASSERT(args.length() == 1); | 7880 ASSERT(args.length() == 1); |
7881 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 7881 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
7882 return *Execution::GetConstructorDelegate(args.at<Object>(0)); | 7882 return *Execution::GetConstructorDelegate(args.at<Object>(0)); |
7883 } | 7883 } |
7884 | 7884 |
7885 | 7885 |
7886 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewContext) { | 7886 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewFunctionContext) { |
7887 NoHandleAllocation ha; | 7887 NoHandleAllocation ha; |
7888 ASSERT(args.length() == 1); | 7888 ASSERT(args.length() == 1); |
7889 | 7889 |
7890 CONVERT_CHECKED(JSFunction, function, args[0]); | 7890 CONVERT_CHECKED(JSFunction, function, args[0]); |
7891 int length = function->shared()->scope_info()->NumberOfContextSlots(); | 7891 int length = function->shared()->scope_info()->NumberOfContextSlots(); |
7892 Object* result; | 7892 Object* result; |
7893 { MaybeObject* maybe_result = | 7893 { MaybeObject* maybe_result = |
7894 isolate->heap()->AllocateFunctionContext(length, function); | 7894 isolate->heap()->AllocateFunctionContext(length, function); |
7895 if (!maybe_result->ToObject(&result)) return maybe_result; | 7895 if (!maybe_result->ToObject(&result)) return maybe_result; |
7896 } | 7896 } |
7897 | 7897 |
7898 isolate->set_context(Context::cast(result)); | 7898 isolate->set_context(Context::cast(result)); |
7899 | 7899 |
7900 return result; // non-failure | 7900 return result; // non-failure |
7901 } | 7901 } |
7902 | 7902 |
7903 | 7903 |
7904 MUST_USE_RESULT static MaybeObject* PushContextHelper(Isolate* isolate, | 7904 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushWithContext) { |
7905 Object* object, | 7905 NoHandleAllocation ha; |
7906 bool is_catch_context) { | 7906 ASSERT(args.length() == 1); |
7907 // Convert the object to a proper JavaScript object. | 7907 JSObject* extension_object; |
7908 Object* js_object = object; | 7908 if (args[0]->IsJSObject()) { |
7909 if (!js_object->IsJSObject()) { | 7909 extension_object = JSObject::cast(args[0]); |
7910 MaybeObject* maybe_js_object = js_object->ToObject(); | 7910 } else { |
7911 if (!maybe_js_object->ToObject(&js_object)) { | 7911 // Convert the object to a proper JavaScript object. |
7912 if (!Failure::cast(maybe_js_object)->IsInternalError()) { | 7912 MaybeObject* maybe_js_object = args[0]->ToObject(); |
7913 if (!maybe_js_object->To(&extension_object)) { | |
7914 if (Failure::cast(maybe_js_object)->IsInternalError()) { | |
7915 HandleScope scope(isolate); | |
7916 Handle<Object> handle = args.at<Object>(0); | |
7917 Handle<Object> result = | |
7918 isolate->factory()->NewTypeError("with_expression", | |
7919 HandleVector(&handle, 1)); | |
7920 return isolate->Throw(*result); | |
7921 } else { | |
7913 return maybe_js_object; | 7922 return maybe_js_object; |
7914 } | 7923 } |
7915 HandleScope scope(isolate); | |
7916 Handle<Object> handle(object, isolate); | |
7917 Handle<Object> result = | |
7918 isolate->factory()->NewTypeError("with_expression", | |
7919 HandleVector(&handle, 1)); | |
7920 return isolate->Throw(*result); | |
7921 } | 7924 } |
7922 } | 7925 } |
7923 | 7926 |
7924 Object* result; | 7927 Context* context; |
7925 { MaybeObject* maybe_result = isolate->heap()->AllocateWithContext( | 7928 MaybeObject* maybe_context = |
7926 isolate->context(), JSObject::cast(js_object), is_catch_context); | 7929 isolate->heap()->AllocateWithContext(isolate->context(), |
7927 if (!maybe_result->ToObject(&result)) return maybe_result; | 7930 extension_object); |
7928 } | 7931 if (!maybe_context->To(&context)) return maybe_context; |
7929 | |
7930 Context* context = Context::cast(result); | |
7931 isolate->set_context(context); | 7932 isolate->set_context(context); |
7932 | 7933 return context; |
7933 return result; | |
7934 } | |
7935 | |
7936 | |
7937 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushContext) { | |
7938 NoHandleAllocation ha; | |
7939 ASSERT(args.length() == 1); | |
7940 return PushContextHelper(isolate, args[0], false); | |
7941 } | 7934 } |
7942 | 7935 |
7943 | 7936 |
7944 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { | 7937 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { |
7945 NoHandleAllocation ha; | 7938 NoHandleAllocation ha; |
7946 ASSERT(args.length() == 1); | 7939 ASSERT(args.length() == 1); |
7947 return PushContextHelper(isolate, args[0], true); | 7940 JSObject* extension_object = JSObject::cast(args[0]); |
7941 Context* context; | |
7942 MaybeObject* maybe_context = | |
7943 isolate->heap()->AllocateCatchContext(isolate->context(), | |
7944 extension_object); | |
7945 if (!maybe_context->To(&context)) return maybe_context; | |
7946 isolate->set_context(context); | |
7947 return context; | |
7948 } | 7948 } |
7949 | 7949 |
7950 | 7950 |
7951 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { | 7951 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { |
7952 HandleScope scope(isolate); | 7952 HandleScope scope(isolate); |
7953 ASSERT(args.length() == 2); | 7953 ASSERT(args.length() == 2); |
7954 | 7954 |
7955 CONVERT_ARG_CHECKED(Context, context, 0); | 7955 CONVERT_ARG_CHECKED(Context, context, 0); |
7956 CONVERT_ARG_CHECKED(String, name, 1); | 7956 CONVERT_ARG_CHECKED(String, name, 1); |
7957 | 7957 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8600 // it is bound in the global context. | 8600 // it is bound in the global context. |
8601 int index = -1; | 8601 int index = -1; |
8602 PropertyAttributes attributes = ABSENT; | 8602 PropertyAttributes attributes = ABSENT; |
8603 while (true) { | 8603 while (true) { |
8604 receiver = context->Lookup(isolate->factory()->eval_symbol(), | 8604 receiver = context->Lookup(isolate->factory()->eval_symbol(), |
8605 FOLLOW_PROTOTYPE_CHAIN, | 8605 FOLLOW_PROTOTYPE_CHAIN, |
8606 &index, &attributes); | 8606 &index, &attributes); |
8607 // Stop search when eval is found or when the global context is | 8607 // Stop search when eval is found or when the global context is |
8608 // reached. | 8608 // reached. |
8609 if (attributes != ABSENT || context->IsGlobalContext()) break; | 8609 if (attributes != ABSENT || context->IsGlobalContext()) break; |
8610 if (context->is_function_context()) { | 8610 if (context->IsFunctionContext()) { |
Kevin Millikin (Chromium)
2011/06/08 16:35:52
Global contexts could not reach this site.
| |
8611 context = Handle<Context>(Context::cast(context->closure()->context()), | 8611 context = Handle<Context>(context->closure()->context(), isolate); |
8612 isolate); | |
8613 } else { | 8612 } else { |
8614 context = Handle<Context>(context->previous(), isolate); | 8613 context = Handle<Context>(context->previous(), isolate); |
8615 } | 8614 } |
8616 } | 8615 } |
8617 | 8616 |
8618 // If eval could not be resolved, it has been deleted and we need to | 8617 // If eval could not be resolved, it has been deleted and we need to |
8619 // throw a reference error. | 8618 // throw a reference error. |
8620 if (attributes == ABSENT) { | 8619 if (attributes == ABSENT) { |
8621 Handle<Object> name = isolate->factory()->eval_symbol(); | 8620 Handle<Object> name = isolate->factory()->eval_symbol(); |
8622 Handle<Object> reference_error = | 8621 Handle<Object> reference_error = |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9835 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); | 9834 it.frame()->LookupCode()->SourcePosition(it.frame()->pc()); |
9836 | 9835 |
9837 // Check for constructor frame. | 9836 // Check for constructor frame. |
9838 bool constructor = it.frame()->IsConstructor(); | 9837 bool constructor = it.frame()->IsConstructor(); |
9839 | 9838 |
9840 // Get scope info and read from it for local variable information. | 9839 // Get scope info and read from it for local variable information. |
9841 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); | 9840 Handle<JSFunction> function(JSFunction::cast(it.frame()->function())); |
9842 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); | 9841 Handle<SerializedScopeInfo> scope_info(function->shared()->scope_info()); |
9843 ScopeInfo<> info(*scope_info); | 9842 ScopeInfo<> info(*scope_info); |
9844 | 9843 |
9845 // Get the context. | 9844 // Get the nearest enclosing function context. |
9846 Handle<Context> context(Context::cast(it.frame()->context())); | 9845 Handle<Context> context(Context::cast(it.frame()->context())->fcontext()); |
9847 | 9846 |
9848 // Get the locals names and values into a temporary array. | 9847 // Get the locals names and values into a temporary array. |
9849 // | 9848 // |
9850 // TODO(1240907): Hide compiler-introduced stack variables | 9849 // TODO(1240907): Hide compiler-introduced stack variables |
9851 // (e.g. .result)? For users of the debugger, they will probably be | 9850 // (e.g. .result)? For users of the debugger, they will probably be |
9852 // confusing. | 9851 // confusing. |
9853 Handle<FixedArray> locals = | 9852 Handle<FixedArray> locals = |
9854 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); | 9853 isolate->factory()->NewFixedArray(info.NumberOfLocals() * 2); |
9855 | 9854 |
9856 // Fill in the names of the locals. | 9855 // Fill in the names of the locals. |
9857 for (int i = 0; i < info.NumberOfLocals(); i++) { | 9856 for (int i = 0; i < info.NumberOfLocals(); i++) { |
9858 locals->set(i * 2, *info.LocalName(i)); | 9857 locals->set(i * 2, *info.LocalName(i)); |
9859 } | 9858 } |
9860 | 9859 |
9861 // Fill in the values of the locals. | 9860 // Fill in the values of the locals. |
9862 for (int i = 0; i < info.NumberOfLocals(); i++) { | 9861 if (is_optimized_frame) { |
9863 if (is_optimized_frame) { | 9862 // If we are inspecting an optimized frame use undefined as the |
9864 // If we are inspecting an optimized frame use undefined as the | 9863 // value for all locals. |
9865 // value for all locals. | 9864 // |
9866 // | 9865 // TODO(1140): We should be able to get the correct values |
9867 // TODO(1140): We should be able to get the correct values | 9866 // for locals in optimized frames. |
9868 // for locals in optimized frames. | 9867 for (int i = 0; i < info.NumberOfLocals(); i++) { |
9869 locals->set(i * 2 + 1, isolate->heap()->undefined_value()); | 9868 locals->set(i * 2 + 1, isolate->heap()->undefined_value()); |
9870 } else if (i < info.number_of_stack_slots()) { | 9869 } |
9870 } else { | |
9871 for (int i = 0; i < info.number_of_stack_slots(); i++) { | |
9871 // Get the value from the stack. | 9872 // Get the value from the stack. |
9872 locals->set(i * 2 + 1, it.frame()->GetExpression(i)); | 9873 locals->set(i * 2 + 1, it.frame()->GetExpression(i)); |
9873 } else { | 9874 } |
9874 // Traverse the context chain to the function context as all local | 9875 for (int i = info.number_of_stack_slots(); i < info.NumberOfLocals(); i++) { |
9875 // variables stored in the context will be on the function context. | |
9876 Handle<String> name = info.LocalName(i); | 9876 Handle<String> name = info.LocalName(i); |
9877 while (!context->is_function_context()) { | |
9878 context = Handle<Context>(context->previous()); | |
9879 } | |
9880 ASSERT(context->is_function_context()); | |
9881 locals->set(i * 2 + 1, | 9877 locals->set(i * 2 + 1, |
9882 context->get(scope_info->ContextSlotIndex(*name, NULL))); | 9878 context->get(scope_info->ContextSlotIndex(*name, NULL))); |
9883 } | 9879 } |
9884 } | 9880 } |
9885 | 9881 |
9886 // Check whether this frame is positioned at return. If not top | 9882 // Check whether this frame is positioned at return. If not top |
9887 // frame or if the frame is optimized it cannot be at a return. | 9883 // frame or if the frame is optimized it cannot be at a return. |
9888 bool at_return = false; | 9884 bool at_return = false; |
9889 if (!is_optimized_frame && index == 0) { | 9885 if (!is_optimized_frame && index == 0) { |
9890 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); | 9886 at_return = isolate->debug()->IsBreakAtReturn(it.frame()); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10132 } | 10128 } |
10133 } | 10129 } |
10134 return local_scope; | 10130 return local_scope; |
10135 } | 10131 } |
10136 | 10132 |
10137 | 10133 |
10138 // Create a plain JSObject which materializes the closure content for the | 10134 // Create a plain JSObject which materializes the closure content for the |
10139 // context. | 10135 // context. |
10140 static Handle<JSObject> MaterializeClosure(Isolate* isolate, | 10136 static Handle<JSObject> MaterializeClosure(Isolate* isolate, |
10141 Handle<Context> context) { | 10137 Handle<Context> context) { |
10142 ASSERT(context->is_function_context()); | 10138 ASSERT(context->IsFunctionContext()); |
Kevin Millikin (Chromium)
2011/06/08 16:35:52
It's a little convoluted, but MaterializeClosure i
| |
10143 | 10139 |
10144 Handle<SharedFunctionInfo> shared(context->closure()->shared()); | 10140 Handle<SharedFunctionInfo> shared(context->closure()->shared()); |
10145 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); | 10141 Handle<SerializedScopeInfo> serialized_scope_info(shared->scope_info()); |
10146 ScopeInfo<> scope_info(*serialized_scope_info); | 10142 ScopeInfo<> scope_info(*serialized_scope_info); |
10147 | 10143 |
10148 // Allocate and initialize a JSObject with all the content of theis function | 10144 // Allocate and initialize a JSObject with all the content of theis function |
10149 // closure. | 10145 // closure. |
10150 Handle<JSObject> closure_scope = | 10146 Handle<JSObject> closure_scope = |
10151 isolate->factory()->NewJSObject(isolate->object_function()); | 10147 isolate->factory()->NewJSObject(isolate->object_function()); |
10152 | 10148 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10231 | 10227 |
10232 // Check whether the first scope is actually a local scope. | 10228 // Check whether the first scope is actually a local scope. |
10233 if (context_->IsGlobalContext()) { | 10229 if (context_->IsGlobalContext()) { |
10234 // If there is a stack slot for .result then this local scope has been | 10230 // If there is a stack slot for .result then this local scope has been |
10235 // created for evaluating top level code and it is not a real local scope. | 10231 // created for evaluating top level code and it is not a real local scope. |
10236 // Checking for the existence of .result seems fragile, but the scope info | 10232 // Checking for the existence of .result seems fragile, but the scope info |
10237 // saved with the code object does not otherwise have that information. | 10233 // saved with the code object does not otherwise have that information. |
10238 int index = function_->shared()->scope_info()-> | 10234 int index = function_->shared()->scope_info()-> |
10239 StackSlotIndex(isolate_->heap()->result_symbol()); | 10235 StackSlotIndex(isolate_->heap()->result_symbol()); |
10240 at_local_ = index < 0; | 10236 at_local_ = index < 0; |
10241 } else if (context_->is_function_context()) { | 10237 } else if (context_->IsFunctionContext()) { |
Kevin Millikin (Chromium)
2011/06/08 16:35:52
Global contexts could not reach this site.
| |
10242 at_local_ = true; | 10238 at_local_ = true; |
10243 } else if (context_->closure() != *function_) { | 10239 } else if (context_->closure() != *function_) { |
10244 // The context_ is a with block from the outer function. | 10240 // The context_ is a with block from the outer function. |
10245 ASSERT(context_->has_extension()); | 10241 ASSERT(context_->has_extension()); |
10246 at_local_ = true; | 10242 at_local_ = true; |
10247 } | 10243 } |
10248 } | 10244 } |
10249 | 10245 |
10250 // More scopes? | 10246 // More scopes? |
10251 bool Done() { return context_.is_null(); } | 10247 bool Done() { return context_.is_null(); } |
(...skipping 13 matching lines...) Expand all Loading... | |
10265 } | 10261 } |
10266 } | 10262 } |
10267 | 10263 |
10268 // The global scope is always the last in the chain. | 10264 // The global scope is always the last in the chain. |
10269 if (context_->IsGlobalContext()) { | 10265 if (context_->IsGlobalContext()) { |
10270 context_ = Handle<Context>(); | 10266 context_ = Handle<Context>(); |
10271 return; | 10267 return; |
10272 } | 10268 } |
10273 | 10269 |
10274 // Move to the next context. | 10270 // Move to the next context. |
10275 if (context_->is_function_context()) { | 10271 if (context_->IsFunctionContext()) { |
Kevin Millikin (Chromium)
2011/06/08 16:35:52
Also here.
| |
10276 context_ = Handle<Context>(Context::cast(context_->closure()->context())); | 10272 context_ = Handle<Context>(context_->closure()->context()); |
10277 } else { | 10273 } else { |
10278 context_ = Handle<Context>(context_->previous()); | 10274 context_ = Handle<Context>(context_->previous()); |
10279 } | 10275 } |
10280 | 10276 |
10281 // If passing the local scope indicate that the current scope is now the | 10277 // If passing the local scope indicate that the current scope is now the |
10282 // local scope. | 10278 // local scope. |
10283 if (!local_done_ && | 10279 if (!local_done_ && |
10284 (context_->IsGlobalContext() || (context_->is_function_context()))) { | 10280 (context_->IsGlobalContext() || (context_->IsFunctionContext()))) { |
Mads Ager (chromium)
2011/06/09 07:31:00
Can't we remove the IsGlobalContext here as well s
Kevin Millikin (Chromium)
2011/06/09 11:09:40
Not here, because this context_ is already the nex
Mads Ager (chromium)
2011/06/09 11:12:53
Oh, yeah. Thanks!
| |
10285 at_local_ = true; | 10281 at_local_ = true; |
10286 } | 10282 } |
10287 } | 10283 } |
10288 | 10284 |
10289 // Return the type of the current scope. | 10285 // Return the type of the current scope. |
10290 int Type() { | 10286 int Type() { |
10291 if (at_local_) { | 10287 if (at_local_) { |
10292 return ScopeTypeLocal; | 10288 return ScopeTypeLocal; |
10293 } | 10289 } |
10294 if (context_->IsGlobalContext()) { | 10290 if (context_->IsGlobalContext()) { |
10295 ASSERT(context_->global()->IsGlobalObject()); | 10291 ASSERT(context_->global()->IsGlobalObject()); |
10296 return ScopeTypeGlobal; | 10292 return ScopeTypeGlobal; |
10297 } | 10293 } |
10298 if (context_->is_function_context()) { | 10294 if (context_->IsFunctionContext()) { |
Kevin Millikin (Chromium)
2011/06/08 16:35:52
Also here.
| |
10299 return ScopeTypeClosure; | 10295 return ScopeTypeClosure; |
10300 } | 10296 } |
10301 ASSERT(context_->has_extension()); | 10297 ASSERT(context_->has_extension()); |
10302 // Current scope is either an explicit with statement or a with statement | 10298 // Current scope is either an explicit with statement or a with statement |
10303 // implicitely generated for a catch block. | 10299 // implicitely generated for a catch block. |
10304 // If the extension object here is a JSContextExtensionObject then | 10300 // If the extension object here is a JSContextExtensionObject then |
10305 // current with statement is one frome a catch block otherwise it's a | 10301 // current with statement is one frome a catch block otherwise it's a |
10306 // regular with statement. | 10302 // regular with statement. |
10307 if (context_->extension()->IsJSContextExtensionObject()) { | 10303 if (context_->extension()->IsJSContextExtensionObject()) { |
10308 return ScopeTypeCatch; | 10304 return ScopeTypeCatch; |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10856 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { | 10852 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { |
10857 HandleScope scope(isolate); | 10853 HandleScope scope(isolate); |
10858 ASSERT(args.length() == 0); | 10854 ASSERT(args.length() == 0); |
10859 isolate->debug()->ClearStepping(); | 10855 isolate->debug()->ClearStepping(); |
10860 return isolate->heap()->undefined_value(); | 10856 return isolate->heap()->undefined_value(); |
10861 } | 10857 } |
10862 | 10858 |
10863 | 10859 |
10864 // Creates a copy of the with context chain. The copy of the context chain is | 10860 // Creates a copy of the with context chain. The copy of the context chain is |
10865 // is linked to the function context supplied. | 10861 // is linked to the function context supplied. |
10866 static Handle<Context> CopyWithContextChain(Handle<Context> context_chain, | 10862 static Handle<Context> CopyWithContextChain(Isolate* isolate, |
10867 Handle<Context> function_context) { | 10863 Handle<Context> current, |
10868 // At the bottom of the chain. Return the function context to link to. | 10864 Handle<Context> base) { |
10869 if (context_chain->is_function_context()) { | 10865 // At the end of the chain. Return the bast context to link to. |
Kevin Millikin (Chromium)
2011/06/08 16:35:52
bast ==> base. Duh.
| |
10870 return function_context; | 10866 if (current->IsFunctionContext() || current->IsGlobalContext()) { |
10867 return base; | |
10871 } | 10868 } |
10872 | 10869 |
10873 // Recursively copy the with contexts. | 10870 // Recursively copy the with and catch contexts. |
10874 Handle<Context> previous(context_chain->previous()); | 10871 HandleScope scope(isolate); |
10875 Handle<JSObject> extension(JSObject::cast(context_chain->extension())); | 10872 Handle<Context> previous(current->previous()); |
10876 Handle<Context> context = CopyWithContextChain(previous, function_context); | 10873 Handle<Context> new_previous = CopyWithContextChain(isolate, previous, base); |
10877 return context->GetIsolate()->factory()->NewWithContext( | 10874 Handle<JSObject> extension(JSObject::cast(current->extension())); |
10878 context, extension, context_chain->IsCatchContext()); | 10875 Handle<Context> new_current = current->IsCatchContext() |
10876 ? isolate->factory()->NewCatchContext(new_previous, extension) | |
10877 : isolate->factory()->NewWithContext(new_previous, extension); | |
10878 return scope.CloseAndEscape(new_current); | |
10879 } | 10879 } |
10880 | 10880 |
10881 | 10881 |
10882 // Helper function to find or create the arguments object for | 10882 // Helper function to find or create the arguments object for |
10883 // Runtime_DebugEvaluate. | 10883 // Runtime_DebugEvaluate. |
10884 static Handle<Object> GetArgumentsObject(Isolate* isolate, | 10884 static Handle<Object> GetArgumentsObject(Isolate* isolate, |
10885 JavaScriptFrame* frame, | 10885 JavaScriptFrame* frame, |
10886 Handle<JSFunction> function, | 10886 Handle<JSFunction> function, |
10887 Handle<SerializedScopeInfo> scope_info, | 10887 Handle<SerializedScopeInfo> scope_info, |
10888 const ScopeInfo<>* sinfo, | 10888 const ScopeInfo<>* sinfo, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10997 | 10997 |
10998 // Allocate a new context for the debug evaluation and set the extension | 10998 // Allocate a new context for the debug evaluation and set the extension |
10999 // object build. | 10999 // object build. |
11000 Handle<Context> context = | 11000 Handle<Context> context = |
11001 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, | 11001 isolate->factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, |
11002 go_between); | 11002 go_between); |
11003 context->set_extension(*local_scope); | 11003 context->set_extension(*local_scope); |
11004 // Copy any with contexts present and chain them in front of this context. | 11004 // Copy any with contexts present and chain them in front of this context. |
11005 Handle<Context> frame_context(Context::cast(frame->context())); | 11005 Handle<Context> frame_context(Context::cast(frame->context())); |
11006 Handle<Context> function_context(frame_context->fcontext()); | 11006 Handle<Context> function_context(frame_context->fcontext()); |
11007 context = CopyWithContextChain(frame_context, context); | 11007 context = CopyWithContextChain(isolate, frame_context, context); |
11008 | 11008 |
11009 if (additional_context->IsJSObject()) { | 11009 if (additional_context->IsJSObject()) { |
11010 context = isolate->factory()->NewWithContext(context, | 11010 Handle<JSObject> extension = Handle<JSObject>::cast(additional_context); |
11011 Handle<JSObject>::cast(additional_context), false); | 11011 context = isolate->factory()->NewWithContext(context, extension); |
11012 } | 11012 } |
11013 | 11013 |
11014 // Wrap the evaluation statement in a new function compiled in the newly | 11014 // Wrap the evaluation statement in a new function compiled in the newly |
11015 // created context. The function has one parameter which has to be called | 11015 // created context. The function has one parameter which has to be called |
11016 // 'arguments'. This it to have access to what would have been 'arguments' in | 11016 // 'arguments'. This it to have access to what would have been 'arguments' in |
11017 // the function being debugged. | 11017 // the function being debugged. |
11018 // function(arguments,__source__) {return eval(__source__);} | 11018 // function(arguments,__source__) {return eval(__source__);} |
11019 | 11019 |
11020 Handle<String> function_source = | 11020 Handle<String> function_source = |
11021 isolate->factory()->NewStringFromAscii( | 11021 isolate->factory()->NewStringFromAscii( |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12363 } else { | 12363 } else { |
12364 // Handle last resort GC and make sure to allow future allocations | 12364 // Handle last resort GC and make sure to allow future allocations |
12365 // to grow the heap without causing GCs (if possible). | 12365 // to grow the heap without causing GCs (if possible). |
12366 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12366 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12367 isolate->heap()->CollectAllGarbage(false); | 12367 isolate->heap()->CollectAllGarbage(false); |
12368 } | 12368 } |
12369 } | 12369 } |
12370 | 12370 |
12371 | 12371 |
12372 } } // namespace v8::internal | 12372 } } // namespace v8::internal |
OLD | NEW |