annotate src/share/vm/runtime/signature.hpp @ 17524:89152779163c

Merge with jdk8-b132
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 15 Oct 2014 11:59:32 +0200
parents 4ca6dc0799b6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17524
89152779163c Merge with jdk8-b132
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14909
diff changeset
2 * Copyright (c) 1997, 2013, 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: 1508
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1508
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: 1508
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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
25 #ifndef SHARE_VM_RUNTIME_SIGNATURE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
26 #define SHARE_VM_RUNTIME_SIGNATURE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
28 #include "memory/allocation.hpp"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
29 #include "oops/method.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
30 #include "utilities/top.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // SignatureIterators iterate over a Java signature (or parts of it).
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // (Syntax according to: "The Java Virtual Machine Specification" by
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // Tim Lindholm & Frank Yellin; section 4.3 Descriptors; p. 89ff.)
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Example: Iterating over ([Lfoo;D)I using
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // 0123456789
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // iterate_parameters() calls: do_array(2, 7); do_double();
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // iterate_returntype() calls: do_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // iterate() calls: do_array(2, 7); do_double(); do_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // is_return_type() is: false ; false ; true
a61af66fc99e Initial load
duke
parents:
diff changeset
44 //
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // NOTE: The new optimizer has an alternate, for-loop based signature
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // iterator implemented in opto/type.cpp, TypeTuple::make().
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 class SignatureIterator: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 protected:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
50 Symbol* _signature; // the signature to iterate over
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51 int _index; // the current character index (only valid during iteration)
a61af66fc99e Initial load
duke
parents:
diff changeset
52 int _parameter_index; // the current parameter index (0 outside iteration phase)
a61af66fc99e Initial load
duke
parents:
diff changeset
53 BasicType _return_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 void expect(char c);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void skip_optional_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 int parse_type(); // returns the parameter size in words (0 for void)
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void check_signature_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Definitions used in generating and iterating the
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // bit field form of the signature generated by the
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Fingerprinter.
a61af66fc99e Initial load
duke
parents:
diff changeset
64 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 static_feature_size = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 result_feature_size = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 result_feature_mask = 0xF,
a61af66fc99e Initial load
duke
parents:
diff changeset
68 parameter_feature_size = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
69 parameter_feature_mask = 0xF,
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 bool_parm = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 byte_parm = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 char_parm = 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 short_parm = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 int_parm = 5,
a61af66fc99e Initial load
duke
parents:
diff changeset
76 long_parm = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 float_parm = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
78 double_parm = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
79 obj_parm = 9,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 done_parm = 10, // marker for end of parameters
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // max parameters is wordsize minus
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // The sign bit, termination field, the result and static bit fields
a61af66fc99e Initial load
duke
parents:
diff changeset
84 max_size_of_parameters = (BitsPerLong-1 -
a61af66fc99e Initial load
duke
parents:
diff changeset
85 result_feature_size - parameter_feature_size -
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static_feature_size) / parameter_feature_size
a61af66fc99e Initial load
duke
parents:
diff changeset
87 };
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Constructors
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
90 SignatureIterator(Symbol* signature);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void dispatch_field(); // dispatches once for field signatures
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void iterate_parameters(); // iterates over parameters only
a61af66fc99e Initial load
duke
parents:
diff changeset
95 void iterate_parameters( uint64_t fingerprint );
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void iterate_returntype(); // iterates over returntype only
a61af66fc99e Initial load
duke
parents:
diff changeset
97 void iterate(); // iterates over whole signature
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Returns the word index of the current parameter;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 int parameter_index() const { return _parameter_index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 bool is_return_type() const { return parameter_index() < 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 BasicType get_ret_type() const { return _return_type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Basic types
a61af66fc99e Initial load
duke
parents:
diff changeset
104 virtual void do_bool () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 virtual void do_char () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 virtual void do_float () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 virtual void do_double() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 virtual void do_byte () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 virtual void do_short () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 virtual void do_int () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 virtual void do_long () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 virtual void do_void () = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Object types (begin indexes the first character of the entry, end indexes the first character after the entry)
a61af66fc99e Initial load
duke
parents:
diff changeset
115 virtual void do_object(int begin, int end) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 virtual void do_array (int begin, int end) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 };
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // Specialized SignatureIterators: Used to compute signature specific values.
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 class SignatureTypeNames : public SignatureIterator {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
124 virtual void type_name(const char* name) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void do_bool() { type_name("jboolean"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void do_char() { type_name("jchar" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void do_float() { type_name("jfloat" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void do_double() { type_name("jdouble" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 void do_byte() { type_name("jbyte" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 void do_short() { type_name("jshort" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 void do_int() { type_name("jint" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 void do_long() { type_name("jlong" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 void do_void() { type_name("void" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void do_object(int begin, int end) { type_name("jobject" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 void do_array (int begin, int end) { type_name("jobject" ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
139 SignatureTypeNames(Symbol* signature) : SignatureIterator(signature) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140 };
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 class SignatureInfo: public SignatureIterator {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
145 bool _has_iterated; // need this because iterate cannot be called in constructor (set is virtual!)
a61af66fc99e Initial load
duke
parents:
diff changeset
146 bool _has_iterated_return;
a61af66fc99e Initial load
duke
parents:
diff changeset
147 int _size;
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 void lazy_iterate_parameters() { if (!_has_iterated) { iterate_parameters(); _has_iterated = true; } }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 void lazy_iterate_return() { if (!_has_iterated_return) { iterate_returntype(); _has_iterated_return = true; } }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 virtual void set(int size, BasicType type) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 void do_bool () { set(T_BOOLEAN_size, T_BOOLEAN); }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 void do_char () { set(T_CHAR_size , T_CHAR ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void do_float () { set(T_FLOAT_size , T_FLOAT ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 void do_double() { set(T_DOUBLE_size , T_DOUBLE ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void do_byte () { set(T_BYTE_size , T_BYTE ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void do_short () { set(T_SHORT_size , T_SHORT ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 void do_int () { set(T_INT_size , T_INT ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void do_long () { set(T_LONG_size , T_LONG ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void do_void () { set(T_VOID_size , T_VOID ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void do_object(int begin, int end) { set(T_OBJECT_size , T_OBJECT ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 void do_array (int begin, int end) { set(T_ARRAY_size , T_ARRAY ); }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
167 SignatureInfo(Symbol* signature) : SignatureIterator(signature) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
168 _has_iterated = _has_iterated_return = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 _size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 _return_type = T_ILLEGAL;
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 };
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Specialized SignatureIterator: Used to compute the argument size.
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 class ArgumentSizeComputer: public SignatureInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
180 void set(int size, BasicType type) { _size += size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
182 ArgumentSizeComputer(Symbol* signature) : SignatureInfo(signature) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 int size() { lazy_iterate_parameters(); return _size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 };
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 class ArgumentCount: public SignatureInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
190 void set(int size, BasicType type) { _size ++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
192 ArgumentCount(Symbol* signature) : SignatureInfo(signature) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 int size() { lazy_iterate_parameters(); return _size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 };
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Specialized SignatureIterator: Used to compute the result type.
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 class ResultTypeFinder: public SignatureInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
202 void set(int size, BasicType type) { _return_type = type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
204 BasicType type() { lazy_iterate_return(); return _return_type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
206 ResultTypeFinder(Symbol* signature) : SignatureInfo(signature) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
207 };
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Fingerprinter computes a unique ID for a given method. The ID
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // is a bitvector characterizing the methods signature (incl. the receiver).
a61af66fc99e Initial load
duke
parents:
diff changeset
212 class Fingerprinter: public SignatureIterator {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
214 uint64_t _fingerprint;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 int _shift_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 methodHandle mh;
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 void do_bool() { _fingerprint |= (((uint64_t)bool_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 void do_char() { _fingerprint |= (((uint64_t)char_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 void do_byte() { _fingerprint |= (((uint64_t)byte_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 void do_short() { _fingerprint |= (((uint64_t)short_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 void do_int() { _fingerprint |= (((uint64_t)int_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void do_long() { _fingerprint |= (((uint64_t)long_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
226 void do_float() { _fingerprint |= (((uint64_t)float_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 void do_double() { _fingerprint |= (((uint64_t)double_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 void do_object(int begin, int end) { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
230 void do_array (int begin, int end) { _fingerprint |= (((uint64_t)obj_parm) << _shift_count); _shift_count += parameter_feature_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 void do_void() { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 Fingerprinter(methodHandle method) : SignatureIterator(method->signature()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 mh = method;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 _fingerprint = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 uint64_t fingerprint() {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // See if we fingerprinted this method already
a61af66fc99e Initial load
duke
parents:
diff changeset
241 if (mh->constMethod()->fingerprint() != CONST64(0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 return mh->constMethod()->fingerprint();
a61af66fc99e Initial load
duke
parents:
diff changeset
243 }
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (mh->size_of_parameters() > max_size_of_parameters ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 _fingerprint = UCONST64(-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 mh->constMethod()->set_fingerprint(_fingerprint);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return _fingerprint;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 assert( (int)mh->result_type() <= (int)result_feature_mask, "bad result type");
a61af66fc99e Initial load
duke
parents:
diff changeset
252 _fingerprint = mh->result_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 _fingerprint <<= static_feature_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 if (mh->is_static()) _fingerprint |= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 _shift_count = result_feature_size + static_feature_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 iterate_parameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 _fingerprint |= ((uint64_t)done_parm) << _shift_count;// mark end of sig
a61af66fc99e Initial load
duke
parents:
diff changeset
258 mh->constMethod()->set_fingerprint(_fingerprint);
a61af66fc99e Initial load
duke
parents:
diff changeset
259 return _fingerprint;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 };
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // Specialized SignatureIterator: Used for native call purposes
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 class NativeSignatureIterator: public SignatureIterator {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
268 methodHandle _method;
605
98cb887364d3 6810672: Comment typos
twisti
parents: 0
diff changeset
269 // We need separate JNI and Java offset values because in 64 bit mode,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // the argument offsets are not in sync with the Java stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // For example a long takes up 1 "C" stack entry but 2 Java stack entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
272 int _offset; // The java stack offset
a61af66fc99e Initial load
duke
parents:
diff changeset
273 int _prepended; // number of prepended JNI parameters (1 JNIEnv, plus 1 mirror if static)
a61af66fc99e Initial load
duke
parents:
diff changeset
274 int _jni_offset; // the current parameter offset, starting with 0
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 void do_bool () { pass_int(); _jni_offset++; _offset++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 void do_char () { pass_int(); _jni_offset++; _offset++; }
1010
354d3184f6b2 6890308: integrate zero assembler hotspot changes
never
parents: 605
diff changeset
278 void do_float () { pass_float(); _jni_offset++; _offset++; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
279 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
280 void do_double() { pass_double(); _jni_offset++; _offset += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
281 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
282 void do_double() { pass_double(); _jni_offset += 2; _offset += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
283 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
284 void do_byte () { pass_int(); _jni_offset++; _offset++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 void do_short () { pass_int(); _jni_offset++; _offset++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
286 void do_int () { pass_int(); _jni_offset++; _offset++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
288 void do_long () { pass_long(); _jni_offset++; _offset += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
290 void do_long () { pass_long(); _jni_offset += 2; _offset += 2; }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
292 void do_void () { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 void do_object(int begin, int end) { pass_object(); _jni_offset++; _offset++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 void do_array (int begin, int end) { pass_object(); _jni_offset++; _offset++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
297 methodHandle method() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
298 int offset() const { return _offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 int jni_offset() const { return _jni_offset + _prepended; }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // int java_offset() const { return method()->size_of_parameters() - _offset - 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 bool is_static() const { return method()->is_static(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 virtual void pass_int() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 virtual void pass_long() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 virtual void pass_object() = 0;
1010
354d3184f6b2 6890308: integrate zero assembler hotspot changes
never
parents: 605
diff changeset
305 virtual void pass_float() = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
306 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
307 virtual void pass_double() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
309 virtual void pass_double() { pass_long(); } // may be same as long
a61af66fc99e Initial load
duke
parents:
diff changeset
310 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 NativeSignatureIterator(methodHandle method) : SignatureIterator(method->signature()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 _method = method;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 _offset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 _jni_offset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
316
a61af66fc99e Initial load
duke
parents:
diff changeset
317 const int JNIEnv_words = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
318 const int mirror_words = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 _prepended = !is_static() ? JNIEnv_words : JNIEnv_words + mirror_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // iterate() calles the 2 virtual methods according to the following invocation syntax:
a61af66fc99e Initial load
duke
parents:
diff changeset
323 //
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // {pass_int | pass_long | pass_object}
a61af66fc99e Initial load
duke
parents:
diff changeset
325 //
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Arguments are handled from left to right (receiver first, if any).
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // The offset() values refer to the Java stack offsets but are 0 based and increasing.
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // The java_offset() values count down to 0, and refer to the Java TOS.
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // The jni_offset() values increase from 1 or 2, and refer to C arguments.
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 void iterate() { iterate(Fingerprinter(method()).fingerprint());
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // Optimized path if we have the bitvector form of signature
a61af66fc99e Initial load
duke
parents:
diff changeset
336 void iterate( uint64_t fingerprint ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 if (!is_static()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // handle receiver (not handled by iterate because not in signature)
a61af66fc99e Initial load
duke
parents:
diff changeset
340 pass_object(); _jni_offset++; _offset++;
a61af66fc99e Initial load
duke
parents:
diff changeset
341 }
a61af66fc99e Initial load
duke
parents:
diff changeset
342
a61af66fc99e Initial load
duke
parents:
diff changeset
343 SignatureIterator::iterate_parameters( fingerprint );
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345 };
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 // Handy stream for iterating over signature
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 class SignatureStream : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 private:
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
352 Symbol* _signature;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
353 int _begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 int _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 BasicType _type;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 bool _at_return_type;
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
357 GrowableArray<Symbol*>* _names; // symbols created while parsing signature
0
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
360 bool at_return_type() const { return _at_return_type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
361 bool is_done() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 void next_non_primitive(int t);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 void next() {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
364 Symbol* sig = _signature;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
365 int len = sig->utf8_length();
a61af66fc99e Initial load
duke
parents:
diff changeset
366 if (_end >= len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 _end = len + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
368 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 _begin = _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
372 int t = sig->byte_at(_begin);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 switch (t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 case 'B': _type = T_BYTE; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
375 case 'C': _type = T_CHAR; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 case 'D': _type = T_DOUBLE; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
377 case 'F': _type = T_FLOAT; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
378 case 'I': _type = T_INT; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
379 case 'J': _type = T_LONG; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
380 case 'S': _type = T_SHORT; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
381 case 'Z': _type = T_BOOLEAN; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
382 case 'V': _type = T_VOID; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
383 default : next_non_primitive(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 _end++;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
389 SignatureStream(Symbol* signature, bool is_method = true);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
390 ~SignatureStream();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 bool is_object() const; // True if this argument is an object
a61af66fc99e Initial load
duke
parents:
diff changeset
393 bool is_array() const; // True if this argument is an array
a61af66fc99e Initial load
duke
parents:
diff changeset
394 BasicType type() const { return _type; }
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
395 Symbol* as_symbol(TRAPS);
1508
2ffde6cfe049 6939196: method handle signatures off the boot class path get linkage errors
jrose
parents: 1010
diff changeset
396 enum FailureMode { ReturnNull, CNFException, NCDFError };
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
397 Klass* as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
1508
2ffde6cfe049 6939196: method handle signatures off the boot class path get linkage errors
jrose
parents: 1010
diff changeset
398 oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2426
diff changeset
399 const jbyte* raw_bytes() { return _signature->bytes() + _begin; }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2426
diff changeset
400 int raw_length() { return _end - _begin; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // return same as_symbol except allocation of new symbols is avoided.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
403 Symbol* as_symbol_or_null();
12875
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 6725
diff changeset
404
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 6725
diff changeset
405 // count the number of references in the signature
d13d7aba8c12 8023657: New type profiling points: arguments to call
roland
parents: 6725
diff changeset
406 int reference_parameter_count();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
407 };
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 class SignatureVerifier : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
410 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // Returns true if the symbol is valid method or type signature
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
412 static bool is_valid_signature(Symbol* sig);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
413
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
414 static bool is_valid_method_signature(Symbol* sig);
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
415 static bool is_valid_type_signature(Symbol* sig);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
416 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 static ssize_t is_valid_type(const char*, ssize_t);
a61af66fc99e Initial load
duke
parents:
diff changeset
419 static bool invalid_name_char(char);
a61af66fc99e Initial load
duke
parents:
diff changeset
420 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
421
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
422 #endif // SHARE_VM_RUNTIME_SIGNATURE_HPP