Ignore:
Timestamp:
Feb 10, 2014, 5:31:41 PM (11 years ago)
Author:
[email protected]
Message:

ReallocatePropertyStorage in FTL
https://bugs.webkit.org/show_bug.cgi?id=128352

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

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLIntrinsicRepository.h:
  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compileNode):
(JSC::FTL::LowerDFGToLLVM::compileReallocatePropertyStorage):

  • tests/stress/ftl-reallocatepropertystorage.js: Added.

(foo):

File:
1 edited

Legend:

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

    r163418 r163841  
    440440        case AllocatePropertyStorage:
    441441            compileAllocatePropertyStorage();
     442            break;
     443        case ReallocatePropertyStorage:
     444            compileReallocatePropertyStorage();
    442445            break;
    443446        case ToString:
     
    26612664        setStorage(result);
    26622665    }
     2666
     2667    void compileReallocatePropertyStorage()
     2668    {
     2669        StructureTransitionData& data = m_node->structureTransitionData();
     2670       
     2671        Structure* previous = data.previousStructure;
     2672        LValue object = lowCell(m_node->child1());
     2673
     2674        size_t oldSize = previous->outOfLineCapacity() * sizeof(JSValue);
     2675        size_t newSize = oldSize * outOfLineGrowthFactor;
     2676
     2677        ASSERT(newSize == data.newStructure->outOfLineCapacity() * sizeof(JSValue));
     2678       
     2679        if (previous->couldHaveIndexingHeader()) {
     2680            LValue newAllocSize = m_out.constInt64(newSize / sizeof(JSValue));                   
     2681            LValue result = vmCall(m_out.operation(operationReallocateButterflyToGrowPropertyStorage), m_callFrame, object, newAllocSize);
     2682            setStorage(result);
     2683            return;
     2684        }
     2685       
     2686        LBasicBlock slowPath = FTL_NEW_BLOCK(m_out, ("ReallocatePropertyStorage slow path"));
     2687        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("ReallocatePropertyStorage continuation"));
     2688        LBasicBlock lastNext = m_out.insertNewBlocksBefore(slowPath);
     2689       
     2690        LValue endOfStorage =
     2691            allocateBasicStorageAndGetEnd(m_out.constIntPtr(newSize), slowPath);
     2692       
     2693        ValueFromBlock fastButterfly = m_out.anchor(m_out.add(m_out.constIntPtr(sizeof(IndexingHeader)), endOfStorage));
     2694       
     2695        m_out.jump(continuation);
     2696       
     2697        m_out.appendTo(slowPath, continuation);
     2698       
     2699        LValue newAllocSize = m_out.constInt64(newSize / sizeof(JSValue));       
     2700       
     2701        LValue storageLocation = vmCall(m_out.operation(operationAllocatePropertyStorage), m_callFrame, newAllocSize);
     2702       
     2703        ValueFromBlock slowButterfly = m_out.anchor(storageLocation);
     2704       
     2705        m_out.jump(continuation);
     2706       
     2707        m_out.appendTo(continuation, lastNext);
     2708       
     2709        LValue result = m_out.phi(m_out.intPtr, fastButterfly, slowButterfly);
     2710        LValue oldStorage = m_out.loadPtr(object, m_heaps.JSObject_butterfly);
     2711
     2712        ptrdiff_t headerSize = -sizeof(JSValue) - sizeof(void *);
     2713        ptrdiff_t endStorage = headerSize - static_cast<ptrdiff_t>(oldSize);
     2714
     2715        for (ptrdiff_t offset = headerSize; offset > endStorage; offset -= sizeof(void*)) {
     2716            LValue loaded =
     2717                m_out.loadPtr(m_out.address(m_heaps.properties.atAnyNumber(), oldStorage, offset));
     2718            m_out.storePtr(loaded, m_out.address(m_heaps.properties.atAnyNumber(), result, offset));
     2719        }
     2720       
     2721        m_out.storePtr(result, m_out.address(object, m_heaps.JSObject_butterfly));
     2722       
     2723        setStorage(result);
     2724    }
     2725   
    26632726   
    26642727    void compileToString()
Note: See TracChangeset for help on using the changeset viewer.