Title: [172804] trunk/Source/_javascript_Core
- Revision
- 172804
- Author
- commit-qu...@webkit.org
- Date
- 2014-08-20 12:27:48 -0700 (Wed, 20 Aug 2014)
Log Message
Fix a memory leak in TypeSet
https://bugs.webkit.org/show_bug.cgi?id=135913
Patch by Saam Barati <sbar...@apple.com> on 2014-08-20
Reviewed by Filip Pizlo.
Currently, TypeSet unconditionally allocates memory for its member
variable m_structureHistory, but never deallocates it. Change this
from being a pointer that is unconditionally allocated to a member
variable that will be deallocated when TypeSet itself is deallocated.
* runtime/TypeSet.cpp:
(JSC::TypeSet::TypeSet):
(JSC::TypeSet::addTypeInformation):
(JSC::TypeSet::seenTypes):
(JSC::TypeSet::displayName):
(JSC::TypeSet::allStructureRepresentations):
(JSC::StructureShape::leastCommonAncestor):
* runtime/TypeSet.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (172803 => 172804)
--- trunk/Source/_javascript_Core/ChangeLog 2014-08-20 19:10:38 UTC (rev 172803)
+++ trunk/Source/_javascript_Core/ChangeLog 2014-08-20 19:27:48 UTC (rev 172804)
@@ -1,3 +1,24 @@
+2014-08-20 Saam Barati <sbar...@apple.com>
+
+ Fix a memory leak in TypeSet
+ https://bugs.webkit.org/show_bug.cgi?id=135913
+
+ Reviewed by Filip Pizlo.
+
+ Currently, TypeSet unconditionally allocates memory for its member
+ variable m_structureHistory, but never deallocates it. Change this
+ from being a pointer that is unconditionally allocated to a member
+ variable that will be deallocated when TypeSet itself is deallocated.
+
+ * runtime/TypeSet.cpp:
+ (JSC::TypeSet::TypeSet):
+ (JSC::TypeSet::addTypeInformation):
+ (JSC::TypeSet::seenTypes):
+ (JSC::TypeSet::displayName):
+ (JSC::TypeSet::allStructureRepresentations):
+ (JSC::StructureShape::leastCommonAncestor):
+ * runtime/TypeSet.h:
+
2014-08-20 pe...@outlook.com <pe...@outlook.com>
[Win] Assertion fails when running JSC stress tests.
Modified: trunk/Source/_javascript_Core/runtime/TypeSet.cpp (172803 => 172804)
--- trunk/Source/_javascript_Core/runtime/TypeSet.cpp 2014-08-20 19:10:38 UTC (rev 172803)
+++ trunk/Source/_javascript_Core/runtime/TypeSet.cpp 2014-08-20 19:27:48 UTC (rev 172804)
@@ -38,7 +38,6 @@
TypeSet::TypeSet()
: m_seenTypes(TypeNothing)
- , m_structureHistory(new Vector<RefPtr<StructureShape>>)
{
}
@@ -79,8 +78,8 @@
// Make one more pass making sure that we don't have the same shape. (Same shapes may have different StructureIDs).
bool found = false;
String hash = shape->propertyHash();
- for (size_t i = 0; i < m_structureHistory->size(); i++) {
- RefPtr<StructureShape> obj = m_structureHistory->at(i);
+ for (size_t i = 0; i < m_structureHistory.size(); i++) {
+ RefPtr<StructureShape> obj = m_structureHistory.at(i);
if (obj->propertyHash() == hash) {
found = true;
break;
@@ -88,7 +87,7 @@
}
if (!found)
- m_structureHistory->append(shape);
+ m_structureHistory.append(shape);
}
}
}
@@ -117,22 +116,22 @@
if (m_seenTypes & TypeObject)
seen.append("Object ");
- for (size_t i = 0; i < m_structureHistory->size(); i++) {
- RefPtr<StructureShape> shape = m_structureHistory->at(i);
+ for (size_t i = 0; i < m_structureHistory.size(); i++) {
+ RefPtr<StructureShape> shape = m_structureHistory.at(i);
seen.append(shape->m_constructorName);
seen.append(" ");
}
- if (m_structureHistory->size())
+ if (m_structureHistory.size())
seen.append("\nStructures:[ ");
- for (size_t i = 0; i < m_structureHistory->size(); i++) {
- seen.append(m_structureHistory->at(i)->stringRepresentation());
+ for (size_t i = 0; i < m_structureHistory.size(); i++) {
+ seen.append(m_structureHistory.at(i)->stringRepresentation());
seen.append(" ");
}
- if (m_structureHistory->size())
+ if (m_structureHistory.size())
seen.append("]");
- if (m_structureHistory->size()) {
+ if (m_structureHistory.size()) {
seen.append("\nLeast Common Ancestor: ");
seen.append(leastCommonAncestor());
}
@@ -165,7 +164,7 @@
if (m_seenTypes == TypeNothing)
return "";
- if (m_structureHistory->size() && doesTypeConformTo(TypeObject | TypeNull | TypeUndefined)) {
+ if (m_structureHistory.size() && doesTypeConformTo(TypeObject | TypeNull | TypeUndefined)) {
String ctorName = leastCommonAncestor();
if (doesTypeConformTo(TypeObject))
@@ -237,8 +236,8 @@
{
RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::StructureDescription>> description = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::StructureDescription>::create();
- for (size_t i = 0; i < m_structureHistory->size(); i++)
- description->addItem(m_structureHistory->at(i)->inspectorRepresentation());
+ for (size_t i = 0; i < m_structureHistory.size(); i++)
+ description->addItem(m_structureHistory.at(i)->inspectorRepresentation());
return description.release();
}
@@ -299,16 +298,16 @@
return *m_propertyHash;
}
-String StructureShape::leastCommonAncestor(const Vector<RefPtr<StructureShape>>* shapes)
+String StructureShape::leastCommonAncestor(const Vector<RefPtr<StructureShape>> shapes)
{
- if (!shapes->size())
+ if (!shapes.size())
return "";
- RefPtr<StructureShape> origin = shapes->at(0);
- for (size_t i = 1; i < shapes->size(); i++) {
+ RefPtr<StructureShape> origin = shapes.at(0);
+ for (size_t i = 1; i < shapes.size(); i++) {
bool foundLUB = false;
while (!foundLUB) {
- RefPtr<StructureShape> check = shapes->at(i);
+ RefPtr<StructureShape> check = shapes.at(i);
String curCtorName = origin->m_constructorName;
while (check) {
if (check->m_constructorName == curCtorName) {
Modified: trunk/Source/_javascript_Core/runtime/TypeSet.h (172803 => 172804)
--- trunk/Source/_javascript_Core/runtime/TypeSet.h 2014-08-20 19:10:38 UTC (rev 172803)
+++ trunk/Source/_javascript_Core/runtime/TypeSet.h 2014-08-20 19:27:48 UTC (rev 172804)
@@ -76,7 +76,7 @@
void setProto(PassRefPtr<StructureShape> shape) { m_proto = shape; }
private:
- static String leastCommonAncestor(const Vector<RefPtr<StructureShape>>*);
+ static String leastCommonAncestor(const Vector<RefPtr<StructureShape>>);
Vector<RefPtr<StringImpl>> m_fields;
RefPtr<StructureShape> m_proto;
@@ -103,7 +103,7 @@
bool doesTypeConformTo(uint32_t test) const;
uint32_t m_seenTypes;
- Vector<RefPtr<StructureShape>>* m_structureHistory;
+ Vector<RefPtr<StructureShape>> m_structureHistory;
HashMap<StructureID, uint8_t> m_structureIDHistory;
};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes