Diff
Modified: trunk/Source/_javascript_Core/API/JSObjectRef.cpp (260734 => 260735)
--- trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2020-04-27 00:37:15 UTC (rev 260735)
@@ -705,9 +705,8 @@
JSGlobalObject* globalObject = toJS(ctx);
VM& vm = globalObject->vm();
JSLockHolder locker(vm);
- CallData callData;
JSCell* cell = toJS(object);
- return cell->methodTable(vm)->getCallData(cell, callData) != CallType::None;
+ return cell->isFunction(vm);
}
JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
Modified: trunk/Source/_javascript_Core/ChangeLog (260734 => 260735)
--- trunk/Source/_javascript_Core/ChangeLog 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-04-27 00:37:15 UTC (rev 260735)
@@ -1,3 +1,32 @@
+2020-04-26 Ross Kirsling <[email protected]>
+
+ [JSC] Clearly distinguish isConstructor from getConstructData
+ https://bugs.webkit.org/show_bug.cgi?id=211053
+
+ Reviewed by Sam Weinig.
+
+ Follow-up to r260722. Remove the isConstructor overload that duplicates getConstructData
+ and clearly distinguish the usage of these two functions.
+
+ * runtime/JSCJSValue.h:
+ * runtime/JSCJSValueInlines.h:
+ * runtime/JSCell.h:
+ * runtime/JSCellInlines.h:
+ (JSC::JSCell::isConstructor):
+ Remove isConstructor overload.
+
+ * runtime/JSBoundFunction.cpp:
+ (JSC::JSBoundFunction::create):
+ Don't use getConstructData if you don't need ConstructData.
+
+ * runtime/ReflectObject.cpp:
+ (JSC::reflectObjectConstruct):
+ Use getConstructData if you need ConstructData.
+
+ * API/JSObjectRef.cpp:
+ (JSObjectIsFunction):
+ Use isFunction (leftover spot from last patch).
+
2020-04-26 Alexey Shvayka <[email protected]>
Symbol should have [[Construct]] internal method
Modified: trunk/Source/_javascript_Core/runtime/JSBoundFunction.cpp (260734 => 260735)
--- trunk/Source/_javascript_Core/runtime/JSBoundFunction.cpp 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/runtime/JSBoundFunction.cpp 2020-04-27 00:37:15 UTC (rev 260735)
@@ -205,9 +205,7 @@
}
bool isJSFunction = getJSFunction(targetFunction);
- ConstructData constructData;
- ConstructType constructType = JSC::getConstructData(vm, targetFunction, constructData);
- bool canConstruct = constructType != ConstructType::None;
+ bool canConstruct = targetFunction->isConstructor(vm);
NativeExecutable* executable = vm.getBoundFunction(isJSFunction, canConstruct);
Structure* structure = getBoundFunctionStructure(vm, globalObject, targetFunction);
Modified: trunk/Source/_javascript_Core/runtime/JSCJSValue.h (260734 => 260735)
--- trunk/Source/_javascript_Core/runtime/JSCJSValue.h 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValue.h 2020-04-27 00:37:15 UTC (rev 260735)
@@ -235,7 +235,6 @@
bool isEmpty() const;
bool isFunction(VM&) const;
bool isConstructor(VM&) const;
- bool isConstructor(VM&, ConstructType&, ConstructData&) const;
bool isUndefined() const;
bool isNull() const;
bool isUndefinedOrNull() const;
Modified: trunk/Source/_javascript_Core/runtime/JSCJSValueInlines.h (260734 => 260735)
--- trunk/Source/_javascript_Core/runtime/JSCJSValueInlines.h 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/runtime/JSCJSValueInlines.h 2020-04-27 00:37:15 UTC (rev 260735)
@@ -889,13 +889,6 @@
return asCell()->isConstructor(vm);
}
-inline bool JSValue::isConstructor(VM& vm, ConstructType& constructType, ConstructData& constructData) const
-{
- if (!isCell())
- return false;
- return asCell()->isConstructor(vm, constructType, constructData);
-}
-
// this method is here to be after the inline declaration of JSCell::inherits
inline bool JSValue::inherits(VM& vm, const ClassInfo* classInfo) const
{
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (260734 => 260735)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2020-04-27 00:37:15 UTC (rev 260735)
@@ -109,7 +109,6 @@
bool isProxy() const;
bool isFunction(VM&);
bool isConstructor(VM&);
- bool isConstructor(VM&, ConstructType&, ConstructData&);
bool inherits(VM&, const ClassInfo*) const;
template<typename Target> bool inherits(VM&) const;
bool isAPIValueWrapper() const;
Modified: trunk/Source/_javascript_Core/runtime/JSCellInlines.h (260734 => 260735)
--- trunk/Source/_javascript_Core/runtime/JSCellInlines.h 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/runtime/JSCellInlines.h 2020-04-27 00:37:15 UTC (rev 260735)
@@ -242,17 +242,10 @@
inline bool JSCell::isConstructor(VM& vm)
{
- ConstructType constructType;
- ConstructData constructData;
- return isConstructor(vm, constructType, constructData);
+ ConstructData ignoredConstructData;
+ return methodTable(vm)->getConstructData(this, ignoredConstructData) != ConstructType::None;
}
-inline bool JSCell::isConstructor(VM& vm, ConstructType& constructType, ConstructData& constructData)
-{
- constructType = methodTable(vm)->getConstructData(this, constructData);
- return constructType != ConstructType::None;
-}
-
inline bool JSCell::isAPIValueWrapper() const
{
return m_type == APIValueWrapperType;
Modified: trunk/Source/_javascript_Core/runtime/ReflectObject.cpp (260734 => 260735)
--- trunk/Source/_javascript_Core/runtime/ReflectObject.cpp 2020-04-26 23:04:20 UTC (rev 260734)
+++ trunk/Source/_javascript_Core/runtime/ReflectObject.cpp 2020-04-27 00:37:15 UTC (rev 260735)
@@ -97,8 +97,8 @@
return JSValue::encode(throwTypeError(globalObject, scope, "Reflect.construct requires the first argument be a constructor"_s));
ConstructData constructData;
- ConstructType constructType;
- if (!target.isConstructor(vm, constructType, constructData))
+ ConstructType constructType = getConstructData(vm, target, constructData);
+ if (constructType == ConstructType::None)
return JSValue::encode(throwTypeError(globalObject, scope, "Reflect.construct requires the first argument be a constructor"_s));
JSValue newTarget = target;