annotate graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HOTSPOTPROFILINGINFO.JAVA @ 4446:48756b901156

bugfixes
author Christian Haeubl <christian.haeubl@oracle.com>
date Tue, 24 Jan 2012 13:25:16 -0800
parents
children 00a04b57a046
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
1 /*
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
4 *
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
8 *
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
13 * accompanied this code).
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
14 *
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
18 *
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
21 * questions.
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
22 */
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
23 package com.oracle.max.graal.hotspot.ri;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
24
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
25 import com.oracle.max.cri.ri.*;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
26 import com.oracle.max.graal.hotspot.*;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
27 import com.oracle.max.graal.hotspot.Compiler;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
28
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
29
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
30 public final class HotSpotProfilingInfo extends CompilerObject implements RiProfilingInfo {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
31
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
32 /**
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
33 *
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
34 */
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
35 private static final long serialVersionUID = -8307682725047864875L;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
36
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
37 private int position;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
38 private int hintPosition;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
39 private int hintBCI;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
40 private HotSpotMethodDataAccessor dataAccessor;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
41 private HotSpotMethodData methodData;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
42
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
43 public HotSpotProfilingInfo(Compiler compiler, HotSpotMethodData methodData) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
44 super(compiler);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
45 this.methodData = methodData;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
46 hintPosition = 0;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
47 hintBCI = -1;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
48 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
49
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
50 @Override
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
51 public RiTypeProfile getTypeProfile(int bci) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
52 findBCI(bci);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
53 return dataAccessor.getTypeProfile(methodData, position);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
54 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
55
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
56 @Override
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
57 public double getBranchTakenProbability(int bci) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
58 findBCI(bci);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
59 return dataAccessor.getBranchTakenProbability(methodData, position);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
60 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
61
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
62 @Override
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
63 public double[] getSwitchProbabilities(int bci) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
64 findBCI(bci);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
65 return dataAccessor.getSwitchProbabilities(methodData, position);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
66 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
67
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
68 @Override
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
69 public boolean getImplicitExceptionSeen(int bci) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
70 findBCI(bci);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
71 return dataAccessor.getImplicitExceptionSeen(methodData, position);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
72 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
73
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
74 @Override
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
75 public int getExecutionCount(int bci) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
76 findBCI(bci);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
77 return dataAccessor.getExecutionCount(methodData, position);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
78 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
79
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
80 private void findBCI(int targetBCI) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
81 assert targetBCI >= 0 : "invalid BCI";
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
82
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
83 if (methodData.hasNormalData()) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
84 int currentPosition = targetBCI < hintBCI ? 0 : hintPosition;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
85 HotSpotMethodDataAccessor currentAccessor;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
86 while ((currentAccessor = methodData.getNormalData(currentPosition)) != null) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
87 int currentBCI = currentAccessor.getBCI(methodData, currentPosition);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
88 if (currentBCI == targetBCI) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
89 normalDataFound(currentAccessor, currentPosition, currentBCI);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
90 return;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
91 } else if (currentBCI > targetBCI) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
92 break;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
93 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
94 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
95 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
96 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
97
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
98 if (methodData.hasExtraData()) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
99 int currentPosition = 0;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
100 HotSpotMethodDataAccessor currentAccessor;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
101 while ((currentAccessor = methodData.getExtraData(currentPosition)) != null) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
102 int currentBCI = currentAccessor.getBCI(methodData, currentPosition);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
103 if (currentBCI == targetBCI) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
104 extraDataFound(currentAccessor, currentPosition);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
105 return;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
106 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
107 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
108 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
109 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
110
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
111 noDataFound();
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
112 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
113
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
114 private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
115 setCurrentData(data, pos);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
116 this.hintPosition = position;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
117 this.hintBCI = bci;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
118 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
119
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
120 private void extraDataFound(HotSpotMethodDataAccessor data, int pos) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
121 setCurrentData(data, pos);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
122 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
123
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
124 private void noDataFound() {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
125 setCurrentData(HotSpotMethodData.getNoDataAccessor(), -1);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
126 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
127
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
128 private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
129 this.dataAccessor = dataAccessor;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
130 this.position = position;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
131 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
132 }