Mercurial > hg > graal-compiler
comparison src/share/vm/code/dependencies.cpp @ 20316:3c048df3ef8b
8040920: Uninitialised memory in hotspot/src/share/vm/code/dependencies.cpp
Summary: Fixed parfait initialization issue.
Reviewed-by: kvn, twisti
author | morris |
---|---|
date | Thu, 07 Aug 2014 18:09:12 -0700 |
parents | ce8f6bb717c9 |
children | bee8095780db d5b74c583ec1 |
comparison
equal
deleted
inserted
replaced
20315:f5b4600d7368 | 20316:3c048df3ef8b |
---|---|
405 } | 405 } |
406 | 406 |
407 // for the sake of the compiler log, print out current dependencies: | 407 // for the sake of the compiler log, print out current dependencies: |
408 void Dependencies::log_all_dependencies() { | 408 void Dependencies::log_all_dependencies() { |
409 if (log() == NULL) return; | 409 if (log() == NULL) return; |
410 ciBaseObject* args[max_arg_count]; | 410 ResourceMark rm; |
411 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { | 411 for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { |
412 DepType dept = (DepType)deptv; | 412 DepType dept = (DepType)deptv; |
413 GrowableArray<ciBaseObject*>* deps = _deps[dept]; | 413 GrowableArray<ciBaseObject*>* deps = _deps[dept]; |
414 if (deps->length() == 0) continue; | 414 int deplen = deps->length(); |
415 if (deplen == 0) { | |
416 continue; | |
417 } | |
415 int stride = dep_args(dept); | 418 int stride = dep_args(dept); |
419 GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(stride); | |
416 for (int i = 0; i < deps->length(); i += stride) { | 420 for (int i = 0; i < deps->length(); i += stride) { |
417 for (int j = 0; j < stride; j++) { | 421 for (int j = 0; j < stride; j++) { |
418 // flush out the identities before printing | 422 // flush out the identities before printing |
419 args[j] = deps->at(i+j); | 423 ciargs->push(deps->at(i+j)); |
420 } | 424 } |
421 write_dependency_to(log(), dept, stride, args); | 425 write_dependency_to(log(), dept, ciargs); |
422 } | 426 ciargs->clear(); |
427 } | |
428 guarantee(deplen == deps->length(), "deps array cannot grow inside nested ResoureMark scope"); | |
423 } | 429 } |
424 } | 430 } |
425 | 431 |
426 void Dependencies::write_dependency_to(CompileLog* log, | 432 void Dependencies::write_dependency_to(CompileLog* log, |
427 DepType dept, | 433 DepType dept, |
428 int nargs, DepArgument args[], | 434 GrowableArray<DepArgument>* args, |
429 Klass* witness) { | 435 Klass* witness) { |
430 if (log == NULL) { | 436 if (log == NULL) { |
431 return; | 437 return; |
432 } | 438 } |
439 ResourceMark rm; | |
433 ciEnv* env = ciEnv::current(); | 440 ciEnv* env = ciEnv::current(); |
434 ciBaseObject* ciargs[max_arg_count]; | 441 GrowableArray<ciBaseObject*>* ciargs = new GrowableArray<ciBaseObject*>(args->length()); |
435 assert(nargs <= max_arg_count, "oob"); | 442 for (GrowableArrayIterator<DepArgument> it = args->begin(); it != args->end(); ++it) { |
436 for (int j = 0; j < nargs; j++) { | 443 DepArgument arg = *it; |
437 if (args[j].is_oop()) { | 444 if (arg.is_oop()) { |
438 ciargs[j] = env->get_object(args[j].oop_value()); | 445 ciargs->push(env->get_object(arg.oop_value())); |
439 } else { | 446 } else { |
440 ciargs[j] = env->get_metadata(args[j].metadata_value()); | 447 ciargs->push(env->get_metadata(arg.metadata_value())); |
441 } | 448 } |
442 } | 449 } |
443 Dependencies::write_dependency_to(log, dept, nargs, ciargs, witness); | 450 int argslen = ciargs->length(); |
451 Dependencies::write_dependency_to(log, dept, ciargs, witness); | |
452 guarantee(argslen == ciargs->length(), "ciargs array cannot grow inside nested ResoureMark scope"); | |
444 } | 453 } |
445 | 454 |
446 void Dependencies::write_dependency_to(CompileLog* log, | 455 void Dependencies::write_dependency_to(CompileLog* log, |
447 DepType dept, | 456 DepType dept, |
448 int nargs, ciBaseObject* args[], | 457 GrowableArray<ciBaseObject*>* args, |
449 Klass* witness) { | 458 Klass* witness) { |
450 if (log == NULL) return; | 459 if (log == NULL) { |
451 assert(nargs <= max_arg_count, "oob"); | 460 return; |
452 int argids[max_arg_count]; | 461 } |
453 int ctxkj = dep_context_arg(dept); // -1 if no context arg | 462 ResourceMark rm; |
454 int j; | 463 GrowableArray<int>* argids = new GrowableArray<int>(args->length()); |
455 for (j = 0; j < nargs; j++) { | 464 for (GrowableArrayIterator<ciBaseObject*> it = args->begin(); it != args->end(); ++it) { |
456 if (args[j]->is_object()) { | 465 ciBaseObject* obj = *it; |
457 argids[j] = log->identify(args[j]->as_object()); | 466 if (obj->is_object()) { |
467 argids->push(log->identify(obj->as_object())); | |
458 } else { | 468 } else { |
459 argids[j] = log->identify(args[j]->as_metadata()); | 469 argids->push(log->identify(obj->as_metadata())); |
460 } | 470 } |
461 } | 471 } |
462 if (witness != NULL) { | 472 if (witness != NULL) { |
463 log->begin_elem("dependency_failed"); | 473 log->begin_elem("dependency_failed"); |
464 } else { | 474 } else { |
465 log->begin_elem("dependency"); | 475 log->begin_elem("dependency"); |
466 } | 476 } |
467 log->print(" type='%s'", dep_name(dept)); | 477 log->print(" type='%s'", dep_name(dept)); |
468 if (ctxkj >= 0) { | 478 const int ctxkj = dep_context_arg(dept); // -1 if no context arg |
469 log->print(" ctxk='%d'", argids[ctxkj]); | 479 if (ctxkj >= 0 && ctxkj < argids->length()) { |
480 log->print(" ctxk='%d'", argids->at(ctxkj)); | |
470 } | 481 } |
471 // write remaining arguments, if any. | 482 // write remaining arguments, if any. |
472 for (j = 0; j < nargs; j++) { | 483 for (int j = 0; j < argids->length(); j++) { |
473 if (j == ctxkj) continue; // already logged | 484 if (j == ctxkj) continue; // already logged |
474 if (j == 1) { | 485 if (j == 1) { |
475 log->print( " x='%d'", argids[j]); | 486 log->print( " x='%d'", argids->at(j)); |
476 } else { | 487 } else { |
477 log->print(" x%d='%d'", j, argids[j]); | 488 log->print(" x%d='%d'", j, argids->at(j)); |
478 } | 489 } |
479 } | 490 } |
480 if (witness != NULL) { | 491 if (witness != NULL) { |
481 log->object("witness", witness); | 492 log->object("witness", witness); |
482 log->stamp(); | 493 log->stamp(); |
484 log->end_elem(); | 495 log->end_elem(); |
485 } | 496 } |
486 | 497 |
487 void Dependencies::write_dependency_to(xmlStream* xtty, | 498 void Dependencies::write_dependency_to(xmlStream* xtty, |
488 DepType dept, | 499 DepType dept, |
489 int nargs, DepArgument args[], | 500 GrowableArray<DepArgument>* args, |
490 Klass* witness) { | 501 Klass* witness) { |
491 if (xtty == NULL) return; | 502 if (xtty == NULL) { |
503 return; | |
504 } | |
505 ResourceMark rm; | |
492 ttyLocker ttyl; | 506 ttyLocker ttyl; |
493 int ctxkj = dep_context_arg(dept); // -1 if no context arg | 507 int ctxkj = dep_context_arg(dept); // -1 if no context arg |
494 if (witness != NULL) { | 508 if (witness != NULL) { |
495 xtty->begin_elem("dependency_failed"); | 509 xtty->begin_elem("dependency_failed"); |
496 } else { | 510 } else { |
497 xtty->begin_elem("dependency"); | 511 xtty->begin_elem("dependency"); |
498 } | 512 } |
499 xtty->print(" type='%s'", dep_name(dept)); | 513 xtty->print(" type='%s'", dep_name(dept)); |
500 if (ctxkj >= 0) { | 514 if (ctxkj >= 0) { |
501 xtty->object("ctxk", args[ctxkj].metadata_value()); | 515 xtty->object("ctxk", args->at(ctxkj).metadata_value()); |
502 } | 516 } |
503 // write remaining arguments, if any. | 517 // write remaining arguments, if any. |
504 for (int j = 0; j < nargs; j++) { | 518 for (int j = 0; j < args->length(); j++) { |
505 if (j == ctxkj) continue; // already logged | 519 if (j == ctxkj) continue; // already logged |
520 DepArgument arg = args->at(j); | |
506 if (j == 1) { | 521 if (j == 1) { |
507 if (args[j].is_oop()) { | 522 if (arg.is_oop()) { |
508 xtty->object("x", args[j].oop_value()); | 523 xtty->object("x", arg.oop_value()); |
509 } else { | 524 } else { |
510 xtty->object("x", args[j].metadata_value()); | 525 xtty->object("x", arg.metadata_value()); |
511 } | 526 } |
512 } else { | 527 } else { |
513 char xn[10]; sprintf(xn, "x%d", j); | 528 char xn[10]; sprintf(xn, "x%d", j); |
514 if (args[j].is_oop()) { | 529 if (arg.is_oop()) { |
515 xtty->object(xn, args[j].oop_value()); | 530 xtty->object(xn, arg.oop_value()); |
516 } else { | 531 } else { |
517 xtty->object(xn, args[j].metadata_value()); | 532 xtty->object(xn, arg.metadata_value()); |
518 } | 533 } |
519 } | 534 } |
520 } | 535 } |
521 if (witness != NULL) { | 536 if (witness != NULL) { |
522 xtty->object("witness", witness); | 537 xtty->object("witness", witness); |
523 xtty->stamp(); | 538 xtty->stamp(); |
524 } | 539 } |
525 xtty->end_elem(); | 540 xtty->end_elem(); |
526 } | 541 } |
527 | 542 |
528 void Dependencies::print_dependency(DepType dept, int nargs, DepArgument args[], | 543 void Dependencies::print_dependency(DepType dept, GrowableArray<DepArgument>* args, |
529 Klass* witness) { | 544 Klass* witness) { |
530 ResourceMark rm; | 545 ResourceMark rm; |
531 ttyLocker ttyl; // keep the following output all in one block | 546 ttyLocker ttyl; // keep the following output all in one block |
532 tty->print_cr("%s of type %s", | 547 tty->print_cr("%s of type %s", |
533 (witness == NULL)? "Dependency": "Failed dependency", | 548 (witness == NULL)? "Dependency": "Failed dependency", |
534 dep_name(dept)); | 549 dep_name(dept)); |
535 // print arguments | 550 // print arguments |
536 int ctxkj = dep_context_arg(dept); // -1 if no context arg | 551 int ctxkj = dep_context_arg(dept); // -1 if no context arg |
537 for (int j = 0; j < nargs; j++) { | 552 for (int j = 0; j < args->length(); j++) { |
538 DepArgument arg = args[j]; | 553 DepArgument arg = args->at(j); |
539 bool put_star = false; | 554 bool put_star = false; |
540 if (arg.is_null()) continue; | 555 if (arg.is_null()) continue; |
541 const char* what; | 556 const char* what; |
542 if (j == ctxkj) { | 557 if (j == ctxkj) { |
543 assert(arg.is_metadata(), "must be"); | 558 assert(arg.is_metadata(), "must be"); |
569 } | 584 } |
570 | 585 |
571 void Dependencies::DepStream::log_dependency(Klass* witness) { | 586 void Dependencies::DepStream::log_dependency(Klass* witness) { |
572 if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime | 587 if (_deps == NULL && xtty == NULL) return; // fast cutout for runtime |
573 ResourceMark rm; | 588 ResourceMark rm; |
574 int nargs = argument_count(); | 589 const int nargs = argument_count(); |
575 DepArgument args[max_arg_count]; | 590 GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs); |
576 for (int j = 0; j < nargs; j++) { | 591 for (int j = 0; j < nargs; j++) { |
577 if (type() == call_site_target_value) { | 592 if (type() == call_site_target_value) { |
578 args[j] = argument_oop(j); | 593 args->push(argument_oop(j)); |
579 } else { | 594 } else { |
580 args[j] = argument(j); | 595 args->push(argument(j)); |
581 } | 596 } |
582 } | 597 } |
598 int argslen = args->length(); | |
583 if (_deps != NULL && _deps->log() != NULL) { | 599 if (_deps != NULL && _deps->log() != NULL) { |
584 Dependencies::write_dependency_to(_deps->log(), | 600 Dependencies::write_dependency_to(_deps->log(), type(), args, witness); |
585 type(), nargs, args, witness); | |
586 } else { | 601 } else { |
587 Dependencies::write_dependency_to(xtty, | 602 Dependencies::write_dependency_to(xtty, type(), args, witness); |
588 type(), nargs, args, witness); | 603 } |
589 } | 604 guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope"); |
590 } | 605 } |
591 | 606 |
592 void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { | 607 void Dependencies::DepStream::print_dependency(Klass* witness, bool verbose) { |
608 ResourceMark rm; | |
593 int nargs = argument_count(); | 609 int nargs = argument_count(); |
594 DepArgument args[max_arg_count]; | 610 GrowableArray<DepArgument>* args = new GrowableArray<DepArgument>(nargs); |
595 for (int j = 0; j < nargs; j++) { | 611 for (int j = 0; j < nargs; j++) { |
596 args[j] = argument(j); | 612 args->push(argument(j)); |
597 } | 613 } |
598 Dependencies::print_dependency(type(), nargs, args, witness); | 614 int argslen = args->length(); |
615 Dependencies::print_dependency(type(), args, witness); | |
599 if (verbose) { | 616 if (verbose) { |
600 if (_code != NULL) { | 617 if (_code != NULL) { |
601 tty->print(" code: "); | 618 tty->print(" code: "); |
602 _code->print_value_on(tty); | 619 _code->print_value_on(tty); |
603 tty->cr(); | 620 tty->cr(); |
604 } | 621 } |
605 } | 622 } |
623 guarantee(argslen == args->length(), "args array cannot grow inside nested ResoureMark scope"); | |
606 } | 624 } |
607 | 625 |
608 | 626 |
609 /// Dependency stream support (decodes dependencies from an nmethod): | 627 /// Dependency stream support (decodes dependencies from an nmethod): |
610 | 628 |