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 *
1329 assert(methods_parameter_annotations == NULL || methods_parameter_annotations->length() == methods->length(), "");
1330 assert(methods_default_annotations == NULL || methods_default_annotations->length() == methods->length(), "");
1331 if (do_annotations) {
1332 ResourceMark rm;
1333 // Allocate temporary storage
1334 GrowableArray<oop>* temp_array = new GrowableArray<oop>(length);
1335 reorder_based_on_method_index(methods, methods_annotations, temp_array);
1336 reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
1337 reorder_based_on_method_index(methods, methods_default_annotations, temp_array);
1338 }
1339
1340 // Reset method ordering
1341 for (int i = 0; i < length; i++) {
1342 methodOop m = (methodOop) methods->obj_at(i);
1343 m->set_method_idnum(i);
1344 }
1345 }
1346 }
1347
1348
1349 //-----------------------------------------------------------------------------------
1350 // Non-product code
1351
1352 #ifndef PRODUCT
1353 class SignatureTypePrinter : public SignatureTypeNames {
1354 private:
1355 outputStream* _st;
1356 bool _use_separator;
1357
1358 void type_name(const char* name) {
1359 if (_use_separator) _st->print(", ");
1360 _st->print(name);
1361 _use_separator = true;
1362 }
1363
1364 public:
1365 SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1366 _st = st;
1367 _use_separator = false;
1368 }
1369
1370 void print_parameters() { _use_separator = false; iterate_parameters(); }
1371 void print_returntype() { _use_separator = false; iterate_returntype(); }
1372 };
1373
1374
1375 void methodOopDesc::print_name(outputStream* st) {
1376 Thread *thread = Thread::current();
1377 ResourceMark rm(thread);
1378 SignatureTypePrinter sig(signature(), st);
1379 st->print("%s ", is_static() ? "static" : "virtual");
1380 sig.print_returntype();
1381 st->print(" %s.", method_holder()->klass_part()->internal_name());
1382 name()->print_symbol_on(st);
1383 st->print("(");
1384 sig.print_parameters();
1385 st->print(")");
1386 }
1387
1388
1389 void methodOopDesc::print_codes_on(outputStream* st) const {
1390 print_codes_on(0, code_size(), st);
1391 }
1392
1393 void methodOopDesc::print_codes_on(int from, int to, outputStream* st) const {
1394 Thread *thread = Thread::current();
1395 ResourceMark rm(thread);
1396 methodHandle mh (thread, (methodOop)this);
1397 BytecodeStream s(mh);
1398 s.set_interval(from, to);
1399 BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1400 while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1401 }
1402 #endif // not PRODUCT
1403
1404
1405 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1406 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1407 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1408 // 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 *
1329 assert(methods_parameter_annotations == NULL || methods_parameter_annotations->length() == methods->length(), "");
1330 assert(methods_default_annotations == NULL || methods_default_annotations->length() == methods->length(), "");
1331 if (do_annotations) {
1332 ResourceMark rm;
1333 // Allocate temporary storage
1334 GrowableArray<oop>* temp_array = new GrowableArray<oop>(length);
1335 reorder_based_on_method_index(methods, methods_annotations, temp_array);
1336 reorder_based_on_method_index(methods, methods_parameter_annotations, temp_array);
1337 reorder_based_on_method_index(methods, methods_default_annotations, temp_array);
1338 }
1339
1340 // Reset method ordering
1341 for (int i = 0; i < length; i++) {
1342 methodOop m = (methodOop) methods->obj_at(i);
1343 m->set_method_idnum(i);
1344 }
1345 }
1346 }
1347
1348
1349 class SignatureTypePrinter : public SignatureTypeNames {
1350 private:
1351 outputStream* _st;
1352 bool _use_separator;
1353
1354 void type_name(const char* name) {
1355 if (_use_separator) _st->print(", ");
1356 _st->print(name);
1357 _use_separator = true;
1358 }
1359
1360 public:
1361 SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1362 _st = st;
1363 _use_separator = false;
1364 }
1365
1366 void print_parameters() { _use_separator = false; iterate_parameters(); }
1367 void print_returntype() { _use_separator = false; iterate_returntype(); }
1368 };
1369
1370
1371 void methodOopDesc::print_name(outputStream* st) {
1372 Thread *thread = Thread::current();
1373 ResourceMark rm(thread);
1374 SignatureTypePrinter sig(signature(), st);
1375 st->print("%s ", is_static() ? "static" : "virtual");
1376 sig.print_returntype();
1377 st->print(" %s.", method_holder()->klass_part()->internal_name());
1378 name()->print_symbol_on(st);
1379 st->print("(");
1380 sig.print_parameters();
1381 st->print(")");
1382 }
1383
1384
1385 //-----------------------------------------------------------------------------------
1386 // Non-product code
1387
1388 #ifndef PRODUCT
1389 void methodOopDesc::print_codes_on(outputStream* st) const {
1390 print_codes_on(0, code_size(), st);
1391 }
1392
1393 void methodOopDesc::print_codes_on(int from, int to, outputStream* st) const {
1394 Thread *thread = Thread::current();
1395 ResourceMark rm(thread);
1396 methodHandle mh (thread, (methodOop)this);
1397 BytecodeStream s(mh);
1398 s.set_interval(from, to);
1399 BytecodeTracer::set_closure(BytecodeTracer::std_closure());
1400 while (s.next() >= 0) BytecodeTracer::trace(mh, s.bcp(), st);
1401 }
1402 #endif // not PRODUCT
1403
1404
1405 // Simple compression of line number tables. We use a regular compressed stream, except that we compress deltas
1406 // between (bci,line) pairs since they are smaller. If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned)
1407 // we save it as one byte, otherwise we write a 0xFF escape character and use regular compression. 0x0 is used
1408 // as end-of-stream terminator.
|