Commit eecc9ff8 authored by dcarney@chromium.org's avatar dcarney@chromium.org

remove use of context scope with persistent argument

R=svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/15837007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14844 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5b469a6f
......@@ -4929,6 +4929,7 @@ class V8EXPORT Context {
explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) {
context_->Enter();
}
// TODO(dcarney): deprecate
V8_INLINE(Scope(Isolate* isolate, Persistent<Context>& context)) // NOLINT
#ifndef V8_USE_UNSAFE_HANDLES
: context_(Handle<Context>::New(isolate, context)) {
......
......@@ -130,7 +130,9 @@ void DispatchDebugMessages() {
// think about.
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
v8::Context::Scope scope(isolate, debug_message_context);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, debug_message_context);
v8::Context::Scope scope(context);
v8::Debug::ProcessDebugMessages();
}
......
......@@ -168,11 +168,12 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
// is what we need for the reference to remain after we return from
// this method. That persistent handle has to be disposed in the
// destructor.
context_.Reset(GetIsolate(), Context::New(GetIsolate(), NULL, global));
v8::Handle<v8::Context> context = Context::New(GetIsolate(), NULL, global);
context_.Reset(GetIsolate(), context);
// Enter the new context so all the following operations take place
// within it.
Context::Scope context_scope(GetIsolate(), context_);
Context::Scope context_scope(context);
// Make the options mapping available within the context
if (!InstallMaps(opts, output))
......@@ -253,9 +254,12 @@ bool JsHttpRequestProcessor::Process(HttpRequest* request) {
// Create a handle scope to keep the temporary object references.
HandleScope handle_scope(GetIsolate());
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(GetIsolate(), context_);
// Enter this processor's context so all the remaining operations
// take place there
Context::Scope context_scope(GetIsolate(), context_);
Context::Scope context_scope(context);
// Wrap the C++ request object in a JavaScript wrapper
Handle<Object> request_obj = WrapRequest(request);
......
......@@ -243,7 +243,9 @@ bool Shell::ExecuteString(Isolate* isolate,
#if !defined(V8_SHARED)
} else {
v8::TryCatch try_catch;
Context::Scope context_scope(isolate, utility_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, utility_context_);
v8::Context::Scope context_scope(context);
Handle<Object> global = utility_context_->Global();
Handle<Value> fun = global->Get(String::New("Stringify"));
Handle<Value> argv[1] = { result };
......@@ -592,7 +594,9 @@ Handle<Array> Shell::GetCompletions(Isolate* isolate,
Handle<String> text,
Handle<String> full) {
HandleScope handle_scope(isolate);
Context::Scope context_scope(isolate, utility_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, utility_context_);
v8::Context::Scope context_scope(context);
Handle<Object> global = utility_context_->Global();
Handle<Value> fun = global->Get(String::New("GetCompletions"));
static const int kArgc = 3;
......@@ -606,7 +610,9 @@ Handle<Array> Shell::GetCompletions(Isolate* isolate,
Handle<Object> Shell::DebugMessageDetails(Isolate* isolate,
Handle<String> message) {
HandleScope handle_scope(isolate);
Context::Scope context_scope(isolate, utility_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, utility_context_);
v8::Context::Scope context_scope(context);
Handle<Object> global = utility_context_->Global();
Handle<Value> fun = global->Get(String::New("DebugMessageDetails"));
static const int kArgc = 1;
......@@ -619,7 +625,9 @@ Handle<Object> Shell::DebugMessageDetails(Isolate* isolate,
Handle<Value> Shell::DebugCommandToJSONRequest(Isolate* isolate,
Handle<String> command) {
HandleScope handle_scope(isolate);
Context::Scope context_scope(isolate, utility_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, utility_context_);
v8::Context::Scope context_scope(context);
Handle<Object> global = utility_context_->Global();
Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest"));
static const int kArgc = 1;
......@@ -632,7 +640,9 @@ Handle<Value> Shell::DebugCommandToJSONRequest(Isolate* isolate,
void Shell::DispatchDebugMessages() {
Isolate* isolate = v8::Isolate::GetCurrent();
HandleScope handle_scope(isolate);
v8::Context::Scope scope(isolate, Shell::evaluation_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, Shell::evaluation_context_);
v8::Context::Scope context_scope(context);
v8::Debug::ProcessDebugMessages();
}
#endif // ENABLE_DEBUGGER_SUPPORT
......@@ -745,7 +755,9 @@ void Shell::InstallUtilityScript(Isolate* isolate) {
// utility, evaluation and debug context can all access each other.
utility_context_->SetSecurityToken(Undefined(isolate));
evaluation_context_->SetSecurityToken(Undefined(isolate));
Context::Scope utility_scope(isolate, utility_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, utility_context_);
v8::Context::Scope context_scope(context);
#ifdef ENABLE_DEBUGGER_SUPPORT
if (i::FLAG_debugger) printf("JavaScript debugger enabled\n");
......@@ -1121,7 +1133,9 @@ Handle<String> Shell::ReadFile(Isolate* isolate, const char* name) {
void Shell::RunShell(Isolate* isolate) {
Locker locker(isolate);
HandleScope outer_scope(isolate);
Context::Scope context_scope(isolate, evaluation_context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate, evaluation_context_);
v8::Context::Scope context_scope(context);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
Handle<String> name = String::New("(d8)");
LineEditor* console = LineEditor::Get();
......
......@@ -17327,7 +17327,9 @@ TEST(RunTwoIsolatesOnSingleThread) {
{
v8::HandleScope scope(isolate1);
v8::Context::Scope cscope(isolate1, context1);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate1, context1);
v8::Context::Scope context_scope(context);
// Run something in new isolate.
CompileRun("var foo = 'isolate 1';");
ExpectString("function f() { return foo; }; f()", "isolate 1");
......@@ -17341,7 +17343,9 @@ TEST(RunTwoIsolatesOnSingleThread) {
v8::Isolate::Scope iscope(isolate2);
v8::HandleScope scope(isolate2);
context2.Reset(isolate2, Context::New(isolate2));
v8::Context::Scope cscope(isolate2, context2);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate2, context2);
v8::Context::Scope context_scope(context);
// Run something in new isolate.
CompileRun("var foo = 'isolate 2';");
......@@ -17350,7 +17354,9 @@ TEST(RunTwoIsolatesOnSingleThread) {
{
v8::HandleScope scope(isolate1);
v8::Context::Scope cscope(isolate1, context1);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate1, context1);
v8::Context::Scope context_scope(context);
// Now again in isolate 1
ExpectString("function f() { return foo; }; f()", "isolate 1");
}
......@@ -17368,7 +17374,9 @@ TEST(RunTwoIsolatesOnSingleThread) {
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Context::Scope cscope(v8::Isolate::GetCurrent(), context_default);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context_default);
v8::Context::Scope context_scope(context);
// Variables in other isolates should be not available, verify there
// is an exception.
ExpectTrue("function f() {"
......@@ -17388,13 +17396,17 @@ TEST(RunTwoIsolatesOnSingleThread) {
{
v8::Isolate::Scope iscope(isolate2);
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Context::Scope cscope(isolate2, context2);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate2, context2);
v8::Context::Scope context_scope(context);
ExpectString("function f() { return foo; }; f()", "isolate 2");
}
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Context::Scope cscope(v8::Isolate::GetCurrent(), context1);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context1);
v8::Context::Scope context_scope(context);
ExpectString("function f() { return foo; }; f()", "isolate 1");
}
......@@ -17420,7 +17432,9 @@ TEST(RunTwoIsolatesOnSingleThread) {
// Check that default isolate still runs.
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Context::Scope cscope(v8::Isolate::GetCurrent(), context_default);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(v8::Isolate::GetCurrent(), context_default);
v8::Context::Scope context_scope(context);
ExpectTrue("function f() { return isDefaultIsolate; }; f()");
}
}
......
......@@ -73,7 +73,9 @@ class KangarooThread : public v8::internal::Thread {
v8::Isolate::Scope isolate_scope(isolate_);
CHECK_EQ(isolate_, v8::internal::Isolate::Current());
v8::HandleScope scope(isolate_);
v8::Context::Scope context_scope(isolate_, context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
Local<Value> v = CompileRun("getValue()");
CHECK(v->IsNumber());
CHECK_EQ(30, static_cast<int>(v->NumberValue()));
......@@ -82,7 +84,9 @@ class KangarooThread : public v8::internal::Thread {
v8::Locker locker(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope scope(isolate_);
v8::Context::Scope context_scope(isolate_, context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
Local<Value> v = CompileRun("getValue()");
CHECK(v->IsNumber());
CHECK_EQ(30, static_cast<int>(v->NumberValue()));
......@@ -352,7 +356,9 @@ class LockIsolateAndCalculateFibSharedContextThread : public JoinableThread {
v8::Locker lock(isolate_);
v8::Isolate::Scope isolate_scope(isolate_);
HandleScope handle_scope(isolate_);
v8::Context::Scope context_scope(isolate_, context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
CalcFibAndCheck();
}
private:
......@@ -540,7 +546,9 @@ class LockUnlockLockThread : public JoinableThread {
{
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
v8::Context::Scope context_scope(isolate_, context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
CalcFibAndCheck();
}
{
......@@ -553,7 +561,9 @@ class LockUnlockLockThread : public JoinableThread {
v8::HandleScope handle_scope(isolate_);
CHECK(v8::Locker::IsLocked(isolate_));
CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
v8::Context::Scope context_scope(isolate_, context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(isolate_, context_);
v8::Context::Scope context_scope(context);
CalcFibAndCheck();
}
}
......@@ -597,7 +607,9 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread {
v8::Locker lock1(CcTest::default_isolate());
{
v8::HandleScope handle_scope(CcTest::default_isolate());
v8::Context::Scope context_scope(CcTest::default_isolate(), context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(CcTest::default_isolate(), context_);
v8::Context::Scope context_scope(context);
CalcFibAndCheck();
}
{
......@@ -605,7 +617,9 @@ class LockUnlockLockDefaultIsolateThread : public JoinableThread {
{
v8::Locker lock2(CcTest::default_isolate());
v8::HandleScope handle_scope(CcTest::default_isolate());
v8::Context::Scope context_scope(CcTest::default_isolate(), context_);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(CcTest::default_isolate(), context_);
v8::Context::Scope context_scope(context);
CalcFibAndCheck();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment