Ignore:
Timestamp:
Oct 7, 2019, 4:34:01 PM (6 years ago)
Author:
[email protected]
Message:

Allow OSR exit to the LLInt
https://bugs.webkit.org/show_bug.cgi?id=197993

Reviewed by Tadeu Zagallo.

JSTests:

  • stress/exit-from-getter-by-val.js: Added.
  • stress/exit-from-setter-by-val.js: Added.

Source/JavaScriptCore:

This patch makes it so we can OSR exit to the LLInt.
Here are the interesting implementation details:

  1. We no longer baseline compile everything in the inline stack.
  1. When the top frame is a LLInt frame, we exit to the corresponding

LLInt bytecode. However, we need to materialize the LLInt registers
for PC, PB, and metadata.

  1. When dealing with inline call frames where the caller is LLInt, we

need to return to the appropriate place. Let's consider we're exiting
at a place A->B (A calls B), where A is LLInt. If A is a normal call,
we place the return PC in the frame we materialize to B to be right
after the LLInt's inline cache for calls. If A is a varargs call, we place
it at the return location for vararg calls. The interesting scenario here
is where A is a getter/setter. This means that A might be get_by_id,
get_by_val, put_by_id, or put_by_val. Since the LLInt does not have any
form of IC for getters/setters, we make this work by creating new LLInt
"return location" stubs for these opcodes.

  1. We need to update what callee saves we store in the callee if the caller frame

is a LLInt frame. Let's consider an inline stack A->B->C, where A is a LLInt frame.
When we materialize the stack frame for B, we need to ensure that the LLInt callee
saves that A uses is stored into B's preserved callee saves. Specifically, this
is just the PB/metadata registers.

This patch also fixes offlineasm's macro expansion to allow us to
use computed label names for global labels.

In a future bug, I'm going to investigate some kind of control system for
throwing away baseline code when we tier up:
https://bugs.webkit.org/show_bug.cgi?id=202503

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • bytecode/CodeBlock.h:

(JSC::CodeBlock::metadataTable):
(JSC::CodeBlock::instructionsRawPointer):

  • dfg/DFGOSRExit.cpp:

(JSC::DFG::OSRExit::executeOSRExit):
(JSC::DFG::reifyInlinedCallFrames):
(JSC::DFG::adjustAndJumpToTarget):
(JSC::DFG::OSRExit::compileOSRExit):

  • dfg/DFGOSRExit.h:

(JSC::DFG::OSRExitState::OSRExitState):

  • dfg/DFGOSRExitCompilerCommon.cpp:

(JSC::DFG::callerReturnPC):
(JSC::DFG::calleeSaveSlot):
(JSC::DFG::reifyInlinedCallFrames):
(JSC::DFG::adjustAndJumpToTarget):

  • dfg/DFGOSRExitCompilerCommon.h:
  • dfg/DFGOSRExitPreparation.cpp:

(JSC::DFG::prepareCodeOriginForOSRExit): Deleted.

  • dfg/DFGOSRExitPreparation.h:
  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileFTLOSRExit):

  • llint/LLIntData.h:

(JSC::LLInt::getCodePtr):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • offlineasm/asm.rb:
  • offlineasm/transform.rb:
  • runtime/OptionsList.h:

Tools:

  • Scripts/run-jsc-stress-tests:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r250803 r250806  
    13291329end)
    13301330
    1331 
    13321331llintOpWithMetadata(op_get_by_id, OpGetById, macro (size, get, dispatch, metadata, return)
    13331332    metadata(t2, t1)
     
    13801379    callSlowPath(_llint_slow_path_get_by_id)
    13811380    dispatch()
     1381
     1382.osrReturnPoint:
     1383    getterSetterOSRExitReturnPoint(op_get_by_id, size)
     1384    metadata(t2, t3)
     1385    valueProfile(OpGetById, t2, r0)
     1386    return(r0)
     1387
    13821388end)
    13831389
     
    14521458    callSlowPath(_llint_slow_path_put_by_id)
    14531459    dispatch()
     1460
     1461.osrReturnPoint:
     1462    getterSetterOSRExitReturnPoint(op_put_by_id, size)
     1463    dispatch()
     1464
    14541465end)
    14551466
     
    16231634    callSlowPath(_llint_slow_path_get_by_val)
    16241635    dispatch()
    1625 end)
    1626 
    1627 
    1628 macro putByValOp(opcodeName, opcodeStruct)
     1636
     1637.osrReturnPoint:
     1638    getterSetterOSRExitReturnPoint(op_get_by_val, size)
     1639    metadata(t5, t2)
     1640    valueProfile(OpGetByVal, t5, r0)
     1641    return(r0)
     1642
     1643end)
     1644
     1645
     1646macro putByValOp(opcodeName, opcodeStruct, osrExitPoint)
    16291647    llintOpWithMetadata(op_%opcodeName%, opcodeStruct, macro (size, get, dispatch, metadata, return)
    16301648        macro contiguousPutByVal(storeCallback)
     
    17141732        callSlowPath(_llint_slow_path_%opcodeName%)
    17151733        dispatch()
     1734
     1735        osrExitPoint(size, dispatch)
     1736       
    17161737    end)
    17171738end
    17181739
    1719 putByValOp(put_by_val, OpPutByVal)
    1720 
    1721 putByValOp(put_by_val_direct, OpPutByValDirect)
     1740putByValOp(put_by_val, OpPutByVal, macro (size, dispatch)
     1741.osrReturnPoint:
     1742    getterSetterOSRExitReturnPoint(op_put_by_val, size)
     1743    dispatch()
     1744end)
     1745
     1746putByValOp(put_by_val_direct, OpPutByValDirect, macro (a, b) end)
    17221747
    17231748
     
    20082033        move t3, sp
    20092034        prepareCall(%opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], t2, t3, t4, JSEntryPtrTag)
    2010         callTargetFunction(size, opcodeStruct, dispatch, %opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], JSEntryPtrTag)
     2035        callTargetFunction(opcodeName, size, opcodeStruct, dispatch, %opcodeStruct%::Metadata::m_callLinkInfo.m_machineCodeTarget[t5], JSEntryPtrTag)
    20112036
    20122037    .opCallSlow:
    2013         slowPathForCall(size, opcodeStruct, dispatch, slowPath, prepareCall)
     2038        slowPathForCall(opcodeName, size, opcodeStruct, dispatch, slowPath, prepareCall)
    20142039    end)
    20152040end
Note: See TracChangeset for help on using the changeset viewer.