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

Side by Side Diff: src/bootstrapper.h

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/arm/codegen-arm.cc ('k') | src/bootstrapper.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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 28
29 #ifndef V8_BOOTSTRAPPER_H_ 29 #ifndef V8_BOOTSTRAPPER_H_
30 #define V8_BOOTSTRAPPER_H_ 30 #define V8_BOOTSTRAPPER_H_
31 31
32 namespace v8 { 32 namespace v8 {
33 namespace internal { 33 namespace internal {
34 34
35 35
36 class BootstrapperActive BASE_EMBEDDED {
37 public:
38 BootstrapperActive() { nesting_++; }
39 ~BootstrapperActive() { nesting_--; }
40
41 // Support for thread preemption.
42 static int ArchiveSpacePerThread();
43 static char* ArchiveState(char* to);
44 static char* RestoreState(char* from);
45
46 private:
47 static bool IsActive() { return nesting_ != 0; }
48 static int nesting_;
49 friend class Bootstrapper;
50 };
51
52
53 // The Boostrapper is the public interface for creating a JavaScript global 36 // The Boostrapper is the public interface for creating a JavaScript global
54 // context. 37 // context.
55 class Bootstrapper { 38 class Bootstrapper {
56 public: 39 public:
57 // Requires: Heap::Setup has been called. 40 // Requires: Heap::Setup has been called.
58 void Initialize(bool create_heap_objects); 41 void Initialize(bool create_heap_objects);
59 void TearDown(); 42 void TearDown();
60 43
61 // Creates a JavaScript Global Context with initial object graph. 44 // Creates a JavaScript Global Context with initial object graph.
62 // The returned value is a global handle casted to V8Environment*. 45 // The returned value is a global handle casted to V8Environment*.
63 Handle<Context> CreateEnvironment( 46 Handle<Context> CreateEnvironment(
64 Handle<Object> global_object, 47 Handle<Object> global_object,
65 v8::Handle<v8::ObjectTemplate> global_template, 48 v8::Handle<v8::ObjectTemplate> global_template,
66 v8::ExtensionConfiguration* extensions); 49 v8::ExtensionConfiguration* extensions);
67 50
68 // Detach the environment from its outer global object. 51 // Detach the environment from its outer global object.
69 void DetachGlobal(Handle<Context> env); 52 void DetachGlobal(Handle<Context> env);
70 53
71 // Reattach an outer global object to an environment. 54 // Reattach an outer global object to an environment.
72 void ReattachGlobal(Handle<Context> env, Handle<Object> global_object); 55 void ReattachGlobal(Handle<Context> env, Handle<Object> global_object);
73 56
74 // Traverses the pointers for memory management. 57 // Traverses the pointers for memory management.
75 void Iterate(ObjectVisitor* v); 58 void Iterate(ObjectVisitor* v);
76 59
77 // Accessor for the native scripts source code. 60 // Accessor for the native scripts source code.
78 static Handle<String> NativesSourceLookup(int index); 61 static Handle<String> NativesSourceLookup(int index);
79 62
80 // Tells whether bootstrapping is active. 63 // Tells whether bootstrapping is active.
81 static bool IsActive() { return BootstrapperActive::IsActive(); } 64 bool IsActive() const { return nesting_ != 0; }
82 65
83 // Support for thread preemption. 66 // Support for thread preemption.
84 RLYSTC int ArchiveSpacePerThread(); 67 RLYSTC int ArchiveSpacePerThread();
85 char* ArchiveState(char* to); 68 char* ArchiveState(char* to);
86 char* RestoreState(char* from); 69 char* RestoreState(char* from);
87 void FreeThreadResources(); 70 void FreeThreadResources();
88 71
89 // This will allocate a char array that is deleted when V8 is shut down. 72 // This will allocate a char array that is deleted when V8 is shut down.
90 // It should only be used for strictly finite allocations. 73 // It should only be used for strictly finite allocations.
91 static char* AllocateAutoDeletedArray(int bytes); 74 static char* AllocateAutoDeletedArray(int bytes);
92 75
93 // Used for new context creation. 76 // Used for new context creation.
94 bool InstallExtensions(Handle<Context> global_context, 77 bool InstallExtensions(Handle<Context> global_context,
95 v8::ExtensionConfiguration* extensions); 78 v8::ExtensionConfiguration* extensions);
96 79
97 private: 80 private:
81 typedef int NestingCounterType;
82 NestingCounterType nesting_;
83
84 friend class BootstrapperActive;
98 friend class Isolate; 85 friend class Isolate;
86
99 Bootstrapper(); 87 Bootstrapper();
100 88
101 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); 89 DISALLOW_COPY_AND_ASSIGN(Bootstrapper);
102 }; 90 };
103 91
104 92
93 class BootstrapperActive BASE_EMBEDDED {
94 public:
95 BootstrapperActive() {
96 ++Isolate::Current()->bootstrapper()->nesting_;
97 }
98
99 ~BootstrapperActive() {
100 --Isolate::Current()->bootstrapper()->nesting_;
101 }
102
103 private:
104 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive);
105 };
106
107
105 class NativesExternalStringResource 108 class NativesExternalStringResource
106 : public v8::String::ExternalAsciiStringResource { 109 : public v8::String::ExternalAsciiStringResource {
107 public: 110 public:
108 explicit NativesExternalStringResource(const char* source); 111 explicit NativesExternalStringResource(const char* source);
109 112
110 const char* data() const { 113 const char* data() const {
111 return data_; 114 return data_;
112 } 115 }
113 116
114 size_t length() const { 117 size_t length() const {
115 return length_; 118 return length_;
116 } 119 }
117 private: 120 private:
118 const char* data_; 121 const char* data_;
119 size_t length_; 122 size_t length_;
120 }; 123 };
121 124
122 }} // namespace v8::internal 125 }} // namespace v8::internal
123 126
124 #endif // V8_BOOTSTRAPPER_H_ 127 #endif // V8_BOOTSTRAPPER_H_
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698