hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp
changeset 31590 427d073af867
parent 31411 92e500124bca
child 33160 c59f1676d27e
child 33105 294e48b4f704
equal deleted inserted replaced
31589:e0d5c4d48464 31590:427d073af867
   729     case T_CHAR:
   729     case T_CHAR:
   730     case T_BYTE:
   730     case T_BYTE:
   731     case T_SHORT:
   731     case T_SHORT:
   732     case T_INT:
   732     case T_INT:
   733       // We must cast ints to longs and use full 64 bit stack slots
   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
   734       // here.  Thus fall through, handle as long.
   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:
   735     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:
   736     case T_OBJECT:
   752     case T_ARRAY:
   737     case T_ARRAY:
   753     case T_ADDRESS:
   738     case T_ADDRESS:
   754     case T_METADATA:
   739     case T_METADATA:
   755       // Oops are already boxed if required (JNI).
   740       // Oops are already boxed if required (JNI).
  1271 }
  1256 }
  1272 
  1257 
  1273 static void int_move(MacroAssembler*masm,
  1258 static void int_move(MacroAssembler*masm,
  1274                      VMRegPair src, VMRegPair dst,
  1259                      VMRegPair src, VMRegPair dst,
  1275                      Register r_caller_sp, Register r_temp) {
  1260                      Register r_caller_sp, Register r_temp) {
  1276   assert(src.first()->is_valid() && src.second() == src.first()->next(), "incoming must be long-int");
  1261   assert(src.first()->is_valid(), "incoming must be int");
  1277   assert(dst.first()->is_valid() && dst.second() == dst.first()->next(), "outgoing must be long");
  1262   assert(dst.first()->is_valid() && dst.second() == dst.first()->next(), "outgoing must be long");
  1278 
  1263 
  1279   if (src.first()->is_stack()) {
  1264   if (src.first()->is_stack()) {
  1280     if (dst.first()->is_stack()) {
  1265     if (dst.first()->is_stack()) {
  1281       // stack to stack
  1266       // stack to stack
  1760   // We have received a description of where all the java args are located
  1745   // 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
  1746   // 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
  1747   // the jni function will expect them. To figure out where they go
  1763   // we convert the java signature to a C signature by inserting
  1748   // we convert the java signature to a C signature by inserting
  1764   // the hidden arguments as arg[0] and possibly arg[1] (static method)
  1749   // 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 
  1750 
  1773   // Calculate the total number of C arguments and create arrays for the
  1751   // Calculate the total number of C arguments and create arrays for the
  1774   // signature and the outgoing registers.
  1752   // signature and the outgoing registers.
  1775   // On ppc64, we have two arrays for the outgoing registers, because
  1753   // On ppc64, we have two arrays for the outgoing registers, because
  1776   // some floating-point arguments must be passed in registers _and_
  1754   // some floating-point arguments must be passed in registers _and_
  1777   // in stack locations.
  1755   // in stack locations.
  1778   bool method_is_static = method->is_static();
  1756   bool method_is_static = method->is_static();
  1779   int  total_c_args     = i2l_argcnt;
  1757   int  total_c_args     = total_in_args;
  1780 
  1758 
  1781   if (!is_critical_native) {
  1759   if (!is_critical_native) {
  1782     int n_hidden_args = method_is_static ? 2 : 1;
  1760     int n_hidden_args = method_is_static ? 2 : 1;
  1783     total_c_args += n_hidden_args;
  1761     total_c_args += n_hidden_args;
  1784   } else {
  1762   } else {
  1785     // No JNIEnv*, no this*, but unpacked arrays (base+length).
  1763     // No JNIEnv*, no this*, but unpacked arrays (base+length).
  1786     for (int i = 0; i < total_in_args; i++) {
  1764     for (int i = 0; i < total_in_args; i++) {
  1787       if (in_sig_bt[i] == T_ARRAY) {
  1765       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)
  1766         total_c_args++;
  1789       }
  1767       }
  1790     }
  1768     }
  1791   }
  1769   }
  1792 
  1770 
  1793   BasicType *out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
  1771   BasicType *out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
  1801   //   3) copy the rest of the incoming signature (shifted by the number of
  1779   //   3) copy the rest of the incoming signature (shifted by the number of
  1802   //      hidden arguments).
  1780   //      hidden arguments).
  1803 
  1781 
  1804   int argc = 0;
  1782   int argc = 0;
  1805   if (!is_critical_native) {
  1783   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;
  1784     out_sig_bt[argc++] = T_ADDRESS;
  1809     if (method->is_static()) {
  1785     if (method->is_static()) {
  1810       out_sig_bt[argc++] = T_OBJECT;
  1786       out_sig_bt[argc++] = T_OBJECT;
  1811     }
  1787     }
  1812 
  1788 
  1813     for (int i = 0; i < total_in_args ; i++ ) {
  1789     for (int i = 0; i < total_in_args ; i++ ) {
  1814       out_sig_bt[argc++] = in_sig_bt[i];
  1790       out_sig_bt[argc++] = in_sig_bt[i];
  1815     }
  1791     }
  1816   } else {
  1792   } else {
  1817     Thread* THREAD = Thread::current();
  1793     Thread* THREAD = Thread::current();
  1818     in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, i2l_argcnt);
  1794     in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
  1819     SignatureStream ss(method->signature());
  1795     SignatureStream ss(method->signature());
  1820     int o = 0;
  1796     int o = 0;
  1821     for (int i = 0; i < total_in_args ; i++, o++) {
  1797     for (int i = 0; i < total_in_args ; i++, o++) {
  1822       if (in_sig_bt[i] == T_ARRAY) {
  1798       if (in_sig_bt[i] == T_ARRAY) {
  1823         // Arrays are passed as int, elem* pair
  1799         // Arrays are passed as int, elem* pair
  1837             default: ShouldNotReachHere();
  1813             default: ShouldNotReachHere();
  1838           }
  1814           }
  1839         }
  1815         }
  1840       } else {
  1816       } else {
  1841         in_elem_bt[o] = T_VOID;
  1817         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       }
  1818       }
  1851       if (in_sig_bt[i] != T_VOID) {
  1819       if (in_sig_bt[i] != T_VOID) {
  1852         assert(in_sig_bt[i] == ss.type(), "must match");
  1820         assert(in_sig_bt[i] == ss.type(), "must match");
  1853         ss.next();
  1821         ss.next();
  1854       }
  1822       }
  1855     }
  1823     }
  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 
  1824 
  1860     for (int i = 0; i < total_in_args ; i++ ) {
  1825     for (int i = 0; i < total_in_args ; i++ ) {
  1861       if (in_sig_bt[i] == T_ARRAY) {
  1826       if (in_sig_bt[i] == T_ARRAY) {
  1862         // Arrays are passed as int, elem* pair.
  1827         // 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;
  1828         out_sig_bt[argc++] = T_INT;
  1865         out_sig_bt[argc++] = T_ADDRESS;
  1829         out_sig_bt[argc++] = T_ADDRESS;
  1866       } else {
  1830       } else {
  1867         out_sig_bt[argc++] = in_sig_bt[i];
  1831         out_sig_bt[argc++] = in_sig_bt[i];
  1868       }
  1832       }
  1919         switch (in_sig_bt[i]) {
  1883         switch (in_sig_bt[i]) {
  1920           case T_BOOLEAN:
  1884           case T_BOOLEAN:
  1921           case T_BYTE:
  1885           case T_BYTE:
  1922           case T_SHORT:
  1886           case T_SHORT:
  1923           case T_CHAR:
  1887           case T_CHAR:
  1924           case T_INT:  /*single_slots++;*/ break; // PPC64: pass ints as longs.
  1888           case T_INT:
       
  1889           // Fall through.
  1925           case T_ARRAY:
  1890           case T_ARRAY:
  1926           case T_LONG: double_slots++; break;
  1891           case T_LONG: double_slots++; break;
  1927           default:  ShouldNotReachHere();
  1892           default:  ShouldNotReachHere();
  1928         }
  1893         }
  1929       } else if (in_regs[i].first()->is_FloatRegister()) {
  1894       } else if (in_regs[i].first()->is_FloatRegister()) {
  2017   // --------------------------------------------------------------------------
  1982   // --------------------------------------------------------------------------
  2018   vep_start_pc = (intptr_t)__ pc();
  1983   vep_start_pc = (intptr_t)__ pc();
  2019 
  1984 
  2020   __ save_LR_CR(r_temp_1);
  1985   __ save_LR_CR(r_temp_1);
  2021   __ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame.
  1986   __ generate_stack_overflow_check(frame_size_in_bytes); // Check before creating frame.
  2022   __ mr(r_callers_sp, R1_SP);                       // Remember frame pointer.
  1987   __ mr(r_callers_sp, R1_SP);                            // Remember frame pointer.
  2023   __ push_frame(frame_size_in_bytes, r_temp_1);          // Push the c2n adapter's frame.
  1988   __ push_frame(frame_size_in_bytes, r_temp_1);          // Push the c2n adapter's frame.
  2024   frame_done_pc = (intptr_t)__ pc();
  1989   frame_done_pc = (intptr_t)__ pc();
  2025 
  1990 
  2026   __ verify_thread();
  1991   __ verify_thread();
  2027 
  1992 
  2096       case T_BOOLEAN:
  2061       case T_BOOLEAN:
  2097       case T_CHAR:
  2062       case T_CHAR:
  2098       case T_BYTE:
  2063       case T_BYTE:
  2099       case T_SHORT:
  2064       case T_SHORT:
  2100       case T_INT:
  2065       case T_INT:
  2101         guarantee(in > 0 && in_sig_bt[in-1] == T_LONG,
  2066         // Move int and do sign extension.
  2102                   "expecting type (T_LONG,bt) for bt in {T_BOOLEAN, T_CHAR, T_BYTE, T_SHORT, T_INT}");
  2067         int_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
  2103         break;
  2068         break;
  2104       case T_LONG:
  2069       case T_LONG:
  2105         if (in_sig_bt[in+1] == T_VOID) {
  2070         long_move(masm, in_regs[in], out_regs[out], r_callers_sp, r_temp_1);
  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;
  2071         break;
  2115       case T_ARRAY:
  2072       case T_ARRAY:
  2116         if (is_critical_native) {
  2073         if (is_critical_native) {
  2117           int body_arg = out;
  2074           int body_arg = out;
  2118           out -= 2; // Point to length arg. PPC64: pass ints as longs.
  2075           out -= 1; // Point to length arg.
  2119           unpack_array_argument(masm, in_regs[in], in_elem_bt[in], out_regs[body_arg], out_regs[out],
  2076           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);
  2077                                 r_callers_sp, r_temp_1, r_temp_2);
  2121           break;
  2078           break;
  2122         }
  2079         }
  2123       case T_OBJECT:
  2080       case T_OBJECT:
  2185   // to native.
  2142   // to native.
  2186 
  2143 
  2187   // Make sure that thread is non-volatile; it crosses a bunch of VM calls below.
  2144   // 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");
  2145   assert(R16_thread->is_nonvolatile(), "thread must be in non-volatile register");
  2189 
  2146 
  2190 
       
  2191 # if 0
  2147 # if 0
  2192   // DTrace method entry
  2148   // DTrace method entry
  2193 # endif
  2149 # endif
  2194 
  2150 
  2195   // Lock a synchronized method.
  2151   // Lock a synchronized method.