src/share/vm/oops/method.cpp

Print this page




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.




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