Use alignas instead of compiler-specific attributes
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Apr 2018 21:30:03 +0000 (21:30 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Apr 2018 21:30:03 +0000 (21:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183508

Reviewed by Mark Lam.

Source/bmalloc:

Use alignas for g_gigacageBasePtr. We also add reinterpret_cast to fix
compile errors in ARMv7 and MIPS JSCOnly ports.

* bmalloc/Gigacage.cpp:
* bmalloc/Gigacage.h:
(Gigacage::basePtrs):

Source/JavaScriptCore:

Use C++11 alignas specifier. It is portable compared to compiler-specific aligned attributes.

* heap/RegisterState.h:
* jit/JIT.h:
(JSC::JIT::compile): Deleted.
(JSC::JIT::compileGetByVal): Deleted.
(JSC::JIT::compileGetByValWithCachedId): Deleted.
(JSC::JIT::compilePutByVal): Deleted.
(JSC::JIT::compileDirectPutByVal): Deleted.
(JSC::JIT::compilePutByValWithCachedId): Deleted.
(JSC::JIT::compileHasIndexedProperty): Deleted.
(JSC::JIT::appendCall): Deleted.
(JSC::JIT::appendCallWithSlowPathReturnType): Deleted.
(JSC::JIT::exceptionCheck): Deleted.
(JSC::JIT::exceptionCheckWithCallFrameRollback): Deleted.
(JSC::JIT::emitInt32Load): Deleted.
(JSC::JIT::emitInt32GetByVal): Deleted.
(JSC::JIT::emitInt32PutByVal): Deleted.
(JSC::JIT::emitDoublePutByVal): Deleted.
(JSC::JIT::emitContiguousPutByVal): Deleted.
(JSC::JIT::emitStoreCell): Deleted.
(JSC::JIT::getSlowCase): Deleted.
(JSC::JIT::linkSlowCase): Deleted.
(JSC::JIT::linkDummySlowCase): Deleted.
(JSC::JIT::linkAllSlowCases): Deleted.
(JSC::JIT::callOperation): Deleted.
(JSC::JIT::callOperationWithProfile): Deleted.
(JSC::JIT::callOperationWithResult): Deleted.
(JSC::JIT::callOperationNoExceptionCheck): Deleted.
(JSC::JIT::callOperationWithCallFrameRollbackOnException): Deleted.
(JSC::JIT::emitEnterOptimizationCheck): Deleted.
(JSC::JIT::sampleCodeBlock): Deleted.
(JSC::JIT::canBeOptimized): Deleted.
(JSC::JIT::canBeOptimizedOrInlined): Deleted.
(JSC::JIT::shouldEmitProfiling): Deleted.
* runtime/VM.h:

Source/WebCore:

Use alignas instead of aligned.

* platform/graphics/cpu/arm/filters/FELightingNEON.cpp:
* platform/graphics/cpu/arm/filters/FELightingNEON.h:
(WebCore::FELighting::platformApplyNeon):

Source/WTF:

Use alignas for g_gigacageBasePtr. We also add reinterpret_cast to fix
compile errors in ARMv7 and MIPS JSCOnly ports.

* wtf/Gigacage.cpp:
* wtf/Gigacage.h:
(Gigacage::basePtrs):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230380 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/RegisterState.h
Source/JavaScriptCore/jit/JIT.h
Source/JavaScriptCore/runtime/VM.h
Source/WTF/ChangeLog
Source/WTF/wtf/Gigacage.cpp
Source/WTF/wtf/Gigacage.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cpu/arm/filters/FELightingNEON.cpp
Source/WebCore/platform/graphics/cpu/arm/filters/FELightingNEON.h
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/Gigacage.cpp
Source/bmalloc/bmalloc/Gigacage.h

index e510c8b..620c12c 100644 (file)
@@ -1,5 +1,49 @@
 2018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
 
+        Use alignas instead of compiler-specific attributes
+        https://bugs.webkit.org/show_bug.cgi?id=183508
+
+        Reviewed by Mark Lam.
+
+        Use C++11 alignas specifier. It is portable compared to compiler-specific aligned attributes.
+
+        * heap/RegisterState.h:
+        * jit/JIT.h:
+        (JSC::JIT::compile): Deleted.
+        (JSC::JIT::compileGetByVal): Deleted.
+        (JSC::JIT::compileGetByValWithCachedId): Deleted.
+        (JSC::JIT::compilePutByVal): Deleted.
+        (JSC::JIT::compileDirectPutByVal): Deleted.
+        (JSC::JIT::compilePutByValWithCachedId): Deleted.
+        (JSC::JIT::compileHasIndexedProperty): Deleted.
+        (JSC::JIT::appendCall): Deleted.
+        (JSC::JIT::appendCallWithSlowPathReturnType): Deleted.
+        (JSC::JIT::exceptionCheck): Deleted.
+        (JSC::JIT::exceptionCheckWithCallFrameRollback): Deleted.
+        (JSC::JIT::emitInt32Load): Deleted.
+        (JSC::JIT::emitInt32GetByVal): Deleted.
+        (JSC::JIT::emitInt32PutByVal): Deleted.
+        (JSC::JIT::emitDoublePutByVal): Deleted.
+        (JSC::JIT::emitContiguousPutByVal): Deleted.
+        (JSC::JIT::emitStoreCell): Deleted.
+        (JSC::JIT::getSlowCase): Deleted.
+        (JSC::JIT::linkSlowCase): Deleted.
+        (JSC::JIT::linkDummySlowCase): Deleted.
+        (JSC::JIT::linkAllSlowCases): Deleted.
+        (JSC::JIT::callOperation): Deleted.
+        (JSC::JIT::callOperationWithProfile): Deleted.
+        (JSC::JIT::callOperationWithResult): Deleted.
+        (JSC::JIT::callOperationNoExceptionCheck): Deleted.
+        (JSC::JIT::callOperationWithCallFrameRollbackOnException): Deleted.
+        (JSC::JIT::emitEnterOptimizationCheck): Deleted.
+        (JSC::JIT::sampleCodeBlock): Deleted.
+        (JSC::JIT::canBeOptimized): Deleted.
+        (JSC::JIT::canBeOptimizedOrInlined): Deleted.
+        (JSC::JIT::shouldEmitProfiling): Deleted.
+        * runtime/VM.h:
+
+2018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
+
         Unreviewed, follow-up patch for DFG 32bit
         https://bugs.webkit.org/show_bug.cgi?id=183970
 
index 6005a91..3751eb1 100644 (file)
@@ -131,25 +131,20 @@ struct RegisterState {
 #endif // !OS(WINDOWS)
 
 #ifndef ALLOCATE_AND_GET_REGISTER_STATE
-#if COMPILER(GCC_OR_CLANG)
-#define REGISTER_BUFFER_ALIGNMENT __attribute__ ((aligned (sizeof(void*))))
-#else
-#define REGISTER_BUFFER_ALIGNMENT
-#endif
 
-typedef jmp_buf RegisterState;
+using RegisterState = jmp_buf;
 
 // ALLOCATE_AND_GET_REGISTER_STATE() is a macro so that it is always "inlined" even in debug builds.
 #if COMPILER(MSVC)
 #pragma warning(push)
 #pragma warning(disable: 4611)
 #define ALLOCATE_AND_GET_REGISTER_STATE(registers) \
-    RegisterState registers REGISTER_BUFFER_ALIGNMENT; \
+    alignas(void*) RegisterState registers; \
     setjmp(registers)
 #pragma warning(pop)
 #else
 #define ALLOCATE_AND_GET_REGISTER_STATE(registers) \
-    RegisterState registers REGISTER_BUFFER_ALIGNMENT; \
+    alignas(void*) RegisterState registers; \
     setjmp(registers)
 #endif
 #endif // ALLOCATE_AND_GET_REGISTER_STATE
index bb6cf51..5e6f558 100644 (file)
 
 #if ENABLE(JIT)
 
-// We've run into some problems where changing the size of the class JIT leads to
-// performance fluctuations.  Try forcing alignment in an attempt to stabalize this.
-#if COMPILER(GCC_OR_CLANG)
-#define JIT_CLASS_ALIGNMENT __attribute__ ((aligned (32)))
-#else
-#define JIT_CLASS_ALIGNMENT
-#endif
-
 #define ASSERT_JIT_OFFSET(actual, expected) ASSERT_WITH_MESSAGE(actual == expected, "JIT Offset \"%s\" should be %d, not %d.\n", #expected, static_cast<int>(expected), static_cast<int>(actual));
 
 #include "CodeBlock.h"
@@ -176,7 +168,9 @@ namespace JSC {
 
     void ctiPatchCallByReturnAddress(ReturnAddressPtr, FunctionPtr newCalleeFunction);
 
-    class JIT : private JSInterfaceJIT {
+    // We've run into some problems where changing the size of the class JIT leads to
+    // performance fluctuations. Try forcing alignment in an attempt to stabilize this.
+    class alignas(32) JIT : private JSInterfaceJIT {
         friend class JITSlowPathCall;
         friend class JITStubCall;
 
@@ -948,7 +942,7 @@ namespace JSC {
         bool m_shouldEmitProfiling;
         bool m_shouldUseIndexMasking;
         unsigned m_loopOSREntryBytecodeOffset { 0 };
-    } JIT_CLASS_ALIGNMENT;
+    };
 
 } // namespace JSC
 
index 3daa693..030e6d5 100644 (file)
@@ -233,7 +233,7 @@ struct ScratchBuffer {
         double pad; // Make sure m_buffer is double aligned.
     } u;
 #if CPU(MIPS) && (defined WTF_MIPS_ARCH_REV && WTF_MIPS_ARCH_REV == 2)
-    void* m_buffer[0] __attribute__((aligned(8)));
+    alignas(8) void* m_buffer[0];
 #else
     void* m_buffer[0];
 #endif
index 7d112ba..f78fc58 100644 (file)
@@ -1,3 +1,17 @@
+2018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use alignas instead of compiler-specific attributes
+        https://bugs.webkit.org/show_bug.cgi?id=183508
+
+        Reviewed by Mark Lam.
+
+        Use alignas for g_gigacageBasePtr. We also add reinterpret_cast to fix
+        compile errors in ARMv7 and MIPS JSCOnly ports.
+
+        * wtf/Gigacage.cpp:
+        * wtf/Gigacage.h:
+        (Gigacage::basePtrs):
+
 2018-04-06  Saam Barati  <sbarati@apple.com>
 
         bmalloc's tryLargeZeroedMemalignVirtual shouldn't treat the entire virtual size as dirty towards its footprint
index 9a831b6..4fcff74 100644 (file)
@@ -32,7 +32,7 @@
 
 #if defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC
 
-char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE];
+alignas(GIGACAGE_BASE_PTRS_SIZE) char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE];
 
 namespace Gigacage {
 
index 6a772ff..d91c69e 100644 (file)
@@ -34,7 +34,7 @@
 #define GIGACAGE_BASE_PTRS_SIZE 8192
 
 extern "C" {
-extern WTF_EXPORT_PRIVATE char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE];
+alignas(GIGACAGE_BASE_PTRS_SIZE) extern WTF_EXPORT_PRIVATE char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE];
 }
 
 namespace Gigacage {
@@ -94,7 +94,7 @@ ALWAYS_INLINE void*& basePtr(BasePtrs& basePtrs, Kind kind)
 
 ALWAYS_INLINE BasePtrs& basePtrs()
 {
-    return *reinterpret_cast<BasePtrs*>(g_gigacageBasePtrs);
+    return *reinterpret_cast<BasePtrs*>(reinterpret_cast<void*>(g_gigacageBasePtrs));
 }
 
 ALWAYS_INLINE void*& basePtr(Kind kind)
index 2d978ea..7ae5549 100644 (file)
@@ -1,3 +1,16 @@
+2018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use alignas instead of compiler-specific attributes
+        https://bugs.webkit.org/show_bug.cgi?id=183508
+
+        Reviewed by Mark Lam.
+
+        Use alignas instead of aligned.
+
+        * platform/graphics/cpu/arm/filters/FELightingNEON.cpp:
+        * platform/graphics/cpu/arm/filters/FELightingNEON.h:
+        (WebCore::FELighting::platformApplyNeon):
+
 2018-04-08  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [WPE][GTK] Remove applicationDirectoryPath() and sharedResourcePath()
index fe44c62..73e32b8 100644 (file)
@@ -35,7 +35,7 @@ namespace WebCore {
 //   ALPHAX_Q ALPHAY_Q REMAPX_D REMAPY_D
 
 
-static short s_FELightingConstantsForNeon[] __attribute__((__aligned__(16))) = {
+static alignas(16) short s_FELightingConstantsForNeon[] = {
     // Alpha coefficients.
     -2, 1, 0, -1, 2, 1, 0, -1,
     0, -1, -2, -1, 0, 1, 2, 1,
index abb32e5..42af922 100644 (file)
@@ -95,7 +95,7 @@ void neonDrawLighting(FELightingPaintingDataForNeon*);
 
 inline void FELighting::platformApplyNeon(const LightingData& data, const LightSource::PaintingData& paintingData)
 {
-    FELightingFloatArgumentsForNeon floatArguments __attribute__((__aligned__(16)));
+    alignas(16) FELightingFloatArgumentsForNeon floatArguments;
     FELightingPaintingDataForNeon neonData = {
         data.pixels->data(),
         1,
index 094d65e..8279393 100644 (file)
@@ -1,3 +1,17 @@
+2018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use alignas instead of compiler-specific attributes
+        https://bugs.webkit.org/show_bug.cgi?id=183508
+
+        Reviewed by Mark Lam.
+
+        Use alignas for g_gigacageBasePtr. We also add reinterpret_cast to fix
+        compile errors in ARMv7 and MIPS JSCOnly ports.
+
+        * bmalloc/Gigacage.cpp:
+        * bmalloc/Gigacage.h:
+        (Gigacage::basePtrs):
+
 2018-04-06  Saam Barati  <sbarati@apple.com>
 
         bmalloc virtual allocation API should not treat memory it vends as dirty with respect to how it drives the scavenger
index aba100a..4813fe8 100644 (file)
@@ -42,7 +42,7 @@
 // If this were less than 32GB, those OOB accesses could reach outside of the cage.
 #define GIGACAGE_RUNWAY (32llu * 1024 * 1024 * 1024)
 
-char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE] __attribute__((aligned(GIGACAGE_BASE_PTRS_SIZE)));
+alignas(GIGACAGE_BASE_PTRS_SIZE) char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE];
 
 using namespace bmalloc;
 
index bef3af5..38abf6c 100644 (file)
@@ -68,7 +68,7 @@ static_assert(bmalloc::isPowerOfTwo(STRING_GIGACAGE_SIZE), "");
 #define GIGACAGE_BASE_PTRS_SIZE 4096
 #endif
 
-extern "C" BEXPORT char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE] __attribute__((aligned(GIGACAGE_BASE_PTRS_SIZE)));
+extern "C" alignas(GIGACAGE_BASE_PTRS_SIZE) BEXPORT char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE];
 
 namespace Gigacage {
 
@@ -133,7 +133,7 @@ BINLINE void*& basePtr(BasePtrs& basePtrs, Kind kind)
 
 BINLINE BasePtrs& basePtrs()
 {
-    return *reinterpret_cast<BasePtrs*>(g_gigacageBasePtrs);
+    return *reinterpret_cast<BasePtrs*>(reinterpret_cast<void*>(g_gigacageBasePtrs));
 }
 
 BINLINE void*& basePtr(Kind kind)