comparison src/share/vm/code/dependencies.cpp @ 3852:fdb992d83a87

7071653: JSR 292: call site change notification should be pushed not pulled Reviewed-by: kvn, never, bdelsart
author twisti
date Tue, 16 Aug 2011 04:14:05 -0700
parents 1d1603768966
children b27c72d69fd1
comparison
equal deleted inserted replaced
3851:95134e034042 3852:fdb992d83a87
111 void Dependencies::assert_has_no_finalizable_subclasses(ciKlass* ctxk) { 111 void Dependencies::assert_has_no_finalizable_subclasses(ciKlass* ctxk) {
112 check_ctxk(ctxk); 112 check_ctxk(ctxk);
113 assert_common_1(no_finalizable_subclasses, ctxk); 113 assert_common_1(no_finalizable_subclasses, ctxk);
114 } 114 }
115 115
116 void Dependencies::assert_call_site_target_value(ciKlass* ctxk, ciCallSite* call_site, ciMethodHandle* method_handle) {
117 check_ctxk(ctxk);
118 assert_common_3(call_site_target_value, ctxk, call_site, method_handle);
119 }
120
116 // Helper function. If we are adding a new dep. under ctxk2, 121 // Helper function. If we are adding a new dep. under ctxk2,
117 // try to find an old dep. under a broader* ctxk1. If there is 122 // try to find an old dep. under a broader* ctxk1. If there is
118 // 123 //
119 bool Dependencies::maybe_merge_ctxk(GrowableArray<ciObject*>* deps, 124 bool Dependencies::maybe_merge_ctxk(GrowableArray<ciObject*>* deps,
120 int ctxk_i, ciKlass* ctxk2) { 125 int ctxk_i, ciKlass* ctxk2) {
339 "abstract_with_no_concrete_subtype", 344 "abstract_with_no_concrete_subtype",
340 "concrete_with_no_concrete_subtype", 345 "concrete_with_no_concrete_subtype",
341 "unique_concrete_method", 346 "unique_concrete_method",
342 "abstract_with_exclusive_concrete_subtypes_2", 347 "abstract_with_exclusive_concrete_subtypes_2",
343 "exclusive_concrete_methods_2", 348 "exclusive_concrete_methods_2",
344 "no_finalizable_subclasses" 349 "no_finalizable_subclasses",
350 "call_site_target_value"
345 }; 351 };
346 352
347 int Dependencies::_dep_args[TYPE_LIMIT] = { 353 int Dependencies::_dep_args[TYPE_LIMIT] = {
348 -1,// end_marker 354 -1,// end_marker
349 1, // evol_method m 355 1, // evol_method m
352 1, // abstract_with_no_concrete_subtype ctxk 358 1, // abstract_with_no_concrete_subtype ctxk
353 1, // concrete_with_no_concrete_subtype ctxk 359 1, // concrete_with_no_concrete_subtype ctxk
354 2, // unique_concrete_method ctxk, m 360 2, // unique_concrete_method ctxk, m
355 3, // unique_concrete_subtypes_2 ctxk, k1, k2 361 3, // unique_concrete_subtypes_2 ctxk, k1, k2
356 3, // unique_concrete_methods_2 ctxk, m1, m2 362 3, // unique_concrete_methods_2 ctxk, m1, m2
357 1 // no_finalizable_subclasses ctxk 363 1, // no_finalizable_subclasses ctxk
364 3 // call_site_target_value ctxk, call_site, method_handle
358 }; 365 };
359 366
360 const char* Dependencies::dep_name(Dependencies::DepType dept) { 367 const char* Dependencies::dep_name(Dependencies::DepType dept) {
361 if (!dept_in_mask(dept, all_types)) return "?bad-dep?"; 368 if (!dept_in_mask(dept, all_types)) return "?bad-dep?";
362 return _dep_name[dept]; 369 return _dep_name[dept];
363 } 370 }
364 371
365 int Dependencies::dep_args(Dependencies::DepType dept) { 372 int Dependencies::dep_args(Dependencies::DepType dept) {
366 if (!dept_in_mask(dept, all_types)) return -1; 373 if (!dept_in_mask(dept, all_types)) return -1;
367 return _dep_args[dept]; 374 return _dep_args[dept];
375 }
376
377 void Dependencies::check_valid_dependency_type(DepType dept) {
378 for (int deptv = (int) FIRST_TYPE; deptv < (int) TYPE_LIMIT; deptv++) {
379 if (dept == ((DepType) deptv)) return;
380 }
381 ShouldNotReachHere();
368 } 382 }
369 383
370 // for the sake of the compiler log, print out current dependencies: 384 // for the sake of the compiler log, print out current dependencies:
371 void Dependencies::log_all_dependencies() { 385 void Dependencies::log_all_dependencies() {
372 if (log() == NULL) return; 386 if (log() == NULL) return;
798 // the actual search method: 812 // the actual search method:
799 klassOop find_witness_anywhere(klassOop context_type, 813 klassOop find_witness_anywhere(klassOop context_type,
800 bool participants_hide_witnesses, 814 bool participants_hide_witnesses,
801 bool top_level_call = true); 815 bool top_level_call = true);
802 // the spot-checking version: 816 // the spot-checking version:
803 klassOop find_witness_in(DepChange& changes, 817 klassOop find_witness_in(KlassDepChange& changes,
804 klassOop context_type, 818 klassOop context_type,
805 bool participants_hide_witnesses); 819 bool participants_hide_witnesses);
806 public: 820 public:
807 klassOop find_witness_subtype(klassOop context_type, DepChange* changes = NULL) { 821 klassOop find_witness_subtype(klassOop context_type, KlassDepChange* changes = NULL) {
808 assert(doing_subtype_search(), "must set up a subtype search"); 822 assert(doing_subtype_search(), "must set up a subtype search");
809 // When looking for unexpected concrete types, 823 // When looking for unexpected concrete types,
810 // do not look beneath expected ones. 824 // do not look beneath expected ones.
811 const bool participants_hide_witnesses = true; 825 const bool participants_hide_witnesses = true;
812 // CX > CC > C' is OK, even if C' is new. 826 // CX > CC > C' is OK, even if C' is new.
815 return find_witness_in(*changes, context_type, participants_hide_witnesses); 829 return find_witness_in(*changes, context_type, participants_hide_witnesses);
816 } else { 830 } else {
817 return find_witness_anywhere(context_type, participants_hide_witnesses); 831 return find_witness_anywhere(context_type, participants_hide_witnesses);
818 } 832 }
819 } 833 }
820 klassOop find_witness_definer(klassOop context_type, DepChange* changes = NULL) { 834 klassOop find_witness_definer(klassOop context_type, KlassDepChange* changes = NULL) {
821 assert(!doing_subtype_search(), "must set up a method definer search"); 835 assert(!doing_subtype_search(), "must set up a method definer search");
822 // When looking for unexpected concrete methods, 836 // When looking for unexpected concrete methods,
823 // look beneath expected ones, to see if there are overrides. 837 // look beneath expected ones, to see if there are overrides.
824 const bool participants_hide_witnesses = true; 838 const bool participants_hide_witnesses = true;
825 // CX.m > CC.m > C'.m is not OK, if C'.m is new, and C' is the witness. 839 // CX.m > CC.m > C'.m is not OK, if C'.m is new, and C' is the witness.
876 #else 890 #else
877 #define count_find_witness_calls() (0) 891 #define count_find_witness_calls() (0)
878 #endif //PRODUCT 892 #endif //PRODUCT
879 893
880 894
881 klassOop ClassHierarchyWalker::find_witness_in(DepChange& changes, 895 klassOop ClassHierarchyWalker::find_witness_in(KlassDepChange& changes,
882 klassOop context_type, 896 klassOop context_type,
883 bool participants_hide_witnesses) { 897 bool participants_hide_witnesses) {
884 assert(changes.involves_context(context_type), "irrelevant dependency"); 898 assert(changes.involves_context(context_type), "irrelevant dependency");
885 klassOop new_type = changes.new_type(); 899 klassOop new_type = changes.new_type();
886 900
1135 // The type conck itself is allowed to have have further concrete subtypes. 1149 // The type conck itself is allowed to have have further concrete subtypes.
1136 // This allows the compiler to narrow occurrences of ctxk by conck, 1150 // This allows the compiler to narrow occurrences of ctxk by conck,
1137 // when dealing with the types of actual instances. 1151 // when dealing with the types of actual instances.
1138 klassOop Dependencies::check_abstract_with_unique_concrete_subtype(klassOop ctxk, 1152 klassOop Dependencies::check_abstract_with_unique_concrete_subtype(klassOop ctxk,
1139 klassOop conck, 1153 klassOop conck,
1140 DepChange* changes) { 1154 KlassDepChange* changes) {
1141 ClassHierarchyWalker wf(conck); 1155 ClassHierarchyWalker wf(conck);
1142 return wf.find_witness_subtype(ctxk, changes); 1156 return wf.find_witness_subtype(ctxk, changes);
1143 } 1157 }
1144 1158
1145 // If a non-concrete class has no concrete subtypes, it is not (yet) 1159 // If a non-concrete class has no concrete subtypes, it is not (yet)
1146 // instantiatable. This can allow the compiler to make some paths go 1160 // instantiatable. This can allow the compiler to make some paths go
1147 // dead, if they are gated by a test of the type. 1161 // dead, if they are gated by a test of the type.
1148 klassOop Dependencies::check_abstract_with_no_concrete_subtype(klassOop ctxk, 1162 klassOop Dependencies::check_abstract_with_no_concrete_subtype(klassOop ctxk,
1149 DepChange* changes) { 1163 KlassDepChange* changes) {
1150 // Find any concrete subtype, with no participants: 1164 // Find any concrete subtype, with no participants:
1151 ClassHierarchyWalker wf; 1165 ClassHierarchyWalker wf;
1152 return wf.find_witness_subtype(ctxk, changes); 1166 return wf.find_witness_subtype(ctxk, changes);
1153 } 1167 }
1154 1168
1155 1169
1156 // If a concrete class has no concrete subtypes, it can always be 1170 // If a concrete class has no concrete subtypes, it can always be
1157 // exactly typed. This allows the use of a cheaper type test. 1171 // exactly typed. This allows the use of a cheaper type test.
1158 klassOop Dependencies::check_concrete_with_no_concrete_subtype(klassOop ctxk, 1172 klassOop Dependencies::check_concrete_with_no_concrete_subtype(klassOop ctxk,
1159 DepChange* changes) { 1173 KlassDepChange* changes) {
1160 // Find any concrete subtype, with only the ctxk as participant: 1174 // Find any concrete subtype, with only the ctxk as participant:
1161 ClassHierarchyWalker wf(ctxk); 1175 ClassHierarchyWalker wf(ctxk);
1162 return wf.find_witness_subtype(ctxk, changes); 1176 return wf.find_witness_subtype(ctxk, changes);
1163 } 1177 }
1164 1178
1215 // allowed to have further concrete subtypes. 1229 // allowed to have further concrete subtypes.
1216 klassOop Dependencies::check_abstract_with_exclusive_concrete_subtypes( 1230 klassOop Dependencies::check_abstract_with_exclusive_concrete_subtypes(
1217 klassOop ctxk, 1231 klassOop ctxk,
1218 klassOop k1, 1232 klassOop k1,
1219 klassOop k2, 1233 klassOop k2,
1220 DepChange* changes) { 1234 KlassDepChange* changes) {
1221 ClassHierarchyWalker wf; 1235 ClassHierarchyWalker wf;
1222 wf.add_participant(k1); 1236 wf.add_participant(k1);
1223 wf.add_participant(k2); 1237 wf.add_participant(k2);
1224 return wf.find_witness_subtype(ctxk, changes); 1238 return wf.find_witness_subtype(ctxk, changes);
1225 } 1239 }
1276 } 1290 }
1277 1291
1278 // If a class (or interface) has a unique concrete method uniqm, return NULL. 1292 // If a class (or interface) has a unique concrete method uniqm, return NULL.
1279 // Otherwise, return a class that contains an interfering method. 1293 // Otherwise, return a class that contains an interfering method.
1280 klassOop Dependencies::check_unique_concrete_method(klassOop ctxk, methodOop uniqm, 1294 klassOop Dependencies::check_unique_concrete_method(klassOop ctxk, methodOop uniqm,
1281 DepChange* changes) { 1295 KlassDepChange* changes) {
1282 // Here is a missing optimization: If uniqm->is_final(), 1296 // Here is a missing optimization: If uniqm->is_final(),
1283 // we don't really need to search beneath it for overrides. 1297 // we don't really need to search beneath it for overrides.
1284 // This is probably not important, since we don't use dependencies 1298 // This is probably not important, since we don't use dependencies
1285 // to track final methods. (They can't be "definalized".) 1299 // to track final methods. (They can't be "definalized".)
1286 ClassHierarchyWalker wf(uniqm->method_holder(), uniqm); 1300 ClassHierarchyWalker wf(uniqm->method_holder(), uniqm);
1319 } 1333 }
1320 1334
1321 klassOop Dependencies::check_exclusive_concrete_methods(klassOop ctxk, 1335 klassOop Dependencies::check_exclusive_concrete_methods(klassOop ctxk,
1322 methodOop m1, 1336 methodOop m1,
1323 methodOop m2, 1337 methodOop m2,
1324 DepChange* changes) { 1338 KlassDepChange* changes) {
1325 ClassHierarchyWalker wf(m1); 1339 ClassHierarchyWalker wf(m1);
1326 wf.add_participant(m1->method_holder()); 1340 wf.add_participant(m1->method_holder());
1327 wf.add_participant(m2->method_holder()); 1341 wf.add_participant(m2->method_holder());
1328 return wf.find_witness_definer(ctxk, changes); 1342 return wf.find_witness_definer(ctxk, changes);
1329 } 1343 }
1381 #endif //PRODUCT 1395 #endif //PRODUCT
1382 return mfill; 1396 return mfill;
1383 } 1397 }
1384 1398
1385 1399
1386 klassOop Dependencies::check_has_no_finalizable_subclasses(klassOop ctxk, DepChange* changes) { 1400 klassOop Dependencies::check_has_no_finalizable_subclasses(klassOop ctxk, KlassDepChange* changes) {
1387 Klass* search_at = ctxk->klass_part(); 1401 Klass* search_at = ctxk->klass_part();
1388 if (changes != NULL) 1402 if (changes != NULL)
1389 search_at = changes->new_type()->klass_part(); // just look at the new bit 1403 search_at = changes->new_type()->klass_part(); // just look at the new bit
1390 Klass* result = find_finalizable_subclass(search_at); 1404 Klass* result = find_finalizable_subclass(search_at);
1391 if (result == NULL) { 1405 if (result == NULL) {
1393 } 1407 }
1394 return result->as_klassOop(); 1408 return result->as_klassOop();
1395 } 1409 }
1396 1410
1397 1411
1398 klassOop Dependencies::DepStream::check_dependency_impl(DepChange* changes) { 1412 klassOop Dependencies::check_call_site_target_value(klassOop ctxk, oop call_site, oop method_handle, CallSiteDepChange* changes) {
1413 assert(call_site ->is_a(SystemDictionary::CallSite_klass()), "sanity");
1414 assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "sanity");
1415 if (changes == NULL) {
1416 // Validate all CallSites
1417 if (java_lang_invoke_CallSite::target(call_site) != method_handle)
1418 return ctxk; // assertion failed
1419 } else {
1420 // Validate the given CallSite
1421 if (call_site == changes->call_site() && java_lang_invoke_CallSite::target(call_site) != changes->method_handle()) {
1422 assert(method_handle != changes->method_handle(), "must be");
1423 return ctxk; // assertion failed
1424 }
1425 }
1426 assert(java_lang_invoke_CallSite::target(call_site) == method_handle, "should still be valid");
1427 return NULL; // assertion still valid
1428 }
1429
1430
1431 void Dependencies::DepStream::trace_and_log_witness(klassOop witness) {
1432 if (witness != NULL) {
1433 if (TraceDependencies) {
1434 print_dependency(witness, /*verbose=*/ true);
1435 }
1436 // The following is a no-op unless logging is enabled:
1437 log_dependency(witness);
1438 }
1439 }
1440
1441
1442 klassOop Dependencies::DepStream::check_klass_dependency(KlassDepChange* changes) {
1399 assert_locked_or_safepoint(Compile_lock); 1443 assert_locked_or_safepoint(Compile_lock);
1444 Dependencies::check_valid_dependency_type(type());
1400 1445
1401 klassOop witness = NULL; 1446 klassOop witness = NULL;
1402 switch (type()) { 1447 switch (type()) {
1403 case evol_method: 1448 case evol_method:
1404 witness = check_evol_method(method_argument(0)); 1449 witness = check_evol_method(method_argument(0));
1405 break; 1450 break;
1406 case leaf_type: 1451 case leaf_type:
1407 witness = check_leaf_type(context_type()); 1452 witness = check_leaf_type(context_type());
1408 break; 1453 break;
1409 case abstract_with_unique_concrete_subtype: 1454 case abstract_with_unique_concrete_subtype:
1410 witness = check_abstract_with_unique_concrete_subtype(context_type(), 1455 witness = check_abstract_with_unique_concrete_subtype(context_type(), type_argument(1), changes);
1411 type_argument(1),
1412 changes);
1413 break; 1456 break;
1414 case abstract_with_no_concrete_subtype: 1457 case abstract_with_no_concrete_subtype:
1415 witness = check_abstract_with_no_concrete_subtype(context_type(), 1458 witness = check_abstract_with_no_concrete_subtype(context_type(), changes);
1416 changes);
1417 break; 1459 break;
1418 case concrete_with_no_concrete_subtype: 1460 case concrete_with_no_concrete_subtype:
1419 witness = check_concrete_with_no_concrete_subtype(context_type(), 1461 witness = check_concrete_with_no_concrete_subtype(context_type(), changes);
1420 changes);
1421 break; 1462 break;
1422 case unique_concrete_method: 1463 case unique_concrete_method:
1423 witness = check_unique_concrete_method(context_type(), 1464 witness = check_unique_concrete_method(context_type(), method_argument(1), changes);
1424 method_argument(1),
1425 changes);
1426 break; 1465 break;
1427 case abstract_with_exclusive_concrete_subtypes_2: 1466 case abstract_with_exclusive_concrete_subtypes_2:
1428 witness = check_abstract_with_exclusive_concrete_subtypes(context_type(), 1467 witness = check_abstract_with_exclusive_concrete_subtypes(context_type(), type_argument(1), type_argument(2), changes);
1429 type_argument(1),
1430 type_argument(2),
1431 changes);
1432 break; 1468 break;
1433 case exclusive_concrete_methods_2: 1469 case exclusive_concrete_methods_2:
1434 witness = check_exclusive_concrete_methods(context_type(), 1470 witness = check_exclusive_concrete_methods(context_type(), method_argument(1), method_argument(2), changes);
1435 method_argument(1),
1436 method_argument(2),
1437 changes);
1438 break; 1471 break;
1439 case no_finalizable_subclasses: 1472 case no_finalizable_subclasses:
1440 witness = check_has_no_finalizable_subclasses(context_type(), 1473 witness = check_has_no_finalizable_subclasses(context_type(), changes);
1441 changes);
1442 break;
1443 default:
1444 witness = NULL;
1445 ShouldNotReachHere();
1446 break;
1447 }
1448 if (witness != NULL) {
1449 if (TraceDependencies) {
1450 print_dependency(witness, /*verbose=*/ true);
1451 }
1452 // The following is a no-op unless logging is enabled:
1453 log_dependency(witness);
1454 }
1455 return witness;
1456 }
1457
1458
1459 klassOop Dependencies::DepStream::spot_check_dependency_at(DepChange& changes) {
1460 if (!changes.involves_context(context_type()))
1461 // irrelevant dependency; skip it
1462 return NULL;
1463
1464 return check_dependency_impl(&changes);
1465 }
1466
1467
1468 void DepChange::initialize() {
1469 // entire transaction must be under this lock:
1470 assert_lock_strong(Compile_lock);
1471
1472 // Mark all dependee and all its superclasses
1473 // Mark transitive interfaces
1474 for (ContextStream str(*this); str.next(); ) {
1475 klassOop d = str.klass();
1476 assert(!instanceKlass::cast(d)->is_marked_dependent(), "checking");
1477 instanceKlass::cast(d)->set_is_marked_dependent(true);
1478 }
1479 }
1480
1481 DepChange::~DepChange() {
1482 // Unmark all dependee and all its superclasses
1483 // Unmark transitive interfaces
1484 for (ContextStream str(*this); str.next(); ) {
1485 klassOop d = str.klass();
1486 instanceKlass::cast(d)->set_is_marked_dependent(false);
1487 }
1488 }
1489
1490 bool DepChange::involves_context(klassOop k) {
1491 if (k == NULL || !Klass::cast(k)->oop_is_instance()) {
1492 return false;
1493 }
1494 instanceKlass* ik = instanceKlass::cast(k);
1495 bool is_contained = ik->is_marked_dependent();
1496 assert(is_contained == Klass::cast(new_type())->is_subtype_of(k),
1497 "correct marking of potential context types");
1498 return is_contained;
1499 }
1500
1501 bool DepChange::ContextStream::next() {
1502 switch (_change_type) {
1503 case Start_Klass: // initial state; _klass is the new type
1504 _ti_base = instanceKlass::cast(_klass)->transitive_interfaces();
1505 _ti_index = 0;
1506 _change_type = Change_new_type;
1507 return true;
1508 case Change_new_type:
1509 // fall through:
1510 _change_type = Change_new_sub;
1511 case Change_new_sub:
1512 // 6598190: brackets workaround Sun Studio C++ compiler bug 6629277
1513 {
1514 _klass = instanceKlass::cast(_klass)->super();
1515 if (_klass != NULL) {
1516 return true;
1517 }
1518 }
1519 // else set up _ti_limit and fall through:
1520 _ti_limit = (_ti_base == NULL) ? 0 : _ti_base->length();
1521 _change_type = Change_new_impl;
1522 case Change_new_impl:
1523 if (_ti_index < _ti_limit) {
1524 _klass = klassOop( _ti_base->obj_at(_ti_index++) );
1525 return true;
1526 }
1527 // fall through:
1528 _change_type = NO_CHANGE; // iterator is exhausted
1529 case NO_CHANGE:
1530 break; 1474 break;
1531 default: 1475 default:
1532 ShouldNotReachHere(); 1476 witness = NULL;
1533 } 1477 break;
1534 return false; 1478 }
1535 } 1479 trace_and_log_witness(witness);
1480 return witness;
1481 }
1482
1483
1484 klassOop Dependencies::DepStream::check_call_site_dependency(CallSiteDepChange* changes) {
1485 assert_locked_or_safepoint(Compile_lock);
1486 Dependencies::check_valid_dependency_type(type());
1487
1488 klassOop witness = NULL;
1489 switch (type()) {
1490 case call_site_target_value:
1491 witness = check_call_site_target_value(context_type(), argument(1), argument(2), changes);
1492 break;
1493 default:
1494 witness = NULL;
1495 break;
1496 }
1497 trace_and_log_witness(witness);
1498 return witness;
1499 }
1500
1501
1502 klassOop Dependencies::DepStream::spot_check_dependency_at(DepChange& changes) {
1503 // Handle klass dependency
1504 if (changes.is_klass_change() && changes.as_klass_change()->involves_context(context_type()))
1505 return check_klass_dependency(changes.as_klass_change());
1506
1507 // Handle CallSite dependency
1508 if (changes.is_call_site_change())
1509 return check_call_site_dependency(changes.as_call_site_change());
1510
1511 // irrelevant dependency; skip it
1512 return NULL;
1513 }
1514
1536 1515
1537 void DepChange::print() { 1516 void DepChange::print() {
1538 int nsup = 0, nint = 0; 1517 int nsup = 0, nint = 0;
1539 for (ContextStream str(*this); str.next(); ) { 1518 for (ContextStream str(*this); str.next(); ) {
1540 klassOop k = str.klass(); 1519 klassOop k = str.klass();
1561 if (nsup + nint != 0) { 1540 if (nsup + nint != 0) {
1562 tty->print_cr(" context supers = %d, interfaces = %d", nsup, nint); 1541 tty->print_cr(" context supers = %d, interfaces = %d", nsup, nint);
1563 } 1542 }
1564 } 1543 }
1565 1544
1545 void DepChange::ContextStream::start() {
1546 klassOop new_type = _changes.is_klass_change() ? _changes.as_klass_change()->new_type() : (klassOop) NULL;
1547 _change_type = (new_type == NULL ? NO_CHANGE : Start_Klass);
1548 _klass = new_type;
1549 _ti_base = NULL;
1550 _ti_index = 0;
1551 _ti_limit = 0;
1552 }
1553
1554 bool DepChange::ContextStream::next() {
1555 switch (_change_type) {
1556 case Start_Klass: // initial state; _klass is the new type
1557 _ti_base = instanceKlass::cast(_klass)->transitive_interfaces();
1558 _ti_index = 0;
1559 _change_type = Change_new_type;
1560 return true;
1561 case Change_new_type:
1562 // fall through:
1563 _change_type = Change_new_sub;
1564 case Change_new_sub:
1565 // 6598190: brackets workaround Sun Studio C++ compiler bug 6629277
1566 {
1567 _klass = instanceKlass::cast(_klass)->super();
1568 if (_klass != NULL) {
1569 return true;
1570 }
1571 }
1572 // else set up _ti_limit and fall through:
1573 _ti_limit = (_ti_base == NULL) ? 0 : _ti_base->length();
1574 _change_type = Change_new_impl;
1575 case Change_new_impl:
1576 if (_ti_index < _ti_limit) {
1577 _klass = klassOop( _ti_base->obj_at(_ti_index++) );
1578 return true;
1579 }
1580 // fall through:
1581 _change_type = NO_CHANGE; // iterator is exhausted
1582 case NO_CHANGE:
1583 break;
1584 default:
1585 ShouldNotReachHere();
1586 }
1587 return false;
1588 }
1589
1590 void KlassDepChange::initialize() {
1591 // entire transaction must be under this lock:
1592 assert_lock_strong(Compile_lock);
1593
1594 // Mark all dependee and all its superclasses
1595 // Mark transitive interfaces
1596 for (ContextStream str(*this); str.next(); ) {
1597 klassOop d = str.klass();
1598 assert(!instanceKlass::cast(d)->is_marked_dependent(), "checking");
1599 instanceKlass::cast(d)->set_is_marked_dependent(true);
1600 }
1601 }
1602
1603 KlassDepChange::~KlassDepChange() {
1604 // Unmark all dependee and all its superclasses
1605 // Unmark transitive interfaces
1606 for (ContextStream str(*this); str.next(); ) {
1607 klassOop d = str.klass();
1608 instanceKlass::cast(d)->set_is_marked_dependent(false);
1609 }
1610 }
1611
1612 bool KlassDepChange::involves_context(klassOop k) {
1613 if (k == NULL || !Klass::cast(k)->oop_is_instance()) {
1614 return false;
1615 }
1616 instanceKlass* ik = instanceKlass::cast(k);
1617 bool is_contained = ik->is_marked_dependent();
1618 assert(is_contained == Klass::cast(new_type())->is_subtype_of(k),
1619 "correct marking of potential context types");
1620 return is_contained;
1621 }
1622
1566 #ifndef PRODUCT 1623 #ifndef PRODUCT
1567 void Dependencies::print_statistics() { 1624 void Dependencies::print_statistics() {
1568 if (deps_find_witness_print != 0) { 1625 if (deps_find_witness_print != 0) {
1569 // Call one final time, to flush out the data. 1626 // Call one final time, to flush out the data.
1570 deps_find_witness_print = -1; 1627 deps_find_witness_print = -1;