Mercurial > hg > gc-bench
view src/main/java/org/openjdk/gcbench/runtime/writes/WriteBarriersKnownNull.java @ 88:583fef4276f5
Update license and copyright headers.
author | shade |
---|---|
date | Wed, 22 Nov 2017 15:58:02 +0100 |
parents | f8496889e1ac |
children |
line wrap: on
line source
/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.gcbench.runtime.writes; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Threads(1) @State(Scope.Thread) public class WriteBarriersKnownNull { Target target; @Setup public void setup() { target = new Target(); } @Benchmark @CompilerControl(CompilerControl.Mode.DONT_INLINE) public void test() { target.field = null; } static class Target { Object field; } /* i7 4790K, 4.0 Ghz, Linux x86_64, JDK 9 (Shenandoah, 2016-09-05) Benchmark Mode Cnt Score Error Units # Shenandoah WriteBarriersKnownNull.test avgt 25 2.637 ± 0.027 ns/op # G1 WriteBarriersKnownNull.test avgt 25 1.958 ± 0.006 ns/op # Parallel WriteBarriersKnownNull.test avgt 25 1.832 ± 0.097 ns/op Mostly the same as the regular barrier, plus the optimized out redundant nullchecks for stored value. Shenandoah: [Verified Entry Point] 9.60% 11.27% 0x00007f7031af6f40: mov %eax,-0x14000(%rsp) 0.02% 0x00007f7031af6f47: push %rbp 0x00007f7031af6f48: sub $0x10,%rsp 10.13% 10.60% 0x00007f7031af6f4c: mov -0x8(%rsi),%r10 ; <--- read barrier 0.02% 0x00007f7031af6f50: mov 0xc(%r10),%r11d ; get field $target 0.07% 0x00007f7031af6f54: test %r11d,%r11d ; null check $target <--- NOT IMPLICIT 0x00007f7031af6f57: je 0x00007f7031af6fc7 9.91% 10.59% 0x00007f7031af6f59: mov %r11,%r10 0x00007f7031af6f5c: mov -0x8(%r10),%rbx ; <--- read barrier AGAIN 0.18% 0.12% 0x00007f7031af6f60: cmpb $0x0,0x3d8(%r15) ; "evacuation in progress?" 0.02% 0x00007f7031af6f68: mov -0x8(%r10),%rbx ; <--- read barrier (in sequence) 10.08% 8.85% ╭ 0x00007f7031af6f6c: je 0x00007f7031af6f79 ; no evacuation in progress, jump over <--- SHOULD BE MOVED TO SLOWPATH │ 0x00007f7031af6f6e: xchg %rax,%rbx │ 0x00007f7031af6f71: callq Stub::shenandoah_wb │ 0x00007f7031af6f76: xchg %rax,%rbx ↘ 0x00007f7031af6f79: movsbl 0x378(%r15),%r11d ; SATB test 0x00007f7031af6f81: test %r11d,%r11d ╭ 0x00007f7031af6f84: jne 0x00007f7031af6f96 │↗ 0x00007f7031af6f86: mov %r12d,0xc(%rbx) ; field store 25.14% 22.09% ││ 0x00007f7031af6f8a: add $0x10,%rsp ││ 0x00007f7031af6f8e: pop %rbp ││ 0x00007f7031af6f8f: test %eax,0x1286706b(%rip) ││ 0x00007f7031af6f95: retq G1: [Verified Entry Point] 7.45% 6.58% 0x00007f3204840cc0: mov %eax,-0x14000(%rsp) 5.74% 6.06% 0x00007f3204840cc7: push %rbp 7.74% 7.35% 0x00007f3204840cc8: sub $0x10,%rsp 0.18% 0.18% 0x00007f3204840ccc: mov 0xc(%rsi),%ebp ; get field $target 5.84% 6.56% 0x00007f3204840ccf: mov 0xc(%rbp),%r10d ; <--- read old for SATB, plus NPE check 18.27% 20.87% 0x00007f3204840cd3: movsbl 0x378(%r15),%r8d ; SATB test 0.02% 0.02% 0x00007f3204840cdb: test %r8d,%r8d ╭ 0x00007f3204840cde: jne 0x00007f3204840cf0 │↗ 0x00007f3204840ce0: mov %r12d,0xc(%rbp) ; field store 4.11% 4.73% ││ 0x00007f3204840ce4: add $0x10,%rsp 9.60% 10.33% ││ 0x00007f3204840ce8: pop %rbp 0.30% 0.33% ││ 0x00007f3204840ce9: test %eax,0x11f29311(%rip) 0.02% ││ 0x00007f3204840cef: retq */ }