src/share/vm/oops/methodOop.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1311     assert(methods_parameter_annotations == NULL || methods_parameter_annotations->length() == methods->length(), "");
1312     assert(methods_default_annotations == NULL   || methods_default_annotations->length() == methods->length(), "");
1313     if (do_annotations) {
1314       ResourceMark rm;
1315       // Allocate temporary storage
1316       GrowableArray<oop>* temp_array = new GrowableArray<oop>(length);
1317       reorder_based_on_method_index(methods, methods_annotations, temp_array);
1318       reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
1319       reorder_based_on_method_index(methods, methods_default_annotations, temp_array);
1320     }
1321 
1322     // Reset method ordering
1323     for (int i = 0; i < length; i++) {
1324       methodOop m = (methodOop) methods->obj_at(i);
1325       m->set_method_idnum(i);
1326     }
1327   }
1328 }
1329 
1330 
1331 //-----------------------------------------------------------------------------------
1332 // Non-product code
1333 
1334 #ifndef PRODUCT
1335 class SignatureTypePrinter : public SignatureTypeNames {
1336  private:
1337   outputStream* _st;
1338   bool _use_separator;
1339 
1340   void type_name(const char* name) {
1341     if (_use_separator) _st->print(", ");
1342     _st->print(name);
1343     _use_separator = true;
1344   }
1345 
1346  public:
1347   SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1348     _st = st;
1349     _use_separator = false;
1350   }
1351 
1352   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1353   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1354 };
1355 
1356 
1357 void methodOopDesc::print_name(outputStream* st) {
1358   Thread *thread = Thread::current();
1359   ResourceMark rm(thread);
1360   SignatureTypePrinter sig(signature(), st);
1361   st->print("%s ", is_static() ? "static" : "virtual");
1362   sig.print_returntype();
1363   st->print(" %s.", method_holder()->klass_part()->internal_name());
1364   name()->print_symbol_on(st);
1365   st->print("(");
1366   sig.print_parameters();
1367   st->print(")");
1368 }
1369 
1370 




1371 void methodOopDesc::print_codes_on(outputStream* st) const {
1372   print_codes_on(0, code_size(), st);
1373 }
1374 
1375 void methodOopDesc::print_codes_on(int from, int to, outputStream* st) const {
1376   Thread *thread = Thread::current();
1377   ResourceMark rm(thread);
1378   methodHandle mh (thread, (methodOop)this);
1379   BytecodeStream s(mh);
1380   s.set_interval(from, to);
1381   BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1382   while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1383 }
1384 #endif // not PRODUCT
1385 
1386 
1387 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1388 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1389 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1390 // as end-of-stream terminator.


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


1311     assert(methods_parameter_annotations == NULL || methods_parameter_annotations->length() == methods->length(), "");
1312     assert(methods_default_annotations == NULL   || methods_default_annotations->length() == methods->length(), "");
1313     if (do_annotations) {
1314       ResourceMark rm;
1315       // Allocate temporary storage
1316       GrowableArray<oop>* temp_array = new GrowableArray<oop>(length);
1317       reorder_based_on_method_index(methods, methods_annotations, temp_array);
1318       reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
1319       reorder_based_on_method_index(methods, methods_default_annotations, temp_array);
1320     }
1321 
1322     // Reset method ordering
1323     for (int i = 0; i < length; i++) {
1324       methodOop m = (methodOop) methods->obj_at(i);
1325       m->set_method_idnum(i);
1326     }
1327   }
1328 }
1329 
1330 




1331 class SignatureTypePrinter : public SignatureTypeNames {
1332  private:
1333   outputStream* _st;
1334   bool _use_separator;
1335 
1336   void type_name(const char* name) {
1337     if (_use_separator) _st->print(", ");
1338     _st->print(name);
1339     _use_separator = true;
1340   }
1341 
1342  public:
1343   SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1344     _st = st;
1345     _use_separator = false;
1346   }
1347 
1348   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1349   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1350 };
1351 
1352 
1353 void methodOopDesc::print_name(outputStream* st) {
1354   Thread *thread = Thread::current();
1355   ResourceMark rm(thread);
1356   SignatureTypePrinter sig(signature(), st);
1357   st->print("%s ", is_static() ? "static" : "virtual");
1358   sig.print_returntype();
1359   st->print(" %s.", method_holder()->klass_part()->internal_name());
1360   name()->print_symbol_on(st);
1361   st->print("(");
1362   sig.print_parameters();
1363   st->print(")");
1364 }
1365 
1366 
1367 //-----------------------------------------------------------------------------------
1368 // Non-product code
1369 
1370 #ifndef PRODUCT
1371 void methodOopDesc::print_codes_on(outputStream* st) const {
1372   print_codes_on(0, code_size(), st);
1373 }
1374 
1375 void methodOopDesc::print_codes_on(int from, int to, outputStream* st) const {
1376   Thread *thread = Thread::current();
1377   ResourceMark rm(thread);
1378   methodHandle mh (thread, (methodOop)this);
1379   BytecodeStream s(mh);
1380   s.set_interval(from, to);
1381   BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1382   while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1383 }
1384 #endif // not PRODUCT
1385 
1386 
1387 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1388 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1389 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1390 // as end-of-stream terminator.