diff -r 689b07445e33 src/cpu/x86/vm/c1_CodeStubs_x86.cpp --- a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp Wed Jul 08 15:28:59 2015 +0200 +++ b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp Thu Jul 16 16:35:58 2015 +0300 @@ -417,9 +417,7 @@ __ jmp(_patch_site_entry); // Add enough nops so deoptimization can overwrite the jmp above with a call // and not destroy the world. - for (int j = __ offset() ; j < jmp_off + 5 ; j++ ) { - __ nop(); - } + __ nop((jmp_off + 5) - __ offset()); if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) { CodeSection* cs = __ code_section(); RelocIterator iter(cs, (address)_pc_start, (address)(_pc_start + 1)); diff -r 689b07445e33 src/cpu/x86/vm/c1_LIRAssembler_x86.cpp --- a/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Wed Jul 08 15:28:59 2015 +0200 +++ b/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Thu Jul 16 16:35:58 2015 +0300 @@ -345,8 +345,9 @@ const bool do_post_padding = VerifyOops || UseCompressedClassPointers; if (!do_post_padding) { // insert some nops so that the verified entry point is aligned on CodeEntryAlignment - while ((__ offset() + ic_cmp_size) % CodeEntryAlignment != 0) { - __ nop(); + int offset = (__ offset() + ic_cmp_size); + if (offset % CodeEntryAlignment != 0) { + __ nop(CodeEntryAlignment - (offset % CodeEntryAlignment)); } } int offset = __ offset(); @@ -2861,8 +2862,8 @@ case lir_virtual_call: // currently, sparc-specific for niagara default: ShouldNotReachHere(); } - while (offset++ % BytesPerWord != 0) { - __ nop(); + if (offset % BytesPerWord != 0) { + __ nop(BytesPerWord - (offset % BytesPerWord)); } } } @@ -2903,8 +2904,8 @@ if (os::is_MP()) { // make sure that the displacement word of the call ends up word aligned int offset = __ offset() + NativeMovConstReg::instruction_size + NativeCall::displacement_offset; - while (offset++ % BytesPerWord != 0) { - __ nop(); + if (offset % BytesPerWord != 0) { + __ nop(BytesPerWord - (offset % BytesPerWord)); } } __ relocate(static_stub_Relocation::spec(call_pc)); diff -r 689b07445e33 src/share/vm/c1/c1_LIRAssembler.cpp --- a/src/share/vm/c1/c1_LIRAssembler.cpp Wed Jul 08 15:28:59 2015 +0200 +++ b/src/share/vm/c1/c1_LIRAssembler.cpp Thu Jul 16 16:35:58 2015 +0300 @@ -34,8 +34,9 @@ void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_code, Register obj, CodeEmitInfo* info) { // we must have enough patching space so that call can be inserted - while ((intx) _masm->pc() - (intx) patch->pc_start() < NativeCall::instruction_size) { - _masm->nop(); + int space = NativeCall::instruction_size - ((intx) _masm->pc() - (intx) patch->pc_start()); + if (space > 0) { + _masm->nop(space); } patch->install(_masm, patch_code, obj, info); append_code_stub(patch); @@ -591,8 +592,9 @@ void LIR_Assembler::emit_op0(LIR_Op0* op) { switch (op->code()) { case lir_word_align: { - while (code_offset() % BytesPerWord != 0) { - _masm->nop(); + int offset = code_offset(); + if (offset % BytesPerWord != 0) { + _masm->nop(BytesPerWord - (offset % BytesPerWord)); } break; }