mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-24 19:40:28 +00:00
Improve dlopen() on Apple Silicon
- Introduce MAP_JIT which is zero on other platforms - Invent __jit_begin() and __jit_end() which wrap Apple's APIs - Runtime dispatch to sys_icache_invalidate() in __clear_cache()
This commit is contained in:
parent
7a9e176ecf
commit
529cb4817c
20 changed files with 120 additions and 117 deletions
37
libc/runtime/jit.c
Normal file
37
libc/runtime/jit.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/syslib.internal.h"
|
||||
|
||||
void __jit_begin(void) {
|
||||
if (IsXnuSilicon()) {
|
||||
if (__syslib->__pthread_jit_write_protect_supported_np()) {
|
||||
__syslib->__pthread_jit_write_protect_np(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __jit_end(void) {
|
||||
if (IsXnuSilicon()) {
|
||||
if (__syslib->__pthread_jit_write_protect_supported_np()) {
|
||||
__syslib->__pthread_jit_write_protect_np(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -115,6 +115,8 @@ bool32 _isheap(void *);
|
|||
/* code morphing */
|
||||
void __morph_begin(void);
|
||||
void __morph_end(void);
|
||||
void __jit_begin(void);
|
||||
void __jit_end(void);
|
||||
void __clear_cache(void *, void *);
|
||||
/* portability */
|
||||
int NtGetVersion(void) pureconst;
|
||||
|
|
|
@ -45,6 +45,7 @@ LIBC_RUNTIME_A_DIRECTDEPS = \
|
|||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_SYSV_CALLS \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
THIRD_PARTY_NSYNC \
|
||||
THIRD_PARTY_PUFF \
|
||||
THIRD_PARTY_XED
|
||||
|
|
|
@ -12,7 +12,7 @@ COSMOPOLITAN_C_START_
|
|||
*/
|
||||
|
||||
#define SYSLIB_MAGIC ('s' | 'l' << 8 | 'i' << 16 | 'b' << 24)
|
||||
#define SYSLIB_VERSION 6
|
||||
#define SYSLIB_VERSION 8
|
||||
|
||||
typedef uint64_t dispatch_time_t;
|
||||
typedef uint64_t dispatch_semaphore_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue