Diff
Modified: trunk/Source/_javascript_Core/API/JSObjectRef.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -274,7 +274,7 @@
JSValue jsValue = toJS(exec, value);
if (attributes && !jsObject->hasProperty(exec, name))
- jsObject->methodTable()->putWithAttributes(jsObject, exec, name, jsValue, attributes);
+ jsObject->methodTable()->putDirectVirtual(jsObject, exec, name, jsValue, attributes);
else {
PutPropertySlot slot;
jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
Modified: trunk/Source/_javascript_Core/ChangeLog (104898 => 104899)
--- trunk/Source/_javascript_Core/ChangeLog 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-01-13 06:44:31 UTC (rev 104899)
@@ -30,6 +30,57 @@
2012-01-12 Gavin Barraclough <barraclo...@apple.com>
+ Clean up putDirect (part 2)
+ https://bugs.webkit.org/show_bug.cgi?id=76232
+
+ Reviewed by Sam Weinig.
+
+ Rename putWithAttributes to putDirectVirtual, to identify that this
+ has the same unchecked-DefineOwnProperty behaviour, change putDirectInternal
+ to be templated on an enum indicating which behaviour it is supposed to be
+ implementing, and change clients that are defining properties to call
+ putDirectInternal correctly.
+
+ * API/JSObjectRef.cpp:
+ (JSObjectSetProperty):
+ * _javascript_Core.exp:
+ * debugger/DebuggerActivation.cpp:
+ (JSC::DebuggerActivation::putDirectVirtual):
+ * debugger/DebuggerActivation.h:
+ * interpreter/Interpreter.cpp:
+ (JSC::Interpreter::execute):
+ * runtime/ClassInfo.h:
+ * runtime/Error.cpp:
+ (JSC::addErrorInfo):
+ * runtime/JSActivation.cpp:
+ (JSC::JSActivation::putDirectVirtual):
+ * runtime/JSActivation.h:
+ * runtime/JSCell.cpp:
+ (JSC::JSCell::putDirectVirtual):
+ * runtime/JSCell.h:
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::putDirectVirtual):
+ * runtime/JSGlobalObject.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::put):
+ (JSC::JSObject::putDirectVirtual):
+ (JSC::JSObject::defineGetter):
+ (JSC::JSObject::initializeGetterSetterProperty):
+ (JSC::JSObject::defineSetter):
+ (JSC::putDescriptor):
+ * runtime/JSObject.h:
+ (JSC::JSObject::putDirectInternal):
+ (JSC::JSObject::putOwnDataProperty):
+ (JSC::JSObject::putDirect):
+ * runtime/JSStaticScopeObject.cpp:
+ (JSC::JSStaticScopeObject::putDirectVirtual):
+ * runtime/JSStaticScopeObject.h:
+ * runtime/JSVariableObject.cpp:
+ (JSC::JSVariableObject::putDirectVirtual):
+ * runtime/JSVariableObject.h:
+
+2012-01-12 Gavin Barraclough <barraclo...@apple.com>
+
Clean up putDirect (part 1)
https://bugs.webkit.org/show_bug.cgi?id=76232
Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (104898 => 104899)
--- trunk/Source/_javascript_Core/_javascript_Core.exp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -168,7 +168,7 @@
__ZN3JSC14JSGlobalObject13clearRareDataEPNS_6JSCellE
__ZN3JSC14JSGlobalObject13visitChildrenEPNS_6JSCellERNS_11SlotVisitorE
__ZN3JSC14JSGlobalObject16addStaticGlobalsEPNS0_18GlobalPropertyInfoEi
-__ZN3JSC14JSGlobalObject17putWithAttributesEPNS_8JSObjectEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
+__ZN3JSC14JSGlobalObject16putDirectVirtualEPNS_8JSObjectEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
__ZN3JSC14JSGlobalObject18getOwnPropertySlotEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC14JSGlobalObject24getOwnPropertyDescriptorEPNS_8JSObjectEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
__ZN3JSC14JSGlobalObject25s_globalObjectMethodTableE
@@ -322,8 +322,7 @@
__ZN3JSC8JSObject16getPropertyNamesEPS0_PNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject17defineOwnPropertyEPS0_PNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
__ZN3JSC8JSObject17preventExtensionsERNS_12JSGlobalDataE
-__ZN3JSC8JSObject17putWithAttributesEPNS_12JSGlobalDataERKNS_10IdentifierENS_7JSValueEj
-__ZN3JSC8JSObject17putWithAttributesEPS0_PNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
+__ZN3JSC8JSObject16putDirectVirtualEPS0_PNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
__ZN3JSC8JSObject19getOwnPropertyNamesEPS0_PNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
__ZN3JSC8JSObject21deletePropertyByIndexEPNS_6JSCellEPNS_9ExecStateEj
__ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (104898 => 104899)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2012-01-13 06:44:31 UTC (rev 104899)
@@ -274,9 +274,8 @@
?put@JSObject@JSC@@SAXPAVJSCell@2@PAVExecState@2@ABVIdentifier@2@VJSValue@2@AAVPutPropertySlot@2@@Z
?putByIndex@JSByteArray@JSC@@SAXPAVJSCell@2@PAVExecState@2@IVJSValue@2@@Z
?putByIndex@JSObject@JSC@@SAXPAVJSCell@2@PAVExecState@2@IVJSValue@2@@Z
- ?putDirectInternal@JSObject@JSC@@AAE_NAAVJSGlobalData@2@ABVIdentifier@2@VJSValue@2@I_NAAVPutPropertySlot@2@PAVJSCell@2@@Z
- ?putWithAttributes@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@VJSValue@2@I@Z
- ?putWithAttributes@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@VJSValue@2@I@Z
+ ?putDirectVirtual@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@VJSValue@2@I@Z
+ ?putDirectVirtual@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@VJSValue@2@I@Z
?randomNumber@WTF@@YANXZ
?recompileAllJSFunctions@Debugger@JSC@@QAEXPAVJSGlobalData@2@@Z
?regExpFlags@JSC@@YA?AW4RegExpFlags@1@ABVUString@1@@Z
Modified: trunk/Source/_javascript_Core/debugger/DebuggerActivation.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/debugger/DebuggerActivation.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/debugger/DebuggerActivation.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -77,10 +77,10 @@
thisObject->m_activation->methodTable()->put(thisObject->m_activation.get(), exec, propertyName, value, slot);
}
-void DebuggerActivation::putWithAttributes(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
+void DebuggerActivation::putDirectVirtual(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
{
DebuggerActivation* thisObject = jsCast<DebuggerActivation*>(object);
- thisObject->m_activation->methodTable()->putWithAttributes(thisObject->m_activation.get(), exec, propertyName, value, attributes);
+ thisObject->m_activation->methodTable()->putDirectVirtual(thisObject->m_activation.get(), exec, propertyName, value, attributes);
}
bool DebuggerActivation::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
Modified: trunk/Source/_javascript_Core/debugger/DebuggerActivation.h (104898 => 104899)
--- trunk/Source/_javascript_Core/debugger/DebuggerActivation.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/debugger/DebuggerActivation.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -45,7 +45,7 @@
static UString className(const JSObject*);
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier& propertyName, PropertySlot&);
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
- static void putWithAttributes(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
+ static void putDirectVirtual(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&);
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -905,7 +905,7 @@
PutPropertySlot slot;
globalObject->methodTable()->put(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);
} else
- globalObject->methodTable()->putWithAttributes(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, DontEnum | DontDelete);
+ globalObject->methodTable()->putDirectVirtual(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, DontEnum | DontDelete);
// var declarations return undefined
result = jsUndefined();
continue;
Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/ClassInfo.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -88,7 +88,7 @@
HasInstanceFunctionPtr hasInstance;
typedef void (*PutWithAttributesFunctionPtr)(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
- PutWithAttributesFunctionPtr putWithAttributes;
+ PutWithAttributesFunctionPtr putDirectVirtual;
typedef bool (*DefineOwnPropertyFunctionPtr)(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&, bool);
DefineOwnPropertyFunctionPtr defineOwnProperty;
@@ -135,7 +135,7 @@
&ClassName::getPropertyNames, \
&ClassName::className, \
&ClassName::hasInstance, \
- &ClassName::putWithAttributes, \
+ &ClassName::putDirectVirtual, \
&ClassName::defineOwnProperty, \
&ClassName::getOwnPropertyDescriptor, \
}, \
Modified: trunk/Source/_javascript_Core/runtime/Error.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/Error.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/Error.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -123,11 +123,11 @@
const UString& sourceURL = source.provider()->url();
if (line != -1)
- error->putWithAttributes(globalData, Identifier(globalData, linePropertyName), jsNumber(line), ReadOnly | DontDelete);
+ error->putDirect(*globalData, Identifier(globalData, linePropertyName), jsNumber(line), ReadOnly | DontDelete);
if (sourceID != -1)
- error->putWithAttributes(globalData, Identifier(globalData, sourceIdPropertyName), jsNumber((double)sourceID), ReadOnly | DontDelete);
+ error->putDirect(*globalData, Identifier(globalData, sourceIdPropertyName), jsNumber((double)sourceID), ReadOnly | DontDelete);
if (!sourceURL.isNull())
- error->putWithAttributes(globalData, Identifier(globalData, sourceURLPropertyName), jsString(globalData, sourceURL), ReadOnly | DontDelete);
+ error->putDirect(*globalData, Identifier(globalData, sourceURLPropertyName), jsString(globalData, sourceURL), ReadOnly | DontDelete);
return error;
}
Modified: trunk/Source/_javascript_Core/runtime/JSActivation.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSActivation.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSActivation.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -188,7 +188,7 @@
}
// FIXME: Make this function honor ReadOnly (const) and DontEnum
-void JSActivation::putWithAttributes(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
+void JSActivation::putDirectVirtual(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
{
JSActivation* thisObject = jsCast<JSActivation*>(object);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
@@ -200,7 +200,7 @@
// properties are non-standard extensions that other implementations do not
// expose in the activation object.
ASSERT(!thisObject->hasGetterSetterProperties());
- JSObject::putWithAttributes(thisObject, exec, propertyName, value, attributes);
+ JSObject::putDirectVirtual(thisObject, exec, propertyName, value, attributes);
}
bool JSActivation::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
Modified: trunk/Source/_javascript_Core/runtime/JSActivation.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSActivation.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSActivation.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -64,7 +64,7 @@
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
- static void putWithAttributes(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
+ static void putDirectVirtual(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
static JSObject* toThisObject(JSCell*, ExecState*);
Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSCell.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -203,7 +203,7 @@
return false;
}
-void JSCell::putWithAttributes(JSObject*, ExecState*, const Identifier&, JSValue, unsigned)
+void JSCell::putDirectVirtual(JSObject*, ExecState*, const Identifier&, JSValue, unsigned)
{
ASSERT_NOT_REACHED();
}
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -159,7 +159,7 @@
static NO_RETURN_DUE_TO_ASSERT void getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
static UString className(const JSObject*);
static bool hasInstance(JSObject*, ExecState*, JSValue, JSValue prototypeProperty);
- static NO_RETURN_DUE_TO_ASSERT void putWithAttributes(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
+ static NO_RETURN_DUE_TO_ASSERT void putDirectVirtual(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
static bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&);
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -153,7 +153,7 @@
JSVariableObject::put(thisObject, exec, propertyName, value, slot);
}
-void JSGlobalObject::putWithAttributes(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
+void JSGlobalObject::putDirectVirtual(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
{
JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(thisObject));
@@ -167,7 +167,7 @@
if (!valueBefore) {
JSValue valueAfter = thisObject->getDirect(exec->globalData(), propertyName);
if (valueAfter)
- JSObject::putWithAttributes(thisObject, exec, propertyName, valueAfter, attributes);
+ JSObject::putDirectVirtual(thisObject, exec, propertyName, valueAfter, attributes);
}
}
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -202,7 +202,7 @@
bool hasOwnPropertyForWrite(ExecState*, const Identifier&);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
- static void putWithAttributes(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
+ static void putDirectVirtual(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
static void defineGetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* getterFunc, unsigned attributes);
static void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunc, unsigned attributes);
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -162,7 +162,7 @@
for (JSObject* obj = thisObject; !obj->structure()->hasGetterSetterProperties(); obj = asObject(prototype)) {
prototype = obj->prototype();
if (prototype.isNull()) {
- if (!thisObject->putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction(value)) && slot.isStrictMode())
+ if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getJSFunction(value)) && slot.isStrictMode())
throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
return;
}
@@ -205,7 +205,7 @@
break;
}
- if (!thisObject->putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction(value)) && slot.isStrictMode())
+ if (!thisObject->putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getJSFunction(value)) && slot.isStrictMode())
throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
return;
}
@@ -217,18 +217,12 @@
thisObject->methodTable()->put(thisObject, exec, Identifier::from(exec, propertyName), value, slot);
}
-void JSObject::putWithAttributes(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
+void JSObject::putDirectVirtual(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
{
PutPropertySlot slot;
- object->putDirectInternal(exec->globalData(), propertyName, value, attributes, true, slot, getJSFunction(value));
+ object->putDirectInternal<PutModeDefineOwnProperty>(exec->globalData(), propertyName, value, attributes, slot, getJSFunction(value));
}
-void JSObject::putWithAttributes(JSGlobalData* globalData, const Identifier& propertyName, JSValue value, unsigned attributes)
-{
- PutPropertySlot slot;
- putDirectInternal(*globalData, propertyName, value, attributes, true, slot, getJSFunction(value));
-}
-
bool JSObject::hasProperty(ExecState* exec, const Identifier& propertyName) const
{
PropertySlot slot;
@@ -361,7 +355,7 @@
JSGlobalData& globalData = exec->globalData();
PutPropertySlot slot;
GetterSetter* getterSetter = GetterSetter::create(exec);
- thisObject->putDirectInternal(globalData, propertyName, getterSetter, attributes | Accessor, true, slot, 0);
+ thisObject->putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, getterSetter, attributes | Accessor, slot, 0);
// putDirect will change our Structure if we add a new property. For
// getters and setters, though, we also need to change our Structure
@@ -381,7 +375,7 @@
JSGlobalData& globalData = exec->globalData();
PutPropertySlot slot;
- putDirectInternal(globalData, propertyName, getterSetter, attributes, true, slot, 0);
+ putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, getterSetter, attributes, slot, 0);
// putDirect will change our Structure if we add a new property. For
// getters and setters, though, we also need to change our Structure
@@ -408,7 +402,7 @@
PutPropertySlot slot;
GetterSetter* getterSetter = GetterSetter::create(exec);
- thisObject->putDirectInternal(exec->globalData(), propertyName, getterSetter, attributes | Accessor, true, slot, 0);
+ thisObject->putDirectInternal<PutModeDefineOwnProperty>(exec->globalData(), propertyName, getterSetter, attributes | Accessor, slot, 0);
// putDirect will change our Structure if we add a new property. For
// getters and setters, though, we also need to change our Structure
@@ -693,7 +687,7 @@
attributes |= Accessor;
accessor->setSetter(exec->globalData(), oldDescriptor.setterObject());
}
- target->methodTable()->putWithAttributes(target, exec, propertyName, accessor, attributes);
+ target->methodTable()->putDirectVirtual(target, exec, propertyName, accessor, attributes);
return true;
}
JSValue newValue = jsUndefined();
@@ -701,7 +695,7 @@
newValue = descriptor.value();
else if (oldDescriptor.value())
newValue = oldDescriptor.value();
- target->methodTable()->putWithAttributes(target, exec, propertyName, newValue, attributes & ~Accessor);
+ target->methodTable()->putDirectVirtual(target, exec, propertyName, newValue, attributes & ~Accessor);
return true;
}
attributes &= ~ReadOnly;
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -76,6 +76,11 @@
friend class MarkedBlock;
friend bool setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot);
+ enum PutMode {
+ PutModePut,
+ PutModeDefineOwnProperty,
+ };
+
public:
typedef JSCell Base;
@@ -107,12 +112,14 @@
static void put(JSCell*, ExecState*, const Identifier& propertyName, JSValue, PutPropertySlot&);
static void putByIndex(JSCell*, ExecState*, unsigned propertyName, JSValue);
- // putWithAttributes is effectively an unchecked vesion of 'defineOwnProperty':
+ // putDirect is effectively an unchecked vesion of 'defineOwnProperty':
// - the prototype chain is not consulted
// - accessors are not called.
// - attributes will be respected (after the call the property will exist with the given attributes)
- static void putWithAttributes(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
- void putWithAttributes(JSGlobalData*, const Identifier& propertyName, JSValue, unsigned attributes);
+ static void putDirectVirtual(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
+ void putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attributes = 0);
+ void putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, PutPropertySlot&);
+ void putDirectWithoutTransition(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attributes = 0);
bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const;
@@ -181,11 +188,6 @@
// This is used by JSActivation.
bool putOwnDataProperty(JSGlobalData&, const Identifier& propertyName, JSValue, PutPropertySlot&);
- void putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr = 0);
- bool putDirect(JSGlobalData&, const Identifier& propertyName, JSValue, PutPropertySlot&);
-
- void putDirectWithoutTransition(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr = 0);
-
// Fast access to known property offsets.
JSValue getDirectOffset(size_t offset) const { return propertyStorage()[offset].get(); }
void putDirectOffset(JSGlobalData& globalData, size_t offset, JSValue value) { propertyStorage()[offset].set(globalData, this, value); }
@@ -290,7 +292,8 @@
return &propertyStorage()[offset];
}
- bool putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr, bool checkReadOnly, PutPropertySlot&, JSCell*);
+ template<PutMode>
+ bool putDirectInternal(JSGlobalData&, const Identifier& propertyName, JSValue, unsigned attr, PutPropertySlot&, JSCell*);
bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
@@ -637,7 +640,8 @@
return jsUndefined();
}
-inline bool JSObject::putDirectInternal(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot, JSCell* specificFunction)
+template<JSObject::PutMode mode>
+inline bool JSObject::putDirectInternal(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes, PutPropertySlot& slot, JSCell* specificFunction)
{
ASSERT(value);
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
@@ -651,7 +655,7 @@
// or the new value is different, then despecify.
if (currentSpecificFunction && (specificFunction != currentSpecificFunction))
structure()->despecifyDictionaryFunction(globalData, propertyName);
- if (checkReadOnly && currentAttributes & ReadOnly)
+ if ((mode == PutModePut) && currentAttributes & ReadOnly)
return false;
putDirectOffset(globalData, offset, value);
@@ -666,7 +670,7 @@
return true;
}
- if (checkReadOnly && !isExtensible())
+ if ((mode == PutModePut) && !isExtensible())
return false;
size_t currentCapacity = structure()->propertyStorageCapacity();
@@ -702,7 +706,7 @@
JSCell* currentSpecificFunction;
offset = structure()->get(globalData, propertyName, currentAttributes, currentSpecificFunction);
if (offset != WTF::notFound) {
- if (checkReadOnly && currentAttributes & ReadOnly)
+ if ((mode == PutModePut) && currentAttributes & ReadOnly)
return false;
// There are three possibilities here:
@@ -730,7 +734,7 @@
return true;
}
- if (checkReadOnly && !isExtensible())
+ if ((mode == PutModePut) && !isExtensible())
return false;
Structure* structure = Structure::addPropertyTransition(globalData, this->structure(), propertyName, attributes, specificFunction, offset);
@@ -754,18 +758,18 @@
ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
ASSERT(!structure()->hasGetterSetterProperties());
- return putDirectInternal(globalData, propertyName, value, 0, true, slot, getJSFunction(value));
+ return putDirectInternal<PutModePut>(globalData, propertyName, value, 0, slot, getJSFunction(value));
}
inline void JSObject::putDirect(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes)
{
PutPropertySlot slot;
- putDirectInternal(globalData, propertyName, value, attributes, false, slot, getJSFunction(value));
+ putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, value, attributes, slot, getJSFunction(value));
}
-inline bool JSObject::putDirect(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
+inline void JSObject::putDirect(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
- return putDirectInternal(globalData, propertyName, value, 0, false, slot, getJSFunction(value));
+ putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, value, 0, slot, getJSFunction(value));
}
inline void JSObject::putDirectWithoutTransition(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes)
Modified: trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -78,7 +78,7 @@
ASSERT_NOT_REACHED();
}
-void JSStaticScopeObject::putWithAttributes(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
+void JSStaticScopeObject::putDirectVirtual(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
{
JSStaticScopeObject* thisObject = jsCast<JSStaticScopeObject*>(object);
if (thisObject->symbolTablePutWithAttributes(exec->globalData(), propertyName, value, attributes))
Modified: trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSStaticScopeObject.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -47,7 +47,7 @@
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
- static void putWithAttributes(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
+ static void putDirectVirtual(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(globalData, globalObject, proto, TypeInfo(StaticScopeObjectType, StructureFlags), &s_info); }
Modified: trunk/Source/_javascript_Core/runtime/JSVariableObject.cpp (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSVariableObject.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSVariableObject.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -73,7 +73,7 @@
return false;
}
-void JSVariableObject::putWithAttributes(JSObject*, ExecState*, const Identifier&, JSValue, unsigned)
+void JSVariableObject::putDirectVirtual(JSObject*, ExecState*, const Identifier&, JSValue, unsigned)
{
ASSERT_NOT_REACHED();
}
Modified: trunk/Source/_javascript_Core/runtime/JSVariableObject.h (104898 => 104899)
--- trunk/Source/_javascript_Core/runtime/JSVariableObject.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/_javascript_Core/runtime/JSVariableObject.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -50,7 +50,7 @@
static void destroy(JSCell*);
- static NO_RETURN_DUE_TO_ASSERT void putWithAttributes(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
+ static NO_RETURN_DUE_TO_ASSERT void putDirectVirtual(JSObject*, ExecState*, const Identifier&, JSValue, unsigned attributes);
static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
Modified: trunk/Source/WebCore/ChangeLog (104898 => 104899)
--- trunk/Source/WebCore/ChangeLog 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/WebCore/ChangeLog 2012-01-13 06:44:31 UTC (rev 104899)
@@ -1,3 +1,16 @@
+2012-01-12 Gavin Barraclough <barraclo...@apple.com>
+
+ Clean up putDirect (part 2)
+ https://bugs.webkit.org/show_bug.cgi?id=76232
+
+ Reviewed by Sam Weinig.
+
+ Rename putWithAttributes to putDirectVirtual.
+
+ * bindings/js/JSDOMWindowShell.cpp:
+ (WebCore::JSDOMWindowShell::putDirectVirtual):
+ * bindings/js/JSDOMWindowShell.h:
+
2012-01-12 MORITA Hajime <morr...@google.com>
[Chromium] JSExportMacros.h should be visible.
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp (104898 => 104899)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp 2012-01-13 06:44:31 UTC (rev 104899)
@@ -109,10 +109,10 @@
thisObject->window()->methodTable()->put(thisObject->window(), exec, propertyName, value, slot);
}
-void JSDOMWindowShell::putWithAttributes(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
+void JSDOMWindowShell::putDirectVirtual(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
{
JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
- thisObject->window()->putWithAttributes(thisObject->window(), exec, propertyName, value, attributes);
+ thisObject->window()->putDirectVirtual(thisObject->window(), exec, propertyName, value, attributes);
}
bool JSDOMWindowShell::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h (104898 => 104899)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h 2012-01-13 06:19:53 UTC (rev 104898)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h 2012-01-13 06:44:31 UTC (rev 104899)
@@ -82,7 +82,7 @@
static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&);
static void put(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&);
- static void putWithAttributes(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, unsigned attributes);
+ static void putDirectVirtual(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, unsigned attributes);
static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, const JSC::Identifier& propertyName);
static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);