Ignore:
Timestamp:
Feb 20, 2011, 9:18:40 PM (14 years ago)
Author:
[email protected]
Message:

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:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r79132 r79177  
    4747#include "FunctionConstructor.h"
    4848#include "FunctionPrototype.h"
    49 #include "GlobalEvalFunction.h"
    5049#include "JSFunction.h"
    5150#include "JSGlobalObjectFunctions.h"
     
    183182
    184183    d()->functionPrototype.set(exec->globalData(), this, new (exec) FunctionPrototype(exec, this, FunctionPrototype::createStructure(jsNull()))); // The real prototype will be set once ObjectPrototype is created.
    185     d()->prototypeFunctionStructure = NativeFunctionWrapper::createStructure(d()->functionPrototype.get());
     184    d()->functionStructure = JSFunction::createStructure(d()->functionPrototype.get());
    186185    d()->internalFunctionStructure = InternalFunction::createStructure(d()->functionPrototype.get());
    187     NativeFunctionWrapper* callFunction = 0;
    188     NativeFunctionWrapper* applyFunction = 0;
    189     d()->functionPrototype->addFunctionProperties(exec, this, d()->prototypeFunctionStructure.get(), &callFunction, &applyFunction);
     186    JSFunction* callFunction = 0;
     187    JSFunction* applyFunction = 0;
     188    d()->functionPrototype->addFunctionProperties(exec, this, d()->functionStructure.get(), &callFunction, &applyFunction);
    190189    d()->callFunction.set(exec->globalData(), this, callFunction);
    191190    d()->applyFunction.set(exec->globalData(), this, applyFunction);
    192     d()->objectPrototype.set(exec->globalData(), this, new (exec) ObjectPrototype(exec, this, ObjectPrototype::createStructure(jsNull()), d()->prototypeFunctionStructure.get()));
     191    d()->objectPrototype.set(exec->globalData(), this, new (exec) ObjectPrototype(exec, this, ObjectPrototype::createStructure(jsNull()), d()->functionStructure.get()));
    193192    d()->functionPrototype->structure()->setPrototypeWithoutTransition(d()->objectPrototype.get());
    194193
    195194    d()->emptyObjectStructure = d()->objectPrototype->inheritorID();
    196195
    197     d()->functionStructure = JSFunction::createStructure(d()->functionPrototype.get());
    198196    d()->callbackFunctionStructure = JSCallbackFunction::createStructure(d()->functionPrototype.get());
    199197    d()->argumentsStructure = Arguments::createStructure(d()->objectPrototype.get());
     
    208206    d()->stringObjectStructure = StringObject::createStructure(d()->stringPrototype.get());
    209207
    210     d()->booleanPrototype.set(exec->globalData(), this, new (exec) BooleanPrototype(exec, this, BooleanPrototype::createStructure(d()->objectPrototype.get()), d()->prototypeFunctionStructure.get()));
     208    d()->booleanPrototype.set(exec->globalData(), this, new (exec) BooleanPrototype(exec, this, BooleanPrototype::createStructure(d()->objectPrototype.get()), d()->functionStructure.get()));
    211209    d()->booleanObjectStructure = BooleanObject::createStructure(d()->booleanPrototype.get());
    212210
    213     d()->numberPrototype.set(exec->globalData(), this, new (exec) NumberPrototype(exec, this, NumberPrototype::createStructure(d()->objectPrototype.get()), d()->prototypeFunctionStructure.get()));
     211    d()->numberPrototype.set(exec->globalData(), this, new (exec) NumberPrototype(exec, this, NumberPrototype::createStructure(d()->objectPrototype.get()), d()->functionStructure.get()));
    214212    d()->numberObjectStructure = NumberObject::createStructure(d()->numberPrototype.get());
    215213
     
    217215    d()->dateStructure = DateInstance::createStructure(d()->datePrototype.get());
    218216
    219     d()->regExpPrototype.set(exec->globalData(), this, new (exec) RegExpPrototype(exec, this, RegExpPrototype::createStructure(d()->objectPrototype.get()), d()->prototypeFunctionStructure.get()));
     217    d()->regExpPrototype.set(exec->globalData(), this, new (exec) RegExpPrototype(exec, this, RegExpPrototype::createStructure(d()->objectPrototype.get()), d()->functionStructure.get()));
    220218    d()->regExpStructure = RegExpObject::createStructure(d()->regExpPrototype.get());
    221219
    222220    d()->methodCallDummy.set(exec->globalData(), this, constructEmptyObject(exec));
    223221
    224     ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, this, ErrorPrototype::createStructure(d()->objectPrototype.get()), d()->prototypeFunctionStructure.get());
     222    ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, this, ErrorPrototype::createStructure(d()->objectPrototype.get()), d()->functionStructure.get());
    225223    d()->errorStructure = ErrorInstance::createStructure(errorPrototype);
    226224
    227225    // Constructors
    228226
    229     JSCell* objectConstructor = new (exec) ObjectConstructor(exec, this, ObjectConstructor::createStructure(d()->functionPrototype.get()), d()->objectPrototype.get(), d()->prototypeFunctionStructure.get());
     227    JSCell* objectConstructor = new (exec) ObjectConstructor(exec, this, ObjectConstructor::createStructure(d()->functionPrototype.get()), d()->objectPrototype.get(), d()->functionStructure.get());
    230228    JSCell* functionConstructor = new (exec) FunctionConstructor(exec, this, FunctionConstructor::createStructure(d()->functionPrototype.get()), d()->functionPrototype.get());
    231     JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, this, ArrayConstructor::createStructure(d()->functionPrototype.get()), d()->arrayPrototype.get(), d()->prototypeFunctionStructure.get());
    232     JSCell* stringConstructor = new (exec) StringConstructor(exec, this, StringConstructor::createStructure(d()->functionPrototype.get()), d()->prototypeFunctionStructure.get(), d()->stringPrototype.get());
     229    JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, this, ArrayConstructor::createStructure(d()->functionPrototype.get()), d()->arrayPrototype.get(), d()->functionStructure.get());
     230    JSCell* stringConstructor = new (exec) StringConstructor(exec, this, StringConstructor::createStructure(d()->functionPrototype.get()), d()->functionStructure.get(), d()->stringPrototype.get());
    233231    JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, this, BooleanConstructor::createStructure(d()->functionPrototype.get()), d()->booleanPrototype.get());
    234232    JSCell* numberConstructor = new (exec) NumberConstructor(exec, this, NumberConstructor::createStructure(d()->functionPrototype.get()), d()->numberPrototype.get());
    235     JSCell* dateConstructor = new (exec) DateConstructor(exec, this, DateConstructor::createStructure(d()->functionPrototype.get()), d()->prototypeFunctionStructure.get(), d()->datePrototype.get());
     233    JSCell* dateConstructor = new (exec) DateConstructor(exec, this, DateConstructor::createStructure(d()->functionPrototype.get()), d()->functionStructure.get(), d()->datePrototype.get());
    236234
    237235    d()->regExpConstructor.set(exec->globalData(), this, new (exec) RegExpConstructor(exec, this, RegExpConstructor::createStructure(d()->functionPrototype.get()), d()->regExpPrototype.get()));
     
    291289    // Set global functions.
    292290
    293     d()->evalFunction.set(exec->globalData(), this, new (exec) GlobalEvalFunction(exec, this, GlobalEvalFunction::createStructure(d()->functionPrototype.get()), 1, exec->propertyNames().eval, globalFuncEval, this));
     291    d()->evalFunction.set(exec->globalData(), this, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, exec->propertyNames().eval, globalFuncEval));
    294292    putDirectFunctionWithoutTransition(exec, d()->evalFunction.get(), DontEnum);
    295     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
    296     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
    297     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
    298     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
    299     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
    300     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
    301     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
    302     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
    303     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
    304     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
     293    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
     294    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
     295    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "isNaN"), globalFuncIsNaN), DontEnum);
     296    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "isFinite"), globalFuncIsFinite), DontEnum);
     297    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "escape"), globalFuncEscape), DontEnum);
     298    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "unescape"), globalFuncUnescape), DontEnum);
     299    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "decodeURI"), globalFuncDecodeURI), DontEnum);
     300    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "decodeURIComponent"), globalFuncDecodeURIComponent), DontEnum);
     301    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "encodeURI"), globalFuncEncodeURI), DontEnum);
     302    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "encodeURIComponent"), globalFuncEncodeURIComponent), DontEnum);
    305303#ifndef NDEBUG
    306     putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, this, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
     304    putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, this, d()->functionStructure.get(), 1, Identifier(exec, "jscprint"), globalFuncJSCPrint), DontEnum);
    307305#endif
    308306
     
    361359    markIfNeeded(markStack, d()->functionStructure);
    362360    markIfNeeded(markStack, d()->numberObjectStructure);
    363     markIfNeeded(markStack, d()->prototypeFunctionStructure);
    364361    markIfNeeded(markStack, d()->regExpMatchesArrayStructure);
    365362    markIfNeeded(markStack, d()->regExpStructure);
Note: See TracChangeset for help on using the changeset viewer.