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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 #include "once.h" | 44 #include "once.h" |
45 #include "platform.h" | 45 #include "platform.h" |
46 #include "sampler.h" | 46 #include "sampler.h" |
47 #include "runtime-profiler.h" | 47 #include "runtime-profiler.h" |
48 #include "serialize.h" | 48 #include "serialize.h" |
49 #include "store-buffer.h" | 49 #include "store-buffer.h" |
50 | 50 |
51 namespace v8 { | 51 namespace v8 { |
52 namespace internal { | 52 namespace internal { |
53 | 53 |
54 static void empty_log_internal_events(const char* name, int se) { return; } | |
Yang
2014/03/06 12:05:33
I think we can remove that return statement too. j
fmeawad
2014/03/06 19:23:04
Done.
| |
55 | |
56 static void log_internal_events(const char* name, int se) { | |
57 Isolate* isolate = Isolate::Current(); | |
58 LOG(isolate, Logger::TimerEvent(static_cast<Logger::StartEnd>(se), name)); | |
59 } | |
60 | |
54 V8_DECLARE_ONCE(init_once); | 61 V8_DECLARE_ONCE(init_once); |
55 | 62 |
56 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; | 63 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; |
57 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; | 64 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; |
58 v8::Platform* V8::platform_ = NULL; | 65 v8::Platform* V8::platform_ = NULL; |
59 | 66 |
60 | 67 |
61 bool V8::Initialize(Deserializer* des) { | 68 bool V8::Initialize(Deserializer* des) { |
62 InitializeOncePerProcess(); | 69 InitializeOncePerProcess(); |
63 | 70 |
64 // The current thread may not yet had entered an isolate to run. | 71 // The current thread may not yet had entered an isolate to run. |
65 // Note the Isolate::Current() may be non-null because for various | 72 // Note the Isolate::Current() may be non-null because for various |
66 // initialization purposes an initializing thread may be assigned an isolate | 73 // initialization purposes an initializing thread may be assigned an isolate |
67 // but not actually enter it. | 74 // but not actually enter it. |
68 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | 75 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { |
69 i::Isolate::EnterDefaultIsolate(); | 76 i::Isolate::EnterDefaultIsolate(); |
70 } | 77 } |
71 | 78 |
72 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); | 79 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); |
73 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( | 80 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( |
74 i::ThreadId::Current())); | 81 i::ThreadId::Current())); |
75 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == | 82 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == |
76 i::Isolate::Current()); | 83 i::Isolate::Current()); |
77 | 84 |
78 Isolate* isolate = Isolate::Current(); | 85 Isolate* isolate = Isolate::Current(); |
79 if (isolate->IsDead()) return false; | 86 if (isolate->IsDead()) return false; |
80 if (isolate->IsInitialized()) return true; | 87 if (isolate->IsInitialized()) return true; |
81 | 88 |
89 if (!isolate->event_logger() && FLAG_log_internal_timer_events) { | |
90 isolate->set_event_logger(log_internal_events); | |
91 } else { | |
92 isolate->set_event_logger(empty_log_internal_events); | |
93 } | |
Yang
2014/03/06 12:05:33
I think this should be put into Isolate::Init. And
fmeawad
2014/03/06 19:23:04
Done.
| |
94 | |
82 #ifdef V8_USE_DEFAULT_PLATFORM | 95 #ifdef V8_USE_DEFAULT_PLATFORM |
83 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); | 96 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); |
84 platform->SetThreadPoolSize(isolate->max_available_threads()); | 97 platform->SetThreadPoolSize(isolate->max_available_threads()); |
85 // We currently only start the threads early, if we know that we'll use them. | 98 // We currently only start the threads early, if we know that we'll use them. |
86 if (FLAG_job_based_sweeping) platform->EnsureInitialized(); | 99 if (FLAG_job_based_sweeping) platform->EnsureInitialized(); |
87 #endif | 100 #endif |
88 | 101 |
89 return isolate->Init(des); | 102 return isolate->Init(des); |
90 } | 103 } |
91 | 104 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 platform_ = NULL; | 245 platform_ = NULL; |
233 } | 246 } |
234 | 247 |
235 | 248 |
236 v8::Platform* V8::GetCurrentPlatform() { | 249 v8::Platform* V8::GetCurrentPlatform() { |
237 ASSERT(platform_); | 250 ASSERT(platform_); |
238 return platform_; | 251 return platform_; |
239 } | 252 } |
240 | 253 |
241 } } // namespace v8::internal | 254 } } // namespace v8::internal |
OLD | NEW |