< prev index next >

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Print this page

1630       (!UseFastNewObjectArray && is_reference_type(op->type())) ||
1631       (!UseFastNewTypeArray   && !is_reference_type(op->type()))) {
1632     __ jmp(*op->stub()->entry());
1633   } else {
1634     Register tmp1 = op->tmp1()->as_register();
1635     Register tmp2 = op->tmp2()->as_register();
1636     Register tmp3 = op->tmp3()->as_register();
1637     if (len == tmp1) {
1638       tmp1 = tmp3;
1639     } else if (len == tmp2) {
1640       tmp2 = tmp3;
1641     } else if (len == tmp3) {
1642       // everything is ok
1643     } else {
1644       __ mov(tmp3, len);
1645     }
1646     __ allocate_array(op->obj()->as_register(),
1647                       len,
1648                       tmp1,
1649                       tmp2,
1650                       arrayOopDesc::header_size(op->type()),
1651                       array_element_size(op->type()),
1652                       op->klass()->as_register(),
1653                       *op->stub()->entry());
1654   }
1655   __ bind(*op->stub()->continuation());
1656 }
1657 
1658 void LIR_Assembler::type_profile_helper(Register mdo,
1659                                         ciMethodData *md, ciProfileData *data,
1660                                         Register recv, Label* update_done) {
1661   for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1662     Label next_test;
1663     // See if the receiver is receiver[n].
1664     __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
1665     __ jccb(Assembler::notEqual, next_test);
1666     Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
1667     __ addptr(data_addr, DataLayout::counter_increment);
1668     __ jmp(*update_done);
1669     __ bind(next_test);
1670   }

3058 void LIR_Assembler::store_parameter(Metadata* m,  int offset_from_rsp_in_words) {
3059   assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
3060   int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3061   assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
3062   __ mov_metadata(Address(rsp, offset_from_rsp_in_bytes), m);
3063 }
3064 
3065 
3066 // This code replaces a call to arraycopy; no exception may
3067 // be thrown in this code, they must be thrown in the System.arraycopy
3068 // activation frame; we could save some checks if this would not be the case
3069 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
3070   ciArrayKlass* default_type = op->expected_type();
3071   Register src = op->src()->as_register();
3072   Register dst = op->dst()->as_register();
3073   Register src_pos = op->src_pos()->as_register();
3074   Register dst_pos = op->dst_pos()->as_register();
3075   Register length  = op->length()->as_register();
3076   Register tmp = op->tmp()->as_register();
3077   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);

3078 
3079   CodeStub* stub = op->stub();
3080   int flags = op->flags();
3081   BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
3082   if (is_reference_type(basic_type)) basic_type = T_OBJECT;
3083 
3084   // if we don't know anything, just go through the generic arraycopy
3085   if (default_type == NULL) {
3086     // save outgoing arguments on stack in case call to System.arraycopy is needed
3087     // HACK ALERT. This code used to push the parameters in a hardwired fashion
3088     // for interpreter calling conventions. Now we have to do it in new style conventions.
3089     // For the moment until C1 gets the new register allocator I just force all the
3090     // args to the right place (except the register args) and then on the back side
3091     // reload the register args properly if we go slow path. Yuck
3092 
3093     // These are proper for the calling convention
3094     store_parameter(length, 2);
3095     store_parameter(dst_pos, 1);
3096     store_parameter(dst, 0);
3097 

3182   switch (elem_size) {
3183     case 1 :
3184       scale = Address::times_1;
3185       break;
3186     case 2 :
3187       scale = Address::times_2;
3188       break;
3189     case 4 :
3190       scale = Address::times_4;
3191       break;
3192     case 8 :
3193       scale = Address::times_8;
3194       break;
3195     default:
3196       scale = Address::no_scale;
3197       ShouldNotReachHere();
3198   }
3199 
3200   Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
3201   Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());

3202   Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
3203   Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
3204 
3205   // length and pos's are all sign extended at this point on 64bit
3206 
3207   // test for NULL
3208   if (flags & LIR_OpArrayCopy::src_null_check) {
3209     __ testptr(src, src);
3210     __ jcc(Assembler::zero, *stub->entry());
3211   }
3212   if (flags & LIR_OpArrayCopy::dst_null_check) {
3213     __ testptr(dst, dst);
3214     __ jcc(Assembler::zero, *stub->entry());
3215   }
3216 
3217   // If the compiler was not able to prove that exact type of the source or the destination
3218   // of the arraycopy is an array type, check at runtime if the source or the destination is
3219   // an instance type.
3220   if (flags & LIR_OpArrayCopy::type_check) {
3221     if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
3222       __ load_klass(tmp, dst, tmp_load_klass);
3223       __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value);
3224       __ jcc(Assembler::greaterEqual, *stub->entry());

3249   if (flags & LIR_OpArrayCopy::dst_range_check) {
3250     __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
3251     __ cmpl(tmp, dst_length_addr);
3252     __ jcc(Assembler::above, *stub->entry());
3253   }
3254 
3255   if (flags & LIR_OpArrayCopy::length_positive_check) {
3256     __ testl(length, length);
3257     __ jcc(Assembler::less, *stub->entry());
3258   }
3259 
3260 #ifdef _LP64
3261   __ movl2ptr(src_pos, src_pos); //higher 32bits must be null
3262   __ movl2ptr(dst_pos, dst_pos); //higher 32bits must be null
3263 #endif
3264 
3265   if (flags & LIR_OpArrayCopy::type_check) {
3266     // We don't know the array types are compatible
3267     if (basic_type != T_OBJECT) {
3268       // Simple test for basic type arrays
3269       if (UseCompressedClassPointers) {
3270         __ movl(tmp, src_klass_addr);
3271         __ cmpl(tmp, dst_klass_addr);
3272       } else {
3273         __ movptr(tmp, src_klass_addr);
3274         __ cmpptr(tmp, dst_klass_addr);
3275       }

3276       __ jcc(Assembler::notEqual, *stub->entry());
3277     } else {
3278       // For object arrays, if src is a sub class of dst then we can
3279       // safely do the copy.
3280       Label cont, slow;
3281 
3282       __ push(src);
3283       __ push(dst);
3284 
3285       __ load_klass(src, src, tmp_load_klass);
3286       __ load_klass(dst, dst, tmp_load_klass);
3287 
3288       __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
3289 
3290       __ push(src);
3291       __ push(dst);
3292       __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
3293       __ pop(dst);
3294       __ pop(src);
3295 

3411       __ jmp(*stub->entry());
3412 
3413       __ bind(cont);
3414       __ pop(dst);
3415       __ pop(src);
3416     }
3417   }
3418 
3419 #ifdef ASSERT
3420   if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
3421     // Sanity check the known type with the incoming class.  For the
3422     // primitive case the types must match exactly with src.klass and
3423     // dst.klass each exactly matching the default type.  For the
3424     // object array case, if no type check is needed then either the
3425     // dst type is exactly the expected type and the src type is a
3426     // subtype which we can't check or src is the same array as dst
3427     // but not necessarily exactly of type default_type.
3428     Label known_ok, halt;
3429     __ mov_metadata(tmp, default_type->constant_encoding());
3430 #ifdef _LP64
3431     if (UseCompressedClassPointers) {
3432       __ encode_klass_not_null(tmp, rscratch1);
3433     }
3434 #endif
3435 
3436     if (basic_type != T_OBJECT) {
3437 
3438       if (UseCompressedClassPointers)          __ cmpl(tmp, dst_klass_addr);
3439       else                   __ cmpptr(tmp, dst_klass_addr);









3440       __ jcc(Assembler::notEqual, halt);
3441       if (UseCompressedClassPointers)          __ cmpl(tmp, src_klass_addr);
3442       else                   __ cmpptr(tmp, src_klass_addr);
3443       __ jcc(Assembler::equal, known_ok);
3444     } else {
3445       if (UseCompressedClassPointers)          __ cmpl(tmp, dst_klass_addr);
3446       else                   __ cmpptr(tmp, dst_klass_addr);
3447       __ jcc(Assembler::equal, known_ok);
3448       __ cmpptr(src, dst);
3449       __ jcc(Assembler::equal, known_ok);
3450     }
3451     __ bind(halt);
3452     __ stop("incorrect type information in arraycopy");
3453     __ bind(known_ok);
3454   }
3455 #endif
3456 
3457 #ifndef PRODUCT
3458   if (PrintC1Statistics) {
3459     __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
3460   }
3461 #endif
3462 
3463 #ifdef _LP64
3464   assert_different_registers(c_rarg0, dst, dst_pos, length);
3465   __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
3466   assert_different_registers(c_rarg1, length);

3511     assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
3512     // add debug info for NullPointerException only if one is possible
3513     int null_check_offset = __ lock_object(hdr, obj, lock, *op->stub()->entry());
3514     if (op->info() != NULL) {
3515       add_debug_info_for_null_check(null_check_offset, op->info());
3516     }
3517     // done
3518   } else if (op->code() == lir_unlock) {
3519     assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
3520     __ unlock_object(hdr, obj, lock, *op->stub()->entry());
3521   } else {
3522     Unimplemented();
3523   }
3524   __ bind(*op->stub()->continuation());
3525 }
3526 
3527 void LIR_Assembler::emit_load_klass(LIR_OpLoadKlass* op) {
3528   Register obj = op->obj()->as_pointer_register();
3529   Register result = op->result_opr()->as_pointer_register();
3530 
3531   CodeEmitInfo* info = op->info();
3532   if (info != NULL) {
3533     add_debug_info_for_null_check_here(info);
3534   }
3535 
3536 #ifdef _LP64
3537   if (UseCompressedClassPointers) {
3538     __ movl(result, Address(obj, oopDesc::klass_offset_in_bytes()));
3539     __ decode_klass_not_null(result, rscratch1);
3540   } else
















3541 #endif
3542     __ movptr(result, Address(obj, oopDesc::klass_offset_in_bytes()));
3543 }
3544 
3545 void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
3546   ciMethod* method = op->profiled_method();
3547   int bci          = op->profiled_bci();
3548   ciMethod* callee = op->profiled_callee();
3549   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
3550 
3551   // Update counter for all call types
3552   ciMethodData* md = method->method_data_or_null();
3553   assert(md != NULL, "Sanity");
3554   ciProfileData* data = md->bci_to_data(bci);
3555   assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
3556   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
3557   Register mdo  = op->mdo()->as_register();
3558   __ mov_metadata(mdo, md->constant_encoding());
3559   Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
3560   // Perform additional virtual call profiling for invokevirtual and
3561   // invokeinterface bytecodes
3562   if (op->should_profile_receiver_type()) {

3628 
3629   bool do_null = !not_null;
3630   bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
3631   bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
3632 
3633   assert(do_null || do_update, "why are we here?");
3634   assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
3635 
3636   __ verify_oop(obj);
3637 
3638   if (tmp != obj) {
3639     __ mov(tmp, obj);
3640   }
3641   if (do_null) {
3642     __ testptr(tmp, tmp);
3643     __ jccb(Assembler::notZero, update);
3644     if (!TypeEntries::was_null_seen(current_klass)) {
3645       __ orptr(mdo_addr, TypeEntries::null_seen);
3646     }
3647     if (do_update) {
3648 #ifndef ASSERT
3649       __ jmpb(next);
3650     }
3651 #else
3652       __ jmp(next);
3653     }

3654   } else {
3655     __ testptr(tmp, tmp);
3656     __ jcc(Assembler::notZero, update);
3657     __ stop("unexpected null obj");
3658 #endif
3659   }
3660 
3661   __ bind(update);
3662 
3663   if (do_update) {
3664 #ifdef ASSERT
3665     if (exact_klass != NULL) {
3666       Label ok;
3667       __ load_klass(tmp, tmp, tmp_load_klass);
3668       __ push(tmp);
3669       __ mov_metadata(tmp, exact_klass->constant_encoding());
3670       __ cmpptr(tmp, Address(rsp, 0));
3671       __ jcc(Assembler::equal, ok);
3672       __ stop("exact klass and actual klass differ");
3673       __ bind(ok);

1630       (!UseFastNewObjectArray && is_reference_type(op->type())) ||
1631       (!UseFastNewTypeArray   && !is_reference_type(op->type()))) {
1632     __ jmp(*op->stub()->entry());
1633   } else {
1634     Register tmp1 = op->tmp1()->as_register();
1635     Register tmp2 = op->tmp2()->as_register();
1636     Register tmp3 = op->tmp3()->as_register();
1637     if (len == tmp1) {
1638       tmp1 = tmp3;
1639     } else if (len == tmp2) {
1640       tmp2 = tmp3;
1641     } else if (len == tmp3) {
1642       // everything is ok
1643     } else {
1644       __ mov(tmp3, len);
1645     }
1646     __ allocate_array(op->obj()->as_register(),
1647                       len,
1648                       tmp1,
1649                       tmp2,
1650                       arrayOopDesc::base_offset_in_bytes(op->type()),
1651                       array_element_size(op->type()),
1652                       op->klass()->as_register(),
1653                       *op->stub()->entry());
1654   }
1655   __ bind(*op->stub()->continuation());
1656 }
1657 
1658 void LIR_Assembler::type_profile_helper(Register mdo,
1659                                         ciMethodData *md, ciProfileData *data,
1660                                         Register recv, Label* update_done) {
1661   for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1662     Label next_test;
1663     // See if the receiver is receiver[n].
1664     __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
1665     __ jccb(Assembler::notEqual, next_test);
1666     Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
1667     __ addptr(data_addr, DataLayout::counter_increment);
1668     __ jmp(*update_done);
1669     __ bind(next_test);
1670   }

3058 void LIR_Assembler::store_parameter(Metadata* m,  int offset_from_rsp_in_words) {
3059   assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
3060   int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3061   assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
3062   __ mov_metadata(Address(rsp, offset_from_rsp_in_bytes), m);
3063 }
3064 
3065 
3066 // This code replaces a call to arraycopy; no exception may
3067 // be thrown in this code, they must be thrown in the System.arraycopy
3068 // activation frame; we could save some checks if this would not be the case
3069 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
3070   ciArrayKlass* default_type = op->expected_type();
3071   Register src = op->src()->as_register();
3072   Register dst = op->dst()->as_register();
3073   Register src_pos = op->src_pos()->as_register();
3074   Register dst_pos = op->dst_pos()->as_register();
3075   Register length  = op->length()->as_register();
3076   Register tmp = op->tmp()->as_register();
3077   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
3078   Register tmp2 = LP64_ONLY(rscratch2) NOT_LP64(noreg);
3079 
3080   CodeStub* stub = op->stub();
3081   int flags = op->flags();
3082   BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
3083   if (is_reference_type(basic_type)) basic_type = T_OBJECT;
3084 
3085   // if we don't know anything, just go through the generic arraycopy
3086   if (default_type == NULL) {
3087     // save outgoing arguments on stack in case call to System.arraycopy is needed
3088     // HACK ALERT. This code used to push the parameters in a hardwired fashion
3089     // for interpreter calling conventions. Now we have to do it in new style conventions.
3090     // For the moment until C1 gets the new register allocator I just force all the
3091     // args to the right place (except the register args) and then on the back side
3092     // reload the register args properly if we go slow path. Yuck
3093 
3094     // These are proper for the calling convention
3095     store_parameter(length, 2);
3096     store_parameter(dst_pos, 1);
3097     store_parameter(dst, 0);
3098 

3183   switch (elem_size) {
3184     case 1 :
3185       scale = Address::times_1;
3186       break;
3187     case 2 :
3188       scale = Address::times_2;
3189       break;
3190     case 4 :
3191       scale = Address::times_4;
3192       break;
3193     case 8 :
3194       scale = Address::times_8;
3195       break;
3196     default:
3197       scale = Address::no_scale;
3198       ShouldNotReachHere();
3199   }
3200 
3201   Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
3202   Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());
3203 #ifndef _LP64
3204   Address src_klass_addr = Address(src, oopDesc::klass_offset_in_bytes());
3205   Address dst_klass_addr = Address(dst, oopDesc::klass_offset_in_bytes());
3206 #endif
3207   // length and pos's are all sign extended at this point on 64bit
3208 
3209   // test for NULL
3210   if (flags & LIR_OpArrayCopy::src_null_check) {
3211     __ testptr(src, src);
3212     __ jcc(Assembler::zero, *stub->entry());
3213   }
3214   if (flags & LIR_OpArrayCopy::dst_null_check) {
3215     __ testptr(dst, dst);
3216     __ jcc(Assembler::zero, *stub->entry());
3217   }
3218 
3219   // If the compiler was not able to prove that exact type of the source or the destination
3220   // of the arraycopy is an array type, check at runtime if the source or the destination is
3221   // an instance type.
3222   if (flags & LIR_OpArrayCopy::type_check) {
3223     if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
3224       __ load_klass(tmp, dst, tmp_load_klass);
3225       __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value);
3226       __ jcc(Assembler::greaterEqual, *stub->entry());

3251   if (flags & LIR_OpArrayCopy::dst_range_check) {
3252     __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
3253     __ cmpl(tmp, dst_length_addr);
3254     __ jcc(Assembler::above, *stub->entry());
3255   }
3256 
3257   if (flags & LIR_OpArrayCopy::length_positive_check) {
3258     __ testl(length, length);
3259     __ jcc(Assembler::less, *stub->entry());
3260   }
3261 
3262 #ifdef _LP64
3263   __ movl2ptr(src_pos, src_pos); //higher 32bits must be null
3264   __ movl2ptr(dst_pos, dst_pos); //higher 32bits must be null
3265 #endif
3266 
3267   if (flags & LIR_OpArrayCopy::type_check) {
3268     // We don't know the array types are compatible
3269     if (basic_type != T_OBJECT) {
3270       // Simple test for basic type arrays
3271 #ifdef _LP64
3272       __ load_nklass(tmp, src);
3273       __ load_nklass(tmp2, dst);
3274       __ cmpl(tmp, tmp2);
3275 #else
3276       __ movptr(tmp, src_klass_addr);
3277       __ cmpptr(tmp, dst_klass_addr);
3278 #endif
3279       __ jcc(Assembler::notEqual, *stub->entry());
3280     } else {
3281       // For object arrays, if src is a sub class of dst then we can
3282       // safely do the copy.
3283       Label cont, slow;
3284 
3285       __ push(src);
3286       __ push(dst);
3287 
3288       __ load_klass(src, src, tmp_load_klass);
3289       __ load_klass(dst, dst, tmp_load_klass);
3290 
3291       __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
3292 
3293       __ push(src);
3294       __ push(dst);
3295       __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
3296       __ pop(dst);
3297       __ pop(src);
3298 

3414       __ jmp(*stub->entry());
3415 
3416       __ bind(cont);
3417       __ pop(dst);
3418       __ pop(src);
3419     }
3420   }
3421 
3422 #ifdef ASSERT
3423   if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
3424     // Sanity check the known type with the incoming class.  For the
3425     // primitive case the types must match exactly with src.klass and
3426     // dst.klass each exactly matching the default type.  For the
3427     // object array case, if no type check is needed then either the
3428     // dst type is exactly the expected type and the src type is a
3429     // subtype which we can't check or src is the same array as dst
3430     // but not necessarily exactly of type default_type.
3431     Label known_ok, halt;
3432     __ mov_metadata(tmp, default_type->constant_encoding());
3433 #ifdef _LP64
3434     assert(UseCompressedClassPointers, "Lilliput");
3435     __ encode_klass_not_null(tmp, rscratch1);



3436     if (basic_type != T_OBJECT) {
3437       __ load_nklass(tmp2, dst);
3438       __ cmpl(tmp, tmp2);
3439       __ jcc(Assembler::notEqual, halt);
3440       __ load_nklass(tmp2, src);
3441       __ cmpl(tmp, tmp2);
3442       __ jcc(Assembler::equal, known_ok);
3443     } else {
3444       __ load_nklass(tmp2, dst);
3445       __ cmpl(tmp, tmp2);
3446 #else
3447     if (basic_type != T_OBJECT) {
3448       __ cmpptr(tmp, dst_klass_addr);
3449       __ jcc(Assembler::notEqual, halt);
3450       __ cmpptr(tmp, src_klass_addr);

3451       __ jcc(Assembler::equal, known_ok);
3452     } else {
3453       __ cmpptr(tmp, dst_klass_addr);
3454 #endif
3455       __ jcc(Assembler::equal, known_ok);
3456       __ cmpptr(src, dst);
3457       __ jcc(Assembler::equal, known_ok);
3458     }
3459     __ bind(halt);
3460     __ stop("incorrect type information in arraycopy");
3461     __ bind(known_ok);
3462   }
3463 #endif
3464 
3465 #ifndef PRODUCT
3466   if (PrintC1Statistics) {
3467     __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
3468   }
3469 #endif
3470 
3471 #ifdef _LP64
3472   assert_different_registers(c_rarg0, dst, dst_pos, length);
3473   __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
3474   assert_different_registers(c_rarg1, length);

3519     assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
3520     // add debug info for NullPointerException only if one is possible
3521     int null_check_offset = __ lock_object(hdr, obj, lock, *op->stub()->entry());
3522     if (op->info() != NULL) {
3523       add_debug_info_for_null_check(null_check_offset, op->info());
3524     }
3525     // done
3526   } else if (op->code() == lir_unlock) {
3527     assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
3528     __ unlock_object(hdr, obj, lock, *op->stub()->entry());
3529   } else {
3530     Unimplemented();
3531   }
3532   __ bind(*op->stub()->continuation());
3533 }
3534 
3535 void LIR_Assembler::emit_load_klass(LIR_OpLoadKlass* op) {
3536   Register obj = op->obj()->as_pointer_register();
3537   Register result = op->result_opr()->as_pointer_register();
3538 
3539   if (op->info() != NULL) {
3540     add_debug_info_for_null_check_here(op->info());

3541   }

3542 #ifdef _LP64
3543   Register tmp = rscratch1;
3544   assert_different_registers(tmp, obj);
3545   assert_different_registers(tmp, result);
3546 
3547   // Check if we can take the (common) fast path, if obj is unlocked.
3548   __ movq(tmp, Address(obj, oopDesc::mark_offset_in_bytes()));
3549   __ xorq(tmp, markWord::unlocked_value);
3550   __ testb(tmp, markWord::lock_mask_in_place);
3551   __ jcc(Assembler::notZero, *op->stub()->entry());
3552 
3553   // Fast-path: shift and decode Klass*.
3554   __ movq(result, tmp);
3555   __ shrq(result, markWord::klass_shift);
3556 
3557   __ bind(*op->stub()->continuation());
3558   __ decode_klass_not_null(result, tmp);
3559 #else
3560   __ movptr(result, Address(obj, oopDesc::klass_offset_in_bytes()));
3561   // Not really needed, but bind the label anyway to make compiler happy.
3562   __ bind(*op->stub()->continuation());
3563 #endif

3564 }
3565 
3566 void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
3567   ciMethod* method = op->profiled_method();
3568   int bci          = op->profiled_bci();
3569   ciMethod* callee = op->profiled_callee();
3570   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
3571 
3572   // Update counter for all call types
3573   ciMethodData* md = method->method_data_or_null();
3574   assert(md != NULL, "Sanity");
3575   ciProfileData* data = md->bci_to_data(bci);
3576   assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
3577   assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
3578   Register mdo  = op->mdo()->as_register();
3579   __ mov_metadata(mdo, md->constant_encoding());
3580   Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()));
3581   // Perform additional virtual call profiling for invokevirtual and
3582   // invokeinterface bytecodes
3583   if (op->should_profile_receiver_type()) {

3649 
3650   bool do_null = !not_null;
3651   bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
3652   bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
3653 
3654   assert(do_null || do_update, "why are we here?");
3655   assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
3656 
3657   __ verify_oop(obj);
3658 
3659   if (tmp != obj) {
3660     __ mov(tmp, obj);
3661   }
3662   if (do_null) {
3663     __ testptr(tmp, tmp);
3664     __ jccb(Assembler::notZero, update);
3665     if (!TypeEntries::was_null_seen(current_klass)) {
3666       __ orptr(mdo_addr, TypeEntries::null_seen);
3667     }
3668     if (do_update) {




3669       __ jmp(next);
3670     }
3671 #ifdef ASSERT
3672   } else {
3673     __ testptr(tmp, tmp);
3674     __ jcc(Assembler::notZero, update);
3675     __ stop("unexpected 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, tmp_load_klass);
3686       __ push(tmp);
3687       __ mov_metadata(tmp, exact_klass->constant_encoding());
3688       __ cmpptr(tmp, Address(rsp, 0));
3689       __ jcc(Assembler::equal, ok);
3690       __ stop("exact klass and actual klass differ");
3691       __ bind(ok);
< prev index next >