Commit 9788fe2f authored by barraclough@apple.com's avatar barraclough@apple.com

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

Remove PrototypeFunction, NativeFunctionWrapper, and GlobalEvalFunction.

Reviewed by Oliver Hunt.

Historically, Native functions used to be represented by PrototypeFunctions, however
since introducing call optimizations to the JIT this has used JSFunctions for host
calls too. At the point this change was made, the interpreter continued to use
PrototypeFunctions, however since fallback from the JIT to interpreter was introduced
the interpreter has had to be able to run using host functions represented using
JSFunctions - leading to an unnecessary and redundant divergence in behaviour between 
interpreter only builds, and situations where the JIT has fallen back to interpreting.

NativeFunctionWrapper only existed to select between PrototypeFunction and JSFunction
for wrappers for host functions, and as such can also be removed.

GlobalEvalFunction is a redundant wrapper that happens to be derived from
PrototypeFunction. It existed to hold a reference to the global object - but since all
functions how derive from JSObjectWithGlobalObject, this no longer requires an
additional class to provide this functionality.

Source/JavaScriptCore: 

* JavaScriptCore.JSVALUE32_64only.exp:
* JavaScriptCore.JSVALUE64only.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
    Removed symbols / references to files.

* runtime/GlobalEvalFunction.cpp: Removed.
* runtime/GlobalEvalFunction.h: Removed.
* runtime/NativeFunctionWrapper.h: Removed.
* runtime/PrototypeFunction.cpp: Removed.
* runtime/PrototypeFunction.h: Removed.
    Removed.

* runtime/Executable.cpp:
(JSC::NativeExecutable::~NativeExecutable):
* runtime/Executable.h:
(JSC::NativeExecutable::create):
(JSC::NativeExecutable::NativeExecutable):
(JSC::JSFunction::nativeFunction):
* runtime/JSFunction.cpp:
(JSC::callHostFunctionAsConstructor):
(JSC::JSFunction::JSFunction):
(JSC::JSFunction::getCallData):
* runtime/JSFunction.h:
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::getHostFunction):
* runtime/JSGlobalData.h:
(JSC::JSGlobalData::getCTIStub):
    Added interpreter-friendly constructors for NativeExecutables.

* bytecompiler/BytecodeGenerator.cpp:
* interpreter/Interpreter.cpp:
* jit/JITStubs.cpp:
* jsc.cpp:
* runtime/ArrayConstructor.cpp:
* runtime/BooleanPrototype.cpp:
* runtime/BooleanPrototype.h:
* runtime/CallData.h:
* runtime/DateConstructor.cpp:
* runtime/DateConstructor.h:
* runtime/ErrorPrototype.cpp:
* runtime/ErrorPrototype.h:
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObjectFunctions.cpp:
* runtime/Lookup.cpp:
* runtime/NumberPrototype.cpp:
* runtime/NumberPrototype.h:
* runtime/ObjectConstructor.cpp:
* runtime/ObjectConstructor.h:
* runtime/ObjectPrototype.cpp:
* runtime/ObjectPrototype.h:
* runtime/RegExpPrototype.cpp:
* runtime/RegExpPrototype.h:
* runtime/SmallStrings.h:
* runtime/StringConstructor.cpp:
* runtime/StringConstructor.h:
    Removed use of redundant classes.

Source/WebCore: 

* bindings/js/JSDOMBinding.cpp:
* bindings/js/JSDOMWindowCustom.cpp:
* bindings/js/JSHistoryCustom.cpp:
* bindings/js/JSLocationCustom.cpp:
    Removed use of redundant classes.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@79177 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 82562ca4
......@@ -94,7 +94,6 @@ LOCAL_SRC_FILES := \
runtime/FunctionPrototype.cpp \
runtime/GCHandle.cpp \
runtime/GetterSetter.cpp \
runtime/GlobalEvalFunction.cpp \
runtime/Identifier.cpp \
runtime/InitializeThreading.cpp \
runtime/InternalFunction.cpp \
......@@ -137,7 +136,6 @@ LOCAL_SRC_FILES := \
runtime/PropertyDescriptor.cpp \
runtime/PropertyNameArray.cpp \
runtime/PropertySlot.cpp \
runtime/PrototypeFunction.cpp \
runtime/RegExp.cpp \
runtime/RegExpConstructor.cpp \
runtime/RegExpObject.cpp \
......
......@@ -104,7 +104,6 @@ SET(JavaScriptCore_SOURCES
runtime/FunctionPrototype.cpp
runtime/GCActivityCallback.cpp
runtime/GetterSetter.cpp
runtime/GlobalEvalFunction.cpp
runtime/Identifier.cpp
runtime/InitializeThreading.cpp
runtime/InternalFunction.cpp
......@@ -148,7 +147,6 @@ SET(JavaScriptCore_SOURCES
runtime/PropertyDescriptor.cpp
runtime/PropertyNameArray.cpp
runtime/PropertySlot.cpp
runtime/PrototypeFunction.cpp
runtime/RegExp.cpp
runtime/RegExpCache.cpp
runtime/RegExpConstructor.cpp
......
2011-02-20 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
https://bugs.webkit.org/show_bug.cgi?id=54839
Remove PrototypeFunction, NativeFunctionWrapper, and GlobalEvalFunction.
Historically, Native functions used to be represented by PrototypeFunctions, however
since introducing call optimizations to the JIT this has used JSFunctions for host
calls too. At the point this change was made, the interpreter continued to use
PrototypeFunctions, however since fallback from the JIT to interpreter was introduced
the interpreter has had to be able to run using host functions represented using
JSFunctions - leading to an unnecessary and redundant divergence in behaviour between
interpreter only builds, and situations where the JIT has fallen back to interpreting.
NativeFunctionWrapper only existed to select between PrototypeFunction and JSFunction
for wrappers for host functions, and as such can also be removed.
GlobalEvalFunction is a redundant wrapper that happens to be derived from
PrototypeFunction. It existed to hold a reference to the global object - but since all
functions how derive from JSObjectWithGlobalObject, this no longer requires an
additional class to provide this functionality.
* JavaScriptCore.JSVALUE32_64only.exp:
* JavaScriptCore.JSVALUE64only.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
Removed symbols / references to files.
* runtime/GlobalEvalFunction.cpp: Removed.
* runtime/GlobalEvalFunction.h: Removed.
* runtime/NativeFunctionWrapper.h: Removed.
* runtime/PrototypeFunction.cpp: Removed.
* runtime/PrototypeFunction.h: Removed.
Removed.
* runtime/Executable.cpp:
(JSC::NativeExecutable::~NativeExecutable):
* runtime/Executable.h:
(JSC::NativeExecutable::create):
(JSC::NativeExecutable::NativeExecutable):
(JSC::JSFunction::nativeFunction):
* runtime/JSFunction.cpp:
(JSC::callHostFunctionAsConstructor):
(JSC::JSFunction::JSFunction):
(JSC::JSFunction::getCallData):
* runtime/JSFunction.h:
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::getHostFunction):
* runtime/JSGlobalData.h:
(JSC::JSGlobalData::getCTIStub):
Added interpreter-friendly constructors for NativeExecutables.
* bytecompiler/BytecodeGenerator.cpp:
* interpreter/Interpreter.cpp:
* jit/JITStubs.cpp:
* jsc.cpp:
* runtime/ArrayConstructor.cpp:
* runtime/BooleanPrototype.cpp:
* runtime/BooleanPrototype.h:
* runtime/CallData.h:
* runtime/DateConstructor.cpp:
* runtime/DateConstructor.h:
* runtime/ErrorPrototype.cpp:
* runtime/ErrorPrototype.h:
* runtime/FunctionPrototype.cpp:
* runtime/FunctionPrototype.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSGlobalObjectFunctions.cpp:
* runtime/Lookup.cpp:
* runtime/NumberPrototype.cpp:
* runtime/NumberPrototype.h:
* runtime/ObjectConstructor.cpp:
* runtime/ObjectConstructor.h:
* runtime/ObjectPrototype.cpp:
* runtime/ObjectPrototype.h:
* runtime/RegExpPrototype.cpp:
* runtime/RegExpPrototype.h:
* runtime/SmallStrings.h:
* runtime/StringConstructor.cpp:
* runtime/StringConstructor.h:
Removed use of redundant classes.
2011-02-19 Laszlo Gombos <laszlo.1.gombos@nokia.com>
Unreviewed build fix for Symbian.
......
......@@ -277,8 +277,6 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/GCActivityCallback.h \
Source/JavaScriptCore/runtime/GetterSetter.cpp \
Source/JavaScriptCore/runtime/GetterSetter.h \
Source/JavaScriptCore/runtime/GlobalEvalFunction.cpp \
Source/JavaScriptCore/runtime/GlobalEvalFunction.h \
Source/JavaScriptCore/runtime/Identifier.cpp \
Source/JavaScriptCore/runtime/Identifier.h \
Source/JavaScriptCore/runtime/InitializeThreading.cpp \
......@@ -349,7 +347,6 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/NativeErrorConstructor.h \
Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp \
Source/JavaScriptCore/runtime/NativeErrorPrototype.h \
Source/JavaScriptCore/runtime/NativeFunctionWrapper.h \
Source/JavaScriptCore/runtime/NumberConstructor.cpp \
Source/JavaScriptCore/runtime/NumberConstructor.h \
Source/JavaScriptCore/runtime/NumberObject.cpp \
......@@ -371,8 +368,6 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/PropertySlot.cpp \
Source/JavaScriptCore/runtime/PropertySlot.h \
Source/JavaScriptCore/runtime/Protect.h \
Source/JavaScriptCore/runtime/PrototypeFunction.cpp \
Source/JavaScriptCore/runtime/PrototypeFunction.h \
Source/JavaScriptCore/runtime/PutPropertySlot.h \
Source/JavaScriptCore/runtime/RegExpCache.cpp \
Source/JavaScriptCore/runtime/RegExpCache.h \
......
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFxS2_E
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFxS2_E
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFPvS2_E
__ZN3JSC17PrototypeFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEN3WTF17NonNullPassRefPtrINS_9StructureEEEiRKNS_10IdentifierEPFPvS2_E
......@@ -219,8 +219,6 @@
'runtime/GCActivityCallback.h',
'runtime/GetterSetter.cpp',
'runtime/GetterSetter.h',
'runtime/GlobalEvalFunction.cpp',
'runtime/GlobalEvalFunction.h',
'runtime/Identifier.cpp',
'runtime/Identifier.h',
'runtime/InitializeThreading.cpp',
......@@ -288,7 +286,6 @@
'runtime/NativeErrorConstructor.h',
'runtime/NativeErrorPrototype.cpp',
'runtime/NativeErrorPrototype.h',
'runtime/NativeFunctionWrapper.h',
'runtime/NumberConstructor.cpp',
'runtime/NumberConstructor.h',
'runtime/NumberObject.cpp',
......@@ -309,8 +306,6 @@
'runtime/PropertySlot.cpp',
'runtime/PropertySlot.h',
'runtime/Protect.h',
'runtime/PrototypeFunction.cpp',
'runtime/PrototypeFunction.h',
'runtime/PutPropertySlot.h',
'runtime/RegExp.cpp',
'runtime/RegExp.h',
......
......@@ -149,7 +149,6 @@ SOURCES += \
runtime/FunctionPrototype.cpp \
runtime/GCActivityCallback.cpp \
runtime/GetterSetter.cpp \
runtime/GlobalEvalFunction.cpp \
runtime/Identifier.cpp \
runtime/InitializeThreading.cpp \
runtime/InternalFunction.cpp \
......@@ -195,7 +194,6 @@ SOURCES += \
runtime/PropertyDescriptor.cpp \
runtime/PropertyNameArray.cpp \
runtime/PropertySlot.cpp \
runtime/PrototypeFunction.cpp \
runtime/RegExpConstructor.cpp \
runtime/RegExp.cpp \
runtime/RegExpObject.cpp \
......
......@@ -16,7 +16,6 @@ EXPORTS
??0JSObjectWithGlobalObject@JSC@@IAE@PAVJSGlobalObject@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@@Z
??0MD5@WTF@@QAE@XZ
??0Mutex@WTF@@QAE@XZ
??0PrototypeFunction@JSC@@QAE@PAVExecState@1@PAVJSGlobalObject@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@HABVIdentifier@1@P6I_J0@Z@Z
??0RefCountedLeakCounter@WTF@@QAE@PBD@Z
??0RegExpObject@JSC@@QAE@PAVJSGlobalObject@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@V?$NonNullPassRefPtr@VRegExp@JSC@@@4@@Z
??0StringObject@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVUString@1@@Z
......
......@@ -757,14 +757,6 @@
RelativePath="..\..\runtime\GetterSetter.h"
>
</File>
<File
RelativePath="..\..\runtime\GlobalEvalFunction.cpp"
>
</File>
<File
RelativePath="..\..\runtime\GlobalEvalFunction.h"
>
</File>
<File
RelativePath="..\..\runtime\Identifier.cpp"
>
......@@ -1041,10 +1033,6 @@
RelativePath="..\..\runtime\NativeErrorPrototype.h"
>
</File>
<File
RelativePath="..\..\runtime\NativeFunctionWrapper.h"
>
</File>
<File
RelativePath="..\..\runtime\NumberConstructor.cpp"
>
......@@ -1129,14 +1117,6 @@
RelativePath="..\..\runtime\Protect.h"
>
</File>
<File
RelativePath="..\..\runtime\PrototypeFunction.cpp"
>
</File>
<File
RelativePath="..\..\runtime\PrototypeFunction.h"
>
</File>
<File
RelativePath="..\..\runtime\RegExp.cpp"
>
......
......@@ -31,7 +31,6 @@
#include "BytecodeGenerator.h"
#include "BatchedTransitionOptimizer.h"
#include "PrototypeFunction.h"
#include "JSFunction.h"
#include "Interpreter.h"
#include "UString.h"
......
......@@ -42,7 +42,6 @@
#include "EvalCodeCache.h"
#include "ExceptionHelpers.h"
#include "GetterSetter.h"
#include "GlobalEvalFunction.h"
#include "JSActivation.h"
#include "JSArray.h"
#include "JSByteArray.h"
......
......@@ -40,7 +40,6 @@
#include "Debugger.h"
#include "ExceptionHelpers.h"
#include "GetterSetter.h"
#include "GlobalEvalFunction.h"
#include "JIT.h"
#include "JSActivation.h"
#include "JSArray.h"
......
......@@ -31,7 +31,6 @@
#include "JSFunction.h"
#include "JSLock.h"
#include "JSString.h"
#include "PrototypeFunction.h"
#include "SamplingTool.h"
#include <math.h>
#include <stdio.h>
......@@ -151,19 +150,19 @@ ASSERT_CLASS_FITS_IN_CELL(GlobalObject);
GlobalObject::GlobalObject(const Vector<UString>& arguments)
: JSGlobalObject()
{
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
#if ENABLE(SAMPLING_FLAGS)
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
putDirectFunction(globalExec(), new (globalExec()) NativeFunctionWrapper(globalExec(), this, prototypeFunctionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
#endif
JSObject* array = constructEmptyArray(globalExec());
......
......@@ -30,7 +30,6 @@
#include "JSArray.h"
#include "JSFunction.h"
#include "Lookup.h"
#include "PrototypeFunction.h"
namespace JSC {
......@@ -38,7 +37,7 @@ ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
static EncodedJSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*);
ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* functionStructure)
: InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, arrayPrototype->classInfo()->className))
{
// ECMA 15.4.3.1 Array.prototype
......@@ -48,7 +47,7 @@ ArrayConstructor::ArrayConstructor(ExecState* exec, JSGlobalObject* globalObject
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
// ES5
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
}
static inline JSObject* constructArrayWithSizeQuirk(ExecState* exec, const ArgList& args)
......
......@@ -26,7 +26,6 @@
#include "JSFunction.h"
#include "JSString.h"
#include "ObjectPrototype.h"
#include "PrototypeFunction.h"
namespace JSC {
......@@ -38,13 +37,13 @@ static EncodedJSValue JSC_HOST_CALL booleanProtoFuncValueOf(ExecState*);
// ECMA 15.6.4
BooleanPrototype::BooleanPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
BooleanPrototype::BooleanPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* functionStructure)
: BooleanObject(exec->globalData(), structure)
{
setInternalValue(exec->globalData(), jsBoolean(false));
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 0, exec->propertyNames().toString, booleanProtoFuncToString), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 0, exec->propertyNames().valueOf, booleanProtoFuncValueOf), DontEnum);
}
......
......@@ -27,7 +27,7 @@ namespace JSC {
class BooleanPrototype : public BooleanObject {
public:
BooleanPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
BooleanPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* functionStructure);
};
} // namespace JSC
......
......@@ -30,7 +30,6 @@
#define CallData_h
#include "JSValue.h"
#include "NativeFunctionWrapper.h"
namespace JSC {
......
......@@ -30,7 +30,6 @@
#include "JSString.h"
#include "JSStringBuilder.h"
#include "ObjectPrototype.h"
#include "PrototypeFunction.h"
#include <math.h>
#include <time.h>
#include <wtf/DateMath.h>
......@@ -58,14 +57,14 @@ static EncodedJSValue JSC_HOST_CALL dateParse(ExecState*);
static EncodedJSValue JSC_HOST_CALL dateNow(ExecState*);
static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState*);
DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure, DatePrototype* datePrototype)
DateConstructor::DateConstructor(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* functionStructure, DatePrototype* datePrototype)
: InternalFunction(&exec->globalData(), globalObject, structure, Identifier(exec, datePrototype->classInfo()->className))
{
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().prototype, datePrototype, DontEnum | DontDelete | ReadOnly);
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 1, exec->propertyNames().parse, dateParse), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 0, exec->propertyNames().now, dateNow), DontEnum);
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(7), ReadOnly | DontEnum | DontDelete);
}
......
......@@ -29,7 +29,7 @@ namespace JSC {
class DateConstructor : public InternalFunction {
public:
DateConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure, DatePrototype*);
DateConstructor(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* functionStructure, DatePrototype*);
private:
virtual ConstructType getConstructData(ConstructData&);
......
......@@ -25,7 +25,6 @@
#include "JSString.h"
#include "JSStringBuilder.h"
#include "ObjectPrototype.h"
#include "PrototypeFunction.h"
#include "StringRecursionChecker.h"
#include "UString.h"
......@@ -36,13 +35,13 @@ ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
static EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState*);
// ECMA 15.9.4
ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* prototypeFunctionStructure)
ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, Structure* functionStructure)
: ErrorInstance(&exec->globalData(), structure)
{
// The constructor will be added later in ErrorConstructor's constructor
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 0, exec->propertyNames().toString, errorProtoFuncToString), DontEnum);
}
EncodedJSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec)
......
......@@ -29,7 +29,7 @@ namespace JSC {
class ErrorPrototype : public ErrorInstance {
public:
ErrorPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* prototypeFunctionStructure);
ErrorPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, Structure* functionStructure);
};
} // namespace JSC
......
......@@ -35,11 +35,9 @@
namespace JSC {
#if ENABLE(JIT)
NativeExecutable::~NativeExecutable()
{
}
#endif
VPtrHackExecutable::~VPtrHackExecutable()
{
......
......@@ -92,22 +92,29 @@ namespace JSC {
#endif
};
#if ENABLE(JIT)
class NativeExecutable : public ExecutableBase {
friend class JIT;
public:
#if ENABLE(JIT)
static PassRefPtr<NativeExecutable> create(MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor)
{
if (!callThunk)
return adoptRef(new NativeExecutable(JITCode(), function, JITCode(), constructor));
return adoptRef(new NativeExecutable(JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor));
}
#else
static PassRefPtr<NativeExecutable> create(NativeFunction function, NativeFunction constructor)
{
return adoptRef(new NativeExecutable(function, constructor));
}
#endif
~NativeExecutable();
NativeFunction function() { return m_function; }
private:
#if ENABLE(JIT)
NativeExecutable(JITCode callThunk, NativeFunction function, JITCode constructThunk, NativeFunction constructor)
: ExecutableBase(NUM_PARAMETERS_IS_HOST)
, m_function(function)
......@@ -118,13 +125,20 @@ namespace JSC {
m_jitCodeForCallWithArityCheck = callThunk.addressForCall();
m_jitCodeForConstructWithArityCheck = constructThunk.addressForCall();
}
#else
NativeExecutable(NativeFunction function, NativeFunction constructor)
: ExecutableBase(NUM_PARAMETERS_IS_HOST)
, m_function(function)
, m_constructor(constructor)
{
}
#endif
NativeFunction m_function;
// Probably should be a NativeConstructor, but this will currently require rewriting the JIT
// trampoline. It may be easier to make NativeFunction be passed 'this' as a part of the ArgList.
NativeFunction m_constructor;
};
#endif
class VPtrHackExecutable : public ExecutableBase {
public:
......@@ -398,13 +412,11 @@ namespace JSC {
return m_executable->isHostFunction();
}
#if ENABLE(JIT)
inline NativeFunction JSFunction::nativeFunction()
{
ASSERT(isHostFunction());
return static_cast<NativeExecutable*>(m_executable.get())->function();
}
#endif
}
#endif
......@@ -28,7 +28,6 @@
#include "JSStringBuilder.h"
#include "Interpreter.h"
#include "Lexer.h"
#include "PrototypeFunction.h"
namespace JSC {
......@@ -44,12 +43,12 @@ FunctionPrototype::FunctionPrototype(ExecState* exec, JSGlobalObject* globalObje
putDirectWithoutTransition(exec->globalData(), exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
}
void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* globalObject, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction)
void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* globalObject, Structure* functionStructure, JSFunction** callFunction, JSFunction** applyFunction)
{
putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
*applyFunction = new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
*applyFunction = new (exec) JSFunction(exec, globalObject, functionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
putDirectFunctionWithoutTransition(exec, *applyFunction, DontEnum);
*callFunction = new (exec) NativeFunctionWrapper(exec, globalObject, prototypeFunctionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
*callFunction = new (exec) JSFunction(exec, globalObject, functionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum);
}
......
......@@ -25,12 +25,10 @@
namespace JSC {
class PrototypeFunction;
class FunctionPrototype : public InternalFunction {
public:
FunctionPrototype(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>);
void addFunctionProperties(ExecState*, JSGlobalObject*, Structure* prototypeFunctionStructure, NativeFunctionWrapper** callFunction, NativeFunctionWrapper** applyFunction);
void addFunctionProperties(ExecState*, JSGlobalObject*, Structure* functionStructure, JSFunction** callFunction, JSFunction** applyFunction);
static PassRefPtr<Structure> createStructure(JSValue proto)
{
......
/*
* Copyright (C) 1999-2002 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca)
* Copyright (C) 2007 Maks Orlovich
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
#include "GlobalEvalFunction.h"