Ignore:
Timestamp:
Apr 11, 2014, 3:38:22 PM (11 years ago)
Author:
[email protected]
Message:

Rollout - Rewrite Function.bind as a builtin
https://bugs.webkit.org/show_bug.cgi?id=131083

Unreviewed.

Rolling out r167020 while investigating a performance regression.

Source/JavaScriptCore:

  • API/JSObjectRef.cpp:

(JSObjectMakeConstructor):

  • API/JSScriptRef.cpp:

(parseScript):

(JSC::BuiltinExecutables::createBuiltinExecutable):

  • builtins/Function.prototype.js:

(apply):
(bind.bindingFunction): Deleted.
(bind.else.bindingFunction): Deleted.
(bind): Deleted.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock):

  • bytecompiler/NodesCodegen.cpp:

(JSC::InstanceOfNode::emitBytecode):

  • interpreter/Interpreter.cpp:
  • parser/Lexer.cpp:

(JSC::Lexer<T>::Lexer):
(JSC::Lexer<LChar>::parseIdentifier):
(JSC::Lexer<UChar>::parseIdentifier):

  • parser/Lexer.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::Parser):
(JSC::Parser<LexerType>::parseInner):

  • parser/Parser.h:

(JSC::parse):

  • parser/ParserModes.h:
  • runtime/ArgumentsIteratorConstructor.cpp:

(JSC::ArgumentsIteratorConstructor::finishCreation):

  • runtime/ArrayConstructor.cpp:

(JSC::ArrayConstructor::finishCreation):

  • runtime/BooleanConstructor.cpp:

(JSC::BooleanConstructor::finishCreation):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/CommonIdentifiers.h:
  • runtime/Completion.cpp:

(JSC::checkSyntax):

  • runtime/DateConstructor.cpp:

(JSC::DateConstructor::finishCreation):

  • runtime/ErrorConstructor.cpp:

(JSC::ErrorConstructor::finishCreation):

  • runtime/Executable.cpp:

(JSC::ProgramExecutable::checkSyntax):

  • runtime/FunctionConstructor.cpp:

(JSC::FunctionConstructor::finishCreation):

  • runtime/FunctionPrototype.cpp:

(JSC::FunctionPrototype::addFunctionProperties):
(JSC::functionProtoFuncBind):

  • runtime/JSArrayBufferConstructor.cpp:

(JSC::JSArrayBufferConstructor::finishCreation):

  • runtime/JSBoundFunction.cpp: Added.

(JSC::boundFunctionCall):
(JSC::boundFunctionConstruct):
(JSC::JSBoundFunction::create):
(JSC::JSBoundFunction::destroy):
(JSC::JSBoundFunction::customHasInstance):
(JSC::JSBoundFunction::JSBoundFunction):
(JSC::JSBoundFunction::finishCreation):
(JSC::JSBoundFunction::visitChildren):

  • runtime/JSBoundFunction.h: Added.

(JSC::JSBoundFunction::targetFunction):
(JSC::JSBoundFunction::boundThis):
(JSC::JSBoundFunction::boundArgs):
(JSC::JSBoundFunction::createStructure):

  • runtime/JSFunction.cpp:

(JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor):
(JSC::RetrieveCallerFunctionFunctor::operator()):
(JSC::retrieveCallerFunction):
(JSC::JSFunction::getOwnPropertySlot):
(JSC::JSFunction::getOwnNonIndexPropertyNames):
(JSC::JSFunction::put):
(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGenericTypedArrayViewConstructorInlines.h:

(JSC::JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncSetTypeErrorAccessor): Deleted.

  • runtime/JSGlobalObjectFunctions.h:
  • runtime/JSObject.cpp:

(JSC::JSObject::putDirectPrototypeProperty): Deleted.
(JSC::JSObject::putDirectPrototypePropertyWithoutTransitions): Deleted.

  • runtime/JSObject.h:
  • runtime/JSPromiseConstructor.cpp:

(JSC::JSPromiseConstructor::finishCreation):

  • runtime/MapConstructor.cpp:

(JSC::MapConstructor::finishCreation):

  • runtime/MapIteratorConstructor.cpp:

(JSC::MapIteratorConstructor::finishCreation):

  • runtime/NameConstructor.cpp:

(JSC::NameConstructor::finishCreation):

  • runtime/NativeErrorConstructor.cpp:

(JSC::NativeErrorConstructor::finishCreation):

  • runtime/NumberConstructor.cpp:

(JSC::NumberConstructor::finishCreation):

  • runtime/ObjectConstructor.cpp:

(JSC::ObjectConstructor::finishCreation):

  • runtime/RegExpConstructor.cpp:

(JSC::RegExpConstructor::finishCreation):

  • runtime/SetConstructor.cpp:

(JSC::SetConstructor::finishCreation):

  • runtime/SetIteratorConstructor.cpp:

(JSC::SetIteratorConstructor::finishCreation):

  • runtime/StringConstructor.cpp:

(JSC::StringConstructor::finishCreation):

  • runtime/WeakMapConstructor.cpp:

(JSC::WeakMapConstructor::finishCreation):

Source/WebCore:

  • bindings/js/JSImageConstructor.cpp:

(WebCore::JSImageConstructor::finishCreation):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateConstructorHelperMethods):

  • bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:

(WebCore::JSTestActiveDOMObjectConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:

(WebCore::JSTestCustomNamedGetterConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestEventConstructor.cpp:

(WebCore::JSTestEventConstructorConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestEventTarget.cpp:

(WebCore::JSTestEventTargetConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestException.cpp:

(WebCore::JSTestExceptionConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:

(WebCore::JSTestGenerateIsReachableConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestInterface.cpp:

(WebCore::JSTestInterfaceConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:

(WebCore::JSTestMediaQueryListListenerConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestNamedConstructor.cpp:

(WebCore::JSTestNamedConstructorConstructor::finishCreation):
(WebCore::JSTestNamedConstructorNamedConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestNode.cpp:

(WebCore::JSTestNodeConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::JSTestObjConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:

(WebCore::JSTestOverloadedConstructorsConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:

(WebCore::JSTestSerializedScriptValueInterfaceConstructor::finishCreation):

  • bindings/scripts/test/JS/JSTestTypedefs.cpp:

(WebCore::JSTestTypedefsConstructor::finishCreation):

  • bindings/scripts/test/JS/JSattribute.cpp:

(WebCore::JSattributeConstructor::finishCreation):

  • bindings/scripts/test/JS/JSreadonly.cpp:

(WebCore::JSreadonlyConstructor::finishCreation):

LayoutTests:

  • js/dom/function-bind-expected.txt:
  • js/regress/function-bind-expected.txt: Removed.
  • js/regress/function-bind.html: Removed.
  • js/regress/script-tests/function-bind.js: Removed.
File:
1 edited

Legend:

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

    r167020 r167165  
    3434#include "GetterSetter.h"
    3535#include "JSArray.h"
     36#include "JSBoundFunction.h"
    3637#include "JSFunctionInlines.h"
    3738#include "JSGlobalObject.h"
     
    251252class RetrieveCallerFunctionFunctor {
    252253public:
    253     RetrieveCallerFunctionFunctor(ExecState* exec, JSFunction* functionObj)
    254         : m_exec(exec)
    255         , m_targetCallee(jsDynamicCast<JSObject*>(functionObj))
     254    RetrieveCallerFunctionFunctor(JSFunction* functionObj)
     255        : m_targetCallee(jsDynamicCast<JSObject*>(functionObj))
    256256        , m_hasFoundFrame(false)
    257257        , m_hasSkippedToCallerFrame(false)
     
    266266        JSObject* callee = visitor->callee();
    267267
    268         if (callee && callee->hasOwnProperty(m_exec, m_exec->propertyNames().boundFunctionNamePrivateName))
     268        if (callee && callee->inherits(JSBoundFunction::info()))
    269269            return StackVisitor::Continue;
    270270
     
    284284
    285285private:
    286     ExecState* m_exec;
    287286    JSObject* m_targetCallee;
    288287    bool m_hasFoundFrame;
     
    293292static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj)
    294293{
    295     RetrieveCallerFunctionFunctor functor(exec, functionObj);
     294    RetrieveCallerFunctionFunctor functor(functionObj);
    296295    exec->iterate(functor);
    297296    return functor.result();
     
    330329{
    331330    JSFunction* thisObject = jsCast<JSFunction*>(object);
    332     if (thisObject->isHostFunction())
     331    if (thisObject->isHostOrBuiltinFunction())
    333332        return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    334     if (thisObject->isBuiltinFunction()) {
    335         if (propertyName == exec->propertyNames().caller) {
    336             if (thisObject->jsExecutable()->isStrictMode()) {
    337                 bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    338                 if (!result) {
    339                     thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor);
    340                     result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    341                     ASSERT(result);
    342                 }
    343                 return result;
    344             }
    345             slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, callerGetter);
    346             return true;
    347         }
    348         if (propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) {
    349             PropertySlot boundFunctionSlot(thisObject);
    350             if (Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot)) {
    351                 JSValue boundFunction = boundFunctionSlot.getValue(exec, exec->propertyNames().boundFunctionPrivateName);
    352                 PropertySlot boundPrototypeSlot(asObject(boundFunction));
    353                 if (asObject(boundFunction)->getPropertySlot(exec, propertyName, boundPrototypeSlot)) {
    354                     slot.setValue(boundPrototypeSlot.slotBase(), boundPrototypeSlot.attributes(), boundPrototypeSlot.getValue(exec, propertyName));
    355                     return true;
    356                 }
    357             }
    358         }
    359         if (propertyName == exec->propertyNames().name) {
    360             PropertySlot nameSlot(thisObject);
    361             if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionNamePrivateName, nameSlot)) {
    362                 slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, nameSlot.getValue(exec, exec->vm().propertyNames->boundFunctionNamePrivateName));
    363                 return true;
    364             }
    365         }
    366         if (propertyName == exec->propertyNames().length) {
    367             PropertySlot lengthSlot(thisObject);
    368             if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionLengthPrivateName, lengthSlot)) {
    369                 slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, lengthSlot.getValue(exec, exec->vm().propertyNames->boundFunctionLengthPrivateName));
    370                 return true;
    371             }
    372         }
    373            
    374         return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    375     }
    376    
    377     if (propertyName == exec->propertyNames().prototype || propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) {
     333
     334    if (propertyName == exec->propertyNames().prototype) {
    378335        VM& vm = exec->vm();
    379336        unsigned attributes;
     
    382339            JSObject* prototype = constructEmptyObject(exec);
    383340            prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum);
    384             thisObject->putDirectPrototypeProperty(vm, prototype, DontDelete | DontEnum);
     341            thisObject->putDirect(vm, exec->propertyNames().prototype, prototype, DontDelete | DontEnum);
    385342            offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes);
    386343            ASSERT(isValidOffset(offset));
     
    434391{
    435392    JSFunction* thisObject = jsCast<JSFunction*>(object);
    436     if (mode == IncludeDontEnumProperties) {
    437         bool shouldIncludeJSFunctionProperties = !thisObject->isHostOrBuiltinFunction();
    438         if (!shouldIncludeJSFunctionProperties && thisObject->isBuiltinFunction()) {
    439             PropertySlot boundFunctionSlot(thisObject);
    440             shouldIncludeJSFunctionProperties = Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot);
    441         }
    442         if (shouldIncludeJSFunctionProperties) {
    443             VM& vm = exec->vm();
    444             // Make sure prototype has been reified.
    445             PropertySlot slot(thisObject);
    446             thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot);
    447 
    448             propertyNames.add(vm.propertyNames->arguments);
    449             propertyNames.add(vm.propertyNames->caller);
    450             propertyNames.add(vm.propertyNames->length);
    451             propertyNames.add(vm.propertyNames->name);
    452         }
     393    if (!thisObject->isHostOrBuiltinFunction() && (mode == IncludeDontEnumProperties)) {
     394        VM& vm = exec->vm();
     395        // Make sure prototype has been reified.
     396        PropertySlot slot(thisObject);
     397        thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot);
     398
     399        propertyNames.add(vm.propertyNames->arguments);
     400        propertyNames.add(vm.propertyNames->caller);
     401        propertyNames.add(vm.propertyNames->length);
     402        propertyNames.add(vm.propertyNames->name);
    453403    }
    454404    Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode);
     
    470420        thisObject->m_allocationProfileWatchpoint.fireAll();
    471421        // Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile.
    472         PutPropertySlot dontCachePrototype(thisObject);
    473         Base::put(thisObject, exec, propertyName, value, dontCachePrototype);
    474         PutPropertySlot dontCachePrototypeForHasInstance(thisObject);
    475         Base::put(thisObject, exec, exec->propertyNames().prototypeForHasInstancePrivateName, value, dontCachePrototypeForHasInstance);
     422        PutPropertySlot dontCache(thisObject);
     423        Base::put(thisObject, exec, propertyName, value, dontCache);
    476424        return;
    477425    }
     
    518466        thisObject->m_allocationProfile.clear();
    519467        thisObject->m_allocationProfileWatchpoint.fireAll();
    520         if (!Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException))
    521             return false;
    522         Base::defineOwnProperty(object, exec, exec->propertyNames().prototypeForHasInstancePrivateName, descriptor, throwException);
    523         return true;
     468        return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    524469    }
    525470
Note: See TracChangeset for help on using the changeset viewer.