Bug 133426 - [ftlopt] DFG should use its own notion of JSValue, which we should call FrozenValue, that will carry around a copy of its structure
Summary: [ftlopt] DFG should use its own notion of JSValue, which we should call Froze...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on: 128073 133624
Blocks: 136055
  Show dependency treegraph
 
Reported: 2014-05-31 14:17 PDT by Filip Pizlo
Modified: 2014-08-18 17:53 PDT (History)
7 users (show)

See Also:


Attachments
it begins! (13.53 KB, patch)
2014-05-31 14:27 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
more (51.53 KB, patch)
2014-05-31 17:51 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
more! (101.35 KB, patch)
2014-06-04 12:38 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
more!! (106.54 KB, patch)
2014-06-04 14:57 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
just a tiny bit more (141.44 KB, patch)
2014-06-04 16:38 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
it compiles! (153.10 KB, patch)
2014-06-06 21:54 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
passes tests (182.06 KB, patch)
2014-06-07 12:27 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (195.30 KB, patch)
2014-06-10 11:31 PDT, Filip Pizlo
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2014-05-31 14:17:22 PDT
...
Comment 1 Filip Pizlo 2014-05-31 14:27:49 PDT
Created attachment 232322 [details]
it begins!
Comment 2 Filip Pizlo 2014-05-31 17:51:57 PDT
Created attachment 232328 [details]
more
Comment 3 Filip Pizlo 2014-05-31 23:11:08 PDT
I initially started working on this because I believed that it would be absolutely necessary for making eager watchable structure watching sound.  I no longer believe it's needed for soundness, but it is worth pursuing anyway because it'll make debugging the DFG a lot easier.

This isn't needed for soundness so long as we always try to watch the structures of constants as soon as they are introduced into the abstract interpreter, inside of AbstractValue::set().  It's of course possible for weirdness:

- The value could start with an unwatchable structure and then transition to a watchable structure. Fortunately, we will assume that the structure is TOP if it is unwatchable.  So, this would mean that during the same abstract interpretation cycle, we will still believe that the structure is TOP.  In future cycles, we may believe that the structure is more specific, but that's OK - it's always fine to continue optimizing code.

- The value could start with some watchable structure and then it transitions to another watchable structure.  This would mean that the first structure's watchpoint would have gotten fired, and the code would get invalidated before installation anyway.

Of course, this may be all fine and good, but it's confusing as heck.  Any bugs in this would be impossible to debug because of the race conditions involved.  So, it's just a whole lot easier lock in the structure of every value we see.
Comment 4 Oliver Hunt 2014-06-01 11:38:11 PDT
Comment on attachment 232328 [details]
more

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

Wow, i really like this.  I also really like the amount of red :)

> Source/JavaScriptCore/runtime/JSCJSValue.cpp:195
> +        out, context, (!!*this && isCell()) ? asCell()->structure() : nullptr);

Our normal approach is to add that awful operator <functionptr madness>() const so that you'd only need *this && isCell(), which i think would look nicer here.
Comment 5 Filip Pizlo 2014-06-01 11:39:47 PDT
(In reply to comment #4)
> (From update of attachment 232328 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=232328&action=review
> 
> Wow, i really like this.  I also really like the amount of red :)
> 
> > Source/JavaScriptCore/runtime/JSCJSValue.cpp:195
> > +        out, context, (!!*this && isCell()) ? asCell()->structure() : nullptr);
> 
> Our normal approach is to add that awful operator <functionptr madness>() const so that you'd only need *this && isCell(), which i think would look nicer here.

Right, exactly, madness.  That's why I didn't add it.  Not-madness is better than madness.
Comment 6 Filip Pizlo 2014-06-04 12:38:44 PDT
Created attachment 232492 [details]
more!
Comment 7 Filip Pizlo 2014-06-04 14:57:35 PDT
Created attachment 232504 [details]
more!!
Comment 8 Filip Pizlo 2014-06-04 16:38:30 PDT
Created attachment 232508 [details]
just a tiny bit more

This is going to be such a surgical and incremental change.
Comment 9 Filip Pizlo 2014-06-06 21:54:12 PDT
Created attachment 232654 [details]
it compiles!
Comment 10 Filip Pizlo 2014-06-07 12:27:55 PDT
Created attachment 232666 [details]
passes tests

I still need to make sure that I didn't break performance.
Comment 11 Filip Pizlo 2014-06-10 11:31:48 PDT
Created attachment 232798 [details]
the patch

Note that the change to Structure::dfgShouldWatch() is going to be landed separately: https://bugs.webkit.org/show_bug.cgi?id=133624
Comment 12 Geoffrey Garen 2014-06-10 13:45:32 PDT
Comment on attachment 232798 [details]
the patch

r=me
Comment 13 Filip Pizlo 2014-06-10 21:53:42 PDT
Landed in http://trac.webkit.org/changeset/169795