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

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: Parameterize Heap::poisonHeap() over ObjectsToPoison 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
« 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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); 912 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers");
913 invokePreFinalizers(*Heap::s_markingVisitor); 913 invokePreFinalizers(*Heap::s_markingVisitor);
914 } 914 }
915 } 915 }
916 916
917 if (isMainThread()) 917 if (isMainThread())
918 ScriptForbiddenScope::exit(); 918 ScriptForbiddenScope::exit();
919 } 919 }
920 920
921 #if defined(ADDRESS_SANITIZER) 921 #if defined(ADDRESS_SANITIZER)
922 // TODO(Oilpan): enable the poisoning always. 922 poisonEagerHeap(SetPoison);
923 #if ENABLE(OILPAN)
924 for (int i = 0; i < NumberOfHeaps; i++)
925 m_heaps[i]->poisonUnmarkedObjects();
926 #endif
927 #endif 923 #endif
928 924
929 #if ENABLE_LAZY_SWEEPING 925 #if ENABLE_LAZY_SWEEPING
930 if (gcState() == EagerSweepScheduled) { 926 if (gcState() == EagerSweepScheduled) {
931 // Eager sweeping should happen only in testing. 927 // Eager sweeping should happen only in testing.
932 setGCState(Sweeping); 928 setGCState(Sweeping);
929 eagerSweep();
930 #if defined(ADDRESS_SANITIZER)
931 poisonAllHeaps();
932 #endif
933 completeSweep(); 933 completeSweep();
934 } else { 934 } else {
935 // The default behavior is lazy sweeping. 935 // The default behavior is lazy sweeping.
936 setGCState(Sweeping); 936 setGCState(Sweeping);
937 eagerSweep(); 937 eagerSweep();
938 #if defined(ADDRESS_SANITIZER)
939 poisonAllHeaps();
940 #endif
938 scheduleIdleLazySweep(); 941 scheduleIdleLazySweep();
939 } 942 }
940 #else 943 #else
941 setGCState(Sweeping); 944 setGCState(Sweeping);
942 completeSweep(); 945 completeSweep();
943 #endif 946 #endif
944 947
945 #if ENABLE(GC_PROFILING) 948 #if ENABLE(GC_PROFILING)
946 snapshotFreeListIfNecessary(); 949 snapshotFreeListIfNecessary();
947 #endif 950 #endif
948 } 951 }
949 952
953 #if defined(ADDRESS_SANITIZER)
954 void ThreadState::poisonAllHeaps()
955 {
956 // TODO(Oilpan): enable the poisoning always.
957 #if ENABLE(OILPAN)
958 // Unpoison the live objects remaining in the eager heaps..
959 poisonEagerHeap(ClearPoison);
960 // ..along with poisoning all unmarked objects in the other heaps.
961 for (int i = 1; i < NumberOfHeaps; i++)
962 m_heaps[i]->poisonHeap(UnmarkedOnly, SetPoison);
963 #endif
964 }
965
966 void ThreadState::poisonEagerHeap(Poisoning poisoning)
967 {
968 // TODO(Oilpan): enable the poisoning always.
969 #if ENABLE(OILPAN)
970 m_heaps[EagerSweepHeapIndex]->poisonHeap(MarkedAndUnmarked, poisoning);
971 #endif
972 }
973 #endif
974
950 void ThreadState::eagerSweep() 975 void ThreadState::eagerSweep()
951 { 976 {
952 // Some objects need to be finalized promptly and cannot be handled 977 // Some objects need to be finalized promptly and cannot be handled
953 // by lazy sweeping. Keep those in a designated heap and sweep it 978 // by lazy sweeping. Keep those in a designated heap and sweep it
954 // eagerly. 979 // eagerly.
955 ASSERT(isSweepingInProgress()); 980 ASSERT(isSweepingInProgress());
956 981
957 // Mirroring the completeSweep() condition; see its comment. 982 // Mirroring the completeSweep() condition; see its comment.
958 if (sweepForbidden()) 983 if (sweepForbidden())
959 return; 984 return;
(...skipping 23 matching lines...) Expand all
983 return; 1008 return;
984 1009
985 ThreadState::SweepForbiddenScope scope(this); 1010 ThreadState::SweepForbiddenScope scope(this);
986 { 1011 {
987 if (isMainThread()) 1012 if (isMainThread())
988 ScriptForbiddenScope::enter(); 1013 ScriptForbiddenScope::enter();
989 1014
990 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep"); 1015 TRACE_EVENT0("blink_gc", "ThreadState::completeSweep");
991 double timeStamp = WTF::currentTimeMS(); 1016 double timeStamp = WTF::currentTimeMS();
992 1017
1018 static_assert(EagerSweepHeapIndex == 0, "Eagerly swept heaps must be pro cessed first.");
993 for (int i = 0; i < NumberOfHeaps; i++) 1019 for (int i = 0; i < NumberOfHeaps; i++)
994 m_heaps[i]->completeSweep(); 1020 m_heaps[i]->completeSweep();
995 1021
996 Platform::current()->histogramCustomCounts("BlinkGC.CompleteSweep", WTF: :currentTimeMS() - timeStamp, 0, 10 * 1000, 50); 1022 Platform::current()->histogramCustomCounts("BlinkGC.CompleteSweep", WTF: :currentTimeMS() - timeStamp, 0, 10 * 1000, 50);
997 1023
998 if (isMainThread()) 1024 if (isMainThread())
999 ScriptForbiddenScope::exit(); 1025 ScriptForbiddenScope::exit();
1000 } 1026 }
1001 1027
1002 postSweep(); 1028 postSweep();
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 json->beginArray(it->key.ascii().data()); 1377 json->beginArray(it->key.ascii().data());
1352 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1378 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1353 json->pushInteger(it->value.ages[age]); 1379 json->pushInteger(it->value.ages[age]);
1354 json->endArray(); 1380 json->endArray();
1355 } 1381 }
1356 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1382 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1357 } 1383 }
1358 #endif 1384 #endif
1359 1385
1360 } // namespace blink 1386 } // 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