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

Side by Side Diff: src/bootstrapper.cc

Issue 2861017: [Isolates] Make statics from BootstrapperActive to be instance members (Closed)
Patch Set: Created 10 years, 6 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
« no previous file with comments | « src/bootstrapper.h ('k') | src/codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (delete_these_non_arrays_on_tear_down == NULL) { 104 if (delete_these_non_arrays_on_tear_down == NULL) {
105 delete_these_non_arrays_on_tear_down = new List<char*>(2); 105 delete_these_non_arrays_on_tear_down = new List<char*>(2);
106 } 106 }
107 // The resources are small objects and we only make a fixed number of 107 // The resources are small objects and we only make a fixed number of
108 // them, but let's clean them up on exit for neatness. 108 // them, but let's clean them up on exit for neatness.
109 delete_these_non_arrays_on_tear_down-> 109 delete_these_non_arrays_on_tear_down->
110 Add(reinterpret_cast<char*>(this)); 110 Add(reinterpret_cast<char*>(this));
111 } 111 }
112 112
113 113
114 Bootstrapper::Bootstrapper() { 114 Bootstrapper::Bootstrapper()
115 : nesting_(0) {
115 } 116 }
116 117
117 118
118 Handle<String> Bootstrapper::NativesSourceLookup(int index) { 119 Handle<String> Bootstrapper::NativesSourceLookup(int index) {
119 ASSERT(0 <= index && index < Natives::GetBuiltinsCount()); 120 ASSERT(0 <= index && index < Natives::GetBuiltinsCount());
120 if (HEAP->natives_source_cache()->get(index)->IsUndefined()) { 121 if (HEAP->natives_source_cache()->get(index)->IsUndefined()) {
121 if (!Snapshot::IsEnabled() || FLAG_new_snapshot) { 122 if (!Snapshot::IsEnabled() || FLAG_new_snapshot) {
122 // We can use external strings for the natives. 123 // We can use external strings for the natives.
123 NativesExternalStringResource* resource = 124 NativesExternalStringResource* resource =
124 new NativesExternalStringResource( 125 new NativesExternalStringResource(
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 1392
1392 int index = 0; 1393 int index = 0;
1393 #define F(size, func) caches->set(index++, CreateCache(size, func)); 1394 #define F(size, func) caches->set(index++, CreateCache(size, func));
1394 JSFUNCTION_RESULT_CACHE_LIST(F) 1395 JSFUNCTION_RESULT_CACHE_LIST(F)
1395 #undef F 1396 #undef F
1396 1397
1397 global_context()->set_jsfunction_result_caches(*caches); 1398 global_context()->set_jsfunction_result_caches(*caches);
1398 } 1399 }
1399 1400
1400 1401
1401 int BootstrapperActive::nesting_ = 0;
1402
1403
1404 bool Bootstrapper::InstallExtensions(Handle<Context> global_context, 1402 bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
1405 v8::ExtensionConfiguration* extensions) { 1403 v8::ExtensionConfiguration* extensions) {
1406 BootstrapperActive active; 1404 BootstrapperActive active;
1407 SaveContext saved_context; 1405 SaveContext saved_context;
1408 Isolate::Current()->set_context(*global_context); 1406 Isolate::Current()->set_context(*global_context);
1409 if (!Genesis::InstallExtensions(global_context, extensions)) return false; 1407 if (!Genesis::InstallExtensions(global_context, extensions)) return false;
1410 Genesis::InstallSpecialObjects(global_context); 1408 Genesis::InstallSpecialObjects(global_context);
1411 return true; 1409 return true;
1412 } 1410 }
1413 1411
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 } 1772 }
1775 1773
1776 result_ = global_context_; 1774 result_ = global_context_;
1777 } 1775 }
1778 1776
1779 1777
1780 // Support for thread preemption. 1778 // Support for thread preemption.
1781 1779
1782 // Reserve space for statics needing saving and restoring. 1780 // Reserve space for statics needing saving and restoring.
1783 int Bootstrapper::ArchiveSpacePerThread() { 1781 int Bootstrapper::ArchiveSpacePerThread() {
1784 return BootstrapperActive::ArchiveSpacePerThread(); 1782 return sizeof(NestingCounterType);
1785 } 1783 }
1786 1784
1787 1785
1788 // Archive statics that are thread local. 1786 // Archive statics that are thread local.
1789 char* Bootstrapper::ArchiveState(char* to) { 1787 char* Bootstrapper::ArchiveState(char* to) {
1790 return BootstrapperActive::ArchiveState(to); 1788 *reinterpret_cast<NestingCounterType*>(to) = nesting_;
1789 nesting_ = 0;
1790 return to + sizeof(NestingCounterType);
1791 } 1791 }
1792 1792
1793 1793
1794 // Restore statics that are thread local. 1794 // Restore statics that are thread local.
1795 char* Bootstrapper::RestoreState(char* from) { 1795 char* Bootstrapper::RestoreState(char* from) {
1796 return BootstrapperActive::RestoreState(from); 1796 nesting_ = *reinterpret_cast<NestingCounterType*>(from);
1797 return from + sizeof(NestingCounterType);
1797 } 1798 }
1798 1799
1799 1800
1800 // Called when the top-level V8 mutex is destroyed. 1801 // Called when the top-level V8 mutex is destroyed.
1801 void Bootstrapper::FreeThreadResources() { 1802 void Bootstrapper::FreeThreadResources() {
1802 ASSERT(!BootstrapperActive::IsActive()); 1803 ASSERT(!IsActive());
1803 }
1804
1805
1806 // Reserve space for statics needing saving and restoring.
1807 int BootstrapperActive::ArchiveSpacePerThread() {
1808 return sizeof(nesting_);
1809 }
1810
1811
1812 // Archive statics that are thread local.
1813 char* BootstrapperActive::ArchiveState(char* to) {
1814 *reinterpret_cast<int*>(to) = nesting_;
1815 nesting_ = 0;
1816 return to + sizeof(nesting_);
1817 }
1818
1819
1820 // Restore statics that are thread local.
1821 char* BootstrapperActive::RestoreState(char* from) {
1822 nesting_ = *reinterpret_cast<int*>(from);
1823 return from + sizeof(nesting_);
1824 } 1804 }
1825 1805
1826 } } // namespace v8::internal 1806 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698