| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8threads.h" | 5 #include "src/v8threads.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/execution.h" | 10 #include "src/execution.h" |
| 11 #include "src/isolate-inl.h" | 11 #include "src/isolate-inl.h" |
| 12 #include "src/regexp/regexp-stack.h" | 12 #include "src/regexp/regexp-stack.h" |
| 13 #include "src/visitors.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 | 16 |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // Track whether this V8 instance has ever called v8::Locker. This allows the | 20 // Track whether this V8 instance has ever called v8::Locker. This allows the |
| 20 // API code to verify that the lock is always held when V8 is being entered. | 21 // API code to verify that the lock is always held when V8 is being entered. |
| 21 base::Atomic32 g_locker_was_ever_used_ = 0; | 22 base::Atomic32 g_locker_was_ever_used_ = 0; |
| 22 | 23 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 DCHECK(!state->id().Equals(ThreadId::Invalid())); | 282 DCHECK(!state->id().Equals(ThreadId::Invalid())); |
| 282 } | 283 } |
| 283 | 284 |
| 284 | 285 |
| 285 void ThreadManager::EagerlyArchiveThread() { | 286 void ThreadManager::EagerlyArchiveThread() { |
| 286 DCHECK(IsLockedByCurrentThread()); | 287 DCHECK(IsLockedByCurrentThread()); |
| 287 ThreadState* state = lazily_archived_thread_state_; | 288 ThreadState* state = lazily_archived_thread_state_; |
| 288 state->LinkInto(ThreadState::IN_USE_LIST); | 289 state->LinkInto(ThreadState::IN_USE_LIST); |
| 289 char* to = state->data(); | 290 char* to = state->data(); |
| 290 // Ensure that data containing GC roots are archived first, and handle them | 291 // Ensure that data containing GC roots are archived first, and handle them |
| 291 // in ThreadManager::Iterate(ObjectVisitor*). | 292 // in ThreadManager::Iterate(RootVisitor*). |
| 292 to = isolate_->handle_scope_implementer()->ArchiveThread(to); | 293 to = isolate_->handle_scope_implementer()->ArchiveThread(to); |
| 293 to = isolate_->ArchiveThread(to); | 294 to = isolate_->ArchiveThread(to); |
| 294 to = Relocatable::ArchiveState(isolate_, to); | 295 to = Relocatable::ArchiveState(isolate_, to); |
| 295 to = isolate_->debug()->ArchiveDebug(to); | 296 to = isolate_->debug()->ArchiveDebug(to); |
| 296 to = isolate_->stack_guard()->ArchiveStackGuard(to); | 297 to = isolate_->stack_guard()->ArchiveStackGuard(to); |
| 297 to = isolate_->regexp_stack()->ArchiveStack(to); | 298 to = isolate_->regexp_stack()->ArchiveStack(to); |
| 298 to = isolate_->bootstrapper()->ArchiveState(to); | 299 to = isolate_->bootstrapper()->ArchiveState(to); |
| 299 lazily_archived_thread_ = ThreadId::Invalid(); | 300 lazily_archived_thread_ = ThreadId::Invalid(); |
| 300 lazily_archived_thread_state_ = NULL; | 301 lazily_archived_thread_state_ = NULL; |
| 301 } | 302 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 313 isolate_->bootstrapper()->FreeThreadResources(); | 314 isolate_->bootstrapper()->FreeThreadResources(); |
| 314 } | 315 } |
| 315 | 316 |
| 316 | 317 |
| 317 bool ThreadManager::IsArchived() { | 318 bool ThreadManager::IsArchived() { |
| 318 Isolate::PerIsolateThreadData* data = | 319 Isolate::PerIsolateThreadData* data = |
| 319 isolate_->FindPerThreadDataForThisThread(); | 320 isolate_->FindPerThreadDataForThisThread(); |
| 320 return data != NULL && data->thread_state() != NULL; | 321 return data != NULL && data->thread_state() != NULL; |
| 321 } | 322 } |
| 322 | 323 |
| 323 | 324 void ThreadManager::Iterate(RootVisitor* v) { |
| 324 void ThreadManager::Iterate(ObjectVisitor* v) { | |
| 325 // Expecting no threads during serialization/deserialization | 325 // Expecting no threads during serialization/deserialization |
| 326 for (ThreadState* state = FirstThreadStateInUse(); | 326 for (ThreadState* state = FirstThreadStateInUse(); |
| 327 state != NULL; | 327 state != NULL; |
| 328 state = state->Next()) { | 328 state = state->Next()) { |
| 329 char* data = state->data(); | 329 char* data = state->data(); |
| 330 data = HandleScopeImplementer::Iterate(v, data); | 330 data = HandleScopeImplementer::Iterate(v, data); |
| 331 data = isolate_->Iterate(v, data); | 331 data = isolate_->Iterate(v, data); |
| 332 data = Relocatable::Iterate(v, data); | 332 data = Relocatable::Iterate(v, data); |
| 333 } | 333 } |
| 334 } | 334 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 356 state = state->Next()) { | 356 state = state->Next()) { |
| 357 if (thread_id.Equals(state->id())) { | 357 if (thread_id.Equals(state->id())) { |
| 358 state->set_terminate_on_restore(true); | 358 state->set_terminate_on_restore(true); |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 | 362 |
| 363 | 363 |
| 364 } // namespace internal | 364 } // namespace internal |
| 365 } // namespace v8 | 365 } // namespace v8 |
| OLD | NEW |