Changeset 247281 in webkit


Ignore:
Timestamp:
Jul 9, 2019 2:49:21 PM (5 years ago)
Author:
commit-queue@webkit.org
Message:

WKObject's minimum object alignment needs to be larger
https://bugs.webkit.org/show_bug.cgi?id=199523

Patch by Saagar Jha <saagarjha@apple.com> on 2019-07-09
Reviewed by Alex Christensen.

WKObject's wrapped objects are currently constructed at addresses aligned to 8-byte boundaries, but some
classes have more stringent requirements. By querying std::aligned_storage for the alignment of an object
larger than anything we can construct, we should be able to satisfy alignment for any of WebKit's types.

  • Shared/Cocoa/APIObject.mm: Use std::aligned_storage in conjunction with alignof to determine

minimumObjectAlignment, instead of hardcoding 8.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r247280 r247281  
     12019-07-09  Saagar Jha  <saagarjha@apple.com>
     2
     3        WKObject's minimum object alignment needs to be larger
     4        https://bugs.webkit.org/show_bug.cgi?id=199523
     5
     6        Reviewed by Alex Christensen.
     7
     8        WKObject's wrapped objects are currently constructed at addresses aligned to 8-byte boundaries, but some
     9        classes have more stringent requirements. By querying std::aligned_storage for the alignment of an object
     10        larger than anything we can construct, we should be able to satisfy alignment for any of WebKit's types.
     11
     12        * Shared/Cocoa/APIObject.mm: Use std::aligned_storage in conjunction with alignof to determine
     13        minimumObjectAlignment, instead of hardcoding 8.
     14
    1152019-07-09  Megan Gardner  <megan_gardner@apple.com>
    216
  • trunk/Source/WebKit/Shared/Cocoa/APIObject.mm

    r246224 r247281  
    9191#endif
    9292
    93 static const size_t minimumObjectAlignment = 8;
     93static const size_t minimumObjectAlignment = alignof(std::aligned_storage<std::numeric_limits<size_t>::max()>::type);
    9494static_assert(minimumObjectAlignment >= alignof(void*), "Objects should always be at least pointer-aligned.");
    9595static const size_t maximumExtraSpaceForAlignment = minimumObjectAlignment - alignof(void*);
Note: See TracChangeset for help on using the changeset viewer.