Bug 211037 - [JSC] isCallable is redundant with isFunction
Summary: [JSC] isCallable is redundant with isFunction
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ross Kirsling
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-25 18:34 PDT by Ross Kirsling
Modified: 2020-04-28 12:29 PDT (History)
10 users (show)

See Also:


Attachments
Patch (12.13 KB, patch)
2020-04-25 18:42 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (12.13 KB, patch)
2020-04-25 20:07 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Kirsling 2020-04-25 18:34:53 PDT
[JSC] isCallable is redundant with isFunction
Comment 1 Ross Kirsling 2020-04-25 18:42:25 PDT
Created attachment 397603 [details]
Patch
Comment 2 Ross Kirsling 2020-04-25 20:07:19 PDT
Created attachment 397606 [details]
Patch
Comment 3 Yusuke Suzuki 2020-04-25 20:22:57 PDT
Comment on attachment 397606 [details]
Patch

r=me
Comment 4 EWS 2020-04-25 22:07:26 PDT
Committed r260722: <https://trac.webkit.org/changeset/260722>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397606 [details].
Comment 5 Radar WebKit Bug Importer 2020-04-25 22:08:14 PDT
<rdar://problem/62380487>
Comment 6 Darin Adler 2020-04-26 09:47:47 PDT
Two other thoughts:

1) Is there something analogous we should be doing with getConstructData?

2) Seems that getCallData could be changed to have a return value, instead of a return value plus two out arguments, and be renamed to callData. Could be more elegant and similar in performance, maybe better.
Comment 7 Alexey Shvayka 2020-04-26 11:16:39 PDT
(In reply to EWS from comment #4)
> Committed r260722: <https://trac.webkit.org/changeset/260722>

I really like this change, especially the usage of isFunction's fast path. Great job, Ross!
We might also want to use isFunction() in JSObjectIsFunction() of JSObjectRef.cpp.

(In reply to Darin Adler from comment #6)
> 2) Seems that getCallData could be changed to have a return value, instead
> of a return value plus two out arguments, and be renamed to callData. Could
> be more elegant and similar in performance, maybe better.

getCallData() seems to be nicely aligned with getConstructData(): they both return a value + one out argument.
However, isConstructor() has an overload which returns a value + two out arguments, with only one call site.
It would be nice to use getConstructData() instead.
Comment 8 Ross Kirsling 2020-04-26 13:42:28 PDT
I hadn't looked into getConstructData but I'll do so in a follow-up bug!

(In reply to Alexey Shvayka from comment #7)
> We might also want to use isFunction() in JSObjectIsFunction() of
> JSObjectRef.cpp.

Oops, yeah, that was an oversight on my part! Will add to the next patch.
Comment 9 Saam Barati 2020-04-28 09:12:31 PDT
Comment on attachment 397606 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397606&action=review

> Source/JavaScriptCore/ChangeLog:9
> +        Where CallData is needed, getCallData should be used; where CallData is not needed, isFunction should be used.

I’m not a fan of us having the “isFunction” name. I would’ve opted for isCallable everywhere. isFunction js ambiguous when I read it. E.g, Is it asking if it’s a JSFunction?

All JSFunctions are callable, not all callable objects are JSFunctions
Comment 10 Saam Barati 2020-04-28 09:14:12 PDT
(In reply to Saam Barati from comment #9)
> Comment on attachment 397606 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=397606&action=review
> 
> > Source/JavaScriptCore/ChangeLog:9
> > +        Where CallData is needed, getCallData should be used; where CallData is not needed, isFunction should be used.
> 
> I’m not a fan of us having the “isFunction” name. I would’ve opted for
> isCallable everywhere. isFunction js ambiguous when I read it. E.g, Is it
> asking if it’s a JSFunction?
> 
> All JSFunctions are callable, not all callable objects are JSFunctions

Oops, I meant “is ambiguous”, not “js ambiguous”
Comment 11 Darin Adler 2020-04-28 10:14:34 PDT
I suggest using do-webcore-rename to rename isFunction to isCallable. There’s very little else besides the isFunction in JavaScriptCore to collide so it should be largely mechanical.
Comment 12 Ross Kirsling 2020-04-28 12:09:05 PDT
Yeah, I agree with that renaming direction. On the plus side, it'll be easier now that everything's clear-cut. Will open a new ticket shortly.