hotspot/src/cpu/x86/vm/x86_32.ad
changeset 6418 6671edbd230e
parent 6272 94a20ad0e9de
child 7115 32300e243300
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Mon Aug 23 09:09:36 2010 -0700
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Wed Aug 25 05:27:54 2010 -0700
@@ -350,54 +350,46 @@
 // EMIT_RM()
 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) {
   unsigned char c = (unsigned char)((f1 << 6) | (f2 << 3) | f3);
-  *(cbuf.code_end()) = c;
-  cbuf.set_code_end(cbuf.code_end() + 1);
+  cbuf.insts()->emit_int8(c);
 }
 
 // EMIT_CC()
 void emit_cc(CodeBuffer &cbuf, int f1, int f2) {
   unsigned char c = (unsigned char)( f1 | f2 );
-  *(cbuf.code_end()) = c;
-  cbuf.set_code_end(cbuf.code_end() + 1);
+  cbuf.insts()->emit_int8(c);
 }
 
 // EMIT_OPCODE()
 void emit_opcode(CodeBuffer &cbuf, int code) {
-  *(cbuf.code_end()) = (unsigned char)code;
-  cbuf.set_code_end(cbuf.code_end() + 1);
+  cbuf.insts()->emit_int8((unsigned char) code);
 }
 
 // EMIT_OPCODE() w/ relocation information
 void emit_opcode(CodeBuffer &cbuf, int code, relocInfo::relocType reloc, int offset = 0) {
-  cbuf.relocate(cbuf.inst_mark() + offset, reloc);
+  cbuf.relocate(cbuf.insts_mark() + offset, reloc);
   emit_opcode(cbuf, code);
 }
 
 // EMIT_D8()
 void emit_d8(CodeBuffer &cbuf, int d8) {
-  *(cbuf.code_end()) = (unsigned char)d8;
-  cbuf.set_code_end(cbuf.code_end() + 1);
+  cbuf.insts()->emit_int8((unsigned char) d8);
 }
 
 // EMIT_D16()
 void emit_d16(CodeBuffer &cbuf, int d16) {
-  *((short *)(cbuf.code_end())) = d16;
-  cbuf.set_code_end(cbuf.code_end() + 2);
+  cbuf.insts()->emit_int16(d16);
 }
 
 // EMIT_D32()
 void emit_d32(CodeBuffer &cbuf, int d32) {
-  *((int *)(cbuf.code_end())) = d32;
-  cbuf.set_code_end(cbuf.code_end() + 4);
+  cbuf.insts()->emit_int32(d32);
 }
 
 // emit 32 bit value and construct relocation entry from relocInfo::relocType
 void emit_d32_reloc(CodeBuffer &cbuf, int d32, relocInfo::relocType reloc,
         int format) {
-  cbuf.relocate(cbuf.inst_mark(), reloc, format);
-
-  *((int *)(cbuf.code_end())) = d32;
-  cbuf.set_code_end(cbuf.code_end() + 4);
+  cbuf.relocate(cbuf.insts_mark(), reloc, format);
+  cbuf.insts()->emit_int32(d32);
 }
 
 // emit 32 bit value and construct relocation entry from RelocationHolder
@@ -408,10 +400,8 @@
     assert(oop(d32)->is_oop() && (ScavengeRootsInCode || !oop(d32)->is_scavengable()), "cannot embed scavengable oops in code");
   }
 #endif
-  cbuf.relocate(cbuf.inst_mark(), rspec, format);
-
-  *((int *)(cbuf.code_end())) = d32;
-  cbuf.set_code_end(cbuf.code_end() + 4);
+  cbuf.relocate(cbuf.insts_mark(), rspec, format);
+  cbuf.insts()->emit_int32(d32);
 }
 
 // Access stack slot for load or store
@@ -613,7 +603,7 @@
     emit_rm(cbuf, 0x3, 0x05, ESP_enc);
     emit_d32(cbuf, framesize);
   }
-  C->set_frame_complete(cbuf.code_end() - cbuf.code_begin());
+  C->set_frame_complete(cbuf.insts_size());
 
 #ifdef ASSERT
   if (VerifyStackAtCalls) {
@@ -695,7 +685,7 @@
   emit_opcode(cbuf, 0x58 | EBP_enc);
 
   if( do_polling() && C->is_method_compilation() ) {
-    cbuf.relocate(cbuf.code_end(), relocInfo::poll_return_type, 0);
+    cbuf.relocate(cbuf.insts_end(), relocInfo::poll_return_type, 0);
     emit_opcode(cbuf,0x85);
     emit_rm(cbuf, 0x0, EAX_enc, 0x5); // EAX
     emit_d32(cbuf, (intptr_t)os::get_polling_page());
@@ -1211,9 +1201,9 @@
   // mov rbx,0
   // jmp -1
 
-  address mark = cbuf.inst_mark();  // get mark within main instrs section
-
-  // Note that the code buffer's inst_mark is always relative to insts.
+  address mark = cbuf.insts_mark();  // get mark within main instrs section
+
+  // Note that the code buffer's insts_mark is always relative to insts.
   // That's why we must use the macroassembler to generate a stub.
   MacroAssembler _masm(&cbuf);
 
@@ -1228,7 +1218,7 @@
   __ jump(RuntimeAddress(__ pc()));
 
   __ end_a_stub();
-  // Update current stubs pointer and restore code_end.
+  // Update current stubs pointer and restore insts_end.
 }
 // size of call stub, compiled java to interpretor
 uint size_java_to_interp() {
@@ -1254,7 +1244,7 @@
 void MachUEPNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
   MacroAssembler masm(&cbuf);
 #ifdef ASSERT
-  uint code_size = cbuf.code_size();
+  uint insts_size = cbuf.insts_size();
 #endif
   masm.cmpptr(rax, Address(rcx, oopDesc::klass_offset_in_bytes()));
   masm.jump_cc(Assembler::notEqual,
@@ -1266,7 +1256,7 @@
      nops_cnt += 1;
   masm.nop(nops_cnt);
 
-  assert(cbuf.code_size() - code_size == size(ra_), "checking code size of inline cache node");
+  assert(cbuf.insts_size() - insts_size == size(ra_), "checking code size of inline cache node");
 }
 
 uint MachUEPNode::size(PhaseRegAlloc *ra_) const {
@@ -1288,14 +1278,14 @@
 // and call a VM stub routine.
 int emit_exception_handler(CodeBuffer& cbuf) {
 
-  // Note that the code buffer's inst_mark is always relative to insts.
+  // Note that the code buffer's insts_mark is always relative to insts.
   // That's why we must use the macroassembler to generate a handler.
   MacroAssembler _masm(&cbuf);
   address base =
   __ start_a_stub(size_exception_handler());
   if (base == NULL)  return 0;  // CodeBuffer::expand failed
   int offset = __ offset();
-  __ jump(RuntimeAddress(OptoRuntime::exception_blob()->instructions_begin()));
+  __ jump(RuntimeAddress(OptoRuntime::exception_blob()->entry_point()));
   assert(__ offset() - offset <= (int) size_exception_handler(), "overflow");
   __ end_a_stub();
   return offset;
@@ -1313,7 +1303,7 @@
 // Emit deopt handler code.
 int emit_deopt_handler(CodeBuffer& cbuf) {
 
-  // Note that the code buffer's inst_mark is always relative to insts.
+  // Note that the code buffer's insts_mark is always relative to insts.
   // That's why we must use the macroassembler to generate a handler.
   MacroAssembler _masm(&cbuf);
   address base =
@@ -1728,12 +1718,12 @@
 
   enc_class Lbl (label labl) %{ // JMP, CALL
     Label *l = $labl$$label;
-    emit_d32(cbuf, l ? (l->loc_pos() - (cbuf.code_size()+4)) : 0);
+    emit_d32(cbuf, l ? (l->loc_pos() - (cbuf.insts_size()+4)) : 0);
   %}
 
   enc_class LblShort (label labl) %{ // JMP, CALL
     Label *l = $labl$$label;
-    int disp = l ? (l->loc_pos() - (cbuf.code_size()+1)) : 0;
+    int disp = l ? (l->loc_pos() - (cbuf.insts_size()+1)) : 0;
     assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
     emit_d8(cbuf, disp);
   %}
@@ -1764,13 +1754,13 @@
     Label *l = $labl$$label;
     $$$emit8$primary;
     emit_cc(cbuf, $secondary, $cop$$cmpcode);
-    emit_d32(cbuf, l ? (l->loc_pos() - (cbuf.code_size()+4)) : 0);
+    emit_d32(cbuf, l ? (l->loc_pos() - (cbuf.insts_size()+4)) : 0);
   %}
 
   enc_class JccShort (cmpOp cop, label labl) %{    // JCC
     Label *l = $labl$$label;
     emit_cc(cbuf, $primary, $cop$$cmpcode);
-    int disp = l ? (l->loc_pos() - (cbuf.code_size()+1)) : 0;
+    int disp = l ? (l->loc_pos() - (cbuf.insts_size()+1)) : 0;
     assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
     emit_d8(cbuf, disp);
   %}
@@ -1838,10 +1828,10 @@
 
   enc_class Java_To_Runtime (method meth) %{    // CALL Java_To_Runtime, Java_To_Runtime_Leaf
     // This is the instruction starting address for relocation info.
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     $$$emit8$primary;
     // CALL directly to the runtime
-    emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
+    emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
                 runtime_call_Relocation::spec(), RELOC_IMM32 );
 
     if (UseSSE >= 2) {
@@ -1871,12 +1861,12 @@
 
   enc_class pre_call_FPU %{
     // If method sets FPU control word restore it here
-    debug_only(int off0 = cbuf.code_size());
+    debug_only(int off0 = cbuf.insts_size());
     if( Compile::current()->in_24_bit_fp_mode() ) {
       MacroAssembler masm(&cbuf);
       masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
     }
-    debug_only(int off1 = cbuf.code_size());
+    debug_only(int off1 = cbuf.insts_size());
     assert(off1 - off0 == pre_call_FPU_size(), "correct size prediction");
   %}
 
@@ -1889,12 +1879,12 @@
   %}
 
   enc_class preserve_SP %{
-    debug_only(int off0 = cbuf.code_size());
+    debug_only(int off0 = cbuf.insts_size());
     MacroAssembler _masm(&cbuf);
     // RBP is preserved across all calls, even compiled calls.
     // Use it to preserve RSP in places where the callee might change the SP.
     __ movptr(rbp_mh_SP_save, rsp);
-    debug_only(int off1 = cbuf.code_size());
+    debug_only(int off1 = cbuf.insts_size());
     assert(off1 - off0 == preserve_SP_size(), "correct size prediction");
   %}
 
@@ -1906,16 +1896,16 @@
   enc_class Java_Static_Call (method meth) %{    // JAVA STATIC CALL
     // CALL to fixup routine.  Fixup routine uses ScopeDesc info to determine
     // who we intended to call.
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     $$$emit8$primary;
     if ( !_method ) {
-      emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
+      emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
                      runtime_call_Relocation::spec(), RELOC_IMM32 );
     } else if(_optimized_virtual) {
-      emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
+      emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
                      opt_virtual_call_Relocation::spec(), RELOC_IMM32 );
     } else {
-      emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
+      emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
                      static_call_Relocation::spec(), RELOC_IMM32 );
     }
     if( _method ) {  // Emit stub for static call
@@ -1927,15 +1917,15 @@
     // !!!!!
     // Generate  "Mov EAX,0x00", placeholder instruction to load oop-info
     // emit_call_dynamic_prologue( cbuf );
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf, 0xB8 + EAX_enc);        // mov    EAX,-1
     emit_d32_reloc(cbuf, (int)Universe::non_oop_word(), oop_Relocation::spec_for_immediate(), RELOC_IMM32);
-    address  virtual_call_oop_addr = cbuf.inst_mark();
+    address  virtual_call_oop_addr = cbuf.insts_mark();
     // CALL to fixup routine.  Fixup routine uses ScopeDesc info to determine
     // who we intended to call.
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     $$$emit8$primary;
-    emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.code_end()) - 4),
+    emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4),
                 virtual_call_Relocation::spec(virtual_call_oop_addr), RELOC_IMM32 );
   %}
 
@@ -1944,7 +1934,7 @@
     assert( -128 <= disp && disp <= 127, "compiled_code_offset isn't small");
 
     // CALL *[EAX+in_bytes(methodOopDesc::from_compiled_code_entry_point_offset())]
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     $$$emit8$primary;
     emit_rm(cbuf, 0x01, $secondary, EAX_enc );  // R/M byte
     emit_d8(cbuf, disp);             // Displacement
@@ -1976,9 +1966,9 @@
 //     emit_rm(cbuf, 0x3, EBP_enc, EBP_enc);
 //
 //     // CALL to interpreter.
-//     cbuf.set_inst_mark();
+//     cbuf.set_insts_mark();
 //     $$$emit8$primary;
-//     emit_d32_reloc(cbuf, ($labl$$label - (int)(cbuf.code_end()) - 4),
+//     emit_d32_reloc(cbuf, ($labl$$label - (int)(cbuf.insts_end()) - 4),
 //                 runtime_call_Relocation::spec(), RELOC_IMM32 );
 //   %}
 
@@ -2087,7 +2077,7 @@
   %}
 
   enc_class Opc_MemImm_F(immF src) %{
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     $$$emit8$primary;
     emit_rm(cbuf, 0x0, $secondary, 0x5);
     emit_float_constant(cbuf, $src$$constant);
@@ -2280,7 +2270,7 @@
   %}
 
   enc_class set_instruction_start( ) %{
-    cbuf.set_inst_mark();            // Mark start of opcode for reloc info in mem operand
+    cbuf.set_insts_mark();            // Mark start of opcode for reloc info in mem operand
   %}
 
   enc_class RegMem (eRegI ereg, memory mem) %{    // emit_reg_mem
@@ -2429,7 +2419,7 @@
       emit_opcode( cbuf, 0xD9 ); // FLD (i.e., push it)
       emit_d8( cbuf, 0xC0-1+$src$$reg );
     }
-    cbuf.set_inst_mark();       // Mark start of opcode for reloc info in mem operand
+    cbuf.set_insts_mark();       // Mark start of opcode for reloc info in mem operand
     emit_opcode(cbuf,$primary);
     encode_RegMem(cbuf, reg_encoding, base, index, scale, displace, disp_is_oop);
   %}
@@ -2474,7 +2464,7 @@
     emit_opcode(cbuf,0x1B);
     emit_rm(cbuf, 0x3, tmpReg, tmpReg);
     // AND $tmp,$y
-    cbuf.set_inst_mark();       // Mark start of opcode for reloc info in mem operand
+    cbuf.set_insts_mark();       // Mark start of opcode for reloc info in mem operand
     emit_opcode(cbuf,0x23);
     int reg_encoding = tmpReg;
     int base  = $mem$$base;
@@ -3157,9 +3147,9 @@
     // PUSH src2.lo
     emit_opcode(cbuf,               0x50+$src2$$reg  );
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);       // Call into runtime
-    emit_d32_reloc(cbuf, (CAST_FROM_FN_PTR(address, SharedRuntime::ldiv) - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (CAST_FROM_FN_PTR(address, SharedRuntime::ldiv) - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
     // Restore stack
     emit_opcode(cbuf, 0x83); // add  SP, #framesize
     emit_rm(cbuf, 0x3, 0x00, ESP_enc);
@@ -3176,9 +3166,9 @@
     // PUSH src2.lo
     emit_opcode(cbuf,               0x50+$src2$$reg  );
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);       // Call into runtime
-    emit_d32_reloc(cbuf, (CAST_FROM_FN_PTR(address, SharedRuntime::lrem ) - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (CAST_FROM_FN_PTR(address, SharedRuntime::lrem ) - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
     // Restore stack
     emit_opcode(cbuf, 0x83); // add  SP, #framesize
     emit_rm(cbuf, 0x3, 0x00, ESP_enc);
@@ -3824,9 +3814,9 @@
   %}
 
   enc_class enc_rethrow() %{
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf, 0xE9);        // jmp    entry
-    emit_d32_reloc(cbuf, (int)OptoRuntime::rethrow_stub() - ((int)cbuf.code_end())-4,
+    emit_d32_reloc(cbuf, (int)OptoRuntime::rethrow_stub() - ((int)cbuf.insts_end())-4,
                    runtime_call_Relocation::spec(), RELOC_IMM32 );
   %}
 
@@ -3873,9 +3863,9 @@
     emit_opcode(cbuf,0xD9 );      // FLD     ST(i)
     emit_d8    (cbuf,0xC0-1+$src$$reg );
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);       // Call into runtime
-    emit_d32_reloc(cbuf, (StubRoutines::d2i_wrapper() - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (StubRoutines::d2i_wrapper() - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
     // Carry on here...
   %}
 
@@ -3915,9 +3905,9 @@
     emit_opcode(cbuf,0xD9 );      // FLD     ST(i)
     emit_d8    (cbuf,0xC0-1+$src$$reg );
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);       // Call into runtime
-    emit_d32_reloc(cbuf, (StubRoutines::d2l_wrapper() - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (StubRoutines::d2l_wrapper() - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
     // Carry on here...
   %}
 
@@ -3988,9 +3978,9 @@
     emit_d8(cbuf,0x04);
 
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);       // Call into runtime
-    emit_d32_reloc(cbuf, (StubRoutines::d2l_wrapper() - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (StubRoutines::d2l_wrapper() - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
     // Carry on here...
   %}
 
@@ -4062,9 +4052,9 @@
     emit_d8(cbuf,0x08);
 
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);      // Call into runtime
-    emit_d32_reloc(cbuf, (StubRoutines::d2l_wrapper() - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (StubRoutines::d2l_wrapper() - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
     // Carry on here...
   %}
 
@@ -4122,9 +4112,9 @@
     emit_d8(cbuf, $primary ? 0x8 : 0x4);
 
     // CALL directly to the runtime
-    cbuf.set_inst_mark();
+    cbuf.set_insts_mark();
     emit_opcode(cbuf,0xE8);       // Call into runtime
-    emit_d32_reloc(cbuf, (StubRoutines::d2i_wrapper() - cbuf.code_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
+    emit_d32_reloc(cbuf, (StubRoutines::d2i_wrapper() - cbuf.insts_end()) - 4, runtime_call_Relocation::spec(), RELOC_IMM32 );
 
     // Carry on here...
   %}
@@ -4321,7 +4311,7 @@
   // so the memory operand is used twice in the encoding.
   enc_class enc_storeL_volatile( memory mem, stackSlotL src ) %{
     store_to_stackslot( cbuf, 0x0DF, 0x05, $src$$disp );
-    cbuf.set_inst_mark();            // Mark start of FIST in case $mem has an oop
+    cbuf.set_insts_mark();            // Mark start of FIST in case $mem has an oop
     emit_opcode(cbuf,0xDF);
     int rm_byte_opcode = 0x07;
     int base     = $mem$$base;
@@ -4345,7 +4335,7 @@
       bool disp_is_oop = $src->disp_is_oop(); // disp-as-oop when working with static globals
       encode_RegMem(cbuf, $tmp$$reg, base, index, scale, displace, disp_is_oop);
     }
-    cbuf.set_inst_mark();            // Mark start of MOVSD in case $mem has an oop
+    cbuf.set_insts_mark();            // Mark start of MOVSD in case $mem has an oop
     { // MOVSD $mem,$tmp ! atomic long store
       emit_opcode(cbuf,0xF2);
       emit_opcode(cbuf,0x0F);
@@ -4378,7 +4368,7 @@
       emit_opcode(cbuf,0x62);
       emit_rm(cbuf, 0x3, $tmp$$reg, $tmp2$$reg);
     }
-    cbuf.set_inst_mark();            // Mark start of MOVSD in case $mem has an oop
+    cbuf.set_insts_mark();            // Mark start of MOVSD in case $mem has an oop
     { // MOVSD $mem,$tmp ! atomic long store
       emit_opcode(cbuf,0xF2);
       emit_opcode(cbuf,0x0F);
@@ -4399,7 +4389,7 @@
   // A better choice might be TESTB [spp + pagesize() - CacheLineSize()],0
 
   enc_class Safepoint_Poll() %{
-    cbuf.relocate(cbuf.inst_mark(), relocInfo::poll_type, 0);
+    cbuf.relocate(cbuf.insts_mark(), relocInfo::poll_type, 0);
     emit_opcode(cbuf,0x85);
     emit_rm (cbuf, 0x0, 0x7, 0x5);
     emit_d32(cbuf, (intptr_t)os::get_polling_page());
@@ -12932,7 +12922,7 @@
     bool ok = false;
     if ($cop$$cmpcode == Assembler::notEqual) {
        // the two jumps 6 bytes apart so the jump distances are too
-       parity_disp = l ? (l->loc_pos() - (cbuf.code_size() + 4)) : 0;
+       parity_disp = l ? (l->loc_pos() - (cbuf.insts_size() + 4)) : 0;
     } else if ($cop$$cmpcode == Assembler::equal) {
        parity_disp = 6;
        ok = true;
@@ -12942,7 +12932,7 @@
     emit_d32(cbuf, parity_disp);
     $$$emit8$primary;
     emit_cc(cbuf, $secondary, $cop$$cmpcode);
-    int disp = l ? (l->loc_pos() - (cbuf.code_size() + 4)) : 0;
+    int disp = l ? (l->loc_pos() - (cbuf.insts_size() + 4)) : 0;
     emit_d32(cbuf, disp);
   %}
   ins_pipe(pipe_jcc);
@@ -13128,7 +13118,7 @@
     emit_cc(cbuf, $primary, Assembler::parity);
     int parity_disp = -1;
     if ($cop$$cmpcode == Assembler::notEqual) {
-      parity_disp = l ? (l->loc_pos() - (cbuf.code_size() + 1)) : 0;
+      parity_disp = l ? (l->loc_pos() - (cbuf.insts_size() + 1)) : 0;
     } else if ($cop$$cmpcode == Assembler::equal) {
       parity_disp = 2;
     } else {
@@ -13136,7 +13126,7 @@
     }
     emit_d8(cbuf, parity_disp);
     emit_cc(cbuf, $primary, $cop$$cmpcode);
-    int disp = l ? (l->loc_pos() - (cbuf.code_size() + 1)) : 0;
+    int disp = l ? (l->loc_pos() - (cbuf.insts_size() + 1)) : 0;
     emit_d8(cbuf, disp);
     assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
     assert(-128 <= parity_disp && parity_disp <= 127, "Displacement too large for short jmp");