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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 } | 348 } |
349 | 349 |
350 #if ENABLE(ASSERT) | 350 #if ENABLE(ASSERT) |
351 bool Heap::weakTableRegistered(const void* table) | 351 bool Heap::weakTableRegistered(const void* table) |
352 { | 352 { |
353 ASSERT(s_ephemeronStack); | 353 ASSERT(s_ephemeronStack); |
354 return s_ephemeronStack->hasCallbackForObject(table); | 354 return s_ephemeronStack->hasCallbackForObject(table); |
355 } | 355 } |
356 #endif | 356 #endif |
357 | 357 |
358 void Heap::decommitCallbackStacks() | |
359 { | |
360 s_markingStack->decommit(); | |
sof
2016/02/24 09:29:39
An alternative scheme would be for Heap to reserve
| |
361 s_postMarkingCallbackStack->decommit(); | |
362 s_globalWeakCallbackStack->decommit(); | |
363 s_ephemeronStack->decommit(); | |
364 } | |
365 | |
358 void Heap::preGC() | 366 void Heap::preGC() |
359 { | 367 { |
360 ASSERT(!ThreadState::current()->isInGC()); | 368 ASSERT(!ThreadState::current()->isInGC()); |
361 for (ThreadState* state : ThreadState::attachedThreads()) | 369 for (ThreadState* state : ThreadState::attachedThreads()) |
362 state->preGC(); | 370 state->preGC(); |
363 } | 371 } |
364 | 372 |
365 void Heap::postGC(BlinkGC::GCType gcType) | 373 void Heap::postGC(BlinkGC::GCType gcType) |
366 { | 374 { |
367 ASSERT(ThreadState::current()->isInGC()); | 375 ASSERT(ThreadState::current()->isInGC()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
462 totalObjectSpaceHistogram.count(Heap::allocatedObjectSize() / 1024); | 470 totalObjectSpaceHistogram.count(Heap::allocatedObjectSize() / 1024); |
463 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalAllocatedSpaceHis togram, new CustomCountHistogram("BlinkGC.TotalAllocatedSpace", 0, 4 * 1024 * 10 24, 50)); | 471 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, totalAllocatedSpaceHis togram, new CustomCountHistogram("BlinkGC.TotalAllocatedSpace", 0, 4 * 1024 * 10 24, 50)); |
464 totalAllocatedSpaceHistogram.count(Heap::allocatedSpace() / 1024); | 472 totalAllocatedSpaceHistogram.count(Heap::allocatedSpace() / 1024); |
465 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, gcReasonHistogram, new EnumerationHistogram("BlinkGC.GCReason", BlinkGC::NumberOfGCReason)); | 473 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, gcReasonHistogram, new EnumerationHistogram("BlinkGC.GCReason", BlinkGC::NumberOfGCReason)); |
466 gcReasonHistogram.count(reason); | 474 gcReasonHistogram.count(reason); |
467 | 475 |
468 Heap::reportMemoryUsageHistogram(); | 476 Heap::reportMemoryUsageHistogram(); |
469 WTF::Partitions::reportMemoryUsageHistogram(); | 477 WTF::Partitions::reportMemoryUsageHistogram(); |
470 | 478 |
471 postGC(gcType); | 479 postGC(gcType); |
480 Heap::decommitCallbackStacks(); | |
472 | 481 |
473 #if ENABLE(ASSERT) | 482 #if ENABLE(ASSERT) |
474 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio n. | 483 // 0 is used to figure non-assigned area, so avoid to use 0 in s_gcGeneratio n. |
475 if (++s_gcGeneration == 0) { | 484 if (++s_gcGeneration == 0) { |
476 s_gcGeneration = 1; | 485 s_gcGeneration = 1; |
477 } | 486 } |
478 #endif | 487 #endif |
479 } | 488 } |
480 | 489 |
481 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 490 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
(...skipping 22 matching lines...) Expand all Loading... | |
504 state->visitPersistents(gcScope.visitor()); | 513 state->visitPersistents(gcScope.visitor()); |
505 | 514 |
506 // 2. Trace objects reachable from the thread's persistent roots | 515 // 2. Trace objects reachable from the thread's persistent roots |
507 // including ephemerons. | 516 // including ephemerons. |
508 processMarkingStack(gcScope.visitor()); | 517 processMarkingStack(gcScope.visitor()); |
509 | 518 |
510 postMarkingProcessing(gcScope.visitor()); | 519 postMarkingProcessing(gcScope.visitor()); |
511 globalWeakProcessing(gcScope.visitor()); | 520 globalWeakProcessing(gcScope.visitor()); |
512 | 521 |
513 state->postGC(BlinkGC::GCWithSweep); | 522 state->postGC(BlinkGC::GCWithSweep); |
523 Heap::decommitCallbackStacks(); | |
514 } | 524 } |
515 state->preSweep(); | 525 state->preSweep(); |
516 } | 526 } |
517 | 527 |
518 void Heap::processMarkingStack(Visitor* visitor) | 528 void Heap::processMarkingStack(Visitor* visitor) |
519 { | 529 { |
520 // Ephemeron fixed point loop. | 530 // Ephemeron fixed point loop. |
521 do { | 531 do { |
522 { | 532 { |
523 // Iteratively mark all objects that are reachable from the objects | 533 // Iteratively mark all objects that are reachable from the objects |
(...skipping 16 matching lines...) Expand all Loading... | |
540 void Heap::postMarkingProcessing(Visitor* visitor) | 550 void Heap::postMarkingProcessing(Visitor* visitor) |
541 { | 551 { |
542 TRACE_EVENT0("blink_gc", "Heap::postMarkingProcessing"); | 552 TRACE_EVENT0("blink_gc", "Heap::postMarkingProcessing"); |
543 // Call post-marking callbacks including: | 553 // Call post-marking callbacks including: |
544 // 1. the ephemeronIterationDone callbacks on weak tables to do cleanup | 554 // 1. the ephemeronIterationDone callbacks on weak tables to do cleanup |
545 // (specifically to clear the queued bits for weak hash tables), and | 555 // (specifically to clear the queued bits for weak hash tables), and |
546 // 2. the markNoTracing callbacks on collection backings to mark them | 556 // 2. the markNoTracing callbacks on collection backings to mark them |
547 // if they are only reachable from their front objects. | 557 // if they are only reachable from their front objects. |
548 while (popAndInvokePostMarkingCallback(visitor)) { } | 558 while (popAndInvokePostMarkingCallback(visitor)) { } |
549 | 559 |
550 s_ephemeronStack->clear(); | |
551 | |
552 // Post-marking callbacks should not trace any objects and | 560 // Post-marking callbacks should not trace any objects and |
553 // therefore the marking stack should be empty after the | 561 // therefore the marking stack should be empty after the |
554 // post-marking callbacks. | 562 // post-marking callbacks. |
555 ASSERT(s_markingStack->isEmpty()); | 563 ASSERT(s_markingStack->isEmpty()); |
556 } | 564 } |
557 | 565 |
558 void Heap::globalWeakProcessing(Visitor* visitor) | 566 void Heap::globalWeakProcessing(Visitor* visitor) |
559 { | 567 { |
560 TRACE_EVENT0("blink_gc", "Heap::globalWeakProcessing"); | 568 TRACE_EVENT0("blink_gc", "Heap::globalWeakProcessing"); |
561 double startTime = WTF::currentTimeMS(); | 569 double startTime = WTF::currentTimeMS(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
726 size_t Heap::s_wrapperCountAtLastGC = 0; | 734 size_t Heap::s_wrapperCountAtLastGC = 0; |
727 size_t Heap::s_collectedWrapperCount = 0; | 735 size_t Heap::s_collectedWrapperCount = 0; |
728 size_t Heap::s_partitionAllocSizeAtLastGC = 0; | 736 size_t Heap::s_partitionAllocSizeAtLastGC = 0; |
729 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 737 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
730 bool Heap::s_isLowEndDevice = false; | 738 bool Heap::s_isLowEndDevice = false; |
731 #if ENABLE(ASSERT) | 739 #if ENABLE(ASSERT) |
732 uint16_t Heap::s_gcGeneration = 0; | 740 uint16_t Heap::s_gcGeneration = 0; |
733 #endif | 741 #endif |
734 | 742 |
735 } // namespace blink | 743 } // namespace blink |
OLD | NEW |