⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 260722 in webkit


Ignore:
Timestamp:
Apr 25, 2020, 10:07:21 PM (6 years ago)
Author:
Ross Kirsling
Message:

[JSC] isCallable is redundant with isFunction
https://bugs.webkit.org/show_bug.cgi?id=211037

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

isCallable is only being used in two places and has the same definition as isFunction (aside from out params).
Where CallData is needed, getCallData should be used; where CallData is not needed, isFunction should be used.

  • runtime/JSCJSValue.h:
  • runtime/JSCJSValueInlines.h:

(JSC::JSValue::isCallable const): Deleted.

  • runtime/JSCell.h:
  • runtime/JSCellInlines.h:

(JSC::JSCell::isCallable): Deleted.
Remove isCallable.

  • runtime/JSONObject.cpp:

(JSC::Stringifier::Stringifier):
(JSC::Stringifier::toJSON):
Use getCallData if you need CallData.

  • runtime/ExceptionHelpers.cpp:

(JSC::errorDescriptionForValue):

  • runtime/ObjectConstructor.cpp:

(JSC::toPropertyDescriptor):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
Don't use getCallData if you don't need CallData.

Source/WebCore:

  • bindings/js/JSDOMConvertScheduledAction.h:

(WebCore::Converter<IDLScheduledAction>::convert):

  • worklets/PaintWorkletGlobalScope.cpp:

(WebCore::PaintWorkletGlobalScope::registerPaint):
Don't use getCallData if you don't need CallData.

Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r260720 r260722  
     12020-04-25  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] isCallable is redundant with isFunction
     4        https://bugs.webkit.org/show_bug.cgi?id=211037
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        isCallable is only being used in two places and has the same definition as isFunction (aside from out params).
     9        Where CallData is needed, getCallData should be used; where CallData is not needed, isFunction should be used.
     10
     11        * runtime/JSCJSValue.h:
     12        * runtime/JSCJSValueInlines.h:
     13        (JSC::JSValue::isCallable const): Deleted.
     14        * runtime/JSCell.h:
     15        * runtime/JSCellInlines.h:
     16        (JSC::JSCell::isCallable): Deleted.
     17        Remove isCallable.
     18
     19        * runtime/JSONObject.cpp:
     20        (JSC::Stringifier::Stringifier):
     21        (JSC::Stringifier::toJSON):
     22        Use getCallData if you need CallData.
     23
     24        * runtime/ExceptionHelpers.cpp:
     25        (JSC::errorDescriptionForValue):
     26        * runtime/ObjectConstructor.cpp:
     27        (JSC::toPropertyDescriptor):
     28        * runtime/ObjectPrototype.cpp:
     29        (JSC::objectProtoFuncDefineGetter):
     30        (JSC::objectProtoFuncDefineSetter):
     31        Don't use getCallData if you don't need CallData.
     32
    1332020-04-25  Yusuke Suzuki  <ysuzuki@apple.com>
    234
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r254464 r260722  
    9595    if (v.isObject()) {
    9696        VM& vm = globalObject->vm();
    97         CallData callData;
    9897        JSObject* object = asObject(v);
    99         if (object->methodTable(vm)->getCallData(object, callData) != CallType::None)
     98        if (object->isFunction(vm))
    10099            return vm.smallStrings.functionString()->value(globalObject);
    101100        return JSObject::calculatedClassName(object);
  • trunk/Source/JavaScriptCore/runtime/JSCJSValue.h

    r260683 r260722  
    235235    bool isEmpty() const;
    236236    bool isFunction(VM&) const;
    237     bool isCallable(VM&) const;
    238     bool isCallable(VM&, CallType&, CallData&) const;
    239237    bool isConstructor(VM&) const;
    240238    bool isConstructor(VM&, ConstructType&, ConstructData&) const;
  • trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h

    r260683 r260722  
    881881        return false;
    882882    return asCell()->isFunction(vm);
    883 }
    884 
    885 inline bool JSValue::isCallable(VM& vm) const
    886 {
    887     CallType unusedType;
    888     CallData unusedData;
    889     return isCallable(vm, unusedType, unusedData);
    890 }
    891 
    892 inline bool JSValue::isCallable(VM& vm, CallType& callType, CallData& callData) const
    893 {
    894     if (!isCell())
    895         return false;
    896     return asCell()->isCallable(vm, callType, callData);
    897883}
    898884
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r260331 r260722  
    109109    bool isProxy() const;
    110110    bool isFunction(VM&);
    111     bool isCallable(VM&, CallType&, CallData&);
    112111    bool isConstructor(VM&);
    113112    bool isConstructor(VM&, ConstructType&, ConstructData&);
  • trunk/Source/JavaScriptCore/runtime/JSCellInlines.h

    r260331 r260722  
    241241}
    242242
    243 inline bool JSCell::isCallable(VM& vm, CallType& callType, CallData& callData)
    244 {
    245     if (type() != JSFunctionType && !(inlineTypeFlags() & OverridesGetCallData))
    246         return false;
    247     callType = methodTable(vm)->getCallData(this, callData);
    248     return callType != CallType::None;
    249 }
    250 
    251243inline bool JSCell::isConstructor(VM& vm)
    252244{
  • trunk/Source/JavaScriptCore/runtime/JSONObject.cpp

    r258081 r260722  
    232232        JSObject* replacerObject = asObject(m_replacer);
    233233
    234         m_replacerCallType = CallType::None;
    235         if (!replacerObject->isCallable(vm, m_replacerCallType, m_replacerCallData)) {
     234        m_replacerCallType = getCallData(vm, replacerObject, m_replacerCallData);
     235        if (m_replacerCallType == CallType::None) {
    236236            bool isArrayReplacer = JSC::isArray(globalObject, replacerObject);
    237237            RETURN_IF_EXCEPTION(scope, );
     
    305305    RETURN_IF_EXCEPTION(scope, { });
    306306
    307     CallType callType;
    308307    CallData callData;
    309     if (!toJSONFunction.isCallable(vm, callType, callData))
     308    CallType callType = getCallData(vm, toJSONFunction, callData);
     309    if (callType == CallType::None)
    310310        return baseValue;
    311311
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r260447 r260722  
    532532        JSValue get = description->get(globalObject, vm.propertyNames->get);
    533533        RETURN_IF_EXCEPTION(scope, false);
    534         if (!get.isUndefined()) {
    535             CallData callData;
    536             if (getCallData(vm, get, callData) == CallType::None) {
    537                 throwTypeError(globalObject, scope, "Getter must be a function."_s);
    538                 return false;
    539             }
     534        if (!get.isUndefined() && !get.isFunction(vm)) {
     535            throwTypeError(globalObject, scope, "Getter must be a function."_s);
     536            return false;
    540537        }
    541538        desc.setGetter(get);
     
    548545        JSValue set = description->get(globalObject, vm.propertyNames->set);
    549546        RETURN_IF_EXCEPTION(scope, false);
    550         if (!set.isUndefined()) {
    551             CallData callData;
    552             if (getCallData(vm, set, callData) == CallType::None) {
    553                 throwTypeError(globalObject, scope, "Setter must be a function."_s);
    554                 return false;
    555             }
     547        if (!set.isUndefined() && !set.isFunction(vm)) {
     548            throwTypeError(globalObject, scope, "Setter must be a function."_s);
     549            return false;
    556550        }
    557551        desc.setSetter(set);
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r259676 r260722  
    155155
    156156    JSValue get = callFrame->argument(1);
    157     CallData callData;
    158     if (getCallData(vm, get, callData) == CallType::None)
     157    if (!get.isFunction(vm))
    159158        return throwVMTypeError(globalObject, scope, "invalid getter usage"_s);
    160159
     
    183182
    184183    JSValue set = callFrame->argument(1);
    185     CallData callData;
    186     if (getCallData(vm, set, callData) == CallType::None)
     184    if (!set.isFunction(vm))
    187185        return throwVMTypeError(globalObject, scope, "invalid setter usage"_s);
    188186
  • trunk/Source/WebCore/ChangeLog

    r260719 r260722  
     12020-04-25  Ross Kirsling  <ross.kirsling@sony.com>
     2
     3        [JSC] isCallable is redundant with isFunction
     4        https://bugs.webkit.org/show_bug.cgi?id=211037
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * bindings/js/JSDOMConvertScheduledAction.h:
     9        (WebCore::Converter<IDLScheduledAction>::convert):
     10        * worklets/PaintWorkletGlobalScope.cpp:
     11        (WebCore::PaintWorkletGlobalScope::registerPaint):
     12        Don't use getCallData if you don't need CallData.
     13
    1142020-04-25  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebCore/bindings/js/JSDOMConvertScheduledAction.h

    r251425 r260722  
    3939        auto scope = DECLARE_THROW_SCOPE(vm);
    4040
    41         JSC::CallData callData;
    42         if (getCallData(vm, value, callData) == JSC::CallType::None) {
     41        if (!value.isFunction(vm)) {
    4342            auto code = Converter<IDLDOMString>::convert(lexicalGlobalObject, value);
    4443            RETURN_IF_EXCEPTION(scope, nullptr);
  • trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.cpp

    r251425 r260722  
    7676
    7777    // Validate that paintConstructor is a VoidFunction
    78     CallData callData;
    79     if (JSC::getCallData(vm, paintConstructor.get(), callData) == JSC::CallType::None)
     78    if (!paintConstructor->isFunction(vm))
    8079        return Exception { TypeError, "paintConstructor must be callable" };
    8180
Note: See TracChangeset for help on using the changeset viewer.