< prev index next >

src/hotspot/cpu/sparc/templateTable_sparc.cpp

Print this page
rev 47594 : imported patch Interpreter-Poll-7
rev 47595 : imported patch Interpreter-Poll-Wide_Ret-8
rev 47597 : imported patch Interpreter-Poll-Switch-10


1710 
1711   // check against lo & hi
1712   __ cmp( Otos_i, O2);
1713   __ br( Assembler::less, false, Assembler::pn, default_case);
1714   __ delayed()->cmp( Otos_i, O3 );
1715   __ br( Assembler::greater, false, Assembler::pn, default_case);
1716   // lookup dispatch offset
1717   __ delayed()->sub(Otos_i, O2, O2);
1718   __ profile_switch_case(O2, O3, G3_scratch, G4_scratch);
1719   __ sll(O2, LogBytesPerInt, O2);
1720   __ add(O2, 3 * BytesPerInt, O2);
1721   __ ba(continue_execution);
1722   __ delayed()->ld(O1, O2, O2);
1723   // handle default
1724   __ bind(default_case);
1725   __ profile_switch_default(O3);
1726   __ ld(O1, 0, O2); // get default offset
1727   // continue execution
1728   __ bind(continue_execution);
1729   __ add(Lbcp, O2, Lbcp);
1730   __ dispatch_next(vtos);
1731 }
1732 
1733 
1734 void TemplateTable::lookupswitch() {
1735   transition(itos, itos);
1736   __ stop("lookupswitch bytecode should have been rewritten");
1737 }
1738 
1739 void TemplateTable::fast_linearswitch() {
1740   transition(itos, vtos);
1741     Label loop_entry, loop, found, continue_execution;
1742   // align bcp
1743   __ add(Lbcp, BytesPerInt, O1);
1744   __ and3(O1, -BytesPerInt, O1);
1745  // set counter
1746   __ ld(O1, BytesPerInt, O2);
1747   __ sll(O2, LogBytesPerInt + 1, O2); // in word-pairs
1748   __ add(O1, 2 * BytesPerInt, O3); // set first pair addr
1749   __ ba(loop_entry);
1750   __ delayed()->add(O3, O2, O2); // counter now points past last pair


1762   __ delayed()->ld(O3, 0, O4);
1763 
1764   // default case
1765   __ ld(O1, 0, O4); // get default offset
1766   if (ProfileInterpreter) {
1767     __ profile_switch_default(O3);
1768     __ ba_short(continue_execution);
1769   }
1770 
1771   // entry found -> get offset
1772   __ bind(found);
1773   if (ProfileInterpreter) {
1774     __ sub(O3, O1, O3);
1775     __ sub(O3, 2*BytesPerInt, O3);
1776     __ srl(O3, LogBytesPerInt + 1, O3); // in word-pairs
1777     __ profile_switch_case(O3, O1, O2, G3_scratch);
1778 
1779     __ bind(continue_execution);
1780   }
1781   __ add(Lbcp, O4, Lbcp);
1782   __ dispatch_next(vtos);
1783 }
1784 
1785 
1786 void TemplateTable::fast_binaryswitch() {
1787   transition(itos, vtos);
1788   // Implementation using the following core algorithm: (copied from Intel)
1789   //
1790   // int binary_search(int key, LookupswitchPair* array, int n) {
1791   //   // Binary search according to "Methodik des Programmierens" by
1792   //   // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985.
1793   //   int i = 0;
1794   //   int j = n;
1795   //   while (i+1 < j) {
1796   //     // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q)
1797   //     // with      Q: for all i: 0 <= i < n: key < a[i]
1798   //     // where a stands for the array and assuming that the (inexisting)
1799   //     // element a[n] is infinitely big.
1800   //     int h = (i + j) >> 1;
1801   //     // i < h < j
1802   //     if (key < array[h].fast_match()) {


1871   // (Rscratch is already in the native byte-ordering.)
1872   __ cmp( Rkey, Rscratch );
1873   __ br( Assembler::notEqual, true, Assembler::pn, default_case );
1874   __ delayed()->ld( Rarray, -2 * BytesPerInt, Rj ); // load default offset -> j
1875 
1876   // entry found -> j = offset
1877   __ inc( Ri, BytesPerInt );
1878   __ profile_switch_case(Rh, Rj, Rscratch, Rkey);
1879   __ ld( Rarray, Ri, Rj );
1880   // (Rj is already in the native byte-ordering.)
1881 
1882   if (ProfileInterpreter) {
1883     __ ba_short(continue_execution);
1884   }
1885 
1886   __ bind(default_case); // fall through (if not profiling)
1887   __ profile_switch_default(Ri);
1888 
1889   __ bind(continue_execution);
1890   __ add( Lbcp, Rj, Lbcp );
1891   __ dispatch_next( vtos );
1892 }
1893 
1894 
1895 void TemplateTable::_return(TosState state) {
1896   transition(state, state);
1897   assert(_desc->calls_vm(), "inconsistent calls_vm information");
1898 
1899   if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
1900     assert(state == vtos, "only valid state");
1901     __ mov(G0, G3_scratch);
1902     __ access_local_ptr(G3_scratch, Otos_i);
1903     __ load_klass(Otos_i, O2);
1904     __ set(JVM_ACC_HAS_FINALIZER, G3);
1905     __ ld(O2, in_bytes(Klass::access_flags_offset()), O2);
1906     __ andcc(G3, O2, G0);
1907     Label skip_register_finalizer;
1908     __ br(Assembler::zero, false, Assembler::pn, skip_register_finalizer);
1909     __ delayed()->nop();
1910 
1911     // Call out to do finalizer registration




1710 
1711   // check against lo & hi
1712   __ cmp( Otos_i, O2);
1713   __ br( Assembler::less, false, Assembler::pn, default_case);
1714   __ delayed()->cmp( Otos_i, O3 );
1715   __ br( Assembler::greater, false, Assembler::pn, default_case);
1716   // lookup dispatch offset
1717   __ delayed()->sub(Otos_i, O2, O2);
1718   __ profile_switch_case(O2, O3, G3_scratch, G4_scratch);
1719   __ sll(O2, LogBytesPerInt, O2);
1720   __ add(O2, 3 * BytesPerInt, O2);
1721   __ ba(continue_execution);
1722   __ delayed()->ld(O1, O2, O2);
1723   // handle default
1724   __ bind(default_case);
1725   __ profile_switch_default(O3);
1726   __ ld(O1, 0, O2); // get default offset
1727   // continue execution
1728   __ bind(continue_execution);
1729   __ add(Lbcp, O2, Lbcp);
1730   __ dispatch_next(vtos, 0, true);
1731 }
1732 
1733 
1734 void TemplateTable::lookupswitch() {
1735   transition(itos, itos);
1736   __ stop("lookupswitch bytecode should have been rewritten");
1737 }
1738 
1739 void TemplateTable::fast_linearswitch() {
1740   transition(itos, vtos);
1741     Label loop_entry, loop, found, continue_execution;
1742   // align bcp
1743   __ add(Lbcp, BytesPerInt, O1);
1744   __ and3(O1, -BytesPerInt, O1);
1745  // set counter
1746   __ ld(O1, BytesPerInt, O2);
1747   __ sll(O2, LogBytesPerInt + 1, O2); // in word-pairs
1748   __ add(O1, 2 * BytesPerInt, O3); // set first pair addr
1749   __ ba(loop_entry);
1750   __ delayed()->add(O3, O2, O2); // counter now points past last pair


1762   __ delayed()->ld(O3, 0, O4);
1763 
1764   // default case
1765   __ ld(O1, 0, O4); // get default offset
1766   if (ProfileInterpreter) {
1767     __ profile_switch_default(O3);
1768     __ ba_short(continue_execution);
1769   }
1770 
1771   // entry found -> get offset
1772   __ bind(found);
1773   if (ProfileInterpreter) {
1774     __ sub(O3, O1, O3);
1775     __ sub(O3, 2*BytesPerInt, O3);
1776     __ srl(O3, LogBytesPerInt + 1, O3); // in word-pairs
1777     __ profile_switch_case(O3, O1, O2, G3_scratch);
1778 
1779     __ bind(continue_execution);
1780   }
1781   __ add(Lbcp, O4, Lbcp);
1782   __ dispatch_next(vtos, 0, true);
1783 }
1784 
1785 
1786 void TemplateTable::fast_binaryswitch() {
1787   transition(itos, vtos);
1788   // Implementation using the following core algorithm: (copied from Intel)
1789   //
1790   // int binary_search(int key, LookupswitchPair* array, int n) {
1791   //   // Binary search according to "Methodik des Programmierens" by
1792   //   // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985.
1793   //   int i = 0;
1794   //   int j = n;
1795   //   while (i+1 < j) {
1796   //     // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q)
1797   //     // with      Q: for all i: 0 <= i < n: key < a[i]
1798   //     // where a stands for the array and assuming that the (inexisting)
1799   //     // element a[n] is infinitely big.
1800   //     int h = (i + j) >> 1;
1801   //     // i < h < j
1802   //     if (key < array[h].fast_match()) {


1871   // (Rscratch is already in the native byte-ordering.)
1872   __ cmp( Rkey, Rscratch );
1873   __ br( Assembler::notEqual, true, Assembler::pn, default_case );
1874   __ delayed()->ld( Rarray, -2 * BytesPerInt, Rj ); // load default offset -> j
1875 
1876   // entry found -> j = offset
1877   __ inc( Ri, BytesPerInt );
1878   __ profile_switch_case(Rh, Rj, Rscratch, Rkey);
1879   __ ld( Rarray, Ri, Rj );
1880   // (Rj is already in the native byte-ordering.)
1881 
1882   if (ProfileInterpreter) {
1883     __ ba_short(continue_execution);
1884   }
1885 
1886   __ bind(default_case); // fall through (if not profiling)
1887   __ profile_switch_default(Ri);
1888 
1889   __ bind(continue_execution);
1890   __ add( Lbcp, Rj, Lbcp );
1891   __ dispatch_next(vtos, 0, true);
1892 }
1893 
1894 
1895 void TemplateTable::_return(TosState state) {
1896   transition(state, state);
1897   assert(_desc->calls_vm(), "inconsistent calls_vm information");
1898 
1899   if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
1900     assert(state == vtos, "only valid state");
1901     __ mov(G0, G3_scratch);
1902     __ access_local_ptr(G3_scratch, Otos_i);
1903     __ load_klass(Otos_i, O2);
1904     __ set(JVM_ACC_HAS_FINALIZER, G3);
1905     __ ld(O2, in_bytes(Klass::access_flags_offset()), O2);
1906     __ andcc(G3, O2, G0);
1907     Label skip_register_finalizer;
1908     __ br(Assembler::zero, false, Assembler::pn, skip_register_finalizer);
1909     __ delayed()->nop();
1910 
1911     // Call out to do finalizer registration


< prev index next >