From b256c9c192afaa87b9b94c521dd0811252d46f2d Mon Sep 17 00:00:00 2001 From: "ricow@chromium.org" Date: Thu, 16 Jun 2011 08:35:26 +0000 Subject: [PATCH] Reinitialize the arguments object in d8 when renewing the evaluation context (fixes issue 1477). Review URL: http://codereview.chromium.org/7189007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8312 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/d8.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/d8.cc b/src/d8.cc index 5a52380..56a43ad 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -613,19 +613,6 @@ void Shell::Initialize() { utility_context_->SetSecurityToken(Undefined()); Context::Scope utility_scope(utility_context_); - i::JSArguments js_args = i::FLAG_js_arguments; - i::Handle arguments_array = - FACTORY->NewFixedArray(js_args.argc()); - for (int j = 0; j < js_args.argc(); j++) { - i::Handle arg = - FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j])); - arguments_array->set(j, *arg); - } - i::Handle arguments_jsarray = - FACTORY->NewJSArrayWithElements(arguments_array); - global_template->Set(String::New("arguments"), - Utils::ToLocal(arguments_jsarray)); - #ifdef ENABLE_DEBUGGER_SUPPORT // Install the debugger object in the utility scope i::Debug* debug = i::Isolate::Current()->debug(); @@ -650,6 +637,20 @@ void Shell::RenewEvaluationContext() { evaluation_context_ = Context::New(NULL, global_template); evaluation_context_->SetSecurityToken(Undefined()); + Context::Scope utility_scope(utility_context_); + i::JSArguments js_args = i::FLAG_js_arguments; + i::Handle arguments_array = + FACTORY->NewFixedArray(js_args.argc()); + for (int j = 0; j < js_args.argc(); j++) { + i::Handle arg = + FACTORY->NewStringFromUtf8(i::CStrVector(js_args[j])); + arguments_array->set(j, *arg); + } + i::Handle arguments_jsarray = + FACTORY->NewJSArrayWithElements(arguments_array); + evaluation_context_->Global()->Set(String::New("arguments"), + Utils::ToLocal(arguments_jsarray)); + #ifdef ENABLE_DEBUGGER_SUPPORT i::Debug* debug = i::Isolate::Current()->debug(); debug->Load(); -- 2.7.4