1963 }
1964
1965 static void install_post_call_nop_displacement(nmethod* nm, address pc) {
1966 NativePostCallNop* nop = nativePostCallNop_at((address) pc);
1967 intptr_t cbaddr = (intptr_t) nm;
1968 intptr_t offset = ((intptr_t) pc) - cbaddr;
1969
1970 int oopmap_slot = nm->oop_maps()->find_slot_for_offset(int((intptr_t) pc - (intptr_t) nm->code_begin()));
1971 if (oopmap_slot < 0) { // this can happen at asynchronous (non-safepoint) stackwalks
1972 log_debug(codecache)("failed to find oopmap for cb: " INTPTR_FORMAT " offset: %d", cbaddr, (int) offset);
1973 } else if (!nop->patch(oopmap_slot, offset)) {
1974 log_debug(codecache)("failed to encode %d %d", oopmap_slot, (int) offset);
1975 }
1976 }
1977
1978 void nmethod::finalize_relocations() {
1979 NoSafepointVerifier nsv;
1980
1981 GrowableArray<NativeMovConstReg*> virtual_call_data;
1982
1983 // Make sure that post call nops fill in nmethod offsets eagerly so
1984 // we don't have to race with deoptimization
1985 RelocIterator iter(this);
1986 while (iter.next()) {
1987 if (iter.type() == relocInfo::virtual_call_type) {
1988 virtual_call_Relocation* r = iter.virtual_call_reloc();
1989 NativeMovConstReg* value = nativeMovConstReg_at(r->cached_value());
1990 virtual_call_data.append(value);
1991 } else if (iter.type() == relocInfo::post_call_nop_type) {
1992 post_call_nop_Relocation* const reloc = iter.post_call_nop_reloc();
1993 address pc = reloc->addr();
1994 install_post_call_nop_displacement(this, pc);
1995 }
1996 }
1997
1998 if (virtual_call_data.length() > 0) {
1999 // We allocate a block of CompiledICData per nmethod so the GC can purge this faster.
2000 _compiled_ic_data = new CompiledICData[virtual_call_data.length()];
2001 CompiledICData* next_data = _compiled_ic_data;
2002
2003 for (NativeMovConstReg* value : virtual_call_data) {
2004 value->set_data((intptr_t)next_data);
2005 next_data++;
2006 }
2007 }
2008 }
2009
2010 void nmethod::make_deoptimized() {
2011 if (!Continuations::enabled()) {
2012 // Don't deopt this again.
2013 set_deoptimized_done();
2014 return;
3836 assert(m->is_method(), "");
3837 m->print_short_name(&st);
3838 }
3839 return st.as_string();
3840 }
3841 case relocInfo::static_stub_type: return "static_stub";
3842 case relocInfo::external_word_type: return "external_word";
3843 case relocInfo::internal_word_type: return "internal_word";
3844 case relocInfo::section_word_type: return "section_word";
3845 case relocInfo::poll_type: return "poll";
3846 case relocInfo::poll_return_type: return "poll_return";
3847 case relocInfo::trampoline_stub_type: return "trampoline_stub";
3848 case relocInfo::entry_guard_type: return "entry_guard";
3849 case relocInfo::post_call_nop_type: return "post_call_nop";
3850 case relocInfo::barrier_type: {
3851 barrier_Relocation* const reloc = iter.barrier_reloc();
3852 stringStream st;
3853 st.print("barrier format=%d", reloc->format());
3854 return st.as_string();
3855 }
3856
3857 case relocInfo::type_mask: return "type_bit_mask";
3858
3859 default: {
3860 stringStream st;
3861 st.print("unknown relocInfo=%d", (int) iter.type());
3862 return st.as_string();
3863 }
3864 }
3865 }
3866 return have_one ? "other" : nullptr;
3867 }
3868
3869 // Return the last scope in (begin..end]
3870 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3871 PcDesc* p = pc_desc_near(begin+1);
3872 if (p != nullptr && p->real_pc(this) <= end) {
3873 return new ScopeDesc(this, p);
3874 }
3875 return nullptr;
|
1963 }
1964
1965 static void install_post_call_nop_displacement(nmethod* nm, address pc) {
1966 NativePostCallNop* nop = nativePostCallNop_at((address) pc);
1967 intptr_t cbaddr = (intptr_t) nm;
1968 intptr_t offset = ((intptr_t) pc) - cbaddr;
1969
1970 int oopmap_slot = nm->oop_maps()->find_slot_for_offset(int((intptr_t) pc - (intptr_t) nm->code_begin()));
1971 if (oopmap_slot < 0) { // this can happen at asynchronous (non-safepoint) stackwalks
1972 log_debug(codecache)("failed to find oopmap for cb: " INTPTR_FORMAT " offset: %d", cbaddr, (int) offset);
1973 } else if (!nop->patch(oopmap_slot, offset)) {
1974 log_debug(codecache)("failed to encode %d %d", oopmap_slot, (int) offset);
1975 }
1976 }
1977
1978 void nmethod::finalize_relocations() {
1979 NoSafepointVerifier nsv;
1980
1981 GrowableArray<NativeMovConstReg*> virtual_call_data;
1982
1983 BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod();
1984
1985 // Make sure that post call nops fill in nmethod offsets eagerly so
1986 // we don't have to race with deoptimization
1987 RelocIterator iter(this);
1988 while (iter.next()) {
1989 if (iter.type() == relocInfo::virtual_call_type) {
1990 virtual_call_Relocation* r = iter.virtual_call_reloc();
1991 NativeMovConstReg* value = nativeMovConstReg_at(r->cached_value());
1992 virtual_call_data.append(value);
1993 } else if (iter.type() == relocInfo::post_call_nop_type) {
1994 post_call_nop_Relocation* const reloc = iter.post_call_nop_reloc();
1995 address pc = reloc->addr();
1996 install_post_call_nop_displacement(this, pc);
1997 } else if (iter.type() == relocInfo::patchable_barrier_type) {
1998 patchable_barrier_Relocation* const reloc = iter.patchable_barrier_reloc();
1999 bs_nm->patch_barrier_relocation(reloc);
2000 }
2001 }
2002
2003 if (virtual_call_data.length() > 0) {
2004 // We allocate a block of CompiledICData per nmethod so the GC can purge this faster.
2005 _compiled_ic_data = new CompiledICData[virtual_call_data.length()];
2006 CompiledICData* next_data = _compiled_ic_data;
2007
2008 for (NativeMovConstReg* value : virtual_call_data) {
2009 value->set_data((intptr_t)next_data);
2010 next_data++;
2011 }
2012 }
2013 }
2014
2015 void nmethod::make_deoptimized() {
2016 if (!Continuations::enabled()) {
2017 // Don't deopt this again.
2018 set_deoptimized_done();
2019 return;
3841 assert(m->is_method(), "");
3842 m->print_short_name(&st);
3843 }
3844 return st.as_string();
3845 }
3846 case relocInfo::static_stub_type: return "static_stub";
3847 case relocInfo::external_word_type: return "external_word";
3848 case relocInfo::internal_word_type: return "internal_word";
3849 case relocInfo::section_word_type: return "section_word";
3850 case relocInfo::poll_type: return "poll";
3851 case relocInfo::poll_return_type: return "poll_return";
3852 case relocInfo::trampoline_stub_type: return "trampoline_stub";
3853 case relocInfo::entry_guard_type: return "entry_guard";
3854 case relocInfo::post_call_nop_type: return "post_call_nop";
3855 case relocInfo::barrier_type: {
3856 barrier_Relocation* const reloc = iter.barrier_reloc();
3857 stringStream st;
3858 st.print("barrier format=%d", reloc->format());
3859 return st.as_string();
3860 }
3861 case relocInfo::patchable_barrier_type: {
3862 patchable_barrier_Relocation* const reloc = iter.patchable_barrier_reloc();
3863 stringStream st;
3864 st.print("patchable_barrier metadata=%d", reloc->metadata());
3865 return st.as_string();
3866 }
3867
3868 case relocInfo::type_mask: return "type_bit_mask";
3869
3870 default: {
3871 stringStream st;
3872 st.print("unknown relocInfo=%d", (int) iter.type());
3873 return st.as_string();
3874 }
3875 }
3876 }
3877 return have_one ? "other" : nullptr;
3878 }
3879
3880 // Return the last scope in (begin..end]
3881 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
3882 PcDesc* p = pc_desc_near(begin+1);
3883 if (p != nullptr && p->real_pc(this) <= end) {
3884 return new ScopeDesc(this, p);
3885 }
3886 return nullptr;
|