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 | 66 // initialization purposes an initializing thread may be assigned an isolate |
67 // isolate but not actually enter it. | 67 // 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 | |
96 Isolate* isolate = Isolate::Current(); | 87 Isolate* isolate = Isolate::Current(); |
97 ASSERT(isolate->IsDefaultIsolate()); | 88 ASSERT(isolate->IsDefaultIsolate()); |
98 if (!isolate->IsInitialized()) return; | 89 if (!isolate->IsInitialized()) return; |
99 | 90 |
100 // The isolate has to be torn down before clearing the LOperand | 91 // The isolate has to be torn down before clearing the LOperand |
101 // caches so that the optimizing compiler thread (if running) | 92 // caches so that the optimizing compiler thread (if running) |
102 // doesn't see an inconsistent view of the lithium instructions. | 93 // doesn't see an inconsistent view of the lithium instructions. |
103 Isolate::SetIsolateThreadLocals(isolate, NULL); | |
104 isolate->TearDown(); | 94 isolate->TearDown(); |
105 delete isolate; | 95 delete isolate; |
106 | 96 |
107 ElementsAccessor::TearDown(); | 97 ElementsAccessor::TearDown(); |
108 LOperand::TearDownCaches(); | 98 LOperand::TearDownCaches(); |
109 ExternalReference::TearDownMathExpData(); | 99 ExternalReference::TearDownMathExpData(); |
110 RegisteredExtension::UnregisterAll(); | 100 RegisteredExtension::UnregisterAll(); |
111 Isolate::GlobalTearDown(); | 101 Isolate::GlobalTearDown(); |
112 | 102 |
113 delete call_completed_callbacks_; | 103 delete call_completed_callbacks_; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 ExternalReference::SetUp(); | 292 ExternalReference::SetUp(); |
303 Bootstrapper::InitializeOncePerProcess(); | 293 Bootstrapper::InitializeOncePerProcess(); |
304 } | 294 } |
305 | 295 |
306 | 296 |
307 void V8::InitializeOncePerProcess() { | 297 void V8::InitializeOncePerProcess() { |
308 CallOnce(&init_once, &InitializeOncePerProcessImpl); | 298 CallOnce(&init_once, &InitializeOncePerProcessImpl); |
309 } | 299 } |
310 | 300 |
311 } } // namespace v8::internal | 301 } } // namespace v8::internal |
OLD | NEW |