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

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

Issue 1200333006: Oilpan: Support nested pre-finalizers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 void ThreadState::lockThreadAttachMutex() 1292 void ThreadState::lockThreadAttachMutex()
1293 { 1293 {
1294 threadAttachMutex().lock(); 1294 threadAttachMutex().lock();
1295 } 1295 }
1296 1296
1297 void ThreadState::unlockThreadAttachMutex() 1297 void ThreadState::unlockThreadAttachMutex()
1298 { 1298 {
1299 threadAttachMutex().unlock(); 1299 threadAttachMutex().unlock();
1300 } 1300 }
1301 1301
1302 void ThreadState::unregisterPreFinalizerInternal(void* target)
1303 {
1304 checkThread();
1305 if (sweepForbidden())
1306 return;
1307 auto it = m_preFinalizers.find(target);
1308 ASSERT(it != m_preFinalizers.end());
1309 m_preFinalizers.remove(it);
1310 }
1311
1312 void ThreadState::invokePreFinalizers() 1302 void ThreadState::invokePreFinalizers()
1313 { 1303 {
1314 checkThread(); 1304 checkThread();
1315 ASSERT(!sweepForbidden()); 1305 ASSERT(!sweepForbidden());
1316 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); 1306 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers");
1317 1307
1318 if (isMainThread()) 1308 if (isMainThread())
1319 ScriptForbiddenScope::enter(); 1309 ScriptForbiddenScope::enter();
1320 1310
1321 SweepForbiddenScope forbiddenScope(this); 1311 SweepForbiddenScope forbiddenScope(this);
1322 Vector<void*> deadObjects; 1312 Vector<void*> deadObjects;
1323 for (auto& entry : m_preFinalizers) { 1313 for (auto& it : m_preFinalizers) {
1324 if (entry.value(entry.key)) 1314 void* object = it.key;
1325 deadObjects.append(entry.key); 1315 Vector<PreFinalizerCallback>* callbackVector = it.value.get();
1316 size_t preFinalizerCount = callbackVector->size();
1317 ASSERT(preFinalizerCount >= 1);
1318 // Call the pre-finalizers in the reverse order in which they
1319 // are registered.
1320 if (!(callbackVector->at(preFinalizerCount - 1))(object))
1321 continue;
1322 deadObjects.append(object);
1323 for (int i = preFinalizerCount - 2; i >= 0; --i) {
1324 bool ret = (callbackVector->at(i))(object);
1325 ASSERT_UNUSED(ret, ret);
1326 }
1326 } 1327 }
1327 // FIXME: removeAll is inefficient. It can shrink repeatedly. 1328 // FIXME: removeAll is inefficient. It can shrink repeatedly.
1328 m_preFinalizers.removeAll(deadObjects); 1329 m_preFinalizers.removeAll(deadObjects);
1329 1330
1330 if (isMainThread()) 1331 if (isMainThread())
1331 ScriptForbiddenScope::exit(); 1332 ScriptForbiddenScope::exit();
1332 } 1333 }
1333 1334
1334 void ThreadState::clearHeapAges() 1335 void ThreadState::clearHeapAges()
1335 { 1336 {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 json->beginArray(it->key.ascii().data()); 1508 json->beginArray(it->key.ascii().data());
1508 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1509 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1509 json->pushInteger(it->value.ages[age]); 1510 json->pushInteger(it->value.ages[age]);
1510 json->endArray(); 1511 json->endArray();
1511 } 1512 }
1512 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1513 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1513 } 1514 }
1514 #endif 1515 #endif
1515 1516
1516 } // namespace blink 1517 } // 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