OLD | NEW |
---|---|
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 EagerlyArchiveThread(); | 137 EagerlyArchiveThread(); |
138 } | 138 } |
139 ThreadState* state = | 139 ThreadState* state = |
140 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); | 140 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); |
141 if (state == NULL) { | 141 if (state == NULL) { |
142 return false; | 142 return false; |
143 } | 143 } |
144 char* from = state->data(); | 144 char* from = state->data(); |
145 from = HandleScopeImplementer::RestoreThread(from); | 145 from = HandleScopeImplementer::RestoreThread(from); |
146 from = Top::RestoreThread(from); | 146 from = Top::RestoreThread(from); |
147 #ifdef ENABLE_DEBUGGER_SUPPORT | |
147 from = Debug::RestoreDebug(from); | 148 from = Debug::RestoreDebug(from); |
149 #endif | |
148 from = StackGuard::RestoreStackGuard(from); | 150 from = StackGuard::RestoreStackGuard(from); |
149 from = RegExpStack::RestoreStack(from); | 151 from = RegExpStack::RestoreStack(from); |
150 from = Bootstrapper::RestoreState(from); | 152 from = Bootstrapper::RestoreState(from); |
151 Thread::SetThreadLocal(thread_state_key, NULL); | 153 Thread::SetThreadLocal(thread_state_key, NULL); |
152 state->set_id(kInvalidId); | 154 state->set_id(kInvalidId); |
153 state->Unlink(); | 155 state->Unlink(); |
154 state->LinkInto(ThreadState::FREE_LIST); | 156 state->LinkInto(ThreadState::FREE_LIST); |
155 return true; | 157 return true; |
156 } | 158 } |
157 | 159 |
158 | 160 |
159 void ThreadManager::Lock() { | 161 void ThreadManager::Lock() { |
160 mutex_->Lock(); | 162 mutex_->Lock(); |
161 mutex_owner_.Initialize(ThreadHandle::SELF); | 163 mutex_owner_.Initialize(ThreadHandle::SELF); |
162 ASSERT(IsLockedByCurrentThread()); | 164 ASSERT(IsLockedByCurrentThread()); |
163 } | 165 } |
164 | 166 |
165 | 167 |
166 void ThreadManager::Unlock() { | 168 void ThreadManager::Unlock() { |
167 mutex_owner_.Initialize(ThreadHandle::INVALID); | 169 mutex_owner_.Initialize(ThreadHandle::INVALID); |
168 mutex_->Unlock(); | 170 mutex_->Unlock(); |
169 } | 171 } |
170 | 172 |
171 | 173 |
172 static int ArchiveSpacePerThread() { | 174 static int ArchiveSpacePerThread() { |
173 return HandleScopeImplementer::ArchiveSpacePerThread() + | 175 return HandleScopeImplementer::ArchiveSpacePerThread() + |
174 Top::ArchiveSpacePerThread() + | 176 Top::ArchiveSpacePerThread() + |
177 #ifdef ENABLE_DEBUGGER_SUPPORT | |
175 Debug::ArchiveSpacePerThread() + | 178 Debug::ArchiveSpacePerThread() + |
Søren Thygesen Gjesse
2009/04/17 23:46:17
Please move this to the bottom of the "list".
| |
179 #endif | |
176 StackGuard::ArchiveSpacePerThread() + | 180 StackGuard::ArchiveSpacePerThread() + |
177 RegExpStack::ArchiveSpacePerThread() + | 181 RegExpStack::ArchiveSpacePerThread() + |
178 Bootstrapper::ArchiveSpacePerThread(); | 182 Bootstrapper::ArchiveSpacePerThread(); |
179 } | 183 } |
180 | 184 |
181 | 185 |
182 ThreadState* ThreadState::free_anchor_ = new ThreadState(); | 186 ThreadState* ThreadState::free_anchor_ = new ThreadState(); |
183 ThreadState* ThreadState::in_use_anchor_ = new ThreadState(); | 187 ThreadState* ThreadState::in_use_anchor_ = new ThreadState(); |
184 | 188 |
185 | 189 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 ASSERT(state->id() != kInvalidId); | 256 ASSERT(state->id() != kInvalidId); |
253 } | 257 } |
254 | 258 |
255 | 259 |
256 void ThreadManager::EagerlyArchiveThread() { | 260 void ThreadManager::EagerlyArchiveThread() { |
257 ThreadState* state = lazily_archived_thread_state_; | 261 ThreadState* state = lazily_archived_thread_state_; |
258 state->LinkInto(ThreadState::IN_USE_LIST); | 262 state->LinkInto(ThreadState::IN_USE_LIST); |
259 char* to = state->data(); | 263 char* to = state->data(); |
260 to = HandleScopeImplementer::ArchiveThread(to); | 264 to = HandleScopeImplementer::ArchiveThread(to); |
261 to = Top::ArchiveThread(to); | 265 to = Top::ArchiveThread(to); |
266 #ifdef ENABLE_DEBUGGER_SUPPORT | |
262 to = Debug::ArchiveDebug(to); | 267 to = Debug::ArchiveDebug(to); |
Søren Thygesen Gjesse
2009/04/17 23:46:17
Please move this to the bottom of the "list".
| |
268 #endif | |
263 to = StackGuard::ArchiveStackGuard(to); | 269 to = StackGuard::ArchiveStackGuard(to); |
264 to = RegExpStack::ArchiveStack(to); | 270 to = RegExpStack::ArchiveStack(to); |
265 to = Bootstrapper::ArchiveState(to); | 271 to = Bootstrapper::ArchiveState(to); |
266 lazily_archived_thread_.Initialize(ThreadHandle::INVALID); | 272 lazily_archived_thread_.Initialize(ThreadHandle::INVALID); |
267 lazily_archived_thread_state_ = NULL; | 273 lazily_archived_thread_state_ = NULL; |
268 } | 274 } |
269 | 275 |
270 | 276 |
271 void ThreadManager::Iterate(ObjectVisitor* v) { | 277 void ThreadManager::Iterate(ObjectVisitor* v) { |
272 // Expecting no threads during serialization/deserialization | 278 // Expecting no threads during serialization/deserialization |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 // Acknowledge the preemption by the receiving thread. | 376 // Acknowledge the preemption by the receiving thread. |
371 void ContextSwitcher::PreemptionReceived() { | 377 void ContextSwitcher::PreemptionReceived() { |
372 ASSERT(Locker::IsLocked()); | 378 ASSERT(Locker::IsLocked()); |
373 // There is currently no accounting being done for this. But could be in the | 379 // There is currently no accounting being done for this. But could be in the |
374 // future, which is why we leave this in. | 380 // future, which is why we leave this in. |
375 } | 381 } |
376 | 382 |
377 | 383 |
378 } // namespace internal | 384 } // namespace internal |
379 } // namespace v8 | 385 } // namespace v8 |
OLD | NEW |