< prev index next >

src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp

Print this page
rev 12692 : 8176100: [REDO][REDO] G1 Needs pre barrier on dereference of weak JNI handles
Reviewed-by:
   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1499   __ set(_thread_in_Java, G3_scratch);
1500   __ st(G3_scratch, thread_state);
1501 
1502   if (CheckJNICalls) {
1503     // clear_pending_jni_exception_check
1504     __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset());
1505   }
1506 
1507   // reset handle block
1508   __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch);
1509   __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
1510 
1511   // If we have an oop result store it where it will be safe for any further gc
1512   // until we return now that we've released the handle it might be protected by
1513 
1514   {
1515     Label no_oop, store_result;
1516 
1517     __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
1518     __ cmp_and_brx_short(G3_scratch, Lscratch, Assembler::notEqual, Assembler::pt, no_oop);
1519     __ addcc(G0, O0, O0);
1520     __ brx(Assembler::notZero, true, Assembler::pt, store_result);     // if result is not NULL:
1521     __ delayed()->ld_ptr(O0, 0, O0);                                   // unbox it
1522     __ mov(G0, O0);
1523 












1524     __ bind(store_result);
1525     // Store it where gc will look for it and result handler expects it.
1526     __ st_ptr(O0, FP, (frame::interpreter_frame_oop_temp_offset*wordSize) + STACK_BIAS);
1527 
1528     __ bind(no_oop);
1529 
1530   }
1531 
1532 
1533   // handle exceptions (exception handling will handle unlocking!)
1534   { Label L;
1535     Address exception_addr(G2_thread, Thread::pending_exception_offset());
1536     __ ld_ptr(exception_addr, Gtemp);
1537     __ br_null_short(Gtemp, Assembler::pt, L);
1538     // Note: This could be handled more efficiently since we know that the native
1539     //       method doesn't have an exception handler. We could directly return
1540     //       to the exception handler for the caller.
1541     __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_pending_exception));
1542     __ should_not_reach_here();
1543     __ bind(L);


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1499   __ set(_thread_in_Java, G3_scratch);
1500   __ st(G3_scratch, thread_state);
1501 
1502   if (CheckJNICalls) {
1503     // clear_pending_jni_exception_check
1504     __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset());
1505   }
1506 
1507   // reset handle block
1508   __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch);
1509   __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
1510 
1511   // If we have an oop result store it where it will be safe for any further gc
1512   // until we return now that we've released the handle it might be protected by
1513 
1514   {
1515     Label no_oop, store_result;
1516 
1517     __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
1518     __ cmp_and_brx_short(G3_scratch, Lscratch, Assembler::notEqual, Assembler::pt, no_oop);
1519     // Unbox oop result, e.g. JNIHandles::resolve value in O0.
1520     __ br_null(O0, false, Assembler::pn, store_result); // Use NULL as-is.
1521     __ delayed()->andcc(O0, JNIHandles::weak_tag_mask, G0); // Test for jweak
1522     __ brx(Assembler::zero, true, Assembler::pt, store_result);
1523     __ delayed()->ld_ptr(O0, 0, O0); // Maybe resolve (untagged) jobject.
1524     // Resolve jweak.
1525     __ ld_ptr(O0, -JNIHandles::weak_tag_value, O0);
1526 #if INCLUDE_ALL_GCS
1527     if (UseG1GC) {
1528       __ g1_write_barrier_pre(noreg /* obj */,
1529                               noreg /* index */,
1530                               0 /* offset */,
1531                               O0 /* pre_val */,
1532                               G3_scratch /* tmp */,
1533                               true /* preserve_o_regs */);
1534     }
1535 #endif // INCLUDE_ALL_GCS
1536     __ bind(store_result);
1537     // Store it where gc will look for it and result handler expects it.
1538     __ st_ptr(O0, FP, (frame::interpreter_frame_oop_temp_offset*wordSize) + STACK_BIAS);
1539 
1540     __ bind(no_oop);
1541 
1542   }
1543 
1544 
1545   // handle exceptions (exception handling will handle unlocking!)
1546   { Label L;
1547     Address exception_addr(G2_thread, Thread::pending_exception_offset());
1548     __ ld_ptr(exception_addr, Gtemp);
1549     __ br_null_short(Gtemp, Assembler::pt, L);
1550     // Note: This could be handled more efficiently since we know that the native
1551     //       method doesn't have an exception handler. We could directly return
1552     //       to the exception handler for the caller.
1553     __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_pending_exception));
1554     __ should_not_reach_here();
1555     __ bind(L);


< prev index next >