| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // From here on ignore all conservatively discovered | 289 // From here on ignore all conservatively discovered |
| 290 // pointers into the heap owned by this thread. | 290 // pointers into the heap owned by this thread. |
| 291 m_isCleaningUp = true; | 291 m_isCleaningUp = true; |
| 292 | 292 |
| 293 for (size_t i = 0; i < m_cleanupTasks.size(); i++) | 293 for (size_t i = 0; i < m_cleanupTasks.size(); i++) |
| 294 m_cleanupTasks[i]->preCleanup(); | 294 m_cleanupTasks[i]->preCleanup(); |
| 295 | 295 |
| 296 // After this GC we expect heap to be empty because | 296 // After this GC we expect heap to be empty because |
| 297 // preCleanup tasks should have cleared all persistent | 297 // preCleanup tasks should have cleared all persistent |
| 298 // handles that were externally owned. | 298 // handles that were externally owned. |
| 299 // FIXME: oilpan: we should perform a single GC and everything | 299 Heap::collectAllGarbage(ThreadState::NoHeapPointersOnStack); |
| 300 // should die. Unfortunately it is not the case for all objects | |
| 301 // because the hierarchy was not completely moved to the heap and | |
| 302 // some heap allocated objects own objects that contain persistents | |
| 303 // pointing to other heap allocated objects. | |
| 304 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | |
| 305 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | |
| 306 | 300 |
| 307 // Verify that all heaps are empty now. | 301 // Verify that all heaps are empty now. |
| 308 for (int i = 0; i < NumberOfHeaps; i++) | 302 for (int i = 0; i < NumberOfHeaps; i++) |
| 309 m_heaps[i]->assertEmpty(); | 303 m_heaps[i]->assertEmpty(); |
| 310 | 304 |
| 311 for (size_t i = 0; i < m_cleanupTasks.size(); i++) | 305 for (size_t i = 0; i < m_cleanupTasks.size(); i++) |
| 312 m_cleanupTasks[i]->postCleanup(); | 306 m_cleanupTasks[i]->postCleanup(); |
| 313 | 307 |
| 314 m_cleanupTasks.clear(); | 308 m_cleanupTasks.clear(); |
| 315 } | 309 } |
| 316 | 310 |
| 317 void ThreadState::detach() | 311 void ThreadState::detach() |
| 318 { | 312 { |
| 319 ThreadState* state = current(); | 313 ThreadState* state = current(); |
| 314 state->cleanup(); |
| 315 |
| 320 // Enter safe point before trying to acquire threadAttachMutex | 316 // Enter safe point before trying to acquire threadAttachMutex |
| 321 // to avoid dead lock if another thread is preparing for GC, has acquired | 317 // to avoid dead lock if another thread is preparing for GC, has acquired |
| 322 // threadAttachMutex and waiting for other threads to pause or reach a | 318 // threadAttachMutex and waiting for other threads to pause or reach a |
| 323 // safepoint. | 319 // safepoint. |
| 324 if (!state->isAtSafePoint()) | 320 if (!state->isAtSafePoint()) |
| 325 state->enterSafePointWithoutPointers(); | 321 state->enterSafePointWithoutPointers(); |
| 326 MutexLocker locker(threadAttachMutex()); | 322 MutexLocker locker(threadAttachMutex()); |
| 327 state->leaveSafePoint(); | 323 state->leaveSafePoint(); |
| 328 attachedThreads().remove(state); | 324 attachedThreads().remove(state); |
| 329 delete state; | 325 delete state; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 state->safePoint(HeapPointersOnStack); | 696 state->safePoint(HeapPointersOnStack); |
| 701 } | 697 } |
| 702 | 698 |
| 703 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() | 699 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() |
| 704 { | 700 { |
| 705 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); | 701 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); |
| 706 return threads; | 702 return threads; |
| 707 } | 703 } |
| 708 | 704 |
| 709 } | 705 } |
| OLD | NEW |