Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: Source/platform/heap/ThreadState.cpp

Issue 1138663002: Oilpan: support eager finalization/sweeping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase + introduce OILPAN_EAGERLY_SWEEP() Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 #endif 905 #endif
906 906
907 #if ENABLE(OILPAN) 907 #if ENABLE(OILPAN)
908 if (gcState() == EagerSweepScheduled) { 908 if (gcState() == EagerSweepScheduled) {
909 // Eager sweeping should happen only in testing. 909 // Eager sweeping should happen only in testing.
910 setGCState(Sweeping); 910 setGCState(Sweeping);
911 completeSweep(); 911 completeSweep();
912 } else { 912 } else {
913 // The default behavior is lazy sweeping. 913 // The default behavior is lazy sweeping.
914 setGCState(Sweeping); 914 setGCState(Sweeping);
915 eagerSweep();
915 scheduleIdleLazySweep(); 916 scheduleIdleLazySweep();
916 } 917 }
917 #else 918 #else
918 // FIXME: For now, we disable lazy sweeping in non-oilpan builds 919 // FIXME: For now, we disable lazy sweeping in non-oilpan builds
919 // to avoid unacceptable behavior regressions on trunk. 920 // to avoid unacceptable behavior regressions on trunk.
920 setGCState(Sweeping); 921 setGCState(Sweeping);
921 completeSweep(); 922 completeSweep();
922 #endif 923 #endif
923 924
924 #if ENABLE(GC_PROFILING) 925 #if ENABLE(GC_PROFILING)
925 snapshotFreeListIfNecessary(); 926 snapshotFreeListIfNecessary();
926 #endif 927 #endif
927 } 928 }
928 929
930 void ThreadState::eagerSweep()
931 {
932 // Some objects need to be finalized promptly and cannot be handled
933 // by lazy sweeping. Keep those in a designated heap and sweep it
934 // eagerly.
935 ASSERT(isSweepingInProgress());
936 ASSERT(!sweepForbidden());
haraken 2015/05/19 23:23:37 I think this should be: if (sweepForbidden())
sof 2015/05/20 09:43:01 Done + xref'ed the comment.
937
938 ThreadState::SweepForbiddenScope scope(this);
939 {
940 if (isMainThread())
941 ScriptForbiddenScope::enter();
942
943 TRACE_EVENT0("blink_gc", "ThreadState::eagerSweep");
944 double timeStamp = WTF::currentTimeMS();
haraken 2015/05/19 23:23:37 Remove this (see below).
sof 2015/05/20 09:43:01 Removed.
945
946 m_heaps[EagerSweepHeapIndex]->completeSweep();
947
948 Platform::current()->histogramCustomCounts("BlinkGC.EagerSweep", WTF::cu rrentTimeMS() - timeStamp, 0, 10 * 1000, 50);
haraken 2015/05/19 23:23:37 This UMA doesn't exist (and wouldn't be worth addi
949
950 if (isMainThread())
951 ScriptForbiddenScope::exit();
952 }
953 }
954
929 void ThreadState::completeSweep() 955 void ThreadState::completeSweep()
930 { 956 {
931 // If we are not in a sweeping phase, there is nothing to do here. 957 // If we are not in a sweeping phase, there is nothing to do here.
932 if (!isSweepingInProgress()) 958 if (!isSweepingInProgress())
933 return; 959 return;
934 960
935 // completeSweep() can be called recursively if finalizers can allocate 961 // completeSweep() can be called recursively if finalizers can allocate
936 // memory and the allocation triggers completeSweep(). This check prevents 962 // memory and the allocation triggers completeSweep(). This check prevents
937 // the sweeping from being executed recursively. 963 // the sweeping from being executed recursively.
938 if (sweepForbidden()) 964 if (sweepForbidden())
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 json->beginArray(it->key.ascii().data()); 1334 json->beginArray(it->key.ascii().data());
1309 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1335 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1310 json->pushInteger(it->value.ages[age]); 1336 json->pushInteger(it->value.ages[age]);
1311 json->endArray(); 1337 json->endArray();
1312 } 1338 }
1313 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1339 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1314 } 1340 }
1315 #endif 1341 #endif
1316 1342
1317 } // namespace blink 1343 } // namespace blink
OLDNEW
« Source/platform/heap/Heap.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698