3070
3071
3072 void MacroAssembler::verify_tlab() {
3073 #ifdef ASSERT
3074 if (UseTLAB && VerifyOops) {
3075 Label next, next2, ok;
3076 Register t1 = L0;
3077 Register t2 = L1;
3078 Register t3 = L2;
3079
3080 save_frame(0);
3081 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
3082 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2);
3083 or3(t1, t2, t3);
3084 cmp_and_br_short(t1, t2, Assembler::greaterEqual, Assembler::pn, next);
3085 STOP("assert(top >= start)");
3086 should_not_reach_here();
3087
3088 bind(next);
3089 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
3090 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t2);
3091 or3(t3, t2, t3);
3092 cmp_and_br_short(t1, t2, Assembler::lessEqual, Assembler::pn, next2);
3093 STOP("assert(top <= end)");
3094 should_not_reach_here();
3095
3096 bind(next2);
3097 and3(t3, MinObjAlignmentInBytesMask, t3);
3098 cmp_and_br_short(t3, 0, Assembler::lessEqual, Assembler::pn, ok);
3099 STOP("assert(aligned)");
3100 should_not_reach_here();
3101
3102 bind(ok);
3103 restore();
3104 }
3105 #endif
3106 }
3107
3108
3109 void MacroAssembler::eden_allocate(
3110 Register obj, // result: pointer to object after successful allocation
3192
3193 void MacroAssembler::tlab_allocate(
3194 Register obj, // result: pointer to object after successful allocation
3195 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
3196 int con_size_in_bytes, // object size in bytes if known at compile time
3197 Register t1, // temp register
3198 Label& slow_case // continuation point if fast allocation fails
3199 ){
3200 // make sure arguments make sense
3201 assert_different_registers(obj, var_size_in_bytes, t1);
3202 assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size");
3203 assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
3204
3205 const Register free = t1;
3206
3207 verify_tlab();
3208
3209 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), obj);
3210
3211 // calculate amount of free space
3212 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), free);
3213 sub(free, obj, free);
3214
3215 Label done;
3216 if (var_size_in_bytes == noreg) {
3217 cmp(free, con_size_in_bytes);
3218 } else {
3219 cmp(free, var_size_in_bytes);
3220 }
3221 br(Assembler::less, false, Assembler::pn, slow_case);
3222 // calculate the new top pointer
3223 if (var_size_in_bytes == noreg) {
3224 delayed()->add(obj, con_size_in_bytes, free);
3225 } else {
3226 delayed()->add(obj, var_size_in_bytes, free);
3227 }
3228
3229 bind(done);
3230
3231 #ifdef ASSERT
3232 // make sure new free pointer is properly aligned
|
3070
3071
3072 void MacroAssembler::verify_tlab() {
3073 #ifdef ASSERT
3074 if (UseTLAB && VerifyOops) {
3075 Label next, next2, ok;
3076 Register t1 = L0;
3077 Register t2 = L1;
3078 Register t3 = L2;
3079
3080 save_frame(0);
3081 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
3082 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2);
3083 or3(t1, t2, t3);
3084 cmp_and_br_short(t1, t2, Assembler::greaterEqual, Assembler::pn, next);
3085 STOP("assert(top >= start)");
3086 should_not_reach_here();
3087
3088 bind(next);
3089 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
3090 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_current_end_offset()), t2);
3091 or3(t3, t2, t3);
3092 cmp_and_br_short(t1, t2, Assembler::lessEqual, Assembler::pn, next2);
3093 STOP("assert(top <= end)");
3094 should_not_reach_here();
3095
3096 bind(next2);
3097 and3(t3, MinObjAlignmentInBytesMask, t3);
3098 cmp_and_br_short(t3, 0, Assembler::lessEqual, Assembler::pn, ok);
3099 STOP("assert(aligned)");
3100 should_not_reach_here();
3101
3102 bind(ok);
3103 restore();
3104 }
3105 #endif
3106 }
3107
3108
3109 void MacroAssembler::eden_allocate(
3110 Register obj, // result: pointer to object after successful allocation
3192
3193 void MacroAssembler::tlab_allocate(
3194 Register obj, // result: pointer to object after successful allocation
3195 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
3196 int con_size_in_bytes, // object size in bytes if known at compile time
3197 Register t1, // temp register
3198 Label& slow_case // continuation point if fast allocation fails
3199 ){
3200 // make sure arguments make sense
3201 assert_different_registers(obj, var_size_in_bytes, t1);
3202 assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size");
3203 assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
3204
3205 const Register free = t1;
3206
3207 verify_tlab();
3208
3209 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), obj);
3210
3211 // calculate amount of free space
3212 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_current_end_offset()), free);
3213 sub(free, obj, free);
3214
3215 Label done;
3216 if (var_size_in_bytes == noreg) {
3217 cmp(free, con_size_in_bytes);
3218 } else {
3219 cmp(free, var_size_in_bytes);
3220 }
3221 br(Assembler::less, false, Assembler::pn, slow_case);
3222 // calculate the new top pointer
3223 if (var_size_in_bytes == noreg) {
3224 delayed()->add(obj, con_size_in_bytes, free);
3225 } else {
3226 delayed()->add(obj, var_size_in_bytes, free);
3227 }
3228
3229 bind(done);
3230
3231 #ifdef ASSERT
3232 // make sure new free pointer is properly aligned
|