55#include  "unixasmmacros.inc" 
66#include  "asmconstants.h" 
77
8+ // On Apple platforms we emit the whole patched region as single function 
9+ // with .alt_entry labels for individual write barrier helpers. This ensures 
10+ // the linker doesn't relocate  or  split the code  and  treats it as single 
11+ // atom. We also need to be careful to produce the correct unwinding 
12+ // information. 
13+ 
14+ // ----------------------------------------------------------------------------- 
15+ // The following Macros help  in  WRITE_BARRIER Implementations 
16+ // WRITE_BARRIER_ENTRY 
17+ // 
18+ // Declare the start of a write barrier function. Use similarly to NESTED_ENTRY. This is the only legal way 
19+ // to declare a write barrier function. 
20+ // 
21+ .macro WRITE_BARRIER_ENTRY name 
22+ #if defined(__APPLE__) 
23+     .text 
24+     .p2align         4 
25+     .alt_entry C_FUNC(\name) 
26+     .private_ extern  C_FUNC(\name) 
27+ C_FUNC(\name): 
28+ #else 
29+     LEAF_ENTRY \name ,  _TEXT 
30+ #endif 
31+ .endm 
32+ 
33+ // WRITE_BARRIER_END 
34+ // 
35+ // The partner to WRITE_BARRIER_ENTRY ,  used like NESTED_END. 
36+ // 
37+ .macro WRITE_BARRIER_END name 
38+ #if defined(__APPLE__) 
39+     .alt_entry C_FUNC(\name\()_End) 
40+     .private_ extern  C_FUNC(\name\()_End) 
41+ C_FUNC(\name\()_End): 
42+     // make sure this symbol gets its own address 
43+      nop 
44+ #else 
45+     LEAF_END_MARKED \name ,  _TEXT 
46+ #endif 
47+ .endm 
48+ 
849// Mark start of the code region th at  we patch  at  runtime 
50+ #if defined(__APPLE__) 
51+     . global  C_FUNC(JIT_PatchedCodeStart) 
52+ C_FUNC(JIT_PatchedCodeStart): 
53+     .cfi_startproc 
54+ #else 
955LEAF_ENTRY JIT_PatchedCodeStart ,  _TEXT 
1056         ret 
1157LEAF_END JIT_PatchedCodeStart ,  _TEXT 
58+ #endif 
1259
1360
1461// There is an even more optimized version of these helpers possible which takes 
@@ -24,7 +71,7 @@ LEAF_END JIT_PatchedCodeStart, _TEXT
2471// it needs to have it's card updated 
2572// 
2673// void JIT_CheckedWriteBarrier(Object **  dst ,  Object *  src) 
27- LEAF_ENTRY_PATCHABLE  JIT_CheckedWriteBarrier,  _TEXT 
74+ WRITE_BARRIER_ENTRY  JIT_CheckedWriteBarrier
2875
2976        // When WRITE_BARRIER_CHECK is defined _NotInHeap will write the reference 
3077        // but if it isn't then it will just return. 
@@ -45,7 +92,7 @@ LEAF_ENTRY_PATCHABLE JIT_CheckedWriteBarrier, _TEXT
4592        // See comment above about possible AV 
4693         mov       [ rdi ],   rsi 
4794         ret 
48- LEAF_END_MARKED  JIT_CheckedWriteBarrier,  _TEXT 
95+ WRITE_BARRIER_END  JIT_CheckedWriteBarrier
4996
5097
5198// This is used by the mechanism to hold either the JIT_WriteBarrier_PreGrow 
@@ -54,7 +101,7 @@ LEAF_END_MARKED JIT_CheckedWriteBarrier, _TEXT
54101// larger of the two functions (JIT_WriteBarrier_PostGrow) to ensure we have created 
55102// enough space to copy th at  code  in . 
56103.balign  16 
57- LEAF_ENTRY_PATCHABLE  JIT_WriteBarrier,  _TEXT 
104+ WRITE_BARRIER_ENTRY  JIT_WriteBarrier
58105#ifdef _DEBUG 
59106        //  In  debug builds ,  this just contains jump to the debug version of the write barrier by default 
60107         jmp  C_FUNC(JIT_WriteBarrier_Debug) 
@@ -237,9 +284,16 @@ LEAF_ENTRY_PATCHABLE JIT_WriteBarrier, _TEXT
237284    // make sure this is bigger than any of the others 
238285    .balign  16 
239286         nop 
240- LEAF_END_MARKED  JIT_WriteBarrier,  _TEXT 
287+ WRITE_BARRIER_END  JIT_WriteBarrier
241288
242289// Mark start of the code region th at  we patch  at  runtime 
243- LEAF_ENTRY_PATCHABLE JIT_PatchedCodeLast ,  _TEXT 
290+ #if defined(__APPLE__) 
291+     .private_ extern  C_FUNC(JIT_PatchedCodeLast) 
292+     .alt_entry C_FUNC(JIT_PatchedCodeLast) 
293+ C_FUNC(JIT_PatchedCodeLast): 
294+     .cfi_endproc 
295+ #else 
296+ LEAF_ENTRY JIT_PatchedCodeLast ,  _TEXT 
244297         ret 
245298LEAF_END JIT_PatchedCodeLast ,  _TEXT 
299+ #endif 
0 commit comments