MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / JitWriteProtection

Method JitWriteProtection

src/os_macos.cpp:67–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67JitWriteProtection::JitWriteProtection(bool enable) {
68#ifdef __aarch64__
69 // Mimic pthread_jit_write_protect_np(), but save the previous state
70 if (*(volatile char*)0xfffffc10c) {
71 u64 val = enable ? *(volatile u64*)0xfffffc118 : *(volatile u64*)0xfffffc110;
72 u64 prev;
73 asm volatile("mrs %0, s3_6_c15_c1_5" : "=r" (prev) : : );
74 if (prev != val) {
75 _prev = prev;
76 _restore = true;
77 asm volatile("msr s3_6_c15_c1_5, %0\n"
78 "isb"
79 : "+r" (val) : : "memory");
80 return;
81 }
82 }
83 // Already in the required mode, or write protection is not supported
84 _restore = false;
85#endif
86}
87
88JitWriteProtection::~JitWriteProtection() {
89#ifdef __aarch64__

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected