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

Side by Side Diff: src/v8.cc

Issue 9666052: Landing for pliard@chromium.org: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/v8.h ('k') | src/x64/assembler-x64.h » ('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 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 18 matching lines...) Expand all
29 29
30 #include "isolate.h" 30 #include "isolate.h"
31 #include "elements.h" 31 #include "elements.h"
32 #include "bootstrapper.h" 32 #include "bootstrapper.h"
33 #include "debug.h" 33 #include "debug.h"
34 #include "deoptimizer.h" 34 #include "deoptimizer.h"
35 #include "heap-profiler.h" 35 #include "heap-profiler.h"
36 #include "hydrogen.h" 36 #include "hydrogen.h"
37 #include "lithium-allocator.h" 37 #include "lithium-allocator.h"
38 #include "log.h" 38 #include "log.h"
39 #include "once.h"
40 #include "platform.h"
39 #include "runtime-profiler.h" 41 #include "runtime-profiler.h"
40 #include "serialize.h" 42 #include "serialize.h"
41 #include "store-buffer.h" 43 #include "store-buffer.h"
42 44
43 namespace v8 { 45 namespace v8 {
44 namespace internal { 46 namespace internal {
45 47
46 static Mutex* init_once_mutex = OS::CreateMutex(); 48 V8_DECLARE_ONCE(init_once);
47 static bool init_once_called = false;
48 49
49 bool V8::is_running_ = false; 50 bool V8::is_running_ = false;
50 bool V8::has_been_set_up_ = false; 51 bool V8::has_been_set_up_ = false;
51 bool V8::has_been_disposed_ = false; 52 bool V8::has_been_disposed_ = false;
52 bool V8::has_fatal_error_ = false; 53 bool V8::has_fatal_error_ = false;
53 bool V8::use_crankshaft_ = true; 54 bool V8::use_crankshaft_ = true;
54 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; 55 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
55 56
56 static Mutex* entropy_mutex = OS::CreateMutex(); 57 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER;
58
57 static EntropySource entropy_source; 59 static EntropySource entropy_source;
58 60
59 61
60 bool V8::Initialize(Deserializer* des) { 62 bool V8::Initialize(Deserializer* des) {
61 FlagList::EnforceFlagImplications(); 63 FlagList::EnforceFlagImplications();
62 64
63 InitializeOncePerProcess(); 65 InitializeOncePerProcess();
64 66
65 // The current thread may not yet had entered an isolate to run. 67 // The current thread may not yet had entered an isolate to run.
66 // Note the Isolate::Current() may be non-null because for various 68 // Note the Isolate::Current() may be non-null because for various
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 call_completed_callbacks_ = NULL; 112 call_completed_callbacks_ = NULL;
111 } 113 }
112 114
113 115
114 static void seed_random(uint32_t* state) { 116 static void seed_random(uint32_t* state) {
115 for (int i = 0; i < 2; ++i) { 117 for (int i = 0; i < 2; ++i) {
116 if (FLAG_random_seed != 0) { 118 if (FLAG_random_seed != 0) {
117 state[i] = FLAG_random_seed; 119 state[i] = FLAG_random_seed;
118 } else if (entropy_source != NULL) { 120 } else if (entropy_source != NULL) {
119 uint32_t val; 121 uint32_t val;
120 ScopedLock lock(entropy_mutex); 122 ScopedLock lock(entropy_mutex.Pointer());
121 entropy_source(reinterpret_cast<unsigned char*>(&val), sizeof(uint32_t)); 123 entropy_source(reinterpret_cast<unsigned char*>(&val), sizeof(uint32_t));
122 state[i] = val; 124 state[i] = val;
123 } else { 125 } else {
124 state[i] = random(); 126 state[i] = random();
125 } 127 }
126 } 128 }
127 } 129 }
128 130
129 131
130 // Random number generator using George Marsaglia's MWC algorithm. 132 // Random number generator using George Marsaglia's MWC algorithm.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). 232 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
231 static const double binary_million = 1048576.0; 233 static const double binary_million = 1048576.0;
232 r.double_value = binary_million; 234 r.double_value = binary_million;
233 r.uint64_t_value |= random_bits; 235 r.uint64_t_value |= random_bits;
234 r.double_value -= binary_million; 236 r.double_value -= binary_million;
235 237
236 HeapNumber::cast(heap_number)->set_value(r.double_value); 238 HeapNumber::cast(heap_number)->set_value(r.double_value);
237 return heap_number; 239 return heap_number;
238 } 240 }
239 241
240 242 void V8::InitializeOncePerProcessImpl() {
241 void V8::InitializeOncePerProcess() {
242 ScopedLock lock(init_once_mutex);
243 if (init_once_called) return;
244 init_once_called = true;
245
246 // Set up the platform OS support. 243 // Set up the platform OS support.
247 OS::SetUp(); 244 OS::SetUp();
248 245
249 use_crankshaft_ = FLAG_crankshaft; 246 use_crankshaft_ = FLAG_crankshaft;
250 247
251 if (Serializer::enabled()) { 248 if (Serializer::enabled()) {
252 use_crankshaft_ = false; 249 use_crankshaft_ = false;
253 } 250 }
254 251
255 CPU::SetUp(); 252 CPU::SetUp();
256 if (!CPU::SupportsCrankshaft()) { 253 if (!CPU::SupportsCrankshaft()) {
257 use_crankshaft_ = false; 254 use_crankshaft_ = false;
258 } 255 }
259 256
260 RuntimeProfiler::GlobalSetup(); 257 RuntimeProfiler::GlobalSetup();
261 258
262 ElementsAccessor::InitializeOncePerProcess(); 259 ElementsAccessor::InitializeOncePerProcess();
263 260
264 if (FLAG_stress_compaction) { 261 if (FLAG_stress_compaction) {
265 FLAG_force_marking_deque_overflows = true; 262 FLAG_force_marking_deque_overflows = true;
266 FLAG_gc_global = true; 263 FLAG_gc_global = true;
267 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; 264 FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2;
268 } 265 }
266
267 LOperand::SetUpCaches();
268 }
269
270 void V8::InitializeOncePerProcess() {
271 CallOnce(&init_once, &InitializeOncePerProcessImpl);
269 } 272 }
270 273
271 } } // namespace v8::internal 274 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/v8.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698