changeset 198:16583c0781de

Blackhole: accept long overflow in consume(L) and consume(L[). Saves up one branch, which may explain some jitter in the generated code performance.
author shade
date Wed, 09 Oct 2013 15:19:30 +0400
parents a06bc28a0a73
children ca90e70f3831
files jmh-core/src/main/java/org/openjdk/jmh/logic/BlackHole.java jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java
diffstat 2 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/logic/BlackHole.java	Tue Oct 08 17:08:09 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/logic/BlackHole.java	Wed Oct 09 15:19:30 2013 +0400
@@ -213,9 +213,7 @@
         this.tlr = (tlr * 0x5DEECE66DL + 0xBL) & (0xFFFFFFFFFFFFL);
         if ((tlr & tlrMask) == 0) {
             // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT
-            if (tlrMask != 0x7FFFFFFFFFFFFFFFL) {
-                this.tlrMask = (tlrMask << 1) + 1;
-            }
+            this.tlrMask = (tlrMask << 1) + 1;
             this.obj1 = obj;
         }
     }
@@ -233,9 +231,7 @@
         this.tlr = (tlr * 0x5DEECE66DL + 0xBL) & (0xFFFFFFFFFFFFL);
         if ((tlr & tlrMask) == 0) {
             // SHOULD ALMOST NEVER HAPPEN IN MEASUREMENT
-            if (tlrMask != 0x7FFFFFFFFFFFFFFFL) {
-                this.tlrMask = (tlrMask << 1) + 1;
-            }
+            this.tlrMask = (tlrMask << 1) + 1;
             this.objs1 = objs;
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core/src/test/java/org/openjdk/jmh/BlackholeTest.java	Wed Oct 09 15:19:30 2013 +0400
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. 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.jmh;
+
+import org.junit.Test;
+
+public class BlackholeTest {
+
+    @Test
+    public void test() {
+        long tlr = 0;
+        for (int t = 0; t < 1000; t++) {
+            tlr = (tlr << 1) + 1;
+            System.out.println(tlr);
+        }
+    }
+
+}