Skip to content

Commit f69c83a

Browse files
committed
Merge remote-tracking branch 'jdk-sandbox/JEP-391-branch' into HEAD
2 parents 52e45a3 + 8ab282d commit f69c83a

85 files changed

Lines changed: 2519 additions & 86 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp

Lines changed: 163 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@
3838

3939
#define __ _masm->
4040

41+
//describe amount of space in bytes occupied by type on native stack
42+
#ifdef __APPLE__
43+
const int nativeByteSpace = sizeof(jbyte);
44+
const int nativeShortSpace = sizeof(jshort);
45+
const int nativeIntSpace = sizeof(jint);
46+
const int nativeLongSpace = wordSize;
47+
const int nativeFloatSpace = nativeIntSpace;
48+
const int nativeDoubleSpace = nativeLongSpace;
49+
#else
50+
const int nativeByteSpace = wordSize;
51+
const int nativeShortSpace = wordSize;
52+
const int nativeIntSpace = wordSize;
53+
const int nativeLongSpace = wordSize;
54+
const int nativeFloatSpace = nativeIntSpace;
55+
const int nativeDoubleSpace = nativeLongSpace;
56+
#endif
57+
58+
template <typename T>
59+
static inline void store_and_inc(char* &to, T value, int inc_size) {
60+
to = align_up(to, inc_size);
61+
*(T *)to = value;
62+
to = to + inc_size;
63+
}
64+
4165
// Implementation of SignatureHandlerGenerator
4266
Register InterpreterRuntime::SignatureHandlerGenerator::from() { return rlocals; }
4367
Register InterpreterRuntime::SignatureHandlerGenerator::to() { return sp; }
@@ -51,6 +75,95 @@ InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator(
5175
_stack_offset = 0;
5276
}
5377

78+
// On macos/aarch64 native stack is packed, int/float are using only 4 bytes
79+
// on stack. Natural alignment for types are still in place,
80+
// for example double/long should be 8 bytes alligned
81+
82+
void InterpreterRuntime::SignatureHandlerGenerator::pass_byte() {
83+
const Address src(from(), Interpreter::local_offset_in_bytes(offset()));
84+
85+
switch (_num_int_args) {
86+
case 0:
87+
__ ldr(c_rarg1, src);
88+
_num_int_args++;
89+
break;
90+
case 1:
91+
__ ldr(c_rarg2, src);
92+
_num_int_args++;
93+
break;
94+
case 2:
95+
__ ldr(c_rarg3, src);
96+
_num_int_args++;
97+
break;
98+
case 3:
99+
__ ldr(c_rarg4, src);
100+
_num_int_args++;
101+
break;
102+
case 4:
103+
__ ldr(c_rarg5, src);
104+
_num_int_args++;
105+
break;
106+
case 5:
107+
__ ldr(c_rarg6, src);
108+
_num_int_args++;
109+
break;
110+
case 6:
111+
__ ldr(c_rarg7, src);
112+
_num_int_args++;
113+
break;
114+
default:
115+
__ ldrb(r0, src);
116+
__ strb(r0, Address(to(), _stack_offset));
117+
_stack_offset += nativeByteSpace;
118+
119+
_num_int_args++;
120+
break;
121+
}
122+
}
123+
124+
void InterpreterRuntime::SignatureHandlerGenerator::pass_short() {
125+
const Address src(from(), Interpreter::local_offset_in_bytes(offset()));
126+
127+
switch (_num_int_args) {
128+
case 0:
129+
__ ldr(c_rarg1, src);
130+
_num_int_args++;
131+
break;
132+
case 1:
133+
__ ldr(c_rarg2, src);
134+
_num_int_args++;
135+
break;
136+
case 2:
137+
__ ldr(c_rarg3, src);
138+
_num_int_args++;
139+
break;
140+
case 3:
141+
__ ldr(c_rarg4, src);
142+
_num_int_args++;
143+
break;
144+
case 4:
145+
__ ldr(c_rarg5, src);
146+
_num_int_args++;
147+
break;
148+
case 5:
149+
__ ldr(c_rarg6, src);
150+
_num_int_args++;
151+
break;
152+
case 6:
153+
__ ldr(c_rarg7, src);
154+
_num_int_args++;
155+
break;
156+
default:
157+
_stack_offset = align_up(_stack_offset, nativeShortSpace);
158+
__ ldrh(r0, src);
159+
__ strh(r0, Address(to(), _stack_offset));
160+
_stack_offset += nativeShortSpace;
161+
162+
_num_int_args++;
163+
break;
164+
}
165+
}
166+
54167
void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
55168
const Address src(from(), Interpreter::local_offset_in_bytes(offset()));
56169

@@ -84,9 +197,10 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
84197
_num_int_args++;
85198
break;
86199
default:
200+
_stack_offset = align_up(_stack_offset, nativeIntSpace);
87201
__ ldr(r0, src);
88202
__ str(r0, Address(to(), _stack_offset));
89-
_stack_offset += wordSize;
203+
_stack_offset += nativeIntSpace;
90204
_num_int_args++;
91205
break;
92206
}
@@ -125,9 +239,10 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {
125239
_num_int_args++;
126240
break;
127241
default:
242+
_stack_offset = align_up(_stack_offset, nativeLongSpace);
128243
__ ldr(r0, src);
129244
__ str(r0, Address(to(), _stack_offset));
130-
_stack_offset += wordSize;
245+
_stack_offset += nativeLongSpace;
131246
_num_int_args++;
132247
break;
133248
}
@@ -139,9 +254,10 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
139254
if (_num_fp_args < Argument::n_float_register_parameters_c) {
140255
__ ldrs(as_FloatRegister(_num_fp_args++), src);
141256
} else {
257+
_stack_offset = align_up(_stack_offset, nativeFloatSpace);
142258
__ ldrw(r0, src);
143259
__ strw(r0, Address(to(), _stack_offset));
144-
_stack_offset += wordSize;
260+
_stack_offset += nativeFloatSpace;
145261
_num_fp_args++;
146262
}
147263
}
@@ -152,9 +268,10 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {
152268
if (_num_fp_args < Argument::n_float_register_parameters_c) {
153269
__ ldrd(as_FloatRegister(_num_fp_args++), src);
154270
} else {
271+
_stack_offset = align_up(_stack_offset, nativeDoubleSpace);
155272
__ ldr(r0, src);
156273
__ str(r0, Address(to(), _stack_offset));
157-
_stack_offset += wordSize;
274+
_stack_offset += nativeDoubleSpace;
158275
_num_fp_args++;
159276
}
160277
}
@@ -247,6 +364,7 @@ void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {
247364
__ cbnz(temp(), L);
248365
__ mov(r0, zr);
249366
__ bind(L);
367+
_stack_offset = align_up(_stack_offset, wordSize);
250368
__ str(r0, Address(to(), _stack_offset));
251369
_stack_offset += wordSize;
252370
_num_int_args++;
@@ -276,13 +394,45 @@ class SlowSignatureHandler
276394
: public NativeSignatureIterator {
277395
private:
278396
address _from;
279-
intptr_t* _to;
397+
char* _to;
280398
intptr_t* _int_args;
281399
intptr_t* _fp_args;
282400
intptr_t* _fp_identifiers;
283401
unsigned int _num_int_args;
284402
unsigned int _num_fp_args;
285403

404+
405+
virtual void pass_byte()
406+
{
407+
NOT_MACOS(return pass_int();)
408+
jbyte from_obj = *(jbyte *)(_from+Interpreter::local_offset_in_bytes(0));
409+
_from -= Interpreter::stackElementSize;
410+
411+
if (_num_int_args < Argument::n_int_register_parameters_c-1) {
412+
*_int_args++ = from_obj;
413+
_num_int_args++;
414+
} else {
415+
store_and_inc(_to, from_obj, nativeByteSpace);
416+
417+
_num_int_args++;
418+
}
419+
}
420+
421+
virtual void pass_short()
422+
{
423+
NOT_MACOS(return pass_int();)
424+
jshort from_obj = *(jshort *)(_from+Interpreter::local_offset_in_bytes(0));
425+
_from -= Interpreter::stackElementSize;
426+
427+
if (_num_int_args < Argument::n_int_register_parameters_c-1) {
428+
*_int_args++ = from_obj;
429+
_num_int_args++;
430+
} else {
431+
store_and_inc(_to, from_obj, nativeShortSpace);
432+
433+
_num_int_args++;
434+
}
435+
}
286436
virtual void pass_int()
287437
{
288438
jint from_obj = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
@@ -292,7 +442,8 @@ class SlowSignatureHandler
292442
*_int_args++ = from_obj;
293443
_num_int_args++;
294444
} else {
295-
*_to++ = from_obj;
445+
store_and_inc(_to, from_obj, nativeIntSpace);
446+
296447
_num_int_args++;
297448
}
298449
}
@@ -306,7 +457,7 @@ class SlowSignatureHandler
306457
*_int_args++ = from_obj;
307458
_num_int_args++;
308459
} else {
309-
*_to++ = from_obj;
460+
store_and_inc(_to, from_obj, nativeLongSpace);
310461
_num_int_args++;
311462
}
312463
}
@@ -320,7 +471,7 @@ class SlowSignatureHandler
320471
*_int_args++ = (*from_addr == 0) ? NULL : (intptr_t)from_addr;
321472
_num_int_args++;
322473
} else {
323-
*_to++ = (*from_addr == 0) ? NULL : (intptr_t) from_addr;
474+
store_and_inc(_to, (*from_addr == 0) ? (intptr_t)NULL : (intptr_t) from_addr, wordSize);
324475
_num_int_args++;
325476
}
326477
}
@@ -334,7 +485,8 @@ class SlowSignatureHandler
334485
*_fp_args++ = from_obj;
335486
_num_fp_args++;
336487
} else {
337-
*_to++ = from_obj;
488+
store_and_inc(_to, from_obj, nativeFloatSpace);
489+
338490
_num_fp_args++;
339491
}
340492
}
@@ -349,7 +501,7 @@ class SlowSignatureHandler
349501
*_fp_identifiers |= (1ull << _num_fp_args); // mark as double
350502
_num_fp_args++;
351503
} else {
352-
*_to++ = from_obj;
504+
store_and_inc(_to, from_obj, nativeDoubleSpace);
353505
_num_fp_args++;
354506
}
355507
}
@@ -359,7 +511,7 @@ class SlowSignatureHandler
359511
: NativeSignatureIterator(method)
360512
{
361513
_from = from;
362-
_to = to;
514+
_to = (char *)to;
363515

364516
_int_args = to - (method->is_static() ? 16 : 17);
365517
_fp_args = to - 8;

src/hotspot/cpu/aarch64/interpreterRT_aarch64.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class SignatureHandlerGenerator: public NativeSignatureIterator {
3838
unsigned int _num_int_args;
3939
int _stack_offset;
4040

41+
void pass_byte();
42+
void pass_short();
4143
void pass_int();
4244
void pass_long();
4345
void pass_float();

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5243,7 +5243,7 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le
52435243
// aarch64_get_thread_helper() clobbers only r0, r1, and flags.
52445244
//
52455245
void MacroAssembler::get_thread(Register dst) {
5246-
RegSet saved_regs = RegSet::range(r0, r1) + lr - dst;
5246+
RegSet saved_regs = RegSet::range(r0, r1) + BSD_ONLY(RegSet::range(r2, r17)) + lr - dst;
52475247
push(saved_regs, sp);
52485248

52495249
mov(lr, CAST_FROM_FN_PTR(address, JavaThread::aarch64_get_thread_helper));

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,11 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
801801
if (int_args < Argument::n_int_register_parameters_c) {
802802
regs[i].set1(INT_ArgReg[int_args++]->as_VMReg());
803803
} else {
804+
#ifdef __APPLE__
805+
// Less-than word types are stored one after another.
806+
// The code unable to handle this, bailout.
807+
return -1;
808+
#endif
804809
regs[i].set1(VMRegImpl::stack2reg(stk_args));
805810
stk_args += 2;
806811
}
@@ -823,6 +828,11 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
823828
if (fp_args < Argument::n_float_register_parameters_c) {
824829
regs[i].set1(FP_ArgReg[fp_args++]->as_VMReg());
825830
} else {
831+
#ifdef __APPLE__
832+
// Less-than word types are stored one after another.
833+
// The code unable to handle this, bailout.
834+
return -1;
835+
#endif
826836
regs[i].set1(VMRegImpl::stack2reg(stk_args));
827837
stk_args += 2;
828838
}
@@ -1384,6 +1394,10 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
13841394
int out_arg_slots;
13851395
out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
13861396

1397+
if (out_arg_slots < 0) {
1398+
return NULL;
1399+
}
1400+
13871401
// Compute framesize for the wrapper. We need to handlize all oops in
13881402
// incoming registers
13891403

src/hotspot/os/aix/os_aix.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ void os::pd_commit_memory_or_exit(char* addr, size_t size,
19761976
pd_commit_memory_or_exit(addr, size, exec, mesg);
19771977
}
19781978

1979-
bool os::pd_uncommit_memory(char* addr, size_t size) {
1979+
bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) {
19801980
assert(is_aligned_to(addr, os::vm_page_size()),
19811981
"addr " PTR_FORMAT " not aligned to vm_page_size (" PTR_FORMAT ")",
19821982
p2i(addr), os::vm_page_size());
@@ -2053,7 +2053,7 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info
20532053
}
20542054

20552055
// Reserves and attaches a shared memory segment.
2056-
char* os::pd_reserve_memory(size_t bytes) {
2056+
char* os::pd_reserve_memory(size_t bytes, bool executable) {
20572057
// Always round to os::vm_page_size(), which may be larger than 4K.
20582058
bytes = align_up(bytes, os::vm_page_size());
20592059

0 commit comments

Comments
 (0)