--- old/src/share/vm/opto/library_call.cpp 2016-02-25 01:11:14.782053900 +0300 +++ new/src/share/vm/opto/library_call.cpp 2016-02-25 01:11:14.734054122 +0300 @@ -244,6 +244,7 @@ bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, bool is_volatile, bool is_unaligned); static bool klass_needs_init_guard(Node* kls); bool inline_unsafe_allocate(); + bool inline_unsafe_newArray(bool uninit); bool inline_unsafe_copyMemory(); bool inline_native_currentThread(); #ifdef TRACE_HAVE_INTRINSICS @@ -254,8 +255,6 @@ bool inline_native_isInterrupted(); bool inline_native_Class_query(vmIntrinsics::ID id); bool inline_native_subtype_check(); - - bool inline_native_newArray(); bool inline_native_getLength(); bool inline_array_copyOf(bool is_copyOfRange); bool inline_array_equals(StrIntrinsicNode::ArgEnc ae); @@ -650,7 +649,8 @@ case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); case vmIntrinsics::_allocateInstance: return inline_unsafe_allocate(); case vmIntrinsics::_copyMemory: return inline_unsafe_copyMemory(); - case vmIntrinsics::_newArray: return inline_native_newArray(); + case vmIntrinsics::_allocateArrayUninit: return inline_unsafe_newArray(true); + case vmIntrinsics::_newArray: return inline_unsafe_newArray(false); case vmIntrinsics::_getLength: return inline_native_getLength(); case vmIntrinsics::_copyOf: return inline_array_copyOf(false); case vmIntrinsics::_copyOfRange: return inline_array_copyOf(true); @@ -3579,9 +3579,17 @@ //-----------------------inline_native_newArray-------------------------- // private static native Object java.lang.reflect.newArray(Class componentType, int length); -bool LibraryCallKit::inline_native_newArray() { - Node* mirror = argument(0); - Node* count_val = argument(1); +// private native Object Unsafe.allocateArrayUninit0(Class cls, int size); +bool LibraryCallKit::inline_unsafe_newArray(bool uninit) { + Node* mirror; + Node* count_val; + if (uninit) { + mirror = argument(1); + count_val = argument(2); + } else { + mirror = argument(0); + count_val = argument(1); + } mirror = null_check(mirror); // If mirror or obj is dead, only null-path is taken. @@ -3626,6 +3634,12 @@ result_val->init_req(_normal_path, obj); result_io ->init_req(_normal_path, i_o()); result_mem->init_req(_normal_path, reset_memory()); + + if (uninit) { + // Mark the allocation so that zeroing is skipped + AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(obj, &_gvn); + alloc->maybe_set_complete(&_gvn); + } } // Return the combined state.