src/share/vm/gc_implementation/g1/bufferingOopClosure.hpp
Print this page
@@ -24,10 +24,11 @@
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_BUFFERINGOOPCLOSURE_HPP
#define SHARE_VM_GC_IMPLEMENTATION_G1_BUFFERINGOOPCLOSURE_HPP
#include "memory/iterator.hpp"
+#include "oops/oopsHierarchy.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
// A BufferingOops closure tries to separate out the cost of finding roots
// from the cost of applying closures to them. It maintains an array of
@@ -43,15 +44,19 @@
class BufferingOopClosure: public OopClosure {
friend class TestBufferingOopClosure;
protected:
static const size_t BufferLength = 1024;
- // The full-sized oops are filled in from the bottom,
- // while the narrowOops are filled in from the top.
- void* _buffer[BufferLength];
- void** _oop_top;
- void** _narrowOop_bottom;
+ // We need to know if the buffered addresses contain oops or narrowOops.
+ // We can't tag the addresses the way StarTask does, because we need to
+ // be able to handle unaligned addresses coming from oops embedded in code.
+ //
+ // The addresses for the full-sized oops are filled in from the bottom,
+ // while the addresses for the narrowOops are filled in from the top.
+ OopOrNarrowOopStar _buffer[BufferLength];
+ OopOrNarrowOopStar* _oop_top;
+ OopOrNarrowOopStar* _narrowOop_bottom;
OopClosure* _oc;
double _closure_app_seconds;
@@ -63,19 +68,19 @@
return _narrowOop_bottom < _oop_top;
}
// Process addresses containing full-sized oops.
void process_oops() {
- for (void** curr = _buffer; curr < _oop_top; ++curr) {
+ for (OopOrNarrowOopStar* curr = _buffer; curr < _oop_top; ++curr) {
_oc->do_oop((oop*)(*curr));
}
_oop_top = _buffer;
}
// Process addresses containing narrow oops.
void process_narrowOops() {
- for (void** curr = _buffer + BufferLength - 1; curr > _narrowOop_bottom; --curr) {
+ for (OopOrNarrowOopStar* curr = _buffer + BufferLength - 1; curr > _narrowOop_bottom; --curr) {
_oc->do_oop((narrowOop*)(*curr));
}
_narrowOop_bottom = _buffer + BufferLength - 1;
}
@@ -96,17 +101,17 @@
}
}
void add_narrowOop(narrowOop* p) {
assert(!is_buffer_full(), "Buffer should not be full");
- *_narrowOop_bottom = (void*)p;
+ *_narrowOop_bottom = (OopOrNarrowOopStar)p;
_narrowOop_bottom--;
}
void add_oop(oop* p) {
assert(!is_buffer_full(), "Buffer should not be full");
- *_oop_top = (void*)p;
+ *_oop_top = (OopOrNarrowOopStar)p;
_oop_top++;
}
public:
virtual void do_oop(narrowOop* p) {