1.1 --- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Thu Nov 05 11:42:42 2015 +0100 1.2 +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Tue May 07 20:38:26 2019 +0000 1.3 @@ -2706,15 +2706,30 @@ 1.4 __ verify_thread(); // G2_thread must be correct 1.5 __ reset_last_Java_frame(); 1.6 1.7 - // Unpack oop result 1.8 + // Unbox oop result, e.g. JNIHandles::resolve value in I0. 1.9 if (ret_type == T_OBJECT || ret_type == T_ARRAY) { 1.10 - Label L; 1.11 - __ addcc(G0, I0, G0); 1.12 - __ brx(Assembler::notZero, true, Assembler::pt, L); 1.13 - __ delayed()->ld_ptr(I0, 0, I0); 1.14 - __ mov(G0, I0); 1.15 - __ bind(L); 1.16 - __ verify_oop(I0); 1.17 + Label done, not_weak; 1.18 + __ br_null(I0, false, Assembler::pn, done); // Use NULL as-is. 1.19 + __ delayed()->andcc(I0, JNIHandles::weak_tag_mask, G0); // Test for jweak 1.20 + __ brx(Assembler::zero, true, Assembler::pt, not_weak); 1.21 + __ delayed()->ld_ptr(I0, 0, I0); // Maybe resolve (untagged) jobject. 1.22 + // Resolve jweak. 1.23 + __ ld_ptr(I0, -JNIHandles::weak_tag_value, I0); 1.24 +#if INCLUDE_ALL_GCS 1.25 + if (UseG1GC) { 1.26 + // Copy to O0 because macro doesn't allow pre_val in input reg. 1.27 + __ mov(I0, O0); 1.28 + __ g1_write_barrier_pre(noreg /* obj */, 1.29 + noreg /* index */, 1.30 + 0 /* offset */, 1.31 + O0 /* pre_val */, 1.32 + G3_scratch /* tmp */, 1.33 + true /* preserve_o_regs */); 1.34 + } 1.35 +#endif // INCLUDE_ALL_GCS 1.36 + __ bind(not_weak); 1.37 + __ verify_oop(I0); 1.38 + __ bind(done); 1.39 } 1.40 1.41 if (!is_critical_native) {