| 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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 | 897 |
| 898 { | 898 { |
| 899 if (isMainThread()) | 899 if (isMainThread()) |
| 900 ScriptForbiddenScope::enter(); | 900 ScriptForbiddenScope::enter(); |
| 901 | 901 |
| 902 SweepForbiddenScope forbiddenScope(this); | 902 SweepForbiddenScope forbiddenScope(this); |
| 903 { | 903 { |
| 904 // Disallow allocation during weak processing. | 904 // Disallow allocation during weak processing. |
| 905 NoAllocationScope noAllocationScope(this); | 905 NoAllocationScope noAllocationScope(this); |
| 906 { | 906 { |
| 907 // Perform thread-specific weak processing. |
| 907 TRACE_EVENT0("blink_gc", "ThreadState::threadLocalWeakProcessing
"); | 908 TRACE_EVENT0("blink_gc", "ThreadState::threadLocalWeakProcessing
"); |
| 908 // Perform thread-specific weak processing. | 909 // TODO(haraken): It is wrong to unconditionally use |
| 910 // s_markingVisitor, which is for GlobalMarking. |
| 911 // ThreadTerminationGC should use a visitor for |
| 912 // ThreadLocalMarking. However, a better fix is just to remove |
| 913 // the visitor parameter. The only user of the visitor parameter |
| 914 // is HashTable::process. |
| 909 while (popAndInvokeThreadLocalWeakCallback(Heap::s_markingVisito
r)) { } | 915 while (popAndInvokeThreadLocalWeakCallback(Heap::s_markingVisito
r)) { } |
| 910 } | 916 } |
| 911 { | 917 { |
| 912 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); | 918 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); |
| 913 invokePreFinalizers(*Heap::s_markingVisitor); | 919 invokePreFinalizers(); |
| 914 } | 920 } |
| 915 } | 921 } |
| 916 | 922 |
| 917 if (isMainThread()) | 923 if (isMainThread()) |
| 918 ScriptForbiddenScope::exit(); | 924 ScriptForbiddenScope::exit(); |
| 919 } | 925 } |
| 920 | 926 |
| 921 #if defined(ADDRESS_SANITIZER) | 927 #if defined(ADDRESS_SANITIZER) |
| 922 // TODO(Oilpan): enable the poisoning always. | 928 // TODO(Oilpan): enable the poisoning always. |
| 923 #if ENABLE(OILPAN) | 929 #if ENABLE(OILPAN) |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 void ThreadState::unregisterPreFinalizerInternal(void* target) | 1210 void ThreadState::unregisterPreFinalizerInternal(void* target) |
| 1205 { | 1211 { |
| 1206 checkThread(); | 1212 checkThread(); |
| 1207 if (sweepForbidden()) | 1213 if (sweepForbidden()) |
| 1208 return; | 1214 return; |
| 1209 auto it = m_preFinalizers.find(target); | 1215 auto it = m_preFinalizers.find(target); |
| 1210 ASSERT(it != m_preFinalizers.end()); | 1216 ASSERT(it != m_preFinalizers.end()); |
| 1211 m_preFinalizers.remove(it); | 1217 m_preFinalizers.remove(it); |
| 1212 } | 1218 } |
| 1213 | 1219 |
| 1214 void ThreadState::invokePreFinalizers(Visitor& visitor) | 1220 void ThreadState::invokePreFinalizers() |
| 1215 { | 1221 { |
| 1216 checkThread(); | 1222 checkThread(); |
| 1217 Vector<void*> deadObjects; | 1223 Vector<void*> deadObjects; |
| 1218 for (auto& entry : m_preFinalizers) { | 1224 for (auto& entry : m_preFinalizers) { |
| 1219 if (entry.value(entry.key, visitor)) | 1225 if (entry.value(entry.key)) |
| 1220 deadObjects.append(entry.key); | 1226 deadObjects.append(entry.key); |
| 1221 } | 1227 } |
| 1222 // FIXME: removeAll is inefficient. It can shrink repeatedly. | 1228 // FIXME: removeAll is inefficient. It can shrink repeatedly. |
| 1223 m_preFinalizers.removeAll(deadObjects); | 1229 m_preFinalizers.removeAll(deadObjects); |
| 1224 } | 1230 } |
| 1225 | 1231 |
| 1226 void ThreadState::clearHeapAges() | 1232 void ThreadState::clearHeapAges() |
| 1227 { | 1233 { |
| 1228 memset(m_heapAges, 0, sizeof(size_t) * NumberOfHeaps); | 1234 memset(m_heapAges, 0, sizeof(size_t) * NumberOfHeaps); |
| 1229 memset(m_likelyToBePromptlyFreed.get(), 0, sizeof(int) * likelyToBePromptlyF
reedArraySize); | 1235 memset(m_likelyToBePromptlyFreed.get(), 0, sizeof(int) * likelyToBePromptlyF
reedArraySize); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 json->beginArray(it->key.ascii().data()); | 1357 json->beginArray(it->key.ascii().data()); |
| 1352 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | 1358 for (size_t age = 0; age <= maxHeapObjectAge; ++age) |
| 1353 json->pushInteger(it->value.ages[age]); | 1359 json->pushInteger(it->value.ages[age]); |
| 1354 json->endArray(); | 1360 json->endArray(); |
| 1355 } | 1361 } |
| 1356 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); | 1362 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s
tatsName, this, json.release()); |
| 1357 } | 1363 } |
| 1358 #endif | 1364 #endif |
| 1359 | 1365 |
| 1360 } // namespace blink | 1366 } // namespace blink |
| OLD | NEW |