Skip to content
Permalink
Browse files
Short-circuit derived pointer processing
  • Loading branch information
pron committed Mar 31, 2021
1 parent 2b98429 commit 5cd6ee410f94e51f9a781b2166ab2ae017ad4357
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
@@ -91,6 +91,7 @@ OopMap::OopMap(int frame_size, int arg_count) {
set_write_stream(new CompressedWriteStream(32));
set_omv_count(0);
_num_oops = 0;
_has_derived_oops = false;
_index = -1;

#ifdef ASSERT
@@ -108,6 +109,7 @@ OopMap::OopMap(OopMap::DeepCopyToken, OopMap* source) {
set_omv_count(0);
set_offset(source->offset());
_num_oops = source->num_oops();
_has_derived_oops = source->has_derived_oops();
_index = -1;

#ifdef ASSERT
@@ -315,8 +317,11 @@ void OopMap::set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional) {
OopMapValue o(reg, x, optional);
o.write_on(write_stream());
increment_count();
if (x == OopMapValue::oop_value || x == OopMapValue::narrowoop_value)
if (x == OopMapValue::oop_value || x == OopMapValue::narrowoop_value) {
increment_num_oops();
} else if (x == OopMapValue::derived_oop_value) {
set_has_derived_oops(true);
}
}


@@ -756,6 +761,7 @@ ImmutableOopMap::ImmutableOopMap(const OopMap* oopmap)
_thaw_stub(NULL /*Continuations::default_thaw_oops_stub()*/),
_count(oopmap->count()), _num_oops(oopmap->num_oops()) {
_num_oops = oopmap->num_oops();
_has_derived_oops = oopmap->has_derived_oops();
address addr = data_addr();
//oopmap->copy_data_to(addr);
oopmap->copy_and_sort_data_to(addr);
@@ -157,6 +157,7 @@ class OopMap: public ResourceObj {
int _omv_count; // number of OopMapValues in the stream
int _num_oops; // number of oops
int _index; // index in OopMapSet
bool _has_derived_oops;
CompressedWriteStream* _write_stream;

debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;)
@@ -166,6 +167,7 @@ class OopMap: public ResourceObj {
void set_omv_count(int value) { _omv_count = value; }
void increment_count() { _omv_count++; }
void increment_num_oops() { _num_oops++; }
void set_has_derived_oops(bool value) { _has_derived_oops = value; }
CompressedWriteStream* write_stream() const { return _write_stream; }
void set_write_stream(CompressedWriteStream* value) { _write_stream = value; }

@@ -185,6 +187,7 @@ class OopMap: public ResourceObj {
int data_size() const { return write_stream()->position(); }
address data() const { return write_stream()->buffer(); }
int num_oops() const { return _num_oops; }
bool has_derived_oops() const { return _has_derived_oops; }
int index() const { return _index; }

// Construction
@@ -283,13 +286,15 @@ class ImmutableOopMap {
mutable address _thaw_stub;
int _count; // contains the number of entries in this OopMap
int _num_oops;
bool _has_derived_oops;

address data_addr() const { return (address) this + sizeof(ImmutableOopMap); }
public:
ImmutableOopMap(const OopMap* oopmap);

int count() const { return _count; }
int num_oops() const { return _num_oops; }
bool has_derived_oops() const { return _has_derived_oops; }
bool has_any(OopMapValue::oop_types type) const;

#ifdef ASSERT
@@ -320,17 +320,23 @@ void InstanceStackChunkKlass::fix_frame(const StackChunkFrameStream<mixed>& f, c

run_nmethod_entry_barrier_if_needed<mixed>(f);

if (UseZGC || UseShenandoahGC) {
RelativizeDerivedPointers<true> derived_closure;
f.iterate_derived_pointers(&derived_closure, map);
assert (!f.is_compiled() || f.oopmap()->has_derived_oops() == f.oopmap()->has_any(OopMapValue::derived_oop_value), "");
bool has_derived = f.is_compiled() && f.oopmap()->has_derived_oops();
if (has_derived) {
if (UseZGC || UseShenandoahGC) {
RelativizeDerivedPointers<true> derived_closure;
f.iterate_derived_pointers(&derived_closure, map);
}
}

BarrierClosure<store> oops_closure(f.sp());
f.iterate_oops(&oops_closure, map);
OrderAccess::loadload(); // observing the barriers will prevent derived pointers from being derelativized concurrently

DerelativizeDerivedPointers derived_closure;
f.iterate_derived_pointers(&derived_closure, map);
if (has_derived) {
DerelativizeDerivedPointers derived_closure;
f.iterate_derived_pointers(&derived_closure, map);
}
}

template void InstanceStackChunkKlass::fix_frame<true, false>(const StackChunkFrameStream<true >& f, const RegisterMap* map);
@@ -934,12 +934,15 @@ class OopOopIterateStackClosure {
}

if (_do_destructive_processing) { // evacuation always takes place at a safepoint; for concurrent iterations, we skip derived pointers, which is ok b/c coarse card marking is used for chunks
if (concurrent_gc) {
_chunk->set_gc_mode(true);
OrderAccess::storestore(); // if you see any following writes, you'll see this
assert (!f.is_compiled() || f.oopmap()->has_derived_oops() == f.oopmap()->has_any(OopMapValue::derived_oop_value), "");
if (f.is_compiled() && f.oopmap()->has_derived_oops()) {
if (concurrent_gc) {
_chunk->set_gc_mode(true);
OrderAccess::storestore(); // if you see any following writes, you'll see this
}
RelativizeDerivedPointers<concurrent_gc> derived_closure;
f.iterate_derived_pointers(&derived_closure, map);
}
RelativizeDerivedPointers<concurrent_gc> derived_closure;
f.iterate_derived_pointers(&derived_closure, map);
}

CheckMutationWrapper<OopClosureType> cl(_closure, _chunk);
@@ -378,11 +378,13 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
#endif

#ifdef ASSERT
bool has_derived_oops = false;
for( OopMapStream oms1(omap); !oms1.is_done(); oms1.next()) {
OopMapValue omv1 = oms1.current();
if (omv1.type() != OopMapValue::derived_oop_value) {
continue;
}
has_derived_oops = true;
bool found = false;
for( OopMapStream oms2(omap); !oms2.is_done(); oms2.next()) {
OopMapValue omv2 = oms2.current();
@@ -394,6 +396,7 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
break;
}
}
assert(has_derived_oops == omap->has_derived_oops(), "");
assert( found, "derived with no base in oopmap" );
}

0 comments on commit 5cd6ee4

Please sign in to comment.