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