Source/JavaScriptCore/ChangeLog

 12018-11-27 Mark Lam <mark.lam@apple.com>
 2
 3 Introducing a ENABLE_SEPARATED_WX_HEAP macro.
 4 https://bugs.webkit.org/show_bug.cgi?id=192013
 5 <rdar://problem/45494310>
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 This makes the code a little more readable.
 10
 11 I put the definition of ENABLE_SEPARATED_WX_HEAP in JSC's config.h instead of
 12 Platform.h because ENABLE_SEPARATED_WX_HEAP is only needed inside JSC. Also,
 13 ENABLE_SEPARATED_WX_HEAP depends on ENABLE(FAST_JIT_PERMISSIONS), which is only
 14 defined for JSC.
 15
 16 * config.h:
 17 * jit/ExecutableAllocator.cpp:
 18 (JSC::FixedVMPoolExecutableAllocator::FixedVMPoolExecutableAllocator):
 19 (JSC::FixedVMPoolExecutableAllocator::initializeSeparatedWXHeaps):
 20 * jit/ExecutableAllocator.h:
 21 (JSC::performJITMemcpy):
 22 * runtime/Options.cpp:
 23 (JSC::recomputeDependentOptions):
 24
1252018-11-26 Caio Lima <ticaiolima@gmail.com>
226
327 Re-introduce op_bitnot
238559

Source/JavaScriptCore/config.h

11/*
2  * Copyright (C) 2006, 2007, 2008, 2013 Apple Inc. All rights reserved.
 2 * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
33 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
44 *
55 * This library is free software; you can redistribute it and/or

3737#endif
3838
3939#include <wtf/DisallowCType.h>
 40
 41#if !defined(ENABLE_SEPARATED_WX_HEAP)
 42#if (!ENABLE(FAST_JIT_PERMISSIONS) || !CPU(ARM64E)) && PLATFORM(IOS_FAMILY) && CPU(ARM64)
 43#define ENABLE_SEPARATED_WX_HEAP 1
 44#else
 45#define ENABLE_SEPARATED_WX_HEAP 0
 46#endif
 47#endif // !defined(ENABLE_SEPARATED_WX_HEAP)
238559

Source/JavaScriptCore/jit/ExecutableAllocator.cpp

@@static const double executablePoolReserv
104104static const double executablePoolReservationFraction = 0.25;
105105#endif
106106
107 #if !ENABLE(FAST_JIT_PERMISSIONS) || !CPU(ARM64E)
 107#if ENABLE(SEPARATED_WX_HEAP)
108108JS_EXPORT_PRIVATE bool useFastPermisionsJITCopy { false };
109109JS_EXPORT_PRIVATE JITWriteSeparateHeapsFunction jitWriteSeparateHeapsFunction;
110110#endif

@@public:
182182 ASSERT(m_reservation.size() == reservationSize);
183183 void* reservationBase = m_reservation.base();
184184
185 #if ENABLE(FAST_JIT_PERMISSIONS) && CPU(ARM64E)
 185#if ENABLE(FAST_JIT_PERMISSIONS) && !ENABLE(SEPARATED_WX_HEAP)
186186 RELEASE_ASSERT(os_thread_self_restrict_rwx_is_supported());
187187 os_thread_self_restrict_rwx_to_rx();
188188
189 #else // not ENABLE(FAST_JIT_PERMISSIONS) or not CPU(ARM64E)
 189#else // not ENABLE(FAST_JIT_PERMISSIONS) or ENABLE(SEPARATED_WX_HEAP)
190190#if ENABLE(FAST_JIT_PERMISSIONS)
191191 if (os_thread_self_restrict_rwx_is_supported()) {
192192 useFastPermisionsJITCopy = true;

@@public:
200200 reservationSize -= pageSize();
201201 initializeSeparatedWXHeaps(m_reservation.base(), pageSize(), reservationBase, reservationSize);
202202 }
203 #endif // not ENABLE(FAST_JIT_PERMISSIONS) or not CPU(ARM64E)
 203#endif // not ENABLE(FAST_JIT_PERMISSIONS) or ENABLE(SEPARATED_WX_HEAP)
204204
205205 addFreshFreeSpace(reservationBase, reservationSize);
206206

@@private:
294294 // Zero out writableAddr to avoid leaking the address of the writable mapping.
295295 memset_s(&writableAddr, sizeof(writableAddr), 0, sizeof(writableAddr));
296296
297 #if !ENABLE(FAST_JIT_PERMISSIONS) || !CPU(ARM64E)
 297#if ENABLE(SEPARATED_WX_HEAP)
298298 jitWriteSeparateHeapsFunction = reinterpret_cast<JITWriteSeparateHeapsFunction>(writeThunk.code().executableAddress());
299299#endif
300300 }
238559

Source/JavaScriptCore/jit/ExecutableAllocator.h

@@T endOfFixedExecutableMemoryPool()
7878
7979JS_EXPORT_PRIVATE bool isJITPC(void* pc);
8080
81 #if !ENABLE(FAST_JIT_PERMISSIONS) || !CPU(ARM64E)
 81#if ENABLE(SEPARATED_WX_HEAP)
8282
8383typedef void (*JITWriteSeparateHeapsFunction)(off_t, const void*, size_t);
8484extern JS_EXPORT_PRIVATE JITWriteSeparateHeapsFunction jitWriteSeparateHeapsFunction;
8585extern JS_EXPORT_PRIVATE bool useFastPermisionsJITCopy;
8686
87 #endif // !ENABLE(FAST_JIT_PERMISSIONS) || !CPU(ARM64E)
 87#endif // ENABLE(SEPARATED_WX_HEAP)
8888
8989static inline void* performJITMemcpy(void *dst, const void *src, size_t n)
9090{

@@static inline void* performJITMemcpy(voi
9696 if (isJITPC(dst)) {
9797 RELEASE_ASSERT(reinterpret_cast<uint8_t*>(dst) + n <= endOfFixedExecutableMemoryPool());
9898#if ENABLE(FAST_JIT_PERMISSIONS)
99 #if !CPU(ARM64E)
 99#if ENABLE(SEPARATED_WX_HEAP)
100100 if (useFastPermisionsJITCopy)
101101#endif
102102 {

@@static inline void* performJITMemcpy(voi
107107 }
108108#endif // ENABLE(FAST_JIT_PERMISSIONS)
109109
110 #if !ENABLE(FAST_JIT_PERMISSIONS) || !CPU(ARM64E)
 110#if ENABLE(SEPARATED_WX_HEAP)
111111 if (jitWriteSeparateHeapsFunction) {
112112 // Use execute-only write thunk for writes inside the JIT region. This is a variant of
113113 // memcpy that takes an offset into the JIT region as its destination (first) parameter.
238559

Source/JavaScriptCore/runtime/Options.cpp

@@static void recomputeDependentOptions()
468468 Options::useOSREntryToFTL() = false;
469469 }
470470
471 #if PLATFORM(IOS_FAMILY) && CPU(ARM64) && !CPU(ARM64E)
 471#if ENABLE(SEPARATED_WX_HEAP)
472472 // Override globally for now. Longer term we'll just make the default
473473 // be to have this option enabled, and have platforms that don't support
474474 // it just silently use a single mapping.
238559