Changeset 43642 in webkit for trunk/JavaScriptCore/parser/ParserArena.cpp
- Timestamp:
- May 13, 2009, 11:14:48 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/ParserArena.cpp
r43479 r43642 31 31 namespace JSC { 32 32 33 ParserArena::ParserArena() 34 : m_freeableMemory(0) 35 , m_freeablePoolEnd(0) 36 , m_identifierArena(new IdentifierArena) 37 { 38 } 39 40 inline void* ParserArena::freeablePool() 41 { 42 ASSERT(m_freeablePoolEnd); 43 return m_freeablePoolEnd - freeablePoolSize; 44 } 45 46 inline void ParserArena::deallocateObjects() 47 { 48 if (m_freeablePoolEnd) 49 fastFree(freeablePool()); 50 51 size_t size = m_freeablePools.size(); 52 for (size_t i = 0; i < size; ++i) 53 fastFree(m_freeablePools[i]); 54 55 size = m_deletableObjects.size(); 56 for (size_t i = 0; i < size; ++i) { 57 ParserArenaDeletable* object = m_deletableObjects[i]; 58 object->~ParserArenaDeletable(); 59 fastFree(object); 60 } 61 } 62 33 63 ParserArena::~ParserArena() 34 64 { 35 de leteAllValues(m_deletableObjects);65 deallocateObjects(); 36 66 } 37 67 … … 53 83 void ParserArena::reset() 54 84 { 55 deleteAllValues(m_deletableObjects); 56 m_deletableObjects.shrink(0); 57 m_refCountedObjects.shrink(0); 85 // Since this code path is used only when parsing fails, it's not bothering to reuse 86 // any of the memory the arena allocated. We could improve that later if we want to 87 // efficiently reuse the same arena. 88 89 deallocateObjects(); 90 91 m_freeableMemory = 0; 92 m_freeablePoolEnd = 0; 93 m_identifierArena->clear(); 94 m_freeablePools.clear(); 95 m_deletableObjects.clear(); 96 m_refCountedObjects.clear(); 97 } 98 99 const Identifier& ParserArena::makeNumericIdentifier(JSGlobalData* globalData, double number) 100 { 101 m_identifierArena->append(Identifier(globalData, UString::from(number))); 102 return m_identifierArena->last(); 103 } 104 105 void ParserArena::allocateFreeablePool() 106 { 107 if (m_freeablePoolEnd) 108 m_freeablePools.append(freeablePool()); 109 110 char* pool = static_cast<char*>(fastMalloc(freeablePoolSize)); 111 m_freeableMemory = pool; 112 m_freeablePoolEnd = pool + freeablePoolSize; 113 ASSERT(freeablePool() == pool); 114 } 115 116 bool ParserArena::isEmpty() const 117 { 118 return !m_freeablePoolEnd 119 && m_identifierArena->isEmpty() 120 && m_freeablePools.isEmpty() 121 && m_deletableObjects.isEmpty() 122 && m_refCountedObjects.isEmpty(); 58 123 } 59 124
Note:
See TracChangeset
for help on using the changeset viewer.