< prev index next >

src/share/vm/opto/library_call.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2015, 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  *


3811     }
3812   } // original reexecute is set back here
3813 
3814   C->set_has_split_ifs(true); // Has chance for split-if optimization
3815   if (!stopped()) {
3816     set_result(newcopy);
3817   }
3818   return true;
3819 }
3820 
3821 
3822 //----------------------generate_virtual_guard---------------------------
3823 // Helper for hashCode and clone.  Peeks inside the vtable to avoid a call.
3824 Node* LibraryCallKit::generate_virtual_guard(Node* obj_klass,
3825                                              RegionNode* slow_region) {
3826   ciMethod* method = callee();
3827   int vtable_index = method->vtable_index();
3828   assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index,
3829          "bad index %d", vtable_index);
3830   // Get the Method* out of the appropriate vtable entry.
3831   int entry_offset  = (InstanceKlass::vtable_start_offset() +
3832                      vtable_index*vtableEntry::size()) * wordSize +
3833                      vtableEntry::method_offset_in_bytes();
3834   Node* entry_addr  = basic_plus_adr(obj_klass, entry_offset);
3835   Node* target_call = make_load(NULL, entry_addr, TypePtr::NOTNULL, T_ADDRESS, MemNode::unordered);
3836 
3837   // Compare the target method with the expected method (e.g., Object.hashCode).
3838   const TypePtr* native_call_addr = TypeMetadataPtr::make(method);
3839 
3840   Node* native_call = makecon(native_call_addr);
3841   Node* chk_native  = _gvn.transform(new CmpPNode(target_call, native_call));
3842   Node* test_native = _gvn.transform(new BoolNode(chk_native, BoolTest::ne));
3843 
3844   return generate_slow_guard(test_native, slow_region);
3845 }
3846 
3847 //-----------------------generate_method_call----------------------------
3848 // Use generate_method_call to make a slow-call to the real
3849 // method if the fast path fails.  An alternative would be to
3850 // use a stub like OptoRuntime::slow_arraycopy_Java.
3851 // This only works for expanding the current library call,
3852 // not another intrinsic.  (E.g., don't use this for making an


   1 /*
   2  * Copyright (c) 1999, 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  *


3811     }
3812   } // original reexecute is set back here
3813 
3814   C->set_has_split_ifs(true); // Has chance for split-if optimization
3815   if (!stopped()) {
3816     set_result(newcopy);
3817   }
3818   return true;
3819 }
3820 
3821 
3822 //----------------------generate_virtual_guard---------------------------
3823 // Helper for hashCode and clone.  Peeks inside the vtable to avoid a call.
3824 Node* LibraryCallKit::generate_virtual_guard(Node* obj_klass,
3825                                              RegionNode* slow_region) {
3826   ciMethod* method = callee();
3827   int vtable_index = method->vtable_index();
3828   assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index,
3829          "bad index %d", vtable_index);
3830   // Get the Method* out of the appropriate vtable entry.
3831   int entry_offset  = in_bytes(InstanceKlass::vtable_start_offset()) +
3832                      vtable_index*vtableEntry::size_in_bytes() +
3833                      vtableEntry::method_offset_in_bytes();
3834   Node* entry_addr  = basic_plus_adr(obj_klass, entry_offset);
3835   Node* target_call = make_load(NULL, entry_addr, TypePtr::NOTNULL, T_ADDRESS, MemNode::unordered);
3836 
3837   // Compare the target method with the expected method (e.g., Object.hashCode).
3838   const TypePtr* native_call_addr = TypeMetadataPtr::make(method);
3839 
3840   Node* native_call = makecon(native_call_addr);
3841   Node* chk_native  = _gvn.transform(new CmpPNode(target_call, native_call));
3842   Node* test_native = _gvn.transform(new BoolNode(chk_native, BoolTest::ne));
3843 
3844   return generate_slow_guard(test_native, slow_region);
3845 }
3846 
3847 //-----------------------generate_method_call----------------------------
3848 // Use generate_method_call to make a slow-call to the real
3849 // method if the fast path fails.  An alternative would be to
3850 // use a stub like OptoRuntime::slow_arraycopy_Java.
3851 // This only works for expanding the current library call,
3852 // not another intrinsic.  (E.g., don't use this for making an


< prev index next >