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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Record that the Locker has been used at least once. | 53 // Record that the Locker has been used at least once. |
54 active_ = true; | 54 active_ = true; |
55 // Get the big lock if necessary. | 55 // Get the big lock if necessary. |
56 if (!internal::ThreadManager::IsLockedByCurrentThread()) { | 56 if (!internal::ThreadManager::IsLockedByCurrentThread()) { |
57 internal::ThreadManager::Lock(); | 57 internal::ThreadManager::Lock(); |
58 has_lock_ = true; | 58 has_lock_ = true; |
59 // This may be a locker within an unlocker in which case we have to | 59 // This may be a locker within an unlocker in which case we have to |
60 // get the saved state for this thread and restore it. | 60 // get the saved state for this thread and restore it. |
61 if (internal::ThreadManager::RestoreThread()) { | 61 if (internal::ThreadManager::RestoreThread()) { |
62 top_level_ = false; | 62 top_level_ = false; |
| 63 } else { |
| 64 internal::ExecutionAccess access; |
| 65 internal::StackGuard::ClearThread(access); |
| 66 internal::StackGuard::InitThread(access); |
63 } | 67 } |
64 } | 68 } |
65 ASSERT(internal::ThreadManager::IsLockedByCurrentThread()); | 69 ASSERT(internal::ThreadManager::IsLockedByCurrentThread()); |
66 | 70 |
67 // Make sure this thread is assigned a thread id. | 71 // Make sure this thread is assigned a thread id. |
68 internal::ThreadManager::AssignId(); | 72 internal::ThreadManager::AssignId(); |
69 } | 73 } |
70 | 74 |
71 | 75 |
72 bool Locker::IsLocked() { | 76 bool Locker::IsLocked() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ExecutionAccess access; | 138 ExecutionAccess access; |
135 | 139 |
136 // If there is another thread that was lazily archived then we have to really | 140 // If there is another thread that was lazily archived then we have to really |
137 // archive it now. | 141 // archive it now. |
138 if (lazily_archived_thread_.IsValid()) { | 142 if (lazily_archived_thread_.IsValid()) { |
139 EagerlyArchiveThread(); | 143 EagerlyArchiveThread(); |
140 } | 144 } |
141 ThreadState* state = | 145 ThreadState* state = |
142 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); | 146 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); |
143 if (state == NULL) { | 147 if (state == NULL) { |
| 148 // This is a new thread. |
| 149 StackGuard::InitThread(access); |
144 return false; | 150 return false; |
145 } | 151 } |
146 char* from = state->data(); | 152 char* from = state->data(); |
147 from = HandleScopeImplementer::RestoreThread(from); | 153 from = HandleScopeImplementer::RestoreThread(from); |
148 from = Top::RestoreThread(from); | 154 from = Top::RestoreThread(from); |
149 #ifdef ENABLE_DEBUGGER_SUPPORT | 155 #ifdef ENABLE_DEBUGGER_SUPPORT |
150 from = Debug::RestoreDebug(from); | 156 from = Debug::RestoreDebug(from); |
151 #endif | 157 #endif |
152 from = StackGuard::RestoreStackGuard(from); | 158 from = StackGuard::RestoreStackGuard(from); |
153 from = RegExpStack::RestoreStack(from); | 159 from = RegExpStack::RestoreStack(from); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 // Acknowledge the preemption by the receiving thread. | 431 // Acknowledge the preemption by the receiving thread. |
426 void ContextSwitcher::PreemptionReceived() { | 432 void ContextSwitcher::PreemptionReceived() { |
427 ASSERT(Locker::IsLocked()); | 433 ASSERT(Locker::IsLocked()); |
428 // There is currently no accounting being done for this. But could be in the | 434 // There is currently no accounting being done for this. But could be in the |
429 // future, which is why we leave this in. | 435 // future, which is why we leave this in. |
430 } | 436 } |
431 | 437 |
432 | 438 |
433 } // namespace internal | 439 } // namespace internal |
434 } // namespace v8 | 440 } // namespace v8 |
OLD | NEW |