annotate agent/src/share/classes/sun/jvm/hotspot/oops/FieldType.java @ 20456:64156d22e49d

8032247: SA: Constantpool lookup for invokedynamic is not implemented Summary: implement constant pool lookup for invokedynamic Reviewed-by: sla, sspitsyn
author dsamersoff
date Thu, 11 Sep 2014 11:55:30 -0700
parents f6f3bb0ee072
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.oops;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.runtime.BasicType;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public class FieldType {
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 private Symbol signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 private char first;
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 public FieldType(Symbol signature) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 this.signature = signature;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 this.first = (char) signature.getByteAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 switch (this.first) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 case 'B':
a61af66fc99e Initial load
duke
parents:
diff changeset
42 case 'C':
a61af66fc99e Initial load
duke
parents:
diff changeset
43 case 'D':
a61af66fc99e Initial load
duke
parents:
diff changeset
44 case 'F':
a61af66fc99e Initial load
duke
parents:
diff changeset
45 case 'I':
a61af66fc99e Initial load
duke
parents:
diff changeset
46 case 'J':
a61af66fc99e Initial load
duke
parents:
diff changeset
47 case 'S':
a61af66fc99e Initial load
duke
parents:
diff changeset
48 case 'Z':
a61af66fc99e Initial load
duke
parents:
diff changeset
49 case 'L':
a61af66fc99e Initial load
duke
parents:
diff changeset
50 case '[':
a61af66fc99e Initial load
duke
parents:
diff changeset
51 break; // Ok. signature char known
a61af66fc99e Initial load
duke
parents:
diff changeset
52 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 Assert.that(false, "Unknown char in field signature \"" + signature.asString() + "\": " + this.first);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public boolean isOop() { return isObject() || isArray(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public boolean isByte() { return first == 'B'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public boolean isChar() { return first == 'C'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public boolean isDouble() { return first == 'D'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public boolean isFloat() { return first == 'F'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 public boolean isInt() { return first == 'I'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public boolean isLong() { return first == 'J'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public boolean isShort() { return first == 'S'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public boolean isBoolean() { return first == 'Z'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public boolean isObject() { return first == 'L'; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 public boolean isArray() { return first == '['; }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
70 public Symbol getSignature() { return signature; }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
71
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 public static class ArrayInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private int dimension;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 private int elementBasicType; // See BasicType.java
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // FIXME: consider adding name of element class
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 public ArrayInfo(int dimension, int elementBasicType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 this.dimension = dimension;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 this.elementBasicType = elementBasicType;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public int dimension() { return dimension; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 /** See BasicType.java */
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public int elementBasicType() { return elementBasicType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 /** Only valid for T_ARRAY; throws unspecified exception otherwise */
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public ArrayInfo getArrayInfo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int index = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 int dim = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 index = skipOptionalSize(signature, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 while (signature.getByteAt(index) == '[') {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 dim++;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 skipOptionalSize(signature, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 int elementType = BasicType.charToType((char) signature.getByteAt(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return new ArrayInfo(dim, elementType);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 private int skipOptionalSize(Symbol sig, int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 byte c = sig.getByteAt(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 while (c >= '0' && c <= '9') {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 ++index;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 c = sig.getByteAt(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return index;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }