| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 EagerlyArchiveThread(); | 149 EagerlyArchiveThread(); |
| 150 } | 150 } |
| 151 ThreadState* state = | 151 ThreadState* state = |
| 152 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); | 152 reinterpret_cast<ThreadState*>(Thread::GetThreadLocal(thread_state_key)); |
| 153 if (state == NULL) { | 153 if (state == NULL) { |
| 154 // This is a new thread. | 154 // This is a new thread. |
| 155 StackGuard::InitThread(access); | 155 StackGuard::InitThread(access); |
| 156 return false; | 156 return false; |
| 157 } | 157 } |
| 158 char* from = state->data(); | 158 char* from = state->data(); |
| 159 printf("Restore from %p\n", (void*)state->data()); | |
| 160 from = HandleScopeImplementer::RestoreThread(from); | 159 from = HandleScopeImplementer::RestoreThread(from); |
| 161 from = Top::RestoreThread(from); | 160 from = Top::RestoreThread(from); |
| 162 from = Relocatable::RestoreState(from); | 161 from = Relocatable::RestoreState(from); |
| 163 #ifdef ENABLE_DEBUGGER_SUPPORT | 162 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 164 from = Debug::RestoreDebug(from); | 163 from = Debug::RestoreDebug(from); |
| 165 #endif | 164 #endif |
| 166 from = StackGuard::RestoreStackGuard(from); | 165 from = StackGuard::RestoreStackGuard(from); |
| 167 from = RegExpStack::RestoreStack(from); | 166 from = RegExpStack::RestoreStack(from); |
| 168 from = Bootstrapper::RestoreState(from); | 167 from = Bootstrapper::RestoreState(from); |
| 169 Thread::SetThreadLocal(thread_state_key, NULL); | 168 Thread::SetThreadLocal(thread_state_key, NULL); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 lazily_archived_thread_state_ = state; | 277 lazily_archived_thread_state_ = state; |
| 279 ASSERT(state->id() == kInvalidId); | 278 ASSERT(state->id() == kInvalidId); |
| 280 state->set_id(CurrentId()); | 279 state->set_id(CurrentId()); |
| 281 ASSERT(state->id() != kInvalidId); | 280 ASSERT(state->id() != kInvalidId); |
| 282 } | 281 } |
| 283 | 282 |
| 284 | 283 |
| 285 void ThreadManager::EagerlyArchiveThread() { | 284 void ThreadManager::EagerlyArchiveThread() { |
| 286 ThreadState* state = lazily_archived_thread_state_; | 285 ThreadState* state = lazily_archived_thread_state_; |
| 287 state->LinkInto(ThreadState::IN_USE_LIST); | 286 state->LinkInto(ThreadState::IN_USE_LIST); |
| 288 printf("Archive into %p\n", (void*)state->data()); | |
| 289 char* to = state->data(); | 287 char* to = state->data(); |
| 290 // Ensure that data containing GC roots are archived first, and handle them | 288 // Ensure that data containing GC roots are archived first, and handle them |
| 291 // in ThreadManager::Iterate(ObjectVisitor*). | 289 // in ThreadManager::Iterate(ObjectVisitor*). |
| 292 to = HandleScopeImplementer::ArchiveThread(to); | 290 to = HandleScopeImplementer::ArchiveThread(to); |
| 293 to = Top::ArchiveThread(to); | 291 to = Top::ArchiveThread(to); |
| 294 to = Relocatable::ArchiveState(to); | 292 to = Relocatable::ArchiveState(to); |
| 295 #ifdef ENABLE_DEBUGGER_SUPPORT | 293 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 296 to = Debug::ArchiveDebug(to); | 294 to = Debug::ArchiveDebug(to); |
| 297 #endif | 295 #endif |
| 298 to = StackGuard::ArchiveStackGuard(to); | 296 to = StackGuard::ArchiveStackGuard(to); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 319 return Thread::HasThreadLocal(thread_state_key); | 317 return Thread::HasThreadLocal(thread_state_key); |
| 320 } | 318 } |
| 321 | 319 |
| 322 | 320 |
| 323 void ThreadManager::Iterate(ObjectVisitor* v) { | 321 void ThreadManager::Iterate(ObjectVisitor* v) { |
| 324 // Expecting no threads during serialization/deserialization | 322 // Expecting no threads during serialization/deserialization |
| 325 for (ThreadState* state = ThreadState::FirstInUse(); | 323 for (ThreadState* state = ThreadState::FirstInUse(); |
| 326 state != NULL; | 324 state != NULL; |
| 327 state = state->Next()) { | 325 state = state->Next()) { |
| 328 char* data = state->data(); | 326 char* data = state->data(); |
| 329 printf("Iterate over %p\n", (void*)state->data()); | |
| 330 data = HandleScopeImplementer::Iterate(v, data); | 327 data = HandleScopeImplementer::Iterate(v, data); |
| 331 data = Top::Iterate(v, data); | 328 data = Top::Iterate(v, data); |
| 332 data = Relocatable::Iterate(v, data); | 329 data = Relocatable::Iterate(v, data); |
| 333 } | 330 } |
| 334 } | 331 } |
| 335 | 332 |
| 336 | 333 |
| 337 void ThreadManager::MarkCompactPrologue(bool is_compacting) { | 334 void ThreadManager::MarkCompactPrologue(bool is_compacting) { |
| 338 for (ThreadState* state = ThreadState::FirstInUse(); | 335 for (ThreadState* state = ThreadState::FirstInUse(); |
| 339 state != NULL; | 336 state != NULL; |
| 340 state = state->Next()) { | 337 state = state->Next()) { |
| 341 char* data = state->data(); | 338 char* data = state->data(); |
| 342 printf("Mark compact prologue %p\n", (void*)state->data()); | |
| 343 data += HandleScopeImplementer::ArchiveSpacePerThread(); | 339 data += HandleScopeImplementer::ArchiveSpacePerThread(); |
| 344 Top::MarkCompactPrologue(is_compacting, data); | 340 Top::MarkCompactPrologue(is_compacting, data); |
| 345 } | 341 } |
| 346 } | 342 } |
| 347 | 343 |
| 348 | 344 |
| 349 void ThreadManager::MarkCompactEpilogue(bool is_compacting) { | 345 void ThreadManager::MarkCompactEpilogue(bool is_compacting) { |
| 350 for (ThreadState* state = ThreadState::FirstInUse(); | 346 for (ThreadState* state = ThreadState::FirstInUse(); |
| 351 state != NULL; | 347 state != NULL; |
| 352 state = state->Next()) { | 348 state = state->Next()) { |
| 353 char* data = state->data(); | 349 char* data = state->data(); |
| 354 printf("Mark compact epilogue %p\n", (void*)state->data()); | |
| 355 data += HandleScopeImplementer::ArchiveSpacePerThread(); | 350 data += HandleScopeImplementer::ArchiveSpacePerThread(); |
| 356 Top::MarkCompactEpilogue(is_compacting, data); | 351 Top::MarkCompactEpilogue(is_compacting, data); |
| 357 } | 352 } |
| 358 } | 353 } |
| 359 | 354 |
| 360 | 355 |
| 361 int ThreadManager::CurrentId() { | 356 int ThreadManager::CurrentId() { |
| 362 return Thread::GetThreadLocalInt(thread_id_key); | 357 return Thread::GetThreadLocalInt(thread_id_key); |
| 363 } | 358 } |
| 364 | 359 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 // Acknowledge the preemption by the receiving thread. | 441 // Acknowledge the preemption by the receiving thread. |
| 447 void ContextSwitcher::PreemptionReceived() { | 442 void ContextSwitcher::PreemptionReceived() { |
| 448 ASSERT(Locker::IsLocked()); | 443 ASSERT(Locker::IsLocked()); |
| 449 // There is currently no accounting being done for this. But could be in the | 444 // There is currently no accounting being done for this. But could be in the |
| 450 // future, which is why we leave this in. | 445 // future, which is why we leave this in. |
| 451 } | 446 } |
| 452 | 447 |
| 453 | 448 |
| 454 } // namespace internal | 449 } // namespace internal |
| 455 } // namespace v8 | 450 } // namespace v8 |
| OLD | NEW |