src/share/vm/runtime/sharedRuntime.hpp

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().


 341 
 342   // Read the array of BasicTypes from a Java signature, and compute where
 343   // compiled Java code would like to put the results.  Values in reg_lo and
 344   // reg_hi refer to 4-byte quantities.  Values less than SharedInfo::stack0 are
 345   // registers, those above refer to 4-byte stack slots.  All stack slots are
 346   // based off of the window top.  SharedInfo::stack0 refers to the first usable
 347   // slot in the bottom of the frame. SharedInfo::stack0+1 refers to the memory word
 348   // 4-bytes higher. So for sparc because the register window save area is at
 349   // the bottom of the frame the first 16 words will be skipped and SharedInfo::stack0
 350   // will be just above it. (
 351   // return value is the maximum number of VMReg stack slots the convention will use.
 352   static int java_calling_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed, int is_outgoing);
 353 
 354   static void check_member_name_argument_is_last_argument(methodHandle method,
 355                                                           const BasicType* sig_bt,
 356                                                           const VMRegPair* regs) NOT_DEBUG_RETURN;
 357 
 358   // Ditto except for calling C
 359   static int c_calling_convention(const BasicType *sig_bt, VMRegPair *regs, int total_args_passed);
 360 












 361   // Generate I2C and C2I adapters. These adapters are simple argument marshalling
 362   // blobs. Unlike adapters in the tiger and earlier releases the code in these
 363   // blobs does not create a new frame and are therefore virtually invisible
 364   // to the stack walking code. In general these blobs extend the callers stack
 365   // as needed for the conversion of argument locations.
 366 
 367   // When calling a c2i blob the code will always call the interpreter even if
 368   // by the time we reach the blob there is compiled code available. This allows
 369   // the blob to pass the incoming stack pointer (the sender sp) in a known
 370   // location for the interpreter to record. This is used by the frame code
 371   // to correct the sender code to match up with the stack pointer when the
 372   // thread left the compiled code. In addition it allows the interpreter
 373   // to remove the space the c2i adapter allocated to do it argument conversion.
 374 
 375   // Although a c2i blob will always run interpreted even if compiled code is
 376   // present if we see that compiled code is present the compiled call site
 377   // will be patched/re-resolved so that later calls will run compiled.
 378 
 379   // Aditionally a c2i blob need to have a unverified entry because it can be reached
 380   // in situations where the call site is an inlined cache site and may go megamorphic.
 381 
 382   // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
 383   // that the interpreter before it does any call dispatch will record the current
 384   // stack pointer in the interpreter frame. On return it will restore the stack
 385   // pointer as needed. This means the i2c adapter code doesn't need any special
 386   // handshaking path with compiled code to keep the stack walking correct.
 387 
 388   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
 389                                                       int total_args_passed,
 390                                                       int max_arg,
 391                                                       const BasicType *sig_bt,
 392                                                       const VMRegPair *regs,
 393                                                       AdapterFingerPrint* fingerprint);




 341 
 342   // Read the array of BasicTypes from a Java signature, and compute where
 343   // compiled Java code would like to put the results.  Values in reg_lo and
 344   // reg_hi refer to 4-byte quantities.  Values less than SharedInfo::stack0 are
 345   // registers, those above refer to 4-byte stack slots.  All stack slots are
 346   // based off of the window top.  SharedInfo::stack0 refers to the first usable
 347   // slot in the bottom of the frame. SharedInfo::stack0+1 refers to the memory word
 348   // 4-bytes higher. So for sparc because the register window save area is at
 349   // the bottom of the frame the first 16 words will be skipped and SharedInfo::stack0
 350   // will be just above it. (
 351   // return value is the maximum number of VMReg stack slots the convention will use.
 352   static int java_calling_convention(const BasicType* sig_bt, VMRegPair* regs, int total_args_passed, int is_outgoing);
 353 
 354   static void check_member_name_argument_is_last_argument(methodHandle method,
 355                                                           const BasicType* sig_bt,
 356                                                           const VMRegPair* regs) NOT_DEBUG_RETURN;
 357 
 358   // Ditto except for calling C
 359   static int c_calling_convention(const BasicType *sig_bt, VMRegPair *regs, int total_args_passed);
 360 
 361   // Querry whether this platforms requires that 32 bit integers are
 362   // passed as 64 bit wide entities in C calls. (This is the case on PPC
 363   // and z/Arch.)
 364   static bool c_calling_convention_requires_ints_as_longs();
 365   // Compute the new number of arguments in the signature if 32 bit ints
 366   // must be converted to longs.
 367   static int  convert_ints_to_longints_argcnt(int in_args_count, BasicType* in_sig_bt);
 368   // Adapt a method's signature if it contains 32 bit integers that must
 369   // be converted to longs.
 370   static void convert_ints_to_longints(int i2l_argcnt, int& in_args_count,
 371                                        BasicType*& in_sig_bt, VMRegPair*& in_regs );
 372 
 373   // Generate I2C and C2I adapters. These adapters are simple argument marshalling
 374   // blobs. Unlike adapters in the tiger and earlier releases the code in these
 375   // blobs does not create a new frame and are therefore virtually invisible
 376   // to the stack walking code. In general these blobs extend the callers stack
 377   // as needed for the conversion of argument locations.
 378 
 379   // When calling a c2i blob the code will always call the interpreter even if
 380   // by the time we reach the blob there is compiled code available. This allows
 381   // the blob to pass the incoming stack pointer (the sender sp) in a known
 382   // location for the interpreter to record. This is used by the frame code
 383   // to correct the sender code to match up with the stack pointer when the
 384   // thread left the compiled code. In addition it allows the interpreter
 385   // to remove the space the c2i adapter allocated to do its argument conversion.
 386 
 387   // Although a c2i blob will always run interpreted even if compiled code is
 388   // present if we see that compiled code is present the compiled call site
 389   // will be patched/re-resolved so that later calls will run compiled.
 390 
 391   // Aditionally a c2i blob need to have a unverified entry because it can be reached
 392   // in situations where the call site is an inlined cache site and may go megamorphic.
 393 
 394   // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
 395   // that the interpreter before it does any call dispatch will record the current
 396   // stack pointer in the interpreter frame. On return it will restore the stack
 397   // pointer as needed. This means the i2c adapter code doesn't need any special
 398   // handshaking path with compiled code to keep the stack walking correct.
 399 
 400   static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
 401                                                       int total_args_passed,
 402                                                       int max_arg,
 403                                                       const BasicType *sig_bt,
 404                                                       const VMRegPair *regs,
 405                                                       AdapterFingerPrint* fingerprint);