changeset 295:6c41487eb634

Prohibit inlining of synthetic microbenchmark methods, thus breaking possible unlucky loop optimizations.
author shade
date Tue, 03 Dec 2013 16:40:23 +0400
parents 56522f915974
children 1098723eff36
files jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Tue Dec 03 14:01:58 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Tue Dec 03 16:40:23 2013 +0400
@@ -25,6 +25,7 @@
 package org.openjdk.jmh.processor.internal;
 
 import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.CompilerControl;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.Group;
@@ -335,7 +336,11 @@
             writer.println();
 
             generateImport(writer);
+
             // Write class header
+            writer.println("@" + CompilerControl.class.getSimpleName() +
+                    "(" + CompilerControl.class.getSimpleName() + "." + CompilerControl.Mode.class.getSimpleName() +
+                    "." + CompilerControl.Mode.DONT_INLINE + ")");
             writer.println("@Generated(\"" + GenerateMicroBenchmarkProcessor.class.getCanonicalName() + "\")");
             writer.println("public final class " + info.generatedClassName + " {");
             writer.println();
@@ -466,6 +471,7 @@
         writer.println("import " + Arrays.class.getName() + ';');
         writer.println("import " + TimeUnit.class.getName() + ';');
         writer.println("import " + Generated.class.getName() + ';');
+        writer.println("import " + CompilerControl.class.getName() + ';');
         writer.println();
         writer.println("import " + InfraControl.class.getName() + ';');
         writer.println("import " + ThreadControl.class.getName() + ';');