Chromium Code Reviews| Index: Source/platform/heap/ThreadState.cpp |
| diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
| index 73afe55fb9d405a2dd345e901dbcd85afe6609e6..574ea1ab75abf6a34cd65bcd5bad02e9e3d88142 100644 |
| --- a/Source/platform/heap/ThreadState.cpp |
| +++ b/Source/platform/heap/ThreadState.cpp |
| @@ -1296,16 +1296,6 @@ void ThreadState::unlockThreadAttachMutex() |
| threadAttachMutex().unlock(); |
| } |
| -void ThreadState::unregisterPreFinalizerInternal(void* target) |
| -{ |
| - checkThread(); |
| - if (sweepForbidden()) |
| - return; |
| - auto it = m_preFinalizers.find(target); |
| - ASSERT(it != m_preFinalizers.end()); |
| - m_preFinalizers.remove(it); |
| -} |
| - |
| void ThreadState::invokePreFinalizers() |
| { |
| checkThread(); |
| @@ -1317,9 +1307,17 @@ void ThreadState::invokePreFinalizers() |
| SweepForbiddenScope forbiddenScope(this); |
| Vector<void*> deadObjects; |
| - for (auto& entry : m_preFinalizers) { |
| - if (entry.value(entry.key)) |
| - deadObjects.append(entry.key); |
| + for (auto& it : m_preFinalizers) { |
| + void* object = it.key; |
| + Vector<PreFinalizerCallback>* callbackVector = it.value.get(); |
| + ASSERT(callbackVector->size() >= 1); |
| + 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.
|
| + continue; |
| + deadObjects.append(object); |
| + 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
|
| + bool ret = (callbackVector->at(i))(object); |
| + ASSERT_UNUSED(ret, ret); |
| + } |
| } |
| // FIXME: removeAll is inefficient. It can shrink repeatedly. |
| m_preFinalizers.removeAll(deadObjects); |