--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Wed Jun 04 13:51:09 2008 -0700
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Thu Jun 05 15:57:56 2008 -0700
@@ -86,14 +86,18 @@
const size_t word_len = objArrayOopDesc::array_size(length);
- // For performance reasons, we assume we are using a card marking write
- // barrier. The assert will fail if this is not the case.
BarrierSet* bs = Universe::heap()->barrier_set();
+ // For performance reasons, we assume we are that the write barrier we
+ // are using has optimized modes for arrays of references. At least one
+ // of the asserts below will fail if this is not the case.
assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
+ assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
+ MemRegion dst_mr = MemRegion((HeapWord*)dst, word_len);
if (s == d) {
// since source and destination are equal we do not need conversion checks.
assert(length > 0, "sanity check");
+ bs->write_ref_array_pre(dst_mr);
Copy::conjoint_oops_atomic(src, dst, length);
} else {
// We have to make sure all elements conform to the destination array
@@ -101,6 +105,7 @@
klassOop stype = objArrayKlass::cast(s->klass())->element_klass();
if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
// elements are guaranteed to be subtypes, so no check necessary
+ bs->write_ref_array_pre(dst_mr);
Copy::conjoint_oops_atomic(src, dst, length);
} else {
// slow case: need individual subtype checks
@@ -110,8 +115,13 @@
for (T* p = dst; from < end; from++, p++) {
// XXX this is going to be slow.
T element = *from;
- if (oopDesc::is_null(element) ||
- Klass::cast(oopDesc::decode_heap_oop_not_null(element)->klass())->is_subtype_of(bound)) {
+ // even slower now
+ bool element_is_null = oopDesc::is_null(element);
+ oop new_val = element_is_null ? oop(NULL)
+ : oopDesc::decode_heap_oop_not_null(element);
+ if (element_is_null ||
+ Klass::cast((new_val->klass()))->is_subtype_of(bound)) {
+ bs->write_ref_field_pre(p, new_val);
*p = *from;
} else {
// We must do a barrier to cover the partial copy.
@@ -401,11 +411,11 @@
}
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
-ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
+ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN)
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
-ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
+ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_m)
ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
-ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
+ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DEFN_r)
int objArrayKlass::oop_adjust_pointers(oop obj) {
assert(obj->is_objArray(), "obj must be obj array");