@@ -48,20 +48,15 @@ int TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode,
48
48
// However, we leave it in the argument list to mirror the prototype for
49
49
// Push/PopCallerSaved().
50
50
51
- #if defined(V8_OS_WIN)
52
- // X18 is excluded from caller-saved register list on Windows ARM64 which
53
- // makes caller-saved registers in odd number. padreg is used accordingly
54
- // to maintain the alignment.
51
+ // X18 is excluded from caller-saved register list on ARM64 which makes
52
+ // caller-saved registers in odd number. padreg is used accordingly to
53
+ // maintain the alignment.
55
54
DCHECK_EQ (list.Count () % 2 , 1 );
56
55
if (exclusion.Is (no_reg)) {
57
56
bytes += kXRegSizeInBits / 8 ;
58
57
} else {
59
58
bytes -= kXRegSizeInBits / 8 ;
60
59
}
61
- #else
62
- DCHECK_EQ (list.Count () % 2 , 0 );
63
- USE (exclusion);
64
- #endif
65
60
66
61
bytes += list.Count () * kXRegSizeInBits / 8 ;
67
62
@@ -77,21 +72,13 @@ int TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode,
77
72
int bytes = 0 ;
78
73
auto list = kCallerSaved ;
79
74
80
- #if defined(V8_OS_WIN)
81
- // X18 is excluded from caller-saved register list on Windows ARM64, use
82
- // padreg accordingly to maintain alignment.
75
+ // X18 is excluded from caller-saved register list on ARM64, use padreg
76
+ // accordingly to maintain alignment.
83
77
if (!exclusion.Is (no_reg)) {
84
78
list.Remove (exclusion);
85
79
} else {
86
80
list.Combine (padreg);
87
81
}
88
- #else
89
- if (!exclusion.Is (no_reg)) {
90
- // Replace the excluded register with padding to maintain alignment.
91
- list.Remove (exclusion);
92
- list.Combine (padreg);
93
- }
94
- #endif
95
82
96
83
DCHECK_EQ (list.Count () % 2 , 0 );
97
84
PushCPURegList (list);
@@ -115,21 +102,13 @@ int TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register exclusion) {
115
102
116
103
auto list = kCallerSaved ;
117
104
118
- #if defined(V8_OS_WIN)
119
- // X18 is excluded from caller-saved register list on Windows ARM64, use
120
- // padreg accordingly to maintain alignment.
105
+ // X18 is excluded from caller-saved register list on ARM64, use padreg
106
+ // accordingly to maintain alignment.
121
107
if (!exclusion.Is (no_reg)) {
122
108
list.Remove (exclusion);
123
109
} else {
124
110
list.Combine (padreg);
125
111
}
126
- #else
127
- if (!exclusion.Is (no_reg)) {
128
- // Replace the excluded register with padding to maintain alignment.
129
- list.Remove (exclusion);
130
- list.Combine (padreg);
131
- }
132
- #endif
133
112
134
113
DCHECK_EQ (list.Count () % 2 , 0 );
135
114
PopCPURegList (list);
@@ -3389,14 +3368,20 @@ void MacroAssembler::Printf(const char * format,
3389
3368
TmpList ()->set_list (0 );
3390
3369
FPTmpList ()->set_list (0 );
3391
3370
3371
+ // x18 is the platform register and is reserved for the use of platform ABIs.
3372
+ // It is not part of the kCallerSaved list, but we add it here anyway to
3373
+ // ensure `reg_list.Count() % 2 == 0` which is required in multiple spots.
3374
+ CPURegList saved_registers = kCallerSaved ;
3375
+ saved_registers.Combine (x18.code ());
3376
+
3392
3377
// Preserve all caller-saved registers as well as NZCV.
3393
3378
// PushCPURegList asserts that the size of each list is a multiple of 16
3394
3379
// bytes.
3395
- PushCPURegList (kCallerSaved );
3380
+ PushCPURegList (saved_registers );
3396
3381
PushCPURegList (kCallerSavedV );
3397
3382
3398
3383
// We can use caller-saved registers as scratch values (except for argN).
3399
- CPURegList tmp_list = kCallerSaved ;
3384
+ CPURegList tmp_list = saved_registers ;
3400
3385
CPURegList fp_tmp_list = kCallerSavedV ;
3401
3386
tmp_list.Remove (arg0, arg1, arg2, arg3);
3402
3387
fp_tmp_list.Remove (arg0, arg1, arg2, arg3);
@@ -3416,7 +3401,8 @@ void MacroAssembler::Printf(const char * format,
3416
3401
// to PrintfNoPreserve as an argument.
3417
3402
Register arg_sp = temps.AcquireX ();
3418
3403
Add (arg_sp, sp,
3419
- kCallerSaved .TotalSizeInBytes () + kCallerSavedV .TotalSizeInBytes ());
3404
+ saved_registers.TotalSizeInBytes () +
3405
+ kCallerSavedV .TotalSizeInBytes ());
3420
3406
if (arg0_sp) arg0 = Register::Create (arg_sp.code (), arg0.SizeInBits ());
3421
3407
if (arg1_sp) arg1 = Register::Create (arg_sp.code (), arg1.SizeInBits ());
3422
3408
if (arg2_sp) arg2 = Register::Create (arg_sp.code (), arg2.SizeInBits ());
@@ -3441,7 +3427,7 @@ void MacroAssembler::Printf(const char * format,
3441
3427
}
3442
3428
3443
3429
PopCPURegList (kCallerSavedV );
3444
- PopCPURegList (kCallerSaved );
3430
+ PopCPURegList (saved_registers );
3445
3431
3446
3432
TmpList ()->set_list (old_tmp_list);
3447
3433
FPTmpList ()->set_list (old_fp_tmp_list);
0 commit comments