1 /*
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 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 *
3691 Label slow_case;
3692 Label done;
3693 Label initialize_header;
3694 Label initialize_object; // Including clearing the fields.
3695 Label allocate_shared;
3696
3697 BLOCK_COMMENT("TemplateTable::_new {");
3698 __ get_2_byte_integer_at_bcp(offset/*dest*/, 1, InterpreterMacroAssembler::Unsigned);
3699 __ get_cpool_and_tags(cpool, tags);
3700 // Make sure the class we're about to instantiate has been resolved.
3701 // This is done before loading InstanceKlass to be consistent with the order
3702 // how Constant Pool is updated (see ConstantPool::klass_at_put).
3703 const int tags_offset = Array<u1>::base_offset_in_bytes();
3704 __ load_address(tmp, Address(tags, offset, tags_offset));
3705 __ z_cli(0, tmp, JVM_CONSTANT_Class);
3706 __ z_brne(slow_case);
3707
3708 __ z_sllg(offset, offset, LogBytesPerWord); // Convert to to offset.
3709 // Get InstanceKlass.
3710 Register iklass = cpool;
3711 __ z_lg(iklass, Address(cpool, offset, sizeof(ConstantPool)));
3712
3713 // Make sure klass is initialized & doesn't have finalizer.
3714 // Make sure klass is fully initialized.
3715 const int state_offset = in_bytes(InstanceKlass::init_state_offset());
3716 if (Immediate::is_uimm12(state_offset)) {
3717 __ z_cli(state_offset, iklass, InstanceKlass::fully_initialized);
3718 } else {
3719 __ z_cliy(state_offset, iklass, InstanceKlass::fully_initialized);
3720 }
3721 __ z_brne(slow_case);
3722
3723 // Get instance_size in InstanceKlass (scaled to a count of bytes).
3724 Register Rsize = offset;
3725 const int mask = 1 << Klass::_lh_instance_slow_path_bit;
3726 __ z_llgf(Rsize, Address(iklass, Klass::layout_helper_offset()));
3727 __ z_tmll(Rsize, mask);
3728 __ z_btrue(slow_case);
3729
3730 // Allocate the instance
3731 // 1) Try to allocate in the TLAB.
3878 Address(tags, index, Array<u1>::base_offset_in_bytes()));
3879 __ compareU64_and_branch(Z_R0_scratch, JVM_CONSTANT_Class,
3880 Assembler::bcondEqual, quicked);
3881
3882 __ push(atos); // Save receiver for result, and for GC.
3883 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3884 __ get_vm_result_2(Z_tos);
3885
3886 Register receiver = Z_ARG4;
3887 Register klass = Z_tos;
3888 Register subklass = Z_ARG5;
3889
3890 __ pop_ptr(receiver); // restore receiver
3891 __ z_bru(resolved);
3892
3893 // Get superklass in klass and subklass in subklass.
3894 __ bind(quicked);
3895
3896 __ z_lgr(Z_ARG4, Z_tos); // Save receiver.
3897 __ z_sllg(index, index, LogBytesPerWord); // index2bytes for addressing
3898 __ mem2reg_opt(klass, Address(cpool, index, sizeof(ConstantPool)));
3899
3900 __ bind(resolved);
3901
3902 __ load_klass(subklass, receiver);
3903
3904 // Generate subtype check. Object in receiver.
3905 // Superklass in klass. Subklass in subklass.
3906 __ gen_subtype_check(subklass, klass, Z_ARG3, Z_tmp_1, ok_is_subtype);
3907
3908 // Come here on failure.
3909 __ push_ptr(receiver);
3910 // Object is at TOS, target klass oop expected in rax by convention.
3911 __ z_brul((address) Interpreter::_throw_ClassCastException_entry);
3912
3913 // Come here on success.
3914 __ bind(ok_is_subtype);
3915
3916 __ z_lgr(Z_tos, receiver); // Restore object.
3917
3918 // Collect counts on whether this test sees NULLs a lot or not.
3952 __ compareU64_and_branch(Z_R0_scratch, JVM_CONSTANT_Class, Assembler::bcondEqual, quicked);
3953
3954 __ push(atos); // Save receiver for result, and for GC.
3955 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3956 __ get_vm_result_2(Z_tos);
3957
3958 Register receiver = Z_tmp_2;
3959 Register klass = Z_tos;
3960 Register subklass = Z_tmp_2;
3961
3962 __ pop_ptr(receiver); // Restore receiver.
3963 __ verify_oop(receiver);
3964 __ load_klass(subklass, subklass);
3965 __ z_bru(resolved);
3966
3967 // Get superklass in klass and subklass in subklass.
3968 __ bind(quicked);
3969
3970 __ load_klass(subklass, Z_tos);
3971 __ z_sllg(index, index, LogBytesPerWord); // index2bytes for addressing
3972 __ mem2reg_opt(klass,
3973 Address(cpool, index, sizeof(ConstantPool)));
3974
3975 __ bind(resolved);
3976
3977 // Generate subtype check.
3978 // Superklass in klass. Subklass in subklass.
3979 __ gen_subtype_check(subklass, klass, Z_ARG4, Z_ARG5, ok_is_subtype);
3980
3981 // Come here on failure.
3982 __ clear_reg(Z_tos, true, false);
3983 __ z_bru(done);
3984
3985 // Come here on success.
3986 __ bind(ok_is_subtype);
3987 __ load_const_optimized(Z_tos, 1);
3988
3989 // Collect counts on whether this test sees NULLs a lot or not.
3990 if (ProfileInterpreter) {
3991 __ z_bru(done);
3992 __ bind(is_null);
3993 __ profile_null_seen(Z_tmp_1);
|
1 /*
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 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 *
3691 Label slow_case;
3692 Label done;
3693 Label initialize_header;
3694 Label initialize_object; // Including clearing the fields.
3695 Label allocate_shared;
3696
3697 BLOCK_COMMENT("TemplateTable::_new {");
3698 __ get_2_byte_integer_at_bcp(offset/*dest*/, 1, InterpreterMacroAssembler::Unsigned);
3699 __ get_cpool_and_tags(cpool, tags);
3700 // Make sure the class we're about to instantiate has been resolved.
3701 // This is done before loading InstanceKlass to be consistent with the order
3702 // how Constant Pool is updated (see ConstantPool::klass_at_put).
3703 const int tags_offset = Array<u1>::base_offset_in_bytes();
3704 __ load_address(tmp, Address(tags, offset, tags_offset));
3705 __ z_cli(0, tmp, JVM_CONSTANT_Class);
3706 __ z_brne(slow_case);
3707
3708 __ z_sllg(offset, offset, LogBytesPerWord); // Convert to to offset.
3709 // Get InstanceKlass.
3710 Register iklass = cpool;
3711 __ load_resolved_klass_at_offset(cpool, offset, iklass);
3712
3713 // Make sure klass is initialized & doesn't have finalizer.
3714 // Make sure klass is fully initialized.
3715 const int state_offset = in_bytes(InstanceKlass::init_state_offset());
3716 if (Immediate::is_uimm12(state_offset)) {
3717 __ z_cli(state_offset, iklass, InstanceKlass::fully_initialized);
3718 } else {
3719 __ z_cliy(state_offset, iklass, InstanceKlass::fully_initialized);
3720 }
3721 __ z_brne(slow_case);
3722
3723 // Get instance_size in InstanceKlass (scaled to a count of bytes).
3724 Register Rsize = offset;
3725 const int mask = 1 << Klass::_lh_instance_slow_path_bit;
3726 __ z_llgf(Rsize, Address(iklass, Klass::layout_helper_offset()));
3727 __ z_tmll(Rsize, mask);
3728 __ z_btrue(slow_case);
3729
3730 // Allocate the instance
3731 // 1) Try to allocate in the TLAB.
3878 Address(tags, index, Array<u1>::base_offset_in_bytes()));
3879 __ compareU64_and_branch(Z_R0_scratch, JVM_CONSTANT_Class,
3880 Assembler::bcondEqual, quicked);
3881
3882 __ push(atos); // Save receiver for result, and for GC.
3883 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3884 __ get_vm_result_2(Z_tos);
3885
3886 Register receiver = Z_ARG4;
3887 Register klass = Z_tos;
3888 Register subklass = Z_ARG5;
3889
3890 __ pop_ptr(receiver); // restore receiver
3891 __ z_bru(resolved);
3892
3893 // Get superklass in klass and subklass in subklass.
3894 __ bind(quicked);
3895
3896 __ z_lgr(Z_ARG4, Z_tos); // Save receiver.
3897 __ z_sllg(index, index, LogBytesPerWord); // index2bytes for addressing
3898 __ load_resolved_klass_at_offset(cpool, index, klass);
3899
3900 __ bind(resolved);
3901
3902 __ load_klass(subklass, receiver);
3903
3904 // Generate subtype check. Object in receiver.
3905 // Superklass in klass. Subklass in subklass.
3906 __ gen_subtype_check(subklass, klass, Z_ARG3, Z_tmp_1, ok_is_subtype);
3907
3908 // Come here on failure.
3909 __ push_ptr(receiver);
3910 // Object is at TOS, target klass oop expected in rax by convention.
3911 __ z_brul((address) Interpreter::_throw_ClassCastException_entry);
3912
3913 // Come here on success.
3914 __ bind(ok_is_subtype);
3915
3916 __ z_lgr(Z_tos, receiver); // Restore object.
3917
3918 // Collect counts on whether this test sees NULLs a lot or not.
3952 __ compareU64_and_branch(Z_R0_scratch, JVM_CONSTANT_Class, Assembler::bcondEqual, quicked);
3953
3954 __ push(atos); // Save receiver for result, and for GC.
3955 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
3956 __ get_vm_result_2(Z_tos);
3957
3958 Register receiver = Z_tmp_2;
3959 Register klass = Z_tos;
3960 Register subklass = Z_tmp_2;
3961
3962 __ pop_ptr(receiver); // Restore receiver.
3963 __ verify_oop(receiver);
3964 __ load_klass(subklass, subklass);
3965 __ z_bru(resolved);
3966
3967 // Get superklass in klass and subklass in subklass.
3968 __ bind(quicked);
3969
3970 __ load_klass(subklass, Z_tos);
3971 __ z_sllg(index, index, LogBytesPerWord); // index2bytes for addressing
3972 __ load_resolved_klass_at_offset(cpool, index, klass);
3973
3974 __ bind(resolved);
3975
3976 // Generate subtype check.
3977 // Superklass in klass. Subklass in subklass.
3978 __ gen_subtype_check(subklass, klass, Z_ARG4, Z_ARG5, ok_is_subtype);
3979
3980 // Come here on failure.
3981 __ clear_reg(Z_tos, true, false);
3982 __ z_bru(done);
3983
3984 // Come here on success.
3985 __ bind(ok_is_subtype);
3986 __ load_const_optimized(Z_tos, 1);
3987
3988 // Collect counts on whether this test sees NULLs a lot or not.
3989 if (ProfileInterpreter) {
3990 __ z_bru(done);
3991 __ bind(is_null);
3992 __ profile_null_seen(Z_tmp_1);
|