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

Side by Side Diff: src/v8-global-context.h

Issue 435003: Patch for allowing several V8 instances in process:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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
« no previous file with comments | « src/v8-counters.cc ('k') | src/v8-global-context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_GLOBAL_CONTEXT_H_
29 #define V8_GLOBAL_CONTEXT_H_
30 #include "apiutils.h"
31 #include "utils.h"
32 #include "platform.h"
33
34 namespace disasm {
35 class DisassemblerData;
36 }
37
38 namespace v8 {
39
40 namespace internal {
41 class HeapData;
42 class ThreadManagerData;
43 class V8Data;
44 class TranscendentalCacheData;
45 class DescriptorLookupCacheData;
46 class KeyedLookupCacheData;
47 class ZoneData;
48 class TopData;
49 class StackGuardData;
50 class RegExpStackData;
51 class SerializerData;
52 class ContextSlotCacheData;
53 class HandleScopeImplementer;
54 class StubCacheData;
55 class CompilationCacheData;
56 class GlobalHandlesData;
57 class MemoryAllocatorData;
58 class CodeRangeData;
59 class MarkCompactCollectorData;
60 class RelocatableData;
61 class CodeGeneratorData;
62 class BootstrapperData;
63 class ScannerData;
64 class CompilerData;
65 class StorageData;
66 class StatsTableData;
67 class RuntimeData;
68 class AssemblerData;
69 class ApiData;
70 class ObjectsData;
71 class BuiltinsData;
72 class Counters;
73 class LoggerData;
74 class LogData;
75 #ifdef ENABLE_DEBUGGER_SUPPORT
76 class DebugData;
77 class DebuggerData;
78 #endif
79
80
81 class V8Context {
82 public:
83 ThreadManagerData& thread_manager_data_;
84 V8Data& v8_data_;
85 HeapData& heap_data_;
86 TranscendentalCacheData& transcendental_cache_data_;
87 DescriptorLookupCacheData& descriptor_lookup_cache_data_;
88 KeyedLookupCacheData& keyed_lookup_cache_data_;
89 ZoneData& zone_data_;
90 TopData& top_data_;
91 StackGuardData& stack_guard_data_;
92 RegExpStackData& reg_exp_stack_data_;
93 SerializerData& serializer_data_;
94 ContextSlotCacheData& context_slot_cache_data_;
95 HandleScopeImplementer& handle_scope_implementer_;
96 ImplementationUtilities::HandleScopeData& handle_scope_data_;
97 StubCacheData& stub_cache_data_;
98 CompilationCacheData& compilation_cache_data_;
99 GlobalHandlesData& global_handles_data_;
100 MemoryAllocatorData& memory_allocator_data_;
101 CodeRangeData& code_range_data_;
102 MarkCompactCollectorData& mark_compact_collector_data_;
103 RelocatableData& relocatable_data_;
104 CodeGeneratorData& code_generator_data_;
105 BootstrapperData& bootstrapper_data_;
106 CompilerData& compiler_data_;
107 ScannerData& scanner_data_;
108 StorageData& storage_data_;
109 StatsTableData& stats_table_data_;
110 RuntimeData* runtime_data_;
111 AssemblerData* assembler_data_;
112 ApiData& api_data_;
113 ObjectsData& objects_data_;
114 BuiltinsData& builtins_data_;
115 Counters& counters_;
116 LoggerData& logger_data_;
117 LogData& log_data_;
118
119 // #ifdef ENABLE_DISASSEMBLER
120 disasm::DisassemblerData* disassembler_data_;
121 // #endif
122
123 #ifdef ENABLE_DEBUGGER_SUPPORT
124 DebugData& debug_data_;
125 DebuggerData& debugger_data_;
126 #endif
127
128
129 V8Context();
130 ~V8Context();
131 private:
132 DISALLOW_COPY_AND_ASSIGN(V8Context);
133 };
134 }
135
136 extern internal::V8Context* default_context;
137 extern bool using_one_v8_instance;
138 extern internal::Thread::LocalStorageKey context_key;
139
140 inline internal::V8Context* v8_context() {
141 if (using_one_v8_instance) return default_context;
142 internal::V8Context* v8context = reinterpret_cast<internal::V8Context*>(
143 internal::Thread::GetThreadLocal(context_key));
144 if (v8context == NULL) v8context = default_context;
145 return v8context;
146 }
147
148 template<class LockType>
149 class V8ResourceLocker {
150 LockType* lock_;
151 bool locked_;
152 public:
153 explicit V8ResourceLocker(LockType* lock)
154 :locked_(false), lock_(lock) {
155 if (!using_one_v8_instance) {
156 lock_->Lock();
157 locked_ = true;
158 }
159 }
160
161 ~V8ResourceLocker() {
162 if (locked_) lock_->Unlock();
163 }
164 };
165
166 class MutexLockAdapter {
167 internal::Mutex* mutex_;
168 public:
169 explicit MutexLockAdapter(internal::Mutex *mutex):mutex_(mutex) {}
170
171 void Lock() {
172 mutex_->Lock();
173 }
174
175 void Unlock() {
176 mutex_->Unlock();
177 }
178 };
179
180 typedef V8ResourceLocker<MutexLockAdapter> V8SharedStateLocker;
181 }
182 #endif // V8_GLOBAL_CONTEXT_H_
183
OLDNEW
« no previous file with comments | « src/v8-counters.cc ('k') | src/v8-global-context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698