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

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

Issue 1157933002: Oilpan: introduce eager finalization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove HeapIndexTrait + tidy up Created 5 years, 6 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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); 906 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers");
907 invokePreFinalizers(*Heap::s_markingVisitor); 907 invokePreFinalizers(*Heap::s_markingVisitor);
908 } 908 }
909 } 909 }
910 910
911 if (isMainThread()) 911 if (isMainThread())
912 ScriptForbiddenScope::exit(); 912 ScriptForbiddenScope::exit();
913 } 913 }
914 914
915 #if defined(ADDRESS_SANITIZER) 915 #if defined(ADDRESS_SANITIZER)
916 // TODO(Oilpan): enable the poisoning always. 916 poisonEagerHeaps(true);
917 #if ENABLE(OILPAN)
918 for (int i = 0; i < NumberOfHeaps; i++)
919 m_heaps[i]->poisonUnmarkedObjects();
920 #endif
921 #endif 917 #endif
922 918
923 #if ENABLE(OILPAN) 919 #if ENABLE(OILPAN)
924 if (gcState() == EagerSweepScheduled) { 920 if (gcState() == EagerSweepScheduled) {
925 // Eager sweeping should happen only in testing. 921 // Eager sweeping should happen only in testing.
926 setGCState(Sweeping); 922 setGCState(Sweeping);
923 eagerSweep();
924 #if defined(ADDRESS_SANITIZER)
925 poisonHeapsForCompleteSweep();
haraken 2015/05/28 12:30:04 poisonEagerHeaps => poisonEagerHeap poisonHeapsFor
sof 2015/05/29 21:25:08 Done.
926 #endif
927 completeSweep(); 927 completeSweep();
928 } else { 928 } else {
929 // The default behavior is lazy sweeping. 929 // The default behavior is lazy sweeping.
930 setGCState(Sweeping); 930 setGCState(Sweeping);
931 eagerSweep(); 931 eagerSweep();
932 #if defined(ADDRESS_SANITIZER)
933 poisonHeapsForCompleteSweep();
934 #endif
932 scheduleIdleLazySweep(); 935 scheduleIdleLazySweep();
933 } 936 }
934 #else 937 #else
935 // FIXME: For now, we disable lazy sweeping in non-oilpan builds 938 // FIXME: For now, we disable lazy sweeping in non-oilpan builds
936 // to avoid unacceptable behavior regressions on trunk. 939 // to avoid unacceptable behavior regressions on trunk.
937 setGCState(Sweeping); 940 setGCState(Sweeping);
938 completeSweep(); 941 completeSweep();
939 #endif 942 #endif
940 943
941 #if ENABLE(GC_PROFILING) 944 #if ENABLE(GC_PROFILING)
942 snapshotFreeListIfNecessary(); 945 snapshotFreeListIfNecessary();
943 #endif 946 #endif
944 } 947 }
945 948
949 #if defined(ADDRESS_SANITIZER)
950 void ThreadState::poisonHeapsForCompleteSweep()
951 {
952 // TODO(Oilpan): enable the poisoning always.
953 #if ENABLE(OILPAN)
954 // Unpoison the live objects remaining in the eager heaps..
955 poisonEagerHeaps(false);
956 // ..along with poisoning all unmarked objects in the other heaps.
957 for (int i = 1; i < NumberOfHeaps; i++)
958 m_heaps[i]->poisonUnmarkedObjects();
959 #endif
960 }
961
962 void ThreadState::poisonEagerHeaps(bool poisonOrNot)
963 {
964 // TODO(Oilpan): enable the poisoning always.
965 #if ENABLE(OILPAN)
966 m_heaps[EagerSweepHeapIndex]->poisonHeap(poisonOrNot);
967 #endif
968 }
969 #endif
970
946 void ThreadState::eagerSweep() 971 void ThreadState::eagerSweep()
947 { 972 {
948 // Some objects need to be finalized promptly and cannot be handled 973 // Some objects need to be finalized promptly and cannot be handled
949 // by lazy sweeping. Keep those in a designated heap and sweep it 974 // by lazy sweeping. Keep those in a designated heap and sweep it
950 // eagerly. 975 // eagerly.
951 ASSERT(isSweepingInProgress()); 976 ASSERT(isSweepingInProgress());
952 977
953 // Mirroring the completeSweep() condition; see its comment. 978 // Mirroring the completeSweep() condition; see its comment.
954 if (sweepForbidden()) 979 if (sweepForbidden())
955 return; 980 return;
(...skipping 23 matching lines...) Expand all
979 return; 1004 return;
980 1005
981 ThreadState::SweepForbiddenScope scope(this); 1006 ThreadState::SweepForbiddenScope scope(this);
982 { 1007 {
983 if (isMainThread()) 1008 if (isMainThread())
984 ScriptForbiddenScope::enter(); 1009 ScriptForbiddenScope::enter();
985 1010
986 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep"); 1011 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep");
987 double timeStamp = WTF::currentTimeMS(); 1012 double timeStamp = WTF::currentTimeMS();
988 1013
1014 static_assert(EagerSweepHeapIndex == 0, "Eagerly swept heaps must be pro cessed first.");
989 for (int i = 0; i < NumberOfHeaps; i++) 1015 for (int i = 0; i < NumberOfHeaps; i++)
990 m_heaps[i]->completeSweep(); 1016 m_heaps[i]->completeSweep();
991 1017
992 Platform::current()->histogramCustomCounts("BlinkGC.CompleteSweep", WTF: :currentTimeMS() - timeStamp, 0, 10 * 1000, 50); 1018 Platform::current()->histogramCustomCounts("BlinkGC.CompleteSweep", WTF: :currentTimeMS() - timeStamp, 0, 10 * 1000, 50);
993 1019
994 if (isMainThread()) 1020 if (isMainThread())
995 ScriptForbiddenScope::exit(); 1021 ScriptForbiddenScope::exit();
996 } 1022 }
997 1023
998 postSweep(); 1024 postSweep();
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 json->beginArray(it->key.ascii().data()); 1374 json->beginArray(it->key.ascii().data());
1349 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1375 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1350 json->pushInteger(it->value.ages[age]); 1376 json->pushInteger(it->value.ages[age]);
1351 json->endArray(); 1377 json->endArray();
1352 } 1378 }
1353 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1379 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1354 } 1380 }
1355 #endif 1381 #endif
1356 1382
1357 } // namespace blink 1383 } // namespace blink
OLDNEW
« Source/platform/heap/Heap.cpp ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698