src/share/vm/code/dependencies.cpp

Print this page




 316     GrowableArray<ciBaseObject*>* deps = _deps[dept];
 317     if (deps->length() == 0)  continue;
 318     int stride = dep_args(dept);
 319     int ctxkj  = dep_context_arg(dept);  // -1 if no context arg
 320     assert(stride > 0, "sanity");
 321     for (int i = 0; i < deps->length(); i += stride) {
 322       jbyte code_byte = (jbyte)dept;
 323       int skipj = -1;
 324       if (ctxkj >= 0 && ctxkj+1 < stride) {
 325         ciKlass*  ctxk = deps->at(i+ctxkj+0)->as_metadata()->as_klass();
 326         ciBaseObject* x     = deps->at(i+ctxkj+1);  // following argument
 327         if (ctxk == ctxk_encoded_as_null(dept, x)) {
 328           skipj = ctxkj;  // we win:  maybe one less oop to keep track of
 329           code_byte |= default_context_type_bit;
 330         }
 331       }
 332       bytes.write_byte(code_byte);
 333       for (int j = 0; j < stride; j++) {
 334         if (j == skipj)  continue;
 335         ciBaseObject* v = deps->at(i+j);

 336         if (v->is_object()) {
 337           bytes.write_int(_oop_recorder->find_index(v->as_object()->constant_encoding()));
 338         } else {
 339           ciMetadata* meta = v->as_metadata();
 340           bytes.write_int(_oop_recorder->find_index(meta->constant_encoding()));
 341         }

 342       }
 343     }
 344   }
 345 
 346   // write a sentinel byte to mark the end
 347   bytes.write_byte(end_marker);
 348 
 349   // round it out to a word boundary
 350   while (bytes.position() % sizeof(HeapWord) != 0) {
 351     bytes.write_byte(end_marker);
 352   }
 353 
 354   // check whether the dept byte encoding really works
 355   assert((jbyte)default_context_type_bit != 0, "byte overflow");
 356 
 357   _content_bytes = bytes.buffer();
 358   _size_in_bytes = bytes.position();
 359 }
 360 
 361 


 648 inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) {
 649   Metadata* o = NULL;
 650   if (_code != NULL) {
 651     o = _code->metadata_at(i);
 652   } else {
 653     o = _deps->oop_recorder()->metadata_at(i);
 654   }
 655   assert(o == NULL || o->is_metadata(),
 656          err_msg("Should be perm " PTR_FORMAT, o));
 657   return o;
 658 }
 659 
 660 inline oop Dependencies::DepStream::recorded_oop_at(int i) {
 661   return (_code != NULL)
 662          ? _code->oop_at(i)
 663     : JNIHandles::resolve(_deps->oop_recorder()->oop_at(i));
 664 }
 665 
 666 Metadata* Dependencies::DepStream::argument(int i) {
 667   Metadata* result = recorded_metadata_at(argument_index(i));








 668   assert(result == NULL || result->is_klass() || result->is_method(), "must be");
 669   return result;
 670 }
 671 
 672 oop Dependencies::DepStream::argument_oop(int i) {
 673   oop result = recorded_oop_at(argument_index(i));
 674   assert(result == NULL || result->is_oop(), "must be");
 675   return result;
 676 }
 677 
 678 Klass* Dependencies::DepStream::context_type() {
 679   assert(must_be_in_vm(), "raw oops here");
 680 
 681   // Most dependencies have an explicit context type argument.
 682   {
 683     int ctxkj = dep_context_arg(_type);  // -1 if no explicit context arg
 684     if (ctxkj >= 0) {
 685       Metadata* k = argument(ctxkj);
 686       if (k != NULL) {       // context type was not compressed away
 687         assert(k->is_klass(), "type check");
 688         return (Klass*) k;
 689       }
 690       // recompute "default" context type
 691       return ctxk_encoded_as_null(_type, argument(ctxkj+1));
 692     }
 693   }
 694 
 695   // Some dependencies are using the klass of the first object
 696   // argument as implicit context type (e.g. call_site_target_value).
 697   {
 698     int ctxkj = dep_implicit_context_arg(_type);
 699     if (ctxkj >= 0) {
 700       Klass* k = argument_oop(ctxkj)->klass();
 701       assert(k->is_klass(), "type check");
 702       return (Klass*) k;
 703     }
 704   }
 705 
 706   // And some dependencies don't have a context type at all,
 707   // e.g. evol_method.
 708   return NULL;
 709 }
 710 
 711 /// Checking dependencies:
 712 
 713 // This hierarchy walker inspects subtypes of a given type,
 714 // trying to find a "bad" class which breaks a dependency.
 715 // Such a class is called a "witness" to the broken dependency.
 716 // While searching around, we ignore "participants", which
 717 // are already known to the dependency.
 718 class ClassHierarchyWalker {
 719  public:
 720   enum { PARTICIPANT_LIMIT = 3 };
 721 




 316     GrowableArray<ciBaseObject*>* deps = _deps[dept];
 317     if (deps->length() == 0)  continue;
 318     int stride = dep_args(dept);
 319     int ctxkj  = dep_context_arg(dept);  // -1 if no context arg
 320     assert(stride > 0, "sanity");
 321     for (int i = 0; i < deps->length(); i += stride) {
 322       jbyte code_byte = (jbyte)dept;
 323       int skipj = -1;
 324       if (ctxkj >= 0 && ctxkj+1 < stride) {
 325         ciKlass*  ctxk = deps->at(i+ctxkj+0)->as_metadata()->as_klass();
 326         ciBaseObject* x     = deps->at(i+ctxkj+1);  // following argument
 327         if (ctxk == ctxk_encoded_as_null(dept, x)) {
 328           skipj = ctxkj;  // we win:  maybe one less oop to keep track of
 329           code_byte |= default_context_type_bit;
 330         }
 331       }
 332       bytes.write_byte(code_byte);
 333       for (int j = 0; j < stride; j++) {
 334         if (j == skipj)  continue;
 335         ciBaseObject* v = deps->at(i+j);
 336         int idx;
 337         if (v->is_object()) {
 338           idx = _oop_recorder->find_index(v->as_object()->constant_encoding());
 339         } else {
 340           ciMetadata* meta = v->as_metadata();
 341           idx = _oop_recorder->find_index(meta->constant_encoding());
 342         }
 343         bytes.write_int(idx);
 344       }
 345     }
 346   }
 347 
 348   // write a sentinel byte to mark the end
 349   bytes.write_byte(end_marker);
 350 
 351   // round it out to a word boundary
 352   while (bytes.position() % sizeof(HeapWord) != 0) {
 353     bytes.write_byte(end_marker);
 354   }
 355 
 356   // check whether the dept byte encoding really works
 357   assert((jbyte)default_context_type_bit != 0, "byte overflow");
 358 
 359   _content_bytes = bytes.buffer();
 360   _size_in_bytes = bytes.position();
 361 }
 362 
 363 


 650 inline Metadata* Dependencies::DepStream::recorded_metadata_at(int i) {
 651   Metadata* o = NULL;
 652   if (_code != NULL) {
 653     o = _code->metadata_at(i);
 654   } else {
 655     o = _deps->oop_recorder()->metadata_at(i);
 656   }
 657   assert(o == NULL || o->is_metadata(),
 658          err_msg("Should be perm " PTR_FORMAT, o));
 659   return o;
 660 }
 661 
 662 inline oop Dependencies::DepStream::recorded_oop_at(int i) {
 663   return (_code != NULL)
 664          ? _code->oop_at(i)
 665     : JNIHandles::resolve(_deps->oop_recorder()->oop_at(i));
 666 }
 667 
 668 Metadata* Dependencies::DepStream::argument(int i) {
 669   Metadata* result = recorded_metadata_at(argument_index(i));
 670 
 671   if (result == NULL) { // Explicit context argument can be compressed
 672     int ctxkj = dep_context_arg(type());  // -1 if no explicit context arg
 673     if (ctxkj >= 0 && i == ctxkj && ctxkj+1 < argument_count()) {
 674       result = ctxk_encoded_as_null(type(), argument(ctxkj+1));
 675     }
 676   }
 677 
 678   assert(result == NULL || result->is_klass() || result->is_method(), "must be");
 679   return result;
 680 }
 681 
 682 oop Dependencies::DepStream::argument_oop(int i) {
 683   oop result = recorded_oop_at(argument_index(i));
 684   assert(result == NULL || result->is_oop(), "must be");
 685   return result;
 686 }
 687 
 688 Klass* Dependencies::DepStream::context_type() {
 689   assert(must_be_in_vm(), "raw oops here");
 690 
 691   // Most dependencies have an explicit context type argument.
 692   {
 693     int ctxkj = dep_context_arg(type());  // -1 if no explicit context arg
 694     if (ctxkj >= 0) {
 695       Metadata* k = argument(ctxkj);
 696       assert(k != NULL && k->is_klass(), "type check");
 697       return (Klass*)k;




 698     }
 699   }
 700 
 701   // Some dependencies are using the klass of the first object
 702   // argument as implicit context type (e.g. call_site_target_value).
 703   {
 704     int ctxkj = dep_implicit_context_arg(type());
 705     if (ctxkj >= 0) {
 706       Klass* k = argument_oop(ctxkj)->klass();
 707       assert(k != NULL && k->is_klass(), "type check");
 708       return (Klass*) k;
 709     }
 710   }
 711 
 712   // And some dependencies don't have a context type at all,
 713   // e.g. evol_method.
 714   return NULL;
 715 }
 716 
 717 /// Checking dependencies:
 718 
 719 // This hierarchy walker inspects subtypes of a given type,
 720 // trying to find a "bad" class which breaks a dependency.
 721 // Such a class is called a "witness" to the broken dependency.
 722 // While searching around, we ignore "participants", which
 723 // are already known to the dependency.
 724 class ClassHierarchyWalker {
 725  public:
 726   enum { PARTICIPANT_LIMIT = 3 };
 727