--- old/src/cpu/ppc/vm/macroAssembler_ppc.cpp 2017-09-14 21:06:06.182433131 +0300 +++ new/src/cpu/ppc/vm/macroAssembler_ppc.cpp 2017-09-14 21:06:06.095766468 +0300 @@ -155,7 +155,7 @@ assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC"); set_imm((int *)inst1_addr, MacroAssembler::largeoffset_si16_si16_hi(offset)); set_imm((int *)inst2_addr, MacroAssembler::largeoffset_si16_si16_lo(offset)); - return (int)((intptr_t)addr - (intptr_t)inst1_addr); + return (int)((intptr_t)inst2_addr - (intptr_t)inst1_addr); } address MacroAssembler::get_address_of_calculate_address_from_global_toc_at(address a, address bound) { --- old/src/cpu/ppc/vm/macroAssembler_ppc.hpp 2017-09-14 21:06:06.542433115 +0300 +++ new/src/cpu/ppc/vm/macroAssembler_ppc.hpp 2017-09-14 21:06:06.455766452 +0300 @@ -105,7 +105,7 @@ }; inline static bool is_calculate_address_from_global_toc_at(address a, address bound); - static int patch_calculate_address_from_global_toc_at(address a, address addr, address bound); + static int patch_calculate_address_from_global_toc_at(address a, address bound, address addr); static address get_address_of_calculate_address_from_global_toc_at(address a, address addr); #ifdef _LP64 --- old/src/cpu/ppc/vm/nativeInst_ppc.cpp 2017-09-14 21:06:06.872433101 +0300 +++ new/src/cpu/ppc/vm/nativeInst_ppc.cpp 2017-09-14 21:06:06.785766438 +0300 @@ -221,12 +221,12 @@ // A calculation relative to the global TOC. if (MacroAssembler::get_address_of_calculate_address_from_global_toc_at(addr, cb->content_begin()) != (address)data) { - const int invalidated_range = + const int first_insn_offset = MacroAssembler::patch_calculate_address_from_global_toc_at(addr, cb->content_begin(), (address)data); - const address start = invalidated_range < 0 ? addr + invalidated_range : addr; - // FIXME: - const int range = invalidated_range < 0 ? 4 - invalidated_range : 8; + assert(first_insn_offset > 0, "first instruction must be found"); + const address start = addr - first_insn_offset; + const int range = BytesPerInstWord + first_insn_offset; ICache::ppc64_flush_icache_bytes(start, range); } next_address = addr + 1 * BytesPerInstWord; @@ -291,11 +291,11 @@ address addr = addr_at(0); CodeBlob* cb = (code) ? code : CodeCache::find_blob(instruction_address()); if (MacroAssembler::get_narrow_oop(addr, cb->content_begin()) == (long)data) return; - const int invalidated_range = + const int first_insn_offset = MacroAssembler::patch_set_narrow_oop(addr, cb->content_begin(), (long)data); - const address start = invalidated_range < 0 ? addr + invalidated_range : addr; - // FIXME: - const int range = invalidated_range < 0 ? 4 - invalidated_range : 8; + assert(first_insn_offset > 0, "first instruction must be found"); + const address start = addr - first_insn_offset; + const int range = BytesPerInstWord + first_insn_offset; ICache::ppc64_flush_icache_bytes(start, range); }