diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/runtime/WeakMapData.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/runtime/WeakMapData.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/WeakMapData.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/Source/JavaScriptCore/runtime/WeakMapData.cpp b/Source/JavaScriptCore/runtime/WeakMapData.cpp index 224be8a46..16d65003b 100644 --- a/Source/JavaScriptCore/runtime/WeakMapData.cpp +++ b/Source/JavaScriptCore/runtime/WeakMapData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,17 +26,14 @@ #include "config.h" #include "WeakMapData.h" -#include "CopiedAllocator.h" -#include "CopyVisitorInlines.h" #include "ExceptionHelpers.h" -#include "JSCJSValueInlines.h" -#include "SlotVisitorInlines.h" +#include "JSCInlines.h" #include <wtf/MathExtras.h> namespace JSC { -const ClassInfo WeakMapData::s_info = { "WeakMapData", 0, 0, 0, CREATE_METHOD_TABLE(WeakMapData) }; +const ClassInfo WeakMapData::s_info = { "WeakMapData", 0, 0, CREATE_METHOD_TABLE(WeakMapData) }; WeakMapData::WeakMapData(VM& vm) : Base(vm, vm.weakMapDataStructure.get()) @@ -54,6 +51,12 @@ void WeakMapData::destroy(JSCell* cell) static_cast<WeakMapData*>(cell)->~WeakMapData(); } +size_t WeakMapData::estimatedSize(JSCell* cell) +{ + WeakMapData* thisObj = jsCast<WeakMapData*>(cell); + return Base::estimatedSize(cell) + (thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>))); +} + void WeakMapData::visitChildren(JSCell* cell, SlotVisitor& visitor) { Base::visitChildren(cell, visitor); @@ -63,8 +66,8 @@ void WeakMapData::visitChildren(JSCell* cell, SlotVisitor& visitor) // Rough approximation of the external storage needed for the hashtable. // This isn't exact, but it is close enough, and proportional to the actual - // external mermory usage. - visitor.reportExtraMemoryUsage(thisObj, thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>))); + // external memory usage. + visitor.reportExtraMemoryVisited(thisObj->m_map.capacity() * (sizeof(JSObject*) + sizeof(WriteBarrier<Unknown>))); } void WeakMapData::set(VM& vm, JSObject* key, JSValue value) @@ -105,11 +108,11 @@ void WeakMapData::clear() void WeakMapData::DeadKeyCleaner::visitWeakReferences(SlotVisitor& visitor) { m_liveKeyCount = 0; - for (auto it = m_target->m_map.begin(), end = m_target->m_map.end(); it != end; ++it) { - if (!Heap::isMarked(it->key)) + for (auto& pair : m_target->m_map) { + if (!Heap::isMarked(pair.key)) continue; m_liveKeyCount++; - visitor.append(&it->value); + visitor.append(pair.value); } RELEASE_ASSERT(m_liveKeyCount <= m_target->m_map.size()); } @@ -123,19 +126,19 @@ void WeakMapData::DeadKeyCleaner::finalizeUnconditionally() return; Vector<JSObject*> deadEntries; deadEntries.reserveCapacity(deadCount); - for (auto it = m_target->m_map.begin(), end = m_target->m_map.end(); it != end; ++it) { - if (Heap::isMarked(it->key)) + for (auto& pair : m_target->m_map) { + if (Heap::isMarked(pair.key)) continue; - deadEntries.uncheckedAppend(it->key); + deadEntries.uncheckedAppend(pair.key); } - for (size_t i = 0; i < deadEntries.size(); i++) - m_target->m_map.remove(deadEntries[i]); + for (auto& deadEntry : deadEntries) + m_target->m_map.remove(deadEntry); } else { MapType newMap; - for (auto it = m_target->m_map.begin(), end = m_target->m_map.end(); it != end; ++it) { - if (!Heap::isMarked(it->key)) + for (auto& pair : m_target->m_map) { + if (!Heap::isMarked(pair.key)) continue; - newMap.add(it->key, it->value); + newMap.add(pair.key, pair.value); } m_target->m_map.swap(newMap); } |