| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 155   if (per_thread == NULL || per_thread->thread_state() == NULL) { | 155   if (per_thread == NULL || per_thread->thread_state() == NULL) { | 
| 156     // This is a new thread. | 156     // This is a new thread. | 
| 157     isolate_->stack_guard()->InitThread(access); | 157     isolate_->stack_guard()->InitThread(access); | 
| 158     return false; | 158     return false; | 
| 159   } | 159   } | 
| 160   ThreadState* state = per_thread->thread_state(); | 160   ThreadState* state = per_thread->thread_state(); | 
| 161   char* from = state->data(); | 161   char* from = state->data(); | 
| 162   from = isolate_->handle_scope_implementer()->RestoreThread(from); | 162   from = isolate_->handle_scope_implementer()->RestoreThread(from); | 
| 163   from = isolate_->RestoreThread(from); | 163   from = isolate_->RestoreThread(from); | 
| 164   from = Relocatable::RestoreState(isolate_, from); | 164   from = Relocatable::RestoreState(isolate_, from); | 
| 165 #ifdef ENABLE_DEBUGGER_SUPPORT |  | 
| 166   from = isolate_->debug()->RestoreDebug(from); | 165   from = isolate_->debug()->RestoreDebug(from); | 
| 167 #endif |  | 
| 168   from = isolate_->stack_guard()->RestoreStackGuard(from); | 166   from = isolate_->stack_guard()->RestoreStackGuard(from); | 
| 169   from = isolate_->regexp_stack()->RestoreStack(from); | 167   from = isolate_->regexp_stack()->RestoreStack(from); | 
| 170   from = isolate_->bootstrapper()->RestoreState(from); | 168   from = isolate_->bootstrapper()->RestoreState(from); | 
| 171   per_thread->set_thread_state(NULL); | 169   per_thread->set_thread_state(NULL); | 
| 172   if (state->terminate_on_restore()) { | 170   if (state->terminate_on_restore()) { | 
| 173     isolate_->stack_guard()->TerminateExecution(); | 171     isolate_->stack_guard()->TerminateExecution(); | 
| 174     state->set_terminate_on_restore(false); | 172     state->set_terminate_on_restore(false); | 
| 175   } | 173   } | 
| 176   state->set_id(ThreadId::Invalid()); | 174   state->set_id(ThreadId::Invalid()); | 
| 177   state->Unlink(); | 175   state->Unlink(); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 189 | 187 | 
| 190 void ThreadManager::Unlock() { | 188 void ThreadManager::Unlock() { | 
| 191   mutex_owner_ = ThreadId::Invalid(); | 189   mutex_owner_ = ThreadId::Invalid(); | 
| 192   mutex_.Unlock(); | 190   mutex_.Unlock(); | 
| 193 } | 191 } | 
| 194 | 192 | 
| 195 | 193 | 
| 196 static int ArchiveSpacePerThread() { | 194 static int ArchiveSpacePerThread() { | 
| 197   return HandleScopeImplementer::ArchiveSpacePerThread() + | 195   return HandleScopeImplementer::ArchiveSpacePerThread() + | 
| 198                         Isolate::ArchiveSpacePerThread() + | 196                         Isolate::ArchiveSpacePerThread() + | 
| 199 #ifdef ENABLE_DEBUGGER_SUPPORT |  | 
| 200                           Debug::ArchiveSpacePerThread() + | 197                           Debug::ArchiveSpacePerThread() + | 
| 201 #endif |  | 
| 202                      StackGuard::ArchiveSpacePerThread() + | 198                      StackGuard::ArchiveSpacePerThread() + | 
| 203                     RegExpStack::ArchiveSpacePerThread() + | 199                     RegExpStack::ArchiveSpacePerThread() + | 
| 204                    Bootstrapper::ArchiveSpacePerThread() + | 200                    Bootstrapper::ArchiveSpacePerThread() + | 
| 205                     Relocatable::ArchiveSpacePerThread(); | 201                     Relocatable::ArchiveSpacePerThread(); | 
| 206 } | 202 } | 
| 207 | 203 | 
| 208 | 204 | 
| 209 ThreadState::ThreadState(ThreadManager* thread_manager) | 205 ThreadState::ThreadState(ThreadManager* thread_manager) | 
| 210     : id_(ThreadId::Invalid()), | 206     : id_(ThreadId::Invalid()), | 
| 211       terminate_on_restore_(false), | 207       terminate_on_restore_(false), | 
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 317 void ThreadManager::EagerlyArchiveThread() { | 313 void ThreadManager::EagerlyArchiveThread() { | 
| 318   ASSERT(IsLockedByCurrentThread()); | 314   ASSERT(IsLockedByCurrentThread()); | 
| 319   ThreadState* state = lazily_archived_thread_state_; | 315   ThreadState* state = lazily_archived_thread_state_; | 
| 320   state->LinkInto(ThreadState::IN_USE_LIST); | 316   state->LinkInto(ThreadState::IN_USE_LIST); | 
| 321   char* to = state->data(); | 317   char* to = state->data(); | 
| 322   // Ensure that data containing GC roots are archived first, and handle them | 318   // Ensure that data containing GC roots are archived first, and handle them | 
| 323   // in ThreadManager::Iterate(ObjectVisitor*). | 319   // in ThreadManager::Iterate(ObjectVisitor*). | 
| 324   to = isolate_->handle_scope_implementer()->ArchiveThread(to); | 320   to = isolate_->handle_scope_implementer()->ArchiveThread(to); | 
| 325   to = isolate_->ArchiveThread(to); | 321   to = isolate_->ArchiveThread(to); | 
| 326   to = Relocatable::ArchiveState(isolate_, to); | 322   to = Relocatable::ArchiveState(isolate_, to); | 
| 327 #ifdef ENABLE_DEBUGGER_SUPPORT |  | 
| 328   to = isolate_->debug()->ArchiveDebug(to); | 323   to = isolate_->debug()->ArchiveDebug(to); | 
| 329 #endif |  | 
| 330   to = isolate_->stack_guard()->ArchiveStackGuard(to); | 324   to = isolate_->stack_guard()->ArchiveStackGuard(to); | 
| 331   to = isolate_->regexp_stack()->ArchiveStack(to); | 325   to = isolate_->regexp_stack()->ArchiveStack(to); | 
| 332   to = isolate_->bootstrapper()->ArchiveState(to); | 326   to = isolate_->bootstrapper()->ArchiveState(to); | 
| 333   lazily_archived_thread_ = ThreadId::Invalid(); | 327   lazily_archived_thread_ = ThreadId::Invalid(); | 
| 334   lazily_archived_thread_state_ = NULL; | 328   lazily_archived_thread_state_ = NULL; | 
| 335 } | 329 } | 
| 336 | 330 | 
| 337 | 331 | 
| 338 void ThreadManager::FreeThreadResources() { | 332 void ThreadManager::FreeThreadResources() { | 
| 339   isolate_->handle_scope_implementer()->FreeThreadResources(); | 333   isolate_->handle_scope_implementer()->FreeThreadResources(); | 
| 340   isolate_->FreeThreadResources(); | 334   isolate_->FreeThreadResources(); | 
| 341 #ifdef ENABLE_DEBUGGER_SUPPORT |  | 
| 342   isolate_->debug()->FreeThreadResources(); | 335   isolate_->debug()->FreeThreadResources(); | 
| 343 #endif |  | 
| 344   isolate_->stack_guard()->FreeThreadResources(); | 336   isolate_->stack_guard()->FreeThreadResources(); | 
| 345   isolate_->regexp_stack()->FreeThreadResources(); | 337   isolate_->regexp_stack()->FreeThreadResources(); | 
| 346   isolate_->bootstrapper()->FreeThreadResources(); | 338   isolate_->bootstrapper()->FreeThreadResources(); | 
| 347 } | 339 } | 
| 348 | 340 | 
| 349 | 341 | 
| 350 bool ThreadManager::IsArchived() { | 342 bool ThreadManager::IsArchived() { | 
| 351   Isolate::PerIsolateThreadData* data = | 343   Isolate::PerIsolateThreadData* data = | 
| 352       isolate_->FindPerThreadDataForThisThread(); | 344       isolate_->FindPerThreadDataForThisThread(); | 
| 353   return data != NULL && data->thread_state() != NULL; | 345   return data != NULL && data->thread_state() != NULL; | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 389        state = state->Next()) { | 381        state = state->Next()) { | 
| 390     if (thread_id.Equals(state->id())) { | 382     if (thread_id.Equals(state->id())) { | 
| 391       state->set_terminate_on_restore(true); | 383       state->set_terminate_on_restore(true); | 
| 392     } | 384     } | 
| 393   } | 385   } | 
| 394 } | 386 } | 
| 395 | 387 | 
| 396 | 388 | 
| 397 }  // namespace internal | 389 }  // namespace internal | 
| 398 }  // namespace v8 | 390 }  // namespace v8 | 
| OLD | NEW | 
|---|