Changeset 232132 in webkit


Ignore:
Timestamp:
May 23, 2018 3:34:18 PM (6 years ago)
Author:
fpizlo@apple.com
Message:

Speed up JetStream/base64
https://bugs.webkit.org/show_bug.cgi?id=185914

Reviewed by Michael Saboff.

Source/JavaScriptCore:

Make allocation fast paths ALWAYS_INLINE.

This is a 1% speed-up on SunSpider, mostly because of base64. It also speeds up pdfjs by
~6%.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • heap/AllocatorInlines.h:

(JSC::Allocator::allocate const):

  • heap/CompleteSubspace.cpp:

(JSC::CompleteSubspace::allocateNonVirtual): Deleted.

  • heap/CompleteSubspace.h:
  • heap/CompleteSubspaceInlines.h: Added.

(JSC::CompleteSubspace::allocateNonVirtual):

  • heap/FreeListInlines.h:

(JSC::FreeList::allocate):

  • heap/IsoSubspace.cpp:

(JSC::IsoSubspace::allocateNonVirtual): Deleted.

  • heap/IsoSubspace.h:

(JSC::IsoSubspace::allocatorForNonVirtual):

  • heap/IsoSubspaceInlines.h: Added.

(JSC::IsoSubspace::allocateNonVirtual):

  • runtime/JSCellInlines.h:
  • runtime/VM.h:

Source/WTF:

Make Vector<>::append ALWAYS_INLINE.

  • wtf/Vector.h:

(WTF::Vector::append):
(WTF::minCapacity>::expandCapacity):
(WTF::minCapacity>::append):
(WTF::minCapacity>::tryAppend):

Location:
trunk/Source
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r232080 r232132  
    491491    heap/AllocationFailureMode.h
    492492    heap/Allocator.h
     493    heap/AllocatorInlines.h
    493494    heap/AllocatorForMode.h
    494495    heap/BlockDirectory.h
     
    501502    heap/CollectorPhase.h
    502503    heap/CompleteSubspace.h
     504    heap/CompleteSubspaceInlines.h
    503505    heap/ConstraintConcurrency.h
    504506    heap/ConstraintParallelism.h
     
    534536    heap/IsoCellSet.h
    535537    heap/IsoSubspace.h
     538    heap/IsoSubspaceInlines.h
    536539    heap/IsoSubspacePerVM.h
    537540    heap/LargeAllocation.h
    538541    heap/ListableHandler.h
    539542    heap/LocalAllocator.h
     543    heap/LocalAllocatorInlines.h
    540544    heap/LockDuringMarking.h
    541545    heap/MachineStackMarker.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r232110 r232132  
     12018-05-23  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Speed up JetStream/base64
     4        https://bugs.webkit.org/show_bug.cgi?id=185914
     5
     6        Reviewed by Michael Saboff.
     7       
     8        Make allocation fast paths ALWAYS_INLINE.
     9       
     10        This is a 1% speed-up on SunSpider, mostly because of base64. It also speeds up pdfjs by
     11        ~6%.
     12
     13        * CMakeLists.txt:
     14        * JavaScriptCore.xcodeproj/project.pbxproj:
     15        * heap/AllocatorInlines.h:
     16        (JSC::Allocator::allocate const):
     17        * heap/CompleteSubspace.cpp:
     18        (JSC::CompleteSubspace::allocateNonVirtual): Deleted.
     19        * heap/CompleteSubspace.h:
     20        * heap/CompleteSubspaceInlines.h: Added.
     21        (JSC::CompleteSubspace::allocateNonVirtual):
     22        * heap/FreeListInlines.h:
     23        (JSC::FreeList::allocate):
     24        * heap/IsoSubspace.cpp:
     25        (JSC::IsoSubspace::allocateNonVirtual): Deleted.
     26        * heap/IsoSubspace.h:
     27        (JSC::IsoSubspace::allocatorForNonVirtual):
     28        * heap/IsoSubspaceInlines.h: Added.
     29        (JSC::IsoSubspace::allocateNonVirtual):
     30        * runtime/JSCellInlines.h:
     31        * runtime/VM.h:
     32
    1332018-05-23  Rick Waldron  <waldron.rick@gmail.com>
    234
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r232080 r232132  
    395395                0F725CB01C506D3B00AD943A /* B3FoldPathConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F725CAE1C506D3B00AD943A /* B3FoldPathConstants.h */; };
    396396                0F74B93B1F89614800B935D3 /* PrototypeKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F74B93A1F89614500B935D3 /* PrototypeKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
    397                 0F75A060200D260B0038E2CF /* LocalAllocatorInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A05A200D25F00038E2CF /* LocalAllocatorInlines.h */; };
     397                0F75A060200D260B0038E2CF /* LocalAllocatorInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A05A200D25F00038E2CF /* LocalAllocatorInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    398398                0F75A061200D26180038E2CF /* LocalAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A057200D25F00038E2CF /* LocalAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    399                 0F75A062200D261D0038E2CF /* AllocatorInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A05D200D25F10038E2CF /* AllocatorInlines.h */; };
     399                0F75A062200D261D0038E2CF /* AllocatorInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A05D200D25F10038E2CF /* AllocatorInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    400400                0F75A063200D261F0038E2CF /* Allocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A054200D25EF0038E2CF /* Allocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    401401                0F75A0662013E4F10038E2CF /* JITAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F75A0652013E4EF0038E2CF /* JITAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    547547                0FD0E5F21E46C8AF0006AB08 /* CollectingScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD0E5F11E46C8AD0006AB08 /* CollectingScope.h */; };
    548548                0FD2C92416D01EE900C7803F /* StructureInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD2C92316D01EE900C7803F /* StructureInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
     549                0FD2FD9420B52BDE00F09441 /* CompleteSubspaceInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD2FD9320B52BDD00F09441 /* CompleteSubspaceInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
     550                0FD2FD9520B52BE200F09441 /* IsoSubspaceInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD2FD9220B52BDC00F09441 /* IsoSubspaceInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    549551                0FD3C82814115D4F00FD81CB /* DFGDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD3C82214115D0E00FD81CB /* DFGDriver.h */; };
    550552                0FD3E4021B618AAF00C80E1E /* DFGAdaptiveInferredPropertyValueWatchpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD3E4001B618AAF00C80E1E /* DFGAdaptiveInferredPropertyValueWatchpoint.h */; };
     
    27062708                0FD0E5F11E46C8AD0006AB08 /* CollectingScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectingScope.h; sourceTree = "<group>"; };
    27072709                0FD2C92316D01EE900C7803F /* StructureInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureInlines.h; sourceTree = "<group>"; };
     2710                0FD2FD9220B52BDC00F09441 /* IsoSubspaceInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IsoSubspaceInlines.h; sourceTree = "<group>"; };
     2711                0FD2FD9320B52BDD00F09441 /* CompleteSubspaceInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompleteSubspaceInlines.h; sourceTree = "<group>"; };
    27082712                0FD3C82014115CF800FD81CB /* DFGDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGDriver.cpp; path = dfg/DFGDriver.cpp; sourceTree = "<group>"; };
    27092713                0FD3C82214115D0E00FD81CB /* DFGDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGDriver.h; path = dfg/DFGDriver.h; sourceTree = "<group>"; };
     
    56365640                                0FDCE1271FAFA859006F3901 /* CompleteSubspace.cpp */,
    56375641                                0FDCE1281FAFA859006F3901 /* CompleteSubspace.h */,
     5642                                0FD2FD9320B52BDD00F09441 /* CompleteSubspaceInlines.h */,
    56385643                                146B14DB12EB5B12001BEC1B /* ConservativeRoots.cpp */,
    56395644                                149DAAF212EB559D0083B12B /* ConservativeRoots.h */,
     
    57115716                                0FDCE12C1FAFB4DE006F3901 /* IsoSubspace.cpp */,
    57125717                                0FDCE12B1FAFB4DE006F3901 /* IsoSubspace.h */,
     5718                                0FD2FD9220B52BDC00F09441 /* IsoSubspaceInlines.h */,
    57135719                                0F5E0FE62086AD470097F0DE /* IsoSubspacePerVM.cpp */,
    57145720                                0F5E0FE52086AD460097F0DE /* IsoSubspacePerVM.h */,
     
    83168322                                0FEC85261BDACDAC0080FF74 /* B3PatchpointSpecial.h in Headers */,
    83178323                                0FEC85281BDACDAC0080FF74 /* B3PatchpointValue.h in Headers */,
     8324                                0FD2FD9520B52BE200F09441 /* IsoSubspaceInlines.h in Headers */,
    83188325                                799EF7C41C56ED96002B0534 /* B3PCToOriginMap.h in Headers */,
    83198326                                0FEC852A1BDACDAC0080FF74 /* B3PhaseScope.h in Headers */,
     
    89508957                                BC18C4150E16F5CD00B34460 /* JavaScriptCorePrefix.h in Headers */,
    89518958                                1429D9300ED22D7000B89619 /* JIT.h in Headers */,
     8959                                0FD2FD9420B52BDE00F09441 /* CompleteSubspaceInlines.h in Headers */,
    89528960                                FE1220271BE7F58C0039E6F2 /* JITAddGenerator.h in Headers */,
    89538961                                0F75A0662013E4F10038E2CF /* JITAllocator.h in Headers */,
  • trunk/Source/JavaScriptCore/heap/AllocatorInlines.h

    r232074 r232132  
    3131namespace JSC {
    3232
    33 inline void* Allocator::allocate(GCDeferralContext* context, AllocationFailureMode mode) const
     33ALWAYS_INLINE void* Allocator::allocate(GCDeferralContext* context, AllocationFailureMode mode) const
    3434{
    3535    return m_localAllocator->allocate(context, mode);
  • trunk/Source/JavaScriptCore/heap/CompleteSubspace.cpp

    r232074 r232132  
    5656{
    5757    return allocateNonVirtual(vm, size, deferralContext, failureMode);
    58 }
    59 
    60 void* CompleteSubspace::allocateNonVirtual(VM& vm, size_t size, GCDeferralContext* deferralContext, AllocationFailureMode failureMode)
    61 {
    62     if (Allocator allocator = allocatorForNonVirtual(size, AllocatorForMode::AllocatorIfExists))
    63         return allocator.allocate(deferralContext, failureMode);
    64     return allocateSlow(vm, size, deferralContext, failureMode);
    6558}
    6659
  • trunk/Source/JavaScriptCore/heap/CompleteSubspace.h

    r232074 r232132  
    4444   
    4545    void* allocate(VM&, size_t, GCDeferralContext*, AllocationFailureMode) override;
    46     JS_EXPORT_PRIVATE void* allocateNonVirtual(VM&, size_t, GCDeferralContext*, AllocationFailureMode);
     46    void* allocateNonVirtual(VM&, size_t, GCDeferralContext*, AllocationFailureMode);
    4747   
    4848    static ptrdiff_t offsetOfAllocatorForSizeStep() { return OBJECT_OFFSETOF(CompleteSubspace, m_allocatorForSizeStep); }
     
    5151
    5252private:
    53     Allocator allocatorForSlow(size_t);
     53    JS_EXPORT_PRIVATE Allocator allocatorForSlow(size_t);
    5454   
    5555    // These slow paths are concerned with large allocations and allocator creation.
    56     void* allocateSlow(VM&, size_t, GCDeferralContext*, AllocationFailureMode);
     56    JS_EXPORT_PRIVATE void* allocateSlow(VM&, size_t, GCDeferralContext*, AllocationFailureMode);
    5757    void* tryAllocateSlow(VM&, size_t, GCDeferralContext*);
    5858   
  • trunk/Source/JavaScriptCore/heap/FreeListInlines.h

    r217711 r232132  
    3232
    3333template<typename Func>
    34 HeapCell* FreeList::allocate(const Func& slowPath)
     34ALWAYS_INLINE HeapCell* FreeList::allocate(const Func& slowPath)
    3535{
    3636    unsigned remaining = m_remaining;
  • trunk/Source/JavaScriptCore/heap/IsoSubspace.cpp

    r232074 r232132  
    6464}
    6565
    66 void* IsoSubspace::allocateNonVirtual(VM&, size_t size, GCDeferralContext* deferralContext, AllocationFailureMode failureMode)
    67 {
    68     RELEASE_ASSERT(size == this->size());
    69     Allocator allocator = allocatorForNonVirtual(size, AllocatorForMode::MustAlreadyHaveAllocator);
    70     void* result = allocator.allocate(deferralContext, failureMode);
    71     return result;
    72 }
    73 
    7466void IsoSubspace::didResizeBits(size_t blockIndex)
    7567{
  • trunk/Source/JavaScriptCore/heap/IsoSubspace.h

    r232074 r232132  
    4646
    4747    void* allocate(VM&, size_t, GCDeferralContext*, AllocationFailureMode) override;
    48     JS_EXPORT_PRIVATE void* allocateNonVirtual(VM&, size_t, GCDeferralContext*, AllocationFailureMode);
     48    void* allocateNonVirtual(VM&, size_t, GCDeferralContext*, AllocationFailureMode);
    4949
    5050private:
     
    6262};
    6363
    64 inline Allocator IsoSubspace::allocatorForNonVirtual(size_t size, AllocatorForMode)
     64ALWAYS_INLINE Allocator IsoSubspace::allocatorForNonVirtual(size_t size, AllocatorForMode)
    6565{
    6666    RELEASE_ASSERT(size == this->size());
  • trunk/Source/JavaScriptCore/runtime/JSCellInlines.h

    r232070 r232132  
    2626#pragma once
    2727
     28#include "AllocatorInlines.h"
     29#include "CompleteSubspaceInlines.h"
    2830#include "CPU.h"
    2931#include "CallFrame.h"
    3032#include "DeferGC.h"
     33#include "FreeListInlines.h"
    3134#include "Handle.h"
     35#include "IsoSubspaceInlines.h"
    3236#include "JSCast.h"
    3337#include "JSDestructibleObject.h"
    3438#include "JSObject.h"
    3539#include "JSString.h"
     40#include "LocalAllocatorInlines.h"
    3641#include "MarkedBlock.h"
    3742#include "Structure.h"
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r231337 r232132  
    296296// Vector before performing any concatenation, but by working backwards we likely
    297297// only fill the queue with the number of substrings at any given level in a
    298 // rope-of-ropes.)   
     298// rope-of-ropes.)
    299299void JSRopeString::resolveRopeSlowCase8(LChar* buffer) const
    300300{
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r232074 r232132  
    951951#endif
    952952
    953 void sanitizeStackForVM(VM*);
     953JS_EXPORT_PRIVATE void sanitizeStackForVM(VM*);
    954954void logSanitizeStack(VM*);
    955955
  • trunk/Source/WTF/ChangeLog

    r232122 r232132  
     12018-05-23  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Speed up JetStream/base64
     4        https://bugs.webkit.org/show_bug.cgi?id=185914
     5
     6        Reviewed by Michael Saboff.
     7       
     8        Make Vector<>::append ALWAYS_INLINE.
     9
     10        * wtf/Vector.h:
     11        (WTF::Vector::append):
     12        (WTF::minCapacity>::expandCapacity):
     13        (WTF::minCapacity>::append):
     14        (WTF::minCapacity>::tryAppend):
     15
    1162018-05-23  Michael Saboff  <msaboff@apple.com>
    217
  • trunk/Source/WTF/wtf/Vector.h

    r231565 r232132  
    759759    void clear() { shrinkCapacity(0); }
    760760
    761     void append(ValueType&& value) { append<ValueType>(std::forward<ValueType>(value)); }
     761    ALWAYS_INLINE void append(ValueType&& value) { append<ValueType>(std::forward<ValueType>(value)); }
    762762    template<typename U> void append(U&&);
    763763    template<typename... Args> void constructAndAppend(Args&&...);
     
    10331033
    10341034template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
    1035 T* Vector<T, inlineCapacity, OverflowHandler, minCapacity>::expandCapacity(size_t newMinCapacity, T* ptr)
     1035NEVER_INLINE T* Vector<T, inlineCapacity, OverflowHandler, minCapacity>::expandCapacity(size_t newMinCapacity, T* ptr)
    10361036{
    10371037    if (ptr < begin() || ptr >= end()) {
     
    12451245template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
    12461246template<typename U>
    1247 void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::append(const U* data, size_t dataSize)
     1247ALWAYS_INLINE void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::append(const U* data, size_t dataSize)
    12481248{
    12491249    size_t newSize = m_size + dataSize;
     
    12621262template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
    12631263template<typename U>
    1264 bool Vector<T, inlineCapacity, OverflowHandler, minCapacity>::tryAppend(const U* data, size_t dataSize)
     1264ALWAYS_INLINE bool Vector<T, inlineCapacity, OverflowHandler, minCapacity>::tryAppend(const U* data, size_t dataSize)
    12651265{
    12661266    size_t newSize = m_size + dataSize;
Note: See TracChangeset for help on using the changeset viewer.