changeset 7571:6078d41cecb2

Merge.
author Doug Simon <doug.simon@oracle.com>
date Wed, 30 Jan 2013 22:44:51 +0100
parents 2025455e7d80 (diff) dea5423a9479 (current diff)
children bbb2619857d4
files mx/sanitycheck.py
diffstat 8 files changed, 107 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Jan 30 16:46:15 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Jan 30 22:44:51 2013 +0100
@@ -36,6 +36,7 @@
     public boolean windowsOs;
     public int codeEntryAlignment;
     public boolean verifyOops;
+    public boolean ciTime;
     public boolean useFastLocking;
     public boolean useTLAB;
     public boolean useBiasedLocking;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Jan 30 16:46:15 2013 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Jan 30 22:44:51 2013 +0100
@@ -56,8 +56,6 @@
 
     private final HotSpotGraalRuntime graalRuntime;
 
-    private static final boolean BenchmarkCompilation = Boolean.getBoolean("graal.benchmark.compilation");
-
     public final HotSpotResolvedPrimitiveType typeBoolean;
     public final HotSpotResolvedPrimitiveType typeChar;
     public final HotSpotResolvedPrimitiveType typeFloat;
@@ -76,6 +74,8 @@
 
     private PrintStream log = System.out;
 
+    private boolean quietMeterAndTime;
+
     public VMToCompilerImpl(HotSpotGraalRuntime compiler) {
         this.graalRuntime = compiler;
 
@@ -98,7 +98,8 @@
 
     public void startCompiler() throws Throwable {
 
-        long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset;
+        HotSpotVMConfig config = graalRuntime.getConfig();
+        long offset = config.graalMirrorInClassOffset;
         initMirror(typeBoolean, offset);
         initMirror(typeChar, offset);
         initMirror(typeFloat, offset);
@@ -126,11 +127,11 @@
             }
         }
 
-        if (BenchmarkCompilation) {
+        if (config.ciTime) {
+            quietMeterAndTime = (GraalOptions.Meter == null && GraalOptions.Time == null);
             GraalOptions.Debug = true;
             GraalOptions.Meter = "";
             GraalOptions.Time = "";
-            GraalOptions.SummarizeDebugValues = true;
         }
 
         if (GraalOptions.Debug) {
@@ -203,7 +204,7 @@
      */
     protected void phaseTransition(String phase) {
         CompilationStatistics.clear(phase);
-        if (BenchmarkCompilation) {
+        if (graalRuntime.getConfig().ciTime) {
             parsedBytecodesPerSecond = MetricRateInPhase.snapshot(phase, parsedBytecodesPerSecond, BytecodesParsed, CompilationTime, TimeUnit.SECONDS);
             inlinedBytecodesPerSecond = MetricRateInPhase.snapshot(phase, inlinedBytecodesPerSecond, InlinedBytecodes, CompilationTime, TimeUnit.SECONDS);
         }
@@ -310,7 +311,7 @@
             CompilationTask.withinEnqueue.set(Boolean.FALSE);
         }
 
-        if (Debug.isEnabled()) {
+        if (Debug.isEnabled() && !quietMeterAndTime) {
             List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
             List<DebugValue> debugValues = KeyRegistry.getDebugValues();
             if (debugValues.size() > 0) {
@@ -345,7 +346,7 @@
         }
         phaseTransition("final");
 
-        if (BenchmarkCompilation) {
+        if (graalRuntime.getConfig().ciTime) {
             parsedBytecodesPerSecond.printAll("ParsedBytecodesPerSecond");
             inlinedBytecodesPerSecond.printAll("InlinedBytecodesPerSecond");
         }
--- a/mx/outputparser.py	Wed Jan 30 16:46:15 2013 +0100
+++ b/mx/outputparser.py	Wed Jan 30 22:44:51 2013 +0100
@@ -23,6 +23,8 @@
 #
 # ----------------------------------------------------------------------------------------------------
 
+import re
+
 class OutputParser:
     
     def __init__(self):
@@ -32,18 +34,17 @@
         self.matchers.append(matcher)
     
     def parse(self, output):
-        records = []
+        valueMaps = []
         for matcher in self.matchers:
-            record = matcher.parse(output)
-            if record:
-                records.append(record)
-        return records
+            matcher.parse(output, valueMaps)
+        return valueMaps
 
 """
-Produces some named values for some given text if it matches a given
-regular expression. The named values are specified by a dictionary
-where any keys or value may be expressed as named group in the
-regular expression. A named group is enclosed in '<' and '>'.
+Produces a value map for each match of a given regular expression
+in some text. The value map is specified by a template map
+where each key and value in the template map is either a constant
+value or a named group in the regular expression. The latter is
+given as the group name enclosed in '<' and '>'.
 """
 class ValuesMatcher:
     
@@ -52,21 +53,19 @@
         self.regex = regex
         self.valuesTemplate = valuesTemplate
         
-    def parse(self, text):
-        match = self.regex.search(text)
-        if not match:
-            return False
-        values = {}
-        for key, value in self.valuesTemplate.items():
-            values[self.get_template_value(match, key)] = self.get_template_value(match, value)
-                    
-        return values
-    
+    def parse(self, text, valueMaps):
+        for match in self.regex.finditer(text):
+            valueMap = {}
+            for keyTemplate, valueTemplate in self.valuesTemplate.items():
+                key = self.get_template_value(match, keyTemplate)
+                value = self.get_template_value(match, valueTemplate)
+                assert not valueMap.has_key(key), key
+                valueMap[key] = value
+            valueMaps.append(valueMap)
         
     def get_template_value(self, match, template):
-        if template.startswith('<'):
-            assert template.endswith('>')
-            groupName = template[1:-1]
+        def replace_var(m):
+            groupName = m.group(1)
             return match.group(groupName)
-        else:
-            return template
+        
+        return re.sub(r'<([\w]+)>', replace_var, template)
--- a/mx/sanitycheck.py	Wed Jan 30 16:46:15 2013 +0100
+++ b/mx/sanitycheck.py	Wed Jan 30 22:44:51 2013 +0100
@@ -224,8 +224,6 @@
         self.output.write(line)
         sys.stdout.write(line)
 
-_debugBenchParser = False
-      
 """
 Encapsulates a single program that is a sanity test and/or a benchmark.
 """
@@ -305,27 +303,41 @@
             parser.addMatcher(scoreMatcher)
 
         if self.benchmarkCompilationRate:
-            opts.append('-Dgraal.benchmark.compilation=true')
-            bps = re.compile(r"ParsedBytecodesPerSecond@final: (?P<rate>[0-9]+)")
-            ibps = re.compile(r"InlinedBytecodesPerSecond@final: (?P<rate>[0-9]+)")
-            parser.addMatcher(ValuesMatcher(bps, {'group' : 'ParsedBytecodesPerSecond', 'name' : self.name, 'score' : '<rate>'}))
-            parser.addMatcher(ValuesMatcher(ibps, {'group' : 'InlinedBytecodesPerSecond', 'name' : self.name, 'score' : '<rate>'}))
+            opts.append('-XX:+CITime')
+            if vm == 'graal':
+                bps = re.compile(r"ParsedBytecodesPerSecond@final: (?P<rate>[0-9]+)")
+                ibps = re.compile(r"InlinedBytecodesPerSecond@final: (?P<rate>[0-9]+)")
+                parser.addMatcher(ValuesMatcher(bps, {'group' : 'ParsedBytecodesPerSecond', 'name' : self.name, 'score' : '<rate>'}))
+                parser.addMatcher(ValuesMatcher(ibps, {'group' : 'InlinedBytecodesPerSecond', 'name' : self.name, 'score' : '<rate>'}))
+            else:
+                ibps = re.compile(r"(?P<compiler>[\w]+) compilation speed: +(?P<rate>[0-9]+) bytes/s {standard")
+                parser.addMatcher(ValuesMatcher(ibps, {'group' : 'InlinedBytecodesPerSecond', 'name' : '<compiler>:' + self.name, 'score' : '<rate>'}))
             
-        outputfile = self.name + '.output'
-        if _debugBenchParser and exists(outputfile):
+        startDelim = 'START: ' + self.name
+        endDelim = 'END: ' + self.name
+        
+        outputfile = os.environ.get('BENCH_OUTPUT', None)
+        if outputfile:
+            # Used only to debug output parsing
             with open(outputfile) as fp:
                 output = fp.read()
+                start = output.find(startDelim)
+                end = output.find(endDelim, start)
+                if start == -1 and end == -1:
+                    return {}
+                output = output[start + len(startDelim + os.linesep): end]
+                mx.log(startDelim)
                 mx.log(output)
+                mx.log(endDelim)
         else:
             tee = Tee()
+            mx.log(startDelim)
             if commands.vm(self.vmOpts + opts + self.cmd, vm, nonZeroIsFatal=False, out=tee.eat, err=subprocess.STDOUT, cwd=cwd, vmbuild=vmbuild) != 0:
                 mx.abort("Benchmark failed (non-zero retcode)")
+            mx.log(endDelim)
             output = tee.output.getvalue()
-            if _debugBenchParser:
-                with open(outputfile, 'wb') as fp:
-                    fp.write(output)
 
-        ret = {}
+        groups = {}
         passed = False
         for valueMap in parser.parse(output):
             assert (valueMap.has_key('name') and valueMap.has_key('score') and valueMap.has_key('group')) or valueMap.has_key('passed') or valueMap.has_key('failed'), valueMap
@@ -335,7 +347,7 @@
                 passed = True
             groupName = valueMap.get('group')
             if groupName:
-                group = ret.setdefault(groupName, {})
+                group = groups.setdefault(groupName, {})
                 name = valueMap.get('name')
                 score = valueMap.get('score')
                 if name and score:
@@ -344,4 +356,4 @@
         if not passed:
             mx.abort("Benchmark failed (not passed)")
         
-        return ret
+        return groups
--- a/src/share/vm/compiler/abstractCompiler.hpp	Wed Jan 30 16:46:15 2013 +0100
+++ b/src/share/vm/compiler/abstractCompiler.hpp	Wed Jan 30 22:44:51 2013 +0100
@@ -29,6 +29,17 @@
 
 typedef void (*initializer)(void);
 
+#ifdef GRAAL
+class CompilerStatistics {
+ public:
+  elapsedTimer _t_osr_compilation;
+  elapsedTimer _t_standard_compilation;
+  int _sum_osr_bytes_compiled;
+  int _sum_standard_bytes_compiled;
+  CompilerStatistics() : _sum_osr_bytes_compiled(0), _sum_standard_bytes_compiled(0) {}
+};
+#endif
+
 class AbstractCompiler : public CHeapObj<mtCompiler> {
  private:
   bool _is_initialized; // Mark whether compiler object is initialized
@@ -49,6 +60,10 @@
  private:
   Type _type;
 
+#ifdef GRAAL
+  CompilerStatistics _stats;
+#endif
+
  public:
   AbstractCompiler(Type type) : _is_initialized(false), _type(type)    {}
 
@@ -83,6 +98,10 @@
   virtual void print_timers() {
     ShouldNotReachHere();
   }
+
+#ifdef GRAAL
+  CompilerStatistics* stats() { return &_stats; }
+#endif
 };
 
 #endif // SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP
--- a/src/share/vm/compiler/compileBroker.cpp	Wed Jan 30 16:46:15 2013 +0100
+++ b/src/share/vm/compiler/compileBroker.cpp	Wed Jan 30 22:44:51 2013 +0100
@@ -2082,9 +2082,17 @@
       if (is_osr) {
         _t_osr_compilation.add(time);
         _sum_osr_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
+#ifdef GRAAL
+        compiler(task->comp_level())->stats()->_t_osr_compilation.add(time);
+        compiler(task->comp_level())->stats()->_sum_osr_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
+#endif
       } else {
         _t_standard_compilation.add(time);
         _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
+#ifdef GRAAL
+        compiler(task->comp_level())->stats()->_t_standard_compilation.add(time);
+        compiler(task->comp_level())->stats()->_sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes();
+#endif
       }
     }
 
@@ -2157,8 +2165,25 @@
   tty->print_cr("  Total compiled bytecodes : %6d bytes", tcb);
   tty->print_cr("    Standard compilation   : %6d bytes", CompileBroker::_sum_standard_bytes_compiled);
   tty->print_cr("    On stack replacement   : %6d bytes", CompileBroker::_sum_osr_bytes_compiled);
-  int bps = (int)(tcb / CompileBroker::_t_total_compilation.seconds());
+  double tcs = CompileBroker::_t_total_compilation.seconds();
+  int bps = tcs == 0.0 ? 0 : (int)(tcb / tcs);
   tty->print_cr("  Average compilation speed: %6d bytes/s", bps);
+#ifdef GRAAL
+  for (unsigned int i = 0; i < sizeof(_compilers) / sizeof(AbstractCompiler*); i++) {
+    AbstractCompiler* comp = _compilers[i];
+    if (comp != NULL) {
+      CompilerStatistics* stats = comp->stats();
+      int bytecodes = stats->_sum_osr_bytes_compiled + stats->_sum_standard_bytes_compiled;
+      if (bytecodes != 0) {
+        double seconds = stats->_t_osr_compilation.seconds() + stats->_t_standard_compilation.seconds();
+        int bps = seconds == 0.0 ? 0 : (int) (bytecodes / seconds);
+        tty->print_cr("  %7s compilation speed: %6d bytes/s {standard: %6.3f s, %6d bytes; osr: %6.3f s, %6d bytes}",
+            comp->name(), bps, stats->_t_standard_compilation.seconds(), stats->_sum_standard_bytes_compiled,
+            stats->_t_osr_compilation.seconds(), stats->_sum_osr_bytes_compiled);
+      }
+    }
+  }
+#endif
   tty->cr();
   tty->print_cr("  nmethod code size        : %6d bytes", CompileBroker::_sum_nmethod_code_size);
   tty->print_cr("  nmethod total size       : %6d bytes", CompileBroker::_sum_nmethod_size);
--- a/src/share/vm/graal/graalCompiler.hpp	Wed Jan 30 16:46:15 2013 +0100
+++ b/src/share/vm/graal/graalCompiler.hpp	Wed Jan 30 22:44:51 2013 +0100
@@ -46,7 +46,7 @@
   static GraalCompiler* instance() { return _instance; }
 
 
-  virtual const char* name() { return "G"; }
+  virtual const char* name() { return "Graal"; }
 
   virtual bool supports_native()                 { return true; }
   virtual bool supports_osr   ()                 { return true; }
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Wed Jan 30 16:46:15 2013 +0100
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Wed Jan 30 22:44:51 2013 +0100
@@ -607,6 +607,7 @@
   set_boolean("windowsOs", false);
 #endif
   set_boolean("verifyOops", VerifyOops);
+  set_boolean("ciTime", CITime);
   set_boolean("useFastLocking", GraalUseFastLocking);
   set_boolean("useBiasedLocking", UseBiasedLocking);
   set_boolean("usePopCountInstruction", UsePopCountInstruction);