Bug 193031

Summary: [JSC] Optimize Object.prototype.toString
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 193037    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Archive of layout-test-results from ews114 for mac-sierra
none
Patch
none
Archive of layout-test-results from ews114 for mac-sierra
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch saam: review+

Description Yusuke Suzuki 2018-12-24 23:46:22 PST
[JSC] Optimize Object.prototype.toString
Comment 1 Yusuke Suzuki 2018-12-24 23:46:54 PST
Created attachment 358056 [details]
Patch
Comment 2 Yusuke Suzuki 2018-12-24 23:56:45 PST
Created attachment 358057 [details]
Patch
Comment 3 Yusuke Suzuki 2018-12-24 23:58:59 PST
Created attachment 358058 [details]
Patch
Comment 4 Yusuke Suzuki 2018-12-25 00:24:31 PST
Created attachment 358060 [details]
Patch
Comment 5 EWS Watchlist 2018-12-25 02:36:24 PST
Comment on attachment 358060 [details]
Patch

Attachment 358060 [details] did not pass mac-debug-ews (mac):
Output: https://webkit-queues.webkit.org/results/10541563

New failing tests:
media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-until-play.html
Comment 6 EWS Watchlist 2018-12-25 02:36:26 PST
Created attachment 358062 [details]
Archive of layout-test-results from ews114 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 7 Yusuke Suzuki 2018-12-26 06:36:57 PST
Created attachment 358078 [details]
Patch
Comment 8 EWS Watchlist 2018-12-26 09:24:00 PST
Comment on attachment 358078 [details]
Patch

Attachment 358078 [details] did not pass mac-debug-ews (mac):
Output: https://webkit-queues.webkit.org/results/10551775

New failing tests:
media/modern-media-controls/airplay-support/airplay-support-disable-event-listeners-until-play.html
Comment 9 EWS Watchlist 2018-12-26 09:24:02 PST
Created attachment 358080 [details]
Archive of layout-test-results from ews114 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 10 Yusuke Suzuki 2018-12-27 05:34:38 PST
Created attachment 358110 [details]
Patch
Comment 11 Yusuke Suzuki 2018-12-27 05:39:37 PST
Created attachment 358111 [details]
Patch
Comment 12 Keith Miller 2018-12-31 15:55:07 PST
Comment on attachment 358111 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:9
> +        It is called so many times in wtb-lebab.js. This patch optimizes

Did you mean to say more in this sentence? If not, I would get rid of the "so" and make this: "It is called many times in wtb-lebab.js, for instance"

> Source/JavaScriptCore/ChangeLog:12
> +        1. We should emit code looking up cached one in DFG and FTL.

Nit: cached one => a cached result.

> Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:12473
> +        auto isUndefined = m_jit.branchIfUndefined(sourceRegs);
> +        m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), m_jit.vm()->smallStrings.nullObjectString()), resultGPR);
> +        auto done = m_jit.jump();
> +        isUndefined.link(&m_jit);
> +        m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), m_jit.vm()->smallStrings.undefinedObjectString()), resultGPR);
> +        done.link(&m_jit);

Don't you need a case here for booleans? If so, can you add a test?

> Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:6449
> +            LBasicBlock undefinedCase = m_out.newBlock();
> +            LBasicBlock nullCase = m_out.newBlock();
> +            LBasicBlock continuation = m_out.newBlock();
> +
> +            speculate(m_node->child1());
> +            LValue source = lowJSValue(m_node->child1(), ManualOperandSpeculation);
> +            LValue valueIsUndefined = m_out.equal(source, m_out.constInt64(ValueUndefined));
> +            m_out.branch(valueIsUndefined, unsure(undefinedCase), unsure(nullCase));
> +
> +            LBasicBlock lastNext = m_out.appendTo(undefinedCase, nullCase);
> +            ValueFromBlock undefinedString = m_out.anchor(weakPointer(vm().smallStrings.undefinedObjectString()));
> +            m_out.jump(continuation);
> +
> +            m_out.appendTo(nullCase, continuation);
> +            ValueFromBlock nullString = m_out.anchor(weakPointer(vm().smallStrings.nullObjectString()));
> +            m_out.jump(continuation);
> +
> +            m_out.appendTo(continuation, lastNext);
> +            setJSValue(m_out.phi(pointerType(), undefinedString, nullString));
> +            return;

Ditto on the boolean here.
Comment 13 Yusuke Suzuki 2018-12-31 18:35:31 PST
Comment on attachment 358111 [details]
Patch

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

>> Source/JavaScriptCore/ChangeLog:9
>> +        It is called so many times in wtb-lebab.js. This patch optimizes
> 
> Did you mean to say more in this sentence? If not, I would get rid of the "so" and make this: "It is called many times in wtb-lebab.js, for instance"

Yeah, fixed by dropping `so`.

>> Source/JavaScriptCore/ChangeLog:12
>> +        1. We should emit code looking up cached one in DFG and FTL.
> 
> Nit: cached one => a cached result.

Nice. Fixed.

>> Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:12473
>> +        done.link(&m_jit);
> 
> Don't you need a case here for booleans? If so, can you add a test?

Oops, fixed to use OtherUse and SpecOther. Misc is not right.

>> Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:6449
>> +            return;
> 
> Ditto on the boolean here.

Fixed.
Comment 14 Yusuke Suzuki 2018-12-31 22:47:33 PST
Created attachment 358166 [details]
Patch
Comment 15 Yusuke Suzuki 2019-01-02 15:10:54 PST
Created attachment 358211 [details]
Patch
Comment 16 Yusuke Suzuki 2019-01-02 15:17:23 PST
Created attachment 358214 [details]
Patch
Comment 17 Yusuke Suzuki 2019-01-03 17:18:48 PST
Ping?
Comment 18 Saam Barati 2019-01-04 08:58:00 PST
Comment on attachment 358214 [details]
Patch

r=me
Comment 19 Saam Barati 2019-01-04 09:00:11 PST
Comment on attachment 358214 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:12
> +        1. We should emit code looking up cached one in DFG and FTL.

cached one => cached to string
Comment 20 Yusuke Suzuki 2019-01-04 09:02:39 PST
Comment on attachment 358214 [details]
Patch

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

Thank you!

>> Source/JavaScriptCore/ChangeLog:12
>> +        1. We should emit code looking up cached one in DFG and FTL.
> 
> cached one => cached to string

Oops, fixed.
Comment 21 Yusuke Suzuki 2019-01-04 09:04:13 PST
Committed r239612: <https://trac.webkit.org/changeset/239612>
Comment 22 Radar WebKit Bug Importer 2019-01-04 09:05:34 PST
<rdar://problem/47049168>