src/share/vm/oops/method.cpp

Print this page




1368     assert(methods_type_annotations == NULL   || methods_type_annotations->length() == methods->length(), "");
1369     if (do_annotations) {
1370       ResourceMark rm;
1371       // Allocate temporary storage
1372       GrowableArray<AnnotationArray*>* temp_array = new GrowableArray<AnnotationArray*>(length);
1373       reorder_based_on_method_index(methods, methods_annotations, temp_array);
1374       reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
1375       reorder_based_on_method_index(methods, methods_default_annotations, temp_array);
1376       reorder_based_on_method_index(methods, methods_type_annotations, temp_array);
1377     }
1378 
1379     // Reset method ordering
1380     for (int i = 0; i < length; i++) {
1381       Method* m = methods->at(i);
1382       m->set_method_idnum(i);
1383     }
1384   }
1385 }
1386 
1387 
1388 //-----------------------------------------------------------------------------------
1389 // Non-product code
1390 
1391 #ifndef PRODUCT
1392 class SignatureTypePrinter : public SignatureTypeNames {
1393  private:
1394   outputStream* _st;
1395   bool _use_separator;
1396 
1397   void type_name(const char* name) {
1398     if (_use_separator) _st->print(", ");
1399     _st->print(name);
1400     _use_separator = true;
1401   }
1402 
1403  public:
1404   SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1405     _st = st;
1406     _use_separator = false;
1407   }
1408 
1409   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1410   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1411 };
1412 
1413 
1414 void Method::print_name(outputStream* st) {
1415   Thread *thread = Thread::current();
1416   ResourceMark rm(thread);
1417   SignatureTypePrinter sig(signature(), st);
1418   st->print("%s ", is_static() ? "static" : "virtual");
1419   sig.print_returntype();
1420   st->print(" %s.", method_holder()->internal_name());
1421   name()->print_symbol_on(st);
1422   st->print("(");
1423   sig.print_parameters();
1424   st->print(")");
1425 }
1426 
1427 




1428 void Method::print_codes_on(outputStream* st) const {
1429   print_codes_on(0, code_size(), st);
1430 }
1431 
1432 void Method::print_codes_on(int from, int to, outputStream* st) const {
1433   Thread *thread = Thread::current();
1434   ResourceMark rm(thread);
1435   methodHandle mh (thread, (Method*)this);
1436   BytecodeStream s(mh);
1437   s.set_interval(from, to);
1438   BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1439   while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1440 }
1441 #endif // not PRODUCT
1442 
1443 
1444 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1445 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1446 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1447 // as end-of-stream terminator.




1368     assert(methods_type_annotations == NULL   || methods_type_annotations->length() == methods->length(), "");
1369     if (do_annotations) {
1370       ResourceMark rm;
1371       // Allocate temporary storage
1372       GrowableArray<AnnotationArray*>* temp_array = new GrowableArray<AnnotationArray*>(length);
1373       reorder_based_on_method_index(methods, methods_annotations, temp_array);
1374       reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
1375       reorder_based_on_method_index(methods, methods_default_annotations, temp_array);
1376       reorder_based_on_method_index(methods, methods_type_annotations, temp_array);
1377     }
1378 
1379     // Reset method ordering
1380     for (int i = 0; i < length; i++) {
1381       Method* m = methods->at(i);
1382       m->set_method_idnum(i);
1383     }
1384   }
1385 }
1386 
1387 




1388 class SignatureTypePrinter : public SignatureTypeNames {
1389  private:
1390   outputStream* _st;
1391   bool _use_separator;
1392 
1393   void type_name(const char* name) {
1394     if (_use_separator) _st->print(", ");
1395     _st->print(name);
1396     _use_separator = true;
1397   }
1398 
1399  public:
1400   SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1401     _st = st;
1402     _use_separator = false;
1403   }
1404 
1405   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1406   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1407 };
1408 
1409 
1410 void Method::print_name(outputStream* st) {
1411   Thread *thread = Thread::current();
1412   ResourceMark rm(thread);
1413   SignatureTypePrinter sig(signature(), st);
1414   st->print("%s ", is_static() ? "static" : "virtual");
1415   sig.print_returntype();
1416   st->print(" %s.", method_holder()->internal_name());
1417   name()->print_symbol_on(st);
1418   st->print("(");
1419   sig.print_parameters();
1420   st->print(")");
1421 }
1422 
1423 
1424 //-----------------------------------------------------------------------------------
1425 // Non-product code
1426 
1427 #ifndef PRODUCT
1428 void Method::print_codes_on(outputStream* st) const {
1429   print_codes_on(0, code_size(), st);
1430 }
1431 
1432 void Method::print_codes_on(int from, int to, outputStream* st) const {
1433   Thread *thread = Thread::current();
1434   ResourceMark rm(thread);
1435   methodHandle mh (thread, (Method*)this);
1436   BytecodeStream s(mh);
1437   s.set_interval(from, to);
1438   BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1439   while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1440 }
1441 #endif // not PRODUCT
1442 
1443 
1444 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1445 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1446 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1447 // as end-of-stream terminator.