Ignore:
Timestamp:
Apr 27, 2020, 2:09:32 AM (5 years ago)
Author:
Ross Kirsling
Message:

[JSC] CallData/ConstructData should include CallType/ConstructType
https://bugs.webkit.org/show_bug.cgi?id=211059

Reviewed by Darin Adler.

Source/JavaScriptCore:

getCallData/getConstructData return a CallType/ConstructType and have a CallData/ConstructData out param,
and then *both* of these are passed side-by-side to call/construct, which all seems a bit silly.

This patch merges CallType/ConstructType into CallData/ConstructData such that getCallData/getConstructData
no longer need an out param and call/construct require one less overt parameter.

In so doing, it also:

  • removes ConstructData entirely as it's an exact duplicate of CallData
  • renames enum value Host to Native in alignment with CallData's union
  • API/JSCallbackConstructor.cpp:

(JSC::JSCallbackConstructor::getConstructData):

  • API/JSCallbackConstructor.h:
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:

(JSC::JSCallbackObject<Parent>::getConstructData):
(JSC::JSCallbackObject<Parent>::getCallData):

  • API/JSObjectRef.cpp:

(JSObjectCallAsFunction):
(JSObjectCallAsConstructor):

  • bindings/ScriptFunctionCall.cpp:

(Deprecated::ScriptFunctionCall::call):

  • bindings/ScriptFunctionCall.h:
  • dfg/DFGOperations.cpp:
  • inspector/InjectedScriptManager.cpp:

(Inspector::InjectedScriptManager::createInjectedScript):

  • inspector/InspectorEnvironment.h:
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::executeProgram):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):

  • interpreter/Interpreter.h:
  • jit/JITOperations.cpp:
  • jsc.cpp:

(functionDollarAgentReceiveBroadcast):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::handleHostCall):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncToString):
(JSC::arrayProtoFuncToLocaleString):

  • runtime/CallData.cpp:

(JSC::call):
(JSC::profiledCall):

  • runtime/CallData.h:
  • runtime/ClassInfo.h:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/ConstructData.cpp:

(JSC::construct):
(JSC::profiledConstruct):

  • runtime/ConstructData.h:

(JSC::construct):
(JSC::profiledConstruct):
(): Deleted.

  • runtime/DatePrototype.cpp:

(JSC::dateProtoFuncToJSON):

  • runtime/GetterSetter.cpp:

(JSC::callGetter):
(JSC::callSetter):

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::getCallData):
(JSC::InternalFunction::getConstructData):

  • runtime/InternalFunction.h:
  • runtime/IteratorOperations.cpp:

(JSC::iteratorNext):
(JSC::iteratorClose):
(JSC::hasIteratorMethod):
(JSC::iteratorMethod):
(JSC::iteratorForIterable):

  • runtime/JSBoundFunction.cpp:

(JSC::boundThisNoArgsFunctionCall):
(JSC::boundFunctionCall):
(JSC::boundThisNoArgsFunctionConstruct):
(JSC::boundFunctionConstruct):

  • runtime/JSCJSValue.h:
  • runtime/JSCell.cpp:

(JSC::JSCell::getCallData):
(JSC::JSCell::getConstructData):

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

(JSC::JSCell::isFunction):
(JSC::JSCell::isConstructor):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getCallData):
(JSC::JSFunction::getConstructData):

  • runtime/JSFunction.h:
  • runtime/JSInternalPromise.cpp:

(JSC::JSInternalPromise::then):

  • runtime/JSMicrotask.cpp:

(JSC::JSMicrotask::run):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::dependencyKeysIfEvaluated):
(JSC::JSModuleLoader::provideFetch):
(JSC::JSModuleLoader::loadAndEvaluateModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::linkAndEvaluateModule):
(JSC::JSModuleLoader::requestImportModule):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::isCallableReplacer const):
(JSC::Stringifier::Stringifier):
(JSC::Stringifier::toJSON):
(JSC::Stringifier::appendStringifiedValue):
(JSC::Walker::Walker):
(JSC::Walker::callReviver):
(JSC::JSONProtoFuncParse):

  • runtime/JSObject.cpp:

(JSC::ordinarySetSlow):
(JSC::callToPrimitiveFunction):
(JSC::JSObject::hasInstance):
(JSC::JSObject::getMethod):

  • runtime/JSObject.h:
  • runtime/JSObjectInlines.h:

(JSC::getCallData):
(JSC::getConstructData):

  • runtime/JSPromise.cpp:

(JSC::JSPromise::createDeferredData):
(JSC::JSPromise::resolvedPromise):
(JSC::callFunction):

  • runtime/MapConstructor.cpp:

(JSC::constructMap):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncToLocaleString):

  • runtime/ProxyObject.cpp:

(JSC::performProxyGet):
(JSC::ProxyObject::performInternalMethodGetOwnProperty):
(JSC::ProxyObject::performHasProperty):
(JSC::ProxyObject::performPut):
(JSC::performProxyCall):
(JSC::ProxyObject::getCallData):
(JSC::performProxyConstruct):
(JSC::ProxyObject::getConstructData):
(JSC::ProxyObject::performDelete):
(JSC::ProxyObject::performPreventExtensions):
(JSC::ProxyObject::performIsExtensible):
(JSC::ProxyObject::performDefineOwnProperty):
(JSC::ProxyObject::performGetOwnPropertyNames):
(JSC::ProxyObject::performSetPrototype):
(JSC::ProxyObject::performGetPrototype):

  • runtime/ProxyObject.h:
  • runtime/ReflectObject.cpp:

(JSC::reflectObjectConstruct):

  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::processUnverifiedStackTraces):

  • runtime/SetConstructor.cpp:

(JSC::constructSet):

  • runtime/StringPrototype.cpp:

(JSC::replaceUsingRegExpSearch):
(JSC::operationStringProtoFuncReplaceRegExpEmptyStr):
(JSC::operationStringProtoFuncReplaceRegExpString):
(JSC::replaceUsingStringSearch):

  • runtime/VM.cpp:

(JSC::VM::callPromiseRejectionCallback):

  • runtime/WeakMapConstructor.cpp:

(JSC::constructWeakMap):

  • runtime/WeakSetConstructor.cpp:

(JSC::constructWeakSet):

  • tools/JSDollarVM.cpp:

(JSC::callWithStackSizeProbeFunction):

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::evaluate):

  • wasm/js/WebAssemblyWrapperFunction.cpp:

(JSC::callWebAssemblyWrapperFunction):

Source/WebCore:

  • Modules/plugins/QuickTimePluginReplacement.mm:

(WebCore::QuickTimePluginReplacement::installReplacement):

  • bindings/js/JSCallbackData.cpp:

(WebCore::JSCallbackData::invokeCallback):

  • bindings/js/JSCustomElementInterface.cpp:

(WebCore::constructCustomElementSynchronously):
(WebCore::JSCustomElementInterface::upgradeElement):
(WebCore::JSCustomElementInterface::invokeCallback):

  • bindings/js/JSCustomXPathNSResolver.cpp:

(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):

  • bindings/js/JSDOMBuiltinConstructor.h:

(WebCore::JSDOMBuiltinConstructor<JSClass>::getConstructData):

  • bindings/js/JSDOMBuiltinConstructorBase.cpp:

(WebCore::JSDOMBuiltinConstructorBase::callFunctionWithCurrentArguments):

  • bindings/js/JSDOMConstructor.h:

(WebCore::JSDOMConstructor<JSClass>::getConstructData):

  • bindings/js/JSDOMConstructorBase.cpp:

(WebCore::JSDOMConstructorBase::getCallData):

  • bindings/js/JSDOMConstructorBase.h:
  • bindings/js/JSDOMConstructorNotConstructable.h:
  • bindings/js/JSDOMIterator.h:

(WebCore::iteratorForEach):

  • bindings/js/JSDOMMapLike.cpp:

(WebCore::clearBackingMap):
(WebCore::setToBackingMap):
(WebCore::forwardFunctionCallToBackingMap):
(WebCore::forwardForEachCallToBackingMap):

  • bindings/js/JSDOMNamedConstructor.h:

(WebCore::JSDOMNamedConstructor<JSClass>::getConstructData):

  • bindings/js/JSDOMPromise.cpp:

(WebCore::DOMPromise::whenPromiseIsSettled):

  • bindings/js/JSDOMPromiseDeferred.cpp:

(WebCore::createRejectedPromiseWithTypeError):

  • bindings/js/JSDOMSetLike.cpp:

(WebCore::clearBackingSet):
(WebCore::addToBackingSet):
(WebCore::forwardFunctionCallToBackingSet):
(WebCore::forwardForEachCallToBackingSet):

  • bindings/js/JSErrorHandler.cpp:

(WebCore::JSErrorHandler::handleEvent):

  • bindings/js/JSEventListener.cpp:

(WebCore::JSEventListener::handleEvent):

  • bindings/js/JSExecState.cpp:

(WebCore::functionCallHandlerFromAnyThread):

  • bindings/js/JSExecState.h:

(WebCore::JSExecState::call):
(WebCore::JSExecState::profiledCall):

  • bindings/js/JSExecStateInstrumentation.h:

(WebCore::JSExecState::instrumentFunction):
(WebCore::JSExecState::instrumentFunctionInternal): Deleted.
(WebCore::JSExecState::instrumentFunctionCall): Deleted.
(WebCore::JSExecState::instrumentFunctionConstruct): Deleted.

  • bindings/js/JSNavigatorCustom.cpp:

(WebCore::JSNavigator::getUserMedia):

  • bindings/js/JSPluginElementFunctions.cpp:

(WebCore::callPlugin):
(WebCore::pluginElementCustomGetCallData):

  • bindings/js/JSPluginElementFunctions.h:
  • bindings/js/ReadableStream.cpp:

(WebCore::ReadableStream::create):
(WebCore::ReadableStreamInternal::callFunction):
(WebCore::ReadableStream::lock):

  • bindings/js/ReadableStreamDefaultController.cpp:

(WebCore::readableStreamCallFunction):

  • bindings/js/ScheduledAction.cpp:

(WebCore::ScheduledAction::executeFunctionInContext):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::callInWorld):
(WebCore::ScriptController::executeAsynchronousUserAgentScriptInWorld):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):
(GeneratePluginCall):
(GenerateLegacyCallerDefinitions):

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

(WebCore::JSTestObj::getCallData):

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

(WebCore::JSTestPluginInterface::getCallData):

  • bindings/scripts/test/JS/JSTestPluginInterface.h:
  • bridge/NP_jsobject.cpp:
  • bridge/objc/WebScriptObject.mm:

(-[WebScriptObject callWebScriptMethod:withArguments:]):

  • bridge/objc/objc_runtime.h:
  • bridge/objc/objc_runtime.mm:

(JSC::Bindings::ObjcFallbackObjectImp::getCallData):

  • bridge/runtime_object.cpp:

(JSC::Bindings::RuntimeObject::getCallData):
(JSC::Bindings::RuntimeObject::getConstructData):

  • bridge/runtime_object.h:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::updateCaptionContainer):
(WebCore::HTMLMediaElement::didAddUserAgentShadowRoot):
(WebCore::HTMLMediaElement::updateMediaControlsAfterPresentationModeChange):
(WebCore::HTMLMediaElement::getCurrentMediaControlsStatus):

  • html/HTMLPlugInImageElement.cpp:

(WebCore::HTMLPlugInImageElement::didAddUserAgentShadowRoot):

  • testing/Internals.cpp:

(WebCore::Internals::cloneArrayBuffer):

Source/WebKit:

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::JSNPObject::getCallData):
(WebKit::JSNPObject::getConstructData):

  • WebProcess/Plugins/Netscape/JSNPObject.h:
  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::hasMethod):
(WebKit::NPJSObject::construct):
(WebKit::NPJSObject::invoke):

Source/WebKitLegacy/mac:

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::invoke):
(WebKit::NetscapePluginInstanceProxy::invokeDefault):
(WebKit::NetscapePluginInstanceProxy::construct):

Source/WebKitLegacy/win:

  • Plugins/PluginPackage.cpp:

(WebCore::NPN_Invoke):

Location:
trunk/Source/JavaScriptCore/bindings
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bindings/ScriptFunctionCall.cpp

    r253423 r260744  
    115115        return makeUnexpected(scope.exception());
    116116
    117     CallData callData;
    118     CallType callType = getCallData(vm, function, callData);
    119     if (callType == CallType::None)
     117    auto callData = getCallData(vm, function);
     118    if (callData.type == CallData::Type::None)
    120119        return { };
    121120
     
    123122    NakedPtr<Exception> exception;
    124123    if (m_callHandler)
    125         result = m_callHandler(m_globalObject, function, callType, callData, thisObject, m_arguments, exception);
     124        result = m_callHandler(m_globalObject, function, callData, thisObject, m_arguments, exception);
    126125    else
    127         result = JSC::call(m_globalObject, function, callType, callData, thisObject, m_arguments, exception);
     126        result = JSC::call(m_globalObject, function, callData, thisObject, m_arguments, exception);
    128127
    129128    if (exception) {
  • trunk/Source/JavaScriptCore/bindings/ScriptFunctionCall.h

    r251425 r260744  
    7171class JS_EXPORT_PRIVATE ScriptFunctionCall : public ScriptCallArgumentHandler {
    7272public:
    73     typedef JSC::JSValue (*ScriptFunctionCallHandler)(JSC::JSGlobalObject* globalObject, JSC::JSValue functionObject, JSC::CallType callType, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>&);
     73    typedef JSC::JSValue (*ScriptFunctionCallHandler)(JSC::JSGlobalObject* globalObject, JSC::JSValue functionObject, const JSC::CallData& callData, JSC::JSValue thisValue, const JSC::ArgList& args, NakedPtr<JSC::Exception>&);
    7474    ScriptFunctionCall(const ScriptObject& thisObject, const String& name, ScriptFunctionCallHandler handler = nullptr);
    7575    Expected<JSC::JSValue, NakedPtr<JSC::Exception>> call();
Note: See TracChangeset for help on using the changeset viewer.