714 #endif
715 // We fill-out regs AND regs2 if an argument must be passed in a
716 // register AND in a stack slot. If regs2 is NULL in such a
717 // situation, we bail-out with a fatal error.
718 for (int i = 0; i < total_args_passed; ++i, ++arg) {
719 // Initialize regs2 to BAD.
720 if (regs2 != NULL) regs2[i].set_bad();
721
722 switch(sig_bt[i]) {
723
724 //
725 // If arguments 0-7 are integers, they are passed in integer registers.
726 // Argument i is placed in iarg_reg[i].
727 //
728 case T_BOOLEAN:
729 case T_CHAR:
730 case T_BYTE:
731 case T_SHORT:
732 case T_INT:
733 // We must cast ints to longs and use full 64 bit stack slots
734 // here. We do the cast in GraphKit::gen_stub() and just guard
735 // here against loosing that change.
736 assert(CCallingConventionRequiresIntsAsLongs,
737 "argument of type int should be promoted to type long");
738 guarantee(i > 0 && sig_bt[i-1] == T_LONG,
739 "argument of type (bt) should have been promoted to type (T_LONG,bt) for bt in "
740 "{T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
741 // Do not count halves.
742 regs[i].set_bad();
743 --arg;
744 break;
745 case T_LONG:
746 guarantee(sig_bt[i+1] == T_VOID ||
747 sig_bt[i+1] == T_BOOLEAN || sig_bt[i+1] == T_CHAR ||
748 sig_bt[i+1] == T_BYTE || sig_bt[i+1] == T_SHORT ||
749 sig_bt[i+1] == T_INT,
750 "expecting type (T_LONG,half) or type (T_LONG,bt) with bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
751 case T_OBJECT:
752 case T_ARRAY:
753 case T_ADDRESS:
754 case T_METADATA:
755 // Oops are already boxed if required (JNI).
756 if (arg < Argument::n_int_register_parameters_c) {
757 reg = iarg_reg[arg];
758 } else {
759 reg = VMRegImpl::stack2reg(stk);
760 stk += inc_stk_for_longdouble;
761 }
762 regs[i].set2(reg);
763 break;
764
765 //
766 // Floats are treated differently from int regs: The first 13 float arguments
767 // are passed in registers (not the float args among the first 13 args).
768 // Thus argument i is NOT passed in farg_reg[i] if it is float. It is passed
769 // in farg_reg[j] if argument i is the j-th float argument of this call.
770 //
1256
1257 __ cmpdi(CCR0, r_oop, 0);
1258 __ bne(CCR0, skip);
1259 // Use a NULL handle if oop is NULL.
1260 __ li(r_handle, 0);
1261 __ bind(skip);
1262
1263 if (dst.first()->is_stack()) {
1264 // reg to stack
1265 __ std(r_handle, reg2offset(dst.first()), R1_SP);
1266 } else {
1267 // reg to reg
1268 // Nothing to do, r_handle is already the dst register.
1269 }
1270 }
1271 }
1272
1273 static void int_move(MacroAssembler*masm,
1274 VMRegPair src, VMRegPair dst,
1275 Register r_caller_sp, Register r_temp) {
1276 assert(src.first()->is_valid() && src.second() == src.first()->next(), "incoming must be long-int");
1277 assert(dst.first()->is_valid() && dst.second() == dst.first()->next(), "outgoing must be long");
1278
1279 if (src.first()->is_stack()) {
1280 if (dst.first()->is_stack()) {
1281 // stack to stack
1282 __ lwa(r_temp, reg2offset(src.first()), r_caller_sp);
1283 __ std(r_temp, reg2offset(dst.first()), R1_SP);
1284 } else {
1285 // stack to reg
1286 __ lwa(dst.first()->as_Register(), reg2offset(src.first()), r_caller_sp);
1287 }
1288 } else if (dst.first()->is_stack()) {
1289 // reg to stack
1290 __ extsw(r_temp, src.first()->as_Register());
1291 __ std(r_temp, reg2offset(dst.first()), R1_SP);
1292 } else {
1293 // reg to reg
1294 __ extsw(dst.first()->as_Register(), src.first()->as_Register());
1295 }
1296 }
1745 (OopMapSet*)NULL);
1746 }
1747
1748 bool is_critical_native = true;
1749 address native_func = method->critical_native_function();
1750 if (native_func == NULL) {
1751 native_func = method->native_function();
1752 is_critical_native = false;
1753 }
1754 assert(native_func != NULL, "must have function");
1755
1756 // First, create signature for outgoing C call
1757 // --------------------------------------------------------------------------
1758
1759 int total_in_args = method->size_of_parameters();
1760 // We have received a description of where all the java args are located
1761 // on entry to the wrapper. We need to convert these args to where
1762 // the jni function will expect them. To figure out where they go
1763 // we convert the java signature to a C signature by inserting
1764 // the hidden arguments as arg[0] and possibly arg[1] (static method)
1765 //
1766 // Additionally, on ppc64 we must convert integers to longs in the C
1767 // signature. We do this in advance in order to have no trouble with
1768 // indexes into the bt-arrays.
1769 // So convert the signature and registers now, and adjust the total number
1770 // of in-arguments accordingly.
1771 int i2l_argcnt = convert_ints_to_longints_argcnt(total_in_args, in_sig_bt); // PPC64: pass ints as longs.
1772
1773 // Calculate the total number of C arguments and create arrays for the
1774 // signature and the outgoing registers.
1775 // On ppc64, we have two arrays for the outgoing registers, because
1776 // some floating-point arguments must be passed in registers _and_
1777 // in stack locations.
1778 bool method_is_static = method->is_static();
1779 int total_c_args = i2l_argcnt;
1780
1781 if (!is_critical_native) {
1782 int n_hidden_args = method_is_static ? 2 : 1;
1783 total_c_args += n_hidden_args;
1784 } else {
1785 // No JNIEnv*, no this*, but unpacked arrays (base+length).
1786 for (int i = 0; i < total_in_args; i++) {
1787 if (in_sig_bt[i] == T_ARRAY) {
1788 total_c_args += 2; // PPC64: T_LONG, T_INT, T_ADDRESS (see convert_ints_to_longints and c_calling_convention)
1789 }
1790 }
1791 }
1792
1793 BasicType *out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
1794 VMRegPair *out_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
1795 VMRegPair *out_regs2 = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
1796 BasicType* in_elem_bt = NULL;
1797
1798 // Create the signature for the C call:
1799 // 1) add the JNIEnv*
1800 // 2) add the class if the method is static
1801 // 3) copy the rest of the incoming signature (shifted by the number of
1802 // hidden arguments).
1803
1804 int argc = 0;
1805 if (!is_critical_native) {
1806 convert_ints_to_longints(i2l_argcnt, total_in_args, in_sig_bt, in_regs); // PPC64: pass ints as longs.
1807
1808 out_sig_bt[argc++] = T_ADDRESS;
1809 if (method->is_static()) {
1810 out_sig_bt[argc++] = T_OBJECT;
1811 }
1812
1813 for (int i = 0; i < total_in_args ; i++ ) {
1814 out_sig_bt[argc++] = in_sig_bt[i];
1815 }
1816 } else {
1817 Thread* THREAD = Thread::current();
1818 in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, i2l_argcnt);
1819 SignatureStream ss(method->signature());
1820 int o = 0;
1821 for (int i = 0; i < total_in_args ; i++, o++) {
1822 if (in_sig_bt[i] == T_ARRAY) {
1823 // Arrays are passed as int, elem* pair
1824 Symbol* atype = ss.as_symbol(CHECK_NULL);
1825 const char* at = atype->as_C_string();
1826 if (strlen(at) == 2) {
1827 assert(at[0] == '[', "must be");
1828 switch (at[1]) {
1829 case 'B': in_elem_bt[o] = T_BYTE; break;
1830 case 'C': in_elem_bt[o] = T_CHAR; break;
1831 case 'D': in_elem_bt[o] = T_DOUBLE; break;
1832 case 'F': in_elem_bt[o] = T_FLOAT; break;
1833 case 'I': in_elem_bt[o] = T_INT; break;
1834 case 'J': in_elem_bt[o] = T_LONG; break;
1835 case 'S': in_elem_bt[o] = T_SHORT; break;
1836 case 'Z': in_elem_bt[o] = T_BOOLEAN; break;
1837 default: ShouldNotReachHere();
1838 }
1839 }
1840 } else {
1841 in_elem_bt[o] = T_VOID;
1842 switch(in_sig_bt[i]) { // PPC64: pass ints as longs.
1843 case T_BOOLEAN:
1844 case T_CHAR:
1845 case T_BYTE:
1846 case T_SHORT:
1847 case T_INT: in_elem_bt[++o] = T_VOID; break;
1848 default: break;
1849 }
1850 }
1851 if (in_sig_bt[i] != T_VOID) {
1852 assert(in_sig_bt[i] == ss.type(), "must match");
1853 ss.next();
1854 }
1855 }
1856 assert(i2l_argcnt==o, "must match");
1857
1858 convert_ints_to_longints(i2l_argcnt, total_in_args, in_sig_bt, in_regs); // PPC64: pass ints as longs.
1859
1860 for (int i = 0; i < total_in_args ; i++ ) {
1861 if (in_sig_bt[i] == T_ARRAY) {
1862 // Arrays are passed as int, elem* pair.
1863 out_sig_bt[argc++] = T_LONG; // PPC64: pass ints as longs.
1864 out_sig_bt[argc++] = T_INT;
1865 out_sig_bt[argc++] = T_ADDRESS;
1866 } else {
1867 out_sig_bt[argc++] = in_sig_bt[i];
1868 }
1869 }
1870 }
1871
1872
1873 // Compute the wrapper's frame size.
1874 // --------------------------------------------------------------------------
1875
1876 // Now figure out where the args must be stored and how much stack space
1877 // they require.
1878 //
1879 // Compute framesize for the wrapper. We need to handlize all oops in
1880 // incoming registers.
1881 //
1882 // Calculate the total number of stack slots we will need:
1883 // 1) abi requirements
1904 // - *_offset Indicates offset from SP in bytes.
1905
1906 int stack_slots = c_calling_convention(out_sig_bt, out_regs, out_regs2, total_c_args) // 1+2)
1907 + SharedRuntime::out_preserve_stack_slots(); // See c_calling_convention.
1908
1909 // Now the space for the inbound oop handle area.
1910 int total_save_slots = num_java_iarg_registers * VMRegImpl::slots_per_word;
1911 if (is_critical_native) {
1912 // Critical natives may have to call out so they need a save area
1913 // for register arguments.
1914 int double_slots = 0;
1915 int single_slots = 0;
1916 for (int i = 0; i < total_in_args; i++) {
1917 if (in_regs[i].first()->is_Register()) {
1918 const Register reg = in_regs[i].first()->as_Register();
1919 switch (in_sig_bt[i]) {
1920 case T_BOOLEAN:
1921 case T_BYTE:
1922 case T_SHORT:
1923 case T_CHAR:
1924 case T_INT: /*single_slots++;*/ break; // PPC64: pass ints as longs.
1925 case T_ARRAY:
1926 case T_LONG: double_slots++; break;
1927 default: ShouldNotReachHere();
1928 }
1929 } else if (in_regs[i].first()->is_FloatRegister()) {
1930 switch (in_sig_bt[i]) {
1931 case T_FLOAT: single_slots++; break;
1932 case T_DOUBLE: double_slots++; break;
1933 default: ShouldNotReachHere();
1934 }
1935 }
1936 }
1937 total_save_slots = double_slots * 2 + round_to(single_slots, 2); // round to even
1938 }
1939
1940 int oop_handle_slot_offset = stack_slots;
1941 stack_slots += total_save_slots; // 3)
1942
1943 int klass_slot_offset = 0;
1944 int klass_offset = -1;
2081 assert(!freg_destroyed[in_regs[in].first()->as_FloatRegister()->encoding()], "ack!");
2082 }
2083 if (out_regs[out].first()->is_Register()) {
2084 reg_destroyed[out_regs[out].first()->as_Register()->encoding()] = true;
2085 } else if (out_regs[out].first()->is_FloatRegister()) {
2086 freg_destroyed[out_regs[out].first()->as_FloatRegister()->encoding()] = true;
2087 }
2088 if (out_regs2[out].first()->is_Register()) {
2089 reg_destroyed[out_regs2[out].first()->as_Register()->encoding()] = true;
2090 } else if (out_regs2[out].first()->is_FloatRegister()) {
2091 freg_destroyed[out_regs2[out].first()->as_FloatRegister()->encoding()] = true;
2092 }
2093 #endif // ASSERT
2094
2095 switch (in_sig_bt[in]) {
2096 case T_BOOLEAN:
2097 case T_CHAR:
2098 case T_BYTE:
2099 case T_SHORT:
2100 case T_INT:
2101 guarantee(in > 0 && in_sig_bt[in-1] == T_LONG,
2102 "expecting type (T_LONG,bt) for bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
2103 break;
2104 case T_LONG:
2105 if (in_sig_bt[in+1] == T_VOID) {
2106 long_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
2107 } else {
2108 guarantee(in_sig_bt[in+1] == T_BOOLEAN || in_sig_bt[in+1] == T_CHAR ||
2109 in_sig_bt[in+1] == T_BYTE || in_sig_bt[in+1] == T_SHORT ||
2110 in_sig_bt[in+1] == T_INT,
2111 "expecting type (T_LONG,bt) for bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
2112 int_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
2113 }
2114 break;
2115 case T_ARRAY:
2116 if (is_critical_native) {
2117 int body_arg = out;
2118 out -= 2; // Point to length arg. PPC64: pass ints as longs.
2119 unpack_array_argument(masm, in_regs[in], in_elem_bt[in], out_regs[body_arg], out_regs[out],
2120 r_callers_sp, r_temp_1, r_temp_2);
2121 break;
2122 }
2123 case T_OBJECT:
2124 assert(!is_critical_native, "no oop arguments");
2125 object_move(masm, stack_slots,
2126 oop_map, oop_handle_slot_offset,
2127 ((in == 0) && (!method_is_static)), &receiver_offset,
2128 in_regs[in], out_regs[out],
2129 r_callers_sp, r_temp_1, r_temp_2);
2130 break;
2131 case T_VOID:
2132 break;
2133 case T_FLOAT:
2134 float_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
2135 if (out_regs2[out].first()->is_valid()) {
2136 float_move(masm, in_regs[in], out_regs2[out], r_callers_sp, r_temp_1);
2137 }
2138 break;
2170
2171 // NOTE:
2172 //
2173 // We have all of the arguments setup at this point.
2174 // We MUST NOT touch any outgoing regs from this point on.
2175 // So if we must call out we must push a new frame.
2176
2177 // Get current pc for oopmap, and load it patchable relative to global toc.
2178 oopmap_pc = (intptr_t) __ pc();
2179 __ calculate_address_from_global_toc(r_return_pc, (address)oopmap_pc, true, true, true, true);
2180
2181 // We use the same pc/oopMap repeatedly when we call out.
2182 oop_maps->add_gc_map(oopmap_pc - start_pc, oop_map);
2183
2184 // r_return_pc now has the pc loaded that we will use when we finally call
2185 // to native.
2186
2187 // Make sure that thread is non-volatile; it crosses a bunch of VM calls below.
2188 assert(R16_thread->is_nonvolatile(), "thread must be in non-volatile register");
2189
2190
2191 # if 0
2192 // DTrace method entry
2193 # endif
2194
2195 // Lock a synchronized method.
2196 // --------------------------------------------------------------------------
2197
2198 if (method->is_synchronized()) {
2199 assert(!is_critical_native, "unhandled");
2200 ConditionRegister r_flag = CCR1;
2201 Register r_oop = r_temp_4;
2202 const Register r_box = r_temp_5;
2203 Label done, locked;
2204
2205 // Load the oop for the object or class. r_carg2_classorobject contains
2206 // either the handlized oop from the incoming arguments or the handlized
2207 // class mirror (if the method is static).
2208 __ ld(r_oop, 0, r_carg2_classorobject);
2209
2210 // Get the lock box slot's address.
|
714 #endif
715 // We fill-out regs AND regs2 if an argument must be passed in a
716 // register AND in a stack slot. If regs2 is NULL in such a
717 // situation, we bail-out with a fatal error.
718 for (int i = 0; i < total_args_passed; ++i, ++arg) {
719 // Initialize regs2 to BAD.
720 if (regs2 != NULL) regs2[i].set_bad();
721
722 switch(sig_bt[i]) {
723
724 //
725 // If arguments 0-7 are integers, they are passed in integer registers.
726 // Argument i is placed in iarg_reg[i].
727 //
728 case T_BOOLEAN:
729 case T_CHAR:
730 case T_BYTE:
731 case T_SHORT:
732 case T_INT:
733 // We must cast ints to longs and use full 64 bit stack slots
734 // here. Thus fall through, handle as long.
735 case T_LONG:
736 case T_OBJECT:
737 case T_ARRAY:
738 case T_ADDRESS:
739 case T_METADATA:
740 // Oops are already boxed if required (JNI).
741 if (arg < Argument::n_int_register_parameters_c) {
742 reg = iarg_reg[arg];
743 } else {
744 reg = VMRegImpl::stack2reg(stk);
745 stk += inc_stk_for_longdouble;
746 }
747 regs[i].set2(reg);
748 break;
749
750 //
751 // Floats are treated differently from int regs: The first 13 float arguments
752 // are passed in registers (not the float args among the first 13 args).
753 // Thus argument i is NOT passed in farg_reg[i] if it is float. It is passed
754 // in farg_reg[j] if argument i is the j-th float argument of this call.
755 //
1241
1242 __ cmpdi(CCR0, r_oop, 0);
1243 __ bne(CCR0, skip);
1244 // Use a NULL handle if oop is NULL.
1245 __ li(r_handle, 0);
1246 __ bind(skip);
1247
1248 if (dst.first()->is_stack()) {
1249 // reg to stack
1250 __ std(r_handle, reg2offset(dst.first()), R1_SP);
1251 } else {
1252 // reg to reg
1253 // Nothing to do, r_handle is already the dst register.
1254 }
1255 }
1256 }
1257
1258 static void int_move(MacroAssembler*masm,
1259 VMRegPair src, VMRegPair dst,
1260 Register r_caller_sp, Register r_temp) {
1261 assert(src.first()->is_valid(), "incoming must be int");
1262 assert(dst.first()->is_valid() && dst.second() == dst.first()->next(), "outgoing must be long");
1263
1264 if (src.first()->is_stack()) {
1265 if (dst.first()->is_stack()) {
1266 // stack to stack
1267 __ lwa(r_temp, reg2offset(src.first()), r_caller_sp);
1268 __ std(r_temp, reg2offset(dst.first()), R1_SP);
1269 } else {
1270 // stack to reg
1271 __ lwa(dst.first()->as_Register(), reg2offset(src.first()), r_caller_sp);
1272 }
1273 } else if (dst.first()->is_stack()) {
1274 // reg to stack
1275 __ extsw(r_temp, src.first()->as_Register());
1276 __ std(r_temp, reg2offset(dst.first()), R1_SP);
1277 } else {
1278 // reg to reg
1279 __ extsw(dst.first()->as_Register(), src.first()->as_Register());
1280 }
1281 }
1730 (OopMapSet*)NULL);
1731 }
1732
1733 bool is_critical_native = true;
1734 address native_func = method->critical_native_function();
1735 if (native_func == NULL) {
1736 native_func = method->native_function();
1737 is_critical_native = false;
1738 }
1739 assert(native_func != NULL, "must have function");
1740
1741 // First, create signature for outgoing C call
1742 // --------------------------------------------------------------------------
1743
1744 int total_in_args = method->size_of_parameters();
1745 // We have received a description of where all the java args are located
1746 // on entry to the wrapper. We need to convert these args to where
1747 // the jni function will expect them. To figure out where they go
1748 // we convert the java signature to a C signature by inserting
1749 // the hidden arguments as arg[0] and possibly arg[1] (static method)
1750
1751 // Calculate the total number of C arguments and create arrays for the
1752 // signature and the outgoing registers.
1753 // On ppc64, we have two arrays for the outgoing registers, because
1754 // some floating-point arguments must be passed in registers _and_
1755 // in stack locations.
1756 bool method_is_static = method->is_static();
1757 int total_c_args = total_in_args;
1758
1759 if (!is_critical_native) {
1760 int n_hidden_args = method_is_static ? 2 : 1;
1761 total_c_args += n_hidden_args;
1762 } else {
1763 // No JNIEnv*, no this*, but unpacked arrays (base+length).
1764 for (int i = 0; i < total_in_args; i++) {
1765 if (in_sig_bt[i] == T_ARRAY) {
1766 total_c_args++;
1767 }
1768 }
1769 }
1770
1771 BasicType *out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
1772 VMRegPair *out_regs = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
1773 VMRegPair *out_regs2 = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
1774 BasicType* in_elem_bt = NULL;
1775
1776 // Create the signature for the C call:
1777 // 1) add the JNIEnv*
1778 // 2) add the class if the method is static
1779 // 3) copy the rest of the incoming signature (shifted by the number of
1780 // hidden arguments).
1781
1782 int argc = 0;
1783 if (!is_critical_native) {
1784 out_sig_bt[argc++] = T_ADDRESS;
1785 if (method->is_static()) {
1786 out_sig_bt[argc++] = T_OBJECT;
1787 }
1788
1789 for (int i = 0; i < total_in_args ; i++ ) {
1790 out_sig_bt[argc++] = in_sig_bt[i];
1791 }
1792 } else {
1793 Thread* THREAD = Thread::current();
1794 in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
1795 SignatureStream ss(method->signature());
1796 int o = 0;
1797 for (int i = 0; i < total_in_args ; i++, o++) {
1798 if (in_sig_bt[i] == T_ARRAY) {
1799 // Arrays are passed as int, elem* pair
1800 Symbol* atype = ss.as_symbol(CHECK_NULL);
1801 const char* at = atype->as_C_string();
1802 if (strlen(at) == 2) {
1803 assert(at[0] == '[', "must be");
1804 switch (at[1]) {
1805 case 'B': in_elem_bt[o] = T_BYTE; break;
1806 case 'C': in_elem_bt[o] = T_CHAR; break;
1807 case 'D': in_elem_bt[o] = T_DOUBLE; break;
1808 case 'F': in_elem_bt[o] = T_FLOAT; break;
1809 case 'I': in_elem_bt[o] = T_INT; break;
1810 case 'J': in_elem_bt[o] = T_LONG; break;
1811 case 'S': in_elem_bt[o] = T_SHORT; break;
1812 case 'Z': in_elem_bt[o] = T_BOOLEAN; break;
1813 default: ShouldNotReachHere();
1814 }
1815 }
1816 } else {
1817 in_elem_bt[o] = T_VOID;
1818 }
1819 if (in_sig_bt[i] != T_VOID) {
1820 assert(in_sig_bt[i] == ss.type(), "must match");
1821 ss.next();
1822 }
1823 }
1824
1825 for (int i = 0; i < total_in_args ; i++ ) {
1826 if (in_sig_bt[i] == T_ARRAY) {
1827 // Arrays are passed as int, elem* pair.
1828 out_sig_bt[argc++] = T_INT;
1829 out_sig_bt[argc++] = T_ADDRESS;
1830 } else {
1831 out_sig_bt[argc++] = in_sig_bt[i];
1832 }
1833 }
1834 }
1835
1836
1837 // Compute the wrapper's frame size.
1838 // --------------------------------------------------------------------------
1839
1840 // Now figure out where the args must be stored and how much stack space
1841 // they require.
1842 //
1843 // Compute framesize for the wrapper. We need to handlize all oops in
1844 // incoming registers.
1845 //
1846 // Calculate the total number of stack slots we will need:
1847 // 1) abi requirements
1868 // - *_offset Indicates offset from SP in bytes.
1869
1870 int stack_slots = c_calling_convention(out_sig_bt, out_regs, out_regs2, total_c_args) // 1+2)
1871 + SharedRuntime::out_preserve_stack_slots(); // See c_calling_convention.
1872
1873 // Now the space for the inbound oop handle area.
1874 int total_save_slots = num_java_iarg_registers * VMRegImpl::slots_per_word;
1875 if (is_critical_native) {
1876 // Critical natives may have to call out so they need a save area
1877 // for register arguments.
1878 int double_slots = 0;
1879 int single_slots = 0;
1880 for (int i = 0; i < total_in_args; i++) {
1881 if (in_regs[i].first()->is_Register()) {
1882 const Register reg = in_regs[i].first()->as_Register();
1883 switch (in_sig_bt[i]) {
1884 case T_BOOLEAN:
1885 case T_BYTE:
1886 case T_SHORT:
1887 case T_CHAR:
1888 case T_INT:
1889 // Fall through.
1890 case T_ARRAY:
1891 case T_LONG: double_slots++; break;
1892 default: ShouldNotReachHere();
1893 }
1894 } else if (in_regs[i].first()->is_FloatRegister()) {
1895 switch (in_sig_bt[i]) {
1896 case T_FLOAT: single_slots++; break;
1897 case T_DOUBLE: double_slots++; break;
1898 default: ShouldNotReachHere();
1899 }
1900 }
1901 }
1902 total_save_slots = double_slots * 2 + round_to(single_slots, 2); // round to even
1903 }
1904
1905 int oop_handle_slot_offset = stack_slots;
1906 stack_slots += total_save_slots; // 3)
1907
1908 int klass_slot_offset = 0;
1909 int klass_offset = -1;
2046 assert(!freg_destroyed[in_regs[in].first()->as_FloatRegister()->encoding()], "ack!");
2047 }
2048 if (out_regs[out].first()->is_Register()) {
2049 reg_destroyed[out_regs[out].first()->as_Register()->encoding()] = true;
2050 } else if (out_regs[out].first()->is_FloatRegister()) {
2051 freg_destroyed[out_regs[out].first()->as_FloatRegister()->encoding()] = true;
2052 }
2053 if (out_regs2[out].first()->is_Register()) {
2054 reg_destroyed[out_regs2[out].first()->as_Register()->encoding()] = true;
2055 } else if (out_regs2[out].first()->is_FloatRegister()) {
2056 freg_destroyed[out_regs2[out].first()->as_FloatRegister()->encoding()] = true;
2057 }
2058 #endif // ASSERT
2059
2060 switch (in_sig_bt[in]) {
2061 case T_BOOLEAN:
2062 case T_CHAR:
2063 case T_BYTE:
2064 case T_SHORT:
2065 case T_INT:
2066 // Move int and do sign extension.
2067 int_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
2068 break;
2069 case T_LONG:
2070 long_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
2071 break;
2072 case T_ARRAY:
2073 if (is_critical_native) {
2074 int body_arg = out;
2075 out -= 1; // Point to length arg.
2076 unpack_array_argument(masm, in_regs[in], in_elem_bt[in], out_regs[body_arg], out_regs[out],
2077 r_callers_sp, r_temp_1, r_temp_2);
2078 break;
2079 }
2080 case T_OBJECT:
2081 assert(!is_critical_native, "no oop arguments");
2082 object_move(masm, stack_slots,
2083 oop_map, oop_handle_slot_offset,
2084 ((in == 0) && (!method_is_static)), &receiver_offset,
2085 in_regs[in], out_regs[out],
2086 r_callers_sp, r_temp_1, r_temp_2);
2087 break;
2088 case T_VOID:
2089 break;
2090 case T_FLOAT:
2091 float_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
2092 if (out_regs2[out].first()->is_valid()) {
2093 float_move(masm, in_regs[in], out_regs2[out], r_callers_sp, r_temp_1);
2094 }
2095 break;
2127
2128 // NOTE:
2129 //
2130 // We have all of the arguments setup at this point.
2131 // We MUST NOT touch any outgoing regs from this point on.
2132 // So if we must call out we must push a new frame.
2133
2134 // Get current pc for oopmap, and load it patchable relative to global toc.
2135 oopmap_pc = (intptr_t) __ pc();
2136 __ calculate_address_from_global_toc(r_return_pc, (address)oopmap_pc, true, true, true, true);
2137
2138 // We use the same pc/oopMap repeatedly when we call out.
2139 oop_maps->add_gc_map(oopmap_pc - start_pc, oop_map);
2140
2141 // r_return_pc now has the pc loaded that we will use when we finally call
2142 // to native.
2143
2144 // Make sure that thread is non-volatile; it crosses a bunch of VM calls below.
2145 assert(R16_thread->is_nonvolatile(), "thread must be in non-volatile register");
2146
2147 # if 0
2148 // DTrace method entry
2149 # endif
2150
2151 // Lock a synchronized method.
2152 // --------------------------------------------------------------------------
2153
2154 if (method->is_synchronized()) {
2155 assert(!is_critical_native, "unhandled");
2156 ConditionRegister r_flag = CCR1;
2157 Register r_oop = r_temp_4;
2158 const Register r_box = r_temp_5;
2159 Label done, locked;
2160
2161 // Load the oop for the object or class. r_carg2_classorobject contains
2162 // either the handlized oop from the incoming arguments or the handlized
2163 // class mirror (if the method is static).
2164 __ ld(r_oop, 0, r_carg2_classorobject);
2165
2166 // Get the lock box slot's address.
|