annotate agent/src/share/classes/sun/jvm/hotspot/oops/MultiBranchData.java @ 3939:f6f3bb0ee072

7088955: add C2 IR support to the SA Reviewed-by: kvn
author never
date Sun, 11 Sep 2011 14:48:24 -0700
parents
children 4bec1b1f7b33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
1 /*
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
3 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
4 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
5 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
6 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
7 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
8 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
9 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
10 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
11 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
12 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
13 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
14 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
15 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
16 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
17 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
18 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
19 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
20 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
21 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
22 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
23 */
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
24
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
25 package sun.jvm.hotspot.oops;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
26
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
27 import java.io.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
28 import java.util.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
31 import sun.jvm.hotspot.types.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
32 import sun.jvm.hotspot.utilities.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
33
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
34 // MultiBranchData
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
35 //
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
36 // A MultiBranchData is used to access profiling information for
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
37 // a multi-way branch (*switch bytecodes). It consists of a series
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
38 // of (count, displacement) pairs, which count the number of times each
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
39 // case was taken and specify the data displacment for each branch target.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
40 public class MultiBranchData extends ArrayData {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
41 static final int defaultCountOffSet = 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
42 static final int defaultDisaplacementOffSet = 1;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
43 static final int caseArrayStart = 2;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
44 static final int relativeCountOffSet = 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
45 static final int relativeDisplacementOffSet = 1;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
46 static final int perCaseCellCount = 2;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
47
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
48 public MultiBranchData(DataLayout layout) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
49 super(layout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
50 //assert(layout.tag() == DataLayout.multiBranchDataTag, "wrong type");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
51 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
52
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
53 // static int computeCellCount(BytecodeStream stream);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
54
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
55 int numberOfCases() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
56 int alen = arrayLen() - 2; // get rid of default case here.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
57 //assert(alen % perCaseCellCount == 0, "must be even");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
58 return (alen / perCaseCellCount);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
59 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
60
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
61 int defaultCount() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
62 return arrayUintAt(defaultCountOffSet);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
63 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
64 int defaultDisplacement() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
65 return arrayIntAt(defaultDisaplacementOffSet);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
66 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
67
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
68 int countAt(int index) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
69 return arrayUintAt(caseArrayStart +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
70 index * perCaseCellCount +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
71 relativeCountOffSet);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
72 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
73 int displacementAt(int index) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
74 return arrayIntAt(caseArrayStart +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
75 index * perCaseCellCount +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
76 relativeDisplacementOffSet);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
77 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
78
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
79 // Code generation support
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
80 static int defaultCountOffset() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
81 return arrayElementOffset(defaultCountOffSet);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
82 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
83 static int defaultDisplacementOffset() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
84 return arrayElementOffset(defaultDisaplacementOffSet);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
85 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
86 static int caseCountOffset(int index) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
87 return caseArrayOffset() +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
88 (perCaseSize() * index) +
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
89 relativeCountOffset();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
90 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
91 static int caseArrayOffset() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
92 return arrayElementOffset(caseArrayStart);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
93 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
94 static int perCaseSize() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
95 return (perCaseCellCount) * MethodData.cellSize;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
96 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
97 static int relativeCountOffset() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
98 return (relativeCountOffSet) * MethodData.cellSize;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
99 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
100 static int relativeDisplacementOffset() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
101 return (relativeDisplacementOffSet) * MethodData.cellSize;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
102 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
103
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
104 public void printDataOn(PrintStream st) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
105 printShared(st, "MultiBranchData");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
106 st.println("default_count(" + defaultCount() + ") displacement(" + defaultDisplacement() + ")");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
107 int cases = numberOfCases();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
108 for (int i = 0; i < cases; i++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
109 tab(st);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
110 st.println("count(" + countAt(i) + ") displacement(" + displacementAt(i) + ")");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
111 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
112 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
113 }