Bug 151741 - [JSC] Add a function attribute for Pure functions in B3
Summary: [JSC] Add a function attribute for Pure functions in B3
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: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-02 01:13 PST by Benjamin Poulain
Modified: 2015-12-02 14:17 PST (History)
6 users (show)

See Also:


Attachments
Patch (3.50 KB, patch)
2015-12-02 01:16 PST, Benjamin Poulain
fpizlo: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2015-12-02 01:13:49 PST
[JSC] Add a function attribute for Pure functions in B3
Comment 1 Benjamin Poulain 2015-12-02 01:16:39 PST
Created attachment 266435 [details]
Patch
Comment 2 Geoffrey Garen 2015-12-02 11:17:28 PST
Comment on attachment 266435 [details]
Patch

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

r=me

> Source/JavaScriptCore/b3/B3CCallValue.h:38
> +    enum Pure { PureCall };

Usually we call this "enum PureCallTag { PureCall }".
Comment 3 Benjamin Poulain 2015-12-02 14:12:46 PST
Committed r192967: <http://trac.webkit.org/changeset/192967>
Comment 4 Filip Pizlo 2015-12-02 14:17:27 PST
Comment on attachment 266435 [details]
Patch

This doesn't belong here at all.  A pure function can be labeled by setting its Effects appropriately.  Also, I really hate the word "pure" since it has no precise meaning.  Do you mean that a call to the function with the same incoming values will yield the same result?  Do you also mean that the function has no hidden effects that cause it to require execution even if the result is unused?  Do you also mean that it will never read any memory, or can it still read some memory?

I created B3::Effects with the intent that it can answer all of these questions precisely:
- You can say that a function reads no memory.
- You can say that a function writes no memory.
- You can say that a function is not control-dependent.
- You can say that a function will not side-exit (for C functions a side-exit would be if it triggered unwinding - so this can always be cleared for all of the C functions we call).

The strongest purity guarantee is "any call to this function with the same arguments will yield the same result".  I believe that this guarantee can be expressed by saying that it does not read or write memory, does not have SSA effects, doesn't do any of the other things (control-dependent, side-exit, terminal).  My goal with CSE was to have pure CSE rules on calls and patchpoints that do this.

So, can we please roll this out?