Bug 88176 - If the DFG bytecode parser detects that op_method_check has gone polymorphic, it shouldn't revert all the way to GetById/GetByIdFlush
Summary: If the DFG bytecode parser detects that op_method_check has gone polymorphic,...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-02 15:55 PDT by Filip Pizlo
Modified: 2012-06-02 17:41 PDT (History)
0 users

See Also:


Attachments
the patch (6.87 KB, patch)
2012-06-02 16:03 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 2012-06-02 15:55:40 PDT
The DFG is capable of four levels of get_by_id optimization:

Fastest: CheckStructure to check if the object still has the right structure, and then WeakJSConstant for the result, if the structure specializes that field.
Fast: CheckStructure to check if the object still has the right structure, and then a GetByOffset.
Slow: GetById, which gets patched and is slightly speculated in favor of the access not causing arbitrary side-effects, in that it doesn't pre flush registers and thus requires getters to go through the slow path
Slowest: GetByIdFlush, which flushes all registers first and allows for any arbitrarily crazy access to happen using the fastest possible dynamically generated stub

When parsing code, the DFG sees two distinct kinds of get_by_id's: those that are preceded by method_check and those that aren't.  Currently for those that have method_check, the DFG first tries to generate the Fastest code, but if that fails (say due to slow path profiling indicating that it's a bad idea) then it reverts to Slow or Slowest.  The Fast mode is thus only available to get_by_id's that don't have a method_check.

This is an unusual and unnecessary restriction that is largely caused by the intelligence necessary to emit the Fast form only being present in the 'case op_get_by_id' part of the parser.  The code should be refactored so that the op_method_check case can gracefully fall through to op_get_by_id and be able to emit all of the optimizations that op_get_by_id would do.
Comment 1 Filip Pizlo 2012-06-02 16:03:49 PDT
Created attachment 145462 [details]
the patch
Comment 2 Geoffrey Garen 2012-06-02 16:09:04 PDT
Comment on attachment 145462 [details]
the patch

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

r=me

> Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:97
> +    // Handle get_by_id.

I don't think this comment adds anything.
Comment 3 Filip Pizlo 2012-06-02 16:09:52 PDT
(In reply to comment #2)
> (From update of attachment 145462 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=145462&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp:97
> > +    // Handle get_by_id.
> 
> I don't think this comment adds anything.

Nope, it sure doesn't.  Removed!

Thanks!
Comment 4 Filip Pizlo 2012-06-02 17:41:40 PDT
Landed in http://trac.webkit.org/changeset/119343