summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/parser/ParserArena.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/parser/ParserArena.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/parser/ParserArena.cpp')
-rw-r--r--Source/JavaScriptCore/parser/ParserArena.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/Source/JavaScriptCore/parser/ParserArena.cpp b/Source/JavaScriptCore/parser/ParserArena.cpp
index a27688770..c53f30753 100644
--- a/Source/JavaScriptCore/parser/ParserArena.cpp
+++ b/Source/JavaScriptCore/parser/ParserArena.cpp
@@ -27,7 +27,7 @@
#include "ParserArena.h"
#include "Nodes.h"
-#include "JSCInlines.h"
+#include <wtf/PassOwnPtr.h>
namespace JSC {
@@ -62,6 +62,38 @@ ParserArena::~ParserArena()
deallocateObjects();
}
+bool ParserArena::contains(ParserArenaRefCounted* object) const
+{
+ return m_refCountedObjects.find(object) != notFound;
+}
+
+ParserArenaRefCounted* ParserArena::last() const
+{
+ return m_refCountedObjects.last().get();
+}
+
+void ParserArena::removeLast()
+{
+ m_refCountedObjects.removeLast();
+}
+
+void ParserArena::reset()
+{
+ // Since this code path is used only when parsing fails, it's not bothering to reuse
+ // any of the memory the arena allocated. We could improve that later if we want to
+ // efficiently reuse the same arena.
+
+ deallocateObjects();
+
+ m_freeableMemory = 0;
+ m_freeablePoolEnd = 0;
+ if (m_identifierArena)
+ m_identifierArena->clear();
+ m_freeablePools.clear();
+ m_deletableObjects.clear();
+ m_refCountedObjects.clear();
+}
+
void ParserArena::allocateFreeablePool()
{
if (m_freeablePoolEnd)
@@ -73,4 +105,18 @@ void ParserArena::allocateFreeablePool()
ASSERT(freeablePool() == pool);
}
+bool ParserArena::isEmpty() const
+{
+ return !m_freeablePoolEnd
+ && (!m_identifierArena || m_identifierArena->isEmpty())
+ && m_freeablePools.isEmpty()
+ && m_deletableObjects.isEmpty()
+ && m_refCountedObjects.isEmpty();
+}
+
+void ParserArena::derefWithArena(PassRefPtr<ParserArenaRefCounted> object)
+{
+ m_refCountedObjects.append(object);
+}
+
}