src/cpu/x86/vm/sharedRuntime_x86_64.cpp

Print this page
rev 5186 : 8024342: PPC64 (part 111): Support for C calling conventions that require 64-bit ints.
Summary: Some platforms, as ppc and s390x/zArch require that 32-bit ints are passed as 64-bit values to C functions. This change adds support to adapt the signature and to issue proper casts to c2-compiled stubs. The functions are used in generate_native_wrapper(). Adapt signature in PhaseIdealLoop::intrinsify_fill().


 983       case T_VOID: // Halves of longs and doubles
 984         assert(i != 0 && (sig_bt[i - 1] == T_LONG || sig_bt[i - 1] == T_DOUBLE), "expecting half");
 985         regs[i].set_bad();
 986         break;
 987       default:
 988         ShouldNotReachHere();
 989         break;
 990       }
 991     }
 992 #ifdef _WIN64
 993   // windows abi requires that we always allocate enough stack space
 994   // for 4 64bit registers to be stored down.
 995   if (stk_args < 8) {
 996     stk_args = 8;
 997   }
 998 #endif // _WIN64
 999 
1000   return stk_args;
1001 }
1002 





1003 // On 64 bit we will store integer like items to the stack as
1004 // 64 bits items (sparc abi) even though java would only store
1005 // 32bits for a parameter. On 32bit it will simply be 32 bits
1006 // So this routine will do 32->32 on 32bit and 32->64 on 64bit
1007 static void move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
1008   if (src.first()->is_stack()) {
1009     if (dst.first()->is_stack()) {
1010       // stack to stack
1011       __ movslq(rax, Address(rbp, reg2offset_in(src.first())));
1012       __ movq(Address(rsp, reg2offset_out(dst.first())), rax);
1013     } else {
1014       // stack to reg
1015       __ movslq(dst.first()->as_Register(), Address(rbp, reg2offset_in(src.first())));
1016     }
1017   } else if (dst.first()->is_stack()) {
1018     // reg to stack
1019     // Do we really have to sign extend???
1020     // __ movslq(src.first()->as_Register(), src.first()->as_Register());
1021     __ movq(Address(rsp, reg2offset_out(dst.first())), src.first()->as_Register());
1022   } else {




 983       case T_VOID: // Halves of longs and doubles
 984         assert(i != 0 && (sig_bt[i - 1] == T_LONG || sig_bt[i - 1] == T_DOUBLE), "expecting half");
 985         regs[i].set_bad();
 986         break;
 987       default:
 988         ShouldNotReachHere();
 989         break;
 990       }
 991     }
 992 #ifdef _WIN64
 993   // windows abi requires that we always allocate enough stack space
 994   // for 4 64bit registers to be stored down.
 995   if (stk_args < 8) {
 996     stk_args = 8;
 997   }
 998 #endif // _WIN64
 999 
1000   return stk_args;
1001 }
1002 
1003 // Do we need to convert ints to longs for c calls?
1004 bool SharedRuntime::c_calling_convention_requires_ints_as_longs() {
1005   return false;
1006 }
1007 
1008 // On 64 bit we will store integer like items to the stack as
1009 // 64 bits items (sparc abi) even though java would only store
1010 // 32bits for a parameter. On 32bit it will simply be 32 bits
1011 // So this routine will do 32->32 on 32bit and 32->64 on 64bit
1012 static void move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
1013   if (src.first()->is_stack()) {
1014     if (dst.first()->is_stack()) {
1015       // stack to stack
1016       __ movslq(rax, Address(rbp, reg2offset_in(src.first())));
1017       __ movq(Address(rsp, reg2offset_out(dst.first())), rax);
1018     } else {
1019       // stack to reg
1020       __ movslq(dst.first()->as_Register(), Address(rbp, reg2offset_in(src.first())));
1021     }
1022   } else if (dst.first()->is_stack()) {
1023     // reg to stack
1024     // Do we really have to sign extend???
1025     // __ movslq(src.first()->as_Register(), src.first()->as_Register());
1026     __ movq(Address(rsp, reg2offset_out(dst.first())), src.first()->as_Register());
1027   } else {