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

Side by Side 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, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 if (templ->constructor()->IsUndefined()) { 2727 if (templ->constructor()->IsUndefined()) {
2728 Local<FunctionTemplate> constructor = FunctionTemplate::New(); 2728 Local<FunctionTemplate> constructor = FunctionTemplate::New();
2729 Utils::OpenHandle(*constructor)->set_instance_template(*templ); 2729 Utils::OpenHandle(*constructor)->set_instance_template(*templ);
2730 templ->set_constructor(*Utils::OpenHandle(*constructor)); 2730 templ->set_constructor(*Utils::OpenHandle(*constructor));
2731 } 2731 }
2732 return i::Handle<i::FunctionTemplateInfo>( 2732 return i::Handle<i::FunctionTemplateInfo>(
2733 i::FunctionTemplateInfo::cast(templ->constructor())); 2733 i::FunctionTemplateInfo::cast(templ->constructor()));
2734 } 2734 }
2735 2735
2736 2736
2737 Persistent<Context> v8::Context::New() {
2738 EnsureInitialized("v8::Context::New()");
2739 LOG_API("Context::New");
2740 ON_BAILOUT("v8::Context::New()", return Persistent<Context>());
2741
2742 if (i::Bootstrapper::AutoExtensionsExist()) {
2743 return New(0);
2744 }
2745
2746 // Enter V8 via an ENTER_V8 scope.
2747 Persistent<Context> result;
2748 {
2749 ENTER_V8;
2750 HandleScope scope;
2751 #if defined(ANDROID)
2752 // On mobile device, full GC is expensive, leave it to the system to
2753 // decide when should make a full GC.
2754 #else
2755 // Give the heap a chance to cleanup if we've disposed contexts.
2756 i::Heap::CollectAllGarbageIfContextDisposed();
2757 #endif
2758 i::Handle<i::Context> env = i::Snapshot::NewContextFromSnapshot();
2759 if (env.is_null()) {
2760 return New(0);
2761 }
2762 i::Counters::contexts_created_by_snapshot.Increment();
2763 return Persistent<Context>::New(Utils::ToLocal(env));
2764 }
2765 }
2766
2767
2768 Persistent<Context> v8::Context::New( 2737 Persistent<Context> v8::Context::New(
2769 v8::ExtensionConfiguration* extensions, 2738 v8::ExtensionConfiguration* extensions,
2770 v8::Handle<ObjectTemplate> global_template, 2739 v8::Handle<ObjectTemplate> global_template,
2771 v8::Handle<Value> global_object) { 2740 v8::Handle<Value> global_object) {
2772 EnsureInitialized("v8::Context::New()"); 2741 EnsureInitialized("v8::Context::New()");
2773 LOG_API("Context::New"); 2742 LOG_API("Context::New");
2774 ON_BAILOUT("v8::Context::New()", return Persistent<Context>()); 2743 ON_BAILOUT("v8::Context::New()", return Persistent<Context>());
2744
2745 // Handle the simple cases with partial snapshot deserialization.
2746 if (global_template.IsEmpty() && global_object.IsEmpty()) {
2747 // Enter V8 via an ENTER_V8 scope.
2748 Persistent<Context> result;
2749 {
2750 ENTER_V8;
2751 HandleScope scope;
2752 #if defined(ANDROID)
2753 // On mobile device, full GC is expensive, leave it to the system to
2754 // decide when should make a full GC.
2755 #else
2756 // Give the heap a chance to cleanup if we've disposed contexts.
2757 i::Heap::CollectAllGarbageIfContextDisposed();
2758 #endif
2759 i::Handle<i::Context> env = i::Snapshot::NewContextFromSnapshot();
2760 if (!env.is_null()) {
2761 if (i::Bootstrapper::InstallExtensions(env, extensions)) {
2762 i::Counters::contexts_created_by_snapshot.Increment();
2763 return Persistent<Context>::New(Utils::ToLocal(env));
2764 } else {
2765 return Persistent<Context>();
2766 }
2767 }
2768 // If there was no snapshot built into the VM then we fall through to the
2769 // slow new context builder.
2770 }
2771 }
2772
2775 i::Counters::contexts_created_from_scratch.Increment(); 2773 i::Counters::contexts_created_from_scratch.Increment();
2776 2774
2777 // Enter V8 via an ENTER_V8 scope. 2775 // Enter V8 via an ENTER_V8 scope.
2778 i::Handle<i::Context> env; 2776 i::Handle<i::Context> env;
2779 { 2777 {
2780 ENTER_V8; 2778 ENTER_V8;
2781 #if defined(ANDROID) 2779 #if defined(ANDROID)
2782 // On mobile device, full GC is expensive, leave it to the system to 2780 // On mobile device, full GC is expensive, leave it to the system to
2783 // decide when should make a full GC. 2781 // decide when should make a full GC.
2784 #else 2782 #else
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
3861 3859
3862 3860
3863 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3861 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3864 HandleScopeImplementer* thread_local = 3862 HandleScopeImplementer* thread_local =
3865 reinterpret_cast<HandleScopeImplementer*>(storage); 3863 reinterpret_cast<HandleScopeImplementer*>(storage);
3866 thread_local->IterateThis(v); 3864 thread_local->IterateThis(v);
3867 return storage + ArchiveSpacePerThread(); 3865 return storage + ArchiveSpacePerThread();
3868 } 3866 }
3869 3867
3870 } } // namespace v8::internal 3868 } } // namespace v8::internal
OLDNEW
« 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