RESOLVED FIXED 156593
AffectsNextSibling style relation marking is inefficient
https://bugs.webkit.org/show_bug.cgi?id=156593
Summary AffectsNextSibling style relation marking is inefficient
Antti Koivisto
Reported 2016-04-14 13:42:40 PDT
We add a StyleRelation entry for each sibling to mark. With long sibling lists this can be inefficient in terms of both memory and speed. Instead make a single entry that includes the sibling count to mark.
Attachments
patch (9.02 KB, patch)
2016-04-14 13:52 PDT, Antti Koivisto
no flags
patch (10.09 KB, patch)
2016-04-14 14:12 PDT, Antti Koivisto
benjamin: review+
patch (9.84 KB, patch)
2016-04-15 00:07 PDT, Antti Koivisto
no flags
Antti Koivisto
Comment 1 2016-04-14 13:52:47 PDT
Antti Koivisto
Comment 2 2016-04-14 14:12:25 PDT
Radar WebKit Bug Importer
Comment 3 2016-04-14 14:38:10 PDT
Benjamin Poulain
Comment 4 2016-04-14 14:46:45 PDT
Comment on attachment 276426 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=276426&action=review > Source/WebCore/css/SelectorChecker.cpp:94 > + if (last.type == Style::Relation::AffectsNextSibling && last.element->previousElementSibling() == &element) { It would likely be better to do: element ->nextElementSibling() == last.element to avoid touching the memory of last.element again. > Source/WebCore/cssjit/SelectorCompiler.cpp:2214 > + LocalRegister lastRelation(m_registerAllocator); > + m_assembler.load32(sizeAddress, lastRelation); It would be better to have this load above the mergeFailure above. Currently the CPU will have to do two loads: 1) m_assembler.branchTest32(Assembler::Zero, sizeAddress) 2) m_assembler.load32(sizeAddress, lastRelation); If you write: LocalRegister size(m_registerAllocator); m_assembler.load32(sizeAddress, size); mergeFailure.append(m_assembler.branchTest32(Assembler::Zero, size)); m_assembler.sub32(Assembler::TrustedImm32(1), size); ... Then you only need one load. > Source/WebCore/cssjit/SelectorCompiler.cpp:2237 > + m_assembler.load32(valueAddress, value); > + m_assembler.add32(Assembler::TrustedImm32(1), value); > + m_assembler.store32(value, valueAddress); If you want you can do m_assembler.add32(Assembler::TrustedImm32(1), valueAddress); That's one instruction on x86. On ARM it generates the same code as you wrote.
Antti Koivisto
Comment 5 2016-04-15 00:07:15 PDT
Antti Koivisto
Comment 6 2016-04-15 00:42:15 PDT
> It would likely be better to do: > element ->nextElementSibling() == last.element > to avoid touching the memory of last.element again. Good idea. Did this also on the compiler path.
Antti Koivisto
Comment 7 2016-04-15 00:56:09 PDT
Note You need to log in before you can comment on or make changes to this bug.