I'm trying to copy all the object in the old heap to the new heap as below.
HeapWord* mark = _space->bottom();
HeapWord* nmark = _nspace->bottom();
HeapWord* cond = _space->top();
while(mark < cond){
oop old_obj = oop(mark);
if(oop(mark)->getUsed() == 1){
memcpy(nmark,mark,oop(mark)->size());
oop new_obj = oop(nmark);
nmark += new_obj->size();
_nspace->set_top(nmark);
}
mark += oop(mark)->size();
}
And the structure oop is as below.
typedef class oopDesc* oop;
class oopDesc {
int used;
volatile markOop _mark;
union _metadata {
Klass* _klass;
narrowKlass _compressed_klass;
} _metadata;
....
//Rest of the functions
....
}
After copying, the contents of the old_obj and new_obj are as below.
How to copy the whole contents of the structure including the contents of the union?.