changeset 384:f2e982b7c51b

Force inline @GMB should only work if no explicit annotation is used.
author shade
date Fri, 31 Jan 2014 12:46:38 +0400
parents 004bc63876c5
children 55a0d7fe2040
files jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineTest.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/CompilerControlProcessor.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java
diffstat 5 files changed, 33 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineTest.java	Tue Jan 28 23:39:50 2014 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlDontInlineTest.java	Fri Jan 31 12:46:38 2014 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.it.ccontrol;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.CompilerControl;
@@ -33,6 +34,7 @@
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Warmup;
 import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.CompilerHints;
 import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.RunnerException;
 import org.openjdk.jmh.runner.options.Options;
@@ -59,6 +61,12 @@
                 .shouldFailOnError(true)
                 .build();
         new Runner(opt).run();
+
+        for (String s : CompilerHints.defaultList().get()) {
+            if (s.contains(this.getClass().getName().replace(".", "/"))) {
+                Assert.assertTrue(s, s.startsWith("dontinline"));
+            }
+        }
     }
 
 }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeTest.java	Tue Jan 28 23:39:50 2014 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlExcludeTest.java	Fri Jan 31 12:46:38 2014 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.it.ccontrol;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.CompilerControl;
@@ -33,6 +34,7 @@
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Warmup;
 import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.CompilerHints;
 import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.RunnerException;
 import org.openjdk.jmh.runner.options.Options;
@@ -59,6 +61,12 @@
                 .shouldFailOnError(true)
                 .build();
         new Runner(opt).run();
+
+        for (String s : CompilerHints.defaultList().get()) {
+            if (s.contains(this.getClass().getName().replace(".", "/"))) {
+                Assert.assertTrue(s, s.startsWith("exclude"));
+            }
+        }
     }
 
 }
--- a/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineTest.java	Tue Jan 28 23:39:50 2014 +0400
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/ccontrol/CompilerControlInlineTest.java	Fri Jan 31 12:46:38 2014 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.it.ccontrol;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.CompilerControl;
@@ -33,6 +34,7 @@
 import org.openjdk.jmh.annotations.Mode;
 import org.openjdk.jmh.annotations.Warmup;
 import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.runner.CompilerHints;
 import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.RunnerException;
 import org.openjdk.jmh.runner.options.Options;
@@ -59,6 +61,12 @@
                 .shouldFailOnError(true)
                 .build();
         new Runner(opt).run();
+
+        for (String s : CompilerHints.defaultList().get()) {
+            if (s.contains(this.getClass().getName().replace(".", "/"))) {
+                Assert.assertTrue(s, s.startsWith("inline"));
+            }
+        }
     }
 
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/CompilerControlProcessor.java	Tue Jan 28 23:39:50 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/CompilerControlProcessor.java	Fri Jan 31 12:46:38 2014 +0400
@@ -41,10 +41,10 @@
 public class CompilerControlProcessor implements SubProcessor {
 
     private final List<String> lines = new ArrayList<String>();
-    private final List<Element> forceInline = new ArrayList<Element>();
+    private final List<Element> defaultForceInline = new ArrayList<Element>();
 
-    public void forceInline(Element element) {
-        forceInline.add(element);
+    public void defaultForceInline(Element element) {
+        defaultForceInline.add(element);
     }
 
     public void process(RoundEnvironment roundEnv, ProcessingEnvironment processingEnv) {
@@ -59,7 +59,8 @@
                 addLine(processingEnv, element, command);
             }
 
-            for (Element element : forceInline) {
+            for (Element element : defaultForceInline) {
+                if (element.getAnnotation(CompilerControl.class) != null) continue;
                 addLine(processingEnv, element, CompilerControl.Mode.INLINE);
             }
         } catch (Throwable t) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Tue Jan 28 23:39:50 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Fri Jan 31 12:46:38 2014 +0400
@@ -625,7 +625,7 @@
         boolean isSingleMethod = (methodGroup.methods().size() == 1);
         int subGroup = -1;
         for (Element method : methodGroup.methods()) {
-            compilerControl.forceInline(method);
+            compilerControl.defaultForceInline(method);
 
             subGroup++;
 
@@ -724,7 +724,7 @@
         boolean isSingleMethod = (methodGroup.methods().size() == 1);
         int subGroup = -1;
         for (Element method : methodGroup.methods()) {
-            compilerControl.forceInline(method);
+            compilerControl.defaultForceInline(method);
 
             subGroup++;
 
@@ -834,7 +834,7 @@
         boolean isSingleMethod = (methodGroup.methods().size() == 1);
         int subGroup = -1;
         for (Element method : methodGroup.methods()) {
-            compilerControl.forceInline(method);
+            compilerControl.defaultForceInline(method);
 
             subGroup++;
 
@@ -944,7 +944,7 @@
         boolean isSingleMethod = (methodGroup.methods().size() == 1);
         int subGroup = -1;
         for (Element method : methodGroup.methods()) {
-            compilerControl.forceInline(method);
+            compilerControl.defaultForceInline(method);
 
             subGroup++;