Commit 5726238d authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

De-virtualize JSObject::getOwnPropertyNames

https://bugs.webkit.org/show_bug.cgi?id=71307

Reviewed by Darin Adler.

Source/JavaScriptCore: 

Added getOwnPropertyNames to the MethodTable, changed all the virtual 
implementations of getOwnPropertyNames to static ones, and replaced 
all call sites with corresponding lookups in the MethodTable.

* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::getOwnPropertyNames):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::getOwnPropertyNames):
* debugger/DebuggerActivation.h:
* runtime/Arguments.cpp:
(JSC::Arguments::getOwnPropertyNames):
* runtime/Arguments.h:
* runtime/ClassInfo.h:
* runtime/JSActivation.cpp:
(JSC::JSActivation::getOwnPropertyNames):
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
(JSC::JSArray::getOwnPropertyNames):
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::getOwnPropertyNames):
* runtime/JSByteArray.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getOwnPropertyNames):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::getOwnPropertyNames):
* runtime/JSFunction.h:
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::getOwnPropertyNames):
* runtime/JSNotAnObject.h:
* runtime/JSONObject.cpp:
(JSC::Stringifier::Holder::appendNextProperty):
(JSC::Walker::walk):
* runtime/JSObject.cpp:
(JSC::JSObject::getPropertyNames):
(JSC::JSObject::getOwnPropertyNames):
* runtime/JSObject.h:
* runtime/JSVariableObject.cpp:
(JSC::JSVariableObject::~JSVariableObject):
(JSC::JSVariableObject::getOwnPropertyNames):
* runtime/JSVariableObject.h:
* runtime/ObjectConstructor.cpp:
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::defineProperties):
* runtime/RegExpMatchesArray.h:
(JSC::RegExpMatchesArray::getOwnPropertyNames):
* runtime/StringObject.cpp:
(JSC::StringObject::getOwnPropertyNames):
* runtime/StringObject.h:
* runtime/Structure.h:

Source/JavaScriptGlue: 

Added getOwnPropertyNames to the MethodTable, changed all the virtual 
implementations of getOwnPropertyNames to static ones, and replaced 
all call sites with corresponding lookups in the MethodTable.

* UserObjectImp.cpp:
(UserObjectImp::getOwnPropertyNames):
* UserObjectImp.h:

Source/WebCore: 

No new tests.

Added getOwnPropertyNames to the MethodTable, changed all the virtual 
implementations of getOwnPropertyNames to static ones, and replaced 
all call sites with corresponding lookups in the MethodTable.

* WebCore.exp.in:
* bindings/js/JSDOMStringMapCustom.cpp:
(WebCore::JSDOMStringMap::getOwnPropertyNames):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::getOwnPropertyNames):
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::getOwnPropertyNames):
* bindings/js/JSDOMWindowShell.h:
* bindings/js/JSHistoryCustom.cpp:
(WebCore::JSHistory::getOwnPropertyNames):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::getOwnPropertyNames):
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::getOwnPropertyNames):
* bindings/js/ScriptValue.cpp:
(WebCore::jsToInspectorValue):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::serialize):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::QtRuntimeMetaMethod::getOwnPropertyNames):
(JSC::Bindings::QtRuntimeConnectionMethod::getOwnPropertyNames):
* bridge/qt/qt_runtime.h:
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::getOwnPropertyNames):
* bridge/runtime_array.h:
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::getOwnPropertyNames):
* bridge/runtime_object.h:

Source/WebKit2: 

Added getOwnPropertyNames to the MethodTable, changed all the virtual 
implementations of getOwnPropertyNames to static ones, and replaced 
all call sites with corresponding lookups in the MethodTable.

* WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::JSNPObject::getOwnPropertyNames):
* WebProcess/Plugins/Netscape/JSNPObject.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@99126 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3be57b85
......@@ -187,7 +187,7 @@ private:
virtual bool hasInstance(ExecState* exec, JSValue value, JSValue proto);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static ConstructType getConstructData(JSCell*, ConstructData&);
static CallType getCallData(JSCell*, CallData&);
......
......@@ -419,12 +419,13 @@ EncodedJSValue JSCallbackObject<Parent>::call(ExecState* exec)
}
template <class Parent>
void JSCallbackObject<Parent>::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSCallbackObject<Parent>::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSCallbackObject* thisObject = static_cast<JSCallbackObject*>(object);
JSContextRef execRef = toRef(exec);
JSObjectRef thisRef = toRef(this);
JSObjectRef thisRef = toRef(thisObject);
for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) {
APICallbackShim callbackShim(exec);
getPropertyNames(execRef, thisRef, toRef(&propertyNames));
......@@ -453,7 +454,7 @@ void JSCallbackObject<Parent>::getOwnPropertyNames(ExecState* exec, PropertyName
}
}
Parent::getOwnPropertyNames(exec, propertyNames, mode);
Parent::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
template <class Parent>
......
2011-11-02 Mark Hahnenberg <mhahnenberg@apple.com>
De-virtualize JSObject::getOwnPropertyNames
https://bugs.webkit.org/show_bug.cgi?id=71307
Reviewed by Darin Adler.
Added getOwnPropertyNames to the MethodTable, changed all the virtual
implementations of getOwnPropertyNames to static ones, and replaced
all call sites with corresponding lookups in the MethodTable.
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::getOwnPropertyNames):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::getOwnPropertyNames):
* debugger/DebuggerActivation.h:
* runtime/Arguments.cpp:
(JSC::Arguments::getOwnPropertyNames):
* runtime/Arguments.h:
* runtime/ClassInfo.h:
* runtime/JSActivation.cpp:
(JSC::JSActivation::getOwnPropertyNames):
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
(JSC::JSArray::getOwnPropertyNames):
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::getOwnPropertyNames):
* runtime/JSByteArray.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getOwnPropertyNames):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::getOwnPropertyNames):
* runtime/JSFunction.h:
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::getOwnPropertyNames):
* runtime/JSNotAnObject.h:
* runtime/JSONObject.cpp:
(JSC::Stringifier::Holder::appendNextProperty):
(JSC::Walker::walk):
* runtime/JSObject.cpp:
(JSC::JSObject::getPropertyNames):
(JSC::JSObject::getOwnPropertyNames):
* runtime/JSObject.h:
* runtime/JSVariableObject.cpp:
(JSC::JSVariableObject::~JSVariableObject):
(JSC::JSVariableObject::getOwnPropertyNames):
* runtime/JSVariableObject.h:
* runtime/ObjectConstructor.cpp:
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::defineProperties):
* runtime/RegExpMatchesArray.h:
(JSC::RegExpMatchesArray::getOwnPropertyNames):
* runtime/StringObject.cpp:
(JSC::StringObject::getOwnPropertyNames):
* runtime/StringObject.h:
* runtime/Structure.h:
2011-11-02 Dean Jackson <dino@apple.com>
Add ENABLE_CSS_SHADERS flag
......@@ -120,6 +120,7 @@ __ZN3JSC10throwErrorEPNS_9ExecStateEPNS_8JSObjectE
__ZN3JSC11JSByteArray10putByIndexEPNS_6JSCellEPNS_9ExecStateEjNS_7JSValueE
__ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE
__ZN3JSC11JSByteArray18getOwnPropertySlotEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC11JSByteArray19getOwnPropertyNamesEPNS_8JSObjectEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC11JSByteArray25getOwnPropertySlotByIndexEPNS_6JSCellEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3JSC11JSByteArray3putEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC11JSByteArray6s_infoE
......@@ -155,7 +156,6 @@ __ZN3JSC12SamplingTool5setupEv
__ZN3JSC12SmallStrings17createEmptyStringEPNS_12JSGlobalDataE
__ZN3JSC12SmallStrings27createSingleCharacterStringEPNS_12JSGlobalDataEh
__ZN3JSC12StringObject14finishCreationERNS_12JSGlobalDataEPNS_8JSStringE
__ZN3JSC12StringObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC12StringObject24getOwnPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC12StringObject6s_infoE
__ZN3JSC12StringObjectC2ERNS_12JSGlobalDataEPNS_9StructureE
......@@ -198,7 +198,7 @@ __ZN3JSC16InternalFunction6s_infoE
__ZN3JSC16InternalFunctionC2EPNS_14JSGlobalObjectEPNS_9StructureE
__ZN3JSC16JSVariableObject14deletePropertyEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC16JSVariableObject14symbolTableGetERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC16JSVariableObject19getOwnPropertyNamesEPNS_8JSObjectEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC16createRangeErrorEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC16slowValidateCellEPNS_14JSGlobalObjectE
__ZN3JSC16slowValidateCellEPNS_6JSCellE
......@@ -322,7 +322,7 @@ __ZN3JSC8JSObject17putWithAttributesEPNS_12JSGlobalDataEjNS_7JSValueEj
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEjbRNS_15PutPropertySlotE
__ZN3JSC8JSObject17putWithAttributesEPNS_9ExecStateEjNS_7JSValueEj
__ZN3JSC8JSObject19getOwnPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject19getOwnPropertyNamesEPS0_PNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject21deletePropertyByIndexEPNS_6JSCellEPNS_9ExecStateEj
__ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPNS_16WriteBarrierBaseINS_7UnknownEEE
......
......@@ -31,6 +31,7 @@ EXPORTS
??1DropAllLocks@JSLock@JSC@@QAE@XZ
??1JSGlobalData@JSC@@QAE@XZ
??1JSGlobalObject@JSC@@UAE@XZ
??1JSVariableObject@JSC@@UAE@XZ
??1Mutex@WTF@@QAE@XZ
??1RefCountedLeakCounter@WTF@@QAE@XZ
??1ScopeChainNode@JSC@@EAE@XZ
......@@ -194,9 +195,9 @@ EXPORTS
?getOwnPropertyDescriptor@JSObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
?getOwnPropertyDescriptor@JSString@JSC@@EAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
?getOwnPropertyDescriptor@StringObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
?getOwnPropertyNames@JSObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getOwnPropertyNames@JSVariableObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getOwnPropertyNames@StringObject@JSC@@UAEXPAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getOwnPropertyNames@JSByteArray@JSC@@SAXPAVJSObject@2@PAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getOwnPropertyNames@JSObject@JSC@@SAXPAV12@PAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getOwnPropertyNames@JSVariableObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
?getOwnPropertySlot@JSByteArray@JSC@@SA_NPAVJSCell@2@PAVExecState@2@ABVIdentifier@2@AAVPropertySlot@2@@Z
?getOwnPropertySlot@JSGlobalObject@JSC@@SA_NPAVJSCell@2@PAVExecState@2@ABVIdentifier@2@AAVPropertySlot@2@@Z
?getOwnPropertySlotByIndex@JSArray@JSC@@SA_NPAVJSCell@2@PAVExecState@2@IAAVPropertySlot@2@@Z
......
......@@ -83,9 +83,10 @@ bool DebuggerActivation::deleteProperty(JSCell* cell, ExecState* exec, const Ide
return thisObject->m_activation->methodTable()->deleteProperty(thisObject->m_activation.get(), exec, propertyName);
}
void DebuggerActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void DebuggerActivation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
m_activation->getPropertyNames(exec, propertyNames, mode);
DebuggerActivation* thisObject = static_cast<DebuggerActivation*>(object);
thisObject->m_activation->getPropertyNames(exec, propertyNames, mode);
}
bool DebuggerActivation::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
......
......@@ -47,7 +47,7 @@ namespace JSC {
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
static void defineGetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes);
static void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes);
......
......@@ -246,17 +246,18 @@ bool Arguments::getOwnPropertyDescriptor(ExecState* exec, const Identifier& prop
return JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
}
void Arguments::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void Arguments::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
for (unsigned i = 0; i < d->numArguments; ++i) {
if (!d->deletedArguments || !d->deletedArguments[i])
Arguments* thisObject = static_cast<Arguments*>(object);
for (unsigned i = 0; i < thisObject->d->numArguments; ++i) {
if (!thisObject->d->deletedArguments || !thisObject->d->deletedArguments[i])
propertyNames.add(Identifier(exec, UString::number(i)));
}
if (mode == IncludeDontEnumProperties) {
propertyNames.add(exec->propertyNames().callee);
propertyNames.add(exec->propertyNames().length);
}
JSObject::getOwnPropertyNames(exec, propertyNames, mode);
JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
void Arguments::putByIndex(JSCell* cell, ExecState* exec, unsigned i, JSValue value)
......
......@@ -138,7 +138,7 @@ namespace JSC {
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier& propertyName, PropertySlot&);
static bool getOwnPropertySlotByIndex(JSCell*, ExecState*, unsigned propertyName, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue);
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
......
......@@ -25,6 +25,7 @@
#include "CallFrame.h"
#include "ConstructData.h"
#include "JSCell.h"
namespace JSC {
......@@ -70,6 +71,9 @@ namespace JSC {
typedef JSValue (*DefaultValueFunctionPtr)(const JSObject*, ExecState*, PreferredPrimitiveType);
DefaultValueFunctionPtr defaultValue;
typedef void (*GetOwnPropertyNamesFunctionPtr)(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
GetOwnPropertyNamesFunctionPtr getOwnPropertyNames;
};
#define CREATE_MEMBER_CHECKER(member) \
......@@ -105,6 +109,7 @@ struct MemberCheck##member { \
&ClassName::defineGetter, \
&ClassName::defineSetter, \
&ClassName::defaultValue, \
&ClassName::getOwnPropertyNames, \
}, \
sizeof(ClassName)
......
......@@ -110,18 +110,19 @@ inline bool JSActivation::symbolTablePut(JSGlobalData& globalData, const Identif
return true;
}
void JSActivation::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSActivation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
SymbolTable::const_iterator end = symbolTable().end();
for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) {
JSActivation* thisObject = static_cast<JSActivation*>(object);
SymbolTable::const_iterator end = thisObject->symbolTable().end();
for (SymbolTable::const_iterator it = thisObject->symbolTable().begin(); it != end; ++it) {
if (it->second.getAttributes() & DontEnum && mode != IncludeDontEnumProperties)
continue;
if (it->second.getIndex() >= m_numCapturedVars)
if (it->second.getIndex() >= thisObject->m_numCapturedVars)
continue;
propertyNames.add(Identifier(exec, it->first.get()));
}
// Skip the JSVariableObject implementation of getOwnPropertyNames
JSObject::getOwnPropertyNames(exec, propertyNames, mode);
JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
inline bool JSActivation::symbolTablePutWithAttributes(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes)
......
......@@ -60,7 +60,7 @@ namespace JSC {
virtual bool isDynamicScope(bool& requiresDynamicChecks) const;
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
......
......@@ -539,15 +539,16 @@ bool JSArray::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned i)
return false;
}
void JSArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSArray::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSArray* thisObject = static_cast<JSArray*>(object);
// FIXME: Filling PropertyNameArray with an identifier for every integer
// is incredibly inefficient for large arrays. We need a different approach,
// which almost certainly means a different structure for PropertyNameArray.
ArrayStorage* storage = m_storage;
ArrayStorage* storage = thisObject->m_storage;
unsigned usedVectorLength = min(storage->m_length, m_vectorLength);
unsigned usedVectorLength = min(storage->m_length, thisObject->m_vectorLength);
for (unsigned i = 0; i < usedVectorLength; ++i) {
if (storage->m_vector[i])
propertyNames.add(Identifier::from(exec, i));
......@@ -562,7 +563,7 @@ void JSArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNa
if (mode == IncludeDontEnumProperties)
propertyNames.add(exec->propertyNames().length);
JSObject::getOwnPropertyNames(exec, propertyNames, mode);
JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
ALWAYS_INLINE unsigned JSArray::getNewVectorLength(unsigned desiredLength)
......
......@@ -172,7 +172,7 @@ namespace JSC {
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
void* subclassData() const;
void setSubclassData(void*);
......
......@@ -104,12 +104,13 @@ void JSByteArray::putByIndex(JSCell* cell, ExecState* exec, unsigned propertyNam
static_cast<JSByteArray*>(cell)->setIndex(exec, propertyName, value);
}
void JSByteArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSByteArray::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
unsigned length = m_storage->length();
JSByteArray* thisObject = static_cast<JSByteArray*>(object);
unsigned length = thisObject->m_storage->length();
for (unsigned i = 0; i < length; ++i)
propertyNames.add(Identifier::from(exec, i));
JSObject::getOwnPropertyNames(exec, propertyNames, mode);
JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
}
......
......@@ -94,7 +94,7 @@ namespace JSC {
static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
static void putByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue);
virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, EnumerationMode);
static JS_EXPORTDATA const ClassInfo s_info;
......
......@@ -174,4 +174,9 @@ JSValue JSCell::defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType
return jsUndefined();
}
void JSCell::getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode)
{
ASSERT_NOT_REACHED();
}
} // namespace JSC
......@@ -37,6 +37,12 @@ namespace JSC {
class JSGlobalObject;
class Structure;
class PropertyNameArray;
enum EnumerationMode {
ExcludeDontEnumProperties,
IncludeDontEnumProperties
};
class JSCell {
friend class JSValue;
......@@ -137,6 +143,7 @@ namespace JSC {
static NO_RETURN_DUE_TO_ASSERT void defineGetter(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned);
static NO_RETURN_DUE_TO_ASSERT void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes = 0);
static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
static NO_RETURN_DUE_TO_ASSERT void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
private:
WriteBarrier<Structure> m_structure;
......
......@@ -298,18 +298,19 @@ bool JSFunction::getOwnPropertyDescriptor(ExecState* exec, const Identifier& pro
return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor);
}
void JSFunction::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSFunction::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
if (!isHostFunction() && (mode == IncludeDontEnumProperties)) {
JSFunction* thisObject = static_cast<JSFunction*>(object);
if (!thisObject->isHostFunction() && (mode == IncludeDontEnumProperties)) {
// Make sure prototype has been reified.
PropertySlot slot;
methodTable()->getOwnPropertySlot(this, exec, exec->propertyNames().prototype, slot);
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, exec->propertyNames().prototype, slot);
propertyNames.add(exec->propertyNames().arguments);
propertyNames.add(exec->propertyNames().caller);
propertyNames.add(exec->propertyNames().length);
}
Base::getOwnPropertyNames(exec, propertyNames, mode);
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
void JSFunction::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
......
......@@ -131,7 +131,7 @@ namespace JSC {
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode = ExcludeDontEnumProperties);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
......
......@@ -86,7 +86,7 @@ bool JSNotAnObject::deletePropertyByIndex(JSCell*, ExecState* exec, unsigned)
return false;
}
void JSNotAnObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray&, EnumerationMode)
void JSNotAnObject::getOwnPropertyNames(JSObject*, ExecState* exec, PropertyNameArray&, EnumerationMode)
{
ASSERT_UNUSED(exec, exec->hadException());
}
......
......@@ -78,7 +78,7 @@ namespace JSC {
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
};
} // namespace JSC
......
......@@ -494,7 +494,7 @@ bool Stringifier::Holder::appendNextProperty(Stringifier& stringifier, UStringBu
m_propertyNames = stringifier.m_arrayReplacerPropertyNames.data();
else {
PropertyNameArray objectPropertyNames(exec);
m_object->getOwnPropertyNames(exec, objectPropertyNames);
m_object->methodTable()->getOwnPropertyNames(m_object.get(), exec, objectPropertyNames, ExcludeDontEnumProperties);
m_propertyNames = objectPropertyNames.releaseData();
}
m_size = m_propertyNames->propertyNameVector().size();
......@@ -728,7 +728,7 @@ NEVER_INLINE JSValue Walker::walk(JSValue unfiltered)
objectStack.push(object);
indexStack.append(0);
propertyStack.append(PropertyNameArray(m_exec));
object->getOwnPropertyNames(m_exec, propertyStack.last());
object->methodTable()->getOwnPropertyNames(object, m_exec, propertyStack.last(), ExcludeDontEnumProperties);
// fallthrough
}
objectStartVisitMember:
......
......@@ -497,7 +497,7 @@ bool JSObject::getPropertySpecificValue(ExecState* exec, const Identifier& prope
void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
getOwnPropertyNames(exec, propertyNames, mode);
methodTable()->getOwnPropertyNames(this, exec, propertyNames, mode);
if (prototype().isNull())
return;
......@@ -508,7 +508,7 @@ void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyName
prototype->getPropertyNames(exec, propertyNames, mode);
break;
}
prototype->getOwnPropertyNames(exec, propertyNames, mode);
prototype->methodTable()->getOwnPropertyNames(prototype, exec, propertyNames, mode);
JSValue nextProto = prototype->prototype();
if (nextProto.isNull())
break;
......@@ -516,11 +516,11 @@ void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyName
}
}
void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
structure()->getPropertyNames(exec->globalData(), propertyNames, mode);
if (!staticFunctionsReified())
getClassPropertyNames(exec, classInfo(), propertyNames, mode);
object->structure()->getPropertyNames(exec->globalData(), propertyNames, mode);
if (!object->staticFunctionsReified())
getClassPropertyNames(exec, object->classInfo(), propertyNames, mode);
}
bool JSObject::toBoolean(ExecState*) const
......
......@@ -127,7 +127,7 @@ namespace JSC {
virtual bool hasInstance(ExecState*, JSValue, JSValue prototypeProperty);
virtual void getPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;
bool toBoolean(ExecState*) const;
......
......@@ -34,6 +34,10 @@
namespace JSC {
JSVariableObject::~JSVariableObject()
{
}
bool JSVariableObject::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
{
JSVariableObject* thisObject = static_cast<JSVariableObject*>(cell);
......@@ -43,15 +47,16 @@ bool JSVariableObject::deleteProperty(JSCell* cell, ExecState* exec, const Ident
return JSObject::deleteProperty(thisObject, exec, propertyName);
}
void JSVariableObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
void JSVariableObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
SymbolTable::const_iterator end = symbolTable().end();
for (SymbolTable::const_iterator it = symbolTable().begin(); it != end; ++it) {
JSVariableObject* thisObject = static_cast<JSVariableObject*>(object);
SymbolTable::const_iterator end = thisObject->symbolTable().end();
for (SymbolTable::const_iterator it = thisObject->symbolTable().begin(); it != end; ++it) {
if (!(it->second.getAttributes() & DontEnum) || (mode == IncludeDontEnumProperties))
propertyNames.add(Identifier(exec, it->first.get()));
}
JSObject::getOwnPropertyNames(exec, propertyNames, mode);
JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertyDescriptor& descriptor)
......
......@@ -48,10 +48,12 @@ namespace JSC {
SymbolTable& symbolTable() const { return *m_symbolTable; }
virtual ~JSVariableObject();
virtual void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes) = 0;
static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
virtual bool isDynamicScope(bool& requiresDynamicChecks) const = 0;
......
......@@ -178,7 +178,7 @@ EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState* exe
if (!exec->argument(0).isObject())
return throwVMError(exec, createTypeError(exec, "Requested property names of a value that is not an object."));
PropertyNameArray properties(exec);
asObject(exec->argument(0))->getOwnPropertyNames(exec, properties, IncludeDontEnumProperties);
asObject(exec->argument(0))->methodTable()->getOwnPropertyNames(asObject(exec->argument(0)), exec, properties, IncludeDontEnumProperties);
JSArray* names = constructEmptyArray(exec);
size_t numProperties = properties.size();
for (size_t i = 0; i < numProperties; i++)
......@@ -192,7 +192,7 @@ EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState* exec)
if (!exec->argument(0).isObject())
return throwVMError(exec, createTypeError(exec, "Requested keys of a value that is not an object."));
PropertyNameArray properties(exec);
asObject(exec->argument(0))->getOwnPropertyNames(exec, properties);
asObject(exec->argument(0))->methodTable()->getOwnPropertyNames(asObject(exec->argument(0)), exec, properties, ExcludeDontEnumProperties);
JSArray* keys = constructEmptyArray(exec);
size_t numProperties = properties.size();
for (size_t i = 0; i < numProperties; i++)
......@@ -306,7 +306,7 @@ EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec)
static JSValue defineProperties(ExecState* exec, JSObject* object, JSObject* properties)
{
PropertyNameArray propertyNames(exec);
asObject(properties)->getOwnPropertyNames(exec, propertyNames);
asObject(properties)->methodTable()->getOwnPropertyNames(asObject(properties), exec, propertyNames, ExcludeDontEnumProperties);
size_t numProperties = propertyNames.size();
Vector<PropertyDescriptor> descriptors;
MarkedArgumentBuffer markBuffer;
......
......@@ -105,11 +105,12 @@ namespace JSC {
return JSArray::deletePropertyByIndex(thisObject, exec, propertyName);
}
virtual void getOwnPropertyNames(ExecState* exec, PropertyNameArray& arr, EnumerationMode mode = ExcludeDontEnumProperties)
static void getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& arr, EnumerationMode mode = ExcludeDontEnumProperties)
{
if (subclassData())
fillArrayInstance(exec);
JSArray::getOwnPropertyNames(exec, arr, mode);
RegExpMatchesArray* thisObject = static_cast<RegExpMatchesArray*>(object);
if (thisObject->subclassData())
thisObject->fillArrayInstance(exec);
JSArray::getOwnPropertyNames(thisObject, exec, arr, mode);
}