Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/C1XMetrics.java @ 2509:16b9a8b5ad39
Renamings Runtime=>GraalRuntime and Compiler=>GraalCompiler
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:50:44 +0200 |
parents | graal/Compiler/src/com/sun/c1x/C1XMetrics.java@9ec15d6914ca |
children | 0f9eeb15e636 |
comparison
equal
deleted
inserted
replaced
2508:fea94949e0a2 | 2509:16b9a8b5ad39 |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.sun.c1x; | |
24 | |
25 import java.lang.reflect.*; | |
26 import java.util.*; | |
27 | |
28 import com.sun.c1x.debug.*; | |
29 | |
30 | |
31 /** | |
32 * This class contains a number of fields that collect metrics about compilation, particularly | |
33 * the number of times certain optimizations are performed. | |
34 * | |
35 * @author Ben L. Titzer | |
36 */ | |
37 public class C1XMetrics { | |
38 public static int CompiledMethods; | |
39 public static int TargetMethods; | |
40 public static int LocalValueNumberHits; | |
41 public static int GlobalValueNumberHits; | |
42 public static int ValueMapResizes; | |
43 public static int InlinedFinalizerChecks; | |
44 public static int MethodsFolded; | |
45 public static int InlineForcedMethods; | |
46 public static int InlineForbiddenMethods; | |
47 public static int InlinedJsrs; | |
48 public static int NullCheckIterations; | |
49 public static int NullCheckEliminations; | |
50 public static int NullChecksRedundant; | |
51 public static int NullCheckIdsAssigned; | |
52 public static int ZeroChecksRedundant; | |
53 public static int DivideSpecialChecksRedundant; | |
54 public static int StoreCheckEliminations; | |
55 public static int BoundsChecksElminations; | |
56 public static int ConditionalEliminations; | |
57 public static int BlocksMerged; | |
58 public static int BlocksSkipped; | |
59 public static int BlocksDeleted; | |
60 public static int DeadCodeEliminated; | |
61 public static int ResolveCPEAttempts; | |
62 public static int BytecodesCompiled; | |
63 public static int CodeBytesEmitted; | |
64 public static int SafepointsEmitted; | |
65 public static int ExceptionHandlersEmitted; | |
66 public static int DataPatches; | |
67 public static int DirectCallSitesEmitted; | |
68 public static int IndirectCallSitesEmitted; | |
69 public static int HIRInstructions; | |
70 public static int LiveHIRInstructions; | |
71 public static int LIRInstructions; | |
72 public static int LIRVariables; | |
73 public static int LIRXIRInstructions; | |
74 public static int LIRMoveInstructions; | |
75 public static int LSRAIntervalsCreated; | |
76 public static int LSRASpills; | |
77 public static int LoadConstantIterations; | |
78 public static int CodeBufferCopies; | |
79 public static int UniqueValueIdsAssigned; | |
80 public static int RedundantConditionals; | |
81 public static int FrameStatesCreated; | |
82 public static int FrameStateValuesCreated; | |
83 | |
84 public static void print() { | |
85 printClassFields(C1XMetrics.class); | |
86 | |
87 } | |
88 | |
89 public static void printClassFields(Class<?> javaClass) { | |
90 final String className = javaClass.getSimpleName(); | |
91 TTY.println(className + " {"); | |
92 for (final Field field : javaClass.getFields()) { | |
93 printField(field, false); | |
94 } | |
95 TTY.println("}"); | |
96 } | |
97 | |
98 public static void printField(final Field field, boolean tabbed) { | |
99 final String fieldName = String.format("%35s", field.getName()); | |
100 try { | |
101 String prefix = tabbed ? "" : " " + fieldName + " = "; | |
102 String postfix = tabbed ? "\t" : "\n"; | |
103 if (field.getType() == int.class) { | |
104 TTY.print(prefix + field.getInt(null) + postfix); | |
105 } else if (field.getType() == boolean.class) { | |
106 TTY.print(prefix + field.getBoolean(null) + postfix); | |
107 } else if (field.getType() == float.class) { | |
108 TTY.print(prefix + field.getFloat(null) + postfix); | |
109 } else if (field.getType() == String.class) { | |
110 TTY.print(prefix + field.get(null) + postfix); | |
111 } else if (field.getType() == Map.class) { | |
112 Map<?, ?> m = (Map<?, ?>) field.get(null); | |
113 TTY.print(prefix + printMap(m) + postfix); | |
114 } else { | |
115 TTY.print(prefix + field.get(null) + postfix); | |
116 } | |
117 } catch (IllegalAccessException e) { | |
118 // do nothing. | |
119 } | |
120 } | |
121 | |
122 private static String printMap(Map<?, ?> m) { | |
123 StringBuilder sb = new StringBuilder(); | |
124 | |
125 List<String> keys = new ArrayList<String>(); | |
126 for (Object key : m.keySet()) { | |
127 keys.add((String) key); | |
128 } | |
129 Collections.sort(keys); | |
130 | |
131 for (String key : keys) { | |
132 sb.append(key); | |
133 sb.append("\t"); | |
134 sb.append(m.get(key)); | |
135 sb.append("\n"); | |
136 } | |
137 | |
138 return sb.toString(); | |
139 } | |
140 | |
141 private static void printField(String fieldName, long value) { | |
142 TTY.print(" " + fieldName + " = " + value + "\n"); | |
143 } | |
144 | |
145 private static void printField(String fieldName, double value) { | |
146 TTY.print(" " + fieldName + " = " + value + "\n"); | |
147 } | |
148 } | |
149 |