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

Side by Side Diff: src/v8.cc

Issue 6670119: VM initialization refactoring. (Closed)
Patch Set: Created 9 years, 8 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 23 matching lines...) Expand all
34 #include "heap-profiler.h" 34 #include "heap-profiler.h"
35 #include "hydrogen.h" 35 #include "hydrogen.h"
36 #include "lithium-allocator.h" 36 #include "lithium-allocator.h"
37 #include "log.h" 37 #include "log.h"
38 #include "runtime-profiler.h" 38 #include "runtime-profiler.h"
39 #include "serialize.h" 39 #include "serialize.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44 static Mutex* init_once_mutex = OS::CreateMutex();
45 static bool init_once_called = false;
46
44 bool V8::is_running_ = false; 47 bool V8::is_running_ = false;
45 bool V8::has_been_setup_ = false; 48 bool V8::has_been_setup_ = false;
46 bool V8::has_been_disposed_ = false; 49 bool V8::has_been_disposed_ = false;
47 bool V8::has_fatal_error_ = false; 50 bool V8::has_fatal_error_ = false;
48 bool V8::use_crankshaft_ = true; 51 bool V8::use_crankshaft_ = true;
49 52
50 53
51 bool V8::Initialize(Deserializer* des) { 54 bool V8::Initialize(Deserializer* des) {
55 InitializeOncePerProcess();
56
52 // The current thread may not yet had entered an isolate to run. 57 // The current thread may not yet had entered an isolate to run.
53 // Note the Isolate::Current() may be non-null because for various 58 // Note the Isolate::Current() may be non-null because for various
54 // initialization purposes an initializing thread may be assigned an isolate 59 // initialization purposes an initializing thread may be assigned an isolate
55 // but not actually enter it. 60 // but not actually enter it.
56 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { 61 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) {
57 i::Isolate::EnterDefaultIsolate(); 62 i::Isolate::EnterDefaultIsolate();
58 } 63 }
59 64
60 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); 65 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL);
61 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id() == 66 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id() ==
62 i::Thread::GetThreadLocalInt(i::Isolate::thread_id_key())); 67 i::Thread::GetThreadLocalInt(i::Isolate::thread_id_key()));
63 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == 68 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() ==
64 i::Isolate::Current()); 69 i::Isolate::Current());
65 70
66 if (IsDead()) return false; 71 if (IsDead()) return false;
67 72
68 Isolate* isolate = Isolate::Current(); 73 Isolate* isolate = Isolate::Current();
69 if (isolate->IsInitialized()) return true; 74 if (isolate->IsInitialized()) return true;
70 75
71 #if defined(V8_TARGET_ARCH_ARM) && !defined(USE_ARM_EABI)
72 use_crankshaft_ = false;
73 #else
74 use_crankshaft_ = FLAG_crankshaft;
75 #endif
76
77 // Peephole optimization might interfere with deoptimization.
78 FLAG_peephole_optimization = !use_crankshaft_;
79
80 is_running_ = true; 76 is_running_ = true;
81 has_been_setup_ = true; 77 has_been_setup_ = true;
82 has_fatal_error_ = false; 78 has_fatal_error_ = false;
83 has_been_disposed_ = false; 79 has_been_disposed_ = false;
84 80
85 return isolate->Init(des); 81 return isolate->Init(des);
86 } 82 }
87 83
88 84
89 void V8::SetFatalError() { 85 void V8::SetFatalError() {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // by computing: 177 // by computing:
182 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). 178 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
183 const double binary_million = 1048576.0; 179 const double binary_million = 1048576.0;
184 r->double_value = binary_million; 180 r->double_value = binary_million;
185 r->uint64_t_value |= random_bits; 181 r->uint64_t_value |= random_bits;
186 r->double_value -= binary_million; 182 r->double_value -= binary_million;
187 183
188 return heap_number; 184 return heap_number;
189 } 185 }
190 186
187
188 void V8::InitializeOncePerProcess() {
189 ScopedLock lock(init_once_mutex);
190 if (init_once_called) return;
191 init_once_called = true;
192
193 // Setup the platform OS support.
194 OS::Setup();
195
196 #if defined(V8_TARGET_ARCH_ARM) && !defined(USE_ARM_EABI)
197 use_crankshaft_ = false;
198 #else
199 use_crankshaft_ = FLAG_crankshaft;
200 #endif
201
202 if (Serializer::enabled()) {
203 use_crankshaft_ = false;
204 }
205
206 CPU::Setup();
207 if (!CPU::SupportsCrankshaft()) {
208 use_crankshaft_ = false;
209 }
210
211 // Peephole optimization might interfere with deoptimization.
Mads Ager (chromium) 2011/03/31 13:48:21 This is fine. Maybe we should file a bug report on
212 FLAG_peephole_optimization = !use_crankshaft_;
213 }
214
191 } } // namespace v8::internal 215 } } // namespace v8::internal
OLDNEW
« src/ia32/code-stubs-ia32.cc ('K') | « src/v8.h ('k') | src/x64/cpu-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698