Bug 159700 - DFG should really support jneq_ptr
Summary: DFG should really support jneq_ptr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-12 19:12 PDT by Filip Pizlo
Modified: 2016-07-18 12:14 PDT (History)
5 users (show)

See Also:


Attachments
the patch (25.03 KB, patch)
2016-07-12 19:17 PDT, Filip Pizlo
keith_miller: review+
Details | Formatted Diff | Diff
patch for landing (25.55 KB, patch)
2016-07-12 20:10 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
performance (78.13 KB, text/plain)
2016-07-13 11:17 PDT, Filip Pizlo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2016-07-12 19:12:01 PDT
Patch forthcoming.
Comment 1 Filip Pizlo 2016-07-12 19:17:32 PDT
Created attachment 283485 [details]
the patch
Comment 2 Keith Miller 2016-07-12 19:30:16 PDT
Comment on attachment 283485 [details]
the patch

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

r=me with question.

> Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:8268
> +    m_jit.boxBooleanPayload(false, resultGPR);
> +    JITCompiler::JumpList notEqual = m_jit.branchIfNotEqual(regs, node->cellOperand()->value());
> +    m_jit.boxBooleanPayload(true, resultGPR);
> +    notEqual.link(&m_jit);

Is this more efficient than doing:

JITCompiler::JumpList notEqual = m_jit.branchIfNotEqual(regs, node->cellOperand()->value());
m_jit.boxBooleanPayload(true, resultGPR);
JITCompiler::Jump done = m_jit.jump();
notEqual.link(&m_jit);
m_jit.boxBooleanPayload(false, resultGPR);
done.link(&m_jit);
Comment 3 Filip Pizlo 2016-07-12 19:38:03 PDT
(In reply to comment #2)
> Comment on attachment 283485 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=283485&action=review
> 
> r=me with question.
> 
> > Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:8268
> > +    m_jit.boxBooleanPayload(false, resultGPR);
> > +    JITCompiler::JumpList notEqual = m_jit.branchIfNotEqual(regs, node->cellOperand()->value());
> > +    m_jit.boxBooleanPayload(true, resultGPR);
> > +    notEqual.link(&m_jit);
> 
> Is this more efficient than doing:
> 
> JITCompiler::JumpList notEqual = m_jit.branchIfNotEqual(regs,
> node->cellOperand()->value());
> m_jit.boxBooleanPayload(true, resultGPR);
> JITCompiler::Jump done = m_jit.jump();
> notEqual.link(&m_jit);
> m_jit.boxBooleanPayload(false, resultGPR);
> done.link(&m_jit);

I don't know!  I think that my version is better because:

- Moving zero into a register is basically free.
- Your version will do two branches in the worst case, while mine will do one.  One of your branches is a jump, which is cheap, but probably worse than zeroing a register.

My version also involves less code.  I like to err on the side of small code when everything else is up in the air.
Comment 4 Filip Pizlo 2016-07-12 19:51:33 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > Comment on attachment 283485 [details]
> > the patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=283485&action=review
> > 
> > r=me with question.
> > 
> > > Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:8268
> > > +    m_jit.boxBooleanPayload(false, resultGPR);
> > > +    JITCompiler::JumpList notEqual = m_jit.branchIfNotEqual(regs, node->cellOperand()->value());
> > > +    m_jit.boxBooleanPayload(true, resultGPR);
> > > +    notEqual.link(&m_jit);
> > 
> > Is this more efficient than doing:
> > 
> > JITCompiler::JumpList notEqual = m_jit.branchIfNotEqual(regs,
> > node->cellOperand()->value());
> > m_jit.boxBooleanPayload(true, resultGPR);
> > JITCompiler::Jump done = m_jit.jump();
> > notEqual.link(&m_jit);
> > m_jit.boxBooleanPayload(false, resultGPR);
> > done.link(&m_jit);
> 
> I don't know!  I think that my version is better because:
> 
> - Moving zero into a register is basically free.
> - Your version will do two branches in the worst case, while mine will do
> one.  One of your branches is a jump, which is cheap, but probably worse
> than zeroing a register.
> 
> My version also involves less code.  I like to err on the side of small code
> when everything else is up in the air.

Brainfart: I'm not moving zero into a register.  I guess the question is: do we care about this code being fast or small?  I like small a bit better, since if it really needs to be fast, it'll get to FTL.  DFG is for functions that don't run that much, so icache matters more.
Comment 5 Filip Pizlo 2016-07-12 20:10:04 PDT
Created attachment 283486 [details]
patch for landing
Comment 6 Filip Pizlo 2016-07-13 11:17:59 PDT
Created attachment 283549 [details]
performance

Looks pretty good!
Comment 7 Filip Pizlo 2016-07-18 12:14:17 PDT
Landed in https://trac.webkit.org/changeset/203361