Changeset 276855 in webkit


Ignore:
Timestamp:
Apr 30, 2021 2:50:21 PM (3 years ago)
Author:
fpizlo@apple.com
Message:

Make the JIT pool smaller on AS
https://bugs.webkit.org/show_bug.cgi?id=225249

Reviewed by Saam Barati.

This adds three related features:

  • Makes it easy to dump where the JIT pool was allocated.
  • Makes it possible to override the JIT pool size with Options even with jump islands.
  • Changes the default JIT pool size on AS to 512MB.

Estimated 2% speed-up on JetStream2, 1.5% speed-up on Speedometer2.

  • jit/ExecutableAllocator.cpp:

(JSC::initializeJITPageReservation):

  • runtime/OptionsList.h:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r276823 r276855  
     12021-04-30  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Make the JIT pool smaller on AS
     4        https://bugs.webkit.org/show_bug.cgi?id=225249
     5
     6        Reviewed by Saam Barati.
     7
     8        This adds three related features:
     9
     10        - Makes it easy to dump where the JIT pool was allocated.
     11
     12        - Makes it possible to override the JIT pool size with Options even with jump islands.
     13
     14        - Changes the default JIT pool size on AS to 512MB.
     15
     16        Estimated 2% speed-up on JetStream2, 1.5% speed-up on Speedometer2.
     17
     18        * jit/ExecutableAllocator.cpp:
     19        (JSC::initializeJITPageReservation):
     20        * runtime/OptionsList.h:
     21
    1222021-04-29  Saam Barati  <sbarati@apple.com>
    223
  • trunk/Source/JavaScriptCore/jit/ExecutableAllocator.cpp

    r274602 r276855  
    11/*
    2  * Copyright (C) 2008-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9696#elif CPU(ARM64)
    9797#if ENABLE(JUMP_ISLANDS)
    98 static constexpr size_t fixedExecutableMemoryPoolSize = 1 * GB;
     98static constexpr size_t fixedExecutableMemoryPoolSize = 512 * MB;
    9999// These sizes guarantee that any jump within an island can jump forwards or backwards
    100100// to the adjacent island in a single instruction.
    101101static constexpr size_t regionSize = 112 * MB;
    102102static constexpr size_t islandRegionSize = 16 * MB;
    103 static constexpr size_t numberOfRegions = fixedExecutableMemoryPoolSize / regionSize;
     103static constexpr size_t maxNumberOfRegions = fixedExecutableMemoryPoolSize / regionSize;
    104104static constexpr size_t islandSizeInBytes = 4;
    105105static constexpr size_t maxIslandsPerRegion = islandRegionSize / islandSizeInBytes;
     
    332332
    333333    reservation.size = fixedExecutableMemoryPoolSize;
    334 #if !ENABLE(JUMP_ISLANDS)
    335     // FIXME: Consider making jump islands work with Options::jitMemoryReservationSize
    336     // https://bugs.webkit.org/show_bug.cgi?id=209037
     334
    337335    if (Options::jitMemoryReservationSize())
    338336        reservation.size = Options::jitMemoryReservationSize();
    339 #endif
     337
    340338    reservation.size = std::max(roundUpToMultipleOf(pageSize(), reservation.size), pageSize() * 2);
    341339
     
    352350
    353351    reservation.pageReservation = tryCreatePageReservation(reservation.size);
     352
     353    if (Options::verboseExecutablePoolAllocation())
     354        dataLog(getpid(), ": Got executable pool reservation at ", RawPointer(reservation.pageReservation.base()), "...", RawPointer(bitwise_cast<char*>(reservation.pageReservation.base()) + reservation.pageReservation.size()), ", while I'm at ", RawPointer(bitwise_cast<void*>(initializeJITPageReservation)), "\n");
     355   
    354356    if (reservation.pageReservation) {
    355357        ASSERT(reservation.pageReservation.size() == reservation.size);
     
    398400    FixedVMPoolExecutableAllocator()
    399401#if ENABLE(JUMP_ISLANDS)
    400         : m_allocators(constructFixedSizeArrayWithArguments<RegionAllocator, numberOfRegions>(*this))
     402        : m_allocators(constructFixedSizeArrayWithArguments<RegionAllocator, maxNumberOfRegions>(*this))
     403        , m_numAllocators(maxNumberOfRegions)
    401404#else
    402405        : m_allocator(*this)
     
    409412            uintptr_t start = bitwise_cast<uintptr_t>(memoryStart());
    410413            uintptr_t reservationEnd = bitwise_cast<uintptr_t>(memoryEnd());
    411             for (size_t i = 0; i < numberOfRegions; ++i) {
    412                 RELEASE_ASSERT(start < reservationEnd);
     414            for (size_t i = 0; i < maxNumberOfRegions; ++i) {
     415                RELEASE_ASSERT(start < reservationEnd || Options::jitMemoryReservationSize());
     416                if (start >= reservationEnd) {
     417                    m_numAllocators = i;
     418                    break;
     419                }
    413420                m_allocators[i].m_start = tagCodePtr<ExecutableMemoryPtrTag>(bitwise_cast<void*>(start));
    414421                m_allocators[i].m_end = tagCodePtr<ExecutableMemoryPtrTag>(bitwise_cast<void*>(start + regionSize));
    415422                if (m_allocators[i].end() > reservationEnd) {
    416423                    // We may have taken a page for the executable only copy thunk.
    417                     RELEASE_ASSERT(i == numberOfRegions - 1);
     424                    RELEASE_ASSERT(i == maxNumberOfRegions - 1 || Options::jitMemoryReservationSize());
    418425                    m_allocators[i].m_end = tagCodePtr<ExecutableMemoryPtrTag>(bitwise_cast<void*>(reservationEnd));
    419426                }
     
    451458        unsigned start = 0;
    452459        if (Options::useRandomizingExecutableIslandAllocation())
    453             start = cryptographicallyRandomNumber() % m_allocators.size();
     460            start = cryptographicallyRandomNumber() % m_numAllocators;
    454461
    455462        unsigned i = start;
     
    458465            if (RefPtr<ExecutableMemoryHandle> result = allocator.allocate(locker, sizeInBytes))
    459466                return result;
    460             i = (i + 1) % m_allocators.size();
     467            i = (i + 1) % m_numAllocators;
    461468            if (i == start)
    462469                break;
     
    833840    PageReservation m_reservation;
    834841#if ENABLE(JUMP_ISLANDS)
    835     std::array<RegionAllocator, numberOfRegions> m_allocators;
     842    std::array<RegionAllocator, maxNumberOfRegions> m_allocators;
     843    unsigned m_numAllocators;
    836844    RedBlackTree<Islands, void*> m_islandsForJumpSourceLocation;
    837845#else
  • trunk/Source/JavaScriptCore/runtime/OptionsList.h

    r276786 r276855  
    533533    v(Bool, useSharedArrayBuffer, false, Normal, nullptr) \
    534534    v(Bool, useTopLevelAwait, true, Normal, "allow the await keyword at the top level of a module.") \
     535    v(Bool, dumpLinking, false, Normal, nullptr) \
     536    v(Bool, verifySame4GBLink, false, Normal, nullptr) \
     537    v(Bool, verboseExecutablePoolAllocation, false, Normal, nullptr) \
    535538
    536539
Note: See TracChangeset for help on using the changeset viewer.