Skip to content

Commit 4b829a2

Browse files
committedMar 30, 2022
Move fix_thawed_frame
1 parent 8855e0b commit 4b829a2

File tree

5 files changed

+64
-65
lines changed

5 files changed

+64
-65
lines changed
 

‎src/hotspot/share/oops/instanceStackChunkKlass.cpp

-57
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,6 @@ void InstanceStackChunkKlass::oop_print_on(oop obj, outputStream* st) {
8989
}
9090
#endif
9191

92-
class DerelativizeDerivedOopClosure : public DerivedOopClosure {
93-
public:
94-
virtual void do_derived_oop(oop* base_loc, derived_pointer* derived_loc) override {
95-
// The ordering in the following is crucial
96-
OrderAccess::loadload();
97-
oop base = Atomic::load(base_loc);
98-
if (base != nullptr) {
99-
assert(!CompressedOops::is_base(base), "");
100-
ZGC_ONLY(assert(ZAddress::is_good(cast_from_oop<uintptr_t>(base)), "");)
101-
102-
OrderAccess::loadload();
103-
intptr_t offset = Atomic::load((intptr_t*)derived_loc); // *derived_loc;
104-
105-
// at this point, we've seen a non-offset value *after* we've read the base, but we write the offset *before* fixing the base,
106-
// so we are guaranteed that the value in derived_loc is consistent with base (i.e. points into the object).
107-
if (offset <= 0) {
108-
offset = -offset;
109-
Atomic::store((intptr_t*)derived_loc, cast_from_oop<intptr_t>(base) + offset);
110-
}
111-
}
112-
}
113-
};
114-
11592
template<typename OopClosureType>
11693
class StackChunkOopIterateFilterClosure: public OopClosure {
11794
private:
@@ -218,40 +195,6 @@ static inline oop safe_load(P* addr) {
218195
}
219196
#endif
220197

221-
class UncompressOopsOopClosure : public OopClosure {
222-
public:
223-
void do_oop(oop* p) override {
224-
assert(UseCompressedOops, "Only needed with compressed oops");
225-
oop obj = CompressedOops::decode(*(narrowOop*)p);
226-
assert(obj == nullptr || dbg_is_good_oop(obj), "p: " INTPTR_FORMAT " obj: " INTPTR_FORMAT, p2i(p), p2i((oopDesc*)obj));
227-
*p = obj;
228-
}
229-
230-
void do_oop(narrowOop* p) override {}
231-
};
232-
233-
template <typename RegisterMapT>
234-
void InstanceStackChunkKlass::fix_thawed_frame(stackChunkOop chunk, const frame& f, const RegisterMapT* map) {
235-
if (chunk->has_bitmap() && UseCompressedOops) {
236-
UncompressOopsOopClosure oop_closure;
237-
if (f.is_interpreted_frame()) {
238-
f.oops_interpreted_do(&oop_closure, nullptr);
239-
} else {
240-
OopMapDo<UncompressOopsOopClosure, DerivedOopClosure, SkipNullValue> visitor(&oop_closure, nullptr);
241-
visitor.oops_do(&f, map, f.oop_map());
242-
}
243-
}
244-
245-
if (f.is_compiled_frame() && f.oop_map()->has_derived_oops()) {
246-
DerelativizeDerivedOopClosure derived_closure;
247-
OopMapDo<OopClosure, DerelativizeDerivedOopClosure, SkipNullValue> visitor(nullptr, &derived_closure);
248-
visitor.oops_do(&f, map, f.oop_map());
249-
}
250-
}
251-
252-
template void InstanceStackChunkKlass::fix_thawed_frame(stackChunkOop chunk, const frame& f, const RegisterMap* map);
253-
template void InstanceStackChunkKlass::fix_thawed_frame(stackChunkOop chunk, const frame& f, const SmallRegisterMap* map);
254-
255198
#ifdef ASSERT
256199

257200
template <typename T>

‎src/hotspot/share/oops/instanceStackChunkKlass.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ class InstanceStackChunkKlass: public InstanceKlass {
169169
template <typename T, class OopClosureType>
170170
inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr);
171171

172-
public:
173-
template <typename RegisterMapT>
174-
static void fix_thawed_frame(stackChunkOop chunk, const frame& f, const RegisterMapT* map);
175-
176172
private:
177173
static size_t bitmap_size_in_bits(size_t stack_size_in_words) { return stack_size_in_words << (UseCompressedOops ? 1 : 0); }
178174

‎src/hotspot/share/oops/stackChunkOop.cpp

+57
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,63 @@ template void stackChunkOopDesc::do_barriers0<stackChunkOopDesc::barrier_type::S
334334
template void stackChunkOopDesc::do_barriers0<stackChunkOopDesc::barrier_type::LOAD> (const StackChunkFrameStream<chunk_frames::COMPILED_ONLY>& f, const SmallRegisterMap* map);
335335
template void stackChunkOopDesc::do_barriers0<stackChunkOopDesc::barrier_type::STORE>(const StackChunkFrameStream<chunk_frames::COMPILED_ONLY>& f, const SmallRegisterMap* map);
336336

337+
class DerelativizeDerivedOopClosure : public DerivedOopClosure {
338+
public:
339+
virtual void do_derived_oop(oop* base_loc, derived_pointer* derived_loc) override {
340+
// The ordering in the following is crucial
341+
OrderAccess::loadload();
342+
oop base = Atomic::load(base_loc);
343+
if (base != nullptr) {
344+
assert(!CompressedOops::is_base(base), "");
345+
ZGC_ONLY(assert(ZAddress::is_good(cast_from_oop<uintptr_t>(base)), "");)
346+
347+
OrderAccess::loadload();
348+
intptr_t offset = Atomic::load((intptr_t*)derived_loc); // *derived_loc;
349+
350+
// at this point, we've seen a non-offset value *after* we've read the base, but we write the offset *before* fixing the base,
351+
// so we are guaranteed that the value in derived_loc is consistent with base (i.e. points into the object).
352+
if (offset <= 0) {
353+
offset = -offset;
354+
Atomic::store((intptr_t*)derived_loc, cast_from_oop<intptr_t>(base) + offset);
355+
}
356+
}
357+
}
358+
};
359+
360+
class UncompressOopsOopClosure : public OopClosure {
361+
public:
362+
void do_oop(oop* p) override {
363+
assert(UseCompressedOops, "Only needed with compressed oops");
364+
oop obj = CompressedOops::decode(*(narrowOop*)p);
365+
assert(obj == nullptr || dbg_is_good_oop(obj), "p: " INTPTR_FORMAT " obj: " INTPTR_FORMAT, p2i(p), p2i((oopDesc*)obj));
366+
*p = obj;
367+
}
368+
369+
void do_oop(narrowOop* p) override {}
370+
};
371+
372+
template <typename RegisterMapT>
373+
void stackChunkOopDesc::fix_thawed_frame(const frame& f, const RegisterMapT* map) {
374+
if (has_bitmap() && UseCompressedOops) {
375+
UncompressOopsOopClosure oop_closure;
376+
if (f.is_interpreted_frame()) {
377+
f.oops_interpreted_do(&oop_closure, nullptr);
378+
} else {
379+
OopMapDo<UncompressOopsOopClosure, DerivedOopClosure, SkipNullValue> visitor(&oop_closure, nullptr);
380+
visitor.oops_do(&f, map, f.oop_map());
381+
}
382+
}
383+
384+
if (f.is_compiled_frame() && f.oop_map()->has_derived_oops()) {
385+
DerelativizeDerivedOopClosure derived_closure;
386+
OopMapDo<OopClosure, DerelativizeDerivedOopClosure, SkipNullValue> visitor(nullptr, &derived_closure);
387+
visitor.oops_do(&f, map, f.oop_map());
388+
}
389+
}
390+
391+
template void stackChunkOopDesc::fix_thawed_frame(const frame& f, const RegisterMap* map);
392+
template void stackChunkOopDesc::fix_thawed_frame(const frame& f, const SmallRegisterMap* map);
393+
337394
void stackChunkOopDesc::print_on(bool verbose, outputStream* st) const {
338395
if (this == nullptr) {
339396
st->print_cr("NULL");

‎src/hotspot/share/oops/stackChunkOop.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class stackChunkOopDesc : public instanceOopDesc {
129129
template <barrier_type, chunk_frames frames, typename RegisterMapT>
130130
inline void do_barriers(const StackChunkFrameStream<frames>& f, const RegisterMapT* map);
131131

132+
template <typename RegisterMapT>
133+
void fix_thawed_frame(const frame& f, const RegisterMapT* map);
134+
132135
template <class StackChunkFrameClosureType>
133136
inline void iterate_stack(StackChunkFrameClosureType* closure);
134137

‎src/hotspot/share/runtime/continuation.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -2718,7 +2718,7 @@ NOINLINE void ThawBase::recurse_thaw_interpreted_frame(const frame& hf, frame& c
27182718

27192719
if (!bottom) {
27202720
// can only fix caller once this frame is thawed (due to callee saved regs)
2721-
InstanceStackChunkKlass::fix_thawed_frame(_cont.tail(), caller, SmallRegisterMap::instance);
2721+
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance);
27222722
} else if (_cont.tail()->has_bitmap() && locals > 0) {
27232723
assert(hf.is_heap_frame(), "should be");
27242724
clear_bitmap_bits(Interpreted::frame_bottom(hf) - locals, locals);
@@ -2787,7 +2787,7 @@ void ThawBase::recurse_thaw_compiled_frame(const frame& hf, frame& caller, int n
27872787

27882788
if (!bottom) {
27892789
// can only fix caller once this frame is thawed (due to callee saved regs)
2790-
InstanceStackChunkKlass::fix_thawed_frame(_cont.tail(), caller, SmallRegisterMap::instance);
2790+
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance);
27912791
} else if (_cont.tail()->has_bitmap() && added_argsize > 0) {
27922792
clear_bitmap_bits(hsp + Compiled::size(hf), added_argsize);
27932793
}
@@ -2832,7 +2832,7 @@ void ThawBase::recurse_thaw_stub_frame(const frame& hf, frame& caller, int num_f
28322832
map.set_include_argument_oops(false);
28332833
f.oop_map()->update_register_map(&f, &map);
28342834
ContinuationHelper::update_register_map_with_callee(caller, &map);
2835-
InstanceStackChunkKlass::fix_thawed_frame(_cont.tail(), caller, &map);
2835+
_cont.tail()->fix_thawed_frame(caller, &map);
28362836
}
28372837

28382838
DEBUG_ONLY(after_thaw_java_frame(f, false);)
@@ -2860,7 +2860,7 @@ void ThawBase::finish_thaw(frame& f) {
28602860
f.set_sp(f.sp() - 1);
28612861
}
28622862
push_return_frame(f);
2863-
InstanceStackChunkKlass::fix_thawed_frame(chunk, f, SmallRegisterMap::instance); // can only fix caller after push_return_frame (due to callee saved regs)
2863+
chunk->fix_thawed_frame(f, SmallRegisterMap::instance); // can only fix caller after push_return_frame (due to callee saved regs)
28642864

28652865
assert(_cont.is_empty() == _cont.last_frame().is_empty(), "");
28662866

0 commit comments

Comments
 (0)
Please sign in to comment.