1101 // insufficient for C calls. What a mess. I sure hope those 6
1102 // stack words were worth it on every java call!
1103
1104 // Another way of cleaning this up would be for out_preserve_stack_slots
1105 // to take a parameter to say whether it was C or java calling conventions.
1106 // Then things might look a little better (but not much).
1107
1108 int mem_parm_offset = i - SPARC_ARGS_IN_REGS_NUM;
1109 if( mem_parm_offset < 0 ) {
1110 return as_oRegister(i)->as_VMReg();
1111 } else {
1112 int actual_offset = (mem_parm_offset + frame::memory_parameter_word_sp_offset) * VMRegImpl::slots_per_word;
1113 // Now return a biased offset that will be correct when out_preserve_slots is added back in
1114 return VMRegImpl::stack2reg(actual_offset - SharedRuntime::out_preserve_stack_slots());
1115 }
1116 }
1117
1118
1119 int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
1120 VMRegPair *regs,
1121 int total_args_passed) {
1122
1123 // Return the number of VMReg stack_slots needed for the args.
1124 // This value does not include an abi space (like register window
1125 // save area).
1126
1127 // The native convention is V8 if !LP64
1128 // The LP64 convention is the V9 convention which is slightly more sane.
1129
1130 // We return the amount of VMReg stack slots we need to reserve for all
1131 // the arguments NOT counting out_preserve_stack_slots. Since we always
1132 // have space for storing at least 6 registers to memory we start with that.
1133 // See int_stk_helper for a further discussion.
1134 int max_stack_slots = (frame::varargs_offset * VMRegImpl::slots_per_word) - SharedRuntime::out_preserve_stack_slots();
1135
1136 #ifdef _LP64
1137 // V9 convention: All things "as-if" on double-wide stack slots.
1138 // Hoist any int/ptr/long's in the first 6 to int regs.
1139 // Hoist any flt/dbl's in the first 16 dbl regs.
1140 int j = 0; // Count of actual args, not HALVES
1141 for( int i=0; i<total_args_passed; i++, j++ ) {
2079 case 'Z': in_elem_bt[i] = T_BOOLEAN; break;
2080 default: ShouldNotReachHere();
2081 }
2082 }
2083 } else {
2084 out_sig_bt[argc++] = in_sig_bt[i];
2085 in_elem_bt[i] = T_VOID;
2086 }
2087 if (in_sig_bt[i] != T_VOID) {
2088 assert(in_sig_bt[i] == ss.type(), "must match");
2089 ss.next();
2090 }
2091 }
2092 }
2093
2094 // Now figure out where the args must be stored and how much stack space
2095 // they require (neglecting out_preserve_stack_slots but space for storing
2096 // the 1st six register arguments). It's weird see int_stk_helper.
2097 //
2098 int out_arg_slots;
2099 out_arg_slots = c_calling_convention(out_sig_bt, out_regs, total_c_args);
2100
2101 if (is_critical_native) {
2102 // Critical natives may have to call out so they need a save area
2103 // for register arguments.
2104 int double_slots = 0;
2105 int single_slots = 0;
2106 for ( int i = 0; i < total_in_args; i++) {
2107 if (in_regs[i].first()->is_Register()) {
2108 const Register reg = in_regs[i].first()->as_Register();
2109 switch (in_sig_bt[i]) {
2110 case T_ARRAY:
2111 case T_BOOLEAN:
2112 case T_BYTE:
2113 case T_SHORT:
2114 case T_CHAR:
2115 case T_INT: assert(reg->is_in(), "don't need to save these"); break;
2116 case T_LONG: if (reg->is_global()) double_slots++; break;
2117 default: ShouldNotReachHere();
2118 }
2119 } else if (in_regs[i].first()->is_FloatRegister()) {
2826
2827 assert(i==total_args_passed, "validly parsed signature");
2828
2829 // Now get the compiled-Java layout as input arguments
2830 int comp_args_on_stack;
2831 comp_args_on_stack = SharedRuntime::java_calling_convention(
2832 in_sig_bt, in_regs, total_args_passed, false);
2833
2834 // We have received a description of where all the java arg are located
2835 // on entry to the wrapper. We need to convert these args to where
2836 // the a native (non-jni) function would expect them. To figure out
2837 // where they go we convert the java signature to a C signature and remove
2838 // T_VOID for any long/double we might have received.
2839
2840
2841 // Now figure out where the args must be stored and how much stack space
2842 // they require (neglecting out_preserve_stack_slots but space for storing
2843 // the 1st six register arguments). It's weird see int_stk_helper.
2844 //
2845 int out_arg_slots;
2846 out_arg_slots = c_calling_convention(out_sig_bt, out_regs, total_c_args);
2847
2848 // Calculate the total number of stack slots we will need.
2849
2850 // First count the abi requirement plus all of the outgoing args
2851 int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
2852
2853 // Plus a temp for possible converion of float/double/long register args
2854
2855 int conversion_temp = stack_slots;
2856 stack_slots += 2;
2857
2858
2859 // Now space for the string(s) we must convert
2860
2861 int string_locs = stack_slots;
2862 stack_slots += total_strings *
2863 (max_dtrace_string_size / VMRegImpl::stack_slot_size);
2864
2865 // Ok The space we have allocated will look like:
2866 //
|
1101 // insufficient for C calls. What a mess. I sure hope those 6
1102 // stack words were worth it on every java call!
1103
1104 // Another way of cleaning this up would be for out_preserve_stack_slots
1105 // to take a parameter to say whether it was C or java calling conventions.
1106 // Then things might look a little better (but not much).
1107
1108 int mem_parm_offset = i - SPARC_ARGS_IN_REGS_NUM;
1109 if( mem_parm_offset < 0 ) {
1110 return as_oRegister(i)->as_VMReg();
1111 } else {
1112 int actual_offset = (mem_parm_offset + frame::memory_parameter_word_sp_offset) * VMRegImpl::slots_per_word;
1113 // Now return a biased offset that will be correct when out_preserve_slots is added back in
1114 return VMRegImpl::stack2reg(actual_offset - SharedRuntime::out_preserve_stack_slots());
1115 }
1116 }
1117
1118
1119 int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
1120 VMRegPair *regs,
1121 VMRegPair *regs2,
1122 int total_args_passed) {
1123 assert(regs2 == NULL, "not needed on sparc");
1124
1125 // Return the number of VMReg stack_slots needed for the args.
1126 // This value does not include an abi space (like register window
1127 // save area).
1128
1129 // The native convention is V8 if !LP64
1130 // The LP64 convention is the V9 convention which is slightly more sane.
1131
1132 // We return the amount of VMReg stack slots we need to reserve for all
1133 // the arguments NOT counting out_preserve_stack_slots. Since we always
1134 // have space for storing at least 6 registers to memory we start with that.
1135 // See int_stk_helper for a further discussion.
1136 int max_stack_slots = (frame::varargs_offset * VMRegImpl::slots_per_word) - SharedRuntime::out_preserve_stack_slots();
1137
1138 #ifdef _LP64
1139 // V9 convention: All things "as-if" on double-wide stack slots.
1140 // Hoist any int/ptr/long's in the first 6 to int regs.
1141 // Hoist any flt/dbl's in the first 16 dbl regs.
1142 int j = 0; // Count of actual args, not HALVES
1143 for( int i=0; i<total_args_passed; i++, j++ ) {
2081 case 'Z': in_elem_bt[i] = T_BOOLEAN; break;
2082 default: ShouldNotReachHere();
2083 }
2084 }
2085 } else {
2086 out_sig_bt[argc++] = in_sig_bt[i];
2087 in_elem_bt[i] = T_VOID;
2088 }
2089 if (in_sig_bt[i] != T_VOID) {
2090 assert(in_sig_bt[i] == ss.type(), "must match");
2091 ss.next();
2092 }
2093 }
2094 }
2095
2096 // Now figure out where the args must be stored and how much stack space
2097 // they require (neglecting out_preserve_stack_slots but space for storing
2098 // the 1st six register arguments). It's weird see int_stk_helper.
2099 //
2100 int out_arg_slots;
2101 out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
2102
2103 if (is_critical_native) {
2104 // Critical natives may have to call out so they need a save area
2105 // for register arguments.
2106 int double_slots = 0;
2107 int single_slots = 0;
2108 for ( int i = 0; i < total_in_args; i++) {
2109 if (in_regs[i].first()->is_Register()) {
2110 const Register reg = in_regs[i].first()->as_Register();
2111 switch (in_sig_bt[i]) {
2112 case T_ARRAY:
2113 case T_BOOLEAN:
2114 case T_BYTE:
2115 case T_SHORT:
2116 case T_CHAR:
2117 case T_INT: assert(reg->is_in(), "don't need to save these"); break;
2118 case T_LONG: if (reg->is_global()) double_slots++; break;
2119 default: ShouldNotReachHere();
2120 }
2121 } else if (in_regs[i].first()->is_FloatRegister()) {
2828
2829 assert(i==total_args_passed, "validly parsed signature");
2830
2831 // Now get the compiled-Java layout as input arguments
2832 int comp_args_on_stack;
2833 comp_args_on_stack = SharedRuntime::java_calling_convention(
2834 in_sig_bt, in_regs, total_args_passed, false);
2835
2836 // We have received a description of where all the java arg are located
2837 // on entry to the wrapper. We need to convert these args to where
2838 // the a native (non-jni) function would expect them. To figure out
2839 // where they go we convert the java signature to a C signature and remove
2840 // T_VOID for any long/double we might have received.
2841
2842
2843 // Now figure out where the args must be stored and how much stack space
2844 // they require (neglecting out_preserve_stack_slots but space for storing
2845 // the 1st six register arguments). It's weird see int_stk_helper.
2846 //
2847 int out_arg_slots;
2848 out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
2849
2850 // Calculate the total number of stack slots we will need.
2851
2852 // First count the abi requirement plus all of the outgoing args
2853 int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
2854
2855 // Plus a temp for possible converion of float/double/long register args
2856
2857 int conversion_temp = stack_slots;
2858 stack_slots += 2;
2859
2860
2861 // Now space for the string(s) we must convert
2862
2863 int string_locs = stack_slots;
2864 stack_slots += total_strings *
2865 (max_dtrace_string_size / VMRegImpl::stack_slot_size);
2866
2867 // Ok The space we have allocated will look like:
2868 //
|