comparison src/share/vm/oops/instanceKlass.cpp @ 1930:2d26b0046e0d

Merge.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 30 Nov 2010 14:53:30 +0100
parents a7b84a5e16c6 d5d065957597
children 06f017f7daa7
comparison
equal deleted inserted replaced
1484:6b7001391c97 1930:2d26b0046e0d
1 /* 1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
14 * 14 *
15 * You should have received a copy of the GNU General Public License version 15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation, 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 * 18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * CA 95054 USA or visit www.sun.com if you need additional information or 20 * or visit www.oracle.com if you need additional information or have any
21 * have any questions. 21 * questions.
22 * 22 *
23 */ 23 */
24 24
25 # include "incls/_precompiled.incl" 25 # include "incls/_precompiled.incl"
26 # include "incls/_instanceKlass.cpp.incl" 26 # include "incls/_instanceKlass.cpp.incl"
380 DTRACE_CLASSINIT_PROBE_WAIT(erroneous, instanceKlass::cast(this_oop()), -1,wait); 380 DTRACE_CLASSINIT_PROBE_WAIT(erroneous, instanceKlass::cast(this_oop()), -1,wait);
381 ResourceMark rm(THREAD); 381 ResourceMark rm(THREAD);
382 const char* desc = "Could not initialize class "; 382 const char* desc = "Could not initialize class ";
383 const char* className = this_oop->external_name(); 383 const char* className = this_oop->external_name();
384 size_t msglen = strlen(desc) + strlen(className) + 1; 384 size_t msglen = strlen(desc) + strlen(className) + 1;
385 char* message = NEW_C_HEAP_ARRAY(char, msglen); 385 char* message = NEW_RESOURCE_ARRAY(char, msglen);
386 if (NULL == message) { 386 if (NULL == message) {
387 // Out of memory: can't create detailed error message 387 // Out of memory: can't create detailed error message
388 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), className); 388 THROW_MSG(vmSymbols::java_lang_NoClassDefFoundError(), className);
389 } else { 389 } else {
390 jio_snprintf(message, msglen, "%s%s", desc, className); 390 jio_snprintf(message, msglen, "%s%s", desc, className);
966 if (m->signature() == signature) return m; 966 if (m->signature() == signature) return m;
967 } 967 }
968 // not found 968 // not found
969 #ifdef ASSERT 969 #ifdef ASSERT
970 int index = linear_search(methods, name, signature); 970 int index = linear_search(methods, name, signature);
971 if (index != -1) fatal1("binary search bug: should have found entry %d", index); 971 assert(index == -1, err_msg("binary search should have found entry %d", index));
972 #endif 972 #endif
973 return NULL; 973 return NULL;
974 } else if (res < 0) { 974 } else if (res < 0) {
975 l = mid + 1; 975 l = mid + 1;
976 } else { 976 } else {
977 h = mid - 1; 977 h = mid - 1;
978 } 978 }
979 } 979 }
980 #ifdef ASSERT 980 #ifdef ASSERT
981 int index = linear_search(methods, name, signature); 981 int index = linear_search(methods, name, signature);
982 if (index != -1) fatal1("binary search bug: should have found entry %d", index); 982 assert(index == -1, err_msg("binary search should have found entry %d", index));
983 #endif 983 #endif
984 return NULL; 984 return NULL;
985 } 985 }
986 986
987 methodOop instanceKlass::uncached_lookup_method(symbolOop name, symbolOop signature) const { 987 methodOop instanceKlass::uncached_lookup_method(symbolOop name, symbolOop signature) const {
1809 obj->adjust_header(); 1809 obj->adjust_header();
1810 return size; 1810 return size;
1811 } 1811 }
1812 1812
1813 #ifndef SERIALGC 1813 #ifndef SERIALGC
1814 void instanceKlass::oop_copy_contents(PSPromotionManager* pm, oop obj) {
1815 assert(!pm->depth_first(), "invariant");
1816 InstanceKlass_OOP_MAP_REVERSE_ITERATE( \
1817 obj, \
1818 if (PSScavenge::should_scavenge(p)) { \
1819 pm->claim_or_forward_breadth(p); \
1820 }, \
1821 assert_nothing )
1822 }
1823
1824 void instanceKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { 1814 void instanceKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
1825 assert(pm->depth_first(), "invariant");
1826 InstanceKlass_OOP_MAP_REVERSE_ITERATE( \ 1815 InstanceKlass_OOP_MAP_REVERSE_ITERATE( \
1827 obj, \ 1816 obj, \
1828 if (PSScavenge::should_scavenge(p)) { \ 1817 if (PSScavenge::should_scavenge(p)) { \
1829 pm->claim_or_forward_depth(p); \ 1818 pm->claim_or_forward_depth(p); \
1830 }, \ 1819 }, \
1846 PSParallelCompact::adjust_pointer(p), \ 1835 PSParallelCompact::adjust_pointer(p), \
1847 assert_nothing) 1836 assert_nothing)
1848 return size_helper(); 1837 return size_helper();
1849 } 1838 }
1850 1839
1851 void instanceKlass::copy_static_fields(PSPromotionManager* pm) {
1852 assert(!pm->depth_first(), "invariant");
1853 InstanceKlass_OOP_ITERATE( \
1854 start_of_static_fields(), static_oop_field_size(), \
1855 if (PSScavenge::should_scavenge(p)) { \
1856 pm->claim_or_forward_breadth(p); \
1857 }, \
1858 assert_nothing )
1859 }
1860
1861 void instanceKlass::push_static_fields(PSPromotionManager* pm) { 1840 void instanceKlass::push_static_fields(PSPromotionManager* pm) {
1862 assert(pm->depth_first(), "invariant");
1863 InstanceKlass_OOP_ITERATE( \ 1841 InstanceKlass_OOP_ITERATE( \
1864 start_of_static_fields(), static_oop_field_size(), \ 1842 start_of_static_fields(), static_oop_field_size(), \
1865 if (PSScavenge::should_scavenge(p)) { \ 1843 if (PSScavenge::should_scavenge(p)) { \
1866 pm->claim_or_forward_depth(p); \ 1844 pm->claim_or_forward_depth(p); \
1867 }, \ 1845 }, \
2222 // This is a short non-blocking critical region, so the no safepoint check is ok. 2200 // This is a short non-blocking critical region, so the no safepoint check is ok.
2223 OsrList_lock->lock_without_safepoint_check(); 2201 OsrList_lock->lock_without_safepoint_check();
2224 assert(n->is_osr_method(), "wrong kind of nmethod"); 2202 assert(n->is_osr_method(), "wrong kind of nmethod");
2225 n->set_osr_link(osr_nmethods_head()); 2203 n->set_osr_link(osr_nmethods_head());
2226 set_osr_nmethods_head(n); 2204 set_osr_nmethods_head(n);
2205 // Raise the highest osr level if necessary
2206 if (TieredCompilation) {
2207 methodOop m = n->method();
2208 m->set_highest_osr_comp_level(MAX2(m->highest_osr_comp_level(), n->comp_level()));
2209 }
2227 // Remember to unlock again 2210 // Remember to unlock again
2228 OsrList_lock->unlock(); 2211 OsrList_lock->unlock();
2212
2213 // Get rid of the osr methods for the same bci that have lower levels.
2214 if (TieredCompilation) {
2215 for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) {
2216 nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true);
2217 if (inv != NULL && inv->is_in_use()) {
2218 inv->make_not_entrant();
2219 }
2220 }
2221 }
2229 } 2222 }
2230 2223
2231 2224
2232 void instanceKlass::remove_osr_nmethod(nmethod* n) { 2225 void instanceKlass::remove_osr_nmethod(nmethod* n) {
2233 // This is a short non-blocking critical region, so the no safepoint check is ok. 2226 // This is a short non-blocking critical region, so the no safepoint check is ok.
2234 OsrList_lock->lock_without_safepoint_check(); 2227 OsrList_lock->lock_without_safepoint_check();
2235 assert(n->is_osr_method(), "wrong kind of nmethod"); 2228 assert(n->is_osr_method(), "wrong kind of nmethod");
2236 nmethod* last = NULL; 2229 nmethod* last = NULL;
2237 nmethod* cur = osr_nmethods_head(); 2230 nmethod* cur = osr_nmethods_head();
2231 int max_level = CompLevel_none; // Find the max comp level excluding n
2232 methodOop m = n->method();
2238 // Search for match 2233 // Search for match
2239 while(cur != NULL && cur != n) { 2234 while(cur != NULL && cur != n) {
2235 if (TieredCompilation) {
2236 // Find max level before n
2237 max_level = MAX2(max_level, cur->comp_level());
2238 }
2240 last = cur; 2239 last = cur;
2241 cur = cur->osr_link(); 2240 cur = cur->osr_link();
2242 } 2241 }
2242 nmethod* next = NULL;
2243 if (cur == n) { 2243 if (cur == n) {
2244 next = cur->osr_link();
2244 if (last == NULL) { 2245 if (last == NULL) {
2245 // Remove first element 2246 // Remove first element
2246 set_osr_nmethods_head(osr_nmethods_head()->osr_link()); 2247 set_osr_nmethods_head(next);
2247 } else { 2248 } else {
2248 last->set_osr_link(cur->osr_link()); 2249 last->set_osr_link(next);
2249 } 2250 }
2250 } 2251 }
2251 n->set_osr_link(NULL); 2252 n->set_osr_link(NULL);
2253 if (TieredCompilation) {
2254 cur = next;
2255 while (cur != NULL) {
2256 // Find max level after n
2257 max_level = MAX2(max_level, cur->comp_level());
2258 cur = cur->osr_link();
2259 }
2260 m->set_highest_osr_comp_level(max_level);
2261 }
2252 // Remember to unlock again 2262 // Remember to unlock again
2253 OsrList_lock->unlock(); 2263 OsrList_lock->unlock();
2254 } 2264 }
2255 2265
2256 nmethod* instanceKlass::lookup_osr_nmethod(const methodOop m, int bci) const { 2266 nmethod* instanceKlass::lookup_osr_nmethod(const methodOop m, int bci, int comp_level, bool match_level) const {
2257 // This is a short non-blocking critical region, so the no safepoint check is ok. 2267 // This is a short non-blocking critical region, so the no safepoint check is ok.
2258 OsrList_lock->lock_without_safepoint_check(); 2268 OsrList_lock->lock_without_safepoint_check();
2259 nmethod* osr = osr_nmethods_head(); 2269 nmethod* osr = osr_nmethods_head();
2270 nmethod* best = NULL;
2260 while (osr != NULL) { 2271 while (osr != NULL) {
2261 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain"); 2272 assert(osr->is_osr_method(), "wrong kind of nmethod found in chain");
2273 // There can be a time when a c1 osr method exists but we are waiting
2274 // for a c2 version. When c2 completes its osr nmethod we will trash
2275 // the c1 version and only be able to find the c2 version. However
2276 // while we overflow in the c1 code at back branches we don't want to
2277 // try and switch to the same code as we are already running
2278
2262 if (osr->method() == m && 2279 if (osr->method() == m &&
2263 (bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) { 2280 (bci == InvocationEntryBci || osr->osr_entry_bci() == bci)) {
2264 // Found a match - return it. 2281 if (match_level) {
2265 OsrList_lock->unlock(); 2282 if (osr->comp_level() == comp_level) {
2266 return osr; 2283 // Found a match - return it.
2284 OsrList_lock->unlock();
2285 return osr;
2286 }
2287 } else {
2288 if (best == NULL || (osr->comp_level() > best->comp_level())) {
2289 if (osr->comp_level() == CompLevel_highest_tier) {
2290 // Found the best possible - return it.
2291 OsrList_lock->unlock();
2292 return osr;
2293 }
2294 best = osr;
2295 }
2296 }
2267 } 2297 }
2268 osr = osr->osr_link(); 2298 osr = osr->osr_link();
2269 } 2299 }
2270 OsrList_lock->unlock(); 2300 OsrList_lock->unlock();
2301 if (best != NULL && best->comp_level() >= comp_level && match_level == false) {
2302 return best;
2303 }
2271 return NULL; 2304 return NULL;
2272 } 2305 }
2273 2306
2274 // ----------------------------------------------------------------------------------------------------- 2307 // -----------------------------------------------------------------------------------------------------
2275 #ifndef PRODUCT 2308 #ifndef PRODUCT