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

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 for (size_t i = 0; i < callbackVector->size(); i++) {
1314 if (!(callbackVector->at(i))(object))
1315 break;
1316 deadObjects.append(object);
1317 }
1323 } 1318 }
1324 // FIXME: removeAll is inefficient. It can shrink repeatedly. 1319 // FIXME: removeAll is inefficient. It can shrink repeatedly.
1325 m_preFinalizers.removeAll(deadObjects); 1320 m_preFinalizers.removeAll(deadObjects);
1326 1321
1327 if (isMainThread()) 1322 if (isMainThread())
1328 ScriptForbiddenScope::exit(); 1323 ScriptForbiddenScope::exit();
1329 } 1324 }
1330 1325
1331 void ThreadState::clearHeapAges() 1326 void ThreadState::clearHeapAges()
1332 { 1327 {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 json->beginArray(it->key.ascii().data()); 1464 json->beginArray(it->key.ascii().data());
1470 for (size_t age = 0; age <= maxHeapObjectAge; ++age) 1465 for (size_t age = 0; age <= maxHeapObjectAge; ++age)
1471 json->pushInteger(it->value.ages[age]); 1466 json->pushInteger(it->value.ages[age]);
1472 json->endArray(); 1467 json->endArray();
1473 } 1468 }
1474 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); 1469 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release());
1475 } 1470 }
1476 #endif 1471 #endif
1477 1472
1478 } // namespace blink 1473 } // namespace blink
OLDNEW
« Source/platform/heap/HeapTest.cpp ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698