src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6911204 Sdiff src/share/vm/runtime

src/share/vm/runtime/sharedRuntime.cpp

Print this page




1770   tty->print_cr("\t  %9d  (%3.0f%%)   megamorphic      ", _nof_megamorphic_interface_calls, percent(_nof_megamorphic_interface_calls, _nof_interface_calls));
1771   tty->print_cr("\t%9d   (%4.1f%%) static/special calls", _nof_static_calls, percent(_nof_static_calls, total));
1772   tty->print_cr("\t  %9d  (%3.0f%%)   inlined          ", _nof_inlined_static_calls, percent(_nof_inlined_static_calls, _nof_static_calls));
1773   tty->cr();
1774   tty->print_cr("Note 1: counter updates are not MT-safe.");
1775   tty->print_cr("Note 2: %% in major categories are relative to total non-inlined calls;");
1776   tty->print_cr("        %% in nested categories are relative to their category");
1777   tty->print_cr("        (and thus add up to more than 100%% with inlining)");
1778   tty->cr();
1779 
1780   MethodArityHistogram h;
1781 }
1782 #endif
1783 
1784 
1785 // A simple wrapper class around the calling convention information
1786 // that allows sharing of adapters for the same calling convention.
1787 class AdapterFingerPrint : public CHeapObj {
1788  private:
1789   union {
1790     signed char  _compact[12];
1791     int          _compact_int[3];
1792     intptr_t*    _fingerprint;
1793   } _value;
1794   int _length; // A negative length indicates that _value._fingerprint is the array.
1795                // Otherwise it's in the compact form.
1796 





































1797  public:
1798   AdapterFingerPrint(int total_args_passed, VMRegPair* regs) {
1799     assert(sizeof(_value._compact) == sizeof(_value._compact_int), "must match");
1800     _length = total_args_passed * 2;
1801     if (_length < (int)sizeof(_value._compact)) {
1802       _value._compact_int[0] = _value._compact_int[1] = _value._compact_int[2] = 0;


1803       // Storing the signature encoded as signed chars hits about 98%
1804       // of the time.
1805       signed char* ptr = _value._compact;
1806       int o = 0;
1807       for (int i = 0; i < total_args_passed; i++) {
1808         VMRegPair pair = regs[i];
1809         intptr_t v1 = pair.first()->value();
1810         intptr_t v2 = pair.second()->value();
1811         if (v1 == (signed char) v1 &&
1812             v2 == (signed char) v2) {
1813           _value._compact[o++] = v1;
1814           _value._compact[o++] = v2;
1815         } else {
1816           goto big;


1817         }







1818       }
1819       _length = -_length;
1820       return;
1821     }
1822   big:
1823     _value._fingerprint = NEW_C_HEAP_ARRAY(intptr_t, _length);
1824     int o = 0;
1825     for (int i = 0; i < total_args_passed; i++) {
1826       VMRegPair pair = regs[i];
1827       intptr_t v1 = pair.first()->value();
1828       intptr_t v2 = pair.second()->value();
1829       _value._fingerprint[o++] = v1;
1830       _value._fingerprint[o++] = v2;
1831     }
1832   }
1833 
1834   AdapterFingerPrint(AdapterFingerPrint* orig) {
1835     _length = orig->_length;
1836     _value = orig->_value;
1837     // take ownership of any storage by destroying the length
1838     orig->_length = 0;
1839   }
1840 
1841   ~AdapterFingerPrint() {
1842     if (_length > 0) {
1843       FREE_C_HEAP_ARRAY(int, _value._fingerprint);
1844     }
1845   }
1846 
1847   AdapterFingerPrint* allocate() {
1848     return new AdapterFingerPrint(this);
1849   }
1850 
1851   intptr_t value(int index) {
1852     if (_length < 0) {
1853       return _value._compact[index];
1854     }
1855     return _value._fingerprint[index];
1856   }
1857   int length() {
1858     if (_length < 0) return -_length;
1859     return _length;
1860   }
1861 
1862   bool is_compact() {
1863     return _length <= 0;
1864   }
1865 
1866   unsigned int compute_hash() {
1867     intptr_t hash = 0;
1868     for (int i = 0; i < length(); i++) {
1869       intptr_t v = value(i);
1870       hash = (hash << 8) ^ v ^ (hash >> 5);
1871     }
1872     return (unsigned int)hash;
1873   }
1874 
1875   const char* as_string() {
1876     stringStream st;
1877     for (int i = 0; i < length(); i++) {
1878       st.print(PTR_FORMAT, value(i));
1879     }
1880     return st.as_string();
1881   }
1882 
1883   bool equals(AdapterFingerPrint* other) {
1884     if (other->_length != _length) {
1885       return false;
1886     }
1887     if (_length < 0) {
1888       return _value._compact_int[0] == other->_value._compact_int[0] &&
1889              _value._compact_int[1] == other->_value._compact_int[1] &&
1890              _value._compact_int[2] == other->_value._compact_int[2];
1891     } else {
1892       for (int i = 0; i < _length; i++) {
1893         if (_value._fingerprint[i] != other->_value._fingerprint[i]) {
1894           return false;
1895         }
1896       }
1897     }
1898     return true;
1899   }
1900 };
1901 
1902 
1903 // A hashtable mapping from AdapterFingerPrints to AdapterHandlerEntries
1904 class AdapterHandlerTable : public BasicHashtable {
1905   friend class AdapterHandlerTableIterator;
1906 
1907  private:
1908 
1909 #ifdef ASSERT
1910   static int _lookups; // number of calls to lookup


1919   }
1920 
1921  public:
1922   AdapterHandlerTable()
1923     : BasicHashtable(293, sizeof(AdapterHandlerEntry)) { }
1924 
1925   // Create a new entry suitable for insertion in the table
1926   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
1927     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable::new_entry(fingerprint->compute_hash());
1928     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
1929     return entry;
1930   }
1931 
1932   // Insert an entry into the table
1933   void add(AdapterHandlerEntry* entry) {
1934     int index = hash_to_index(entry->hash());
1935     add_entry(index, entry);
1936   }
1937 
1938   // Find a entry with the same fingerprint if it exists
1939   AdapterHandlerEntry* lookup(int total_args_passed, VMRegPair* regs) {
1940     debug_only(_lookups++);
1941     AdapterFingerPrint fp(total_args_passed, regs);
1942     unsigned int hash = fp.compute_hash();
1943     int index = hash_to_index(hash);
1944     for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) {
1945       debug_only(_buckets++);
1946       if (e->hash() == hash) {
1947         debug_only(_equals++);
1948         if (fp.equals(e->fingerprint())) {
1949 #ifdef ASSERT
1950           if (fp.is_compact()) _compact++;
1951           _hits++;
1952 #endif
1953           return e;
1954         }
1955       }
1956     }
1957     return NULL;
1958   }
1959 
1960   void print_statistics() {
1961     ResourceMark rm;


2074   // Get the address of the ic_miss handlers before we grab the
2075   // AdapterHandlerLibrary_lock. This fixes bug 6236259 which
2076   // was caused by the initialization of the stubs happening
2077   // while we held the lock and then notifying jvmti while
2078   // holding it. This just forces the initialization to be a little
2079   // earlier.
2080   address ic_miss = SharedRuntime::get_ic_miss_stub();
2081   assert(ic_miss != NULL, "must have handler");
2082 
2083   ResourceMark rm;
2084 
2085   NOT_PRODUCT(int code_size);
2086   BufferBlob *B = NULL;
2087   AdapterHandlerEntry* entry = NULL;
2088   AdapterFingerPrint* fingerprint = NULL;
2089   {
2090     MutexLocker mu(AdapterHandlerLibrary_lock);
2091     // make sure data structure is initialized
2092     initialize();
2093 


2094     if (method->is_abstract()) {
2095       return _abstract_method_handler;
2096     }
2097 
2098     // Fill in the signature array, for the calling-convention call.
2099     int total_args_passed = method->size_of_parameters(); // All args on stack
2100 
2101     BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2102     VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2103     int i = 0;
2104     if (!method->is_static())  // Pass in receiver first
2105       sig_bt[i++] = T_OBJECT;
2106     for (SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
2107       sig_bt[i++] = ss.type();  // Collect remaining bits of signature
2108       if (ss.type() == T_LONG || ss.type() == T_DOUBLE)
2109         sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
2110     }
2111     assert(i == total_args_passed, "");
2112 
2113     // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
2114     int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
2115 
2116     // Lookup method signature's fingerprint
2117     entry = _adapters->lookup(total_args_passed, regs);
2118     if (entry != NULL) {




2119       return entry;
2120     }

2121 



2122     // Make a C heap allocated version of the fingerprint to store in the adapter
2123     fingerprint = new AdapterFingerPrint(total_args_passed, regs);
2124 
2125     // Create I2C & C2I handlers
2126 
2127     BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
2128     if (buf != NULL) {
2129       CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
2130       short buffer_locs[20];
2131       buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs,
2132                                              sizeof(buffer_locs)/sizeof(relocInfo));
2133       MacroAssembler _masm(&buffer);
2134 
2135       entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
2136                                                      total_args_passed,
2137                                                      comp_args_on_stack,
2138                                                      sig_bt,
2139                                                      regs,
2140                                                      fingerprint);
2141 








2142       B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
2143       NOT_PRODUCT(code_size = buffer.code_size());
2144     }
2145     if (B == NULL) {
2146       // CodeCache is full, disable compilation
2147       // Ought to log this but compile log is only per compile thread
2148       // and we're some non descript Java thread.
2149       MutexUnlocker mu(AdapterHandlerLibrary_lock);
2150       CompileBroker::handle_full_code_cache();
2151       return NULL; // Out of CodeCache space
2152     }
2153     entry->relocate(B->instructions_begin());
2154 #ifndef PRODUCT
2155     // debugging suppport
2156     if (PrintAdapterHandlers) {
2157       tty->cr();
2158       tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = %s, %d bytes generated)",
2159                     _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"),
2160                     method->signature()->as_C_string(), fingerprint->as_string(), code_size );
2161       tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());


2176                  B->instructions_begin());
2177     VTune::register_stub(blob_id, B->instructions_begin(), B->instructions_end());
2178     Forte::register_stub(blob_id, B->instructions_begin(), B->instructions_end());
2179 
2180     if (JvmtiExport::should_post_dynamic_code_generated()) {
2181       JvmtiExport::post_dynamic_code_generated(blob_id,
2182                                                B->instructions_begin(),
2183                                                B->instructions_end());
2184     }
2185   }
2186   return entry;
2187 }
2188 
2189 void AdapterHandlerEntry::relocate(address new_base) {
2190     ptrdiff_t delta = new_base - _i2c_entry;
2191     _i2c_entry += delta;
2192     _c2i_entry += delta;
2193     _c2i_unverified_entry += delta;
2194 }
2195 























2196 // Create a native wrapper for this native method.  The wrapper converts the
2197 // java compiled calling convention to the native convention, handlizes
2198 // arguments, and transitions to native.  On return from the native we transition
2199 // back to java blocking if a safepoint is in progress.
2200 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method) {
2201   ResourceMark rm;
2202   nmethod* nm = NULL;
2203 
2204   if (PrintCompilation) {
2205     ttyLocker ttyl;
2206     tty->print("---   n%s ", (method->is_synchronized() ? "s" : " "));
2207     method->print_short_name(tty);
2208     if (method->is_static()) {
2209       tty->print(" (static)");
2210     }
2211     tty->cr();
2212   }
2213 
2214   assert(method->has_native_function(), "must have something valid to call!");
2215 




1770   tty->print_cr("\t  %9d  (%3.0f%%)   megamorphic      ", _nof_megamorphic_interface_calls, percent(_nof_megamorphic_interface_calls, _nof_interface_calls));
1771   tty->print_cr("\t%9d   (%4.1f%%) static/special calls", _nof_static_calls, percent(_nof_static_calls, total));
1772   tty->print_cr("\t  %9d  (%3.0f%%)   inlined          ", _nof_inlined_static_calls, percent(_nof_inlined_static_calls, _nof_static_calls));
1773   tty->cr();
1774   tty->print_cr("Note 1: counter updates are not MT-safe.");
1775   tty->print_cr("Note 2: %% in major categories are relative to total non-inlined calls;");
1776   tty->print_cr("        %% in nested categories are relative to their category");
1777   tty->print_cr("        (and thus add up to more than 100%% with inlining)");
1778   tty->cr();
1779 
1780   MethodArityHistogram h;
1781 }
1782 #endif
1783 
1784 
1785 // A simple wrapper class around the calling convention information
1786 // that allows sharing of adapters for the same calling convention.
1787 class AdapterFingerPrint : public CHeapObj {
1788  private:
1789   union {
1790     int  _compact[3];
1791     int* _fingerprint;

1792   } _value;
1793   int _length; // A negative length indicates the fingerprint is in the compact form, 
1794                // Otherwise _value._fingerprint is the array.
1795 
1796   // Remap BasicTypes that are handled equivalently by the adapters.
1797   // These are correct for the current system but someday it might be
1798   // necessary to make this mapping platform dependent.
1799   static BasicType adapter_encoding(BasicType in) {
1800     assert((~0xf & in) == 0, "must fit in 4 bits");
1801     switch(in) {
1802       case T_BOOLEAN:
1803       case T_BYTE:
1804       case T_SHORT:
1805       case T_CHAR:
1806         // There are all promoted to T_INT in the calling convention
1807         return T_INT;
1808         
1809       case T_OBJECT:
1810       case T_ARRAY:
1811         if (!TaggedStackInterpreter) {
1812 #ifdef _LP64
1813           return T_LONG;
1814 #else
1815           return T_INT;
1816 #endif
1817         }
1818         return T_OBJECT;
1819 
1820       case T_INT:
1821       case T_LONG:
1822       case T_FLOAT:
1823       case T_DOUBLE:
1824       case T_VOID:
1825         return in;
1826 
1827       default:
1828         ShouldNotReachHere();
1829         return T_CONFLICT;
1830     }
1831   }
1832 
1833  public:
1834   AdapterFingerPrint(int total_args_passed, BasicType* sig_bt) {
1835     // The fingerprint is based on the BasicType signature encoded
1836     // into an array of ints with four entries per int.
1837     int* ptr;
1838     int l = (total_args_passed + 3) >> 2;
1839     if (l <= (int)sizeof(_value._compact) / sizeof(int)) {
1840       _value._compact[0] = _value._compact[1] = _value._compact[2] = 0;
1841       // Storing the signature encoded as signed chars hits about 98%
1842       // of the time.
1843       _length = -l;
1844       ptr = _value._compact;








1845     } else {
1846       _length = l;
1847       _value._fingerprint = NEW_C_HEAP_ARRAY(int, _length);
1848       ptr = _value._fingerprint;
1849     }
1850 
1851     int i = 0;
1852     for (int o = 0; o < l;) {
1853       int value = 0;
1854       for (int i = 0; i < 4; i++) {
1855         if (i + o * 4 < total_args_passed)
1856           value = (value << 4) | adapter_encoding(sig_bt[i + o * 4]);
1857       }
1858       ptr[o++] = value;

1859     }









1860   }

1861 







1862   ~AdapterFingerPrint() {
1863     if (_length > 0) {
1864       FREE_C_HEAP_ARRAY(int, _value._fingerprint);
1865     }
1866   }
1867 
1868   int value(int index) {




1869     if (_length < 0) {
1870       return _value._compact[index];
1871     }
1872     return _value._fingerprint[index];
1873   }
1874   int length() {
1875     if (_length < 0) return -_length;
1876     return _length;
1877   }
1878 
1879   bool is_compact() {
1880     return _length <= 0;
1881   }
1882 
1883   unsigned int compute_hash() {
1884     int hash = 0;
1885     for (int i = 0; i < length(); i++) {
1886       int v = value(i);
1887       hash = (hash << 8) ^ v ^ (hash >> 5);
1888     }
1889     return (unsigned int)hash;
1890   }
1891 
1892   const char* as_string() {
1893     stringStream st;
1894     for (int i = 0; i < length(); i++) {
1895       st.print(PTR_FORMAT, value(i));
1896     }
1897     return st.as_string();
1898   }
1899 
1900   bool equals(AdapterFingerPrint* other) {
1901     if (other->_length != _length) {
1902       return false;
1903     }
1904     if (_length < 0) {
1905       return _value._compact[0] == other->_value._compact[0] &&
1906              _value._compact[1] == other->_value._compact[1] &&
1907              _value._compact[2] == other->_value._compact[2];
1908     } else {
1909       for (int i = 0; i < _length; i++) {
1910         if (_value._fingerprint[i] != other->_value._fingerprint[i]) {
1911           return false;
1912         }
1913       }
1914     }
1915     return true;
1916   }
1917 };
1918 
1919 
1920 // A hashtable mapping from AdapterFingerPrints to AdapterHandlerEntries
1921 class AdapterHandlerTable : public BasicHashtable {
1922   friend class AdapterHandlerTableIterator;
1923 
1924  private:
1925 
1926 #ifdef ASSERT
1927   static int _lookups; // number of calls to lookup


1936   }
1937 
1938  public:
1939   AdapterHandlerTable()
1940     : BasicHashtable(293, sizeof(AdapterHandlerEntry)) { }
1941 
1942   // Create a new entry suitable for insertion in the table
1943   AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
1944     AdapterHandlerEntry* entry = (AdapterHandlerEntry*)BasicHashtable::new_entry(fingerprint->compute_hash());
1945     entry->init(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
1946     return entry;
1947   }
1948 
1949   // Insert an entry into the table
1950   void add(AdapterHandlerEntry* entry) {
1951     int index = hash_to_index(entry->hash());
1952     add_entry(index, entry);
1953   }
1954 
1955   // Find a entry with the same fingerprint if it exists
1956   AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) {
1957     debug_only(_lookups++);
1958     AdapterFingerPrint fp(total_args_passed, sig_bt);
1959     unsigned int hash = fp.compute_hash();
1960     int index = hash_to_index(hash);
1961     for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) {
1962       debug_only(_buckets++);
1963       if (e->hash() == hash) {
1964         debug_only(_equals++);
1965         if (fp.equals(e->fingerprint())) {
1966 #ifdef ASSERT
1967           if (fp.is_compact()) _compact++;
1968           _hits++;
1969 #endif
1970           return e;
1971         }
1972       }
1973     }
1974     return NULL;
1975   }
1976 
1977   void print_statistics() {
1978     ResourceMark rm;


2091   // Get the address of the ic_miss handlers before we grab the
2092   // AdapterHandlerLibrary_lock. This fixes bug 6236259 which
2093   // was caused by the initialization of the stubs happening
2094   // while we held the lock and then notifying jvmti while
2095   // holding it. This just forces the initialization to be a little
2096   // earlier.
2097   address ic_miss = SharedRuntime::get_ic_miss_stub();
2098   assert(ic_miss != NULL, "must have handler");
2099 
2100   ResourceMark rm;
2101 
2102   NOT_PRODUCT(int code_size);
2103   BufferBlob *B = NULL;
2104   AdapterHandlerEntry* entry = NULL;
2105   AdapterFingerPrint* fingerprint = NULL;
2106   {
2107     MutexLocker mu(AdapterHandlerLibrary_lock);
2108     // make sure data structure is initialized
2109     initialize();
2110 
2111     AdapterHandlerEntry* cached_entry = NULL;
2112 
2113     if (method->is_abstract()) {
2114       return _abstract_method_handler;
2115     }
2116 
2117     // Fill in the signature array, for the calling-convention call.
2118     int total_args_passed = method->size_of_parameters(); // All args on stack
2119 
2120     BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed);
2121     VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed);
2122     int i = 0;
2123     if (!method->is_static())  // Pass in receiver first
2124       sig_bt[i++] = T_OBJECT;
2125     for (SignatureStream ss(method->signature()); !ss.at_return_type(); ss.next()) {
2126       sig_bt[i++] = ss.type();  // Collect remaining bits of signature
2127       if (ss.type() == T_LONG || ss.type() == T_DOUBLE)
2128         sig_bt[i++] = T_VOID;   // Longs & doubles take 2 Java slots
2129     }
2130     assert(i == total_args_passed, "");
2131 



2132     // Lookup method signature's fingerprint
2133     entry = _adapters->lookup(total_args_passed, sig_bt);
2134     if (entry != NULL) {
2135       if (UseNewCode) {
2136         cached_entry = entry;
2137         entry = NULL;
2138       } else {
2139         return entry;
2140       }
2141     }
2142 
2143     // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
2144     int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
2145 
2146     // Make a C heap allocated version of the fingerprint to store in the adapter
2147     fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt);
2148 
2149     // Create I2C & C2I handlers
2150 
2151     BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
2152     if (buf != NULL) {
2153       CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
2154       short buffer_locs[20];
2155       buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs,
2156                                              sizeof(buffer_locs)/sizeof(relocInfo));
2157       MacroAssembler _masm(&buffer);
2158 
2159       entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
2160                                                      total_args_passed,
2161                                                      comp_args_on_stack,
2162                                                      sig_bt,
2163                                                      regs,
2164                                                      fingerprint);
2165 
2166       if (cached_entry != NULL) {
2167         assert(cached_entry->compare_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt),
2168                "code must match");
2169         _adapters->free_entry(entry);
2170         return cached_entry;
2171       } else if (UseNewCode) {
2172         entry->save_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt);
2173       }
2174       B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
2175       NOT_PRODUCT(code_size = buffer.code_size());
2176     }
2177     if (B == NULL) {
2178       // CodeCache is full, disable compilation
2179       // Ought to log this but compile log is only per compile thread
2180       // and we're some non descript Java thread.
2181       MutexUnlocker mu(AdapterHandlerLibrary_lock);
2182       CompileBroker::handle_full_code_cache();
2183       return NULL; // Out of CodeCache space
2184     }
2185     entry->relocate(B->instructions_begin());
2186 #ifndef PRODUCT
2187     // debugging suppport
2188     if (PrintAdapterHandlers) {
2189       tty->cr();
2190       tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = %s, %d bytes generated)",
2191                     _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"),
2192                     method->signature()->as_C_string(), fingerprint->as_string(), code_size );
2193       tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());


2208                  B->instructions_begin());
2209     VTune::register_stub(blob_id, B->instructions_begin(), B->instructions_end());
2210     Forte::register_stub(blob_id, B->instructions_begin(), B->instructions_end());
2211 
2212     if (JvmtiExport::should_post_dynamic_code_generated()) {
2213       JvmtiExport::post_dynamic_code_generated(blob_id,
2214                                                B->instructions_begin(),
2215                                                B->instructions_end());
2216     }
2217   }
2218   return entry;
2219 }
2220 
2221 void AdapterHandlerEntry::relocate(address new_base) {
2222     ptrdiff_t delta = new_base - _i2c_entry;
2223     _i2c_entry += delta;
2224     _c2i_entry += delta;
2225     _c2i_unverified_entry += delta;
2226 }
2227 
2228 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) {
2229   _data = NEW_C_HEAP_ARRAY(unsigned char, length);
2230   _data_length = length;
2231   memcpy(_data, buffer, length);
2232   _total_args_passed = total_args_passed;
2233   _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed);
2234   memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType));
2235 }
2236 
2237 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) {
2238   if (length != _data_length) {
2239     assert(false, "what");
2240     return false;
2241   }
2242   for (int i = 0; i < length; i++) {
2243     if (buffer[i] != _data[i]) {
2244       assert(false, "what");
2245       return false;
2246     }
2247   }
2248   return true;
2249 }
2250 
2251 // Create a native wrapper for this native method.  The wrapper converts the
2252 // java compiled calling convention to the native convention, handlizes
2253 // arguments, and transitions to native.  On return from the native we transition
2254 // back to java blocking if a safepoint is in progress.
2255 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method) {
2256   ResourceMark rm;
2257   nmethod* nm = NULL;
2258 
2259   if (PrintCompilation) {
2260     ttyLocker ttyl;
2261     tty->print("---   n%s ", (method->is_synchronized() ? "s" : " "));
2262     method->print_short_name(tty);
2263     if (method->is_static()) {
2264       tty->print(" (static)");
2265     }
2266     tty->cr();
2267   }
2268 
2269   assert(method->has_native_function(), "must have something valid to call!");
2270 


src/share/vm/runtime/sharedRuntime.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File