@@ -5340,7 +5340,41 @@ bool MacroAssembler::set_klass_decode_mode(address base, int shift, const size_t
53405340 return _klass_decode_mode != KlassDecodeNone;
53415341}
53425342
5343+ static Register pick_different_tmp (Register dst, Register src) {
5344+ auto tmps = RegSet::of (r0, r1, r2) - RegSet::of (src, dst);
5345+ return *tmps.begin ();
5346+ }
5347+
5348+ void MacroAssembler::encode_klass_not_null_for_aot (Register dst, Register src) {
5349+ // we have to load the klass base from the AOT constants area but
5350+ // not the shift because it is not allowed to change
5351+ int shift = CompressedKlassPointers::shift ();
5352+ assert (shift >= 0 && shift <= CompressedKlassPointers::max_shift (), " unexpected compressed klass shift!" );
5353+ if (dst != src) {
5354+ // we can load the base into dst, subtract it formthe src and shift down
5355+ lea (dst, ExternalAddress (CompressedKlassPointers::base_addr ()));
5356+ ldr (dst, dst);
5357+ sub (dst, src, dst);
5358+ lsr (dst, dst, shift);
5359+ } else {
5360+ // we need an extra register in order to load the coop base
5361+ Register tmp = pick_different_tmp (dst, src);
5362+ RegSet regs = RegSet::of (tmp);
5363+ push (regs, sp);
5364+ lea (tmp, ExternalAddress (CompressedKlassPointers::base_addr ()));
5365+ ldr (tmp, tmp);
5366+ sub (dst, src, tmp);
5367+ lsr (dst, dst, shift);
5368+ pop (regs, sp);
5369+ }
5370+ }
5371+
53435372void MacroAssembler::encode_klass_not_null (Register dst, Register src) {
5373+ if (AOTCodeCache::is_on_for_dump ()) {
5374+ encode_klass_not_null_for_aot (dst, src);
5375+ return ;
5376+ }
5377+
53445378 switch (klass_decode_mode ()) {
53455379 case KlassDecodeZero:
53465380 if (CompressedKlassPointers::shift () != 0 ) {
@@ -5377,9 +5411,36 @@ void MacroAssembler::encode_klass_not_null(Register r) {
53775411 encode_klass_not_null (r, r);
53785412}
53795413
5414+ void MacroAssembler::decode_klass_not_null_for_aot (Register dst, Register src) {
5415+ // we have to load the klass base from the AOT constants area but
5416+ // not the shift because it is not allowed to change
5417+ int shift = CompressedKlassPointers::shift ();
5418+ assert (shift >= 0 && shift <= CompressedKlassPointers::max_shift (), " unexpected compressed klass shift!" );
5419+ if (dst != src) {
5420+ // we can load the base into dst then add the offset with a suitable shift
5421+ lea (dst, ExternalAddress (CompressedKlassPointers::base_addr ()));
5422+ ldr (dst, dst);
5423+ add (dst, dst, src, LSL, shift);
5424+ } else {
5425+ // we need an extra register in order to load the coop base
5426+ Register tmp = pick_different_tmp (dst, src);
5427+ RegSet regs = RegSet::of (tmp);
5428+ push (regs, sp);
5429+ lea (tmp, ExternalAddress (CompressedKlassPointers::base_addr ()));
5430+ ldr (tmp, tmp);
5431+ add (dst, tmp, src, LSL, shift);
5432+ pop (regs, sp);
5433+ }
5434+ }
5435+
53805436void MacroAssembler::decode_klass_not_null (Register dst, Register src) {
53815437 assert (UseCompressedClassPointers, " should only be used for compressed headers" );
53825438
5439+ if (AOTCodeCache::is_on_for_dump ()) {
5440+ decode_klass_not_null_for_aot (dst, src);
5441+ return ;
5442+ }
5443+
53835444 switch (klass_decode_mode ()) {
53845445 case KlassDecodeZero:
53855446 if (CompressedKlassPointers::shift () != 0 ) {
@@ -6654,7 +6715,7 @@ void MacroAssembler::get_thread(Register dst) {
66546715 protect_return_address ();
66556716 push (saved_regs, sp);
66566717
6657- mov (lr, CAST_FROM_FN_PTR (address, JavaThread::aarch64_get_thread_helper));
6718+ mov (lr, ExternalAddress ( CAST_FROM_FN_PTR (address, JavaThread::aarch64_get_thread_helper) ));
66586719 blr (lr);
66596720 if (dst != c_rarg0) {
66606721 mov (dst, c_rarg0);
0 commit comments