Changeset 196652 in webkit


Ignore:
Timestamp:
Feb 16, 2016 1:12:04 PM (8 years ago)
Author:
fpizlo@apple.com
Message:

FTL should support NewTypedArray
https://bugs.webkit.org/show_bug.cgi?id=154268

Reviewed by Saam Barati.

3% speed-up on pdfjs. This was already covered by many different tests.

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
(JSC::FTL::DFG::LowerDFGToLLVM::compileNewArrayWithSize):
(JSC::FTL::DFG::LowerDFGToLLVM::compileNewTypedArray):
(JSC::FTL::DFG::LowerDFGToLLVM::compileAllocatePropertyStorage):
(JSC::FTL::DFG::LowerDFGToLLVM::allocateBasicStorageAndGetEnd):
(JSC::FTL::DFG::LowerDFGToLLVM::allocateBasicStorage):
(JSC::FTL::DFG::LowerDFGToLLVM::allocateObject):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196650 r196652  
     12016-02-16  Filip Pizlo  <fpizlo@apple.com>
     2
     3        FTL should support NewTypedArray
     4        https://bugs.webkit.org/show_bug.cgi?id=154268
     5
     6        Reviewed by Saam Barati.
     7
     8        3% speed-up on pdfjs. This was already covered by many different tests.
     9
     10        * ftl/FTLCapabilities.cpp:
     11        (JSC::FTL::canCompile):
     12        * ftl/FTLLowerDFGToLLVM.cpp:
     13        (JSC::FTL::DFG::LowerDFGToLLVM::compileNode):
     14        (JSC::FTL::DFG::LowerDFGToLLVM::compileNewArrayWithSize):
     15        (JSC::FTL::DFG::LowerDFGToLLVM::compileNewTypedArray):
     16        (JSC::FTL::DFG::LowerDFGToLLVM::compileAllocatePropertyStorage):
     17        (JSC::FTL::DFG::LowerDFGToLLVM::allocateBasicStorageAndGetEnd):
     18        (JSC::FTL::DFG::LowerDFGToLLVM::allocateBasicStorage):
     19        (JSC::FTL::DFG::LowerDFGToLLVM::allocateObject):
     20
    1212016-02-16  Saam barati  <sbarati@apple.com>
    222
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r196642 r196652  
    11/*
    2  * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7373    case NewArray:
    7474    case NewArrayBuffer:
     75    case NewTypedArray:
    7576    case GetByOffset:
    7677    case GetGetterSetterByOffset:
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r196642 r196652  
    845845        case NewArrayWithSize:
    846846            compileNewArrayWithSize();
     847            break;
     848        case NewTypedArray:
     849            compileNewTypedArray();
    847850            break;
    848851        case GetTypedArrayByteOffset:
     
    40914094            LValue butterfly = m_out.sub(endOfStorage, payloadSize);
    40924095           
    4093             LValue object = allocateObject<JSArray>(
    4094                 structure, butterfly, failCase);
     4096            LValue object = allocateObject<JSArray>(structure, butterfly, failCase);
    40954097           
    40964098            m_out.store32(publicLength, butterfly, m_heaps.Butterfly_publicLength);
     
    41594161            m_out.constIntPtr(structure));
    41604162        setJSValue(vmCall(m_out.int64, m_out.operation(operationNewArrayWithSize), m_callFrame, structureValue, publicLength));
     4163    }
     4164
     4165    void compileNewTypedArray()
     4166    {
     4167        JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->origin.semantic);
     4168        TypedArrayType type = m_node->typedArrayType();
     4169        Structure* structure = globalObject->typedArrayStructure(type);
     4170
     4171        LValue size = lowInt32(m_node->child1());
     4172
     4173        LBasicBlock smallEnoughCase = FTL_NEW_BLOCK(m_out, ("NewTypedArray small enough case"));
     4174        LBasicBlock nonZeroCase = FTL_NEW_BLOCK(m_out, ("NewTypedArray non-zero case"));
     4175        LBasicBlock slowCase = FTL_NEW_BLOCK(m_out, ("NewTypedArray slow case"));
     4176        LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("NewTypedArray continuation"));
     4177
     4178        m_out.branch(
     4179            m_out.above(size, m_out.constInt32(JSArrayBufferView::fastSizeLimit)),
     4180            rarely(slowCase), usually(smallEnoughCase));
     4181
     4182        LBasicBlock lastNext = m_out.appendTo(smallEnoughCase, nonZeroCase);
     4183
     4184        m_out.branch(m_out.notZero32(size), usually(nonZeroCase), rarely(slowCase));
     4185
     4186        m_out.appendTo(nonZeroCase, slowCase);
     4187
     4188        LValue byteSize = m_out.shl(m_out.zeroExtPtr(size), m_out.constInt32(logElementSize(type)));
     4189        if (elementSize(type) < 8) {
     4190            byteSize = m_out.bitAnd(
     4191                m_out.add(byteSize, m_out.constIntPtr(7)),
     4192                m_out.constIntPtr(~static_cast<intptr_t>(7)));
     4193        }
     4194       
     4195        LValue storage = allocateBasicStorage(byteSize, slowCase);
     4196
     4197        LValue fastResultValue = allocateObject<JSArrayBufferView>(structure, storage, slowCase);
     4198
     4199        m_out.storePtr(storage, fastResultValue, m_heaps.JSArrayBufferView_vector);
     4200        m_out.store32(size, fastResultValue, m_heaps.JSArrayBufferView_length);
     4201        m_out.store32(m_out.constInt32(FastTypedArray), fastResultValue, m_heaps.JSArrayBufferView_mode);
     4202
     4203        ValueFromBlock fastResult = m_out.anchor(fastResultValue);
     4204        m_out.jump(continuation);
     4205
     4206        m_out.appendTo(slowCase, continuation);
     4207
     4208        LValue slowResultValue = lazySlowPath(
     4209            [=] (const Vector<Location>& locations) -> RefPtr<LazySlowPath::Generator> {
     4210                return createLazyCallGenerator(
     4211                    operationNewTypedArrayWithSizeForType(type), locations[0].directGPR(),
     4212                    CCallHelpers::TrustedImmPtr(structure), locations[1].directGPR());
     4213            },
     4214            size);
     4215        ValueFromBlock slowResult = m_out.anchor(slowResultValue);
     4216        m_out.jump(continuation);
     4217
     4218        m_out.appendTo(continuation, lastNext);
     4219        setJSValue(m_out.phi(m_out.intPtr, fastResult, slowResult));
    41614220    }
    41624221   
     
    79327991        return m_out.sub(
    79337992            m_out.loadPtr(m_out.absolute(&allocator.m_currentPayloadEnd)), newRemaining);
     7993    }
     7994
     7995    LValue allocateBasicStorage(LValue size, LBasicBlock slowPath)
     7996    {
     7997        return m_out.sub(allocateBasicStorageAndGetEnd(size, slowPath), size);
    79347998    }
    79357999   
Note: See TracChangeset for help on using the changeset viewer.