Ignore:
Timestamp:
Feb 3, 2014, 1:51:47 PM (11 years ago)
Author:
[email protected]
Message:

Added GetTypedArrayByteOffset to FTL
https://bugs.webkit.org/show_bug.cgi?id=127589

Patch by Matthew Mirman <[email protected]> on 2014-02-03
Reviewed by Filip Pizlo.

  • ftl/FTLAbstractHeapRepository.h:
  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileGetTypedArrayByteOffset):

  • tests/stress/ftl-gettypedarrayoffset-simple.js: Added.

(foo):

  • tests/stress/ftl-gettypedarrayoffset-wasteful.js: Added.

(foo):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r163119 r163324  
    435435            compileNewArrayWithSize();
    436436            break;
     437        case GetTypedArrayByteOffset:
     438            compileGetTypedArrayByteOffset();
     439            break;
    437440        case AllocatePropertyStorage:
    438441            compileAllocatePropertyStorage();
     
    17251728            BadIndexingType, jsValueValue(cell), 0,
    17261729            m_out.bitNot(isArrayType(cell, m_node->arrayMode())));
     1730    }
     1731
     1732    void compileGetTypedArrayByteOffset()
     1733    {
     1734        LValue basePtr = lowCell(m_node->child1());   
     1735
     1736        LBasicBlock simpleCase = FTL_NEW_BLOCK(m_out, ("wasteless typed array"));
     1737        LBasicBlock wastefulCase = FTL_NEW_BLOCK(m_out, ("wasteful typed array"));
     1738        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("continuation branch"));
     1739       
     1740        LValue baseAddress = m_out.addPtr(basePtr, JSArrayBufferView::offsetOfMode());
     1741        m_out.branch(m_out.notEqual(baseAddress , m_out.constIntPtr(WastefulTypedArray)), simpleCase, wastefulCase);
     1742
     1743        // begin simple case       
     1744        LBasicBlock lastNext = m_out.appendTo(simpleCase, wastefulCase);
     1745
     1746        ValueFromBlock simpleOut = m_out.anchor(m_out.constIntPtr(0));
     1747
     1748        m_out.jump(continuation);
     1749
     1750        // begin wasteful case
     1751        m_out.appendTo(wastefulCase, continuation);
     1752
     1753        LValue vectorPtr = m_out.loadPtr(basePtr, m_heaps.JSArrayBufferView_vector);
     1754        LValue butterflyPtr = m_out.loadPtr(basePtr, m_heaps.JSObject_butterfly);
     1755        LValue arrayBufferPtr = m_out.loadPtr(butterflyPtr, m_heaps.Butterfly_arrayBuffer);
     1756        LValue dataPtr = m_out.loadPtr(arrayBufferPtr, m_heaps.ArrayBuffer_data);
     1757
     1758        ValueFromBlock wastefulOut = m_out.anchor(m_out.sub(dataPtr, vectorPtr));       
     1759
     1760        m_out.jump(continuation);
     1761        m_out.appendTo(continuation, lastNext);
     1762
     1763        // output
     1764        setInt32(m_out.castToInt32(m_out.phi(m_out.intPtr, simpleOut, wastefulOut)));
    17271765    }
    17281766   
Note: See TracChangeset for help on using the changeset viewer.