X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/ba379fdc102753d6be2c4d937058fe40257329fe..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/parser/ParserArena.cpp?ds=inline diff --git a/parser/ParserArena.cpp b/parser/ParserArena.cpp index 2617506..a276887 100644 --- a/parser/ParserArena.cpp +++ b/parser/ParserArena.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,34 +27,50 @@ #include "ParserArena.h" #include "Nodes.h" +#include "JSCInlines.h" namespace JSC { -ParserArena::~ParserArena() +ParserArena::ParserArena() + : m_freeableMemory(0) + , m_freeablePoolEnd(0) { - deleteAllValues(m_deletableObjects); } -bool ParserArena::contains(ParserArenaRefCounted* object) const +inline void* ParserArena::freeablePool() { - return m_refCountedObjects.find(object) != notFound; + ASSERT(m_freeablePoolEnd); + return m_freeablePoolEnd - freeablePoolSize; } -ParserArenaRefCounted* ParserArena::last() const +inline void ParserArena::deallocateObjects() { - return m_refCountedObjects.last().get(); + size_t size = m_deletableObjects.size(); + for (size_t i = 0; i < size; ++i) + m_deletableObjects[i]->~ParserArenaDeletable(); + + if (m_freeablePoolEnd) + fastFree(freeablePool()); + + size = m_freeablePools.size(); + for (size_t i = 0; i < size; ++i) + fastFree(m_freeablePools[i]); } -void ParserArena::removeLast() +ParserArena::~ParserArena() { - m_refCountedObjects.removeLast(); + deallocateObjects(); } -void ParserArena::reset() +void ParserArena::allocateFreeablePool() { - deleteAllValues(m_deletableObjects); - m_deletableObjects.shrink(0); - m_refCountedObjects.shrink(0); + if (m_freeablePoolEnd) + m_freeablePools.append(freeablePool()); + + char* pool = static_cast(fastMalloc(freeablePoolSize)); + m_freeableMemory = pool; + m_freeablePoolEnd = pool + freeablePoolSize; + ASSERT(freeablePool() == pool); } }