https://bugs.webkit.org/show_bug.cgi?id=70958
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.
* API/JSContextRef.cpp:
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* runtime/ClassInfo.h:
* runtime/JSActivation.cpp:
(JSC::JSActivation::toThisObject):
* runtime/JSActivation.h:
* runtime/JSCell.cpp:
(JSC::JSCell::toThisObject):
* runtime/JSCell.h:
* runtime/JSObject.cpp:
(JSC::JSObject::put):
(JSC::JSObject::toThisObject):
* runtime/JSObject.h:
(JSC::JSValue::toThisObject):
* runtime/JSStaticScopeObject.cpp:
(JSC::JSStaticScopeObject::toThisObject):
* runtime/JSStaticScopeObject.h:
* runtime/JSString.cpp:
(JSC::JSString::toThisObject):
* runtime/JSString.h:
* runtime/StrictEvalActivation.cpp:
(JSC::StrictEvalActivation::toThisObject):
* runtime/StrictEvalActivation.h:
Source/WebCore:
No new tests.
Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::toThisObject):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bridge/NP_jsobject.cpp:
(_NPN_Invoke):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::QtRuntimeConnectionMethod::call):
Source/WebKit/mac:
Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::invoke):
(WebKit::NetscapePluginInstanceProxy::invokeDefault):
Source/WebKit2:
Converted all instances of toThisObject to static functions,
added toThisObject to the MethodTable, and replaced all call sites
with a corresponding lookup in the MethodTable.
* WebProcess/Plugins/Netscape/NPJSObject.cpp:
(WebKit::NPJSObject::invoke):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@98593
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
APIEntryShim entryShim(exec);
// It is necessary to call toThisObject to get the wrapper object when used with WebCore.
- return toRef(exec->lexicalGlobalObject()->toThisObject(exec));
+ return toRef(exec->lexicalGlobalObject()->methodTable()->toThisObject(exec->lexicalGlobalObject(), exec));
}
JSContextGroupRef JSContextGetGroup(JSContextRef ctx)
+2011-10-27 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ De-virtualize JSCell::toThisObject
+ https://bugs.webkit.org/show_bug.cgi?id=70958
+
+ Reviewed by Geoffrey Garen.
+
+ Converted all instances of toThisObject to static functions,
+ added toThisObject to the MethodTable, and replaced all call sites
+ with a corresponding lookup in the MethodTable.
+
+ * API/JSContextRef.cpp:
+ * JavaScriptCore.exp:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+ * runtime/ClassInfo.h:
+ * runtime/JSActivation.cpp:
+ (JSC::JSActivation::toThisObject):
+ * runtime/JSActivation.h:
+ * runtime/JSCell.cpp:
+ (JSC::JSCell::toThisObject):
+ * runtime/JSCell.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::put):
+ (JSC::JSObject::toThisObject):
+ * runtime/JSObject.h:
+ (JSC::JSValue::toThisObject):
+ * runtime/JSStaticScopeObject.cpp:
+ (JSC::JSStaticScopeObject::toThisObject):
+ * runtime/JSStaticScopeObject.h:
+ * runtime/JSString.cpp:
+ (JSC::JSString::toThisObject):
+ * runtime/JSString.h:
+ * runtime/StrictEvalActivation.cpp:
+ (JSC::StrictEvalActivation::toThisObject):
+ * runtime/StrictEvalActivation.h:
+
2011-10-27 Yuqiang Xian <yuqiang.xian@intel.com>
Fix a small bug in callOperation after r98431
__ZN3JSC8JSObject12defineSetterEPNS_9ExecStateERKNS_10IdentifierEPS0_j
__ZN3JSC8JSObject12lookupGetterEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC8JSObject12lookupSetterEPNS_9ExecStateERKNS_10IdentifierE
+__ZN3JSC8JSObject12toThisObjectEPNS_6JSCellEPNS_9ExecStateE
__ZN3JSC8JSObject13visitChildrenEPNS_6JSCellERNS_11SlotVisitorE
__ZN3JSC8JSObject14deletePropertyEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC8JSObject15unwrappedObjectEv
__ZNK3JSC18PropertyDescriptor8writableEv
__ZNK3JSC19SourceProviderCache8byteSizeEv
__ZNK3JSC6JSCell11toPrimitiveEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
-__ZNK3JSC6JSCell12toThisObjectEPNS_9ExecStateE
__ZNK3JSC6JSCell8toNumberEPNS_9ExecStateE
__ZNK3JSC6JSCell8toObjectEPNS_9ExecStateEPNS_14JSGlobalObjectE
__ZNK3JSC6JSCell8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZNK3JSC8JSObject11hasPropertyEPNS_9ExecStateEj
__ZNK3JSC8JSObject12defaultValueEPNS_9ExecStateENS_22PreferredPrimitiveTypeE
-__ZNK3JSC8JSObject12toThisObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
__ZNK3JSC8JSObject9classNameEv
?toString@JSObject@JSC@@QBE?AVUString@2@PAVExecState@2@@Z
?toStringDecimal@DecimalNumber@WTF@@QBEIPA_WI@Z
?toStringExponential@DecimalNumber@WTF@@QBEIPA_WI@Z
- ?toThisObject@JSCell@JSC@@UBEPAVJSObject@2@PAVExecState@2@@Z
- ?toThisObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@@Z
- ?toThisObject@JSString@JSC@@EBEPAVJSObject@2@PAVExecState@2@@Z
?toThisObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@@Z
?toUInt32@Identifier@JSC@@SAIABVUString@2@AA_N@Z
?tryFastCalloc@WTF@@YA?AUTryMallocReturnValue@1@II@Z
typedef bool (*GetOwnPropertySlotByIndexFunctionPtr)(JSCell*, ExecState*, unsigned, PropertySlot&);
GetOwnPropertySlotByIndexFunctionPtr getOwnPropertySlotByIndex;
+
+ typedef JSObject* (*ToThisObjectFunctionPtr)(JSCell*, ExecState*);
+ ToThisObjectFunctionPtr toThisObject;
};
#define CREATE_METHOD_TABLE(ClassName) { \
&ClassName::deletePropertyByIndex, \
&ClassName::getOwnPropertySlot, \
&ClassName::getOwnPropertySlotByIndex, \
+ &ClassName::toThisObject, \
}, \
sizeof(ClassName)
return Base::deleteProperty(cell, exec, propertyName);
}
-JSObject* JSActivation::toThisObject(ExecState* exec) const
+JSObject* JSActivation::toThisObject(JSCell*, ExecState* exec)
{
return exec->globalThisValue();
}
virtual void putWithAttributes(ExecState*, const Identifier&, JSValue, unsigned attributes);
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
- virtual JSObject* toThisObject(ExecState*) const;
+ static JSObject* toThisObject(JSCell*, ExecState*);
void copyRegisters(JSGlobalData&);
return thisObject->methodTable()->deletePropertyByIndex(thisObject, exec, identifier);
}
-JSObject* JSCell::toThisObject(ExecState* exec) const
+JSObject* JSCell::toThisObject(JSCell* cell, ExecState* exec)
{
- return toObject(exec, exec->lexicalGlobalObject());
+ return cell->toObject(exec, exec->lexicalGlobalObject());
}
JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const
static bool deleteProperty(JSCell*, ExecState*, const Identifier& propertyName);
static bool deletePropertyByIndex(JSCell*, ExecState*, unsigned propertyName);
- virtual JSObject* toThisObject(ExecState*) const;
+ static JSObject* toThisObject(JSCell*, ExecState*);
void* vptr() const { ASSERT(!isZapped()); return *reinterpret_cast<void* const*>(this); }
void setVPtr(void* vptr) { *reinterpret_cast<void**>(this) = vptr; ASSERT(!isZapped()); }
return isCell() ? asCell()->toObject(exec, globalObject) : toObjectSlowCase(exec, globalObject);
}
- inline JSObject* JSValue::toThisObject(ExecState* exec) const
- {
- return isCell() ? asCell()->toThisObject(exec) : toThisObjectSlowCase(exec);
- }
-
template <typename T> void* allocateCell(Heap& heap)
{
#if ENABLE(GC_VALIDATION)
args.append(value);
// If this is WebCore's global object then we need to substitute the shell.
- call(exec, setterFunc, callType, callData, thisObject->toThisObject(exec), args);
+ call(exec, setterFunc, callType, callData, thisObject->methodTable()->toThisObject(thisObject, exec), args);
return;
}
return primitive.toString(exec);
}
-JSObject* JSObject::toThisObject(ExecState*) const
+JSObject* JSObject::toThisObject(JSCell* cell, ExecState*)
{
- return const_cast<JSObject*>(this);
+ return static_cast<JSObject*>(cell);
}
JSObject* JSObject::unwrappedObject()
double toNumber(ExecState*) const;
UString toString(ExecState*) const;
- virtual JSObject* toThisObject(ExecState*) const;
+ static JSObject* toThisObject(JSCell*, ExecState*);
virtual JSObject* unwrappedObject();
bool getPropertySpecificValue(ExecState* exec, const Identifier& propertyName, JSCell*& specificFunction) const;
return isCell() && asCell()->inherits(classInfo);
}
+inline JSObject* JSValue::toThisObject(ExecState* exec) const
+{
+ return isCell() ? asCell()->methodTable()->toThisObject(asCell(), exec) : toThisObjectSlowCase(exec);
+}
+
ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (WriteBarrierBase<Unknown>* location = getDirectLocation(exec->globalData(), propertyName)) {
visitor.append(&thisObject->m_registerStore);
}
-JSObject* JSStaticScopeObject::toThisObject(ExecState* exec) const
+JSObject* JSStaticScopeObject::toThisObject(JSCell*, ExecState* exec)
{
return exec->globalThisValue();
}
static void visitChildren(JSCell*, SlotVisitor&);
bool isDynamicScope(bool& requiresDynamicChecks) const;
- virtual JSObject* toThisObject(ExecState*) const;
+ static JSObject* toThisObject(JSCell*, ExecState*);
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier&, PropertySlot&);
static void put(JSCell*, ExecState*, const Identifier&, JSValue, PutPropertySlot&);
return StringObject::create(exec, globalObject, const_cast<JSString*>(this));
}
-JSObject* JSString::toThisObject(ExecState* exec) const
+JSObject* JSString::toThisObject(JSCell* cell, ExecState* exec)
{
- return StringObject::create(exec, exec->lexicalGlobalObject(), const_cast<JSString*>(this));
+ return StringObject::create(exec, exec->lexicalGlobalObject(), static_cast<JSString*>(cell));
}
bool JSString::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
void resolveRopeSlowCase(ExecState*, UChar*) const;
void outOfMemory(ExecState*) const;
- virtual JSObject* toThisObject(ExecState*) const;
+ static JSObject* toThisObject(JSCell*, ExecState*);
// Actually getPropertySlot, not getOwnPropertySlot (see JSCell).
static bool getOwnPropertySlot(JSCell*, ExecState*, const Identifier& propertyName, PropertySlot&);
return false;
}
-JSObject* StrictEvalActivation::toThisObject(ExecState* exec) const
+JSObject* StrictEvalActivation::toThisObject(JSCell*, ExecState* exec)
{
return exec->globalThisValue();
}
}
static bool deleteProperty(JSCell*, ExecState*, const Identifier&);
- virtual JSObject* toThisObject(ExecState*) const;
+ static JSObject* toThisObject(JSCell*, ExecState*);
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
+2011-10-27 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ De-virtualize JSCell::toThisObject
+ https://bugs.webkit.org/show_bug.cgi?id=70958
+
+ Reviewed by Geoffrey Garen.
+
+ No new tests.
+
+ Converted all instances of toThisObject to static functions,
+ added toThisObject to the MethodTable, and replaced all call sites
+ with a corresponding lookup in the MethodTable.
+
+ * bindings/js/JSDOMWindowBase.cpp:
+ (WebCore::JSDOMWindowBase::toThisObject):
+ * bindings/js/JSDOMWindowBase.h:
+ * bindings/js/JSErrorHandler.cpp:
+ (WebCore::JSErrorHandler::handleEvent):
+ * bridge/NP_jsobject.cpp:
+ (_NPN_Invoke):
+ * bridge/qt/qt_runtime.cpp:
+ (JSC::Bindings::QtRuntimeConnectionMethod::call):
+
2011-10-27 Adam Roben <aroben@apple.com>
Windows build fix after r98512
setCurrentEvent(0);
}
-JSObject* JSDOMWindowBase::toThisObject(ExecState*) const
+JSObject* JSDOMWindowBase::toThisObject(JSCell* cell, ExecState*)
{
- return shell();
+ return static_cast<JSDOMWindowBase*>(cell)->shell();
}
JSDOMWindowShell* JSDOMWindowBase::shell() const
// Don't call this version of allowsAccessFrom -- it's a slightly incorrect implementation used only by WebScriptObject
virtual bool allowsAccessFrom(const JSC::JSGlobalObject*) const;
- virtual JSC::JSObject* toThisObject(JSC::ExecState*) const;
+ static JSC::JSObject* toThisObject(JSC::JSCell*, JSC::ExecState*);
JSDOMWindowShell* shell() const;
static JSC::JSGlobalData* commonJSGlobalData();
JSGlobalData& globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(globalData, globalData.dynamicGlobalObject ? globalData.dynamicGlobalObject : globalObject);
- JSValue thisValue = globalObject->toThisObject(exec);
+ JSValue thisValue = globalObject->methodTable()->toThisObject(globalObject, exec);
globalData.timeoutChecker.start();
JSValue returnValue = JSC::call(exec, jsFunction, callType, callData, thisValue, args);
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
RefPtr<JSGlobalData> globalData(&exec->globalData());
globalData->timeoutChecker.start();
- JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp->toThisObject(exec), argList);
+ JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp->methodTable()->toThisObject(obj->imp, exec), argList);
globalData->timeoutChecker.stop();
// Convert and return the result of the function call.
if (sender) {
- JSObject* thisObject = exec->lexicalGlobalObject()->toThisObject(exec);
+ JSObject* thisObject = exec->lexicalGlobalObject()->methodTable()->toThisObject(exec->lexicalGlobalObject(), exec);
JSObject* funcObject = 0;
// QtScript checks signalness first, arguments second
+2011-10-27 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ De-virtualize JSCell::toThisObject
+ https://bugs.webkit.org/show_bug.cgi?id=70958
+
+ Reviewed by Geoffrey Garen.
+
+ Converted all instances of toThisObject to static functions,
+ added toThisObject to the MethodTable, and replaced all call sites
+ with a corresponding lookup in the MethodTable.
+
+ * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+ (WebKit::NetscapePluginInstanceProxy::invoke):
+ (WebKit::NetscapePluginInstanceProxy::invokeDefault):
+
2011-10-25 Mark Hahnenberg <mhahnenberg@apple.com>
Remove deletePropertyVirtual
RefPtr<JSGlobalData> globalData = pluginWorld()->globalData();
globalData->timeoutChecker.start();
- JSValue value = call(exec, function, callType, callData, object->toThisObject(exec), argList);
+ JSValue value = call(exec, function, callType, callData, object->methodTable()->toThisObject(object, exec), argList);
globalData->timeoutChecker.stop();
marshalValue(exec, value, resultData, resultLength);
RefPtr<JSGlobalData> globalData = pluginWorld()->globalData();
globalData->timeoutChecker.start();
- JSValue value = call(exec, object, callType, callData, object->toThisObject(exec), argList);
+ JSValue value = call(exec, object, callType, callData, object->methodTable()->toThisObject(object, exec), argList);
globalData->timeoutChecker.stop();
marshalValue(exec, value, resultData, resultLength);
+2011-10-27 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ De-virtualize JSCell::toThisObject
+ https://bugs.webkit.org/show_bug.cgi?id=70958
+
+ Reviewed by Geoffrey Garen.
+
+ Converted all instances of toThisObject to static functions,
+ added toThisObject to the MethodTable, and replaced all call sites
+ with a corresponding lookup in the MethodTable.
+
+ * WebProcess/Plugins/Netscape/NPJSObject.cpp:
+ (WebKit::NPJSObject::invoke):
+
2011-10-27 Adam Roben <aroben@apple.com>
Add WKBundlePageGetBackingScaleFactor
argumentList.append(m_objectMap->convertNPVariantToJSValue(exec, globalObject, arguments[i]));
exec->globalData().timeoutChecker.start();
- JSValue value = JSC::call(exec, function, callType, callData, m_jsObject->toThisObject(exec), argumentList);
+ JSValue value = JSC::call(exec, function, callType, callData, m_jsObject->methodTable()->toThisObject(m_jsObject.get(), exec), argumentList);
exec->globalData().timeoutChecker.stop();
// Convert and return the result of the function call.