Commit 5e2b7127 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

Add static version of JSCell::put

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Added static version of both versions of put to all classes that
override them and changed the virtual versions to call the static
versions.

* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::put):
* JavaScriptCore.exp:
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::put):
* debugger/DebuggerActivation.h:
* runtime/Arguments.cpp:
(JSC::Arguments::put):
* runtime/Arguments.h:
* runtime/JSActivation.cpp:
(JSC::JSActivation::put):
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
(JSC::JSArray::put):
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::put):
* runtime/JSByteArray.h:
* runtime/JSCell.cpp:
(JSC::JSCell::put):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::put):
* runtime/JSFunction.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::put):
* runtime/JSGlobalObject.h:
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::put):
* runtime/JSNotAnObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::put):
* runtime/JSObject.h:
* runtime/JSStaticScopeObject.cpp:
(JSC::JSStaticScopeObject::put):
* runtime/JSStaticScopeObject.h:
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::put):
* runtime/ObjectPrototype.h:
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::put):
* runtime/RegExpConstructor.h:
* runtime/RegExpMatchesArray.h:
(JSC::RegExpMatchesArray::put):
* runtime/RegExpObject.cpp:
(JSC::RegExpObject::put):
* runtime/RegExpObject.h:
* runtime/StringObject.cpp:
(JSC::StringObject::put):
* runtime/StringObject.h:

Source/JavaScriptGlue:

Added static version of both versions of put to all classes that
override them and changed the virtual versions to call the static
versions.

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

Source/WebCore:

No new tests.

Added static version of both versions of put to all classes that
override them and changed the virtual versions to call the static
versions.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObj::put):
* bindings/scripts/test/JS/JSTestObj.h:
* bridge/objc/objc_runtime.h:
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcFallbackObjectImp::put):
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::put):
* bridge/runtime_array.h:
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::put):
* bridge/runtime_object.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96992 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 75dc1490
......@@ -182,6 +182,7 @@ private:
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual bool deleteProperty(ExecState*, unsigned);
......
......@@ -203,12 +203,19 @@ bool JSCallbackObject<Parent>::getOwnPropertyDescriptor(ExecState* exec, const I
template <class Parent>
void JSCallbackObject<Parent>::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
put(this, exec, propertyName, value, slot);
}
template <class Parent>
void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSCallbackObject* thisObject = static_cast<JSCallbackObject*>(cell);
JSContextRef ctx = toRef(exec);
JSObjectRef thisRef = toRef(this);
JSObjectRef thisRef = toRef(thisObject);
RefPtr<OpaqueJSString> propertyNameRef;
JSValueRef valueRef = toRef(exec, value);
for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
if (!propertyNameRef)
propertyNameRef = OpaqueJSString::create(propertyName.ustring());
......@@ -249,13 +256,13 @@ void JSCallbackObject<Parent>::put(ExecState* exec, const Identifier& propertyNa
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
if (entry->attributes & kJSPropertyAttributeReadOnly)
return;
JSCallbackObject<Parent>::putDirect(exec->globalData(), propertyName, value); // put as override property
thisObject->JSCallbackObject<Parent>::putDirect(exec->globalData(), propertyName, value); // put as override property
return;
}
}
}
return Parent::put(exec, propertyName, value, slot);
return Parent::put(thisObject, exec, propertyName, value, slot);
}
template <class Parent>
......
2011-10-07 Mark Hahnenberg <mhahnenberg@apple.com>
Add static version of JSCell::put
https://bugs.webkit.org/show_bug.cgi?id=69382
Reviewed by Geoffrey Garen.
Added static version of both versions of put to all classes that
override them and changed the virtual versions to call the static
versions.
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::put):
* JavaScriptCore.exp:
* debugger/DebuggerActivation.cpp:
(JSC::DebuggerActivation::put):
* debugger/DebuggerActivation.h:
* runtime/Arguments.cpp:
(JSC::Arguments::put):
* runtime/Arguments.h:
* runtime/JSActivation.cpp:
(JSC::JSActivation::put):
* runtime/JSActivation.h:
* runtime/JSArray.cpp:
(JSC::JSArray::put):
* runtime/JSArray.h:
* runtime/JSByteArray.cpp:
(JSC::JSByteArray::put):
* runtime/JSByteArray.h:
* runtime/JSCell.cpp:
(JSC::JSCell::put):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::put):
* runtime/JSFunction.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::put):
* runtime/JSGlobalObject.h:
* runtime/JSNotAnObject.cpp:
(JSC::JSNotAnObject::put):
* runtime/JSNotAnObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::put):
* runtime/JSObject.h:
* runtime/JSStaticScopeObject.cpp:
(JSC::JSStaticScopeObject::put):
* runtime/JSStaticScopeObject.h:
* runtime/ObjectPrototype.cpp:
(JSC::ObjectPrototype::put):
* runtime/ObjectPrototype.h:
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::put):
* runtime/RegExpConstructor.h:
* runtime/RegExpMatchesArray.h:
(JSC::RegExpMatchesArray::put):
* runtime/RegExpObject.cpp:
(JSC::RegExpObject::put):
* runtime/RegExpObject.h:
* runtime/StringObject.cpp:
(JSC::StringObject::put):
* runtime/StringObject.h:
2011-10-07 Gavin Barraclough <barraclough@apple.com>
Refactor DFG to make for use of callOperation
......@@ -331,6 +331,7 @@ __ZN3JSC8JSObject23allocatePropertyStorageERNS_12JSGlobalDataEmm
__ZN3JSC8JSObject24getOwnPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC8JSObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC8JSObject3putEPNS_9ExecStateEjNS_7JSValueE
__ZN3JSC8JSObject3putEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
__ZN3JSC8JSObject6s_infoE
__ZN3JSC8JSString6s_infoE
__ZN3JSC8Profiler13stopProfilingEPNS_9ExecStateERKNS_7UStringE
......
......@@ -275,6 +275,7 @@ EXPORTS
?put@JSCell@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
?put@JSCell@JSC@@UAEXPAVExecState@2@IVJSValue@2@@Z
?put@JSGlobalObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
?put@JSObject@JSC@@SAXPAVJSCell@2@PAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
?put@JSObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
?put@JSObject@JSC@@UAEXPAVExecState@2@IVJSValue@2@@Z
?put@StringObject@JSC@@UAEXPAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
......
......@@ -67,7 +67,12 @@ bool DebuggerActivation::getOwnPropertySlot(ExecState* exec, const Identifier& p
void DebuggerActivation::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
m_activation->put(exec, propertyName, value, slot);
put(this, exec, propertyName, value, slot);
}
void DebuggerActivation::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
static_cast<DebuggerActivation*>(cell)->m_activation->put(exec, propertyName, value, slot);
}
void DebuggerActivation::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
......
......@@ -45,6 +45,7 @@ namespace JSC {
virtual UString className() const;
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
......
......@@ -259,49 +259,61 @@ void Arguments::getOwnPropertyNames(ExecState* exec, PropertyNameArray& property
void Arguments::put(ExecState* exec, unsigned i, JSValue value)
{
if (i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {
if (i < d->numParameters)
d->registers[d->firstParameterIndex + i].set(exec->globalData(), d->activation ? static_cast<JSCell*>(d->activation.get()) : static_cast<JSCell*>(this), value);
put(this, exec, i, value);
}
void Arguments::put(JSCell* cell, ExecState* exec, unsigned i, JSValue value)
{
Arguments* thisObject = static_cast<Arguments*>(cell);
if (i < thisObject->d->numArguments && (!thisObject->d->deletedArguments || !thisObject->d->deletedArguments[i])) {
if (i < thisObject->d->numParameters)
thisObject->d->registers[thisObject->d->firstParameterIndex + i].set(exec->globalData(), thisObject->d->activation ? static_cast<JSCell*>(thisObject->d->activation.get()) : cell, value);
else
d->extraArguments[i - d->numParameters].set(exec->globalData(), this, value);
thisObject->d->extraArguments[i - thisObject->d->numParameters].set(exec->globalData(), thisObject, value);
return;
}
PutPropertySlot slot;
JSObject::put(exec, Identifier(exec, UString::number(i)), value, slot);
JSObject::put(thisObject, exec, Identifier(exec, UString::number(i)), value, slot);
}
void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
put(this, exec, propertyName, value, slot);
}
void Arguments::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
Arguments* thisObject = static_cast<Arguments*>(cell);
bool isArrayIndex;
unsigned i = propertyName.toArrayIndex(isArrayIndex);
if (isArrayIndex && i < d->numArguments && (!d->deletedArguments || !d->deletedArguments[i])) {
if (i < d->numParameters)
d->registers[d->firstParameterIndex + i].set(exec->globalData(), d->activation ? static_cast<JSCell*>(d->activation.get()) : static_cast<JSCell*>(this), value);
if (isArrayIndex && i < thisObject->d->numArguments && (!thisObject->d->deletedArguments || !thisObject->d->deletedArguments[i])) {
if (i < thisObject->d->numParameters)
thisObject->d->registers[thisObject->d->firstParameterIndex + i].set(exec->globalData(), thisObject->d->activation ? static_cast<JSCell*>(thisObject->d->activation.get()) : static_cast<JSCell*>(thisObject), value);
else
d->extraArguments[i - d->numParameters].set(exec->globalData(), this, value);
thisObject->d->extraArguments[i - thisObject->d->numParameters].set(exec->globalData(), thisObject, value);
return;
}
if (propertyName == exec->propertyNames().length && !d->overrodeLength) {
d->overrodeLength = true;
putDirect(exec->globalData(), propertyName, value, DontEnum);
if (propertyName == exec->propertyNames().length && !thisObject->d->overrodeLength) {
thisObject->d->overrodeLength = true;
thisObject->putDirect(exec->globalData(), propertyName, value, DontEnum);
return;
}
if (propertyName == exec->propertyNames().callee && !d->overrodeCallee) {
if (!d->isStrictMode) {
d->overrodeCallee = true;
putDirect(exec->globalData(), propertyName, value, DontEnum);
if (propertyName == exec->propertyNames().callee && !thisObject->d->overrodeCallee) {
if (!thisObject->d->isStrictMode) {
thisObject->d->overrodeCallee = true;
thisObject->putDirect(exec->globalData(), propertyName, value, DontEnum);
return;
}
createStrictModeCalleeIfNecessary(exec);
thisObject->createStrictModeCalleeIfNecessary(exec);
}
if (propertyName == exec->propertyNames().caller && d->isStrictMode)
createStrictModeCallerIfNecessary(exec);
if (propertyName == exec->propertyNames().caller && thisObject->d->isStrictMode)
thisObject->createStrictModeCallerIfNecessary(exec);
JSObject::put(exec, propertyName, value, slot);
JSObject::put(thisObject, exec, propertyName, value, slot);
}
bool Arguments::deleteProperty(ExecState* exec, unsigned i)
......
......@@ -129,7 +129,9 @@ namespace JSC {
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual void put(ExecState*, unsigned propertyName, JSValue);
static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual bool deleteProperty(ExecState*, unsigned propertyName);
void createStrictModeCallerIfNecessary(ExecState*);
......
......@@ -165,16 +165,22 @@ bool JSActivation::getOwnPropertySlot(ExecState* exec, const Identifier& propert
void JSActivation::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
put(this, exec, propertyName, value, slot);
}
void JSActivation::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSActivation* thisObject = static_cast<JSActivation*>(cell);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
if (symbolTablePut(exec->globalData(), propertyName, value))
if (thisObject->symbolTablePut(exec->globalData(), propertyName, value))
return;
// We don't call through to JSObject because __proto__ and getter/setter
// properties are non-standard extensions that other implementations do not
// expose in the activation object.
ASSERT(!hasGetterSetterProperties());
putDirect(exec->globalData(), propertyName, value, 0, true, slot);
ASSERT(!thisObject->hasGetterSetterProperties());
thisObject->putDirect(exec->globalData(), propertyName, value, 0, true, slot);
}
// FIXME: Make this function honor ReadOnly (const) and DontEnum
......
......@@ -65,6 +65,7 @@ namespace JSC {
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode);
virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
virtual void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
......
......@@ -322,13 +322,19 @@ bool JSArray::getOwnPropertyDescriptor(ExecState* exec, const Identifier& proper
return JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor);
}
// ECMA 15.4.5.1
void JSArray::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
put(this, exec, propertyName, value, slot);
}
// ECMA 15.4.5.1
void JSArray::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSArray* thisObject = static_cast<JSArray*>(cell);
bool isArrayIndex;
unsigned i = propertyName.toArrayIndex(isArrayIndex);
if (isArrayIndex) {
put(exec, i, value);
put(thisObject, exec, i, value);
return;
}
......@@ -338,18 +344,24 @@ void JSArray::put(ExecState* exec, const Identifier& propertyName, JSValue value
throwError(exec, createRangeError(exec, "Invalid array length"));
return;
}
setLength(newLength);
thisObject->setLength(newLength);
return;
}
JSObject::put(exec, propertyName, value, slot);
JSObject::put(thisObject, exec, propertyName, value, slot);
}
void JSArray::put(ExecState* exec, unsigned i, JSValue value)
{
checkConsistency();
put(this, exec, i, value);
}
ArrayStorage* storage = m_storage;
void JSArray::put(JSCell* cell, ExecState* exec, unsigned i, JSValue value)
{
JSArray* thisObject = static_cast<JSArray*>(cell);
thisObject->checkConsistency();
ArrayStorage* storage = thisObject->m_storage;
unsigned length = storage->m_length;
if (i >= length && i <= MAX_ARRAY_INDEX) {
......@@ -357,20 +369,20 @@ void JSArray::put(ExecState* exec, unsigned i, JSValue value)
storage->m_length = length;
}
if (i < m_vectorLength) {
if (i < thisObject->m_vectorLength) {
WriteBarrier<Unknown>& valueSlot = storage->m_vector[i];
if (valueSlot) {
valueSlot.set(exec->globalData(), this, value);
checkConsistency();
valueSlot.set(exec->globalData(), thisObject, value);
thisObject->checkConsistency();
return;
}
valueSlot.set(exec->globalData(), this, value);
valueSlot.set(exec->globalData(), thisObject, value);
++storage->m_numValuesInVector;
checkConsistency();
thisObject->checkConsistency();
return;
}
putSlowCase(exec, i, value);
thisObject->putSlowCase(exec, i, value);
}
NEVER_INLINE void JSArray::putSlowCase(ExecState* exec, unsigned i, JSValue value)
......
......@@ -98,6 +98,7 @@ namespace JSC {
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void put(ExecState*, unsigned propertyName, JSValue); // FIXME: Make protected and add setItem.
static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
static JS_EXPORTDATA const ClassInfo s_info;
......@@ -169,6 +170,8 @@ namespace JSC {
protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | OverridesGetPropertyNames | JSObject::StructureFlags;
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual bool deleteProperty(ExecState*, unsigned propertyName);
virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
......
......@@ -87,18 +87,29 @@ bool JSByteArray::getOwnPropertySlot(ExecState* exec, unsigned propertyName, Pro
void JSByteArray::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
put(this, exec, propertyName, value, slot);
}
void JSByteArray::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSByteArray* thisObject = static_cast<JSByteArray*>(cell);
bool ok;
unsigned index = propertyName.toUInt32(ok);
if (ok) {
setIndex(exec, index, value);
thisObject->setIndex(exec, index, value);
return;
}
JSObject::put(exec, propertyName, value, slot);
JSObject::put(thisObject, exec, propertyName, value, slot);
}
void JSByteArray::put(ExecState* exec, unsigned propertyName, JSValue value)
{
setIndex(exec, propertyName, value);
put(this, exec, propertyName, value);
}
void JSByteArray::put(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue value)
{
static_cast<JSByteArray*>(cell)->setIndex(exec, propertyName, value);
}
void JSByteArray::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
......
......@@ -92,7 +92,9 @@ namespace JSC {
virtual bool getOwnPropertySlot(JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
virtual void put(JSC::ExecState*, unsigned propertyName, JSC::JSValue);
static void put(JSC::JSCell*, JSC::ExecState*, unsigned propertyName, JSC::JSValue);
virtual void getOwnPropertyNames(JSC::ExecState*, JSC::PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties);
......
......@@ -95,12 +95,22 @@ bool JSCell::getOwnPropertySlot(ExecState* exec, unsigned identifier, PropertySl
void JSCell::put(ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot)
{
toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value, slot);
put(this, exec, identifier, value, slot);
}
void JSCell::put(JSCell* cell, ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot)
{
cell->toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value, slot);
}
void JSCell::put(ExecState* exec, unsigned identifier, JSValue value)
{
toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value);
put(this, exec, identifier, value);
}
void JSCell::put(JSCell* cell, ExecState* exec, unsigned identifier, JSValue value)
{
cell->toObject(exec, exec->lexicalGlobalObject())->put(exec, identifier, value);
}
bool JSCell::deleteProperty(ExecState* exec, const Identifier& identifier)
......
......@@ -91,7 +91,10 @@ namespace JSC {
const ClassInfo* classInfo() const;
const MethodTable* methodTable() const;
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual void put(ExecState*, unsigned propertyName, JSValue);
static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
virtual bool deleteProperty(ExecState*, unsigned propertyName);
......
......@@ -301,17 +301,23 @@ void JSFunction::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propert
void JSFunction::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
if (isHostFunction()) {
Base::put(exec, propertyName, value, slot);
put(this, exec, propertyName, value, slot);
}
void JSFunction::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSFunction* thisObject = static_cast<JSFunction*>(cell);
if (thisObject->isHostFunction()) {
Base::put(thisObject, exec, propertyName, value, slot);
return;
}
if (propertyName == exec->propertyNames().prototype) {
// Make sure prototype has been reified, such that it can only be overwritten
// following the rules set out in ECMA-262 8.12.9.
PropertySlot slot;
getOwnPropertySlot(exec, propertyName, slot);
thisObject->getOwnPropertySlot(exec, propertyName, slot);
}
if (jsExecutable()->isStrictMode()) {
if (thisObject->jsExecutable()->isStrictMode()) {
if (propertyName == exec->propertyNames().arguments) {
throwTypeError(exec, StrictModeArgumentsAccessError);
return;
......@@ -323,7 +329,7 @@ void JSFunction::put(ExecState* exec, const Identifier& propertyName, JSValue va
}
if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length)
return;
Base::put(exec, propertyName, value, slot);
Base::put(thisObject, exec, propertyName, value, slot);
}
bool JSFunction::deleteProperty(ExecState* exec, const Identifier& propertyName)
......
......@@ -143,6 +143,8 @@ namespace JSC {
bool isHostFunctionNonInline() const;
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
static JSValue argumentsGetter(ExecState*, JSValue, const Identifier&);
......
......@@ -136,11 +136,17 @@ void JSGlobalObject::init(JSObject* thisValue)
void JSGlobalObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
put(this, exec, propertyName, value, slot);
}
void JSGlobalObject::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
JSGlobalObject* thisObject = static_cast<JSGlobalObject*>(cell);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
if (symbolTablePut(exec->globalData(), propertyName, value))
if (thisObject->symbolTablePut(exec->globalData(), propertyName, value))
return;
JSVariableObject::put(exec, propertyName, value, slot);
JSVariableObject::put(thisObject, exec, propertyName, value, slot);
}
void JSGlobalObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
......
......@@ -183,6 +183,8 @@ namespace JSC {
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual bool hasOwnPropertyForWrite(ExecState*, const Identifier&);
virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue value, unsigned attributes);
virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunc, unsigned attributes);
......
......@@ -76,12 +76,22 @@ bool JSNotAnObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier&,
return false;
}
void JSNotAnObject::put(ExecState* exec, const Identifier& , JSValue, PutPropertySlot&)
void JSNotAnObject::put(ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot)
{
put(this, exec, identifier, value, slot);
}
void JSNotAnObject::put(JSCell*, ExecState* exec, const Identifier& , JSValue, PutPropertySlot&)
{
ASSERT_UNUSED(exec, exec->hadException());
}
void JSNotAnObject::put(ExecState* exec, unsigned, JSValue)
void JSNotAnObject::put(ExecState* exec, unsigned i, JSValue value)
{
put(this, exec, i, value);
}
void JSNotAnObject::put(JSCell*, ExecState* exec, unsigned, JSValue)
{
ASSERT_UNUSED(exec, exec->hadException());
}
......
......@@ -75,7 +75,10 @@ namespace JSC {
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual void put(ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
virtual void put(ExecState*, unsigned propertyName, JSValue);
static void put(JSCell*, ExecState*, unsigned propertyName, JSValue);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);