Changeset 36282 in webkit for trunk/JavaScriptCore/VM/CTI.cpp


Ignore:
Timestamp:
Sep 8, 2008, 9:43:25 PM (17 years ago)
Author:
[email protected]
Message:

Fix codegen for slow script dialog.

Reviewed by Mark Rowe

Correct error in timeout logic where execution tick count would
be reset to incorrect value due to incorrect offset and indirection.
Codegen for the slow script dialog was factored out into a separate
method (emitSlowScriptCheck) rather than having multiple copies of
the same code. Also added calls to generate slow script checks
for loop_if_less and loop_if_true opcodes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CTI.cpp

    r36279 r36282  
    443443}
    444444
     445void CTI::emitSlowScriptCheck(unsigned opcodeIndex)
     446{
     447    m_jit.emitSubl_i8r(1, MacroAssembler::esi);
     448    MacroAssembler::JmpSrc skipTimeout = m_jit.emitUnlinkedJne();
     449    emitCall(opcodeIndex, Machine::cti_timeout_check);
     450
     451    emitGetCTIParam(CTI_ARGS_exec, MacroAssembler::ecx);
     452    m_jit.emitMovl_mr(OBJECT_OFFSET(ExecState, m_globalData), MacroAssembler::ecx, MacroAssembler::ecx);
     453    m_jit.emitMovl_mr(OBJECT_OFFSET(JSGlobalData, machine), MacroAssembler::ecx, MacroAssembler::ecx);
     454    m_jit.emitMovl_mr(OBJECT_OFFSET(Machine, m_ticksUntilNextTimeoutCheck), MacroAssembler::ecx, MacroAssembler::esi);
     455    m_jit.link(skipTimeout, m_jit.label());
     456}
     457
    445458void CTI::privateCompileMainPass()
    446459{
     
    530543        }
    531544        case op_loop: {
    532             m_jit.emitSubl_i8r(1, MacroAssembler::esi);
    533             MacroAssembler::JmpSrc skipTimeout = m_jit.emitUnlinkedJne();
    534             emitCall(i, Machine::cti_timeout_check);
    535 
    536             emitGetCTIParam(CTI_ARGS_exec, MacroAssembler::ecx);
    537             m_jit.emitMovl_mr(OBJECT_OFFSET(ExecState, m_globalData) + OBJECT_OFFSET(JSGlobalData, machine), MacroAssembler::ecx, MacroAssembler::ecx);
    538             m_jit.emitMovl_mr(OBJECT_OFFSET(Machine, m_ticksUntilNextTimeoutCheck), MacroAssembler::ecx, MacroAssembler::esi);
    539             m_jit.link(skipTimeout, m_jit.label());
     545            emitSlowScriptCheck(i);
    540546
    541547            unsigned target = instruction[i + 1].u.operand;
     
    545551        }
    546552        case op_loop_if_less: {
    547             m_jit.emitSubl_i8r(1, MacroAssembler::esi);
    548             MacroAssembler::JmpSrc skipTimeout = m_jit.emitUnlinkedJne();
    549             emitCall(i, Machine::cti_timeout_check);
    550 
    551             emitGetCTIParam(CTI_ARGS_exec, MacroAssembler::ecx);
    552             m_jit.emitMovl_mr(OBJECT_OFFSET(ExecState, m_globalData) + OBJECT_OFFSET(JSGlobalData, machine), MacroAssembler::ecx, MacroAssembler::ecx);
    553             m_jit.emitMovl_mr(OBJECT_OFFSET(Machine, m_ticksUntilNextTimeoutCheck), MacroAssembler::ecx, MacroAssembler::esi);
    554             m_jit.link(skipTimeout, m_jit.label());
     553            emitSlowScriptCheck(i);
    555554
    556555            unsigned target = instruction[i + 3].u.operand;
     
    750749        CTI_COMPILE_BINARY_OP(op_lesseq)
    751750        case op_loop_if_true: {
    752             m_jit.emitSubl_i8r(1, MacroAssembler::esi);
    753             MacroAssembler::JmpSrc skipTimeout = m_jit.emitUnlinkedJne();
    754             emitCall(i, Machine::cti_timeout_check);
    755 
    756             emitGetCTIParam(CTI_ARGS_exec, MacroAssembler::ecx);
    757             m_jit.emitMovl_mr(OBJECT_OFFSET(ExecState, m_globalData) + OBJECT_OFFSET(JSGlobalData, machine), MacroAssembler::ecx, MacroAssembler::ecx);
    758             m_jit.emitMovl_mr(OBJECT_OFFSET(Machine, m_ticksUntilNextTimeoutCheck), MacroAssembler::ecx, MacroAssembler::esi);
    759             m_jit.link(skipTimeout, m_jit.label());
     751            emitSlowScriptCheck(i);
    760752
    761753            unsigned target = instruction[i + 2].u.operand;
     
    13711363        }
    13721364        case op_loop_if_less: {
     1365            emitSlowScriptCheck(i);
     1366
    13731367            unsigned target = instruction[i + 3].u.operand;
    13741368            JSValue* src2imm = getConstantImmediateNumericArg(instruction[i + 2].u.operand);
     
    14191413        }
    14201414        case op_loop_if_true: {
     1415            emitSlowScriptCheck(i);
     1416
    14211417            m_jit.link(iter->from, m_jit.label());
    14221418            emitPutArg(MacroAssembler::eax, 0);
Note: See TracChangeset for help on using the changeset viewer.