⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244058 in webkit


Ignore:
Timestamp:
Apr 8, 2019, 5:00:24 PM (7 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] isRope jump in StringSlice should not jump over register allocations
https://bugs.webkit.org/show_bug.cgi?id=196716

Reviewed by Saam Barati.

JSTests:

  • stress/is-rope-check-in-string-slice-should-not-jump-over-register-allocations.js: Added.

(foo.bar):
(foo):

Source/JavaScriptCore:

Jumping over the register allocation code in DFG (like the following) is wrong.

auto jump = m_jit.branchXXX();
{

GPRTemporary reg(this);
GPRReg regGPR = reg.gpr();
...

}
jump.link(&m_jit);

When GPRTemporary::gpr allocates a new register, it can flush the previous register value into the stack and make the register usable.
Jumping over this register allocation code skips the flushing code, and makes the DFG's stack and register content tracking inconsistent:
DFG thinks that the content is flushed and stored in particular stack slot even while this flushing code is skipped.
In this patch, we perform register allocations before jumping to the slow path based on isRope condition in StringSlice.

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileStringSlice):

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r244057 r244058  
     12019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] isRope jump in StringSlice should not jump over register allocations
     4        https://bugs.webkit.org/show_bug.cgi?id=196716
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/is-rope-check-in-string-slice-should-not-jump-over-register-allocations.js: Added.
     9        (foo.bar):
     10        (foo):
     11
    1122019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r244057 r244058  
     12019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] isRope jump in StringSlice should not jump over register allocations
     4        https://bugs.webkit.org/show_bug.cgi?id=196716
     5
     6        Reviewed by Saam Barati.
     7
     8        Jumping over the register allocation code in DFG (like the following) is wrong.
     9
     10            auto jump = m_jit.branchXXX();
     11            {
     12                GPRTemporary reg(this);
     13                GPRReg regGPR = reg.gpr();
     14                ...
     15            }
     16            jump.link(&m_jit);
     17
     18        When GPRTemporary::gpr allocates a new register, it can flush the previous register value into the stack and make the register usable.
     19        Jumping over this register allocation code skips the flushing code, and makes the DFG's stack and register content tracking inconsistent:
     20        DFG thinks that the content is flushed and stored in particular stack slot even while this flushing code is skipped.
     21        In this patch, we perform register allocations before jumping to the slow path based on `isRope` condition in StringSlice.
     22
     23        * dfg/DFGSpeculativeJIT.cpp:
     24        (JSC::DFG::SpeculativeJIT::compileStringSlice):
     25
    1262019-04-08  Yusuke Suzuki  <ysuzuki@apple.com>
    227
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r243959 r244058  
    15481548
    15491549    GPRTemporary temp(this);
     1550    GPRTemporary temp2(this);
     1551    GPRTemporary startIndex(this);
     1552
    15501553    GPRReg tempGPR = temp.gpr();
     1554    GPRReg temp2GPR = temp2.gpr();
     1555    GPRReg startIndexGPR = startIndex.gpr();
    15511556
    15521557    m_jit.loadPtr(CCallHelpers::Address(stringGPR, JSString::offsetOfValue()), tempGPR);
    15531558    auto isRope = m_jit.branchIfRopeStringImpl(tempGPR);
    1554 
    1555     GPRTemporary temp2(this);
    1556     GPRTemporary startIndex(this);
    1557 
    1558     GPRReg temp2GPR = temp2.gpr();
    1559     GPRReg startIndexGPR = startIndex.gpr();
    15601559    {
    15611560        m_jit.load32(MacroAssembler::Address(tempGPR, StringImpl::lengthMemoryOffset()), temp2GPR);
Note: See TracChangeset for help on using the changeset viewer.