| 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 , m_gcRequested(false) | 237 , m_gcRequested(false) |
| 238 , m_sweepRequested(0) | 238 , m_sweepRequested(0) |
| 239 , m_sweepInProgress(false) | 239 , m_sweepInProgress(false) |
| 240 , m_noAllocationCount(0) | 240 , m_noAllocationCount(0) |
| 241 , m_inGC(false) | 241 , m_inGC(false) |
| 242 , m_heapContainsCache(adoptPtr(new HeapContainsCache())) | 242 , m_heapContainsCache(adoptPtr(new HeapContainsCache())) |
| 243 , m_isCleaningUp(false) | 243 , m_isCleaningUp(false) |
| 244 { | 244 { |
| 245 ASSERT(!**s_threadSpecific); | 245 ASSERT(!**s_threadSpecific); |
| 246 **s_threadSpecific = this; | 246 **s_threadSpecific = this; |
| 247 | |
| 248 m_stats.clear(); | 247 m_stats.clear(); |
| 249 m_statsAfterLastGC.clear(); | 248 m_statsAfterLastGC.clear(); |
| 250 // First allocate the general heap, second iterate through to | 249 // First allocate the general heap, second iterate through to |
| 251 // allocate the type specific heaps | 250 // allocate the type specific heaps |
| 252 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); | 251 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); |
| 253 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++) | 252 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++) |
| 254 m_heaps[i] = new ThreadHeap<HeapObjectHeader>(this); | 253 m_heaps[i] = new ThreadHeap<HeapObjectHeader>(this); |
| 255 | 254 |
| 256 CallbackStack::init(&m_weakCallbackStack); | 255 CallbackStack::init(&m_weakCallbackStack); |
| 257 } | 256 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 for (size_t i = 0; i < m_cleanupTasks.size(); i++) | 306 for (size_t i = 0; i < m_cleanupTasks.size(); i++) |
| 308 m_cleanupTasks[i]->postCleanup(); | 307 m_cleanupTasks[i]->postCleanup(); |
| 309 | 308 |
| 310 m_cleanupTasks.clear(); | 309 m_cleanupTasks.clear(); |
| 311 } | 310 } |
| 312 | 311 |
| 313 void ThreadState::detach() | 312 void ThreadState::detach() |
| 314 { | 313 { |
| 315 ThreadState* state = current(); | 314 ThreadState* state = current(); |
| 316 state->cleanup(); | 315 state->cleanup(); |
| 317 | |
| 318 // Enter safe point before trying to acquire threadAttachMutex | 316 // Enter safe point before trying to acquire threadAttachMutex |
| 319 // 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 |
| 320 // threadAttachMutex and waiting for other threads to pause or reach a | 318 // threadAttachMutex and waiting for other threads to pause or reach a |
| 321 // safepoint. | 319 // safepoint. |
| 322 if (!state->isAtSafePoint()) | 320 if (!state->isAtSafePoint()) |
| 323 state->enterSafePointWithoutPointers(); | 321 state->enterSafePointWithoutPointers(); |
| 324 MutexLocker locker(threadAttachMutex()); | 322 MutexLocker locker(threadAttachMutex()); |
| 325 state->leaveSafePoint(); | 323 state->leaveSafePoint(); |
| 326 attachedThreads().remove(state); | 324 attachedThreads().remove(state); |
| 327 delete state; | 325 delete state; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 state->safePoint(HeapPointersOnStack); | 716 state->safePoint(HeapPointersOnStack); |
| 719 } | 717 } |
| 720 | 718 |
| 721 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() | 719 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() |
| 722 { | 720 { |
| 723 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); | 721 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); |
| 724 return threads; | 722 return threads; |
| 725 } | 723 } |
| 726 | 724 |
| 727 } | 725 } |
| OLD | NEW |