src/cpu/x86/vm/x86_32.ad

Print this page
rev 3419 : 7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
Summary: use shorter instruction sequences for atomic add and atomic exchange when possible.
Reviewed-by:

*** 1375,1384 **** --- 1375,1387 ---- switch (opcode) { case Op_PopCountI: case Op_PopCountL: if (!UsePopCountInstruction) return false; + case Op_CompareAndSwapL: + if (!VM_Version::supports_cx8()) + return false; break; } return true; // Per default match rules are supported. }
*** 7787,7796 **** --- 7790,7800 ---- %} // No flag versions for CompareAndSwap{P,I,L} because matcher can't match them instruct compareAndSwapL( rRegI res, eSIRegP mem_ptr, eADXRegL oldval, eBCXRegL newval, eFlagsReg cr ) %{ + predicate(VM_Version::supports_cx8()); match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval))); effect(KILL cr, KILL oldval); format %{ "CMPXCHG8 [$mem_ptr],$newval\t# If EDX:EAX==[$mem_ptr] Then store $newval into [$mem_ptr]\n\t" "MOV $res,0\n\t" "JNE,s fail\n\t"
*** 7823,7832 **** --- 7827,7877 ---- "fail:" %} ins_encode( enc_cmpxchg(mem_ptr), enc_flags_ne_to_boolean(res) ); ins_pipe( pipe_cmpxchg ); %} + instruct xaddI_no_res( memory mem, Universe dummy, immI add, eFlagsReg cr) %{ + predicate(n->as_LoadStore()->result_not_used()); + match(Set dummy (GetAndAddI mem add)); + effect(KILL cr); + format %{ "ADDL [$mem],$add" %} + ins_encode %{ + if (os::is_MP()) { __ lock(); } + __ addl($mem$$Address, $add$$constant); + %} + ins_pipe( pipe_cmpxchg ); + %} + + instruct xaddI( memory mem, rRegI newval, eFlagsReg cr) %{ + match(Set newval (GetAndAddI mem newval)); + effect(KILL cr); + format %{ "XADDL [$mem],$newval" %} + ins_encode %{ + if (os::is_MP()) { __ lock(); } + __ xaddl($mem$$Address, $newval$$Register); + %} + ins_pipe( pipe_cmpxchg ); + %} + + instruct xchgI( memory mem, rRegI newval) %{ + match(Set newval (GetAndSetI mem newval)); + format %{ "XCHGL $newval,[$mem]" %} + ins_encode %{ + __ xchgl($newval$$Register, $mem$$Address); + %} + ins_pipe( pipe_cmpxchg ); + %} + + instruct xchgP( memory mem, pRegP newval) %{ + match(Set newval (GetAndSetP mem newval)); + format %{ "XCHGL $newval,[$mem]" %} + ins_encode %{ + __ xchgl($newval$$Register, $mem$$Address); + %} + ins_pipe( pipe_cmpxchg ); + %} + //----------Subtraction Instructions------------------------------------------- // Integer Subtraction Instructions instruct subI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{ match(Set dst (SubI dst src)); effect(KILL cr);