< prev index next >

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


 283 
 284   builder()->SetInsertPoint(exception);
 285   CreateResetHandleBlock();
 286   stack()->CreatePopFrame(0);
 287   builder()->CreateRet(LLVMValue::jint_constant(0));
 288 
 289   builder()->SetInsertPoint(no_exception);
 290 
 291   // If the result was an oop then unbox it before
 292   // releasing the handle it might be protected by
 293   if (is_returning_oop()) {
 294     BasicBlock *null     = builder()->GetInsertBlock();
 295     BasicBlock *not_null = CreateBlock("not_null");
 296     BasicBlock *merge    = CreateBlock("merge");
 297 
 298     builder()->CreateCondBr(
 299       builder()->CreateICmpNE(result, ConstantPointerNull::get(box_type)),
 300       not_null, merge);
 301 
 302     builder()->SetInsertPoint(not_null);

 303     Value *unboxed_result = builder()->CreateLoad(result);
 304     builder()->CreateBr(merge);
 305 
 306     builder()->SetInsertPoint(merge);
 307     PHINode *phi = builder()->CreatePHI(SharkType::oop_type(), 0, "result");
 308     phi->addIncoming(LLVMValue::null(), null);
 309     phi->addIncoming(unboxed_result, not_null);
 310     result = phi;
 311   }
 312 
 313   // Reset handle block
 314   CreateResetHandleBlock();
 315 
 316   // Unlock if necessary.
 317   if (is_synchronized())
 318     Unimplemented();
 319 
 320   // Unwind and return
 321   Value *result_addr = stack()->CreatePopFrame(type2size[result_type]);
 322   if (result_type != T_VOID) {


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


 283 
 284   builder()->SetInsertPoint(exception);
 285   CreateResetHandleBlock();
 286   stack()->CreatePopFrame(0);
 287   builder()->CreateRet(LLVMValue::jint_constant(0));
 288 
 289   builder()->SetInsertPoint(no_exception);
 290 
 291   // If the result was an oop then unbox it before
 292   // releasing the handle it might be protected by
 293   if (is_returning_oop()) {
 294     BasicBlock *null     = builder()->GetInsertBlock();
 295     BasicBlock *not_null = CreateBlock("not_null");
 296     BasicBlock *merge    = CreateBlock("merge");
 297 
 298     builder()->CreateCondBr(
 299       builder()->CreateICmpNE(result, ConstantPointerNull::get(box_type)),
 300       not_null, merge);
 301 
 302     builder()->SetInsertPoint(not_null);
 303 #error Needs to be updated for tagged jweak; see JNIHandles.
 304     Value *unboxed_result = builder()->CreateLoad(result);
 305     builder()->CreateBr(merge);
 306 
 307     builder()->SetInsertPoint(merge);
 308     PHINode *phi = builder()->CreatePHI(SharkType::oop_type(), 0, "result");
 309     phi->addIncoming(LLVMValue::null(), null);
 310     phi->addIncoming(unboxed_result, not_null);
 311     result = phi;
 312   }
 313 
 314   // Reset handle block
 315   CreateResetHandleBlock();
 316 
 317   // Unlock if necessary.
 318   if (is_synchronized())
 319     Unimplemented();
 320 
 321   // Unwind and return
 322   Value *result_addr = stack()->CreatePopFrame(type2size[result_type]);
 323   if (result_type != T_VOID) {


< prev index next >