| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // pointers into the heap owned by this thread. | 236 // pointers into the heap owned by this thread. |
| 237 m_isTerminating = true; | 237 m_isTerminating = true; |
| 238 | 238 |
| 239 // Set the terminate flag on all heap pages of this thread. This is used
to | 239 // Set the terminate flag on all heap pages of this thread. This is used
to |
| 240 // ensure we don't trace pages on other threads that are not part of the | 240 // ensure we don't trace pages on other threads that are not part of the |
| 241 // thread local GC. | 241 // thread local GC. |
| 242 prepareHeapForTermination(); | 242 prepareHeapForTermination(); |
| 243 | 243 |
| 244 // Do thread local GC's as long as the count of thread local Persistents | 244 // Do thread local GC's as long as the count of thread local Persistents |
| 245 // changes and is above zero. | 245 // changes and is above zero. |
| 246 PersistentAnchor* anchor = static_cast<PersistentAnchor*>(m_persistents.
get()); | 246 PersistentAnchor* anchor = m_persistents.get(); |
| 247 int oldCount = -1; | 247 int oldCount = -1; |
| 248 int currentCount = anchor->numberOfPersistents(); | 248 int currentCount = anchor->numberOfPersistents(); |
| 249 ASSERT(currentCount >= 0); | 249 ASSERT(currentCount >= 0); |
| 250 while (currentCount != oldCount) { | 250 while (currentCount != oldCount) { |
| 251 Heap::collectGarbageForTerminatingThread(this); | 251 Heap::collectGarbageForTerminatingThread(this); |
| 252 oldCount = currentCount; | 252 oldCount = currentCount; |
| 253 currentCount = anchor->numberOfPersistents(); | 253 currentCount = anchor->numberOfPersistents(); |
| 254 } | 254 } |
| 255 // We should not have any persistents left when getting to this point, | 255 // We should not have any persistents left when getting to this point, |
| 256 // if we have it is probably a bug so adding a debug ASSERT to catch thi
s. | 256 // if we have it is probably a bug so adding a debug ASSERT to catch thi
s. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 void ThreadState::visitPersistentRoots(Visitor* visitor) | 280 void ThreadState::visitPersistentRoots(Visitor* visitor) |
| 281 { | 281 { |
| 282 TRACE_EVENT0("blink_gc", "ThreadState::visitPersistentRoots"); | 282 TRACE_EVENT0("blink_gc", "ThreadState::visitPersistentRoots"); |
| 283 { | 283 { |
| 284 // All threads are at safepoints so this is not strictly necessary. | 284 // All threads are at safepoints so this is not strictly necessary. |
| 285 // However we acquire the mutex to make mutation and traversal of this | 285 // However we acquire the mutex to make mutation and traversal of this |
| 286 // list symmetrical. | 286 // list symmetrical. |
| 287 MutexLocker locker(globalRootsMutex()); | 287 MutexLocker locker(globalRootsMutex()); |
| 288 globalRoots().trace(visitor); | 288 globalRoots().tracePersistentNodes(visitor); |
| 289 } | 289 } |
| 290 | 290 |
| 291 for (ThreadState* state : attachedThreads()) | 291 for (ThreadState* state : attachedThreads()) |
| 292 state->visitPersistents(visitor); | 292 state->visitPersistents(visitor); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void ThreadState::visitStackRoots(Visitor* visitor) | 295 void ThreadState::visitStackRoots(Visitor* visitor) |
| 296 { | 296 { |
| 297 TRACE_EVENT0("blink_gc", "ThreadState::visitStackRoots"); | 297 TRACE_EVENT0("blink_gc", "ThreadState::visitStackRoots"); |
| 298 for (ThreadState* state : attachedThreads()) | 298 for (ThreadState* state : attachedThreads()) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // See the comment above. | 366 // See the comment above. |
| 367 __msan_unpoison(&ptr, sizeof(ptr)); | 367 __msan_unpoison(&ptr, sizeof(ptr)); |
| 368 #endif | 368 #endif |
| 369 Heap::checkAndMarkPointer(visitor, ptr); | 369 Heap::checkAndMarkPointer(visitor, ptr); |
| 370 visitAsanFakeStackForPointer(visitor, ptr); | 370 visitAsanFakeStackForPointer(visitor, ptr); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 void ThreadState::visitPersistents(Visitor* visitor) | 374 void ThreadState::visitPersistents(Visitor* visitor) |
| 375 { | 375 { |
| 376 m_persistents->trace(visitor); | 376 m_persistents->tracePersistentNodes(visitor); |
| 377 if (m_traceDOMWrappers) { | 377 if (m_traceDOMWrappers) { |
| 378 TRACE_EVENT0("blink_gc", "V8GCController::traceDOMWrappers"); | 378 TRACE_EVENT0("blink_gc", "V8GCController::traceDOMWrappers"); |
| 379 m_traceDOMWrappers(m_isolate, visitor); | 379 m_traceDOMWrappers(m_isolate, visitor); |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 | 382 |
| 383 #if ENABLE(GC_PROFILING) | 383 #if ENABLE(GC_PROFILING) |
| 384 const GCInfo* ThreadState::findGCInfo(Address address) | 384 const GCInfo* ThreadState::findGCInfo(Address address) |
| 385 { | 385 { |
| 386 if (BasePage* page = findPageFromAddress(address)) | 386 if (BasePage* page = findPageFromAddress(address)) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 // TODO(Oilpan): Avoid calling weak callbacks for dead objects. | 506 // TODO(Oilpan): Avoid calling weak callbacks for dead objects. |
| 507 // We can do that by checking isHeapObjectAlive(object) before | 507 // We can do that by checking isHeapObjectAlive(object) before |
| 508 // calling the weak callback, but in that case Callback::Item | 508 // calling the weak callback, but in that case Callback::Item |
| 509 // needs to understand T*. | 509 // needs to understand T*. |
| 510 item->call(visitor); | 510 item->call(visitor); |
| 511 return true; | 511 return true; |
| 512 } | 512 } |
| 513 return false; | 513 return false; |
| 514 } | 514 } |
| 515 | 515 |
| 516 PersistentNode& ThreadState::globalRoots() | 516 PersistentAnchor& ThreadState::globalRoots() |
| 517 { | 517 { |
| 518 AtomicallyInitializedStaticReference(PersistentNode, anchor, new PersistentA
nchor); | 518 AtomicallyInitializedStaticReference(PersistentAnchor, anchor, new Persisten
tAnchor); |
| 519 return anchor; | 519 return anchor; |
| 520 } | 520 } |
| 521 | 521 |
| 522 Mutex& ThreadState::globalRootsMutex() | 522 Mutex& ThreadState::globalRootsMutex() |
| 523 { | 523 { |
| 524 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex); | 524 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex); |
| 525 return mutex; | 525 return mutex; |
| 526 } | 526 } |
| 527 | 527 |
| 528 // TODO(haraken): We should improve the GC heuristics. | 528 // TODO(haraken): We should improve the GC heuristics. |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 json->beginArray(it->key.ascii().data()); | 1407 json->beginArray(it->key.ascii().data()); |
| 1408 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1408 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1409 json->pushInteger(it->value.ages[age]); | 1409 json->pushInteger(it->value.ages[age]); |
| 1410 json->endArray(); | 1410 json->endArray(); |
| 1411 } | 1411 } |
| 1412 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1412 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
| 1413 } | 1413 } |
| 1414 #endif | 1414 #endif |
| 1415 | 1415 |
| 1416 } // namespace blink | 1416 } // namespace blink |
| OLD | NEW |