Bug 204317 - [JSC] DFG terminal's liveness should respect caller's opcodeID
Summary: [JSC] DFG terminal's liveness should respect caller's opcodeID
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-11-18 14:28 PST by Yusuke Suzuki
Modified: 2019-11-22 11:55 PST (History)
7 users (show)

See Also:


Attachments
Patch (15.24 KB, patch)
2019-11-18 19:49 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (39.72 KB, patch)
2019-11-20 17:54 PST, Yusuke Suzuki
saam: review+
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews212 for win-future (14.96 MB, application/zip)
2019-11-20 19:58 PST, EWS Watchlist
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2019-11-18 14:28:21 PST
Let's consider the following example,

"use strict";

function assertImpl(cond)
{
    if (!cond)
        throw new Error();
}

function assert()
{
    assertImpl.apply(undefined, arguments);
}
noInline(assert);

When compiling `throw`, we emit a terminal and put Phantom/PhantomLocal based on the bytecode liveness.
At this point, we use `op_tail_call_varargs`'s bytecode index for the liveness in "assert" function. And this involves `arguments`.
But this is not necessary in fact.
Comment 1 Yusuke Suzuki 2019-11-18 14:46:45 PST
<rdar://problem/54857307>
Comment 2 Yusuke Suzuki 2019-11-18 19:49:34 PST
Created attachment 383835 [details]
Patch

It "works"...
Comment 3 Yusuke Suzuki 2019-11-19 15:30:43 PST
Talked with Saam and Phil, Let's introduce BeforeUse/AfterUse notation to bytecode liveness to avoid making some of them unnecessary live.
Add Comment
Comment 4 Yusuke Suzuki 2019-11-20 17:54:28 PST
Created attachment 384015 [details]
Patch
Comment 5 EWS Watchlist 2019-11-20 19:58:17 PST
Comment on attachment 384015 [details]
Patch

Attachment 384015 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/13270399

New failing tests:
imported/blink/fast/events/panScroll-crash.html
Comment 6 EWS Watchlist 2019-11-20 19:58:19 PST
Created attachment 384021 [details]
Archive of layout-test-results from ews212 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews212  Port: win-future  Platform: CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit
Comment 7 Yusuke Suzuki 2019-11-20 20:36:14 PST
(In reply to Build Bot from comment #6)
> Created attachment 384021 [details]
> Archive of layout-test-results from ews212 for win-future
> 
> The attached test failures were seen while running run-webkit-tests on the
> win-ews.
> Bot: ews212  Port: win-future  Platform:
> CYGWIN_NT-10.0-17763-3.0.5-338.x86_64-x86_64-64bit

Checked, but looks unrelated.
Comment 8 Saam Barati 2019-11-21 15:56:41 PST
Comment on attachment 384015 [details]
Patch

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

r=me

> Source/JavaScriptCore/ChangeLog:29
> +        in DFG, but this is wasting.

"wasting" => "wasteful". Maybe also say "because varargs forwarding phase could eliminate the allocation."

> Source/JavaScriptCore/ChangeLog:33
> +        is not profitable, and (2) we need to be careful to make stack arguments live to allow materialization of arguments objects.

why would (2) not Just Work? It seems more principled to apply this to all calls and see if there is any bug fallout. I don't see why we should special case varargs calls.

> Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h:43
> +// <- AfterUse
> +//     Use by exception handlers

nice!

> Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h:46
> +    BeforeUse = 0,

is = 0 needed for anything?

> Source/JavaScriptCore/dfg/DFGGraph.h:916
> +        InlineCallFrame* inlineCallFrame = origin.inlineCallFrame();
> +        CodeBlock* codeBlock = baselineCodeBlockFor(inlineCallFrame);
> +        auto instruction = codeBlock->instructions().at(bytecodeIndex.offset());

nit: if you keep this code, you should put it inside the "if".

However, I think the more robust thing is for all inlined things, we used BeforeUse.

> Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:94
> +# After calling, calling bytecode is claiming input registers are not used.

are these comments needed?
Comment 9 Yusuke Suzuki 2019-11-22 11:47:10 PST
Comment on attachment 384015 [details]
Patch

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

Thanks!

>> Source/JavaScriptCore/ChangeLog:29
>> +        in DFG, but this is wasting.
> 
> "wasting" => "wasteful". Maybe also say "because varargs forwarding phase could eliminate the allocation."

Fixed.

>> Source/JavaScriptCore/ChangeLog:33
>> +        is not profitable, and (2) we need to be careful to make stack arguments live to allow materialization of arguments objects.
> 
> why would (2) not Just Work? It seems more principled to apply this to all calls and see if there is any bug fallout. I don't see why we should special case varargs calls.

Talked with Saam. Maybe, doing for op_call is OK. But we did not verify that all callable bytecode uses are not used after the call (for example, getter inlining by op_get_by_id).
So, for now, we just do this only for op_call_varargs / op_tail_call_varargs b/c we verified that they are OK, and they are the only bytecodes which get benefit from this change.

>> Source/JavaScriptCore/bytecode/BytecodeLivenessAnalysis.h:46
>> +    BeforeUse = 0,
> 
> is = 0 needed for anything?

Not necessary. Removed.

>> Source/JavaScriptCore/dfg/DFGGraph.h:916
>> +        auto instruction = codeBlock->instructions().at(bytecodeIndex.offset());
> 
> nit: if you keep this code, you should put it inside the "if".
> 
> However, I think the more robust thing is for all inlined things, we used BeforeUse.

Talked with Saam. We need to ensure that bytecode does not use `uses` after inlining. And we ensured that this is true for these three bytecodes, but we do not verify it for the other bytecodes.
And if a new bytecode is introduced, we need to verify it. So this white-list is necessary.

>> Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:94
>> +# After calling, calling bytecode is claiming input registers are not used.
> 
> are these comments needed?

Ditto
Comment 10 Yusuke Suzuki 2019-11-22 11:55:37 PST
Committed r252789: <https://trac.webkit.org/changeset/252789>