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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 , m_noAllocationCount(0) | 242 , m_noAllocationCount(0) |
243 , m_inGC(false) | 243 , m_inGC(false) |
244 , m_heapContainsCache(adoptPtr(new HeapContainsCache())) | 244 , m_heapContainsCache(adoptPtr(new HeapContainsCache())) |
245 , m_isCleaningUp(false) | 245 , m_isCleaningUp(false) |
246 #if defined(ADDRESS_SANITIZER) && !OS(WIN) | 246 #if defined(ADDRESS_SANITIZER) && !OS(WIN) |
247 , m_asanFakeStack(__asan_get_current_fake_stack()) | 247 , m_asanFakeStack(__asan_get_current_fake_stack()) |
248 #endif | 248 #endif |
249 { | 249 { |
250 ASSERT(!**s_threadSpecific); | 250 ASSERT(!**s_threadSpecific); |
251 **s_threadSpecific = this; | 251 **s_threadSpecific = this; |
252 | |
253 m_stats.clear(); | 252 m_stats.clear(); |
254 m_statsAfterLastGC.clear(); | 253 m_statsAfterLastGC.clear(); |
255 // First allocate the general heap, second iterate through to | 254 // First allocate the general heap, second iterate through to |
256 // allocate the type specific heaps | 255 // allocate the type specific heaps |
257 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); | 256 m_heaps[GeneralHeap] = new ThreadHeap<FinalizedHeapObjectHeader>(this); |
258 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++) | 257 for (int i = GeneralHeap + 1; i < NumberOfHeaps; i++) |
259 m_heaps[i] = new ThreadHeap<HeapObjectHeader>(this); | 258 m_heaps[i] = new ThreadHeap<HeapObjectHeader>(this); |
260 | 259 |
261 CallbackStack::init(&m_weakCallbackStack); | 260 CallbackStack::init(&m_weakCallbackStack); |
262 } | 261 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 for (size_t i = 0; i < m_cleanupTasks.size(); i++) | 311 for (size_t i = 0; i < m_cleanupTasks.size(); i++) |
313 m_cleanupTasks[i]->postCleanup(); | 312 m_cleanupTasks[i]->postCleanup(); |
314 | 313 |
315 m_cleanupTasks.clear(); | 314 m_cleanupTasks.clear(); |
316 } | 315 } |
317 | 316 |
318 void ThreadState::detach() | 317 void ThreadState::detach() |
319 { | 318 { |
320 ThreadState* state = current(); | 319 ThreadState* state = current(); |
321 state->cleanup(); | 320 state->cleanup(); |
322 | |
323 // Enter safe point before trying to acquire threadAttachMutex | 321 // Enter safe point before trying to acquire threadAttachMutex |
324 // to avoid dead lock if another thread is preparing for GC, has acquired | 322 // to avoid dead lock if another thread is preparing for GC, has acquired |
325 // threadAttachMutex and waiting for other threads to pause or reach a | 323 // threadAttachMutex and waiting for other threads to pause or reach a |
326 // safepoint. | 324 // safepoint. |
327 if (!state->isAtSafePoint()) | 325 if (!state->isAtSafePoint()) |
328 state->enterSafePointWithoutPointers(); | 326 state->enterSafePointWithoutPointers(); |
329 MutexLocker locker(threadAttachMutex()); | 327 MutexLocker locker(threadAttachMutex()); |
330 state->leaveSafePoint(); | 328 state->leaveSafePoint(); |
331 attachedThreads().remove(state); | 329 attachedThreads().remove(state); |
332 delete state; | 330 delete state; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 state->safePoint(HeapPointersOnStack); | 775 state->safePoint(HeapPointersOnStack); |
778 } | 776 } |
779 | 777 |
780 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() | 778 ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() |
781 { | 779 { |
782 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); | 780 DEFINE_STATIC_LOCAL(AttachedThreadStateSet, threads, ()); |
783 return threads; | 781 return threads; |
784 } | 782 } |
785 | 783 |
786 } | 784 } |
OLD | NEW |