Bug 136906 - CSS JIT: minimumRegisterRequirements() can be one register short for :nth-child()
Summary: CSS JIT: minimumRegisterRequirements() can be one register short for :nth-chi...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-09-17 21:11 PDT by Benjamin Poulain
Modified: 2014-09-18 17:38 PDT (History)
1 user (show)

See Also:


Attachments
Patch (5.05 KB, patch)
2014-09-17 21:17 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (5.05 KB, patch)
2014-09-17 23:37 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (6.09 KB, patch)
2014-09-18 00:57 PDT, Benjamin Poulain
darin: review+
benjamin: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2014-09-17 21:11:25 PDT
CSS JIT: The backtracking register can be ignored from the minimumRegisterRequirements
Comment 1 Benjamin Poulain 2014-09-17 21:17:55 PDT
Created attachment 238286 [details]
Patch
Comment 2 Benjamin Poulain 2014-09-17 21:19:51 PDT
Yusuke, could you please double check I am not missing any case?

I'll add more testing infrastructure tomorrow but I would like multiple reviews on this.
Comment 3 Benjamin Poulain 2014-09-17 21:20:06 PDT
rdar://problem/18368294
Comment 4 Yusuke Suzuki 2014-09-17 22:29:16 PDT
(In reply to comment #2)
> Yusuke, could you please double check I am not missing any case?
> 
> I'll add more testing infrastructure tomorrow but I would like multiple reviews on this.

Sure. I'll check it now :)
Comment 5 Yusuke Suzuki 2014-09-17 23:00:20 PDT
Comment on attachment 238286 [details]
Patch

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

Maybe I don't understand the issue's background enough, sorry, I can't see the rdar link...

If I understand this issue correctly, I think there's 2 meanings. Please point it :)

1.
When there's no :not, :-webkit-any or attributes, `backtrackingRegisterRequirements` is not added to the minimum requirements.

However, seeing the comment on `minimumRequiredRegisterCount`, it contains `BacktrackingRegister`. So I think that `BacktrackingRegister` count is already added, right?

2.
`BacktrackingRegister` count is always added to the minimum register requirements whenever it isn't used. I think this pointing is right. So to fix it,

1) changing `minimumRequiredRegisterCount` to 5, it doesn't contains `BacktrackingRegister`.
2) defining `minimum` as `minimumRequiredRegisterCount + backtrackingRegisterRequirements` after the `InChainWithDescendantTail` check. OR adding `backtrackingRegisterRequirements` to `minimum` inside the `InChainWithDescendantTail` check. (like your change!)

Is it correct?

> Source/WebCore/cssjit/SelectorCompiler.cpp:859
> +        minimum += minimumRequiredRegisterCount;

I think it would be `+= backtrackingRegisterRequirements`. Is it correct?
Comment 6 Benjamin Poulain 2014-09-17 23:36:38 PDT
Comment on attachment 238286 [details]
Patch

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

>> Source/WebCore/cssjit/SelectorCompiler.cpp:859
>> +        minimum += minimumRequiredRegisterCount;
> 
> I think it would be `+= backtrackingRegisterRequirements`. Is it correct?

Arg, ffs. I did a last minute change and I messed up the copy-paste.

I am glad I asked you for a review.
Comment 7 Benjamin Poulain 2014-09-17 23:37:57 PDT
Created attachment 238289 [details]
Patch
Comment 8 Benjamin Poulain 2014-09-17 23:43:17 PDT
You are right, this is wrong as you pointed out, minimumRequiredRegisterCount already account for the backtracking register.

Looks like :nth-child() uses 6 registers in some path then. I'll look into it and upload a new patch asap.
Comment 9 Benjamin Poulain 2014-09-18 00:57:10 PDT
Created attachment 238292 [details]
Patch
Comment 10 Benjamin Poulain 2014-09-18 00:58:33 PDT
Comment on attachment 238292 [details]
Patch

The patch is for the branches. ToT will get a different patch, I'll work that out tomorrow.

The test is for ToT and the branches.
Comment 11 Benjamin Poulain 2014-09-18 12:49:30 PDT
Committed r173730: <http://trac.webkit.org/changeset/173730>
Comment 12 Benjamin Poulain 2014-09-18 17:38:57 PDT
Closing:

Patch submitted in the branch.
Test submitted in ToT.

Added some code to catch such case earlier next time: https://bugs.webkit.org/show_bug.cgi?id=136933

ToT does not need the extra register. There are two patch of maximum allocation:
1) currentElement
2) elementCounter
3) previousSibling
4) elementRareData
5) cachedChildIndex
and
1) currentElement
2) elementCounter
3) checkingContext
4) childStyle
5) flags
6) isFirstChildStateFlagImmediate

The second path is safe for now because it is only executed on for the rightmost element. By definition, it cannot have a backtracking register.