Changeset 55684 in webkit


Ignore:
Timestamp:
Mar 8, 2010 2:45:22 PM (14 years ago)
Author:
oliver@apple.com
Message:

2010-03-07 Oliver Hunt <oliver@apple.com>

Reviewed by Darin Adler.

TypeInfo is unnecessarily large
https://bugs.webkit.org/show_bug.cgi?id=35850

Reduce the size of the type and flags members to a single
byte each, reducing the size of Structure by 8 bytes.

  • assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::branch8): (JSC::MacroAssemblerX86Common::branchTest8): (JSC::MacroAssemblerX86Common::setTest8): Add single byte branches, and correct setTest8 to do a single byte read from memory, and actually store the result
  • assembler/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::cmpb_im): (JSC::X86Assembler::testb_im):
  • jit/JITCall.cpp: (JSC::JIT::emit_op_construct_verify):
  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_instanceof): (JSC::JIT::emit_op_jeq_null): (JSC::JIT::emit_op_jneq_null): (JSC::JIT::emit_op_get_pnames): (JSC::JIT::emit_op_convert_this): (JSC::JIT::emit_op_construct_verify): (JSC::JIT::emit_op_to_jsnumber): (JSC::JIT::emit_op_eq_null): (JSC::JIT::emit_op_neq_null):
  • runtime/JSTypeInfo.h: (JSC::TypeInfo::TypeInfo): (JSC::TypeInfo::type):
Location:
trunk/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r55679 r55684  
     12010-03-07  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        TypeInfo is unnecessarily large
     6        https://bugs.webkit.org/show_bug.cgi?id=35850
     7
     8        Reduce the size of the type and flags members to a single
     9        byte each, reducing the size of Structure by 8 bytes.
     10
     11        * assembler/MacroAssemblerX86Common.h:
     12        (JSC::MacroAssemblerX86Common::branch8):
     13        (JSC::MacroAssemblerX86Common::branchTest8):
     14        (JSC::MacroAssemblerX86Common::setTest8):
     15          Add single byte branches, and correct setTest8 to do a
     16          single byte read from memory, and actually store the result
     17        * assembler/X86Assembler.h:
     18        (JSC::X86Assembler::):
     19        (JSC::X86Assembler::cmpb_im):
     20        (JSC::X86Assembler::testb_im):
     21        * jit/JITCall.cpp:
     22        (JSC::JIT::emit_op_construct_verify):
     23        * jit/JITOpcodes.cpp:
     24        (JSC::JIT::emit_op_instanceof):
     25        (JSC::JIT::emit_op_jeq_null):
     26        (JSC::JIT::emit_op_jneq_null):
     27        (JSC::JIT::emit_op_get_pnames):
     28        (JSC::JIT::emit_op_convert_this):
     29        (JSC::JIT::emit_op_construct_verify):
     30        (JSC::JIT::emit_op_to_jsnumber):
     31        (JSC::JIT::emit_op_eq_null):
     32        (JSC::JIT::emit_op_neq_null):
     33        * runtime/JSTypeInfo.h:
     34        (JSC::TypeInfo::TypeInfo):
     35        (JSC::TypeInfo::type):
     36
    1372010-03-08  Gavin Barraclough  <barraclough@apple.com>
    238
  • trunk/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r55633 r55684  
    619619
    620620public:
     621    Jump branch8(Condition cond, Address left, Imm32 right)
     622    {
     623        m_assembler.cmpb_im(right.m_value, left.offset, left.base);
     624        return Jump(m_assembler.jCC(x86Condition(cond)));
     625    }
     626
    621627    Jump branch32(Condition cond, RegisterID left, RegisterID right)
    622628    {
     
    714720        else
    715721            m_assembler.testl_i32m(mask.m_value, address.offset, address.base, address.index, address.scale);
     722        return Jump(m_assembler.jCC(x86Condition(cond)));
     723    }
     724   
     725    Jump branchTest8(Condition cond, Address address, Imm32 mask = Imm32(-1))
     726    {
     727        ASSERT((cond == Zero) || (cond == NonZero));
     728        if (mask.m_value == -1)
     729            m_assembler.cmpb_im(0, address.offset, address.base);
     730        else
     731            m_assembler.testb_im(mask.m_value, address.offset, address.base);
    716732        return Jump(m_assembler.jCC(x86Condition(cond)));
    717733    }
     
    916932    {
    917933        if (mask.m_value == -1)
    918             m_assembler.cmpl_im(0, address.offset, address.base);
     934            m_assembler.cmpb_im(0, address.offset, address.base);
    919935        else
    920             m_assembler.testl_i32m(mask.m_value, address.offset, address.base);
     936            m_assembler.testb_im(mask.m_value, address.offset, address.base);
    921937        m_assembler.setCC_r(x86Condition(cond), dest);
     938        m_assembler.movzbl_rr(dest, dest);
    922939    }
    923940
  • trunk/JavaScriptCore/assembler/X86Assembler.h

    r55633 r55684  
    129129        OP_PUSH_Iz                      = 0x68,
    130130        OP_IMUL_GvEvIz                  = 0x69,
     131        OP_GROUP1_EbIb                  = 0x80,
    131132        OP_GROUP1_EvIz                  = 0x81,
    132133        OP_GROUP1_EvIb                  = 0x83,
     
    759760        m_formatter.immediate32(imm);
    760761    }
    761 
     762   
    762763    void cmpl_im(int imm, int offset, RegisterID base)
    763764    {
     
    769770            m_formatter.immediate32(imm);
    770771        }
     772    }
     773   
     774    void cmpb_im(int imm, int offset, RegisterID base)
     775    {
     776        m_formatter.oneByteOp(OP_GROUP1_EbIb, GROUP1_OP_CMP, base, offset);
     777        m_formatter.immediate8(imm);
    771778    }
    772779
     
    888895        m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, base, offset);
    889896        m_formatter.immediate32(imm);
     897    }
     898   
     899    void testb_im(int imm, int offset, RegisterID base)
     900    {
     901        m_formatter.oneByteOp(OP_GROUP3_EbIb, GROUP3_OP_TEST, base, offset);
     902        m_formatter.immediate8(imm);
    890903    }
    891904
  • trunk/JavaScriptCore/jit/JITCall.cpp

    r51067 r55684  
    160160    addSlowCase(branch32(NotEqual, regT1, Imm32(JSValue::CellTag)));
    161161    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    162     addSlowCase(branch32(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo) + OBJECT_OFFSETOF(TypeInfo, m_type)), Imm32(ObjectType)));
     162    addSlowCase(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo) + OBJECT_OFFSETOF(TypeInfo, m_type)), Imm32(ObjectType)));
    163163}
    164164
  • trunk/JavaScriptCore/jit/JITOpcodes.cpp

    r55615 r55684  
    517517    // Check that baseVal 'ImplementsDefaultHasInstance'.
    518518    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT0);
    519     addSlowCase(branchTest32(Zero, Address(regT0, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(ImplementsDefaultHasInstance)));
     519    addSlowCase(branchTest8(Zero, Address(regT0, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(ImplementsDefaultHasInstance)));
    520520
    521521    // Optimistically load the result true, and start looping.
     
    870870    // First, handle JSCell cases - check MasqueradesAsUndefined bit on the structure.
    871871    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    872     addJump(branchTest32(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
     872    addJump(branchTest8(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
    873873
    874874    Jump wasNotImmediate = jump();
     
    897897    // First, handle JSCell cases - check MasqueradesAsUndefined bit on the structure.
    898898    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    899     addJump(branchTest32(Zero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
     899    addJump(branchTest8(Zero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
    900900
    901901    Jump wasNotImmediate = jump();
     
    12101210    if (base != m_codeBlock->thisRegister()) {
    12111211        loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    1212         isNotObject.append(branch32(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(ObjectType)));
     1212        isNotObject.append(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(ObjectType)));
    12131213    }
    12141214
     
    14891489
    14901490    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    1491     addSlowCase(branchTest32(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(NeedsThisConversion)));
     1491    addSlowCase(branchTest8(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(NeedsThisConversion)));
    14921492
    14931493    map(m_bytecodeIndex + OPCODE_LENGTH(op_convert_this), thisRegister, regT1, regT0);
     
    19931993    // Check that baseVal 'ImplementsDefaultHasInstance'.
    19941994    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT0);
    1995     addSlowCase(branchTest32(Zero, Address(regT0, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(ImplementsDefaultHasInstance)));
     1995    addSlowCase(branchTest8(Zero, Address(regT0, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(ImplementsDefaultHasInstance)));
    19961996
    19971997    // Optimistically load the result true, and start looping.
     
    21542154    emitJumpSlowCaseIfNotJSCell(regT0);
    21552155    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2156     addSlowCase(branch32(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo) + OBJECT_OFFSETOF(TypeInfo, m_type)), Imm32(ObjectType)));
     2156    addSlowCase(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(ObjectType)));
    21572157
    21582158}
     
    22632263    // First, handle JSCell cases - check MasqueradesAsUndefined bit on the structure.
    22642264    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2265     addJump(branchTest32(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
     2265    addJump(branchTest8(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
    22662266    Jump wasNotImmediate = jump();
    22672267
     
    22842284    // First, handle JSCell cases - check MasqueradesAsUndefined bit on the structure.
    22852285    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2286     addJump(branchTest32(Zero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
     2286    addJump(branchTest8(Zero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined)), target);
    22872287    Jump wasNotImmediate = jump();
    22882288
     
    24402440    if (base != m_codeBlock->thisRegister()) {
    24412441        loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2442         isNotObject.append(branch32(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(ObjectType)));
     2442        isNotObject.append(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(ObjectType)));
    24432443    }
    24442444
     
    25912591    emitJumpSlowCaseIfNotJSCell(regT0, srcVReg);
    25922592    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2593     addSlowCase(branch32(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(NumberType)));
     2593    addSlowCase(branch8(NotEqual, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_type)), Imm32(NumberType)));
    25942594   
    25952595    wasImmediate.link(this);
     
    27022702
    27032703    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2704     setTest32(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined), regT0);
     2704    setTest8(NonZero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined), regT0);
    27052705
    27062706    Jump wasNotImmediate = jump();
     
    27272727
    27282728    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT2);
    2729     setTest32(Zero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined), regT0);
     2729    setTest8(Zero, Address(regT2, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(MasqueradesAsUndefined), regT0);
    27302730
    27312731    Jump wasNotImmediate = jump();
     
    27872787    emitJumpSlowCaseIfNotJSCell(regT0);
    27882788    loadPtr(Address(regT0, OBJECT_OFFSETOF(JSCell, m_structure)), regT1);
    2789     addSlowCase(branchTest32(NonZero, Address(regT1, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(NeedsThisConversion)));
     2789    addSlowCase(branchTest8(NonZero, Address(regT1, OBJECT_OFFSETOF(Structure, m_typeInfo.m_flags)), Imm32(NeedsThisConversion)));
    27902790
    27912791}
  • trunk/JavaScriptCore/runtime/JSTypeInfo.h

    r49694 r55684  
    5151            : m_type(type)
    5252        {
     53            ASSERT(flags <= 0xFF);
     54            ASSERT(type <= 0xFF);
    5355            // ImplementsDefaultHasInstance means (ImplementsHasInstance & !OverridesHasInstance)
    5456            if ((flags & (ImplementsHasInstance | OverridesHasInstance)) == ImplementsHasInstance)
     
    5860        }
    5961
    60         JSType type() const { return m_type; }
     62        JSType type() const { return (JSType)m_type; }
    6163
    6264        bool masqueradesAsUndefined() const { return m_flags & MasqueradesAsUndefined; }
     
    7072
    7173    private:
    72         JSType m_type;
    73         unsigned m_flags;
     74        unsigned char m_type;
     75        unsigned char m_flags;
    7476    };
    7577
Note: See TracChangeset for help on using the changeset viewer.