Title: [207186] trunk/Source/_javascript_Core
- Revision
- 207186
- Author
- [email protected]
- Date
- 2016-10-11 20:14:56 -0700 (Tue, 11 Oct 2016)
Log Message
HasOwnPropertyCache needs to ref the UniquedStringImpls it sees
https://bugs.webkit.org/show_bug.cgi?id=163255
Reviewed by Geoffrey Garen.
The cache needs to be responsible for ensuring that things
in the cache stay alive. Before, it wasn't doing this, and
that was wrong.
* runtime/HasOwnPropertyCache.h:
(JSC::HasOwnPropertyCache::Entry::operator=):
(JSC::HasOwnPropertyCache::operator delete):
(JSC::HasOwnPropertyCache::create):
(JSC::HasOwnPropertyCache::get):
(JSC::HasOwnPropertyCache::tryAdd):
(JSC::HasOwnPropertyCache::clear):
(JSC::HasOwnPropertyCache::zeroBuffer):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (207185 => 207186)
--- trunk/Source/_javascript_Core/ChangeLog 2016-10-12 02:24:50 UTC (rev 207185)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-10-12 03:14:56 UTC (rev 207186)
@@ -1,3 +1,23 @@
+2016-10-11 Saam Barati <[email protected]>
+
+ HasOwnPropertyCache needs to ref the UniquedStringImpls it sees
+ https://bugs.webkit.org/show_bug.cgi?id=163255
+
+ Reviewed by Geoffrey Garen.
+
+ The cache needs to be responsible for ensuring that things
+ in the cache stay alive. Before, it wasn't doing this, and
+ that was wrong.
+
+ * runtime/HasOwnPropertyCache.h:
+ (JSC::HasOwnPropertyCache::Entry::operator=):
+ (JSC::HasOwnPropertyCache::operator delete):
+ (JSC::HasOwnPropertyCache::create):
+ (JSC::HasOwnPropertyCache::get):
+ (JSC::HasOwnPropertyCache::tryAdd):
+ (JSC::HasOwnPropertyCache::clear):
+ (JSC::HasOwnPropertyCache::zeroBuffer):
+
2016-10-06 Filip Pizlo <[email protected]>
MarkedBlock should know what objects are live during marking
Modified: trunk/Source/_javascript_Core/runtime/HasOwnPropertyCache.h (207185 => 207186)
--- trunk/Source/_javascript_Core/runtime/HasOwnPropertyCache.h 2016-10-12 02:24:50 UTC (rev 207185)
+++ trunk/Source/_javascript_Core/runtime/HasOwnPropertyCache.h 2016-10-12 03:14:56 UTC (rev 207186)
@@ -42,9 +42,19 @@
static ptrdiff_t offsetOfImpl() { return OBJECT_OFFSETOF(Entry, impl); }
static ptrdiff_t offsetOfResult() { return OBJECT_OFFSETOF(Entry, result); }
- UniquedStringImpl* impl;
- StructureID structureID;
- bool result;
+ Entry() = default;
+
+ Entry& operator=(Entry&& other)
+ {
+ impl = WTFMove(other.impl);
+ structureID = other.structureID;
+ result = other.result;
+ return *this;
+ }
+
+ RefPtr<UniquedStringImpl> impl { };
+ StructureID structureID { 0 };
+ bool result { false };
};
HasOwnPropertyCache() = delete;
@@ -51,6 +61,7 @@
void operator delete(void* cache)
{
+ static_cast<HasOwnPropertyCache*>(cache)->clear();
fastFree(cache);
}
@@ -58,7 +69,7 @@
{
size_t allocationSize = sizeof(Entry) * size;
HasOwnPropertyCache* result = static_cast<HasOwnPropertyCache*>(fastMalloc(allocationSize));
- result->clear();
+ result->clearBuffer();
return result;
}
@@ -73,7 +84,7 @@
StructureID id = structure->id();
uint32_t index = HasOwnPropertyCache::hash(id, impl) & mask;
Entry& entry = bitwise_cast<Entry*>(this)[index];
- if (entry.structureID == id && entry.impl == impl)
+ if (entry.structureID == id && entry.impl.get() == impl)
return entry.result;
return Nullopt;
}
@@ -104,14 +115,26 @@
UniquedStringImpl* impl = propName.uid();
StructureID id = structure->id();
uint32_t index = HasOwnPropertyCache::hash(id, impl) & mask;
- bitwise_cast<Entry*>(this)[index] = Entry{ impl, id, result };
+ bitwise_cast<Entry*>(this)[index] = Entry{ RefPtr<UniquedStringImpl>(impl), id, result };
}
}
void clear()
{
- memset(this, 0, sizeof(Entry) * size);
+ Entry* buffer = bitwise_cast<Entry*>(this);
+ for (uint32_t i = 0; i < size; ++i)
+ buffer[i].Entry::~Entry();
+
+ clearBuffer();
}
+
+private:
+ void clearBuffer()
+ {
+ Entry* buffer = bitwise_cast<Entry*>(this);
+ for (uint32_t i = 0; i < size; ++i)
+ new (&buffer[i]) Entry();
+ }
};
ALWAYS_INLINE HasOwnPropertyCache* VM::ensureHasOwnPropertyCache()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes