Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/code/dependencies.cpp
          +++ new/src/share/vm/code/dependencies.cpp
↓ open down ↓ 105 lines elided ↑ open up ↑
 106  106  void Dependencies::assert_exclusive_concrete_methods(ciKlass* ctxk, ciMethod* m1, ciMethod* m2) {
 107  107    check_ctxk(ctxk);
 108  108    assert_common_3(exclusive_concrete_methods_2, ctxk, m1, m2);
 109  109  }
 110  110  
 111  111  void Dependencies::assert_has_no_finalizable_subclasses(ciKlass* ctxk) {
 112  112    check_ctxk(ctxk);
 113  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  121  // Helper function.  If we are adding a new dep. under ctxk2,
 117  122  // try to find an old dep. under a broader* ctxk1.  If there is
 118  123  //
 119  124  bool Dependencies::maybe_merge_ctxk(GrowableArray<ciObject*>* deps,
 120  125                                      int ctxk_i, ciKlass* ctxk2) {
 121  126    ciKlass* ctxk1 = deps->at(ctxk_i)->as_klass();
 122  127    if (ctxk2->is_subtype_of(ctxk1)) {
 123  128      return true;  // success, and no need to change
 124  129    } else if (ctxk1->is_subtype_of(ctxk2)) {
 125  130      // new context class fully subsumes previous one
↓ open down ↓ 208 lines elided ↑ open up ↑
 334  339  const char* Dependencies::_dep_name[TYPE_LIMIT] = {
 335  340    "end_marker",
 336  341    "evol_method",
 337  342    "leaf_type",
 338  343    "abstract_with_unique_concrete_subtype",
 339  344    "abstract_with_no_concrete_subtype",
 340  345    "concrete_with_no_concrete_subtype",
 341  346    "unique_concrete_method",
 342  347    "abstract_with_exclusive_concrete_subtypes_2",
 343  348    "exclusive_concrete_methods_2",
 344      -  "no_finalizable_subclasses"
      349 +  "no_finalizable_subclasses",
      350 +  "call_site_target_value"
 345  351  };
 346  352  
 347  353  int Dependencies::_dep_args[TYPE_LIMIT] = {
 348  354    -1,// end_marker
 349  355    1, // evol_method m
 350  356    1, // leaf_type ctxk
 351  357    2, // abstract_with_unique_concrete_subtype ctxk, k
 352  358    1, // abstract_with_no_concrete_subtype ctxk
 353  359    1, // concrete_with_no_concrete_subtype ctxk
 354  360    2, // unique_concrete_method ctxk, m
 355  361    3, // unique_concrete_subtypes_2 ctxk, k1, k2
 356  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  367  const char* Dependencies::dep_name(Dependencies::DepType dept) {
 361  368    if (!dept_in_mask(dept, all_types))  return "?bad-dep?";
 362  369    return _dep_name[dept];
 363  370  }
 364  371  
 365  372  int Dependencies::dep_args(Dependencies::DepType dept) {
 366  373    if (!dept_in_mask(dept, all_types))  return -1;
 367  374    return _dep_args[dept];
 368  375  }
 369  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();
      382 +}
      383 +
 370  384  // for the sake of the compiler log, print out current dependencies:
 371  385  void Dependencies::log_all_dependencies() {
 372  386    if (log() == NULL)  return;
 373  387    ciObject* args[max_arg_count];
 374  388    for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) {
 375  389      DepType dept = (DepType)deptv;
 376  390      GrowableArray<ciObject*>* deps = _deps[dept];
 377  391      if (deps->length() == 0)  continue;
 378  392      int stride = dep_args(dept);
 379  393      for (int i = 0; i < deps->length(); i += stride) {
↓ open down ↓ 413 lines elided ↑ open up ↑
 793  807      }
 794  808      return false;  // not in list
 795  809    }
 796  810  
 797  811   private:
 798  812    // the actual search method:
 799  813    klassOop find_witness_anywhere(klassOop context_type,
 800  814                                   bool participants_hide_witnesses,
 801  815                                   bool top_level_call = true);
 802  816    // the spot-checking version:
 803      -  klassOop find_witness_in(DepChange& changes,
      817 +  klassOop find_witness_in(KlassDepChange& changes,
 804  818                             klassOop context_type,
 805  819                             bool participants_hide_witnesses);
 806  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  822      assert(doing_subtype_search(), "must set up a subtype search");
 809  823      // When looking for unexpected concrete types,
 810  824      // do not look beneath expected ones.
 811  825      const bool participants_hide_witnesses = true;
 812  826      // CX > CC > C' is OK, even if C' is new.
 813  827      // CX > { CC,  C' } is not OK if C' is new, and C' is the witness.
 814  828      if (changes != NULL) {
 815  829        return find_witness_in(*changes, context_type, participants_hide_witnesses);
 816  830      } else {
 817  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  835      assert(!doing_subtype_search(), "must set up a method definer search");
 822  836      // When looking for unexpected concrete methods,
 823  837      // look beneath expected ones, to see if there are overrides.
 824  838      const bool participants_hide_witnesses = true;
 825  839      // CX.m > CC.m > C'.m is not OK, if C'.m is new, and C' is the witness.
 826  840      if (changes != NULL) {
 827  841        return find_witness_in(*changes, context_type, !participants_hide_witnesses);
 828  842      } else {
 829  843        return find_witness_anywhere(context_type, !participants_hide_witnesses);
 830  844      }
↓ open down ↓ 40 lines elided ↑ open up ↑
 871  885      }
 872  886      return true;
 873  887    }
 874  888    return false;
 875  889  }
 876  890  #else
 877  891  #define count_find_witness_calls() (0)
 878  892  #endif //PRODUCT
 879  893  
 880  894  
 881      -klassOop ClassHierarchyWalker::find_witness_in(DepChange& changes,
      895 +klassOop ClassHierarchyWalker::find_witness_in(KlassDepChange& changes,
 882  896                                                 klassOop context_type,
 883  897                                                 bool participants_hide_witnesses) {
 884  898    assert(changes.involves_context(context_type), "irrelevant dependency");
 885  899    klassOop new_type = changes.new_type();
 886  900  
 887  901    count_find_witness_calls();
 888  902    NOT_PRODUCT(deps_find_witness_singles++);
 889  903  
 890  904    // Current thread must be in VM (not native mode, as in CI):
 891  905    assert(must_be_in_vm(), "raw oops here");
↓ open down ↓ 238 lines elided ↑ open up ↑
1130 1144      return NULL;
1131 1145    }
1132 1146  }
1133 1147  
1134 1148  // Test the assertion that conck is the only concrete subtype* of ctxk.
1135 1149  // The type conck itself is allowed to have have further concrete subtypes.
1136 1150  // This allows the compiler to narrow occurrences of ctxk by conck,
1137 1151  // when dealing with the types of actual instances.
1138 1152  klassOop Dependencies::check_abstract_with_unique_concrete_subtype(klassOop ctxk,
1139 1153                                                                     klassOop conck,
1140      -                                                                   DepChange* changes) {
     1154 +                                                                   KlassDepChange* changes) {
1141 1155    ClassHierarchyWalker wf(conck);
1142 1156    return wf.find_witness_subtype(ctxk, changes);
1143 1157  }
1144 1158  
1145 1159  // If a non-concrete class has no concrete subtypes, it is not (yet)
1146 1160  // instantiatable.  This can allow the compiler to make some paths go
1147 1161  // dead, if they are gated by a test of the type.
1148 1162  klassOop Dependencies::check_abstract_with_no_concrete_subtype(klassOop ctxk,
1149      -                                                               DepChange* changes) {
     1163 +                                                               KlassDepChange* changes) {
1150 1164    // Find any concrete subtype, with no participants:
1151 1165    ClassHierarchyWalker wf;
1152 1166    return wf.find_witness_subtype(ctxk, changes);
1153 1167  }
1154 1168  
1155 1169  
1156 1170  // If a concrete class has no concrete subtypes, it can always be
1157 1171  // exactly typed.  This allows the use of a cheaper type test.
1158 1172  klassOop Dependencies::check_concrete_with_no_concrete_subtype(klassOop ctxk,
1159      -                                                               DepChange* changes) {
     1173 +                                                               KlassDepChange* changes) {
1160 1174    // Find any concrete subtype, with only the ctxk as participant:
1161 1175    ClassHierarchyWalker wf(ctxk);
1162 1176    return wf.find_witness_subtype(ctxk, changes);
1163 1177  }
1164 1178  
1165 1179  
1166 1180  // Find the unique concrete proper subtype of ctxk, or NULL if there
1167 1181  // is more than one concrete proper subtype.  If there are no concrete
1168 1182  // proper subtypes, return ctxk itself, whether it is concrete or not.
1169 1183  // The returned subtype is allowed to have have further concrete subtypes.
↓ open down ↓ 40 lines elided ↑ open up ↑
1210 1224  }
1211 1225  
1212 1226  // Test the assertion that the k[12] are the only concrete subtypes of ctxk,
1213 1227  // except possibly for further subtypes of k[12] themselves.
1214 1228  // The context type must be abstract.  The types k1 and k2 are themselves
1215 1229  // allowed to have further concrete subtypes.
1216 1230  klassOop Dependencies::check_abstract_with_exclusive_concrete_subtypes(
1217 1231                                                  klassOop ctxk,
1218 1232                                                  klassOop k1,
1219 1233                                                  klassOop k2,
1220      -                                                DepChange* changes) {
     1234 +                                                KlassDepChange* changes) {
1221 1235    ClassHierarchyWalker wf;
1222 1236    wf.add_participant(k1);
1223 1237    wf.add_participant(k2);
1224 1238    return wf.find_witness_subtype(ctxk, changes);
1225 1239  }
1226 1240  
1227 1241  // Search ctxk for concrete implementations.  If there are klen or fewer,
1228 1242  // pack them into the given array and return the number.
1229 1243  // Otherwise, return -1, meaning the given array would overflow.
1230 1244  // (Note that a return of 0 means there are exactly no concrete subtypes.)
↓ open down ↓ 40 lines elided ↑ open up ↑
1271 1285        ShouldNotReachHere();  // klen > 2 yet supported
1272 1286      }
1273 1287    }
1274 1288  #endif //PRODUCT
1275 1289    return num;
1276 1290  }
1277 1291  
1278 1292  // If a class (or interface) has a unique concrete method uniqm, return NULL.
1279 1293  // Otherwise, return a class that contains an interfering method.
1280 1294  klassOop Dependencies::check_unique_concrete_method(klassOop ctxk, methodOop uniqm,
1281      -                                                    DepChange* changes) {
     1295 +                                                    KlassDepChange* changes) {
1282 1296    // Here is a missing optimization:  If uniqm->is_final(),
1283 1297    // we don't really need to search beneath it for overrides.
1284 1298    // This is probably not important, since we don't use dependencies
1285 1299    // to track final methods.  (They can't be "definalized".)
1286 1300    ClassHierarchyWalker wf(uniqm->method_holder(), uniqm);
1287 1301    return wf.find_witness_definer(ctxk, changes);
1288 1302  }
1289 1303  
1290 1304  // Find the set of all non-abstract methods under ctxk that match m.
1291 1305  // (The method m must be defined or inherited in ctxk.)
↓ open down ↓ 22 lines elided ↑ open up ↑
1314 1328      guarantee(NULL == (void *)check_unique_concrete_method(ctxk, fm),
1315 1329                "verify dep.");
1316 1330    }
1317 1331  #endif //PRODUCT
1318 1332    return fm;
1319 1333  }
1320 1334  
1321 1335  klassOop Dependencies::check_exclusive_concrete_methods(klassOop ctxk,
1322 1336                                                          methodOop m1,
1323 1337                                                          methodOop m2,
1324      -                                                        DepChange* changes) {
     1338 +                                                        KlassDepChange* changes) {
1325 1339    ClassHierarchyWalker wf(m1);
1326 1340    wf.add_participant(m1->method_holder());
1327 1341    wf.add_participant(m2->method_holder());
1328 1342    return wf.find_witness_definer(ctxk, changes);
1329 1343  }
1330 1344  
1331 1345  // Find the set of all non-abstract methods under ctxk that match m[0].
1332 1346  // (The method m[0] must be defined or inherited in ctxk.)
1333 1347  // Include m itself in the set, unless it is abstract.
1334 1348  // Fill the given array m[0..(mlen-1)] with this set, and return the length.
↓ open down ↓ 41 lines elided ↑ open up ↑
1376 1390        break;
1377 1391      default:
1378 1392        ShouldNotReachHere();  // mlen > 2 yet supported
1379 1393      }
1380 1394    }
1381 1395  #endif //PRODUCT
1382 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 1401    Klass* search_at = ctxk->klass_part();
1388 1402    if (changes != NULL)
1389 1403      search_at = changes->new_type()->klass_part(); // just look at the new bit
1390 1404    Klass* result = find_finalizable_subclass(search_at);
1391 1405    if (result == NULL) {
1392 1406      return NULL;
1393 1407    }
1394 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 1443    assert_locked_or_safepoint(Compile_lock);
     1444 +  Dependencies::check_valid_dependency_type(type());
1400 1445  
1401 1446    klassOop witness = NULL;
1402 1447    switch (type()) {
1403 1448    case evol_method:
1404 1449      witness = check_evol_method(method_argument(0));
1405 1450      break;
1406 1451    case leaf_type:
1407 1452      witness = check_leaf_type(context_type());
1408 1453      break;
1409 1454    case abstract_with_unique_concrete_subtype:
1410      -    witness = check_abstract_with_unique_concrete_subtype(context_type(),
1411      -                                                          type_argument(1),
1412      -                                                          changes);
     1455 +    witness = check_abstract_with_unique_concrete_subtype(context_type(), type_argument(1), changes);
1413 1456      break;
1414 1457    case abstract_with_no_concrete_subtype:
1415      -    witness = check_abstract_with_no_concrete_subtype(context_type(),
1416      -                                                      changes);
     1458 +    witness = check_abstract_with_no_concrete_subtype(context_type(), changes);
1417 1459      break;
1418 1460    case concrete_with_no_concrete_subtype:
1419      -    witness = check_concrete_with_no_concrete_subtype(context_type(),
1420      -                                                      changes);
     1461 +    witness = check_concrete_with_no_concrete_subtype(context_type(), changes);
1421 1462      break;
1422 1463    case unique_concrete_method:
1423      -    witness = check_unique_concrete_method(context_type(),
1424      -                                           method_argument(1),
1425      -                                           changes);
     1464 +    witness = check_unique_concrete_method(context_type(), method_argument(1), changes);
1426 1465      break;
1427 1466    case abstract_with_exclusive_concrete_subtypes_2:
1428      -    witness = check_abstract_with_exclusive_concrete_subtypes(context_type(),
1429      -                                                              type_argument(1),
1430      -                                                              type_argument(2),
1431      -                                                              changes);
     1467 +    witness = check_abstract_with_exclusive_concrete_subtypes(context_type(), type_argument(1), type_argument(2), changes);
1432 1468      break;
1433 1469    case exclusive_concrete_methods_2:
1434      -    witness = check_exclusive_concrete_methods(context_type(),
1435      -                                               method_argument(1),
1436      -                                               method_argument(2),
1437      -                                               changes);
     1470 +    witness = check_exclusive_concrete_methods(context_type(), method_argument(1), method_argument(2), changes);
1438 1471      break;
1439 1472    case no_finalizable_subclasses:
1440      -    witness = check_has_no_finalizable_subclasses(context_type(),
1441      -                                                  changes);
     1473 +    witness = check_has_no_finalizable_subclasses(context_type(), changes);
1442 1474      break;
1443      -          default:
     1475 +  default:
1444 1476      witness = NULL;
1445      -    ShouldNotReachHere();
1446 1477      break;
1447 1478    }
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      -  }
     1479 +  trace_and_log_witness(witness);
1455 1480    return witness;
1456 1481  }
1457 1482  
1458 1483  
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;
     1484 +klassOop Dependencies::DepStream::check_call_site_dependency(CallSiteDepChange* changes) {
     1485 +  assert_locked_or_safepoint(Compile_lock);
     1486 +  Dependencies::check_valid_dependency_type(type());
1463 1487  
1464      -  return check_dependency_impl(&changes);
     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;
1465 1499  }
1466 1500  
1467 1501  
1468      -void DepChange::initialize() {
1469      -  // entire transaction must be under this lock:
1470      -  assert_lock_strong(Compile_lock);
     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());
1471 1510  
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      -  }
     1511 +  // irrelevant dependency; skip it
     1512 +  return NULL;
1479 1513  }
1480 1514  
1481      -DepChange::~DepChange() {
1482      -  // Unmark all dependee and all its superclasses
1483      -  // Unmark transitive interfaces
     1515 +
     1516 +void DepChange::print() {
     1517 +  int nsup = 0, nint = 0;
1484 1518    for (ContextStream str(*this); str.next(); ) {
1485      -    klassOop d = str.klass();
1486      -    instanceKlass::cast(d)->set_is_marked_dependent(false);
     1519 +    klassOop k = str.klass();
     1520 +    switch (str.change_type()) {
     1521 +    case Change_new_type:
     1522 +      tty->print_cr("  dependee = %s", instanceKlass::cast(k)->external_name());
     1523 +      break;
     1524 +    case Change_new_sub:
     1525 +      if (!WizardMode) {
     1526 +        ++nsup;
     1527 +      } else {
     1528 +        tty->print_cr("  context super = %s", instanceKlass::cast(k)->external_name());
     1529 +      }
     1530 +      break;
     1531 +    case Change_new_impl:
     1532 +      if (!WizardMode) {
     1533 +        ++nint;
     1534 +      } else {
     1535 +        tty->print_cr("  context interface = %s", instanceKlass::cast(k)->external_name());
     1536 +      }
     1537 +      break;
     1538 +    }
     1539 +  }
     1540 +  if (nsup + nint != 0) {
     1541 +    tty->print_cr("  context supers = %d, interfaces = %d", nsup, nint);
1487 1542    }
1488 1543  }
1489 1544  
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;
     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;
1499 1552  }
1500 1553  
1501 1554  bool DepChange::ContextStream::next() {
1502 1555    switch (_change_type) {
1503 1556    case Start_Klass:             // initial state; _klass is the new type
1504 1557      _ti_base = instanceKlass::cast(_klass)->transitive_interfaces();
1505 1558      _ti_index = 0;
1506 1559      _change_type = Change_new_type;
1507 1560      return true;
1508 1561    case Change_new_type:
↓ open down ↓ 18 lines elided ↑ open up ↑
1527 1580      // fall through:
1528 1581      _change_type = NO_CHANGE;  // iterator is exhausted
1529 1582    case NO_CHANGE:
1530 1583      break;
1531 1584    default:
1532 1585      ShouldNotReachHere();
1533 1586    }
1534 1587    return false;
1535 1588  }
1536 1589  
1537      -void DepChange::print() {
1538      -  int nsup = 0, nint = 0;
     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
1539 1596    for (ContextStream str(*this); str.next(); ) {
1540      -    klassOop k = str.klass();
1541      -    switch (str.change_type()) {
1542      -    case Change_new_type:
1543      -      tty->print_cr("  dependee = %s", instanceKlass::cast(k)->external_name());
1544      -      break;
1545      -    case Change_new_sub:
1546      -      if (!WizardMode) {
1547      -        ++nsup;
1548      -      } else {
1549      -        tty->print_cr("  context super = %s", instanceKlass::cast(k)->external_name());
1550      -      }
1551      -      break;
1552      -    case Change_new_impl:
1553      -      if (!WizardMode) {
1554      -        ++nint;
1555      -      } else {
1556      -        tty->print_cr("  context interface = %s", instanceKlass::cast(k)->external_name());
1557      -      }
1558      -      break;
1559      -    }
     1597 +    klassOop d = str.klass();
     1598 +    assert(!instanceKlass::cast(d)->is_marked_dependent(), "checking");
     1599 +    instanceKlass::cast(d)->set_is_marked_dependent(true);
1560 1600    }
1561      -  if (nsup + nint != 0) {
1562      -    tty->print_cr("  context supers = %d, interfaces = %d", nsup, nint);
     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);
1563 1609    }
1564 1610  }
1565 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 1623  #ifndef PRODUCT
1567 1624  void Dependencies::print_statistics() {
1568 1625    if (deps_find_witness_print != 0) {
1569 1626      // Call one final time, to flush out the data.
1570 1627      deps_find_witness_print = -1;
1571 1628      count_find_witness_calls();
1572 1629    }
1573 1630  }
1574 1631  #endif
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX