hotspot/src/share/vm/code/dependencies.cpp
changeset 30296 95baefac8485
parent 30195 fff35af9b018
child 31037 01a5c5fa5681
equal deleted inserted replaced
30226:5f1a3a275862 30296:95baefac8485
   115   check_ctxk(ctxk);
   115   check_ctxk(ctxk);
   116   assert_common_1(no_finalizable_subclasses, ctxk);
   116   assert_common_1(no_finalizable_subclasses, ctxk);
   117 }
   117 }
   118 
   118 
   119 void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle) {
   119 void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle) {
   120   check_ctxk(call_site->klass());
   120   ciKlass* ctxk = call_site->get_context();
   121   assert_common_2(call_site_target_value, call_site, method_handle);
   121   check_ctxk(ctxk);
       
   122   assert_common_3(call_site_target_value, ctxk, call_site, method_handle);
   122 }
   123 }
   123 
   124 
   124 // Helper function.  If we are adding a new dep. under ctxk2,
   125 // Helper function.  If we are adding a new dep. under ctxk2,
   125 // try to find an old dep. under a broader* ctxk1.  If there is
   126 // try to find an old dep. under a broader* ctxk1.  If there is
   126 //
   127 //
   386   1, // concrete_with_no_concrete_subtype ctxk
   387   1, // concrete_with_no_concrete_subtype ctxk
   387   2, // unique_concrete_method ctxk, m
   388   2, // unique_concrete_method ctxk, m
   388   3, // unique_concrete_subtypes_2 ctxk, k1, k2
   389   3, // unique_concrete_subtypes_2 ctxk, k1, k2
   389   3, // unique_concrete_methods_2 ctxk, m1, m2
   390   3, // unique_concrete_methods_2 ctxk, m1, m2
   390   1, // no_finalizable_subclasses ctxk
   391   1, // no_finalizable_subclasses ctxk
   391   2  // call_site_target_value call_site, method_handle
   392   3  // call_site_target_value ctxk, call_site, method_handle
   392 };
   393 };
   393 
   394 
   394 const char* Dependencies::dep_name(Dependencies::DepType dept) {
   395 const char* Dependencies::dep_name(Dependencies::DepType dept) {
   395   if (!dept_in_mask(dept, all_types))  return "?bad-dep?";
   396   if (!dept_in_mask(dept, all_types))  return "?bad-dep?";
   396   return _dep_name[dept];
   397   return _dep_name[dept];
   592   if (_deps == NULL && xtty == NULL)  return;  // fast cutout for runtime
   593   if (_deps == NULL && xtty == NULL)  return;  // fast cutout for runtime
   593   ResourceMark rm;
   594   ResourceMark rm;
   594   const int nargs = argument_count();
   595   const int nargs = argument_count();
   595   GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
   596   GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
   596   for (int j = 0; j < nargs; j++) {
   597   for (int j = 0; j < nargs; j++) {
   597     if (type() == call_site_target_value) {
   598     if (is_oop_argument(j)) {
   598       args->push(argument_oop(j));
   599       args->push(argument_oop(j));
   599     } else {
   600     } else {
   600       args->push(argument(j));
   601       args->push(argument(j));
   601     }
   602     }
   602   }
   603   }
   612 void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) {
   613 void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) {
   613   ResourceMark rm;
   614   ResourceMark rm;
   614   int nargs = argument_count();
   615   int nargs = argument_count();
   615   GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
   616   GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs);
   616   for (int j = 0; j < nargs; j++) {
   617   for (int j = 0; j < nargs; j++) {
   617     if (type() == call_site_target_value) {
   618     if (is_oop_argument(j)) {
   618       args->push(argument_oop(j));
   619       args->push(argument_oop(j));
   619     } else {
   620     } else {
   620       args->push(argument(j));
   621       args->push(argument(j));
   621     }
   622     }
   622   }
   623   }
   708 
   709 
   709 /**
   710 /**
   710  * Returns a unique identifier for each dependency argument.
   711  * Returns a unique identifier for each dependency argument.
   711  */
   712  */
   712 uintptr_t Dependencies::DepStream::get_identifier(int i) {
   713 uintptr_t Dependencies::DepStream::get_identifier(int i) {
   713   if (has_oop_argument()) {
   714   if (is_oop_argument(i)) {
   714     return (uintptr_t)(oopDesc*)argument_oop(i);
   715     return (uintptr_t)(oopDesc*)argument_oop(i);
   715   } else {
   716   } else {
   716     return (uintptr_t)argument(i);
   717     return (uintptr_t)argument(i);
   717   }
   718   }
   718 }
   719 }
   735       return (Klass*)k;
   736       return (Klass*)k;
   736     }
   737     }
   737   }
   738   }
   738 
   739 
   739   // Some dependencies are using the klass of the first object
   740   // Some dependencies are using the klass of the first object
   740   // argument as implicit context type (e.g. call_site_target_value).
   741   // argument as implicit context type.
   741   {
   742   {
   742     int ctxkj = dep_implicit_context_arg(type());
   743     int ctxkj = dep_implicit_context_arg(type());
   743     if (ctxkj >= 0) {
   744     if (ctxkj >= 0) {
   744       Klass* k = argument_oop(ctxkj)->klass();
   745       Klass* k = argument_oop(ctxkj)->klass();
   745       assert(k != NULL && k->is_klass(), "type check");
   746       assert(k != NULL && k->is_klass(), "type check");
  1512   if (changes != NULL)
  1513   if (changes != NULL)
  1513     search_at = changes->new_type(); // just look at the new bit
  1514     search_at = changes->new_type(); // just look at the new bit
  1514   return find_finalizable_subclass(search_at);
  1515   return find_finalizable_subclass(search_at);
  1515 }
  1516 }
  1516 
  1517 
  1517 Klass* Dependencies::check_call_site_target_value(oop call_site, oop method_handle, CallSiteDepChange* changes) {
  1518 Klass* Dependencies::check_call_site_target_value(Klass* recorded_ctxk, oop call_site, oop method_handle, CallSiteDepChange* changes) {
  1518   assert(call_site    ->is_a(SystemDictionary::CallSite_klass()),     "sanity");
  1519   assert(call_site->is_a(SystemDictionary::CallSite_klass()),     "sanity");
  1519   assert(method_handle->is_a(SystemDictionary::MethodHandle_klass()), "sanity");
  1520   assert(!oopDesc::is_null(method_handle), "sanity");
       
  1521 
       
  1522   Klass* call_site_ctxk = MethodHandles::get_call_site_context(call_site);
       
  1523   assert(!Klass::is_null(call_site_ctxk), "call site context should be initialized already");
       
  1524   if (recorded_ctxk != call_site_ctxk) {
       
  1525     // Stale context
       
  1526     return recorded_ctxk;
       
  1527   }
  1520   if (changes == NULL) {
  1528   if (changes == NULL) {
  1521     // Validate all CallSites
  1529     // Validate all CallSites
  1522     if (java_lang_invoke_CallSite::target(call_site) != method_handle)
  1530     if (java_lang_invoke_CallSite::target(call_site) != method_handle)
  1523       return call_site->klass();  // assertion failed
  1531       return call_site->klass();  // assertion failed
  1524   } else {
  1532   } else {
  1528       return call_site->klass();  // assertion failed
  1536       return call_site->klass();  // assertion failed
  1529     }
  1537     }
  1530   }
  1538   }
  1531   return NULL;  // assertion still valid
  1539   return NULL;  // assertion still valid
  1532 }
  1540 }
  1533 
       
  1534 
  1541 
  1535 void Dependencies::DepStream::trace_and_log_witness(Klass* witness) {
  1542 void Dependencies::DepStream::trace_and_log_witness(Klass* witness) {
  1536   if (witness != NULL) {
  1543   if (witness != NULL) {
  1537     if (TraceDependencies) {
  1544     if (TraceDependencies) {
  1538       print_dependency(witness, /*verbose=*/ true);
  1545       print_dependency(witness, /*verbose=*/ true);
  1590   Dependencies::check_valid_dependency_type(type());
  1597   Dependencies::check_valid_dependency_type(type());
  1591 
  1598 
  1592   Klass* witness = NULL;
  1599   Klass* witness = NULL;
  1593   switch (type()) {
  1600   switch (type()) {
  1594   case call_site_target_value:
  1601   case call_site_target_value:
  1595     witness = check_call_site_target_value(argument_oop(0), argument_oop(1), changes);
  1602     witness = check_call_site_target_value(context_type(), argument_oop(1), argument_oop(2), changes);
  1596     break;
  1603     break;
  1597   default:
  1604   default:
  1598     witness = NULL;
  1605     witness = NULL;
  1599     break;
  1606     break;
  1600   }
  1607   }