| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 V8_DECLARE_ONCE(init_once); | 54 V8_DECLARE_ONCE(init_once); |
| 55 | 55 |
| 56 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; | 56 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; |
| 57 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; | 57 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; |
| 58 v8::Platform* V8::platform_ = NULL; | 58 v8::Platform* V8::platform_ = NULL; |
| 59 | 59 |
| 60 | 60 |
| 61 bool V8::Initialize(Deserializer* des) { | 61 bool V8::Initialize(Deserializer* des) { |
| 62 InitializeOncePerProcess(); | 62 InitializeOncePerProcess(); |
| 63 | 63 Isolate* isolate = Isolate::UncheckedCurrent(); |
| 64 // The current thread may not yet had entered an isolate to run. | 64 if (isolate == NULL) return true; |
| 65 // Note the Isolate::Current() may be non-null because for various | |
| 66 // initialization purposes an initializing thread may be assigned an isolate | |
| 67 // but not actually enter it. | |
| 68 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | |
| 69 i::Isolate::EnterDefaultIsolate(); | |
| 70 } | |
| 71 | |
| 72 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); | |
| 73 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( | |
| 74 i::ThreadId::Current())); | |
| 75 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == | |
| 76 i::Isolate::Current()); | |
| 77 | |
| 78 Isolate* isolate = Isolate::Current(); | |
| 79 if (isolate->IsDead()) return false; | 65 if (isolate->IsDead()) return false; |
| 80 if (isolate->IsInitialized()) return true; | 66 if (isolate->IsInitialized()) return true; |
| 81 | 67 |
| 82 #ifdef V8_USE_DEFAULT_PLATFORM | 68 #ifdef V8_USE_DEFAULT_PLATFORM |
| 83 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); | 69 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); |
| 84 platform->SetThreadPoolSize(isolate->max_available_threads()); | 70 platform->SetThreadPoolSize(isolate->max_available_threads()); |
| 85 // We currently only start the threads early, if we know that we'll use them. | 71 // We currently only start the threads early, if we know that we'll use them. |
| 86 if (FLAG_job_based_sweeping) platform->EnsureInitialized(); | 72 if (FLAG_job_based_sweeping) platform->EnsureInitialized(); |
| 87 #endif | 73 #endif |
| 88 | 74 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 platform_ = NULL; | 215 platform_ = NULL; |
| 230 } | 216 } |
| 231 | 217 |
| 232 | 218 |
| 233 v8::Platform* V8::GetCurrentPlatform() { | 219 v8::Platform* V8::GetCurrentPlatform() { |
| 234 ASSERT(platform_); | 220 ASSERT(platform_); |
| 235 return platform_; | 221 return platform_; |
| 236 } | 222 } |
| 237 | 223 |
| 238 } } // namespace v8::internal | 224 } } // namespace v8::internal |
| OLD | NEW |