Changeset 109194 in webkit


Ignore:
Timestamp:
Feb 28, 2012 10:28:29 PM (12 years ago)
Author:
mhahnenberg@apple.com
Message:

Refactor SpeculativeJIT::emitAllocateJSFinalObject
https://bugs.webkit.org/show_bug.cgi?id=79801

Reviewed by Filip Pizlo.

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::emitAllocateBasicJSObject): Split emitAllocateJSFinalObject out to form this
function, which is more generic in that it can allocate a variety of classes.
(SpeculativeJIT):
(JSC::DFG::SpeculativeJIT::emitAllocateJSFinalObject): Changed to use the new helper function.

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r109177 r109194  
     12012-02-28  Mark Hahnenberg  <mhahnenberg@apple.com>
     2
     3        Refactor SpeculativeJIT::emitAllocateJSFinalObject
     4        https://bugs.webkit.org/show_bug.cgi?id=79801
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * dfg/DFGSpeculativeJIT.h:
     9        (JSC::DFG::SpeculativeJIT::emitAllocateBasicJSObject): Split emitAllocateJSFinalObject out to form this
     10        function, which is more generic in that it can allocate a variety of classes.
     11        (SpeculativeJIT):
     12        (JSC::DFG::SpeculativeJIT::emitAllocateJSFinalObject): Changed to use the new helper function.
     13
    1142012-02-28  Gavin Barraclough  <barraclough@apple.com>
    215
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r109038 r109194  
    17381738    void compileNewFunctionExpression(Node& node);
    17391739   
     1740    template <typename ClassType, bool destructor, typename StructureType>
     1741    void emitAllocateBasicJSObject(StructureType structure, GPRReg resultGPR, GPRReg scratchGPR, MacroAssembler::JumpList& slowPath)
     1742    {
     1743        MarkedAllocator* allocator = 0;
     1744        if (destructor)
     1745            allocator = &m_jit.globalData()->heap.allocatorForObjectWithDestructor(sizeof(ClassType));
     1746        else
     1747            allocator = &m_jit.globalData()->heap.allocatorForObjectWithoutDestructor(sizeof(ClassType));
     1748
     1749        m_jit.loadPtr(&allocator->m_firstFreeCell, resultGPR);
     1750        slowPath.append(m_jit.branchTestPtr(MacroAssembler::Zero, resultGPR));
     1751       
     1752        // The object is half-allocated: we have what we know is a fresh object, but
     1753        // it's still on the GC's free list.
     1754       
     1755        // Ditch the structure by placing it into the structure slot, so that we can reuse
     1756        // scratchGPR.
     1757        m_jit.storePtr(structure, MacroAssembler::Address(resultGPR, JSObject::structureOffset()));
     1758       
     1759        // Now that we have scratchGPR back, remove the object from the free list
     1760        m_jit.loadPtr(MacroAssembler::Address(resultGPR), scratchGPR);
     1761        m_jit.storePtr(scratchGPR, &allocator->m_firstFreeCell);
     1762       
     1763        // Initialize the object's classInfo pointer
     1764        m_jit.storePtr(MacroAssembler::TrustedImmPtr(&ClassType::s_info), MacroAssembler::Address(resultGPR, JSCell::classInfoOffset()));
     1765       
     1766        // Initialize the object's inheritorID.
     1767        m_jit.storePtr(MacroAssembler::TrustedImmPtr(0), MacroAssembler::Address(resultGPR, JSObject::offsetOfInheritorID()));
     1768       
     1769        // Initialize the object's property storage pointer.
     1770        m_jit.addPtr(MacroAssembler::TrustedImm32(sizeof(JSObject)), resultGPR, scratchGPR);
     1771        m_jit.storePtr(scratchGPR, MacroAssembler::Address(resultGPR, ClassType::offsetOfPropertyStorage()));
     1772    }
     1773
    17401774    // It is acceptable to have structure be equal to scratch, so long as you're fine
    17411775    // with the structure GPR being clobbered.
     
    17431777    void emitAllocateJSFinalObject(T structure, GPRReg resultGPR, GPRReg scratchGPR, MacroAssembler::JumpList& slowPath)
    17441778    {
    1745         MarkedAllocator* allocator = &m_jit.globalData()->heap.allocatorForObjectWithoutDestructor(sizeof(JSFinalObject));
    1746        
    1747         m_jit.loadPtr(&allocator->m_firstFreeCell, resultGPR);
    1748         slowPath.append(m_jit.branchTestPtr(MacroAssembler::Zero, resultGPR));
    1749        
    1750         // The object is half-allocated: we have what we know is a fresh object, but
    1751         // it's still on the GC's free list.
    1752        
    1753         // Ditch the structure by placing it into the structure slot, so that we can reuse
    1754         // scratchGPR.
    1755         m_jit.storePtr(structure, MacroAssembler::Address(resultGPR, JSObject::structureOffset()));
    1756        
    1757         // Now that we have scratchGPR back, remove the object from the free list
    1758         m_jit.loadPtr(MacroAssembler::Address(resultGPR), scratchGPR);
    1759         m_jit.storePtr(scratchGPR, &allocator->m_firstFreeCell);
    1760        
    1761         // Initialize the object's classInfo pointer
    1762         m_jit.storePtr(MacroAssembler::TrustedImmPtr(&JSFinalObject::s_info), MacroAssembler::Address(resultGPR, JSCell::classInfoOffset()));
    1763        
    1764         // Initialize the object's inheritorID.
    1765         m_jit.storePtr(MacroAssembler::TrustedImmPtr(0), MacroAssembler::Address(resultGPR, JSObject::offsetOfInheritorID()));
    1766        
    1767         // Initialize the object's property storage pointer.
    1768         m_jit.addPtr(MacroAssembler::TrustedImm32(sizeof(JSObject)), resultGPR, scratchGPR);
    1769         m_jit.storePtr(scratchGPR, MacroAssembler::Address(resultGPR, JSFinalObject::offsetOfPropertyStorage()));
     1779        return emitAllocateBasicJSObject<JSFinalObject, false>(structure, resultGPR, scratchGPR, slowPath);
    17701780    }
    17711781
Note: See TracChangeset for help on using the changeset viewer.