src/cpu/x86/vm/c1_MacroAssembler_x86.cpp

Print this page




   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  *
  23  */
  24 
  25 #include "incls/_precompiled.incl"
  26 #include "incls/_c1_MacroAssembler_x86.cpp.incl"










  27 
  28 int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Register scratch, Label& slow_case) {
  29   const int aligned_mask = BytesPerWord -1;
  30   const int hdr_offset = oopDesc::mark_offset_in_bytes();
  31   assert(hdr == rax, "hdr must be rax, for the cmpxchg instruction");
  32   assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
  33   Label done;
  34   int null_check_offset = -1;
  35 
  36   verify_oop(obj);
  37 
  38   // save object being locked into the BasicObjectLock
  39   movptr(Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()), obj);
  40 
  41   if (UseBiasedLocking) {
  42     assert(scratch != noreg, "should have scratch register at this point");
  43     null_check_offset = biased_locking_enter(disp_hdr, obj, hdr, scratch, false, done, &slow_case);
  44   } else {
  45     null_check_offset = offset();
  46   }




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_MacroAssembler.hpp"
  27 #include "c1/c1_Runtime1.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "gc_interface/collectedHeap.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "oops/arrayOop.hpp"
  32 #include "oops/markOop.hpp"
  33 #include "runtime/biasedLocking.hpp"
  34 #include "runtime/os.hpp"
  35 #include "runtime/stubRoutines.hpp"
  36 #include "runtime/synchronizer.hpp"
  37 
  38 int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Register scratch, Label& slow_case) {
  39   const int aligned_mask = BytesPerWord -1;
  40   const int hdr_offset = oopDesc::mark_offset_in_bytes();
  41   assert(hdr == rax, "hdr must be rax, for the cmpxchg instruction");
  42   assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
  43   Label done;
  44   int null_check_offset = -1;
  45 
  46   verify_oop(obj);
  47 
  48   // save object being locked into the BasicObjectLock
  49   movptr(Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()), obj);
  50 
  51   if (UseBiasedLocking) {
  52     assert(scratch != noreg, "should have scratch register at this point");
  53     null_check_offset = biased_locking_enter(disp_hdr, obj, hdr, scratch, false, done, &slow_case);
  54   } else {
  55     null_check_offset = offset();
  56   }