< prev index next >

src/cpu/ppc/vm/templateTable_ppc_64.cpp

Print this page
rev 12861 : ppc64 addons for 8171392: make contant pool read-only
   1 /*
   2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2013, 2016 SAP SE. All rights reserved.
   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.
  23  *


3643   const bool allow_shared_alloc = Universe::heap()->supports_inline_contig_alloc();
3644 
3645   // --------------------------------------------------------------------------
3646   // Check if fast case is possible.
3647 
3648   // Load pointers to const pool and const pool's tags array.
3649   __ get_cpool_and_tags(Rcpool, Rtags);
3650   // Load index of constant pool entry.
3651   __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
3652 
3653   if (UseTLAB) {
3654     // Make sure the class we're about to instantiate has been resolved
3655     // This is done before loading instanceKlass to be consistent with the order
3656     // how Constant Pool is updated (see ConstantPoolCache::klass_at_put).
3657     __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3658     __ lbzx(Rtags, Rindex, Rtags);
3659 
3660     __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3661     __ bne(CCR0, Lslow_case);
3662 
3663     // Get instanceKlass (load from Rcpool + sizeof(ConstantPool) + Rindex*BytesPerWord).
3664     __ sldi(Roffset, Rindex, LogBytesPerWord);
3665     __ addi(Rscratch, Rcpool, sizeof(ConstantPool));
3666     __ isync(); // Order load of instance Klass wrt. tags.
3667     __ ldx(RinstanceKlass, Roffset, Rscratch);
3668 
3669     // Make sure klass is fully initialized and get instance_size.
3670     __ lbz(Rscratch, in_bytes(InstanceKlass::init_state_offset()), RinstanceKlass);
3671     __ lwz(Rinstance_size, in_bytes(Klass::layout_helper_offset()), RinstanceKlass);
3672 
3673     __ cmpdi(CCR1, Rscratch, InstanceKlass::fully_initialized);
3674     // Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class.
3675     __ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0?
3676 
3677     __ crnand(CCR0, Assembler::equal, CCR1, Assembler::equal); // slow path bit set or not fully initialized?
3678     __ beq(CCR0, Lslow_case);
3679 
3680     // --------------------------------------------------------------------------
3681     // Fast case:
3682     // Allocate the instance.
3683     // 1) Try to allocate in the TLAB.
3684     // 2) If fail, and the TLAB is not full enough to discard, allocate in the shared Eden.
3685     // 3) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
3686 
3687     Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits.


3858   __ get_cpool_and_tags(Rcpool, Rtags);
3859 
3860   __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
3861 
3862   __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3863   __ lbzx(Rtags, Rtags, Roffset);
3864 
3865   __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3866   __ beq(CCR0, Lquicked);
3867 
3868   // Call into the VM to "quicken" instanceof.
3869   __ push_ptr();  // for GC
3870   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3871   __ get_vm_result_2(RspecifiedKlass);
3872   __ pop_ptr();   // Restore receiver.
3873   __ b(Lresolved);
3874 
3875   // Extract target class from constant pool.
3876   __ bind(Lquicked);
3877   __ sldi(Roffset, Roffset, LogBytesPerWord);
3878   __ addi(Rcpool, Rcpool, sizeof(ConstantPool));
3879   __ isync(); // Order load of specified Klass wrt. tags.
3880   __ ldx(RspecifiedKlass, Rcpool, Roffset);
3881 
3882   // Do the checkcast.
3883   __ bind(Lresolved);
3884   // Get value klass in RobjKlass.
3885   __ load_klass(RobjKlass, R17_tos);
3886   // Generate a fast subtype check. Branch to cast_ok if no failure. Return 0 if failure.
3887   __ gen_subtype_check(RobjKlass, RspecifiedKlass, /*3 temp regs*/ Roffset, Rcpool, Rtags, /*target if subtype*/ Ldone);
3888 
3889   // Not a subtype; so must throw exception
3890   // Target class oop is in register R6_ARG4 == RspecifiedKlass by convention.
3891   __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ClassCastException_entry);
3892   __ mtctr(R11_scratch1);
3893   __ bctr();
3894 
3895   // Profile the null case.
3896   __ align(32, 12);
3897   __ bind(Lis_null);
3898   __ profile_null_seen(R11_scratch1, Rtags); // Rtags used as scratch.
3899 
3900   __ align(32, 12);


3922   __ get_cpool_and_tags(Rcpool, Rtags);
3923 
3924   __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
3925 
3926   __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3927   __ lbzx(Rtags, Rtags, Roffset);
3928 
3929   __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3930   __ beq(CCR0, Lquicked);
3931 
3932   // Call into the VM to "quicken" instanceof.
3933   __ push_ptr();  // for GC
3934   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3935   __ get_vm_result_2(RspecifiedKlass);
3936   __ pop_ptr();   // Restore receiver.
3937   __ b(Lresolved);
3938 
3939   // Extract target class from constant pool.
3940   __ bind(Lquicked);
3941   __ sldi(Roffset, Roffset, LogBytesPerWord);
3942   __ addi(Rcpool, Rcpool, sizeof(ConstantPool));
3943   __ isync(); // Order load of specified Klass wrt. tags.
3944   __ ldx(RspecifiedKlass, Rcpool, Roffset);
3945 
3946   // Do the checkcast.
3947   __ bind(Lresolved);
3948   // Get value klass in RobjKlass.
3949   __ load_klass(RobjKlass, R17_tos);
3950   // Generate a fast subtype check. Branch to cast_ok if no failure. Return 0 if failure.
3951   __ li(R17_tos, 1);
3952   __ gen_subtype_check(RobjKlass, RspecifiedKlass, /*3 temp regs*/ Roffset, Rcpool, Rtags, /*target if subtype*/ Ldone);
3953   __ li(R17_tos, 0);
3954 
3955   if (ProfileInterpreter) {
3956     __ b(Ldone);
3957   }
3958 
3959   // Profile the null case.
3960   __ align(32, 12);
3961   __ bind(Lis_null);
3962   __ profile_null_seen(Rcpool, Rtags); // Rcpool and Rtags used as scratch.
3963 
3964   __ align(32, 12);


   1 /*
   2  * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2013, 2017 SAP SE. All rights reserved.
   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.
  23  *


3643   const bool allow_shared_alloc = Universe::heap()->supports_inline_contig_alloc();
3644 
3645   // --------------------------------------------------------------------------
3646   // Check if fast case is possible.
3647 
3648   // Load pointers to const pool and const pool's tags array.
3649   __ get_cpool_and_tags(Rcpool, Rtags);
3650   // Load index of constant pool entry.
3651   __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
3652 
3653   if (UseTLAB) {
3654     // Make sure the class we're about to instantiate has been resolved
3655     // This is done before loading instanceKlass to be consistent with the order
3656     // how Constant Pool is updated (see ConstantPoolCache::klass_at_put).
3657     __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3658     __ lbzx(Rtags, Rindex, Rtags);
3659 
3660     __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3661     __ bne(CCR0, Lslow_case);
3662 
3663     // Get instanceKlass
3664     __ sldi(Roffset, Rindex, LogBytesPerWord);
3665     __ load_resolved_klass_at_offset(Rcpool, Roffset, RinstanceKlass);


3666 
3667     // Make sure klass is fully initialized and get instance_size.
3668     __ lbz(Rscratch, in_bytes(InstanceKlass::init_state_offset()), RinstanceKlass);
3669     __ lwz(Rinstance_size, in_bytes(Klass::layout_helper_offset()), RinstanceKlass);
3670 
3671     __ cmpdi(CCR1, Rscratch, InstanceKlass::fully_initialized);
3672     // Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class.
3673     __ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0?
3674 
3675     __ crnand(CCR0, Assembler::equal, CCR1, Assembler::equal); // slow path bit set or not fully initialized?
3676     __ beq(CCR0, Lslow_case);
3677 
3678     // --------------------------------------------------------------------------
3679     // Fast case:
3680     // Allocate the instance.
3681     // 1) Try to allocate in the TLAB.
3682     // 2) If fail, and the TLAB is not full enough to discard, allocate in the shared Eden.
3683     // 3) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
3684 
3685     Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits.


3856   __ get_cpool_and_tags(Rcpool, Rtags);
3857 
3858   __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
3859 
3860   __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3861   __ lbzx(Rtags, Rtags, Roffset);
3862 
3863   __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3864   __ beq(CCR0, Lquicked);
3865 
3866   // Call into the VM to "quicken" instanceof.
3867   __ push_ptr();  // for GC
3868   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3869   __ get_vm_result_2(RspecifiedKlass);
3870   __ pop_ptr();   // Restore receiver.
3871   __ b(Lresolved);
3872 
3873   // Extract target class from constant pool.
3874   __ bind(Lquicked);
3875   __ sldi(Roffset, Roffset, LogBytesPerWord);
3876   __ load_resolved_klass_at_offset(Rcpool, Roffset, RspecifiedKlass);


3877 
3878   // Do the checkcast.
3879   __ bind(Lresolved);
3880   // Get value klass in RobjKlass.
3881   __ load_klass(RobjKlass, R17_tos);
3882   // Generate a fast subtype check. Branch to cast_ok if no failure. Return 0 if failure.
3883   __ gen_subtype_check(RobjKlass, RspecifiedKlass, /*3 temp regs*/ Roffset, Rcpool, Rtags, /*target if subtype*/ Ldone);
3884 
3885   // Not a subtype; so must throw exception
3886   // Target class oop is in register R6_ARG4 == RspecifiedKlass by convention.
3887   __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ClassCastException_entry);
3888   __ mtctr(R11_scratch1);
3889   __ bctr();
3890 
3891   // Profile the null case.
3892   __ align(32, 12);
3893   __ bind(Lis_null);
3894   __ profile_null_seen(R11_scratch1, Rtags); // Rtags used as scratch.
3895 
3896   __ align(32, 12);


3918   __ get_cpool_and_tags(Rcpool, Rtags);
3919 
3920   __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
3921 
3922   __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3923   __ lbzx(Rtags, Rtags, Roffset);
3924 
3925   __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3926   __ beq(CCR0, Lquicked);
3927 
3928   // Call into the VM to "quicken" instanceof.
3929   __ push_ptr();  // for GC
3930   call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3931   __ get_vm_result_2(RspecifiedKlass);
3932   __ pop_ptr();   // Restore receiver.
3933   __ b(Lresolved);
3934 
3935   // Extract target class from constant pool.
3936   __ bind(Lquicked);
3937   __ sldi(Roffset, Roffset, LogBytesPerWord);
3938   __ load_resolved_klass_at_offset(Rcpool, Roffset, RspecifiedKlass);


3939 
3940   // Do the checkcast.
3941   __ bind(Lresolved);
3942   // Get value klass in RobjKlass.
3943   __ load_klass(RobjKlass, R17_tos);
3944   // Generate a fast subtype check. Branch to cast_ok if no failure. Return 0 if failure.
3945   __ li(R17_tos, 1);
3946   __ gen_subtype_check(RobjKlass, RspecifiedKlass, /*3 temp regs*/ Roffset, Rcpool, Rtags, /*target if subtype*/ Ldone);
3947   __ li(R17_tos, 0);
3948 
3949   if (ProfileInterpreter) {
3950     __ b(Ldone);
3951   }
3952 
3953   // Profile the null case.
3954   __ align(32, 12);
3955   __ bind(Lis_null);
3956   __ profile_null_seen(Rcpool, Rtags); // Rcpool and Rtags used as scratch.
3957 
3958   __ align(32, 12);


< prev index next >