OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "assembler.h" | 30 #include "assembler.h" |
31 #include "isolate.h" | 31 #include "isolate.h" |
32 #include "elements.h" | 32 #include "elements.h" |
33 #include "bootstrapper.h" | 33 #include "bootstrapper.h" |
34 #include "debug.h" | 34 #include "debug.h" |
| 35 #ifdef V8_USE_DEFAULT_PLATFORM |
| 36 #include "default-platform.h" |
| 37 #endif |
35 #include "deoptimizer.h" | 38 #include "deoptimizer.h" |
36 #include "frames.h" | 39 #include "frames.h" |
37 #include "heap-profiler.h" | 40 #include "heap-profiler.h" |
38 #include "hydrogen.h" | 41 #include "hydrogen.h" |
39 #include "lithium-allocator.h" | 42 #include "lithium-allocator.h" |
40 #include "objects.h" | 43 #include "objects.h" |
41 #include "once.h" | 44 #include "once.h" |
42 #include "platform.h" | 45 #include "platform.h" |
43 #include "sampler.h" | 46 #include "sampler.h" |
44 #include "runtime-profiler.h" | 47 #include "runtime-profiler.h" |
45 #include "serialize.h" | 48 #include "serialize.h" |
46 #include "store-buffer.h" | 49 #include "store-buffer.h" |
47 | 50 |
48 namespace v8 { | 51 namespace v8 { |
49 namespace internal { | 52 namespace internal { |
50 | 53 |
51 V8_DECLARE_ONCE(init_once); | 54 V8_DECLARE_ONCE(init_once); |
52 | 55 |
53 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; | 56 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; |
54 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; | 57 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; |
| 58 v8::Platform* V8::platform_ = NULL; |
55 | 59 |
56 | 60 |
57 bool V8::Initialize(Deserializer* des) { | 61 bool V8::Initialize(Deserializer* des) { |
58 InitializeOncePerProcess(); | 62 InitializeOncePerProcess(); |
59 | 63 |
60 // The current thread may not yet had entered an isolate to run. | 64 // The current thread may not yet had entered an isolate to run. |
61 // Note the Isolate::Current() may be non-null because for various | 65 // Note the Isolate::Current() may be non-null because for various |
62 // initialization purposes an initializing thread may be assigned an isolate | 66 // initialization purposes an initializing thread may be assigned an isolate |
63 // but not actually enter it. | 67 // but not actually enter it. |
64 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | 68 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { |
(...skipping 28 matching lines...) Expand all Loading... |
93 ElementsAccessor::TearDown(); | 97 ElementsAccessor::TearDown(); |
94 LOperand::TearDownCaches(); | 98 LOperand::TearDownCaches(); |
95 ExternalReference::TearDownMathExpData(); | 99 ExternalReference::TearDownMathExpData(); |
96 RegisteredExtension::UnregisterAll(); | 100 RegisteredExtension::UnregisterAll(); |
97 Isolate::GlobalTearDown(); | 101 Isolate::GlobalTearDown(); |
98 | 102 |
99 delete call_completed_callbacks_; | 103 delete call_completed_callbacks_; |
100 call_completed_callbacks_ = NULL; | 104 call_completed_callbacks_ = NULL; |
101 | 105 |
102 Sampler::TearDown(); | 106 Sampler::TearDown(); |
| 107 |
| 108 #ifdef V8_USE_DEFAULT_PLATFORM |
| 109 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); |
| 110 platform_ = NULL; |
| 111 delete platform; |
| 112 #endif |
103 } | 113 } |
104 | 114 |
105 | 115 |
106 void V8::SetReturnAddressLocationResolver( | 116 void V8::SetReturnAddressLocationResolver( |
107 ReturnAddressLocationResolver resolver) { | 117 ReturnAddressLocationResolver resolver) { |
108 StackFrame::SetReturnAddressLocationResolver(resolver); | 118 StackFrame::SetReturnAddressLocationResolver(resolver); |
109 } | 119 } |
110 | 120 |
111 | 121 |
112 // Used by JavaScript APIs | 122 // Used by JavaScript APIs |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 182 |
173 | 183 |
174 void V8::InitializeOncePerProcessImpl() { | 184 void V8::InitializeOncePerProcessImpl() { |
175 FlagList::EnforceFlagImplications(); | 185 FlagList::EnforceFlagImplications(); |
176 if (FLAG_stress_compaction) { | 186 if (FLAG_stress_compaction) { |
177 FLAG_force_marking_deque_overflows = true; | 187 FLAG_force_marking_deque_overflows = true; |
178 FLAG_gc_global = true; | 188 FLAG_gc_global = true; |
179 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; | 189 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; |
180 } | 190 } |
181 | 191 |
| 192 #ifdef V8_USE_DEFAULT_PLATFORM |
| 193 platform_ = new DefaultPlatform; |
| 194 #endif |
182 Sampler::SetUp(); | 195 Sampler::SetUp(); |
183 CPU::SetUp(); | 196 CPU::SetUp(); |
184 OS::PostSetUp(); | 197 OS::PostSetUp(); |
185 ElementsAccessor::InitializeOncePerProcess(); | 198 ElementsAccessor::InitializeOncePerProcess(); |
186 LOperand::SetUpCaches(); | 199 LOperand::SetUpCaches(); |
187 SetUpJSCallerSavedCodeData(); | 200 SetUpJSCallerSavedCodeData(); |
188 ExternalReference::SetUp(); | 201 ExternalReference::SetUp(); |
189 Bootstrapper::InitializeOncePerProcess(); | 202 Bootstrapper::InitializeOncePerProcess(); |
190 } | 203 } |
191 | 204 |
192 | 205 |
193 void V8::InitializeOncePerProcess() { | 206 void V8::InitializeOncePerProcess() { |
194 CallOnce(&init_once, &InitializeOncePerProcessImpl); | 207 CallOnce(&init_once, &InitializeOncePerProcessImpl); |
195 } | 208 } |
196 | 209 |
| 210 |
| 211 void V8::InitializePlatform(v8::Platform* platform) { |
| 212 ASSERT(!platform_); |
| 213 ASSERT(platform); |
| 214 platform_ = platform; |
| 215 } |
| 216 |
| 217 |
| 218 void V8::ShutdownPlatform() { |
| 219 ASSERT(platform_); |
| 220 platform_ = NULL; |
| 221 } |
| 222 |
| 223 |
| 224 v8::Platform* V8::GetCurrentPlatform() { |
| 225 ASSERT(platform_); |
| 226 return platform_; |
| 227 } |
| 228 |
197 } } // namespace v8::internal | 229 } } // namespace v8::internal |
OLD | NEW |