diff --git a/src/share/vm/opto/runtime.cpp b/src/share/vm/opto/runtime.cpp index 46c90f49fd92c66d1b83af63782a58affcdfb1d8..b97f06a024fe60cae180cd1216ec54e9d37a12d3 100644 --- a/src/share/vm/opto/runtime.cpp +++ b/src/share/vm/opto/runtime.cpp @@ -338,6 +338,24 @@ JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(klassOopDesc* array_type, // inform GC that we won't do card marks for initializing writes. new_store_pre_barrier(thread); } + + oop result = thread->vm_result(); + if ((len > 0) && (result != NULL) && + is_deoptimized_caller_frame(thread)) { + // Zero array here if the caller is deoptimized. + int size = ((typeArrayOop)result)->object_size(); + BasicType elem_type = typeArrayKlass::cast(array_type)->element_type(); + const size_t hs = arrayOopDesc::header_size(elem_type); + // Align to next 8 bytes to avoid trashing arrays's length. + const size_t aligned_hs = align_object_offset(hs); + HeapWord* obj = (HeapWord*)result; + if (aligned_hs > hs) { + Copy::zero_to_words(obj+hs, aligned_hs-hs); + } + // Optimized zeroing. + Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs); + } + JRT_END // Note: multianewarray for one dimension is handled inline by GraphKit::new_array. @@ -1136,6 +1154,16 @@ void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) { } +bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) { + // Called from within the owner thread, so no need for safepoint + RegisterMap reg_map(thread); + frame stub_frame = thread->last_frame(); + assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check"); + frame caller_frame = stub_frame.sender(®_map); + return caller_frame.is_deoptimized_frame(); +} + + const TypeFunc *OptoRuntime::register_finalizer_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1); diff --git a/src/share/vm/opto/runtime.hpp b/src/share/vm/opto/runtime.hpp index f2c538b00753567df18e365f1f8743616f21bb5a..39702980597c8fd070c9274f32a07c963a2f910d 100644 --- a/src/share/vm/opto/runtime.hpp +++ b/src/share/vm/opto/runtime.hpp @@ -175,6 +175,7 @@ private: static address handle_exception_C_helper(JavaThread* thread, nmethod*& nm); static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc ); static void deoptimize_caller_frame (JavaThread *thread, bool doit); + static bool is_deoptimized_caller_frame (JavaThread *thread); // CodeBlob support // ===================================================================