--- old/src/hotspot/share/opto/library_call.cpp 2018-07-25 11:31:27.161916789 +0100 +++ new/src/hotspot/share/opto/library_call.cpp 2018-07-25 11:31:26.881915953 +0100 @@ -252,6 +252,8 @@ static bool klass_needs_init_guard(Node* kls); bool inline_unsafe_allocate(); bool inline_unsafe_newArray(bool uninitialized); + bool inline_unsafe_writeback0(); + bool inline_unsafe_writebackSync0(bool isPre); bool inline_unsafe_copyMemory(); bool inline_native_currentThread(); @@ -750,6 +752,9 @@ #endif case vmIntrinsics::_currentTimeMillis: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeMillis), "currentTimeMillis"); case vmIntrinsics::_nanoTime: return inline_native_time_funcs(CAST_FROM_FN_PTR(address, os::javaTimeNanos), "nanoTime"); + case vmIntrinsics::_writeback0: return inline_unsafe_writeback0(); + case vmIntrinsics::_writebackPreSync0: return inline_unsafe_writebackSync0(true); + case vmIntrinsics::_writebackPostSync0: return inline_unsafe_writebackSync0(false); case vmIntrinsics::_allocateInstance: return inline_unsafe_allocate(); case vmIntrinsics::_copyMemory: return inline_unsafe_copyMemory(); case vmIntrinsics::_getLength: return inline_native_getLength(); @@ -2754,6 +2759,55 @@ return !ik->is_initialized(); } +//----------------------------inline_unsafe_writeback0------------------------- +// public native void Unsafe.writeback0(long address) +bool LibraryCallKit::inline_unsafe_writeback0() { + if (!Matcher::has_match_rule(Op_CacheWB)) { + return false; + } +#ifndef PRODUCT + assert(Matcher::has_match_rule(Op_CacheWBPreSync), "found match rule for CacheWB but not CacheWBPreSync"); + assert(Matcher::has_match_rule(Op_CacheWBPostSync), "found match rule for CacheWB but not CacheWBPostSync"); + ciSignature* sig = callee()->signature(); + assert(sig->type_at(0)->basic_type() == T_LONG, "Unsafe_writeback0 address is long!"); +#endif + null_check_receiver(); // null-check, then ignore + Node *addr = argument(1); + addr = new CastX2PNode(addr); + addr = _gvn.transform(addr); + Node *flush = new CacheWBNode(control(), memory(TypeRawPtr::BOTTOM), addr); + flush = _gvn.transform(flush); + set_memory(flush, TypeRawPtr::BOTTOM); + return true; +} + +//----------------------------inline_unsafe_writeback0------------------------- +// public native void Unsafe.writeback0(long address) +bool LibraryCallKit::inline_unsafe_writebackSync0(bool isPre) { + if (isPre && !Matcher::has_match_rule(Op_CacheWBPreSync)) { + return false; + } + if (!isPre && !Matcher::has_match_rule(Op_CacheWBPostSync)) { + return false; + } +#ifndef PRODUCT + assert(Matcher::has_match_rule(Op_CacheWB), + (isPre ? "found match rule for CacheWBPreSync but not CacheWB" + : "found match rule for CacheWBPostSync but not CacheWB")); + +#endif + null_check_receiver(); // null-check, then ignore + Node *sync; + if (isPre) { + sync = new CacheWBPreSyncNode(control(), memory(TypeRawPtr::BOTTOM)); + } else { + sync = new CacheWBPostSyncNode(control(), memory(TypeRawPtr::BOTTOM)); + } + sync = _gvn.transform(sync); + set_memory(sync, TypeRawPtr::BOTTOM); + return true; +} + //----------------------------inline_unsafe_allocate--------------------------- // public native Object Unsafe.allocateInstance(Class cls); bool LibraryCallKit::inline_unsafe_allocate() {