Commit 597be029 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

Remove getCallDataVirtual methods

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore: 

Removed all getCallDataVirtual methods and replaced their call sites 
with an explicit lookup in the MethodTable.

* API/JSCallbackFunction.cpp:
* API/JSCallbackFunction.h:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
* API/JSObjectRef.cpp:
(JSObjectIsFunction):
(JSObjectCallAsFunction):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/ArrayConstructor.cpp:
* runtime/ArrayConstructor.h:
* runtime/BooleanConstructor.cpp:
* runtime/BooleanConstructor.h:
* runtime/DateConstructor.cpp:
* runtime/DateConstructor.h:
* runtime/Error.cpp:
(JSC::createTypeErrorFunction):

Moved StrictModeTypeErrorFunction to Error.h in order to be able to include 
the class definition in JSGlobalObject.cpp.
* runtime/Error.h:
(JSC::StrictModeTypeErrorFunction::StrictModeTypeErrorFunction):
(JSC::StrictModeTypeErrorFunction::create):
(JSC::StrictModeTypeErrorFunction::constructThrowTypeError):
(JSC::StrictModeTypeErrorFunction::getConstructData):
(JSC::StrictModeTypeErrorFunction::callThrowTypeError):
(JSC::StrictModeTypeErrorFunction::getCallData):
(JSC::StrictModeTypeErrorFunction::createStructure):
* runtime/ErrorConstructor.cpp:
* runtime/ErrorConstructor.h:
* runtime/FunctionConstructor.cpp:
* runtime/FunctionConstructor.h:
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:

To allow subclasses of InternalFunction (e.g. QtRuntimeMethod) to not have 
to declare their own ClassInfo if they don't override getCallData, provided 
an implementation that calls ASSERT_NOT_REACHED if called, providing roughly the same 
functionality as of the pure virtual method InternalFunction used to have.
Also made this new implementation protected rather than private for the same reason.
Also added an ASSERT in InternalFunction::finishCreation to make sure that whatever 
object is being created provides their own implementation of getCallData.  This 
just makes execution fail earlier in a place where the source of the error is 
easy to trace.  These ASSERTs are better than putting a null in the MethodTable because
they appear much more intentional to anybody who fails to provide their own 
implementation or who tries to explicitly call InternalFunction::getCallData.
* runtime/InternalFunction.cpp:
(JSC::InternalFunction::finishCreation):
(JSC::InternalFunction::getCallData):
* runtime/InternalFunction.h:
* runtime/JSCell.cpp:
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:

Added a global structure to JSGlobalObject for StrictModeTypeErrorFunction to enable 
it to be reused rather than creating a new Structure every time we instantiate it.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::strictModeTypeErrorFunctionStructure):
* runtime/JSONObject.cpp:
(JSC::Stringifier::Stringifier):
(JSC::Stringifier::toJSON):
(JSC::Stringifier::appendStringifiedValue):
* runtime/JSObject.cpp:
(JSC::JSObject::put):
* runtime/JSObject.h:
(JSC::getCallData):
* runtime/NativeErrorConstructor.cpp:
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
* runtime/NumberConstructor.h:
* runtime/ObjectConstructor.cpp:
* runtime/ObjectConstructor.h:
* runtime/Operations.cpp:
(JSC::jsTypeStringForValue):
(JSC::jsIsObjectType):
(JSC::jsIsFunctionType):
* runtime/PropertySlot.cpp:
(JSC::PropertySlot::functionGetter):
* runtime/RegExpConstructor.cpp:
* runtime/RegExpConstructor.h:
* runtime/StringConstructor.cpp:
* runtime/StringConstructor.h:
* runtime/Structure.h:

Source/JavaScriptGlue: 

Removed all getCallDataVirtual methods and replaced their call sites 
with an explicit lookup in the MethodTable.

* JSValueWrapper.cpp:
(JSValueWrapper::JSObjectCallFunction):
* UserObjectImp.cpp:
* UserObjectImp.h:

Source/WebCore: 

No new tests.

Removed all getCallDataVirtual methods and replaced their call sites 
with an explicit lookup in the MethodTable.

* WebCore.exp.in:
* bindings/js/JSCallbackData.cpp:
(WebCore::JSCallbackData::invokeCallback):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/js/JSErrorHandler.cpp:
(WebCore::JSErrorHandler::handleEvent):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
* bindings/js/JSHTMLAppletElementCustom.cpp:
* bindings/js/JSHTMLEmbedElementCustom.cpp:
* bindings/js/JSHTMLObjectElementCustom.cpp:
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::JSInjectedScriptHost::evaluate):
* bindings/js/JSPluginElementFunctions.cpp:
(WebCore::runtimeObjectGetCallData):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
* bridge/objc/objc_runtime.h:
* bridge/objc/objc_runtime.mm:
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::QtRuntimeConnectionMethod::call):
(JSC::Bindings::isJavaScriptFunction):
* bridge/qt/qt_runtime.h:
(JSC::Bindings::QtRuntimeMetaMethod::createStructure):
(JSC::Bindings::QtRuntimeConnectionMethod::createStructure):
* bridge/runtime_method.cpp:
* bridge/runtime_method.h:
* bridge/runtime_object.cpp:
* bridge/runtime_object.h:

Source/WebKit/mac: 

Removed all getCallDataVirtual methods and replaced their call sites 
with an explicit lookup in the MethodTable.

* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::invokeDefault):

Source/WebKit2: 

Removed all getCallDataVirtual methods and replaced their call sites 
with an explicit lookup in the MethodTable.

* WebProcess/Plugins/Netscape/JSNPMethod.cpp:
* WebProcess/Plugins/Netscape/JSNPMethod.h:
* WebProcess/Plugins/Netscape/JSNPObject.cpp:
* WebProcess/Plugins/Netscape/JSNPObject.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96996 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 381db9f5
......@@ -78,11 +78,6 @@ EncodedJSValue JSCallbackFunction::call(ExecState* exec)
return JSValue::encode(toJS(exec, result));
}
CallType JSCallbackFunction::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType JSCallbackFunction::getCallData(JSCell*, CallData& callData)
{
callData.native.function = call;
......
......@@ -59,7 +59,6 @@ public:
static JSValueRef valueOfCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
private:
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
static EncodedJSValue JSC_HOST_CALL call(ExecState*);
......
......@@ -195,7 +195,6 @@ private:
virtual UString toString(ExecState*) const;
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
static void visitChildren(JSCell* cell, SlotVisitor& visitor)
......
......@@ -378,12 +378,6 @@ bool JSCallbackObject<Parent>::hasInstance(ExecState* exec, JSValue value, JSVal
return false;
}
template <class Parent>
CallType JSCallbackObject<Parent>::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
template <class Parent>
CallType JSCallbackObject<Parent>::getCallData(JSCell* cell, CallData& callData)
{
......
......@@ -416,7 +416,8 @@ bool JSObjectDeletePrivateProperty(JSContextRef ctx, JSObjectRef object, JSStrin
bool JSObjectIsFunction(JSContextRef, JSObjectRef object)
{
CallData callData;
return toJS(object)->getCallDataVirtual(callData) != CallTypeNone;
JSCell* cell = toJS(object);
return cell->methodTable()->getCallData(cell, callData) != CallTypeNone;
}
JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
......@@ -435,7 +436,7 @@ JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObject
argList.append(toJS(exec, arguments[i]));
CallData callData;
CallType callType = jsObject->getCallDataVirtual(callData);
CallType callType = jsObject->methodTable()->getCallData(jsObject, callData);
if (callType == CallTypeNone)
return 0;
......
2011-10-07 Mark Hahnenberg <mhahnenberg@apple.com>
Remove getCallDataVirtual methods
https://bugs.webkit.org/show_bug.cgi?id=69186
Reviewed by Geoffrey Garen.
Removed all getCallDataVirtual methods and replaced their call sites
with an explicit lookup in the MethodTable.
* API/JSCallbackFunction.cpp:
* API/JSCallbackFunction.h:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
* API/JSObjectRef.cpp:
(JSObjectIsFunction):
(JSObjectCallAsFunction):
* JavaScriptCore.exp:
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/ArrayConstructor.cpp:
* runtime/ArrayConstructor.h:
* runtime/BooleanConstructor.cpp:
* runtime/BooleanConstructor.h:
* runtime/DateConstructor.cpp:
* runtime/DateConstructor.h:
* runtime/Error.cpp:
(JSC::createTypeErrorFunction):
Moved StrictModeTypeErrorFunction to Error.h in order to be able to include
the class definition in JSGlobalObject.cpp.
* runtime/Error.h:
(JSC::StrictModeTypeErrorFunction::StrictModeTypeErrorFunction):
(JSC::StrictModeTypeErrorFunction::create):
(JSC::StrictModeTypeErrorFunction::constructThrowTypeError):
(JSC::StrictModeTypeErrorFunction::getConstructData):
(JSC::StrictModeTypeErrorFunction::callThrowTypeError):
(JSC::StrictModeTypeErrorFunction::getCallData):
(JSC::StrictModeTypeErrorFunction::createStructure):
* runtime/ErrorConstructor.cpp:
* runtime/ErrorConstructor.h:
* runtime/FunctionConstructor.cpp:
* runtime/FunctionConstructor.h:
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:
To allow subclasses of InternalFunction (e.g. QtRuntimeMethod) to not have
to declare their own ClassInfo if they don't override getCallData, provided
an implementation that calls ASSERT_NOT_REACHED if called, providing roughly the same
functionality as of the pure virtual method InternalFunction used to have.
Also made this new implementation protected rather than private for the same reason.
Also added an ASSERT in InternalFunction::finishCreation to make sure that whatever
object is being created provides their own implementation of getCallData. This
just makes execution fail earlier in a place where the source of the error is
easy to trace. These ASSERTs are better than putting a null in the MethodTable because
they appear much more intentional to anybody who fails to provide their own
implementation or who tries to explicitly call InternalFunction::getCallData.
* runtime/InternalFunction.cpp:
(JSC::InternalFunction::finishCreation):
(JSC::InternalFunction::getCallData):
* runtime/InternalFunction.h:
* runtime/JSCell.cpp:
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
Added a global structure to JSGlobalObject for StrictModeTypeErrorFunction to enable
it to be reused rather than creating a new Structure every time we instantiate it.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::strictModeTypeErrorFunctionStructure):
* runtime/JSONObject.cpp:
(JSC::Stringifier::Stringifier):
(JSC::Stringifier::toJSON):
(JSC::Stringifier::appendStringifiedValue):
* runtime/JSObject.cpp:
(JSC::JSObject::put):
* runtime/JSObject.h:
(JSC::getCallData):
* runtime/NativeErrorConstructor.cpp:
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
* runtime/NumberConstructor.h:
* runtime/ObjectConstructor.cpp:
* runtime/ObjectConstructor.h:
* runtime/Operations.cpp:
(JSC::jsTypeStringForValue):
(JSC::jsIsObjectType):
(JSC::jsIsFunctionType):
* runtime/PropertySlot.cpp:
(JSC::PropertySlot::functionGetter):
* runtime/RegExpConstructor.cpp:
* runtime/RegExpConstructor.h:
* runtime/StringConstructor.cpp:
* runtime/StringConstructor.h:
* runtime/Structure.h:
2011-10-07 Oliver Hunt <oliver@apple.com>
Add missing break statement.
......@@ -260,7 +260,6 @@ __ZN3JSC6JSCell11getCallDataEPS0_RNS_8CallDataE
__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC6JSCell14deletePropertyEPNS_9ExecStateEj
__ZN3JSC6JSCell16getConstructDataERNS_13ConstructDataE
__ZN3JSC6JSCell18getCallDataVirtualERNS_8CallDataE
__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateERKNS_10IdentifierERNS_12PropertySlotE
__ZN3JSC6JSCell18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3JSC6JSCell3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE
......
......@@ -190,7 +190,6 @@ EXPORTS
?get@Structure@JSC@@QAEIAAVJSGlobalData@2@ABVIdentifier@2@AAIAAPAVJSCell@2@@Z
?get@Structure@JSC@@QAEIAAVJSGlobalData@2@PAVStringImpl@WTF@@AAIAAPAVJSCell@2@@Z
?getCallData@JSCell@JSC@@SA?AW4CallType@2@PAV12@AATCallData@2@@Z
?getCallDataVirtual@JSCell@JSC@@UAE?AW4CallType@2@AATCallData@2@@Z
?getConstructData@JSCell@JSC@@UAE?AW4ConstructType@2@AATConstructData@2@@Z
?getObject@JSCell@JSC@@QAEPAVJSObject@2@XZ
?getOwnPropertyDescriptor@JSGlobalObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
......
......@@ -2829,7 +2829,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
if (GetterSetter* getterSetter = asGetterSetter(protoObject->getDirectOffset(offset).asCell())) {
JSObject* getter = getterSetter->getter();
CallData callData;
CallType callType = getter->getCallDataVirtual(callData);
CallType callType = getter->methodTable()->getCallData(getter, callData);
JSValue result = call(callFrame, getter, callType, callData, asObject(baseCell), ArgList());
CHECK_FOR_EXCEPTION();
callFrame->uncheckedR(dst) = result;
......@@ -2964,7 +2964,7 @@ JSValue Interpreter::privateExecute(ExecutionFlag flag, RegisterFile* registerFi
if (GetterSetter* getterSetter = asGetterSetter(baseObject->getDirectOffset(offset).asCell())) {
JSObject* getter = getterSetter->getter();
CallData callData;
CallType callType = getter->getCallDataVirtual(callData);
CallType callType = getter->methodTable()->getCallData(getter, callData);
JSValue result = call(callFrame, getter, callType, callData, baseObject, ArgList());
CHECK_FOR_EXCEPTION();
callFrame->uncheckedR(dst) = result;
......@@ -3072,7 +3072,7 @@ skip_id_custom_self:
if (GetterSetter* getterSetter = asGetterSetter(baseObject->getDirectOffset(offset).asCell())) {
JSObject* getter = getterSetter->getter();
CallData callData;
CallType callType = getter->getCallDataVirtual(callData);
CallType callType = getter->methodTable()->getCallData(getter, callData);
JSValue result = call(callFrame, getter, callType, callData, baseValue, ArgList());
CHECK_FOR_EXCEPTION();
callFrame->uncheckedR(dst) = result;
......
......@@ -1752,7 +1752,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_getter_stub)
return JSValue::encode(jsUndefined());
JSObject* getter = asObject(getterSetter->getter());
CallData callData;
CallType callType = getter->getCallDataVirtual(callData);
CallType callType = getter->methodTable()->getCallData(getter, callData);
JSValue result = call(callFrame, getter, callType, callData, stackFrame.args[1].jsObject(), ArgList());
if (callFrame->hadException())
returnToThrowTrampoline(&callFrame->globalData(), stackFrame.args[2].returnAddress(), STUB_RETURN_ADDRESS);
......@@ -2153,7 +2153,7 @@ DEFINE_STUB_FUNCTION(void*, op_call_jitCompile)
#if !ASSERT_DISABLED
CallData callData;
ASSERT(stackFrame.callFrame->callee()->getCallDataVirtual(callData) == CallTypeJS);
ASSERT(stackFrame.callFrame->callee()->methodTable()->getCallData(stackFrame.callFrame->callee(), callData) == CallTypeJS);
#endif
return jitCompileFor(stackFrame, CodeForCall);
......
......@@ -109,11 +109,6 @@ static EncodedJSValue JSC_HOST_CALL callArrayConstructor(ExecState* exec)
return JSValue::encode(constructArrayWithSizeQuirk(exec, args));
}
CallType ArrayConstructor::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType ArrayConstructor::getCallData(JSCell*, CallData& callData)
{
// equivalent to 'new Array(....)'
......
......@@ -55,7 +55,6 @@ namespace JSC {
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -70,11 +70,6 @@ static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec)
return JSValue::encode(jsBoolean(exec->argument(0).toBoolean(exec)));
}
CallType BooleanConstructor::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType BooleanConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callBooleanConstructor;
......
......@@ -51,7 +51,6 @@ namespace JSC {
private:
BooleanConstructor(JSGlobalObject*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -176,11 +176,6 @@ static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec)
return JSValue::encode(jsMakeNontrivialString(exec, date, " ", time));
}
CallType DateConstructor::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType DateConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callDate;
......
......@@ -52,7 +52,6 @@ namespace JSC {
private:
DateConstructor(JSGlobalObject*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
......
......@@ -26,6 +26,7 @@
#include "ConstructData.h"
#include "ErrorConstructor.h"
#include "FunctionPrototype.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
#include "JSObject.h"
......@@ -165,71 +166,14 @@ JSObject* throwSyntaxError(ExecState* exec)
return throwError(exec, createSyntaxError(exec, "Syntax error"));
}
class StrictModeTypeErrorFunction : public InternalFunction {
private:
StrictModeTypeErrorFunction(JSGlobalObject* globalObject, Structure* structure, const UString& message)
: InternalFunction(globalObject, structure)
, m_message(message)
{
}
public:
typedef InternalFunction Base;
static StrictModeTypeErrorFunction* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const UString& message)
{
StrictModeTypeErrorFunction* function = new (allocateCell<StrictModeTypeErrorFunction>(*exec->heap())) StrictModeTypeErrorFunction(globalObject, structure, message);
function->finishCreation(exec->globalData(), exec->globalData().propertyNames->emptyIdentifier);
return function;
}
static EncodedJSValue JSC_HOST_CALL constructThrowTypeError(ExecState* exec)
{
throwTypeError(exec, static_cast<StrictModeTypeErrorFunction*>(exec->callee())->m_message);
return JSValue::encode(jsNull());
}
ConstructType getConstructData(ConstructData& constructData)
{
constructData.native.function = constructThrowTypeError;
return ConstructTypeHost;
}
static EncodedJSValue JSC_HOST_CALL callThrowTypeError(ExecState* exec)
{
throwTypeError(exec, static_cast<StrictModeTypeErrorFunction*>(exec->callee())->m_message);
return JSValue::encode(jsNull());
}
virtual CallType getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
static CallType getCallData(JSCell*, CallData& callData)
{
callData.native.function = callThrowTypeError;
return CallTypeHost;
}
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
}
private:
UString m_message;
};
ASSERT_CLASS_FITS_IN_CELL(StrictModeTypeErrorFunction);
const ClassInfo StrictModeTypeErrorFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(StrictModeTypeErrorFunction) };
JSValue createTypeErrorFunction(ExecState* exec, const UString& message)
{
return StrictModeTypeErrorFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->internalFunctionStructure(), message);
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
return StrictModeTypeErrorFunction::create(exec, globalObject, globalObject->strictModeTypeErrorFunctionStructure(), message);
}
} // namespace JSC
......@@ -23,6 +23,7 @@
#ifndef Error_h
#define Error_h
#include "InternalFunction.h"
#include "JSObject.h"
#include <stdint.h>
......@@ -73,6 +74,59 @@ namespace JSC {
JSValue createTypeErrorFunction(ExecState* exec, const UString& message);
class StrictModeTypeErrorFunction : public InternalFunction {
private:
StrictModeTypeErrorFunction(JSGlobalObject* globalObject, Structure* structure, const UString& message)
: InternalFunction(globalObject, structure)
, m_message(message)
{
}
public:
typedef InternalFunction Base;
static StrictModeTypeErrorFunction* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const UString& message)
{
StrictModeTypeErrorFunction* function = new (allocateCell<StrictModeTypeErrorFunction>(*exec->heap())) StrictModeTypeErrorFunction(globalObject, structure, message);
function->finishCreation(exec->globalData(), exec->globalData().propertyNames->emptyIdentifier);
return function;
}
static EncodedJSValue JSC_HOST_CALL constructThrowTypeError(ExecState* exec)
{
throwTypeError(exec, static_cast<StrictModeTypeErrorFunction*>(exec->callee())->m_message);
return JSValue::encode(jsNull());
}
ConstructType getConstructData(ConstructData& constructData)
{
constructData.native.function = constructThrowTypeError;
return ConstructTypeHost;
}
static EncodedJSValue JSC_HOST_CALL callThrowTypeError(ExecState* exec)
{
throwTypeError(exec, static_cast<StrictModeTypeErrorFunction*>(exec->callee())->m_message);
return JSValue::encode(jsNull());
}
static CallType getCallData(JSCell*, CallData& callData)
{
callData.native.function = callThrowTypeError;
return CallTypeHost;
}
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info);
}
private:
UString m_message;
};
} // namespace JSC
#endif // Error_h
......@@ -66,11 +66,6 @@ static EncodedJSValue JSC_HOST_CALL callErrorConstructor(ExecState* exec)
return JSValue::encode(ErrorInstance::create(exec, errorStructure, message));
}
CallType ErrorConstructor::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType ErrorConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callErrorConstructor;
......
......@@ -52,7 +52,6 @@ namespace JSC {
private:
ErrorConstructor(JSGlobalObject*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -71,11 +71,6 @@ static EncodedJSValue JSC_HOST_CALL callFunctionConstructor(ExecState* exec)
return JSValue::encode(constructFunction(exec, asInternalFunction(exec->callee())->globalObject(), args));
}
CallType FunctionConstructor::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
// ECMA 15.3.1 The Function Constructor Called as a Function
CallType FunctionConstructor::getCallData(JSCell*, CallData& callData)
{
......
......@@ -49,7 +49,6 @@ namespace JSC {
FunctionConstructor(JSGlobalObject*, Structure*);
void finishCreation(ExecState*, FunctionPrototype*);
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -34,13 +34,13 @@ namespace JSC {
ASSERT_CLASS_FITS_IN_CELL(FunctionPrototype);
const ClassInfo FunctionPrototype::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionPrototype) };
static EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionProtoFuncApply(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionProtoFuncCall(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState*);
const ClassInfo FunctionPrototype::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionPrototype) };
FunctionPrototype::FunctionPrototype(JSGlobalObject* globalObject, Structure* structure)
: InternalFunction(globalObject, structure)
{
......@@ -72,11 +72,6 @@ static EncodedJSValue JSC_HOST_CALL callFunctionPrototype(ExecState*)
return JSValue::encode(jsUndefined());
}
CallType FunctionPrototype::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
// ECMA 15.3.4
CallType FunctionPrototype::getCallData(JSCell*, CallData& callData)
{
......
......@@ -50,7 +50,6 @@ namespace JSC {
private:
FunctionPrototype(JSGlobalObject*, Structure*);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -50,6 +50,7 @@ void InternalFunction::finishCreation(JSGlobalData& globalData, const Identifier
{
Base::finishCreation(globalData);
ASSERT(inherits(&s_info));
ASSERT(methodTable()->getCallData != InternalFunction::s_info.methodTable.getCallData);
putDirect(globalData, globalData.propertyNames->name, jsString(&globalData, name.isNull() ? "" : name.ustring()), DontDelete | ReadOnly | DontEnum);
}
......@@ -68,6 +69,12 @@ const UString InternalFunction::displayName(ExecState* exec)
return UString();
}
CallType InternalFunction::getCallData(JSCell*, CallData&)
{
ASSERT_NOT_REACHED();
return CallTypeNone;
}
const UString InternalFunction::calculatedDisplayName(ExecState* exec)
{
const UString explicitName = displayName(exec);
......
......@@ -56,9 +56,9 @@ namespace JSC {
void finishCreation(JSGlobalData&, const Identifier& name);
private:
virtual CallType getCallDataVirtual(CallData&) = 0;
static CallType getCallData(JSCell*, CallData&);
private:
virtual void vtableAnchor();
};
......
......@@ -54,11 +54,6 @@ const JSObject* JSCell::getObject() const
return isObject() ? static_cast<const JSObject*>(this) : 0;
}
CallType JSCell::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType JSCell::getCallData(JSCell*, CallData&)
{
return CallTypeNone;
......
......@@ -73,7 +73,6 @@ namespace JSC {
JSObject* getObject(); // NULL if not an object
const JSObject* getObject() const; // NULL if not an object
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
virtual ConstructType getConstructData(ConstructData&);
......@@ -138,7 +137,7 @@ namespace JSC {
WriteBarrier<Structure> m_structure;
};
inline JSCell::JSCell(JSGlobalData& globalData, Structure* structure)
: m_structure(globalData, this, structure)
{
......@@ -231,13 +230,6 @@ namespace JSC {
return isCell() ? asCell()->getObject() : 0;
}
inline CallType getCallData(JSValue value, CallData& callData)
{
CallType result = value.isCell() ? value.asCell()->getCallDataVirtual(callData) : CallTypeNone;
ASSERT(result == CallTypeNone || value.isValidCallee());
return result;
}
inline ConstructType getConstructData(JSValue value, ConstructData& constructData)
{
ConstructType result = value.isCell() ? value.asCell()->getConstructData(constructData) : ConstructTypeNone;
......
......@@ -164,11 +164,6 @@ void JSFunction::visitChildren(JSCell* cell, SlotVisitor& visitor)
visitor.append(&thisObject->m_executable);
}
CallType JSFunction::getCallDataVirtual(CallData& callData)
{
return getCallData(this, callData);
}
CallType JSFunction::getCallData(JSCell* cell, CallData& callData)
{
JSFunction* thisObject = static_cast<JSFunction*>(cell);
......
......@@ -109,7 +109,6 @@ namespace JSC {
NativeFunction nativeConstructor();
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
static inline size_t offsetOfScopeChain()
......
......@@ -42,6 +42,7 @@
#include "CodeBlock.h"
#include "DateConstructor.h"
#include "DatePrototype.h"
#include "Error.h"