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

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, 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 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 void ThreadState::lockThreadAttachMutex() 1289 void ThreadState::lockThreadAttachMutex()
1290 { 1290 {
1291 threadAttachMutex().lock(); 1291 threadAttachMutex().lock();
1292 } 1292 }
1293 1293
1294 void ThreadState::unlockThreadAttachMutex() 1294 void ThreadState::unlockThreadAttachMutex()
1295 { 1295 {
1296 threadAttachMutex().unlock(); 1296 threadAttachMutex().unlock();
1297 } 1297 }
1298 1298
1299 void ThreadState::unregisterPreFinalizerInternal(void* target)
1300 {
1301 checkThread();
1302 if (sweepForbidden())
1303 return;
1304 auto it = m_preFinalizers.find(target);
1305 ASSERT(it != m_preFinalizers.end());
1306 m_preFinalizers.remove(it);
1307 }
1308
1309 void ThreadState::invokePreFinalizers() 1299 void ThreadState::invokePreFinalizers()
1310 { 1300 {
1311 checkThread(); 1301 checkThread();
1312 ASSERT(!sweepForbidden()); 1302 ASSERT(!sweepForbidden());
1313 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); 1303 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers");
1314 1304
1315 if (isMainThread()) 1305 if (isMainThread())
1316 ScriptForbiddenScope::enter(); 1306 ScriptForbiddenScope::enter();
1317 1307
1318 SweepForbiddenScope forbiddenScope(this); 1308 SweepForbiddenScope forbiddenScope(this);
1319 Vector<void*> deadObjects; 1309 Vector<void*> deadObjects;
1320 for (auto& entry : m_preFinalizers) { 1310 for (auto& it : m_preFinalizers) {
1321 if (entry.value(entry.key)) 1311 void* object = it.key;
1322 deadObjects.append(entry.key); 1312 Vector<PreFinalizerCallback>* callbackVector = it.value.get();
1313 ASSERT(callbackVector->size() >= 1);
1314 if (!(callbackVector->at(0))(object))
sof 2015/06/24 11:21:56 I wonder if it would be tidier to just check if 'o
haraken 2015/06/24 12:54:01 Unfortunately we can't do this because isHeapObjec
sof 2015/06/24 13:40:31 ..and we have to support mixin prefinalizers.
1315 continue;
1316 deadObjects.append(object);
1317 for (size_t i = 1; i < callbackVector->size(); i++) {
sof 2015/06/24 11:21:56 Don't you want to do this the other way around? th
haraken 2015/06/24 12:54:01 Nice catch! Done. However, we cannot guarantee th
sof 2015/06/24 13:40:31 It would have been preferable to avoid that non-de
haraken 2015/06/24 13:47:50 Maybe can we use a LinkedListHashSet instead of a
1318 bool ret = (callbackVector->at(i))(object);
1319 ASSERT_UNUSED(ret, ret);
1320 }
1323 } 1321 }
1324 // FIXME: removeAll is inefficient. It can shrink repeatedly. 1322 // FIXME: removeAll is inefficient. It can shrink repeatedly.
1325 m_preFinalizers.removeAll(deadObjects); 1323 m_preFinalizers.removeAll(deadObjects);
1326 1324
1327 if (isMainThread()) 1325 if (isMainThread())
1328 ScriptForbiddenScope::exit(); 1326 ScriptForbiddenScope::exit();
1329 } 1327 }
1330 1328
1331 void ThreadState::clearHeapAges() 1329 void ThreadState::clearHeapAges()
1332 { 1330 {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 json->beginArray(it->key.ascii().data()); 1467 json->beginArray(it->key.ascii().data());
1470 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1468 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1471 json->pushInteger(it->value.ages[age]); 1469 json->pushInteger(it->value.ages[age]);
1472 json->endArray(); 1470 json->endArray();
1473 } 1471 }
1474 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1472 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1475 } 1473 }
1476 #endif 1474 #endif
1477 1475
1478 } // namespace blink 1476 } // namespace blink
OLDNEW
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698