Bug 168685 - Implement a mega-disassembler that'll be used in the FTL
Summary: Implement a mega-disassembler that'll be used in the FTL
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-21 15:52 PST by Saam Barati
Modified: 2017-03-01 11:16 PST (History)
11 users (show)

See Also:


Attachments
patch (16.37 KB, patch)
2017-02-28 17:37 PST, Saam Barati
no flags Details | Formatted Diff | Diff
patch (16.37 KB, patch)
2017-02-28 17:41 PST, Saam Barati
mark.lam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2017-02-21 15:52:10 PST
Here is Phil's rough sketch:
```
Say we have:

function foo(a, b) { return a + b; }

And say that it translates to this BC:

[   0] op_enter
[   1] op_add loc0, arg0, arg1
[   6] op_ret

And say that it's all predicted ints without overflows.

So here's the megadisasm:


                0x100000000  pushq %ebp
                 ... prologue
    0: JSConstant(...)
    1: JSConstant(...)
    ... more prologue
[   0] op_enter
    0: JSConstant(...)
    MovHint(...)
    ... more DFG prologue
[   1] op_add loc0, arg0, arg1
    2: GetStack(arg0)
        Int32 @42 = Load(@13, stuff)
            Move stuff(%rbp), %things
                movl stuff(%rbp), %things
    3: GetStack(arg1)
        Int32 @43 = Load(@13, otherstuff)
            Move otherstuff(%rbp), %otherthings
                movl otherstuff(%rbp), %otherthings
    4: ArithAdd(Int32: @2, Int32:@3)
        Int32 @44 = CheckAdd(@2, @3, ...)
            Patch &BranchAdd32, ...
                addl ...
                jo ...
... and so on
```

This would be super cool.
Comment 1 Saam Barati 2017-02-28 17:37:40 PST
Created attachment 303016 [details]
patch
Comment 2 Saam Barati 2017-02-28 17:41:25 PST
Created attachment 303018 [details]
patch

Change a variable name.
Comment 3 WebKit Commit Bot 2017-02-28 17:44:19 PST
Attachment 303018 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/ChangeLog:20:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:23:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:27:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:37:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:41:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:45:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:49:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:53:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:63:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:69:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:78:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ChangeLog:84:  Line contains tab character.  [whitespace/tab] [5]
ERROR: Source/JavaScriptCore/ftl/FTLCompile.cpp:35:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Source/JavaScriptCore/ftl/FTLCompile.cpp:190:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 14 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Saam Barati 2017-02-28 20:41:45 PST
Will fix style before landing.
Comment 5 Mark Lam 2017-03-01 09:47:58 PST
Comment on attachment 303018 [details]
patch

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

LGTM

> Source/JavaScriptCore/b3/air/AirDisassembler.h:53
> +    void dump(Code&, PrintStream&, LinkBuffer&, const char*, const char*, std::function<void(Inst&)> doToEachInst);

nit: I think it's worth const char* airPrefix, const char* asmPrefix in the args because it's not obvious from the type alone what the purpose of the args are.
Comment 6 Saam Barati 2017-03-01 11:16:00 PST
landed in:
https://trac.webkit.org/changeset/213233