30 #include "code/vtableStubs.hpp"
31 #include "gc/shared/gcLocker.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "interpreter/interp_masm.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "oops/compiledICHolder.hpp"
36 #include "oops/klass.inline.hpp"
37 #include "registerSaver_s390.hpp"
38 #include "runtime/safepointMechanism.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/vframeArray.hpp"
41 #include "utilities/align.hpp"
42 #include "vmreg_s390.inline.hpp"
43 #ifdef COMPILER1
44 #include "c1/c1_Runtime1.hpp"
45 #endif
46 #ifdef COMPILER2
47 #include "opto/ad.hpp"
48 #include "opto/runtime.hpp"
49 #endif
50
51 #ifdef PRODUCT
52 #define __ masm->
53 #else
54 #define __ (Verbose ? (masm->block_comment(FILE_AND_LINE),masm):masm)->
55 #endif
56
57 #define BLOCK_COMMENT(str) __ block_comment(str)
58 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
59
60 #define RegisterSaver_LiveIntReg(regname) \
61 { RegisterSaver::int_reg, regname->encoding(), regname->as_VMReg() }
62
63 #define RegisterSaver_LiveFloatReg(regname) \
64 { RegisterSaver::float_reg, regname->encoding(), regname->as_VMReg() }
65
66 // Registers which are not saved/restored, but still they have got a frame slot.
67 // Used to get same frame size for RegisterSaver_LiveRegs and RegisterSaver_LiveRegsWithoutR2
68 #define RegisterSaver_ExcludedIntReg(regname) \
69 { RegisterSaver::excluded_reg, regname->encoding(), regname->as_VMReg() }
1504 __ compare64_and_branch(first, (RegisterOrConstant)0L, Assembler::bcondEqual, set_out_args);
1505 __ z_lgf(tmp2_reg, Address(first, arrayOopDesc::length_offset_in_bytes()));
1506 __ add2reg(tmp_reg, arrayOopDesc::base_offset_in_bytes(in_elem_type), first);
1507
1508 __ bind(set_out_args);
1509 move_ptr(masm, tmp, body_arg, framesize_in_slots);
1510 move32_64(masm, tmp2, length_arg, framesize_in_slots);
1511 }
1512
1513 //----------------------------------------------------------------------
1514 // Wrap a JNI call.
1515 //----------------------------------------------------------------------
1516 #undef USE_RESIZE_FRAME
1517 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
1518 const methodHandle& method,
1519 int compile_id,
1520 BasicType *in_sig_bt,
1521 VMRegPair *in_regs,
1522 BasicType ret_type,
1523 address critical_entry) {
1524 #ifdef COMPILER2
1525 int total_in_args = method->size_of_parameters();
1526 if (method->is_method_handle_intrinsic()) {
1527 vmIntrinsics::ID iid = method->intrinsic_id();
1528 intptr_t start = (intptr_t) __ pc();
1529 int vep_offset = ((intptr_t) __ pc()) - start;
1530
1531 gen_special_dispatch(masm, total_in_args,
1532 method->intrinsic_id(), in_sig_bt, in_regs);
1533
1534 int frame_complete = ((intptr_t)__ pc()) - start; // Not complete, period.
1535
1536 __ flush();
1537
1538 int stack_slots = SharedRuntime::out_preserve_stack_slots(); // No out slots at all, actually.
1539
1540 return nmethod::new_native_nmethod(method,
1541 compile_id,
1542 masm->code(),
1543 vep_offset,
1544 frame_complete,
2384 //////////////////////////////////////////////////////////////////////
2385 // end of code generation
2386 //////////////////////////////////////////////////////////////////////
2387
2388
2389 nmethod *nm = nmethod::new_native_nmethod(method,
2390 compile_id,
2391 masm->code(),
2392 (int)(wrapper_VEPStart-wrapper_CodeStart),
2393 (int)(wrapper_FrameDone-wrapper_CodeStart),
2394 stack_slots / VMRegImpl::slots_per_word,
2395 (method_is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
2396 in_ByteSize(lock_offset),
2397 oop_maps);
2398
2399 if (is_critical_native) {
2400 nm->set_lazy_critical_native(true);
2401 }
2402
2403 return nm;
2404 #else
2405 ShouldNotReachHere();
2406 return NULL;
2407 #endif // COMPILER2
2408 }
2409
2410 static address gen_c2i_adapter(MacroAssembler *masm,
2411 int total_args_passed,
2412 int comp_args_on_stack,
2413 const BasicType *sig_bt,
2414 const VMRegPair *regs,
2415 Label &skip_fixup) {
2416 // Before we get into the guts of the C2I adapter, see if we should be here
2417 // at all. We've come from compiled code and are attempting to jump to the
2418 // interpreter, which means the caller made a static call to get here
2419 // (vcalls always get a compiled target if there is one). Check for a
2420 // compiled target. If there is one, we need to patch the caller's call.
2421
2422 // These two defs MUST MATCH code in gen_i2c2i_adapter!
2423 const Register ientry = Z_R11;
2424 const Register code = Z_R11;
2425
2426 address c2i_entrypoint;
2427 Label patch_callsite;
2863 CodeBuffer buffer("deopt_blob", 2048, 1024);
2864 InterpreterMacroAssembler* masm = new InterpreterMacroAssembler(&buffer);
2865 Label exec_mode_initialized;
2866 OopMap* map = NULL;
2867 OopMapSet *oop_maps = new OopMapSet();
2868
2869 unsigned int start_off = __ offset();
2870 Label cont;
2871
2872 // --------------------------------------------------------------------------
2873 // Normal entry (non-exception case)
2874 //
2875 // We have been called from the deopt handler of the deoptee.
2876 // Z_R14 points behind the call in the deopt handler. We adjust
2877 // it such that it points to the start of the deopt handler.
2878 // The return_pc has been stored in the frame of the deoptee and
2879 // will replace the address of the deopt_handler in the call
2880 // to Deoptimization::fetch_unroll_info below.
2881 // The (int) cast is necessary, because -((unsigned int)14)
2882 // is an unsigned int.
2883 __ add2reg(Z_R14, -(int)HandlerImpl::size_deopt_handler());
2884
2885 const Register exec_mode_reg = Z_tmp_1;
2886
2887 // stack: (deoptee, caller of deoptee, ...)
2888
2889 // pushes an "unpack" frame
2890 // R14 contains the return address pointing into the deoptimized
2891 // nmethod that was valid just before the nmethod was deoptimized.
2892 // save R14 into the deoptee frame. the `fetch_unroll_info'
2893 // procedure called below will read it from there.
2894 map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
2895
2896 // note the entry point.
2897 __ load_const_optimized(exec_mode_reg, Deoptimization::Unpack_deopt);
2898 __ z_bru(exec_mode_initialized);
2899
2900 #ifndef COMPILER1
2901 int reexecute_offset = 1; // odd offset will produce odd pc, which triggers an hardware trap
2902 #else
2903 // --------------------------------------------------------------------------
|
30 #include "code/vtableStubs.hpp"
31 #include "gc/shared/gcLocker.hpp"
32 #include "interpreter/interpreter.hpp"
33 #include "interpreter/interp_masm.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "oops/compiledICHolder.hpp"
36 #include "oops/klass.inline.hpp"
37 #include "registerSaver_s390.hpp"
38 #include "runtime/safepointMechanism.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/vframeArray.hpp"
41 #include "utilities/align.hpp"
42 #include "vmreg_s390.inline.hpp"
43 #ifdef COMPILER1
44 #include "c1/c1_Runtime1.hpp"
45 #endif
46 #ifdef COMPILER2
47 #include "opto/ad.hpp"
48 #include "opto/runtime.hpp"
49 #endif
50 #include "nativeInst_s390.hpp"
51
52 #ifdef PRODUCT
53 #define __ masm->
54 #else
55 #define __ (Verbose ? (masm->block_comment(FILE_AND_LINE),masm):masm)->
56 #endif
57
58 #define BLOCK_COMMENT(str) __ block_comment(str)
59 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
60
61 #define RegisterSaver_LiveIntReg(regname) \
62 { RegisterSaver::int_reg, regname->encoding(), regname->as_VMReg() }
63
64 #define RegisterSaver_LiveFloatReg(regname) \
65 { RegisterSaver::float_reg, regname->encoding(), regname->as_VMReg() }
66
67 // Registers which are not saved/restored, but still they have got a frame slot.
68 // Used to get same frame size for RegisterSaver_LiveRegs and RegisterSaver_LiveRegsWithoutR2
69 #define RegisterSaver_ExcludedIntReg(regname) \
70 { RegisterSaver::excluded_reg, regname->encoding(), regname->as_VMReg() }
1505 __ compare64_and_branch(first, (RegisterOrConstant)0L, Assembler::bcondEqual, set_out_args);
1506 __ z_lgf(tmp2_reg, Address(first, arrayOopDesc::length_offset_in_bytes()));
1507 __ add2reg(tmp_reg, arrayOopDesc::base_offset_in_bytes(in_elem_type), first);
1508
1509 __ bind(set_out_args);
1510 move_ptr(masm, tmp, body_arg, framesize_in_slots);
1511 move32_64(masm, tmp2, length_arg, framesize_in_slots);
1512 }
1513
1514 //----------------------------------------------------------------------
1515 // Wrap a JNI call.
1516 //----------------------------------------------------------------------
1517 #undef USE_RESIZE_FRAME
1518 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
1519 const methodHandle& method,
1520 int compile_id,
1521 BasicType *in_sig_bt,
1522 VMRegPair *in_regs,
1523 BasicType ret_type,
1524 address critical_entry) {
1525 int total_in_args = method->size_of_parameters();
1526 if (method->is_method_handle_intrinsic()) {
1527 vmIntrinsics::ID iid = method->intrinsic_id();
1528 intptr_t start = (intptr_t) __ pc();
1529 int vep_offset = ((intptr_t) __ pc()) - start;
1530
1531 gen_special_dispatch(masm, total_in_args,
1532 method->intrinsic_id(), in_sig_bt, in_regs);
1533
1534 int frame_complete = ((intptr_t)__ pc()) - start; // Not complete, period.
1535
1536 __ flush();
1537
1538 int stack_slots = SharedRuntime::out_preserve_stack_slots(); // No out slots at all, actually.
1539
1540 return nmethod::new_native_nmethod(method,
1541 compile_id,
1542 masm->code(),
1543 vep_offset,
1544 frame_complete,
2384 //////////////////////////////////////////////////////////////////////
2385 // end of code generation
2386 //////////////////////////////////////////////////////////////////////
2387
2388
2389 nmethod *nm = nmethod::new_native_nmethod(method,
2390 compile_id,
2391 masm->code(),
2392 (int)(wrapper_VEPStart-wrapper_CodeStart),
2393 (int)(wrapper_FrameDone-wrapper_CodeStart),
2394 stack_slots / VMRegImpl::slots_per_word,
2395 (method_is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
2396 in_ByteSize(lock_offset),
2397 oop_maps);
2398
2399 if (is_critical_native) {
2400 nm->set_lazy_critical_native(true);
2401 }
2402
2403 return nm;
2404 }
2405
2406 static address gen_c2i_adapter(MacroAssembler *masm,
2407 int total_args_passed,
2408 int comp_args_on_stack,
2409 const BasicType *sig_bt,
2410 const VMRegPair *regs,
2411 Label &skip_fixup) {
2412 // Before we get into the guts of the C2I adapter, see if we should be here
2413 // at all. We've come from compiled code and are attempting to jump to the
2414 // interpreter, which means the caller made a static call to get here
2415 // (vcalls always get a compiled target if there is one). Check for a
2416 // compiled target. If there is one, we need to patch the caller's call.
2417
2418 // These two defs MUST MATCH code in gen_i2c2i_adapter!
2419 const Register ientry = Z_R11;
2420 const Register code = Z_R11;
2421
2422 address c2i_entrypoint;
2423 Label patch_callsite;
2859 CodeBuffer buffer("deopt_blob", 2048, 1024);
2860 InterpreterMacroAssembler* masm = new InterpreterMacroAssembler(&buffer);
2861 Label exec_mode_initialized;
2862 OopMap* map = NULL;
2863 OopMapSet *oop_maps = new OopMapSet();
2864
2865 unsigned int start_off = __ offset();
2866 Label cont;
2867
2868 // --------------------------------------------------------------------------
2869 // Normal entry (non-exception case)
2870 //
2871 // We have been called from the deopt handler of the deoptee.
2872 // Z_R14 points behind the call in the deopt handler. We adjust
2873 // it such that it points to the start of the deopt handler.
2874 // The return_pc has been stored in the frame of the deoptee and
2875 // will replace the address of the deopt_handler in the call
2876 // to Deoptimization::fetch_unroll_info below.
2877 // The (int) cast is necessary, because -((unsigned int)14)
2878 // is an unsigned int.
2879 __ add2reg(Z_R14, -(int)NativeCall::max_instruction_size());
2880
2881 const Register exec_mode_reg = Z_tmp_1;
2882
2883 // stack: (deoptee, caller of deoptee, ...)
2884
2885 // pushes an "unpack" frame
2886 // R14 contains the return address pointing into the deoptimized
2887 // nmethod that was valid just before the nmethod was deoptimized.
2888 // save R14 into the deoptee frame. the `fetch_unroll_info'
2889 // procedure called below will read it from there.
2890 map = RegisterSaver::save_live_registers(masm, RegisterSaver::all_registers);
2891
2892 // note the entry point.
2893 __ load_const_optimized(exec_mode_reg, Deoptimization::Unpack_deopt);
2894 __ z_bru(exec_mode_initialized);
2895
2896 #ifndef COMPILER1
2897 int reexecute_offset = 1; // odd offset will produce odd pc, which triggers an hardware trap
2898 #else
2899 // --------------------------------------------------------------------------
|