Changeset 207186 in webkit
- Timestamp:
- Oct 11, 2016 8:14:56 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r207179 r207186 1 2016-10-11 Saam Barati <sbarati@apple.com> 2 3 HasOwnPropertyCache needs to ref the UniquedStringImpls it sees 4 https://bugs.webkit.org/show_bug.cgi?id=163255 5 6 Reviewed by Geoffrey Garen. 7 8 The cache needs to be responsible for ensuring that things 9 in the cache stay alive. Before, it wasn't doing this, and 10 that was wrong. 11 12 * runtime/HasOwnPropertyCache.h: 13 (JSC::HasOwnPropertyCache::Entry::operator=): 14 (JSC::HasOwnPropertyCache::operator delete): 15 (JSC::HasOwnPropertyCache::create): 16 (JSC::HasOwnPropertyCache::get): 17 (JSC::HasOwnPropertyCache::tryAdd): 18 (JSC::HasOwnPropertyCache::clear): 19 (JSC::HasOwnPropertyCache::zeroBuffer): 20 1 21 2016-10-06 Filip Pizlo <fpizlo@apple.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/HasOwnPropertyCache.h
r206885 r207186 43 43 static ptrdiff_t offsetOfResult() { return OBJECT_OFFSETOF(Entry, result); } 44 44 45 UniquedStringImpl* impl; 46 StructureID structureID; 47 bool result; 45 Entry() = default; 46 47 Entry& operator=(Entry&& other) 48 { 49 impl = WTFMove(other.impl); 50 structureID = other.structureID; 51 result = other.result; 52 return *this; 53 } 54 55 RefPtr<UniquedStringImpl> impl { }; 56 StructureID structureID { 0 }; 57 bool result { false }; 48 58 }; 49 59 … … 52 62 void operator delete(void* cache) 53 63 { 64 static_cast<HasOwnPropertyCache*>(cache)->clear(); 54 65 fastFree(cache); 55 66 } … … 59 70 size_t allocationSize = sizeof(Entry) * size; 60 71 HasOwnPropertyCache* result = static_cast<HasOwnPropertyCache*>(fastMalloc(allocationSize)); 61 result->clear ();72 result->clearBuffer(); 62 73 return result; 63 74 } … … 74 85 uint32_t index = HasOwnPropertyCache::hash(id, impl) & mask; 75 86 Entry& entry = bitwise_cast<Entry*>(this)[index]; 76 if (entry.structureID == id && entry.impl == impl)87 if (entry.structureID == id && entry.impl.get() == impl) 77 88 return entry.result; 78 89 return Nullopt; … … 105 116 StructureID id = structure->id(); 106 117 uint32_t index = HasOwnPropertyCache::hash(id, impl) & mask; 107 bitwise_cast<Entry*>(this)[index] = Entry{ impl, id, result };118 bitwise_cast<Entry*>(this)[index] = Entry{ RefPtr<UniquedStringImpl>(impl), id, result }; 108 119 } 109 120 } … … 111 122 void clear() 112 123 { 113 memset(this, 0, sizeof(Entry) * size); 124 Entry* buffer = bitwise_cast<Entry*>(this); 125 for (uint32_t i = 0; i < size; ++i) 126 buffer[i].Entry::~Entry(); 127 128 clearBuffer(); 129 } 130 131 private: 132 void clearBuffer() 133 { 134 Entry* buffer = bitwise_cast<Entry*>(this); 135 for (uint32_t i = 0; i < size; ++i) 136 new (&buffer[i]) Entry(); 114 137 } 115 138 };
Note: See TracChangeset
for help on using the changeset viewer.