comparison src/cpu/x86/vm/x86_64.ad @ 6795:7eca5de9e0b6

7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement() Summary: use shorter instruction sequences for atomic add and atomic exchange when possible. Reviewed-by: kvn, jrose
author roland
date Thu, 20 Sep 2012 16:49:17 +0200
parents da91efe96a93
children 8e47bac5643a
comparison
equal deleted inserted replaced
6794:8ae8f9dd7099 6795:7eca5de9e0b6
7240 instruct compareAndSwapP(rRegI res, 7240 instruct compareAndSwapP(rRegI res,
7241 memory mem_ptr, 7241 memory mem_ptr,
7242 rax_RegP oldval, rRegP newval, 7242 rax_RegP oldval, rRegP newval,
7243 rFlagsReg cr) 7243 rFlagsReg cr)
7244 %{ 7244 %{
7245 predicate(VM_Version::supports_cx8());
7245 match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval))); 7246 match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval)));
7246 effect(KILL cr, KILL oldval); 7247 effect(KILL cr, KILL oldval);
7247 7248
7248 format %{ "cmpxchgq $mem_ptr,$newval\t# " 7249 format %{ "cmpxchgq $mem_ptr,$newval\t# "
7249 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" 7250 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7263 instruct compareAndSwapL(rRegI res, 7264 instruct compareAndSwapL(rRegI res,
7264 memory mem_ptr, 7265 memory mem_ptr,
7265 rax_RegL oldval, rRegL newval, 7266 rax_RegL oldval, rRegL newval,
7266 rFlagsReg cr) 7267 rFlagsReg cr)
7267 %{ 7268 %{
7269 predicate(VM_Version::supports_cx8());
7268 match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval))); 7270 match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval)));
7269 effect(KILL cr, KILL oldval); 7271 effect(KILL cr, KILL oldval);
7270 7272
7271 format %{ "cmpxchgq $mem_ptr,$newval\t# " 7273 format %{ "cmpxchgq $mem_ptr,$newval\t# "
7272 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" 7274 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t"
7324 OpcP, OpcS, 7326 OpcP, OpcS,
7325 reg_mem(newval, mem_ptr), 7327 reg_mem(newval, mem_ptr),
7326 REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete 7328 REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete
7327 REX_reg_breg(res, res), // movzbl 7329 REX_reg_breg(res, res), // movzbl
7328 Opcode(0xF), Opcode(0xB6), reg_reg(res, res)); 7330 Opcode(0xF), Opcode(0xB6), reg_reg(res, res));
7331 ins_pipe( pipe_cmpxchg );
7332 %}
7333
7334 instruct xaddI_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{
7335 predicate(n->as_LoadStore()->result_not_used());
7336 match(Set dummy (GetAndAddI mem add));
7337 effect(KILL cr);
7338 format %{ "ADDL [$mem],$add" %}
7339 ins_encode %{
7340 if (os::is_MP()) { __ lock(); }
7341 __ addl($mem$$Address, $add$$constant);
7342 %}
7343 ins_pipe( pipe_cmpxchg );
7344 %}
7345
7346 instruct xaddI( memory mem, rRegI newval, rFlagsReg cr) %{
7347 match(Set newval (GetAndAddI mem newval));
7348 effect(KILL cr);
7349 format %{ "XADDL [$mem],$newval" %}
7350 ins_encode %{
7351 if (os::is_MP()) { __ lock(); }
7352 __ xaddl($mem$$Address, $newval$$Register);
7353 %}
7354 ins_pipe( pipe_cmpxchg );
7355 %}
7356
7357 instruct xaddL_no_res( memory mem, Universe dummy, immL add, rFlagsReg cr) %{
7358 predicate(n->as_LoadStore()->result_not_used());
7359 match(Set dummy (GetAndAddL mem add));
7360 effect(KILL cr);
7361 format %{ "ADDQ [$mem],$add" %}
7362 ins_encode %{
7363 if (os::is_MP()) { __ lock(); }
7364 __ addq($mem$$Address, $add$$constant);
7365 %}
7366 ins_pipe( pipe_cmpxchg );
7367 %}
7368
7369 instruct xaddL( memory mem, rRegL newval, rFlagsReg cr) %{
7370 match(Set newval (GetAndAddL mem newval));
7371 effect(KILL cr);
7372 format %{ "XADDQ [$mem],$newval" %}
7373 ins_encode %{
7374 if (os::is_MP()) { __ lock(); }
7375 __ xaddq($mem$$Address, $newval$$Register);
7376 %}
7377 ins_pipe( pipe_cmpxchg );
7378 %}
7379
7380 instruct xchgI( memory mem, rRegI newval) %{
7381 match(Set newval (GetAndSetI mem newval));
7382 format %{ "XCHGL $newval,[$mem]" %}
7383 ins_encode %{
7384 __ xchgl($newval$$Register, $mem$$Address);
7385 %}
7386 ins_pipe( pipe_cmpxchg );
7387 %}
7388
7389 instruct xchgL( memory mem, rRegL newval) %{
7390 match(Set newval (GetAndSetL mem newval));
7391 format %{ "XCHGL $newval,[$mem]" %}
7392 ins_encode %{
7393 __ xchgq($newval$$Register, $mem$$Address);
7394 %}
7395 ins_pipe( pipe_cmpxchg );
7396 %}
7397
7398 instruct xchgP( memory mem, rRegP newval) %{
7399 match(Set newval (GetAndSetP mem newval));
7400 format %{ "XCHGQ $newval,[$mem]" %}
7401 ins_encode %{
7402 __ xchgq($newval$$Register, $mem$$Address);
7403 %}
7404 ins_pipe( pipe_cmpxchg );
7405 %}
7406
7407 instruct xchgN( memory mem, rRegN newval) %{
7408 match(Set newval (GetAndSetN mem newval));
7409 format %{ "XCHGL $newval,$mem]" %}
7410 ins_encode %{
7411 __ xchgl($newval$$Register, $mem$$Address);
7412 %}
7329 ins_pipe( pipe_cmpxchg ); 7413 ins_pipe( pipe_cmpxchg );
7330 %} 7414 %}
7331 7415
7332 //----------Subtraction Instructions------------------------------------------- 7416 //----------Subtraction Instructions-------------------------------------------
7333 7417