< prev index next >

src/hotspot/cpu/x86/gc/shared/barrierSetAssembler_x86.cpp

Print this page
rev 57093 : 8230765: Implement nmethod barrier for x86_32 platforms
   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 310     __ get_thread(thread);
 311 #endif
 312   }
 313 
 314 #ifdef _LP64
 315   if (var_size_in_bytes->is_valid()) {
 316     __ addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
 317   } else {
 318     __ addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
 319   }
 320 #else
 321   if (var_size_in_bytes->is_valid()) {
 322     __ addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
 323   } else {
 324     __ addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
 325   }
 326   __ adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0);
 327 #endif
 328 }
 329 

 330 void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {
 331   BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
 332   if (bs_nm == NULL) {
 333     return;
 334   }
 335 #ifndef _LP64
 336   ShouldNotReachHere();
 337 #else
 338   Label continuation;
 339   Register thread = LP64_ONLY(r15_thread);
 340   Address disarmed_addr(thread, in_bytes(bs_nm->thread_disarmed_offset()));
 341   __ align(8);
 342   __ cmpl(disarmed_addr, 0);
 343   __ jcc(Assembler::equal, continuation);
 344   __ call(RuntimeAddress(StubRoutines::x86::method_entry_barrier()));
 345   __ bind(continuation);
 346 #endif
 347 }





















 348 
 349 void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler* masm) {
 350   BarrierSetNMethod* bs = BarrierSet::barrier_set()->barrier_set_nmethod();
 351   if (bs == NULL) {
 352     return;
 353   }
 354 
 355   Label bad_call;
 356   __ cmpptr(rbx, 0); // rbx contains the incoming method for c2i adapters.
 357   __ jcc(Assembler::equal, bad_call);
 358 
 359   // Pointer chase to the method holder to find out if the method is concurrently unloading.
 360   Label method_live;
 361   __ load_method_holder_cld(rscratch1, rbx);
 362 
 363   // Is it a strong CLD?
 364   __ movl(rscratch2, Address(rscratch1, ClassLoaderData::keep_alive_offset()));
 365   __ cmpptr(rscratch2, 0);
 366   __ jcc(Assembler::greater, method_live);
 367 
   1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 310     __ get_thread(thread);
 311 #endif
 312   }
 313 
 314 #ifdef _LP64
 315   if (var_size_in_bytes->is_valid()) {
 316     __ addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
 317   } else {
 318     __ addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
 319   }
 320 #else
 321   if (var_size_in_bytes->is_valid()) {
 322     __ addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
 323   } else {
 324     __ addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
 325   }
 326   __ adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0);
 327 #endif
 328 }
 329 
 330 #ifdef _LP64
 331 void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {
 332   BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
 333   if (bs_nm == NULL) {
 334     return;
 335   }



 336   Label continuation;
 337   Register thread = r15_thread;
 338   Address disarmed_addr(thread, in_bytes(bs_nm->thread_disarmed_offset()));
 339   __ align(8);
 340   __ cmpl(disarmed_addr, 0);
 341   __ jcc(Assembler::equal, continuation);
 342   __ call(RuntimeAddress(StubRoutines::x86::method_entry_barrier()));
 343   __ bind(continuation);

 344 }
 345 #else
 346 void BarrierSetAssembler::nmethod_entry_barrier(MacroAssembler* masm) {
 347   BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
 348   if (bs_nm == NULL) {
 349     return;
 350   }
 351 
 352   Label continuation;
 353 
 354   Register tmp = rdi;
 355   __ push(tmp);
 356   __ movptr(tmp, bs_nm->disarmed_value_address());
 357   Address disarmed_addr(tmp, 0);
 358   __ align(4);
 359   __ cmpl(disarmed_addr, 0);
 360   __ pop(tmp);
 361   __ jcc(Assembler::equal, continuation);
 362   __ call(RuntimeAddress(StubRoutines::x86::method_entry_barrier()));
 363   __ bind(continuation);
 364 }
 365 #endif
 366 
 367 void BarrierSetAssembler::c2i_entry_barrier(MacroAssembler* masm) {
 368   BarrierSetNMethod* bs = BarrierSet::barrier_set()->barrier_set_nmethod();
 369   if (bs == NULL) {
 370     return;
 371   }
 372 
 373   Label bad_call;
 374   __ cmpptr(rbx, 0); // rbx contains the incoming method for c2i adapters.
 375   __ jcc(Assembler::equal, bad_call);
 376 
 377   // Pointer chase to the method holder to find out if the method is concurrently unloading.
 378   Label method_live;
 379   __ load_method_holder_cld(rscratch1, rbx);
 380 
 381   // Is it a strong CLD?
 382   __ movl(rscratch2, Address(rscratch1, ClassLoaderData::keep_alive_offset()));
 383   __ cmpptr(rscratch2, 0);
 384   __ jcc(Assembler::greater, method_live);
 385 
< prev index next >