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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 void ThreadState::schedulePreciseGC() | 620 void ThreadState::schedulePreciseGC() |
621 { | 621 { |
622 if (isSweepingInProgress()) { | 622 if (isSweepingInProgress()) { |
623 setGCState(SweepingAndPreciseGCScheduled); | 623 setGCState(SweepingAndPreciseGCScheduled); |
624 return; | 624 return; |
625 } | 625 } |
626 | 626 |
627 setGCState(PreciseGCScheduled); | 627 setGCState(PreciseGCScheduled); |
628 } | 628 } |
629 | 629 |
630 namespace { | |
631 | |
632 #define UNEXPECTED_GCSTATE(s) case ThreadState::s: RELEASE_ASSERT_WITH_MESSAGE(f alse, "Unexpected transition while in GCState " #s); return | |
633 | |
634 void unexpectedGCState(ThreadState::GCState gcState) | |
635 { | |
636 switch (gcState) { | |
637 UNEXPECTED_GCSTATE(NoGCScheduled); | |
sof
2015/03/13 10:49:32
The presubmit script enforced this indentation.
| |
638 UNEXPECTED_GCSTATE(IdleGCScheduled); | |
639 UNEXPECTED_GCSTATE(PreciseGCScheduled); | |
640 UNEXPECTED_GCSTATE(GCScheduledForTesting); | |
641 UNEXPECTED_GCSTATE(StoppingOtherThreads); | |
642 UNEXPECTED_GCSTATE(GCRunning); | |
643 UNEXPECTED_GCSTATE(EagerSweepScheduled); | |
644 UNEXPECTED_GCSTATE(LazySweepScheduled); | |
645 UNEXPECTED_GCSTATE(Sweeping); | |
646 UNEXPECTED_GCSTATE(SweepingAndIdleGCScheduled); | |
647 UNEXPECTED_GCSTATE(SweepingAndPreciseGCScheduled); | |
648 default: | |
649 ASSERT_NOT_REACHED(); | |
650 return; | |
651 } | |
652 } | |
653 | |
654 #undef UNEXPECTED_GCSTATE | |
655 | |
656 } // namespace | |
657 | |
658 #define VERIFY_STATE_TRANSITION(condition) if (UNLIKELY(!(condition))) unexpecte dGCState(m_gcState) | |
659 | |
630 void ThreadState::setGCState(GCState gcState) | 660 void ThreadState::setGCState(GCState gcState) |
631 { | 661 { |
632 switch (gcState) { | 662 switch (gcState) { |
633 case NoGCScheduled: | 663 case NoGCScheduled: |
634 checkThread(); | 664 checkThread(); |
635 RELEASE_ASSERT(m_gcState == StoppingOtherThreads || m_gcState == Sweepin g || m_gcState == SweepingAndIdleGCScheduled); | 665 VERIFY_STATE_TRANSITION(m_gcState == StoppingOtherThreads || m_gcState = = Sweeping || m_gcState == SweepingAndIdleGCScheduled); |
636 break; | 666 break; |
637 case IdleGCScheduled: | 667 case IdleGCScheduled: |
638 case PreciseGCScheduled: | 668 case PreciseGCScheduled: |
639 case GCScheduledForTesting: | 669 case GCScheduledForTesting: |
640 checkThread(); | 670 checkThread(); |
641 RELEASE_ASSERT(m_gcState == NoGCScheduled || m_gcState == IdleGCSchedule d || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTesting || m_ gcState == StoppingOtherThreads || m_gcState == SweepingAndIdleGCScheduled || m_ gcState == SweepingAndPreciseGCScheduled); | 671 VERIFY_STATE_TRANSITION(m_gcState == NoGCScheduled || m_gcState == IdleG CScheduled || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTest ing || m_gcState == StoppingOtherThreads || m_gcState == SweepingAndIdleGCSchedu led || m_gcState == SweepingAndPreciseGCScheduled); |
642 completeSweep(); | 672 completeSweep(); |
643 break; | 673 break; |
644 case StoppingOtherThreads: | 674 case StoppingOtherThreads: |
645 checkThread(); | 675 checkThread(); |
646 RELEASE_ASSERT(m_gcState == NoGCScheduled || m_gcState == IdleGCSchedule d || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTesting || m_ gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled || m_gcState == S weepingAndPreciseGCScheduled); | 676 VERIFY_STATE_TRANSITION(m_gcState == NoGCScheduled || m_gcState == IdleG CScheduled || m_gcState == PreciseGCScheduled || m_gcState == GCScheduledForTest ing || m_gcState == Sweeping || m_gcState == SweepingAndIdleGCScheduled || m_gcS tate == SweepingAndPreciseGCScheduled); |
647 completeSweep(); | 677 completeSweep(); |
648 break; | 678 break; |
649 case GCRunning: | 679 case GCRunning: |
650 ASSERT(!isInGC()); | 680 ASSERT(!isInGC()); |
651 RELEASE_ASSERT(m_gcState != GCRunning); | 681 VERIFY_STATE_TRANSITION(m_gcState != GCRunning); |
652 break; | 682 break; |
653 case EagerSweepScheduled: | 683 case EagerSweepScheduled: |
654 case LazySweepScheduled: | 684 case LazySweepScheduled: |
655 ASSERT(isInGC()); | 685 ASSERT(isInGC()); |
656 RELEASE_ASSERT(m_gcState == GCRunning); | 686 VERIFY_STATE_TRANSITION(m_gcState == GCRunning); |
657 break; | 687 break; |
658 case Sweeping: | 688 case Sweeping: |
659 checkThread(); | 689 checkThread(); |
660 RELEASE_ASSERT(m_gcState == EagerSweepScheduled || m_gcState == LazySwee pScheduled); | 690 VERIFY_STATE_TRANSITION(m_gcState == EagerSweepScheduled || m_gcState == LazySweepScheduled); |
661 break; | 691 break; |
662 case SweepingAndIdleGCScheduled: | 692 case SweepingAndIdleGCScheduled: |
663 case SweepingAndPreciseGCScheduled: | 693 case SweepingAndPreciseGCScheduled: |
664 checkThread(); | 694 checkThread(); |
665 RELEASE_ASSERT(m_gcState == Sweeping || m_gcState == SweepingAndIdleGCSc heduled || m_gcState == SweepingAndPreciseGCScheduled || m_gcState == StoppingOt herThreads); | 695 VERIFY_STATE_TRANSITION(m_gcState == Sweeping || m_gcState == SweepingAn dIdleGCScheduled || m_gcState == SweepingAndPreciseGCScheduled || m_gcState == S toppingOtherThreads); |
666 break; | 696 break; |
667 default: | 697 default: |
668 ASSERT_NOT_REACHED(); | 698 ASSERT_NOT_REACHED(); |
669 } | 699 } |
670 m_gcState = gcState; | 700 m_gcState = gcState; |
671 } | 701 } |
672 | 702 |
703 #undef VERIFY_STATE_TRANSITION | |
704 | |
673 ThreadState::GCState ThreadState::gcState() const | 705 ThreadState::GCState ThreadState::gcState() const |
674 { | 706 { |
675 return m_gcState; | 707 return m_gcState; |
676 } | 708 } |
677 | 709 |
678 void ThreadState::didV8GC() | 710 void ThreadState::didV8GC() |
679 { | 711 { |
680 checkThread(); | 712 checkThread(); |
681 m_didV8GCAfterLastGC = true; | 713 m_didV8GCAfterLastGC = true; |
682 } | 714 } |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1199 json->beginArray(it->key.ascii().data()); | 1231 json->beginArray(it->key.ascii().data()); |
1200 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1232 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
1201 json->pushInteger(it->value.ages[age]); | 1233 json->pushInteger(it->value.ages[age]); |
1202 json->endArray(); | 1234 json->endArray(); |
1203 } | 1235 } |
1204 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | 1236 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); |
1205 } | 1237 } |
1206 #endif | 1238 #endif |
1207 | 1239 |
1208 } // namespace blink | 1240 } // namespace blink |
OLD | NEW |