< prev index next >

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Print this page

1616       (!UseFastNewObjectArray && is_reference_type(op->type())) ||
1617       (!UseFastNewTypeArray   && !is_reference_type(op->type()))) {
1618     __ jmp(*op->stub()->entry());
1619   } else {
1620     Register tmp1 = op->tmp1()->as_register();
1621     Register tmp2 = op->tmp2()->as_register();
1622     Register tmp3 = op->tmp3()->as_register();
1623     if (len == tmp1) {
1624       tmp1 = tmp3;
1625     } else if (len == tmp2) {
1626       tmp2 = tmp3;
1627     } else if (len == tmp3) {
1628       // everything is ok
1629     } else {
1630       __ mov(tmp3, len);
1631     }
1632     __ allocate_array(op->obj()->as_register(),
1633                       len,
1634                       tmp1,
1635                       tmp2,
1636                       arrayOopDesc::header_size(op->type()),
1637                       array_element_size(op->type()),
1638                       op->klass()->as_register(),
1639                       *op->stub()->entry());
1640   }
1641   __ bind(*op->stub()->continuation());
1642 }
1643 
1644 void LIR_Assembler::type_profile_helper(Register mdo,
1645                                         ciMethodData *md, ciProfileData *data,
1646                                         Register recv, Label* update_done) {
1647   for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1648     Label next_test;
1649     // See if the receiver is receiver[n].
1650     __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
1651     __ jccb(Assembler::notEqual, next_test);
1652     Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
1653     __ addptr(data_addr, DataLayout::counter_increment);
1654     __ jmp(*update_done);
1655     __ bind(next_test);
1656   }

3046 void LIR_Assembler::store_parameter(Metadata* m,  int offset_from_rsp_in_words) {
3047   assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
3048   int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
3049   assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
3050   __ mov_metadata(Address(rsp, offset_from_rsp_in_bytes), m);
3051 }
3052 
3053 
3054 // This code replaces a call to arraycopy; no exception may
3055 // be thrown in this code, they must be thrown in the System.arraycopy
3056 // activation frame; we could save some checks if this would not be the case
3057 void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
3058   ciArrayKlass* default_type = op->expected_type();
3059   Register src = op->src()->as_register();
3060   Register dst = op->dst()->as_register();
3061   Register src_pos = op->src_pos()->as_register();
3062   Register dst_pos = op->dst_pos()->as_register();
3063   Register length  = op->length()->as_register();
3064   Register tmp = op->tmp()->as_register();
3065   Register tmp_load_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);

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

3170   switch (elem_size) {
3171     case 1 :
3172       scale = Address::times_1;
3173       break;
3174     case 2 :
3175       scale = Address::times_2;
3176       break;
3177     case 4 :
3178       scale = Address::times_4;
3179       break;
3180     case 8 :
3181       scale = Address::times_8;
3182       break;
3183     default:
3184       scale = Address::no_scale;
3185       ShouldNotReachHere();
3186   }
3187 
3188   Address src_length_addr = Address(src, arrayOopDesc::length_offset_in_bytes());
3189   Address dst_length_addr = Address(dst, arrayOopDesc::length_offset_in_bytes());

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

3237   if (flags & LIR_OpArrayCopy::dst_range_check) {
3238     __ lea(tmp, Address(dst_pos, length, Address::times_1, 0));
3239     __ cmpl(tmp, dst_length_addr);
3240     __ jcc(Assembler::above, *stub->entry());
3241   }
3242 
3243   if (flags & LIR_OpArrayCopy::length_positive_check) {
3244     __ testl(length, length);
3245     __ jcc(Assembler::less, *stub->entry());
3246   }
3247 
3248 #ifdef _LP64
3249   __ movl2ptr(src_pos, src_pos); //higher 32bits must be null
3250   __ movl2ptr(dst_pos, dst_pos); //higher 32bits must be null
3251 #endif
3252 
3253   if (flags & LIR_OpArrayCopy::type_check) {
3254     // We don't know the array types are compatible
3255     if (basic_type != T_OBJECT) {
3256       // Simple test for basic type arrays
3257       if (UseCompressedClassPointers) {
3258         __ movl(tmp, src_klass_addr);
3259         __ cmpl(tmp, dst_klass_addr);
3260       } else {
3261         __ movptr(tmp, src_klass_addr);
3262         __ cmpptr(tmp, dst_klass_addr);
3263       }

3264       __ jcc(Assembler::notEqual, *stub->entry());
3265     } else {
3266       // For object arrays, if src is a sub class of dst then we can
3267       // safely do the copy.
3268       Label cont, slow;
3269 
3270       __ push(src);
3271       __ push(dst);
3272 
3273       __ load_klass(src, src, tmp_load_klass);
3274       __ load_klass(dst, dst, tmp_load_klass);
3275 
3276       __ check_klass_subtype_fast_path(src, dst, tmp, &cont, &slow, NULL);
3277 
3278       __ push(src);
3279       __ push(dst);
3280       __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
3281       __ pop(dst);
3282       __ pop(src);
3283 

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









3428       __ jcc(Assembler::notEqual, halt);
3429       if (UseCompressedClassPointers)          __ cmpl(tmp, src_klass_addr);
3430       else                   __ cmpptr(tmp, src_klass_addr);
3431       __ jcc(Assembler::equal, known_ok);
3432     } else {
3433       if (UseCompressedClassPointers)          __ cmpl(tmp, dst_klass_addr);
3434       else                   __ cmpptr(tmp, dst_klass_addr);
3435       __ jcc(Assembler::equal, known_ok);
3436       __ cmpptr(src, dst);
3437       __ jcc(Assembler::equal, known_ok);
3438     }
3439     __ bind(halt);
3440     __ stop("incorrect type information in arraycopy");
3441     __ bind(known_ok);
3442   }
3443 #endif
3444 
3445 #ifndef PRODUCT
3446   if (PrintC1Statistics) {
3447     __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
3448   }
3449 #endif
3450 
3451 #ifdef _LP64
3452   assert_different_registers(c_rarg0, dst, dst_pos, length);
3453   __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
3454   assert_different_registers(c_rarg1, length);

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
















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

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

3646   } else {
3647     __ testptr(tmp, tmp);
3648     __ jcc(Assembler::notZero, update);
3649     __ stop("unexpected null obj");
3650 #endif
3651   }
3652 
3653   __ bind(update);
3654 
3655   if (do_update) {
3656 #ifdef ASSERT
3657     if (exact_klass != NULL) {
3658       Label ok;
3659       __ load_klass(tmp, tmp, tmp_load_klass);
3660       __ push(tmp);
3661       __ mov_metadata(tmp, exact_klass->constant_encoding());
3662       __ cmpptr(tmp, Address(rsp, 0));
3663       __ jcc(Assembler::equal, ok);
3664       __ stop("exact klass and actual klass differ");
3665       __ bind(ok);

1616       (!UseFastNewObjectArray && is_reference_type(op->type())) ||
1617       (!UseFastNewTypeArray   && !is_reference_type(op->type()))) {
1618     __ jmp(*op->stub()->entry());
1619   } else {
1620     Register tmp1 = op->tmp1()->as_register();
1621     Register tmp2 = op->tmp2()->as_register();
1622     Register tmp3 = op->tmp3()->as_register();
1623     if (len == tmp1) {
1624       tmp1 = tmp3;
1625     } else if (len == tmp2) {
1626       tmp2 = tmp3;
1627     } else if (len == tmp3) {
1628       // everything is ok
1629     } else {
1630       __ mov(tmp3, len);
1631     }
1632     __ allocate_array(op->obj()->as_register(),
1633                       len,
1634                       tmp1,
1635                       tmp2,
1636                       arrayOopDesc::base_offset_in_bytes(op->type()),
1637                       array_element_size(op->type()),
1638                       op->klass()->as_register(),
1639                       *op->stub()->entry());
1640   }
1641   __ bind(*op->stub()->continuation());
1642 }
1643 
1644 void LIR_Assembler::type_profile_helper(Register mdo,
1645                                         ciMethodData *md, ciProfileData *data,
1646                                         Register recv, Label* update_done) {
1647   for (uint i = 0; i < ReceiverTypeData::row_limit(); i++) {
1648     Label next_test;
1649     // See if the receiver is receiver[n].
1650     __ cmpptr(recv, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i))));
1651     __ jccb(Assembler::notEqual, next_test);
1652     Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)));
1653     __ addptr(data_addr, DataLayout::counter_increment);
1654     __ jmp(*update_done);
1655     __ bind(next_test);
1656   }

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

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

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

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



3424     if (basic_type != T_OBJECT) {
3425       __ load_nklass(tmp2, dst);
3426       __ cmpl(tmp, tmp2);
3427       __ jcc(Assembler::notEqual, halt);
3428       __ load_nklass(tmp2, src);
3429       __ cmpl(tmp, tmp2);
3430       __ jcc(Assembler::equal, known_ok);
3431     } else {
3432       __ load_nklass(tmp2, dst);
3433       __ cmpl(tmp, tmp2);
3434 #else
3435     if (basic_type != T_OBJECT) {
3436       __ cmpptr(tmp, dst_klass_addr);
3437       __ jcc(Assembler::notEqual, halt);
3438       __ cmpptr(tmp, src_klass_addr);

3439       __ jcc(Assembler::equal, known_ok);
3440     } else {
3441       __ cmpptr(tmp, dst_klass_addr);
3442 #endif
3443       __ jcc(Assembler::equal, known_ok);
3444       __ cmpptr(src, dst);
3445       __ jcc(Assembler::equal, known_ok);
3446     }
3447     __ bind(halt);
3448     __ stop("incorrect type information in arraycopy");
3449     __ bind(known_ok);
3450   }
3451 #endif
3452 
3453 #ifndef PRODUCT
3454   if (PrintC1Statistics) {
3455     __ incrementl(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)));
3456   }
3457 #endif
3458 
3459 #ifdef _LP64
3460   assert_different_registers(c_rarg0, dst, dst_pos, length);
3461   __ lea(c_rarg0, Address(src, src_pos, scale, arrayOopDesc::base_offset_in_bytes(basic_type)));
3462   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   if (op->info() != NULL) {
3532     add_debug_info_for_null_check_here(op->info());

3533   }

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

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

3641 
3642   bool do_null = !not_null;
3643   bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
3644   bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
3645 
3646   assert(do_null || do_update, "why are we here?");
3647   assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
3648 
3649   __ verify_oop(obj);
3650 
3651   if (tmp != obj) {
3652     __ mov(tmp, obj);
3653   }
3654   if (do_null) {
3655     __ testptr(tmp, tmp);
3656     __ jccb(Assembler::notZero, update);
3657     if (!TypeEntries::was_null_seen(current_klass)) {
3658       __ orptr(mdo_addr, TypeEntries::null_seen);
3659     }
3660     if (do_update) {




3661       __ jmp(next);
3662     }
3663 #ifdef ASSERT
3664   } else {
3665     __ testptr(tmp, tmp);
3666     __ jcc(Assembler::notZero, update);
3667     __ stop("unexpected null obj");
3668 #endif
3669   }
3670 
3671   __ bind(update);
3672 
3673   if (do_update) {
3674 #ifdef ASSERT
3675     if (exact_klass != NULL) {
3676       Label ok;
3677       __ load_klass(tmp, tmp, tmp_load_klass);
3678       __ push(tmp);
3679       __ mov_metadata(tmp, exact_klass->constant_encoding());
3680       __ cmpptr(tmp, Address(rsp, 0));
3681       __ jcc(Assembler::equal, ok);
3682       __ stop("exact klass and actual klass differ");
3683       __ bind(ok);
< prev index next >