[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
ggaren at apple.com
ggaren at apple.com
Thu Oct 29 20:42:33 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit a850b0607b198675d28e2fa844e9450ff36811d8
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Oct 9 18:14:08 2009 +0000
Migrated some code that didn't belong out of Structure.
Patch by Geoffrey Garen <ggaren at apple.com> on 2009-10-09
Reviewed by Sam Weinig.
SunSpider says maybe 1.03x faster.
* runtime/JSCell.h: Nixed Structure::markAggregate, and made marking of
a Structure's prototype the direct responsility of the object using it.
(Giving Structure a mark function was misleading because it implied that
all live structures get marked during GC, when they don't.)
* runtime/JSGlobalObject.cpp:
(JSC::markIfNeeded):
(JSC::JSGlobalObject::markChildren): Added code to mark prototypes stored
on the global object. Maybe this wasn't necessary, but now we don't have
to wonder.
* runtime/JSObject.cpp:
(JSC::JSObject::getPropertyNames):
(JSC::JSObject::getOwnPropertyNames):
(JSC::JSObject::getEnumerableNamesFromClassInfoTable):
* runtime/JSObject.h:
(JSC::JSObject::markChildrenDirect):
* runtime/PropertyNameArray.h:
* runtime/Structure.cpp:
* runtime/Structure.h:
(JSC::Structure::setEnumerationCache):
(JSC::Structure::enumerationCache): Moved property name gathering code
from Structure to JSObject because having a Structure iterate its JSObject
was a layering violation. A JSObject is implemented using a Structure; not
the other way around.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49398 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 3649704..0ee02ae 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,37 @@
+2009-10-09 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Migrated some code that didn't belong out of Structure.
+
+ SunSpider says maybe 1.03x faster.
+
+ * runtime/JSCell.h: Nixed Structure::markAggregate, and made marking of
+ a Structure's prototype the direct responsility of the object using it.
+ (Giving Structure a mark function was misleading because it implied that
+ all live structures get marked during GC, when they don't.)
+
+ * runtime/JSGlobalObject.cpp:
+ (JSC::markIfNeeded):
+ (JSC::JSGlobalObject::markChildren): Added code to mark prototypes stored
+ on the global object. Maybe this wasn't necessary, but now we don't have
+ to wonder.
+
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::getPropertyNames):
+ (JSC::JSObject::getOwnPropertyNames):
+ (JSC::JSObject::getEnumerableNamesFromClassInfoTable):
+ * runtime/JSObject.h:
+ (JSC::JSObject::markChildrenDirect):
+ * runtime/PropertyNameArray.h:
+ * runtime/Structure.cpp:
+ * runtime/Structure.h:
+ (JSC::Structure::setEnumerationCache):
+ (JSC::Structure::enumerationCache): Moved property name gathering code
+ from Structure to JSObject because having a Structure iterate its JSObject
+ was a layering violation. A JSObject is implemented using a Structure; not
+ the other way around.
+
2009-10-09 Mark Rowe <mrowe at apple.com>
Attempt to fix the GTK release build.
diff --git a/JavaScriptCore/runtime/JSCell.h b/JavaScriptCore/runtime/JSCell.h
index 1bfdf2d..63c58ac 100644
--- a/JavaScriptCore/runtime/JSCell.h
+++ b/JavaScriptCore/runtime/JSCell.h
@@ -338,11 +338,6 @@ namespace JSC {
append(value.asCell());
}
- inline void Structure::markAggregate(MarkStack& markStack)
- {
- markStack.append(m_prototype);
- }
-
inline Heap* Heap::heap(JSValue v)
{
if (!v.isCell())
diff --git a/JavaScriptCore/runtime/JSGlobalObject.cpp b/JavaScriptCore/runtime/JSGlobalObject.cpp
index bedf9a7..cf3f1d1 100644
--- a/JavaScriptCore/runtime/JSGlobalObject.cpp
+++ b/JavaScriptCore/runtime/JSGlobalObject.cpp
@@ -89,7 +89,7 @@ static inline void markIfNeeded(MarkStack& markStack, JSValue v)
static inline void markIfNeeded(MarkStack& markStack, const RefPtr<Structure>& s)
{
if (s)
- s->markAggregate(markStack);
+ markIfNeeded(markStack, s->storedPrototype());
}
JSGlobalObject::~JSGlobalObject()
@@ -394,6 +394,21 @@ void JSGlobalObject::markChildren(MarkStack& markStack)
markIfNeeded(markStack, d()->methodCallDummy);
markIfNeeded(markStack, d()->errorStructure);
+ markIfNeeded(markStack, d()->argumentsStructure);
+ markIfNeeded(markStack, d()->arrayStructure);
+ markIfNeeded(markStack, d()->booleanObjectStructure);
+ markIfNeeded(markStack, d()->callbackConstructorStructure);
+ markIfNeeded(markStack, d()->callbackFunctionStructure);
+ markIfNeeded(markStack, d()->callbackObjectStructure);
+ markIfNeeded(markStack, d()->dateStructure);
+ markIfNeeded(markStack, d()->emptyObjectStructure);
+ markIfNeeded(markStack, d()->errorStructure);
+ markIfNeeded(markStack, d()->functionStructure);
+ markIfNeeded(markStack, d()->numberObjectStructure);
+ markIfNeeded(markStack, d()->prototypeFunctionStructure);
+ markIfNeeded(markStack, d()->regExpMatchesArrayStructure);
+ markIfNeeded(markStack, d()->regExpStructure);
+ markIfNeeded(markStack, d()->stringObjectStructure);
// No need to mark the other structures, because their prototypes are all
// guaranteed to be referenced elsewhere.
diff --git a/JavaScriptCore/runtime/JSObject.cpp b/JavaScriptCore/runtime/JSObject.cpp
index db2a9b2..90c36aa 100644
--- a/JavaScriptCore/runtime/JSObject.cpp
+++ b/JavaScriptCore/runtime/JSObject.cpp
@@ -42,6 +42,25 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(JSObject);
+static inline void getEnumerablePropertyNames(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames)
+{
+ // Add properties from the static hashtables of properties
+ for (; classInfo; classInfo = classInfo->parentClass) {
+ const HashTable* table = classInfo->propHashTable(exec);
+ if (!table)
+ continue;
+ table->initializeIfNeeded(exec);
+ ASSERT(table->table);
+
+ int hashSizeMask = table->compactSize - 1;
+ const HashEntry* entry = table->table;
+ for (int i = 0; i <= hashSizeMask; ++i, ++entry) {
+ if (entry->key() && !(entry->attributes() & DontEnum))
+ propertyNames.add(entry->key());
+ }
+ }
+}
+
void JSObject::markChildren(MarkStack& markStack)
{
#ifndef NDEBUG
@@ -424,12 +443,52 @@ bool JSObject::getPropertySpecificValue(ExecState*, const Identifier& propertyNa
void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
- m_structure->getEnumerablePropertyNames(exec, propertyNames, this);
+ bool shouldCache = propertyNames.shouldCache() && !(propertyNames.size() || m_structure->isDictionary());
+
+ if (shouldCache) {
+ if (PropertyNameArrayData* data = m_structure->enumerationCache()) {
+ if (data->cachedPrototypeChain() == m_structure->prototypeChain(exec)) {
+ propertyNames.setData(data);
+ return;
+ }
+
+ m_structure->clearEnumerationCache();
+ }
+ }
+
+ getOwnPropertyNames(exec, propertyNames);
+
+ if (prototype().isObject()) {
+ propertyNames.setShouldCache(false); // No need for our prototypes to waste memory on caching, since they're not being enumerated directly.
+ JSObject* prototype = asObject(this->prototype());
+ while(1) {
+ if (!prototype->structure()->typeInfo().hasDefaultGetPropertyNames()) {
+ prototype->getPropertyNames(exec, propertyNames);
+ break;
+ }
+ prototype->getOwnPropertyNames(exec, propertyNames);
+ JSValue nextProto = prototype->prototype();
+ if (!nextProto.isObject())
+ break;
+ prototype = asObject(nextProto);
+ }
+ }
+
+ if (shouldCache) {
+ StructureChain* protoChain = m_structure->prototypeChain(exec);
+ if (!protoChain->isCacheable())
+ return;
+ RefPtr<PropertyNameArrayData> data = propertyNames.data();
+ data->setCachedPrototypeChain(protoChain);
+ data->setCachedStructure(m_structure);
+ m_structure->setEnumerationCache(data.release());
+ }
}
void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
{
- m_structure->getOwnEnumerablePropertyNames(exec, propertyNames, this);
+ m_structure->getEnumerablePropertyNames(propertyNames);
+ getEnumerablePropertyNames(exec, classInfo(), propertyNames);
}
bool JSObject::toBoolean(ExecState*) const
diff --git a/JavaScriptCore/runtime/JSObject.h b/JavaScriptCore/runtime/JSObject.h
index 84b5f4b..dc40a63 100644
--- a/JavaScriptCore/runtime/JSObject.h
+++ b/JavaScriptCore/runtime/JSObject.h
@@ -682,7 +682,7 @@ ALWAYS_INLINE void JSObject::markChildrenDirect(MarkStack& markStack)
{
JSCell::markChildren(markStack);
- m_structure->markAggregate(markStack);
+ markStack.append(prototype());
PropertyStorage storage = propertyStorage();
size_t storageSize = m_structure->propertyStorageSize();
diff --git a/JavaScriptCore/runtime/PropertyNameArray.cpp b/JavaScriptCore/runtime/PropertyNameArray.cpp
index 0878e73..cff2605 100644
--- a/JavaScriptCore/runtime/PropertyNameArray.cpp
+++ b/JavaScriptCore/runtime/PropertyNameArray.cpp
@@ -21,6 +21,9 @@
#include "config.h"
#include "PropertyNameArray.h"
+#include "Structure.h"
+#include "StructureChain.h"
+
namespace JSC {
static const size_t setThreshold = 20;
diff --git a/JavaScriptCore/runtime/PropertyNameArray.h b/JavaScriptCore/runtime/PropertyNameArray.h
index afcc83f..7d6edd0 100644
--- a/JavaScriptCore/runtime/PropertyNameArray.h
+++ b/JavaScriptCore/runtime/PropertyNameArray.h
@@ -23,11 +23,13 @@
#include "CallFrame.h"
#include "Identifier.h"
-#include "Structure.h"
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
namespace JSC {
+
+ class Structure;
+ class StructureChain;
class PropertyNameArrayData : public RefCounted<PropertyNameArrayData> {
public:
diff --git a/JavaScriptCore/runtime/Structure.cpp b/JavaScriptCore/runtime/Structure.cpp
index 7209b5f..643a49a 100644
--- a/JavaScriptCore/runtime/Structure.cpp
+++ b/JavaScriptCore/runtime/Structure.cpp
@@ -282,52 +282,6 @@ void Structure::materializePropertyMap()
}
}
-void Structure::getOwnEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject)
-{
- getEnumerableNamesFromPropertyTable(propertyNames);
- getEnumerableNamesFromClassInfoTable(exec, baseObject->classInfo(), propertyNames);
-}
-
-void Structure::getEnumerablePropertyNames(ExecState* exec, PropertyNameArray& propertyNames, JSObject* baseObject)
-{
- bool shouldCache = propertyNames.shouldCache() && !(propertyNames.size() || isDictionary());
-
- if (shouldCache && m_cachedPropertyNameArrayData) {
- if (m_cachedPropertyNameArrayData->cachedPrototypeChain() == prototypeChain(exec)) {
- propertyNames.setData(m_cachedPropertyNameArrayData);
- return;
- }
- clearEnumerationCache();
- }
-
- baseObject->getOwnPropertyNames(exec, propertyNames);
-
- if (m_prototype.isObject()) {
- propertyNames.setShouldCache(false); // No need for our prototypes to waste memory on caching, since they're not being enumerated directly.
- JSObject* prototype = asObject(m_prototype);
- while(1) {
- if (!prototype->structure()->typeInfo().hasDefaultGetPropertyNames()) {
- prototype->getPropertyNames(exec, propertyNames);
- break;
- }
- prototype->getOwnPropertyNames(exec, propertyNames);
- JSValue nextProto = prototype->prototype();
- if (!nextProto.isObject())
- break;
- prototype = asObject(nextProto);
- }
- }
-
- if (shouldCache) {
- StructureChain* protoChain = prototypeChain(exec);
- m_cachedPropertyNameArrayData = propertyNames.data();
- if (!protoChain->isCacheable())
- return;
- m_cachedPropertyNameArrayData->setCachedPrototypeChain(protoChain);
- m_cachedPropertyNameArrayData->setCachedStructure(this);
- }
-}
-
void Structure::clearEnumerationCache()
{
if (m_cachedPropertyNameArrayData)
@@ -1057,7 +1011,7 @@ static int comparePropertyMapEntryIndices(const void* a, const void* b)
return 0;
}
-void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyNames)
+void Structure::getEnumerablePropertyNames(PropertyNameArray& propertyNames)
{
materializePropertyMapIfNecessary();
if (!m_propertyTable)
@@ -1114,25 +1068,6 @@ void Structure::getEnumerableNamesFromPropertyTable(PropertyNameArray& propertyN
}
}
-void Structure::getEnumerableNamesFromClassInfoTable(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames)
-{
- // Add properties from the static hashtables of properties
- for (; classInfo; classInfo = classInfo->parentClass) {
- const HashTable* table = classInfo->propHashTable(exec);
- if (!table)
- continue;
- table->initializeIfNeeded(exec);
- ASSERT(table->table);
-
- int hashSizeMask = table->compactSize - 1;
- const HashEntry* entry = table->table;
- for (int i = 0; i <= hashSizeMask; ++i, ++entry) {
- if (entry->key() && !(entry->attributes() & DontEnum))
- propertyNames.add(entry->key());
- }
- }
-}
-
#if DO_PROPERTYMAP_CONSTENCY_CHECK
void Structure::checkConsistency()
diff --git a/JavaScriptCore/runtime/Structure.h b/JavaScriptCore/runtime/Structure.h
index ed9f6e5..a027b1a 100644
--- a/JavaScriptCore/runtime/Structure.h
+++ b/JavaScriptCore/runtime/Structure.h
@@ -30,6 +30,7 @@
#include "JSType.h"
#include "JSValue.h"
#include "PropertyMapHashTable.h"
+#include "PropertyNameArray.h"
#include "StructureChain.h"
#include "StructureTransitionTable.h"
#include "JSTypeInfo.h"
@@ -76,8 +77,6 @@ namespace JSC {
~Structure();
- void markAggregate(MarkStack&);
-
// These should be used with caution.
size_t addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes, JSCell* specificValue);
size_t removePropertyWithoutTransition(const Identifier& propertyName);
@@ -116,9 +115,6 @@ namespace JSC {
return hasTransition(propertyName._ustring.rep(), attributes);
}
- void getEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*);
- void getOwnEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*);
-
bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; }
void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; }
@@ -127,6 +123,11 @@ namespace JSC {
JSCell* specificValue() { return m_specificValueInPrevious; }
void despecifyDictionaryFunction(const Identifier& propertyName);
+ void setEnumerationCache(PassRefPtr<PropertyNameArrayData> data) { m_cachedPropertyNameArrayData = data; }
+ PropertyNameArrayData* enumerationCache() { return m_cachedPropertyNameArrayData.get(); }
+ void clearEnumerationCache();
+ void getEnumerablePropertyNames(PropertyNameArray&);
+
private:
Structure(JSValue prototype, const TypeInfo&);
@@ -140,8 +141,6 @@ namespace JSC {
size_t put(const Identifier& propertyName, unsigned attributes, JSCell* specificValue);
size_t remove(const Identifier& propertyName);
void addAnonymousSlots(unsigned slotCount);
- void getEnumerableNamesFromPropertyTable(PropertyNameArray&);
- void getEnumerableNamesFromClassInfoTable(ExecState*, const ClassInfo*, PropertyNameArray&);
void expandPropertyMapHashTable();
void rehashPropertyMapHashTable();
@@ -162,8 +161,6 @@ namespace JSC {
materializePropertyMap();
}
- void clearEnumerationCache();
-
signed char transitionCount() const
{
// Since the number of transitions is always the same as m_offset, we keep the size of Structure down by not storing both.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list