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

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: review iteration + rebase 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
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
937 // Mirroring the completeSweep() condition; see its comment.
938 if (sweepForbidden())
939 return;
940
941 ThreadState::SweepForbiddenScope scope(this);
942 {
943 if (isMainThread())
944 ScriptForbiddenScope::enter();
945
946 m_heaps[EagerSweepHeapIndex]->completeSweep();
947
948 if (isMainThread())
949 ScriptForbiddenScope::exit();
950 }
951 }
952
929 void ThreadState::completeSweep() 953 void ThreadState::completeSweep()
930 { 954 {
931 // If we are not in a sweeping phase, there is nothing to do here. 955 // If we are not in a sweeping phase, there is nothing to do here.
932 if (!isSweepingInProgress()) 956 if (!isSweepingInProgress())
933 return; 957 return;
934 958
935 // completeSweep() can be called recursively if finalizers can allocate 959 // completeSweep() can be called recursively if finalizers can allocate
936 // memory and the allocation triggers completeSweep(). This check prevents 960 // memory and the allocation triggers completeSweep(). This check prevents
937 // the sweeping from being executed recursively. 961 // the sweeping from being executed recursively.
938 if (sweepForbidden()) 962 if (sweepForbidden())
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 json->beginArray(it->key.ascii().data()); 1332 json->beginArray(it->key.ascii().data());
1309 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1333 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1310 json->pushInteger(it->value.ages[age]); 1334 json->pushInteger(it->value.ages[age]);
1311 json->endArray(); 1335 json->endArray();
1312 } 1336 }
1313 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1337 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1314 } 1338 }
1315 #endif 1339 #endif
1316 1340
1317 } // namespace blink 1341 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698