< prev index next >

src/hotspot/cpu/s390/c1_MacroAssembler_s390.cpp

Print this page
rev 57534 : 8236555: [s390] Fix VerifyOops
Reviewed-by:


  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "c1/c1_MacroAssembler.hpp"
  29 #include "c1/c1_Runtime1.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "oops/arrayOop.hpp"
  34 #include "oops/markWord.hpp"
  35 #include "runtime/basicLock.hpp"
  36 #include "runtime/biasedLocking.hpp"
  37 #include "runtime/os.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/stubRoutines.hpp"
  40 
  41 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
  42   Label ic_miss, ic_hit;
  43   verify_oop(receiver);
  44   int klass_offset = oopDesc::klass_offset_in_bytes();
  45 
  46   if (!ImplicitNullChecks || MacroAssembler::needs_explicit_null_check(klass_offset)) {
  47     if (VM_Version::has_CompareBranch()) {
  48       z_cgij(receiver, 0, Assembler::bcondEqual, ic_miss);
  49     } else {
  50       z_ltgr(receiver, receiver);
  51       z_bre(ic_miss);
  52     }
  53   }
  54 
  55   compare_klass_ptr(iCache, klass_offset, receiver, false);
  56   z_bre(ic_hit);
  57 
  58   // If icache check fails, then jump to runtime routine.
  59   // Note: RECEIVER must still contain the receiver!
  60   load_const_optimized(Z_R1_scratch, AddressLiteral(SharedRuntime::get_ic_miss_stub()));
  61   z_br(Z_R1_scratch);
  62   align(CodeEntryAlignment);
  63   bind(ic_hit);


  66 void C1_MacroAssembler::explicit_null_check(Register base) {
  67   ShouldNotCallThis(); // unused
  68 }
  69 
  70 void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
  71   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
  72   generate_stack_overflow_check(bang_size_in_bytes);
  73   save_return_pc();
  74   push_frame(frame_size_in_bytes);
  75 }
  76 
  77 void C1_MacroAssembler::verified_entry() {
  78   if (C1Breakpoint) z_illtrap(0xC1);
  79 }
  80 
  81 void C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
  82   const int hdr_offset = oopDesc::mark_offset_in_bytes();
  83   assert_different_registers(hdr, obj, disp_hdr);
  84   NearLabel done;
  85 
  86   verify_oop(obj);
  87 
  88   // Load object header.
  89   z_lg(hdr, Address(obj, hdr_offset));
  90 
  91   // Save object being locked into the BasicObjectLock...
  92   z_stg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
  93 
  94   if (UseBiasedLocking) {
  95     biased_locking_enter(obj, hdr, Z_R1_scratch, Z_R0_scratch, done, &slow_case);
  96   }
  97 
  98   // and mark it as unlocked.
  99   z_oill(hdr, markWord::unlocked_value);
 100   // Save unlocked object header into the displaced header location on the stack.
 101   z_stg(hdr, Address(disp_hdr, (intptr_t)0));
 102   // Test if object header is still the same (i.e. unlocked), and if so, store the
 103   // displaced header address in the object header. If it is not the same, get the
 104   // object header instead.
 105   z_csg(hdr, disp_hdr, hdr_offset, obj);
 106   // If the object header was the same, we're done.


 141 void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
 142   const int aligned_mask = BytesPerWord -1;
 143   const int hdr_offset = oopDesc::mark_offset_in_bytes();
 144   assert_different_registers(hdr, obj, disp_hdr);
 145   NearLabel done;
 146 
 147   if (UseBiasedLocking) {
 148     // Load object.
 149     z_lg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
 150     biased_locking_exit(obj, hdr, done);
 151   }
 152 
 153   // Load displaced header.
 154   z_ltg(hdr, Address(disp_hdr, (intptr_t)0));
 155   // If the loaded hdr is NULL we had recursive locking, and we are done.
 156   z_bre(done);
 157   if (!UseBiasedLocking) {
 158     // Load object.
 159     z_lg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
 160   }
 161   verify_oop(obj);
 162   // Test if object header is pointing to the displaced header, and if so, restore
 163   // the displaced header in the object. If the object header is not pointing to
 164   // the displaced header, get the object header instead.
 165   z_csg(disp_hdr, hdr, hdr_offset, obj);
 166   // If the object header was not pointing to the displaced header,
 167   // we do unlocking via runtime call.
 168   branch_optimized(Assembler::bcondNotEqual, slow_case);
 169   // done
 170   bind(done);
 171 }
 172 
 173 void C1_MacroAssembler::try_allocate(
 174   Register obj,                        // result: Pointer to object after successful allocation.
 175   Register var_size_in_bytes,          // Object size in bytes if unknown at compile time; invalid otherwise.
 176   int      con_size_in_bytes,          // Object size in bytes if   known at compile time.
 177   Register t1,                         // Temp register: Must be global register for incr_allocated_bytes.
 178   Label&   slow_case                   // Continuation point if fast allocation fails.
 179 ) {
 180   if (UseTLAB) {
 181     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);


 261   if (con_size_in_bytes <= threshold) {
 262     // Use explicit null stores.
 263     // code size = 6*n bytes (n = number of fields to clear)
 264     for (int i = hdr_size_in_bytes; i < con_size_in_bytes; i += BytesPerWord)
 265       z_stg(Rzero, Address(obj, i));
 266   } else {
 267     // Code size generated by initialize_body() is 16.
 268     Register object_fields = Z_R0_scratch;
 269     Register len_in_bytes  = Z_R1_scratch;
 270     z_la(object_fields, hdr_size_in_bytes, obj);
 271     load_const_optimized(len_in_bytes, con_size_in_bytes - hdr_size_in_bytes);
 272     initialize_body(object_fields, len_in_bytes, Rzero);
 273   }
 274 
 275   // Dtrace support is unimplemented.
 276   //  if (CURRENT_ENV->dtrace_alloc_probes()) {
 277   //    assert(obj == rax, "must be");
 278   //    call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
 279   //  }
 280 
 281   verify_oop(obj);
 282 }
 283 
 284 void C1_MacroAssembler::allocate_array(
 285   Register obj,                        // result: Pointer to array after successful allocation.
 286   Register len,                        // array length
 287   Register t1,                         // temp register
 288   Register t2,                         // temp register
 289   int      hdr_size,                   // object header size in words
 290   int      elt_size,                   // element size in bytes
 291   Register klass,                      // object klass
 292   Label&   slow_case                   // Continuation point if fast allocation fails.
 293 ) {
 294   assert_different_registers(obj, len, t1, t2, klass);
 295 
 296   // Determine alignment mask.
 297   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
 298 
 299   // Check for negative or excessive length.
 300   compareU64_and_branch(len, (int32_t)max_array_allocation_length, bcondHigh, slow_case);
 301 


 319 
 320   initialize_header(obj, klass, len, noreg, t1);
 321 
 322   // Clear rest of allocated space.
 323   Label done;
 324   Register object_fields = t1;
 325   Register Rzero = Z_R1_scratch;
 326   z_aghi(arr_size, -(hdr_size * BytesPerWord));
 327   z_bre(done); // Jump if size of fields is zero.
 328   z_la(object_fields, hdr_size * BytesPerWord, obj);
 329   z_xgr(Rzero, Rzero);
 330   initialize_body(object_fields, arr_size, Rzero);
 331   bind(done);
 332 
 333   // Dtrace support is unimplemented.
 334   // if (CURRENT_ENV->dtrace_alloc_probes()) {
 335   //   assert(obj == rax, "must be");
 336   //   call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
 337   // }
 338 
 339   verify_oop(obj);
 340 }
 341 
 342 
 343 #ifndef PRODUCT
 344 
 345 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
 346   Unimplemented();
 347   // if (!VerifyOops) return;
 348   // verify_oop_addr(Address(SP, stack_offset + STACK_BIAS));
 349 }
 350 
 351 void C1_MacroAssembler::verify_not_null_oop(Register r) {
 352   if (!VerifyOops) return;
 353   NearLabel not_null;
 354   compareU64_and_branch(r, (intptr_t)0, bcondNotEqual, not_null);
 355   stop("non-null oop required");
 356   bind(not_null);
 357   verify_oop(r);
 358 }
 359 
 360 void C1_MacroAssembler::invalidate_registers(Register preserve1,
 361                                              Register preserve2,
 362                                              Register preserve3) {
 363   Register dead_value = noreg;
 364   for (int i = 0; i < FrameMap::nof_cpu_regs; i++) {
 365     Register r = as_Register(i);
 366     if (r != preserve1 && r != preserve2 && r != preserve3 && r != Z_SP && r != Z_thread) {
 367       if (dead_value == noreg) {
 368         load_const_optimized(r, 0xc1dead);
 369         dead_value = r;
 370       } else {
 371         z_lgr(r, dead_value);
 372       }
 373     }
 374   }
 375 }
 376 
 377 #endif // !PRODUCT


  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "c1/c1_MacroAssembler.hpp"
  29 #include "c1/c1_Runtime1.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "oops/arrayOop.hpp"
  34 #include "oops/markWord.hpp"
  35 #include "runtime/basicLock.hpp"
  36 #include "runtime/biasedLocking.hpp"
  37 #include "runtime/os.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/stubRoutines.hpp"
  40 
  41 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
  42   Label ic_miss, ic_hit;
  43   verify_oop(receiver, FILE_AND_LINE);
  44   int klass_offset = oopDesc::klass_offset_in_bytes();
  45 
  46   if (!ImplicitNullChecks || MacroAssembler::needs_explicit_null_check(klass_offset)) {
  47     if (VM_Version::has_CompareBranch()) {
  48       z_cgij(receiver, 0, Assembler::bcondEqual, ic_miss);
  49     } else {
  50       z_ltgr(receiver, receiver);
  51       z_bre(ic_miss);
  52     }
  53   }
  54 
  55   compare_klass_ptr(iCache, klass_offset, receiver, false);
  56   z_bre(ic_hit);
  57 
  58   // If icache check fails, then jump to runtime routine.
  59   // Note: RECEIVER must still contain the receiver!
  60   load_const_optimized(Z_R1_scratch, AddressLiteral(SharedRuntime::get_ic_miss_stub()));
  61   z_br(Z_R1_scratch);
  62   align(CodeEntryAlignment);
  63   bind(ic_hit);


  66 void C1_MacroAssembler::explicit_null_check(Register base) {
  67   ShouldNotCallThis(); // unused
  68 }
  69 
  70 void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
  71   assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
  72   generate_stack_overflow_check(bang_size_in_bytes);
  73   save_return_pc();
  74   push_frame(frame_size_in_bytes);
  75 }
  76 
  77 void C1_MacroAssembler::verified_entry() {
  78   if (C1Breakpoint) z_illtrap(0xC1);
  79 }
  80 
  81 void C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
  82   const int hdr_offset = oopDesc::mark_offset_in_bytes();
  83   assert_different_registers(hdr, obj, disp_hdr);
  84   NearLabel done;
  85 
  86   verify_oop(obj, FILE_AND_LINE);
  87 
  88   // Load object header.
  89   z_lg(hdr, Address(obj, hdr_offset));
  90 
  91   // Save object being locked into the BasicObjectLock...
  92   z_stg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
  93 
  94   if (UseBiasedLocking) {
  95     biased_locking_enter(obj, hdr, Z_R1_scratch, Z_R0_scratch, done, &slow_case);
  96   }
  97 
  98   // and mark it as unlocked.
  99   z_oill(hdr, markWord::unlocked_value);
 100   // Save unlocked object header into the displaced header location on the stack.
 101   z_stg(hdr, Address(disp_hdr, (intptr_t)0));
 102   // Test if object header is still the same (i.e. unlocked), and if so, store the
 103   // displaced header address in the object header. If it is not the same, get the
 104   // object header instead.
 105   z_csg(hdr, disp_hdr, hdr_offset, obj);
 106   // If the object header was the same, we're done.


 141 void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
 142   const int aligned_mask = BytesPerWord -1;
 143   const int hdr_offset = oopDesc::mark_offset_in_bytes();
 144   assert_different_registers(hdr, obj, disp_hdr);
 145   NearLabel done;
 146 
 147   if (UseBiasedLocking) {
 148     // Load object.
 149     z_lg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
 150     biased_locking_exit(obj, hdr, done);
 151   }
 152 
 153   // Load displaced header.
 154   z_ltg(hdr, Address(disp_hdr, (intptr_t)0));
 155   // If the loaded hdr is NULL we had recursive locking, and we are done.
 156   z_bre(done);
 157   if (!UseBiasedLocking) {
 158     // Load object.
 159     z_lg(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
 160   }
 161   verify_oop(obj, FILE_AND_LINE);
 162   // Test if object header is pointing to the displaced header, and if so, restore
 163   // the displaced header in the object. If the object header is not pointing to
 164   // the displaced header, get the object header instead.
 165   z_csg(disp_hdr, hdr, hdr_offset, obj);
 166   // If the object header was not pointing to the displaced header,
 167   // we do unlocking via runtime call.
 168   branch_optimized(Assembler::bcondNotEqual, slow_case);
 169   // done
 170   bind(done);
 171 }
 172 
 173 void C1_MacroAssembler::try_allocate(
 174   Register obj,                        // result: Pointer to object after successful allocation.
 175   Register var_size_in_bytes,          // Object size in bytes if unknown at compile time; invalid otherwise.
 176   int      con_size_in_bytes,          // Object size in bytes if   known at compile time.
 177   Register t1,                         // Temp register: Must be global register for incr_allocated_bytes.
 178   Label&   slow_case                   // Continuation point if fast allocation fails.
 179 ) {
 180   if (UseTLAB) {
 181     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);


 261   if (con_size_in_bytes <= threshold) {
 262     // Use explicit null stores.
 263     // code size = 6*n bytes (n = number of fields to clear)
 264     for (int i = hdr_size_in_bytes; i < con_size_in_bytes; i += BytesPerWord)
 265       z_stg(Rzero, Address(obj, i));
 266   } else {
 267     // Code size generated by initialize_body() is 16.
 268     Register object_fields = Z_R0_scratch;
 269     Register len_in_bytes  = Z_R1_scratch;
 270     z_la(object_fields, hdr_size_in_bytes, obj);
 271     load_const_optimized(len_in_bytes, con_size_in_bytes - hdr_size_in_bytes);
 272     initialize_body(object_fields, len_in_bytes, Rzero);
 273   }
 274 
 275   // Dtrace support is unimplemented.
 276   //  if (CURRENT_ENV->dtrace_alloc_probes()) {
 277   //    assert(obj == rax, "must be");
 278   //    call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
 279   //  }
 280 
 281   verify_oop(obj, FILE_AND_LINE);
 282 }
 283 
 284 void C1_MacroAssembler::allocate_array(
 285   Register obj,                        // result: Pointer to array after successful allocation.
 286   Register len,                        // array length
 287   Register t1,                         // temp register
 288   Register t2,                         // temp register
 289   int      hdr_size,                   // object header size in words
 290   int      elt_size,                   // element size in bytes
 291   Register klass,                      // object klass
 292   Label&   slow_case                   // Continuation point if fast allocation fails.
 293 ) {
 294   assert_different_registers(obj, len, t1, t2, klass);
 295 
 296   // Determine alignment mask.
 297   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
 298 
 299   // Check for negative or excessive length.
 300   compareU64_and_branch(len, (int32_t)max_array_allocation_length, bcondHigh, slow_case);
 301 


 319 
 320   initialize_header(obj, klass, len, noreg, t1);
 321 
 322   // Clear rest of allocated space.
 323   Label done;
 324   Register object_fields = t1;
 325   Register Rzero = Z_R1_scratch;
 326   z_aghi(arr_size, -(hdr_size * BytesPerWord));
 327   z_bre(done); // Jump if size of fields is zero.
 328   z_la(object_fields, hdr_size * BytesPerWord, obj);
 329   z_xgr(Rzero, Rzero);
 330   initialize_body(object_fields, arr_size, Rzero);
 331   bind(done);
 332 
 333   // Dtrace support is unimplemented.
 334   // if (CURRENT_ENV->dtrace_alloc_probes()) {
 335   //   assert(obj == rax, "must be");
 336   //   call(RuntimeAddress(Runtime1::entry_for (Runtime1::dtrace_object_alloc_id)));
 337   // }
 338 
 339   verify_oop(obj, FILE_AND_LINE);
 340 }
 341 
 342 
 343 #ifndef PRODUCT
 344 
 345 void C1_MacroAssembler::verify_stack_oop(int stack_offset) {
 346   if (!VerifyOops) return;
 347   verify_oop_addr(Address(Z_SP, stack_offset), FILE_AND_LINE);

 348 }
 349 
 350 void C1_MacroAssembler::verify_not_null_oop(Register r) {
 351   if (!VerifyOops) return;
 352   NearLabel not_null;
 353   compareU64_and_branch(r, (intptr_t)0, bcondNotEqual, not_null);
 354   stop("non-null oop required");
 355   bind(not_null);
 356   verify_oop(r, FILE_AND_LINE);
 357 }
 358 
 359 void C1_MacroAssembler::invalidate_registers(Register preserve1,
 360                                              Register preserve2,
 361                                              Register preserve3) {
 362   Register dead_value = noreg;
 363   for (int i = 0; i < FrameMap::nof_cpu_regs; i++) {
 364     Register r = as_Register(i);
 365     if (r != preserve1 && r != preserve2 && r != preserve3 && r != Z_SP && r != Z_thread) {
 366       if (dead_value == noreg) {
 367         load_const_optimized(r, 0xc1dead);
 368         dead_value = r;
 369       } else {
 370         z_lgr(r, dead_value);
 371       }
 372     }
 373   }
 374 }
 375 
 376 #endif // !PRODUCT
< prev index next >