1 /* |
1 /* |
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright (c) 2016, 2018 SAP SE. All rights reserved. |
3 * Copyright (c) 2016, 2019, SAP SE. All rights reserved. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * |
5 * |
6 * This code is free software; you can redistribute it and/or modify it |
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 |
7 * under the terms of the GNU General Public License version 2 only, as |
8 * published by the Free Software Foundation. |
8 * published by the Free Software Foundation. |
31 #include "gc/shared/gcLocker.hpp" |
31 #include "gc/shared/gcLocker.hpp" |
32 #include "interpreter/interpreter.hpp" |
32 #include "interpreter/interpreter.hpp" |
33 #include "interpreter/interp_masm.hpp" |
33 #include "interpreter/interp_masm.hpp" |
34 #include "memory/resourceArea.hpp" |
34 #include "memory/resourceArea.hpp" |
35 #include "oops/compiledICHolder.hpp" |
35 #include "oops/compiledICHolder.hpp" |
|
36 #include "oops/klass.inline.hpp" |
36 #include "registerSaver_s390.hpp" |
37 #include "registerSaver_s390.hpp" |
37 #include "runtime/safepointMechanism.hpp" |
38 #include "runtime/safepointMechanism.hpp" |
38 #include "runtime/sharedRuntime.hpp" |
39 #include "runtime/sharedRuntime.hpp" |
39 #include "runtime/vframeArray.hpp" |
40 #include "runtime/vframeArray.hpp" |
40 #include "utilities/align.hpp" |
41 #include "utilities/align.hpp" |
881 const BasicType *sig_bt, |
882 const BasicType *sig_bt, |
882 const VMRegPair *regs) { |
883 const VMRegPair *regs) { |
883 if (!VerifyOops) { return; } |
884 if (!VerifyOops) { return; } |
884 |
885 |
885 for (int i = 0; i < total_args_passed; i++) { |
886 for (int i = 0; i < total_args_passed; i++) { |
886 if (sig_bt[i] == T_OBJECT || sig_bt[i] == T_ARRAY) { |
887 if (is_reference_type(sig_bt[i])) { |
887 VMReg r = regs[i].first(); |
888 VMReg r = regs[i].first(); |
888 assert(r->is_valid(), "bad oop arg"); |
889 assert(r->is_valid(), "bad oop arg"); |
889 |
890 |
890 if (r->is_stack()) { |
891 if (r->is_stack()) { |
891 __ z_lg(Z_R0_scratch, |
892 __ z_lg(Z_R0_scratch, |
1516 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, |
1517 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm, |
1517 const methodHandle& method, |
1518 const methodHandle& method, |
1518 int compile_id, |
1519 int compile_id, |
1519 BasicType *in_sig_bt, |
1520 BasicType *in_sig_bt, |
1520 VMRegPair *in_regs, |
1521 VMRegPair *in_regs, |
1521 BasicType ret_type) { |
1522 BasicType ret_type, |
|
1523 address critical_entry) { |
1522 #ifdef COMPILER2 |
1524 #ifdef COMPILER2 |
1523 int total_in_args = method->size_of_parameters(); |
1525 int total_in_args = method->size_of_parameters(); |
1524 if (method->is_method_handle_intrinsic()) { |
1526 if (method->is_method_handle_intrinsic()) { |
1525 vmIntrinsics::ID iid = method->intrinsic_id(); |
1527 vmIntrinsics::ID iid = method->intrinsic_id(); |
1526 intptr_t start = (intptr_t) __ pc(); |
1528 intptr_t start = (intptr_t) __ pc(); |
1552 // Precalculations before generating any code |
1554 // Precalculations before generating any code |
1553 // |
1555 // |
1554 /////////////////////////////////////////////////////////////////////// |
1556 /////////////////////////////////////////////////////////////////////// |
1555 |
1557 |
1556 bool is_critical_native = true; |
1558 bool is_critical_native = true; |
1557 address native_func = method->critical_native_function(); |
1559 address native_func = critical_entry; |
1558 if (native_func == NULL) { |
1560 if (native_func == NULL) { |
1559 native_func = method->native_function(); |
1561 native_func = method->native_function(); |
1560 is_critical_native = false; |
1562 is_critical_native = false; |
1561 } |
1563 } |
1562 assert(native_func != NULL, "must have function"); |
1564 assert(native_func != NULL, "must have function"); |
1830 //--------------------------------------------------------------------- |
1832 //--------------------------------------------------------------------- |
1831 // Verified entry point (VEP) |
1833 // Verified entry point (VEP) |
1832 //--------------------------------------------------------------------- |
1834 //--------------------------------------------------------------------- |
1833 wrapper_VEPStart = __ offset(); |
1835 wrapper_VEPStart = __ offset(); |
1834 |
1836 |
|
1837 if (VM_Version::supports_fast_class_init_checks() && method->needs_clinit_barrier()) { |
|
1838 Label L_skip_barrier; |
|
1839 Register klass = Z_R1_scratch; |
|
1840 // Notify OOP recorder (don't need the relocation) |
|
1841 AddressLiteral md = __ constant_metadata_address(method->method_holder()); |
|
1842 __ load_const_optimized(klass, md.value()); |
|
1843 __ clinit_barrier(klass, Z_thread, &L_skip_barrier /*L_fast_path*/); |
|
1844 |
|
1845 __ load_const_optimized(klass, SharedRuntime::get_handle_wrong_method_stub()); |
|
1846 __ z_br(klass); |
|
1847 |
|
1848 __ bind(L_skip_barrier); |
|
1849 } |
|
1850 |
1835 __ save_return_pc(); |
1851 __ save_return_pc(); |
1836 __ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame. |
1852 __ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame. |
1837 #ifndef USE_RESIZE_FRAME |
1853 #ifndef USE_RESIZE_FRAME |
1838 __ push_frame(frame_size_in_bytes); // Create a new frame for the wrapper. |
1854 __ push_frame(frame_size_in_bytes); // Create a new frame for the wrapper. |
1839 #else |
1855 #else |
2301 __ verify_thread(); // Z_thread must be correct. |
2317 __ verify_thread(); // Z_thread must be correct. |
2302 |
2318 |
2303 __ reset_last_Java_frame(); |
2319 __ reset_last_Java_frame(); |
2304 |
2320 |
2305 // Unpack oop result, e.g. JNIHandles::resolve result. |
2321 // Unpack oop result, e.g. JNIHandles::resolve result. |
2306 if (ret_type == T_OBJECT || ret_type == T_ARRAY) { |
2322 if (is_reference_type(ret_type)) { |
2307 __ resolve_jobject(Z_RET, /* tmp1 */ Z_R13, /* tmp2 */ Z_R7); |
2323 __ resolve_jobject(Z_RET, /* tmp1 */ Z_R13, /* tmp2 */ Z_R7); |
2308 } |
2324 } |
2309 |
2325 |
2310 if (CheckJNICalls) { |
2326 if (CheckJNICalls) { |
2311 // clear_pending_jni_exception_check |
2327 // clear_pending_jni_exception_check |
2604 __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*)); |
2620 __ z_mvc(Address(Z_SP, st_off), Address(ld_ptr, ld_offset), sizeof(void*)); |
2605 } |
2621 } |
2606 } else { |
2622 } else { |
2607 if (!r_2->is_valid()) { |
2623 if (!r_2->is_valid()) { |
2608 // Not sure we need to do this but it shouldn't hurt. |
2624 // Not sure we need to do this but it shouldn't hurt. |
2609 if (sig_bt[i] == T_OBJECT || sig_bt[i] == T_ADDRESS || sig_bt[i] == T_ARRAY) { |
2625 if (is_reference_type(sig_bt[i]) || sig_bt[i] == T_ADDRESS) { |
2610 __ z_lg(r_1->as_Register(), ld_offset, ld_ptr); |
2626 __ z_lg(r_1->as_Register(), ld_offset, ld_ptr); |
2611 } else { |
2627 } else { |
2612 __ z_l(r_1->as_Register(), ld_offset, ld_ptr); |
2628 __ z_l(r_1->as_Register(), ld_offset, ld_ptr); |
2613 } |
2629 } |
2614 } else { |
2630 } else { |
2694 __ z_brne(ic_miss); // Cache miss: call runtime to handle this. |
2710 __ z_brne(ic_miss); // Cache miss: call runtime to handle this. |
2695 |
2711 |
2696 // Fallthru to VEP. Duplicate LTG, but saved taken branch. |
2712 // Fallthru to VEP. Duplicate LTG, but saved taken branch. |
2697 } |
2713 } |
2698 |
2714 |
2699 address c2i_entry; |
2715 address c2i_entry = __ pc(); |
2700 c2i_entry = gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup); |
2716 |
2701 |
2717 // Class initialization barrier for static methods |
2702 return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry); |
2718 address c2i_no_clinit_check_entry = NULL; |
|
2719 if (VM_Version::supports_fast_class_init_checks()) { |
|
2720 Label L_skip_barrier; |
|
2721 |
|
2722 { // Bypass the barrier for non-static methods |
|
2723 __ testbit(Address(Z_method, Method::access_flags_offset()), JVM_ACC_STATIC_BIT); |
|
2724 __ z_bfalse(L_skip_barrier); // non-static |
|
2725 } |
|
2726 |
|
2727 Register klass = Z_R11; |
|
2728 __ load_method_holder(klass, Z_method); |
|
2729 __ clinit_barrier(klass, Z_thread, &L_skip_barrier /*L_fast_path*/); |
|
2730 |
|
2731 __ load_const_optimized(klass, SharedRuntime::get_handle_wrong_method_stub()); |
|
2732 __ z_br(klass); |
|
2733 |
|
2734 __ bind(L_skip_barrier); |
|
2735 c2i_no_clinit_check_entry = __ pc(); |
|
2736 } |
|
2737 |
|
2738 gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup); |
|
2739 |
|
2740 return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry); |
2703 } |
2741 } |
2704 |
2742 |
2705 // This function returns the adjust size (in number of words) to a c2i adapter |
2743 // This function returns the adjust size (in number of words) to a c2i adapter |
2706 // activation for use during deoptimization. |
2744 // activation for use during deoptimization. |
2707 // |
2745 // |