Changeset 246022 in webkit


Ignore:
Timestamp:
Jun 2, 2019 1:02:00 PM (5 years ago)
Author:
keith_miller@apple.com
Message:

Reenable Gigacage on ARM64.
https://bugs.webkit.org/show_bug.cgi?id=198453

Reviewed by Filip Pizlo.

Source/bmalloc:

  • bmalloc/Gigacage.h:

Source/JavaScriptCore:

This patch adds back Gigacaging on Apple's ARM64 ports. Unlike the
old Gigacage however, arm64e uses both Gigacaging and PAC. Since
Gigacaging would otherwise strip a PAC failed authenticate bit we
force a load of the pointer into some garbage register.

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::jumpForTypedArrayIsNeuteredIfOutOfBounds):
(JSC::DFG::SpeculativeJIT::cageTypedArrayStorage):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray):
(JSC::FTL::DFG::LowerDFGToB3::untagArrayPtr):
(JSC::FTL::DFG::LowerDFGToB3::caged):

  • jit/AssemblyHelpers.h:

(JSC::AssemblyHelpers::cageConditionally):

  • llint/LowLevelInterpreter64.asm:

Source/WTF:

  • wtf/CagedPtr.h:

(WTF::CagedPtr::authenticatingLoad):
(WTF::CagedPtr::get const):
(WTF::CagedPtr::getMayBeNull const):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r246021 r246022  
     12019-06-02  Keith Miller  <keith_miller@apple.com>
     2
     3        Reenable Gigacage on ARM64.
     4        https://bugs.webkit.org/show_bug.cgi?id=198453
     5
     6        Reviewed by Filip Pizlo.
     7
     8        This patch adds back Gigacaging on Apple's ARM64 ports. Unlike the
     9        old Gigacage however, arm64e uses both Gigacaging and PAC. Since
     10        Gigacaging would otherwise strip a PAC failed authenticate bit we
     11        force a load of the pointer into some garbage register.
     12
     13        * dfg/DFGSpeculativeJIT.cpp:
     14        (JSC::DFG::SpeculativeJIT::jumpForTypedArrayIsNeuteredIfOutOfBounds):
     15        (JSC::DFG::SpeculativeJIT::cageTypedArrayStorage):
     16        * ftl/FTLLowerDFGToB3.cpp:
     17        (JSC::FTL::DFG::LowerDFGToB3::compileNewTypedArray):
     18        (JSC::FTL::DFG::LowerDFGToB3::untagArrayPtr):
     19        (JSC::FTL::DFG::LowerDFGToB3::caged):
     20        * jit/AssemblyHelpers.h:
     21        (JSC::AssemblyHelpers::cageConditionally):
     22        * llint/LowLevelInterpreter64.asm:
     23
    1242019-06-02  Tadeu Zagallo  <tzagallo@apple.com>
    225
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r245658 r246022  
    28742874
    28752875            JITCompiler::Jump hasNullVector;
    2876 #if !GIGACAGE_ENABLED && CPU(ARM64E)
     2876#if CPU(ARM64E)
    28772877            {
    28782878                GPRReg scratch = m_jit.scratchRegister();
     
    28832883                hasNullVector = m_jit.branchTestPtr(MacroAssembler::Zero, scratch);
    28842884            }
    2885 #else // !GIGACAGE_ENABLED && CPU(ARM64E)
     2885#else // CPU(ARM64E)
    28862886            hasNullVector = m_jit.branchTestPtr(
    28872887                MacroAssembler::Zero,
     
    67206720void SpeculativeJIT::cageTypedArrayStorage(GPRReg baseReg, GPRReg storageReg)
    67216721{
     6722#if CPU(ARM64E)
     6723    m_jit.untagArrayPtr(MacroAssembler::Address(baseReg, JSArrayBufferView::offsetOfLength()), storageReg);
     6724    m_jit.loadPtr(storageReg, m_jit.scratchRegister());
     6725#else
     6726    UNUSED_PARAM(baseReg);
     6727    UNUSED_PARAM(storageReg);
     6728#endif
     6729
    67226730#if GIGACAGE_ENABLED
    67236731    UNUSED_PARAM(baseReg);
     
    67336741   
    67346742    m_jit.cage(Gigacage::Primitive, storageReg);
    6735 #elif CPU(ARM64E)
    6736     m_jit.untagArrayPtr(MacroAssembler::Address(baseReg, JSArrayBufferView::offsetOfLength()), storageReg);
    6737 #else
    6738     UNUSED_PARAM(baseReg);
    6739     UNUSED_PARAM(storageReg);
    67406743#endif
    67416744}
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r245313 r246022  
    64646464                m_heaps.typedArrayProperties);
    64656465
    6466 #if !GIGACAGE_ENABLED && CPU(ARM64E)
     6466#if CPU(ARM64E)
    64676467            {
    64686468                LValue sizePtr = m_out.zeroExtPtr(size);
     
    1410914109        authenticate->appendSomeRegister(ptr);
    1411014110        authenticate->append(size, B3::ValueRep(B3::ValueRep::SomeLateRegister));
     14111        authenticate->numGPScratchRegisters = 1;
    1411114112        authenticate->setGenerator([=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
    1411214113            jit.move(params[1].gpr(), params[0].gpr());
    1411314114            jit.untagArrayPtr(params[2].gpr(), params[0].gpr());
     14115            // Force a load to check authentication. before it is cleared by Gigacaging later.
     14116            jit.loadPtr(params[0].gpr(), params.gpScratch(0));
    1411414117        });
    1411514118        return authenticate;
     
    1413614139    LValue caged(Gigacage::Kind kind, LValue ptr, LValue base)
    1413714140    {
     14141#if CPU(ARM64E)
     14142        if (kind == Gigacage::Primitive) {
     14143            LValue size = m_out.load32(base, m_heaps.JSArrayBufferView_length);
     14144            ptr = untagArrayPtr(ptr, size);
     14145        }
     14146#else
     14147        UNUSED_PARAM(kind);
     14148        UNUSED_PARAM(base);
     14149#endif
     14150
    1413814151#if GIGACAGE_ENABLED
    1413914152        UNUSED_PARAM(base);
     
    1416614179        // https://bugs.webkit.org/show_bug.cgi?id=175493
    1416714180        return m_out.opaque(result);
    14168 #elif CPU(ARM64E)
    14169         if (kind == Gigacage::Primitive) {
    14170             LValue size = m_out.load32(base, m_heaps.JSArrayBufferView_length);
    14171             return untagArrayPtr(ptr, size);
    14172         }
    14173 
    14174         return ptr;
    14175 #else
    14176         UNUSED_PARAM(kind);
    14177         UNUSED_PARAM(base);
    14178         return ptr;
    1417914181#endif
    1418014182    }
  • trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h

    r245064 r246022  
    15721572    void cageConditionally(Gigacage::Kind kind, GPRReg storage, GPRReg scratchOrLength)
    15731573    {
     1574#if CPU(ARM64E)
     1575        if (kind == Gigacage::Primitive) {
     1576            untagArrayPtr(scratchOrLength, storage);
     1577            // Force a load to trap on authentication failure. storage shouldn't be null here.
     1578            loadPtr(storage, scratchOrLength);
     1579        }
     1580#else
     1581        UNUSED_PARAM(kind);
     1582        UNUSED_PARAM(storage);
     1583        UNUSED_PARAM(scratchOrLength);
     1584#endif
     1585
    15741586#if GIGACAGE_ENABLED
    15751587        if (!Gigacage::isEnabled(kind))
     
    15841596        addPtr(scratchOrLength, storage);
    15851597        done.link(this);
    1586 #elif CPU(ARM64E)
    1587         if (kind == Gigacage::Primitive)
    1588             untagArrayPtr(scratchOrLength, storage);
    1589 #else
    1590         UNUSED_PARAM(kind);
    1591         UNUSED_PARAM(storage);
    1592         UNUSED_PARAM(scratchOrLength);
    15931598#endif
    15941599    }
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r245906 r246022  
    435435macro loadCagedPrimitive(source, dest, scratchOrLength)
    436436    loadp source, dest
     437    if ARM64E
     438        untagArrayPtr scratchOrLength, dest
     439        # Force a load to check PAC before we clear it below.
     440        loadp [dest], scratchOrLength
     441    end
    437442    if GIGACAGE_ENABLED
    438443        uncage(_g_gigacageBasePtrs + Gigacage::BasePtrs::primitive, constexpr Gigacage::primitiveGigacageMask, dest, scratchOrLength)
    439     elsif ARM64E
    440         untagArrayPtr scratchOrLength, dest
    441444    end
    442445end
  • trunk/Source/WTF/ChangeLog

    r245983 r246022  
     12019-06-02  Keith Miller  <keith_miller@apple.com>
     2
     3        Reenable Gigacage on ARM64.
     4        https://bugs.webkit.org/show_bug.cgi?id=198453
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * wtf/CagedPtr.h:
     9        (WTF::CagedPtr::authenticatingLoad):
     10        (WTF::CagedPtr::get const):
     11        (WTF::CagedPtr::getMayBeNull const):
     12
    1132019-05-31  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Source/WTF/wtf/CagedPtr.h

    r245432 r246022  
    3636template<Gigacage::Kind passedKind, typename T, bool shouldTag = false, typename PtrTraits = DumbPtrTraits<T>>
    3737class CagedPtr {
     38#if CPU(ARM64E)
     39    static void authenticatingLoad(T* ptr)
     40    {
     41        double result;
     42        asm volatile("ldr %[out], [%[in]]"
     43            : [out] "=&r"(result)
     44            : [in] "r"(ptr) :);
     45    }
     46#else
     47    static void authenticatingLoad(T*) { }
     48#endif
     49
    3850public:
    3951    static constexpr Gigacage::Kind kind = passedKind;
     
    5365        ASSERT(m_ptr);
    5466        T* ptr = PtrTraits::unwrap(m_ptr);
    55         if (shouldTag)
     67        if (shouldTag) {
    5668            ptr = untagArrayPtr(ptr, size);
     69            authenticatingLoad(ptr);
     70        }
    5771        return Gigacage::caged(kind, ptr);
    5872    }
     
    6175    {
    6276        T* ptr = PtrTraits::unwrap(m_ptr);
    63         if (shouldTag)
     77        if (shouldTag) {
    6478            ptr = untagArrayPtr(ptr, size);
     79            if (ptr)
     80                authenticatingLoad(ptr);
     81        }
    6582        return Gigacage::cagedMayBeNull(kind, ptr);
    6683    }
  • trunk/Source/bmalloc/ChangeLog

    r245940 r246022  
     12019-06-02  Keith Miller  <keith_miller@apple.com>
     2
     3        Reenable Gigacage on ARM64.
     4        https://bugs.webkit.org/show_bug.cgi?id=198453
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * bmalloc/Gigacage.h:
     9
    1102019-05-30  Don Olmstead  <don.olmstead@sony.com>
    211
  • trunk/Source/bmalloc/bmalloc/Gigacage.h

    r245432 r246022  
    3535#include <inttypes.h>
    3636
    37 #if ((BOS(DARWIN) || BOS(LINUX)) && BCPU(X86_64))
     37#if ((BOS(DARWIN) || BOS(LINUX)) && \
     38    (BCPU(X86_64) || (BCPU(ARM64) && !defined(__ILP32__) && (!BPLATFORM(IOS_FAMILY) || BPLATFORM(IOS)))))
    3839#define GIGACAGE_ENABLED 1
    3940#else
Note: See TracChangeset for help on using the changeset viewer.