Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: src/api.cc

Issue 13799003: Change Context::New not create persistent handles. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adapted cctest initialization to new API. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 2df32ca6fc814bdec05983fae63ceaeb14fd9d51..a7b45c4307e7a51b2642d94e6c77a56c18cac0a8 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4863,18 +4863,14 @@ static i::Handle<i::FunctionTemplateInfo>
}
-Persistent<Context> v8::Context::New(
+static i::Handle<i::Context> CreateEnvironment(
+ i::Isolate* isolate,
v8::ExtensionConfiguration* extensions,
v8::Handle<ObjectTemplate> global_template,
v8::Handle<Value> global_object) {
- i::Isolate::EnsureDefaultIsolate();
- i::Isolate* isolate = i::Isolate::Current();
- EnsureInitializedForIsolate(isolate, "v8::Context::New()");
- LOG_API(isolate, "Context::New");
- ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>());
+ i::Handle<i::Context> env;
// Enter V8 via an ENTER_V8 scope.
- i::Handle<i::Context> env;
{
ENTER_V8(isolate);
v8::Handle<ObjectTemplate> proxy_template = global_template;
@@ -4929,10 +4925,43 @@ Persistent<Context> v8::Context::New(
}
// Leave V8.
- if (env.is_null()) {
- return Persistent<Context>();
- }
- return Persistent<Context>(Utils::ToLocal(env));
+ return env;
+}
+
+
+Persistent<Context> v8::Context::New(
+ v8::ExtensionConfiguration* extensions,
+ v8::Handle<ObjectTemplate> global_template,
+ v8::Handle<Value> global_object) {
+ i::Isolate::EnsureDefaultIsolate();
+ i::Isolate* isolate = i::Isolate::Current();
+ Isolate* external_isolate = reinterpret_cast<Isolate*>(isolate);
+ EnsureInitializedForIsolate(isolate, "v8::Context::New()");
+ LOG_API(isolate, "Context::New");
+ ON_BAILOUT(isolate, "v8::Context::New()", return Persistent<Context>());
+ i::HandleScope scope(isolate);
+ i::Handle<i::Context> env =
+ CreateEnvironment(isolate, extensions, global_template, global_object);
+ if (env.is_null()) return Persistent<Context>();
+ return Persistent<Context>::New(external_isolate, Utils::ToLocal(env));
+}
+
+
+Local<Context> v8::Context::New(
+ v8::Isolate* external_isolate,
+ v8::ExtensionConfiguration* extensions,
+ v8::Handle<ObjectTemplate> global_template,
+ v8::Handle<Value> global_object) {
+ i::Isolate::EnsureDefaultIsolate();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
+ EnsureInitializedForIsolate(isolate, "v8::Context::New()");
+ LOG_API(isolate, "Context::New");
+ ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>());
+ i::HandleScope scope(isolate);
+ i::Handle<i::Context> env =
+ CreateEnvironment(isolate, extensions, global_template, global_object);
+ if (env.is_null()) return Local<Context>();
+ return Utils::ToLocal(scope.CloseAndEscape(env));
}
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698