3615 __ addptr(data_addr, DataLayout::counter_increment);
3616 return;
3617 }
3618 }
3619 } else {
3620 __ load_klass(recv, recv);
3621 Label update_done;
3622 type_profile_helper(mdo, md, data, recv, &update_done);
3623 // Receiver did not match any saved receiver and there is no empty row for it.
3624 // Increment total counter to indicate polymorphic case.
3625 __ addptr(counter_addr, DataLayout::counter_increment);
3626
3627 __ bind(update_done);
3628 }
3629 } else {
3630 // Static call
3631 __ addptr(counter_addr, DataLayout::counter_increment);
3632 }
3633 }
3634
3635 void LIR_Assembler::emit_delay(LIR_OpDelay*) {
3636 Unimplemented();
3637 }
3638
3639
3640 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
3641 __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
3642 }
3643
3644
3645 void LIR_Assembler::align_backward_branch_target() {
3646 __ align(BytesPerWord);
3647 }
3648
3649
3650 void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
3651 if (left->is_single_cpu()) {
3652 __ negl(left->as_register());
3653 move_regs(left->as_register(), dest->as_register());
3654
|
3615 __ addptr(data_addr, DataLayout::counter_increment);
3616 return;
3617 }
3618 }
3619 } else {
3620 __ load_klass(recv, recv);
3621 Label update_done;
3622 type_profile_helper(mdo, md, data, recv, &update_done);
3623 // Receiver did not match any saved receiver and there is no empty row for it.
3624 // Increment total counter to indicate polymorphic case.
3625 __ addptr(counter_addr, DataLayout::counter_increment);
3626
3627 __ bind(update_done);
3628 }
3629 } else {
3630 // Static call
3631 __ addptr(counter_addr, DataLayout::counter_increment);
3632 }
3633 }
3634
3635 void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
3636 Register obj = op->obj()->as_register();
3637 Register tmp = op->tmp()->as_pointer_register();
3638 Address mdo_addr = as_Address(op->mdp()->as_address_ptr());
3639 ciKlass* exact_klass = op->exact_klass();
3640 intptr_t current_klass = op->current_klass();
3641 bool not_null = op->not_null();
3642 bool no_conflict = op->no_conflict();
3643
3644 Label update, next, none;
3645
3646 bool do_null = !not_null;
3647 bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
3648 bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
3649
3650 assert(do_null || do_update, "why are we here?");
3651 assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
3652
3653 __ verify_oop(obj);
3654
3655 if (tmp != obj) {
3656 __ mov(tmp, obj);
3657 }
3658 if (do_null) {
3659 __ testptr(tmp, tmp);
3660 __ jccb(Assembler::notZero, update);
3661 if (!TypeEntries::was_null_seen(current_klass)) {
3662 __ orptr(mdo_addr, TypeEntries::null_seen);
3663 }
3664 if (do_update) {
3665 #ifndef ASSERT
3666 __ jmpb(next);
3667 #else
3668 __ jmp(next);
3669 #endif
3670 }
3671 } else {
3672 #ifdef ASSERT
3673 __ testptr(tmp, tmp);
3674 __ jccb(Assembler::notZero, update);
3675 __ stop("unexpect null obj");
3676 #endif
3677 }
3678
3679 __ bind(update);
3680
3681 if (do_update) {
3682 #ifdef ASSERT
3683 if (exact_klass != NULL) {
3684 Label ok;
3685 __ load_klass(tmp, tmp);
3686 __ push(tmp);
3687 __ mov_metadata(tmp, exact_klass->constant_encoding());
3688 __ cmpptr(tmp, Address(rsp, 0));
3689 __ jccb(Assembler::equal, ok);
3690 __ stop("exact klass and actual klass differ");
3691 __ bind(ok);
3692 __ pop(tmp);
3693 }
3694 #endif
3695 if (!no_conflict) {
3696 if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
3697 if (exact_klass != NULL) {
3698 __ mov_metadata(tmp, exact_klass->constant_encoding());
3699 } else {
3700 __ load_klass(tmp, tmp);
3701 }
3702
3703 __ xorptr(tmp, mdo_addr);
3704 __ testptr(tmp, TypeEntries::type_klass_mask);
3705 // klass seen before, nothing to do. The unknown bit may have been
3706 // set already but no need to check.
3707 __ jccb(Assembler::zero, next);
3708
3709 __ testptr(tmp, TypeEntries::type_unknown);
3710 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
3711
3712 if (TypeEntries::is_type_none(current_klass)) {
3713 __ cmpptr(mdo_addr, 0);
3714 __ jccb(Assembler::equal, none);
3715 __ cmpptr(mdo_addr, TypeEntries::null_seen);
3716 __ jccb(Assembler::equal, none);
3717 // There is a chance that the checks above (re-reading profiling
3718 // data from memory) fail if another thread has just set the
3719 // profiling to this obj's klass
3720 __ xorptr(tmp, mdo_addr);
3721 __ testptr(tmp, TypeEntries::type_klass_mask);
3722 __ jccb(Assembler::zero, next);
3723 }
3724 } else {
3725 assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
3726 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
3727
3728 __ movptr(tmp, mdo_addr);
3729 __ testptr(tmp, TypeEntries::type_unknown);
3730 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
3731 }
3732
3733 // different than before. Cannot keep accurate profile.
3734 __ orptr(mdo_addr, TypeEntries::type_unknown);
3735
3736 if (TypeEntries::is_type_none(current_klass)) {
3737 __ jmpb(next);
3738
3739 __ bind(none);
3740 // first time here. Set profile type.
3741 __ movptr(mdo_addr, tmp);
3742 }
3743 } else {
3744 // There's a single possible klass at this profile point
3745 assert(exact_klass != NULL, "should be");
3746 if (TypeEntries::is_type_none(current_klass)) {
3747 __ mov_metadata(tmp, exact_klass->constant_encoding());
3748 __ xorptr(tmp, mdo_addr);
3749 __ testptr(tmp, TypeEntries::type_klass_mask);
3750 #ifdef ASSERT
3751 __ jcc(Assembler::zero, next);
3752
3753 {
3754 Label ok;
3755 __ push(tmp);
3756 __ cmpptr(mdo_addr, 0);
3757 __ jcc(Assembler::equal, ok);
3758 __ cmpptr(mdo_addr, TypeEntries::null_seen);
3759 __ jcc(Assembler::equal, ok);
3760 // may have been set by another thread
3761 __ mov_metadata(tmp, exact_klass->constant_encoding());
3762 __ xorptr(tmp, mdo_addr);
3763 __ testptr(tmp, TypeEntries::type_mask);
3764 __ jcc(Assembler::zero, ok);
3765
3766 __ stop("unexpected profiling mismatch");
3767 __ bind(ok);
3768 __ pop(tmp);
3769 }
3770 #else
3771 __ jccb(Assembler::zero, next);
3772 #endif
3773 // first time here. Set profile type.
3774 __ movptr(mdo_addr, tmp);
3775 } else {
3776 assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
3777 ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
3778
3779 __ movptr(tmp, mdo_addr);
3780 __ testptr(tmp, TypeEntries::type_unknown);
3781 __ jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore.
3782
3783 __ orptr(mdo_addr, TypeEntries::type_unknown);
3784 }
3785 }
3786
3787 __ bind(next);
3788 }
3789 }
3790
3791 void LIR_Assembler::emit_delay(LIR_OpDelay*) {
3792 Unimplemented();
3793 }
3794
3795
3796 void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst) {
3797 __ lea(dst->as_register(), frame_map()->address_for_monitor_lock(monitor_no));
3798 }
3799
3800
3801 void LIR_Assembler::align_backward_branch_target() {
3802 __ align(BytesPerWord);
3803 }
3804
3805
3806 void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
3807 if (left->is_single_cpu()) {
3808 __ negl(left->as_register());
3809 move_regs(left->as_register(), dest->as_register());
3810
|