Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; | 56 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; |
| 57 | 57 |
| 58 static EntropySource entropy_source; | 58 static EntropySource entropy_source; |
| 59 | 59 |
| 60 | 60 |
| 61 bool V8::Initialize(Deserializer* des) { | 61 bool V8::Initialize(Deserializer* des) { |
| 62 InitializeOncePerProcess(); | 62 InitializeOncePerProcess(); |
| 63 | 63 |
| 64 // 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. |
| 65 // Note the Isolate::Current() may be non-null because for various | 65 // Note the Isolate::Current() may be non-null because for various |
| 66 // initialization purposes an initializing thread may be assigned an isolate | 66 // initialization purposes an initializing thread may be assigned an |
| 67 // but not actually enter it. | 67 // isolate but not actually enter it. |
| 68 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | 68 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { |
| 69 i::Isolate::EnterDefaultIsolate(); | 69 i::Isolate::EnterDefaultIsolate(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); | 72 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); |
| 73 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( | 73 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( |
| 74 i::ThreadId::Current())); | 74 i::ThreadId::Current())); |
| 75 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == | 75 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == |
| 76 i::Isolate::Current()); | 76 i::Isolate::Current()); |
| 77 | 77 |
| 78 Isolate* isolate = Isolate::Current(); | 78 Isolate* isolate = Isolate::Current(); |
| 79 if (isolate->IsDead()) return false; | 79 if (isolate->IsDead()) return false; |
| 80 if (isolate->IsInitialized()) return true; | 80 if (isolate->IsInitialized()) return true; |
| 81 | 81 |
| 82 return isolate->Init(des); | 82 return isolate->Init(des); |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 void V8::TearDown() { | 86 void V8::TearDown() { |
| 87 // The current thread may not yet had entered an isolate to run or may | |
| 88 // have already disposed the entered isolated before. | |
| 89 // Note the Isolate::Current() may be non-null because for various | |
| 90 // initialization purposes an initializing thread may be assigned an | |
| 91 // isolate but not actually enter it. | |
| 92 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { | |
| 93 return; | |
| 94 } | |
| 95 | |
| 87 Isolate* isolate = Isolate::Current(); | 96 Isolate* isolate = Isolate::Current(); |
| 88 ASSERT(isolate->IsDefaultIsolate()); | 97 ASSERT(isolate->IsDefaultIsolate()); |
| 89 if (!isolate->IsInitialized()) return; | 98 if (!isolate->IsInitialized()) return; |
| 90 | 99 |
| 91 // The isolate has to be torn down before clearing the LOperand | 100 // The isolate has to be torn down before clearing the LOperand |
| 92 // caches so that the optimizing compiler thread (if running) | 101 // caches so that the optimizing compiler thread (if running) |
| 93 // doesn't see an inconsistent view of the lithium instructions. | 102 // doesn't see an inconsistent view of the lithium instructions. |
| 103 Isolate::SetIsolateThreadLocals(isolate, NULL); | |
|
Sven Panne
2013/09/06 10:48:27
This looks a bit strange, but to be honest, I don'
| |
| 94 isolate->TearDown(); | 104 isolate->TearDown(); |
| 95 delete isolate; | 105 delete isolate; |
| 96 | 106 |
| 97 ElementsAccessor::TearDown(); | 107 ElementsAccessor::TearDown(); |
| 98 LOperand::TearDownCaches(); | 108 LOperand::TearDownCaches(); |
| 99 ExternalReference::TearDownMathExpData(); | 109 ExternalReference::TearDownMathExpData(); |
| 100 RegisteredExtension::UnregisterAll(); | 110 RegisteredExtension::UnregisterAll(); |
| 101 Isolate::GlobalTearDown(); | 111 Isolate::GlobalTearDown(); |
| 102 | 112 |
| 103 delete call_completed_callbacks_; | 113 delete call_completed_callbacks_; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 ExternalReference::SetUp(); | 302 ExternalReference::SetUp(); |
| 293 Bootstrapper::InitializeOncePerProcess(); | 303 Bootstrapper::InitializeOncePerProcess(); |
| 294 } | 304 } |
| 295 | 305 |
| 296 | 306 |
| 297 void V8::InitializeOncePerProcess() { | 307 void V8::InitializeOncePerProcess() { |
| 298 CallOnce(&init_once, &InitializeOncePerProcessImpl); | 308 CallOnce(&init_once, &InitializeOncePerProcessImpl); |
| 299 } | 309 } |
| 300 | 310 |
| 301 } } // namespace v8::internal | 311 } } // namespace v8::internal |
| OLD | NEW |