Changeset 36976 in webkit for trunk/JavaScriptCore/masm


Ignore:
Timestamp:
Sep 26, 2008, 6:44:15 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-26 Gavin Barraclough <[email protected]>

Reviewed by Maciej Stachowiak & Oliver Hunt.

Add support for reusing temporary JSNumberCells. This change is based on the observation
that if the result of certain operations is a JSNumberCell and is consumed by a subsequent
operation that would produce a JSNumberCell, we can reuse the object rather than allocating
a fresh one. E.g. given the expression ((a * b) * c), we can statically determine that
(a * b) will have a numeric result (or else it will have thrown an exception), so the result
will either be a JSNumberCell or a JSImmediate.

This patch changes three areas of JSC:

  • The AST now tracks type information about the result of each node.
  • This information is consumed in bytecode compilation, and certain bytecode operations now carry the statically determined type information about their operands.
  • CTI uses the information in a number of fashions:
    • Where an operand to certain arithmetic operations is reusable, it will plant code to try to perform the operation in JIT code & reuse the cell, where appropriate.
    • Where it can be statically determined that an operand can only be numeric (typically the result of another arithmetic operation) the code will not redundantly check that the JSCell is a JSNumberCell.
    • Where either of the operands to an add are non-numeric do not plant an optimized arithmetic code path, just call straight out to the C function.

+6% Sunspider (10% progression on 3D, 16% progression on math, 60% progression on access-nbody),
+1% v8-tests (improvements in raytrace & crypto)

  • VM/CTI.cpp: Add optimized code generation with reuse of temporary JSNumberCells.
  • VM/CTI.h:
  • kjs/JSNumberCell.h:
  • masm/X86Assembler.h:
  • VM/CodeBlock.cpp: Add type information to specific bytecodes.
  • VM/CodeGenerator.cpp:
  • VM/CodeGenerator.h:
  • VM/Machine.cpp:
  • kjs/nodes.cpp: Track static type information for nodes.
  • kjs/nodes.h:
  • kjs/ResultDescriptor.h: (Added)
  • JavaScriptCore.xcodeproj/project.pbxproj:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/masm/X86Assembler.h

    r36821 r36976  
    163163        noScale = esp,
    164164    } RegisterID;
     165
     166    typedef enum {
     167        xmm0,
     168        xmm1,
     169        xmm2,
     170        xmm3,
     171        xmm4,
     172        xmm5,
     173        xmm6,
     174        xmm7,
     175    } XMMRegisterID;
    165176}
    166177
     
    168179public:
    169180    typedef X86::RegisterID RegisterID;
    170 
     181    typedef X86::XMMRegisterID XMMRegisterID;
    171182    typedef enum {
    172183        OP_ADD_EvGv                     = 0x01,
     
    183194        OP_POP_EAX                      = 0x58,
    184195        PRE_OPERAND_SIZE                = 0x66,
     196        PRE_SSE_66                      = 0x66,
    185197        OP_IMUL_GvEvIz                  = 0x69,
    186198        OP_GROUP1_EvIz                  = 0x81,
     
    202214        OP_CALL_rel32                   = 0xE8,
    203215        OP_JMP_rel32                    = 0xE9,
     216        PRE_SSE_F2                      = 0xF2,
    204217        OP_GROUP3_Ev                    = 0xF7,
    205218        OP_GROUP3_EvIz                  = 0xF7, // OP_GROUP3_Ev has an immediate, when instruction is a test.
    206219        OP_GROUP5_Ev                    = 0xFF,
    207220
    208         OP2_JO_rel32    = 0x80,
    209         OP2_JB_rel32    = 0x82,
    210         OP2_JAE_rel32   = 0x83,
    211         OP2_JE_rel32    = 0x84,
    212         OP2_JNE_rel32   = 0x85,
    213         OP2_JBE_rel32   = 0x86,
    214         OP2_JA_rel32    = 0x87,
    215         OP2_JL_rel32    = 0x8C,
    216         OP2_JGE_rel32   = 0x8D,
    217         OP2_JLE_rel32   = 0x8E,
    218         OP2_IMUL_GvEv   = 0xAF,
    219         OP2_MOVZX_GvEb  = 0xB6,
    220         OP2_MOVZX_GvEw  = 0xB7,
     221        OP2_MOVSD_VsdWsd    = 0x10,
     222        OP2_MOVSD_WsdVsd    = 0x11,
     223        OP2_CVTSI2SD_VsdEd  = 0x2A,
     224        OP2_CVTTSD2SI_GdWsd = 0x2C,
     225        OP2_UCOMISD_VsdWsd  = 0x2E,
     226        OP2_ADDSD_VsdWsd    = 0x58,
     227        OP2_MULSD_VsdWsd    = 0x59,
     228        OP2_SUBSD_VsdWsd    = 0x5C,
     229        OP2_MOVD_EdVd       = 0x7E,
     230        OP2_JO_rel32        = 0x80,
     231        OP2_JB_rel32        = 0x82,
     232        OP2_JAE_rel32       = 0x83,
     233        OP2_JE_rel32        = 0x84,
     234        OP2_JNE_rel32       = 0x85,
     235        OP2_JBE_rel32       = 0x86,
     236        OP2_JA_rel32        = 0x87,
     237        OP2_JP_rel32        = 0x8A,
     238        OP2_JL_rel32        = 0x8C,
     239        OP2_JGE_rel32       = 0x8D,
     240        OP2_JLE_rel32       = 0x8E,
     241        OP2_IMUL_GvEv       = 0xAF,
     242        OP2_MOVZX_GvEb      = 0xB6,
     243        OP2_MOVZX_GvEw      = 0xB7,
     244        OP2_PEXTRW_GdUdIb   = 0xC5,
    221245
    222246        GROUP1_OP_ADD = 0,
     
    662686    }
    663687
     688    void leal_mr(int offset, RegisterID index, int scale, RegisterID dst)
     689    {
     690        m_buffer->putByte(OP_LEA);
     691        emitModRm_rmsib(dst, X86::noBase, index, scale, offset);
     692    }
     693
    664694    void ret()
    665695    {
     
    679709    }
    680710   
     711    void movsd_mr(int offset, RegisterID base, XMMRegisterID dst)
     712    {
     713        m_buffer->putByte(PRE_SSE_F2);
     714        m_buffer->putByte(OP_2BYTE_ESCAPE);
     715        m_buffer->putByte(OP2_MOVSD_VsdWsd);
     716        emitModRm_rm((RegisterID)dst, base, offset);
     717    }
     718
     719    void movsd_rm(XMMRegisterID src, int offset, RegisterID base)
     720    {
     721        m_buffer->putByte(PRE_SSE_F2);
     722        m_buffer->putByte(OP_2BYTE_ESCAPE);
     723        m_buffer->putByte(OP2_MOVSD_WsdVsd);
     724        emitModRm_rm((RegisterID)src, base, offset);
     725    }
     726
     727    void movd_rr(XMMRegisterID src, RegisterID dst)
     728    {
     729        m_buffer->putByte(PRE_SSE_66);
     730        m_buffer->putByte(OP_2BYTE_ESCAPE);
     731        m_buffer->putByte(OP2_MOVD_EdVd);
     732        emitModRm_rr((RegisterID)src, dst);
     733    }
     734
     735    void cvtsi2sd_rr(RegisterID src, XMMRegisterID dst)
     736    {
     737        m_buffer->putByte(PRE_SSE_F2);
     738        m_buffer->putByte(OP_2BYTE_ESCAPE);
     739        m_buffer->putByte(OP2_CVTSI2SD_VsdEd);
     740        emitModRm_rr((RegisterID)dst, src);
     741    }
     742
     743    void cvttsd2si_rr(XMMRegisterID src, RegisterID dst)
     744    {
     745        m_buffer->putByte(PRE_SSE_F2);
     746        m_buffer->putByte(OP_2BYTE_ESCAPE);
     747        m_buffer->putByte(OP2_CVTTSD2SI_GdWsd);
     748        emitModRm_rr(dst, (RegisterID)src);
     749    }
     750
     751    void addsd_mr(int offset, RegisterID base, XMMRegisterID dst)
     752    {
     753        m_buffer->putByte(PRE_SSE_F2);
     754        m_buffer->putByte(OP_2BYTE_ESCAPE);
     755        m_buffer->putByte(OP2_ADDSD_VsdWsd);
     756        emitModRm_rm((RegisterID)dst, base, offset);
     757    }
     758
     759    void subsd_mr(int offset, RegisterID base, XMMRegisterID dst)
     760    {
     761        m_buffer->putByte(PRE_SSE_F2);
     762        m_buffer->putByte(OP_2BYTE_ESCAPE);
     763        m_buffer->putByte(OP2_SUBSD_VsdWsd);
     764        emitModRm_rm((RegisterID)dst, base, offset);
     765    }
     766
     767    void mulsd_mr(int offset, RegisterID base, XMMRegisterID dst)
     768    {
     769        m_buffer->putByte(PRE_SSE_F2);
     770        m_buffer->putByte(OP_2BYTE_ESCAPE);
     771        m_buffer->putByte(OP2_MULSD_VsdWsd);
     772        emitModRm_rm((RegisterID)dst, base, offset);
     773    }
     774
     775    void addsd_rr(XMMRegisterID src, XMMRegisterID dst)
     776    {
     777        m_buffer->putByte(PRE_SSE_F2);
     778        m_buffer->putByte(OP_2BYTE_ESCAPE);
     779        m_buffer->putByte(OP2_ADDSD_VsdWsd);
     780        emitModRm_rr((RegisterID)dst, (RegisterID)src);
     781    }
     782
     783    void subsd_rr(XMMRegisterID src, XMMRegisterID dst)
     784    {
     785        m_buffer->putByte(PRE_SSE_F2);
     786        m_buffer->putByte(OP_2BYTE_ESCAPE);
     787        m_buffer->putByte(OP2_SUBSD_VsdWsd);
     788        emitModRm_rr((RegisterID)dst, (RegisterID)src);
     789    }
     790
     791    void mulsd_rr(XMMRegisterID src, XMMRegisterID dst)
     792    {
     793        m_buffer->putByte(PRE_SSE_F2);
     794        m_buffer->putByte(OP_2BYTE_ESCAPE);
     795        m_buffer->putByte(OP2_MULSD_VsdWsd);
     796        emitModRm_rr((RegisterID)dst, (RegisterID)src);
     797    }
     798
     799    void ucomis_rr(XMMRegisterID src, XMMRegisterID dst)
     800    {
     801        m_buffer->putByte(PRE_SSE_66);
     802        m_buffer->putByte(OP_2BYTE_ESCAPE);
     803        m_buffer->putByte(OP2_UCOMISD_VsdWsd);
     804        emitModRm_rr((RegisterID)dst, (RegisterID)src);
     805    }
     806
     807    void pextrw_irr(int whichWord, XMMRegisterID src, RegisterID dst)
     808    {
     809        m_buffer->putByte(PRE_SSE_66);
     810        m_buffer->putByte(OP_2BYTE_ESCAPE);
     811        m_buffer->putByte(OP2_PEXTRW_GdUdIb);
     812        emitModRm_rr(dst, (RegisterID)src);
     813        m_buffer->putByte(whichWord);
     814    }
     815
    681816    // Opaque label types
    682817   
     
    824959        m_buffer->putByte(OP_2BYTE_ESCAPE);
    825960        m_buffer->putByte(OP2_JO_rel32);
     961        m_buffer->putInt(0);
     962        return JmpSrc(m_buffer->getOffset());
     963    }
     964
     965    JmpSrc emitUnlinkedJp()
     966    {
     967        m_buffer->putByte(OP_2BYTE_ESCAPE);
     968        m_buffer->putByte(OP2_JP_rel32);
    826969        m_buffer->putInt(0);
    827970        return JmpSrc(m_buffer->getOffset());
Note: See TracChangeset for help on using the changeset viewer.