@@ -1741,7 +1741,7 @@ class ThawBase : public StackObj {
1741
1741
inline void before_thaw_java_frame(const frame& hf, const frame& caller, bool bottom, int num_frame);
1742
1742
inline void after_thaw_java_frame(const frame& f, bool bottom);
1743
1743
inline void patch(frame& f, const frame& caller, bool bottom);
1744
- void clear_bitmap_bits(intptr_t* start, int range );
1744
+ void clear_bitmap_bits(address start, address end );
1745
1745
1746
1746
NOINLINE void recurse_thaw_interpreted_frame(const frame& hf, frame& caller, int num_frames);
1747
1747
void recurse_thaw_compiled_frame(const frame& hf, frame& caller, int num_frames, bool stub_caller);
@@ -2122,13 +2122,22 @@ inline void ThawBase::patch(frame& f, const frame& caller, bool bottom) {
2122
2122
assert(!bottom || (_cont.is_empty() != Continuation::is_cont_barrier_frame(f)), "");
2123
2123
}
2124
2124
2125
- void ThawBase::clear_bitmap_bits(intptr_t* start, int range) {
2125
+ void ThawBase::clear_bitmap_bits(address start, address end) {
2126
+ assert(is_aligned(start, wordSize), "should be aligned: " PTR_FORMAT, p2i(start));
2127
+ assert(is_aligned(end, VMRegImpl::stack_slot_size), "should be aligned: " PTR_FORMAT, p2i(end));
2128
+
2126
2129
// we need to clear the bits that correspond to arguments as they reside in the caller frame
2127
- // or they will keep objects that are otherwise unreachable alive
2128
- log_develop_trace(continuations)("clearing bitmap for " INTPTR_FORMAT " - " INTPTR_FORMAT, p2i(start), p2i(start+range));
2130
+ // or they will keep objects that are otherwise unreachable alive.
2131
+
2132
+ // Align `end` if UseCompressedOops is not set to avoid UB when calculating the bit index, since
2133
+ // `end` could be at an odd number of stack slots from `start`, i.e might not be oop aligned.
2134
+ // If that's the case the bit range corresponding to the last stack slot should not have bits set
2135
+ // anyways and we assert that before returning.
2136
+ address effective_end = UseCompressedOops ? end : align_down(end, wordSize);
2137
+ log_develop_trace(continuations)("clearing bitmap for " INTPTR_FORMAT " - " INTPTR_FORMAT, p2i(start), p2i(effective_end));
2129
2138
stackChunkOop chunk = _cont.tail();
2130
- chunk->bitmap().clear_range(chunk->bit_index_for(start),
2131
- chunk->bit_index_for(start+range) );
2139
+ chunk->bitmap().clear_range(chunk->bit_index_for(start), chunk->bit_index_for(effective_end));
2140
+ assert(effective_end == end || ! chunk->bitmap().at(chunk-> bit_index_for(effective_end)), "bit should not be set" );
2132
2141
}
2133
2142
2134
2143
NOINLINE void ThawBase::recurse_thaw_interpreted_frame(const frame& hf, frame& caller, int num_frames) {
@@ -2181,7 +2190,9 @@ NOINLINE void ThawBase::recurse_thaw_interpreted_frame(const frame& hf, frame& c
2181
2190
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance);
2182
2191
} else if (_cont.tail()->has_bitmap() && locals > 0) {
2183
2192
assert(hf.is_heap_frame(), "should be");
2184
- clear_bitmap_bits(heap_frame_bottom - locals, locals);
2193
+ address start = (address)(heap_frame_bottom - locals);
2194
+ address end = (address)heap_frame_bottom;
2195
+ clear_bitmap_bits(start, end);
2185
2196
}
2186
2197
2187
2198
DEBUG_ONLY(after_thaw_java_frame(f, is_bottom_frame);)
@@ -2254,7 +2265,10 @@ void ThawBase::recurse_thaw_compiled_frame(const frame& hf, frame& caller, int n
2254
2265
// can only fix caller once this frame is thawed (due to callee saved regs); this happens on the stack
2255
2266
_cont.tail()->fix_thawed_frame(caller, SmallRegisterMap::instance);
2256
2267
} else if (_cont.tail()->has_bitmap() && added_argsize > 0) {
2257
- clear_bitmap_bits(heap_frame_top + ContinuationHelper::CompiledFrame::size(hf) + frame::metadata_words_at_top, added_argsize);
2268
+ address start = (address)(heap_frame_top + ContinuationHelper::CompiledFrame::size(hf) + frame::metadata_words_at_top);
2269
+ int stack_args_slots = f.cb()->as_compiled_method()->method()->num_stack_arg_slots(false /* rounded */);
2270
+ int argsize_in_bytes = stack_args_slots * VMRegImpl::stack_slot_size;
2271
+ clear_bitmap_bits(start, start + argsize_in_bytes);
2258
2272
}
2259
2273
2260
2274
DEBUG_ONLY(after_thaw_java_frame(f, is_bottom_frame);)
0 commit comments