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

Unified Diff: src/api.cc

Issue 573018: * Generate contexts involving extensions using partial snapshots. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 11 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.h » ('j') | src/bootstrapper.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 3800)
+++ src/api.cc (working copy)
@@ -2734,44 +2734,42 @@
}
-Persistent<Context> v8::Context::New() {
+Persistent<Context> v8::Context::New(
+ v8::ExtensionConfiguration* extensions,
+ v8::Handle<ObjectTemplate> global_template,
+ v8::Handle<Value> global_object) {
EnsureInitialized("v8::Context::New()");
LOG_API("Context::New");
ON_BAILOUT("v8::Context::New()", return Persistent<Context>());
- if (i::Bootstrapper::AutoExtensionsExist()) {
- return New(0);
- }
-
- // Enter V8 via an ENTER_V8 scope.
- Persistent<Context> result;
- {
- ENTER_V8;
- HandleScope scope;
+ // Handle the simple cases with partial snapshot deserialization.
+ if (global_template.IsEmpty() && global_object.IsEmpty()) {
+ // Enter V8 via an ENTER_V8 scope.
+ Persistent<Context> result;
+ {
+ ENTER_V8;
+ HandleScope scope;
#if defined(ANDROID)
- // On mobile device, full GC is expensive, leave it to the system to
- // decide when should make a full GC.
+ // On mobile device, full GC is expensive, leave it to the system to
+ // decide when should make a full GC.
#else
- // Give the heap a chance to cleanup if we've disposed contexts.
- i::Heap::CollectAllGarbageIfContextDisposed();
+ // Give the heap a chance to cleanup if we've disposed contexts.
+ i::Heap::CollectAllGarbageIfContextDisposed();
#endif
- i::Handle<i::Context> env = i::Snapshot::NewContextFromSnapshot();
- if (env.is_null()) {
- return New(0);
+ i::Handle<i::Context> env = i::Snapshot::NewContextFromSnapshot();
+ if (!env.is_null()) {
+ if (i::Bootstrapper::InstallExtensions(env, extensions)) {
+ i::Counters::contexts_created_by_snapshot.Increment();
+ return Persistent<Context>::New(Utils::ToLocal(env));
+ } else {
+ return Persistent<Context>();
+ }
+ }
+ // If there was no snapshot built into the VM then we fall through to the
+ // slow new context builder.
}
- i::Counters::contexts_created_by_snapshot.Increment();
- return Persistent<Context>::New(Utils::ToLocal(env));
}
-}
-
-Persistent<Context> v8::Context::New(
- v8::ExtensionConfiguration* extensions,
- v8::Handle<ObjectTemplate> global_template,
- v8::Handle<Value> global_object) {
- EnsureInitialized("v8::Context::New()");
- LOG_API("Context::New");
- ON_BAILOUT("v8::Context::New()", return Persistent<Context>());
i::Counters::contexts_created_from_scratch.Increment();
// Enter V8 via an ENTER_V8 scope.
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.h » ('j') | src/bootstrapper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698