# HG changeset patch # User Christos Kotselidis # Date 1381878767 -7200 # Node ID 43e0044612485e5913d8ded08dba1a4ff0ba79ab # Parent 90f3c090a002ea3a114b1ba774f1cf3f462794a8# Parent 90494fdf11c809c112e8a8613015765bdd1871cf Merge diff -r 90494fdf11c8 -r 43e004461248 src/share/vm/graal/graalGlobals.hpp --- a/src/share/vm/graal/graalGlobals.hpp Tue Oct 15 23:06:27 2013 +0200 +++ b/src/share/vm/graal/graalGlobals.hpp Wed Oct 16 01:12:47 2013 +0200 @@ -55,7 +55,7 @@ product(intx, TraceGraal, 0, \ "Trace level for Graal") \ \ - product(bool, GraalDeferredInitBarriers, false, \ + product(bool, GraalDeferredInitBarriers, true, \ "Defer write barriers of young objects") \ \ develop(bool, GraalUseFastLocking, true, \ diff -r 90494fdf11c8 -r 43e004461248 src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Tue Oct 15 23:06:27 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.cpp Wed Oct 16 01:12:47 2013 +0200 @@ -56,7 +56,8 @@ } } -JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) +JRT_BLOCK_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) + JRT_BLOCK; assert(klass->is_klass(), "not a class"); instanceKlassHandle h(thread, klass); h->check_valid_for_instantiation(true, CHECK); @@ -64,13 +65,16 @@ h->initialize(CHECK); // allocate instance and return via TLS oop obj = h->allocate_instance(CHECK); + thread->set_vm_result(obj); + JRT_BLOCK_END; + if (GraalDeferredInitBarriers) { - obj = Universe::heap()->new_store_pre_barrier(thread, obj); + new_store_pre_barrier(thread); } - thread->set_vm_result(obj); JRT_END -JRT_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) +JRT_BLOCK_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) + JRT_BLOCK; // Note: no handle for klass needed since they are not used // anymore after new_objArray() and no GC can happen before. // (This may have to change if this code changes!) @@ -83,9 +87,6 @@ Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); obj = oopFactory::new_objArray(elem_klass, length, CHECK); } - if (GraalDeferredInitBarriers) { - obj = Universe::heap()->new_store_pre_barrier(thread, obj); - } thread->set_vm_result(obj); // This is pretty rare but this runtime patch is stressful to deoptimization // if we deoptimize here so force a deopt to stress the path. @@ -99,8 +100,30 @@ deopt_caller(); } } + JRT_BLOCK_END; + + if (GraalDeferredInitBarriers) { + new_store_pre_barrier(thread); + } JRT_END +void GraalRuntime::new_store_pre_barrier(JavaThread* thread) { + // After any safepoint, just before going back to compiled code, + // we inform the GC that we will be doing initializing writes to + // this object in the future without emitting card-marks, so + // GC may take any compensating steps. + // NOTE: Keep this code consistent with GraphKit::store_barrier. + + oop new_obj = thread->vm_result(); + if (new_obj == NULL) return; + + assert(Universe::heap()->can_elide_tlab_store_barriers(), + "compiler must check this first"); + // GC may decide to give back a safer copy of new_obj. + new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj); + thread->set_vm_result(new_obj); +} + JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) assert(klass->is_klass(), "not a class"); assert(rank >= 1, "rank must be nonzero"); diff -r 90494fdf11c8 -r 43e004461248 src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Tue Oct 15 23:06:27 2013 +0200 +++ b/src/share/vm/graal/graalRuntime.hpp Wed Oct 16 01:12:47 2013 +0200 @@ -56,6 +56,7 @@ static void write_barrier_pre(JavaThread* thread, oopDesc* obj); static void write_barrier_post(JavaThread* thread, void* card); static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child); + static void new_store_pre_barrier(JavaThread* thread); }; #endif // SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP