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