Permalink
Browse files

Revert "deprecate Context::New which returns Persistent"

This reverts r14573 because of test failures in no-snapshot mode in the
cctest/test-debug/ScriptCollectedEventContext test case.

TBR=dcarney@chromium.org,svenpanne@chromium.org
TEST=cctest/test-debug/ScriptCollectedEventContext

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@14578 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information...
1 parent 920d2a7 commit 504a788c1423868d08f48b5de703aa0ff98da78c mstarzinger@chromium.org committed May 7, 2013
View
@@ -4609,11 +4609,11 @@ class V8EXPORT Context {
Handle<Value> global_object = Handle<Value>());
/** Deprecated. Use Isolate version instead. */
- V8_DEPRECATED(
- static Persistent<Context> New(
- ExtensionConfiguration* extensions = NULL,
- Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
- Handle<Value> global_object = Handle<Value>()));
+ // TODO(mstarzinger): Put this behind the V8_DEPRECATED guard.
+ static Persistent<Context> New(
+ ExtensionConfiguration* extensions = NULL,
+ Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
+ Handle<Value> global_object = Handle<Value>());
/** Returns the last entered context. */
static Local<Context> GetEntered();
View
@@ -168,7 +168,7 @@ 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));
+ context_ = Context::New(NULL, global);
// Enter the new context so all the following operations take place
// within it.
View
@@ -1539,8 +1539,7 @@ void Shell::InitializeDebugger(Isolate* isolate) {
Locker lock(isolate);
HandleScope scope(isolate);
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
- utility_context_.Reset(isolate,
- Context::New(isolate, NULL, global_template));
+ utility_context_ = Context::New(NULL, global_template);
#ifdef ENABLE_DEBUGGER_SUPPORT
// Start the debugger agent if requested.
@@ -1553,17 +1552,17 @@ void Shell::InitializeDebugger(Isolate* isolate) {
}
-Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
+Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
#ifndef V8_SHARED
// This needs to be a critical section since this is not thread-safe
i::ScopedLock lock(context_mutex_);
#endif // V8_SHARED
// Initialize the global objects
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
- HandleScope handle_scope(isolate);
- Local<Context> context = Context::New(isolate, NULL, global_template);
+ Persistent<Context> context = Context::New(NULL, global_template);
ASSERT(!context.IsEmpty());
- Context::Scope scope(context);
+ HandleScope handle_scope(isolate);
+ Context::Scope scope(isolate, context);
#ifndef V8_SHARED
i::JSArguments js_args = i::FLAG_js_arguments;
@@ -1579,7 +1578,7 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
context->Global()->Set(String::New("arguments"),
Utils::ToLocal(arguments_jsarray));
#endif // V8_SHARED
- return handle_scope.Close(context);
+ return context;
}
@@ -1810,9 +1809,9 @@ void ShellThread::Run() {
// Prepare the context for this thread.
Locker locker(isolate_);
HandleScope outer_scope(isolate_);
- Local<Context> thread_context =
+ Persistent<Context> thread_context =
Shell::CreateEvaluationContext(isolate_);
- Context::Scope context_scope(thread_context);
+ Context::Scope context_scope(isolate_, thread_context);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate_));
while ((ptr != NULL) && (*ptr != '\0')) {
@@ -1834,6 +1833,7 @@ void ShellThread::Run() {
Shell::ExecuteString(isolate_, str, String::New(filename), false, false);
}
+ thread_context.Dispose(thread_context->GetIsolate());
ptr = next_line;
}
}
@@ -1910,16 +1910,15 @@ void SourceGroup::ExecuteInThread() {
{
Isolate::Scope iscope(isolate);
Locker lock(isolate);
+ HandleScope scope(isolate);
+ PerIsolateData data(isolate);
+ Persistent<Context> context = Shell::CreateEvaluationContext(isolate);
{
- HandleScope scope(isolate);
- PerIsolateData data(isolate);
- Local<Context> context = Shell::CreateEvaluationContext(isolate);
- {
- Context::Scope cscope(context);
- PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
- Execute(isolate);
- }
+ Context::Scope cscope(isolate, context);
+ PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
+ Execute(isolate);
}
+ context.Dispose(isolate);
if (Shell::options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000;
V8::ContextDisposedNotification();
@@ -2110,27 +2109,26 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
#endif // V8_SHARED
{ // NOLINT
Locker lock(isolate);
- {
- HandleScope scope(isolate);
- Local<Context> context = CreateEvaluationContext(isolate);
- if (options.last_run) {
- // Keep using the same context in the interactive shell.
- evaluation_context_.Reset(isolate, context);
+ HandleScope scope(isolate);
+ Persistent<Context> context = CreateEvaluationContext(isolate);
+ if (options.last_run) {
+ // Keep using the same context in the interactive shell.
+ evaluation_context_ = context;
#if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
- // If the interactive debugger is enabled make sure to activate
- // it before running the files passed on the command line.
- if (i::FLAG_debugger) {
- InstallUtilityScript(isolate);
- }
-#endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
- }
- {
- Context::Scope cscope(context);
- PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
- options.isolate_sources[0].Execute(isolate);
+ // If the interactive debugger is enabled make sure to activate
+ // it before running the files passed on the command line.
+ if (i::FLAG_debugger) {
+ InstallUtilityScript(isolate);
}
+#endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
+ }
+ {
+ Context::Scope cscope(isolate, context);
+ PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
+ options.isolate_sources[0].Execute(isolate);
}
if (!options.last_run) {
+ context.Dispose(isolate);
if (options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000;
V8::ContextDisposedNotification();
View
@@ -273,7 +273,7 @@ class Shell : public i::AllStatic {
static const char* ToCString(const v8::String::Utf8Value& value);
static void ReportException(Isolate* isolate, TryCatch* try_catch);
static Handle<String> ReadFile(Isolate* isolate, const char* name);
- static Local<Context> CreateEvaluationContext(Isolate* isolate);
+ static Persistent<Context> CreateEvaluationContext(Isolate* isolate);
static int RunMain(Isolate* isolate, int argc, char* argv[]);
static int Main(int argc, char* argv[]);
static void Exit(int exit_code);
View
@@ -328,18 +328,13 @@ int main(int argc, char** argv) {
}
#endif
i::Serializer::Enable();
- Isolate* isolate = Isolate::GetCurrent();
- Persistent<Context> context;
- {
- HandleScope handle_scope(isolate);
- context.Reset(isolate, Context::New(isolate));
- }
-
+ Persistent<Context> context = v8::Context::New();
if (context.IsEmpty()) {
fprintf(stderr,
"\nException thrown while compiling natives - see above.\n\n");
exit(1);
}
+ Isolate* isolate = context->GetIsolate();
if (i::FLAG_extra_code != NULL) {
context->Enter();
// Capture 100 frames if anything happens.
View
@@ -207,14 +207,8 @@ class LocalContext {
LocalContext(v8::ExtensionConfiguration* extensions = 0,
v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(),
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- HandleScope scope(isolate);
- context_.Reset(isolate,
- Context::New(isolate,
- extensions,
- global_template,
- global_object));
+ v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
+ : context_(v8::Context::New(extensions, global_template, global_object)) {
context_->Enter();
// We can't do this later perhaps because of a fatal error.
isolate_ = context_->GetIsolate();
Oops, something went wrong.

0 comments on commit 504a788

Please sign in to comment.