Skip to content

Commit ba594e5

Browse files
committed
Do not modify r18_tls when restoring registers on Windows AArch64
1 parent ffa3599 commit ba594e5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,18 @@ static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registe
301301
__ add(sp, sp, 32 * wordSize);
302302
}
303303

304+
#ifdef _WINDOWS
305+
/*
306+
Do not modify r18_tls when restoring registers on Windows as it is used to
307+
store the pointer to the current thread's TEB (where TLS variables are stored).
308+
See r18_tls comment in register_aarch64.hpp.
309+
*/
310+
__ pop(RegSet::range(r0, r17), sp);
311+
__ ldp(zr, r19, Address(__ post(sp, 2 * wordSize)));
312+
__ pop(RegSet::range(r20, r29), sp);
313+
#else
304314
__ pop(RegSet::range(r0, r29), sp);
315+
#endif
305316
}
306317

307318
static void restore_live_registers_except_r0(StubAssembler* sasm, bool restore_fpu_registers = true) {
@@ -314,8 +325,20 @@ static void restore_live_registers_except_r0(StubAssembler* sasm, bool restore_f
314325
__ add(sp, sp, 32 * wordSize);
315326
}
316327

328+
#ifdef _WINDOWS
329+
/*
330+
Do not modify r18_tls when restoring registers on Windows as it is used to
331+
store the pointer to the current thread's TEB (where TLS variables are stored).
332+
See r18_tls comment in register_aarch64.hpp.
333+
*/
334+
__ ldp(zr, r1, Address(__ post(sp, 2 * wordSize)));
335+
__ pop(RegSet::range(r2, r17), sp);
336+
__ ldp(zr, r19, Address(__ post(sp, 2 * wordSize)));
337+
__ pop(RegSet::range(r20, r29), sp);
338+
#else
317339
__ ldp(zr, r1, Address(__ post(sp, 16)));
318340
__ pop(RegSet::range(r2, r29), sp);
341+
#endif
319342
}
320343

321344

0 commit comments

Comments
 (0)