Changeset 261050 in webkit


Ignore:
Timestamp:
May 2, 2020, 10:03:42 AM (5 years ago)
Author:
mark.lam@apple.com
Message:

Allow Bitmap to use up to a UCPURegister word size for internal bit storage.
https://bugs.webkit.org/show_bug.cgi?id=211328
<rdar://problem/62755865>

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

  • assembler/CPU.h:

Source/WTF:

  1. Moved the definition of CPURegister and UCPURegister down into WTF.
  2. Updated Bitmap so that it will automatically choose the minimal required word size for the number of bits it needs to store. This means the Bitmap can automatically choose a WordType from uint8_t up to UCPURegister. Previously, the WordType is always uint32_t by default.

This should improve perf with use of Bitmap on 64-bit platforms. The size
optimization is necessary to prevent bloat on 64-bit platforms which would have
resulted if we simply set the default to always be UCPURegister.

  • WTF.xcodeproj/project.pbxproj:
  • wtf/Bitmap.h:
  • wtf/CMakeLists.txt:
  • wtf/StdIntExtras.h: Added.
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r261041 r261050  
     12020-05-01  Mark Lam  <mark.lam@apple.com>
     2
     3        Allow Bitmap to use up to a UCPURegister word size for internal bit storage.
     4        https://bugs.webkit.org/show_bug.cgi?id=211328
     5        <rdar://problem/62755865>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        * assembler/CPU.h:
     10
    1112020-05-01  Saam Barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/assembler/CPU.h

    r259320 r261050  
    11/*
    2  * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#include "Options.h"
    2929#include <wtf/NumberOfCores.h>
     30#include <wtf/StdIntExtras.h>
    3031
    3132namespace JSC {
    32 
    33 #if USE(JSVALUE64)
    34 using CPURegister = int64_t;
    35 using UCPURegister = uint64_t;
    36 #else
    37 using CPURegister = int32_t;
    38 using UCPURegister = uint32_t;
    39 #endif
    4033
    4134using UCPUStrictInt32 = UCPURegister;
  • trunk/Source/WTF/ChangeLog

    r261041 r261050  
     12020-05-01  Mark Lam  <mark.lam@apple.com>
     2
     3        Allow Bitmap to use up to a UCPURegister word size for internal bit storage.
     4        https://bugs.webkit.org/show_bug.cgi?id=211328
     5        <rdar://problem/62755865>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        1. Moved the definition of CPURegister and UCPURegister down into WTF.
     10        2. Updated Bitmap so that it will automatically choose the minimal required
     11           word size for the number of bits it needs to store.  This means the Bitmap
     12           can automatically choose a WordType from uint8_t up to UCPURegister.
     13           Previously, the WordType is always uint32_t by default.
     14
     15        This should improve perf with use of Bitmap on 64-bit platforms.  The size
     16        optimization is necessary to prevent bloat on 64-bit platforms which would have
     17        resulted if we simply set the default to always be UCPURegister.
     18
     19        * WTF.xcodeproj/project.pbxproj:
     20        * wtf/Bitmap.h:
     21        * wtf/CMakeLists.txt:
     22        * wtf/StdIntExtras.h: Added.
     23
    1242020-05-01  Saam Barati  <sbarati@apple.com>
    225
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r260882 r261050  
    752752                FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ForbidHeapAllocation.h; sourceTree = "<group>"; };
    753753                FE8925AF1D00DAEC0046907E /* Indenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Indenter.h; sourceTree = "<group>"; };
     754                FE97F6A8245CE5DD00C63FC6 /* StdIntExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdIntExtras.h; sourceTree = "<group>"; };
    754755                FEB6B035201BE0B600B958C1 /* PointerPreparations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerPreparations.h; sourceTree = "<group>"; };
    755756                FEDACD3B1630F83F00C69634 /* StackStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackStats.cpp; sourceTree = "<group>"; };
     
    12351236                                313EDEC9778E49C9BEA91CFC /* StackTrace.cpp */,
    12361237                                EF7D6CD59D8642A8A0DA86AD /* StackTrace.h */,
     1238                                FE97F6A8245CE5DD00C63FC6 /* StdIntExtras.h */,
    12371239                                A8A47311151A825B004123FF /* StdLibExtras.h */,
    12381240                                FF0A436588954F3CB07DBECA /* StdList.h */,
  • trunk/Source/WTF/wtf/Bitmap.h

    r254735 r261050  
    11/*
    2  *  Copyright (C) 2010-2019 Apple Inc. All rights reserved.
     2 *  Copyright (C) 2010-2020 Apple Inc. All rights reserved.
    33 *
    44 *  This library is free software; you can redistribute it and/or
     
    2323#include <wtf/Atomics.h>
    2424#include <wtf/HashFunctions.h>
     25#include <wtf/StdIntExtras.h>
    2526#include <wtf/StdLibExtras.h>
    26 #include <stdint.h>
    2727#include <string.h>
     28#include <type_traits>
    2829
    2930namespace WTF {
    3031
    31 template<size_t bitmapSize, typename WordType = uint32_t>
     32template<size_t size>
     33using BitmapWordType = std::conditional_t<(size <= 32 && sizeof(UCPURegister) > sizeof(uint32_t)), uint32_t, UCPURegister>;
     34
     35template<size_t bitmapSize, typename WordType = BitmapWordType<bitmapSize>>
    3236class Bitmap final {
    3337    WTF_MAKE_FAST_ALLOCATED;
    3438   
    35     static_assert(sizeof(WordType) <= sizeof(unsigned), "WordType must not be bigger than unsigned");
     39    static_assert(sizeof(WordType) <= sizeof(UCPURegister), "WordType must not be bigger than the CPU atomic word size");
    3640public:
    3741    constexpr Bitmap();
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r260882 r261050  
    239239    StackStats.h
    240240    StackTrace.h
     241    StdIntExtras.h
    241242    StdLibExtras.h
    242243    StdList.h
Note: See TracChangeset for help on using the changeset viewer.