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

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

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-global-context.h ('k') | src/v8threads.h » ('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 #include "v8.h"
29 #include "allocation.h"
30 #include "api.h"
31 #include "bootstrapper.h"
32 #include "compilation-cache.h"
33 #include "compiler.h"
34 #include "debug.h"
35 #include "disassembler.h"
36 #include "execution.h"
37 #include "global-handles.h"
38 #include "jump-target.h"
39 #include "mark-compact.h"
40 #include "objects.h"
41 #include "regexp-stack.h"
42 #include "scanner.h"
43 #include "scopeinfo.h"
44 #include "serialize.h"
45 #include "stub-cache.h"
46 #include "top.h"
47 #include "v8threads.h"
48
49 namespace v8 {
50
51 internal::Thread::LocalStorageKey context_key =
52 internal::Thread::CreateThreadLocalKey();
53
54 internal::V8Context* default_context;
55 internal::V8Context v8context;
56 V8ContextBinder default_context_binder(&v8context, true);
57 bool using_one_v8_instance = true;
58
59 AllowSeveralV8InstancesInProcess::AllowSeveralV8InstancesInProcess() {
60 using_one_v8_instance = false;
61 }
62
63 AllowSeveralV8InstancesInProcess::~AllowSeveralV8InstancesInProcess() {
64 }
65
66 void BindContext(internal::V8Context* context,
67 bool bind_default = using_one_v8_instance) {
68 if (bind_default) {
69 default_context = context;
70 } else {
71 ASSERT(v8_context() != context);
72 internal::Thread::SetThreadLocal(context_key, context);
73 }
74 }
75
76 V8ContextProvider::V8ContextProvider()
77 :v8context_(new internal::V8Context()) {
78 }
79
80 V8ContextProvider::~V8ContextProvider() { delete v8context_; }
81
82 V8ContextBinder::V8ContextBinder(internal::V8Context* v8context,
83 bool bind_default)
84 :v8context_(v8context), bound_default_(bind_default) {
85 BindContext(v8context_, bind_default);
86 }
87
88 V8ContextBinder::~V8ContextBinder() {
89 BindContext(NULL, bound_default_);
90 }
91
92 internal::V8Context::V8Context()
93 :thread_manager_data_(*new ThreadManagerData()),
94 heap_data_(*new HeapData()),
95 v8_data_(*new V8Data()),
96 transcendental_cache_data_(*new TranscendentalCacheData()),
97 descriptor_lookup_cache_data_(*new DescriptorLookupCacheData()),
98 keyed_lookup_cache_data_(*new KeyedLookupCacheData()),
99 stack_guard_data_(*new StackGuardData()),
100 top_data_(*new TopData()),
101 reg_exp_stack_data_(*new RegExpStackData()),
102 serializer_data_(*new SerializerData()),
103 context_slot_cache_data_(*new ContextSlotCacheData()),
104 handle_scope_implementer_(*new HandleScopeImplementer()),
105 handle_scope_data_(*new ImplementationUtilities::HandleScopeData()),
106 stub_cache_data_(*new StubCacheData()),
107 compilation_cache_data_(*new CompilationCacheData()),
108 global_handles_data_(*new GlobalHandlesData()),
109 memory_allocator_data_(*new MemoryAllocatorData()),
110 code_range_data_(*new CodeRangeData()),
111 mark_compact_collector_data_(*new MarkCompactCollectorData()),
112 relocatable_data_(*new RelocatableData()),
113 code_generator_data_(*new CodeGeneratorData()),
114 bootstrapper_data_(*new BootstrapperData()),
115 compiler_data_(*new CompilerData()),
116 scanner_data_(*new ScannerData()),
117 storage_data_(*new StorageData()),
118 builtins_data_(*new BuiltinsData()),
119 api_data_(*new ApiData()),
120 objects_data_(*new ObjectsData()),
121 stats_table_data_(*new StatsTableData()),
122 runtime_data_(NULL),
123 assembler_data_(NULL),
124 counters_(*new Counters()),
125 logger_data_(*new LoggerData()),
126 log_data_(*new LogData()),
127 #ifdef ENABLE_DEBUGGER_SUPPORT
128 debugger_data_(*new DebuggerData()),
129 debug_data_(*new DebugData()),
130 #endif
131 zone_data_(*new ZoneData()) {
132 handle_scope_data_.Initialize();
133 // explicitly bind during construction
134 V8Context* const prev_v8_context = v8_context();
135 BindContext(this);
136
137 StackGuard::PostConstruct();
138 Top::PostConstruct();
139 Runtime::PostConstruct();
140 Assembler::PostConstruct();
141
142 #ifdef ENABLE_DISASSEMBLER
143 Disassembler::PostConstruct();
144 #endif
145
146 BindContext(prev_v8_context);
147 }
148
149 internal::V8Context::~V8Context() {
150 // explicitly bind during destruction
151 BindContext(this);
152
153 internal::ThreadManager::FreeThreadResources();
154 Top::PreDestroy();
155 StackGuard::PreDestroy();
156
157 Runtime::PreDestroy();
158 Assembler::PreDestroy();
159 #ifdef ENABLE_DISASSEMBLER
160 Disassembler::PreDestroy();
161 #endif
162
163 delete &thread_manager_data_;
164 delete &v8_data_;
165 delete &heap_data_;
166 delete &transcendental_cache_data_;
167 delete &descriptor_lookup_cache_data_;
168 delete &keyed_lookup_cache_data_;
169 delete &zone_data_;
170 delete &top_data_;
171 delete &stack_guard_data_;
172 delete &reg_exp_stack_data_;
173 delete &serializer_data_;
174 delete &context_slot_cache_data_;
175 delete &handle_scope_implementer_;
176 delete &handle_scope_data_;
177 delete &stub_cache_data_;
178 delete &compilation_cache_data_;
179 delete &global_handles_data_;
180 delete &memory_allocator_data_;
181 delete &code_range_data_;
182 delete &mark_compact_collector_data_;
183 delete &relocatable_data_;
184 delete &code_generator_data_;
185 delete &bootstrapper_data_;
186 delete &scanner_data_;
187 delete &compiler_data_;
188 delete &storage_data_;
189 delete &stats_table_data_;
190 delete &api_data_;
191 delete &objects_data_;
192 delete &builtins_data_;
193 delete &counters_;
194 delete &logger_data_;
195 delete &log_data_;
196
197 #ifdef ENABLE_DEBUGGER_SUPPORT
198 delete &debugger_data_;
199 delete &debug_data_;
200 #endif
201 BindContext(NULL);
202 }
203 }
204
OLDNEW
« no previous file with comments | « src/v8-global-context.h ('k') | src/v8threads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698