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