annotate src/share/vm/interpreter/bytecode.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children be93aad57795
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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 // Base class for different kinds of abstractions working
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // relative to an objects 'this' pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class ThisRelativeObj VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
30 int sign_extend (int x, int size) const { const int s = (BytesPerInt - size)*BitsPerByte; return (x << s) >> s; }
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Address computation
a61af66fc99e Initial load
duke
parents:
diff changeset
34 address addr_at (int offset) const { return (address)this + offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
35 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
36 int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Java unsigned accessors (using Java spec byte ordering)
a61af66fc99e Initial load
duke
parents:
diff changeset
39 int java_byte_at (int offset) const { return *(jubyte*)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int java_hwrd_at (int offset) const { return java_byte_at(offset) << (1 * BitsPerByte) | java_byte_at(offset + 1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
41 int java_word_at (int offset) const { return java_hwrd_at(offset) << (2 * BitsPerByte) | java_hwrd_at(offset + 2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Java signed accessors (using Java spec byte ordering)
a61af66fc99e Initial load
duke
parents:
diff changeset
44 int java_signed_byte_at(int offset) const { return sign_extend(java_byte_at(offset), 1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 int java_signed_hwrd_at(int offset) const { return sign_extend(java_hwrd_at(offset), 2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
46 int java_signed_word_at(int offset) const { return java_word_at(offset) ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Fast accessors (using the machine's natural byte ordering)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 int fast_byte_at (int offset) const { return *(jubyte *)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 int fast_hwrd_at (int offset) const { return *(jushort*)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
51 int fast_word_at (int offset) const { return *(juint *)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Fast signed accessors (using the machine's natural byte ordering)
a61af66fc99e Initial load
duke
parents:
diff changeset
54 int fast_signed_byte_at(int offset) const { return *(jbyte *)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int fast_signed_hwrd_at(int offset) const { return *(jshort*)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int fast_signed_word_at(int offset) const { return *(jint *)addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Fast manipulators (using the machine's natural byte ordering)
a61af66fc99e Initial load
duke
parents:
diff changeset
59 void set_fast_byte_at (int offset, int x) const { *(jbyte *)addr_at(offset) = (jbyte )x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 void set_fast_hwrd_at (int offset, int x) const { *(jshort*)addr_at(offset) = (jshort)x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 void set_fast_word_at (int offset, int x) const { *(jint *)addr_at(offset) = (jint )x; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 };
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // The base class for different kinds of bytecode abstractions.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Provides the primitive operations to manipulate code relative
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // to an objects 'this' pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
68 //
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Note: Even though it seems that the fast_index & set_fast_index
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // functions are machine specific, they're not. They only use
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // the natural way to store a 16bit index on a given machine,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // independent of the particular byte ordering. Since all other
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // places in the system that refer to these indices use the
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // same method (the natural byte ordering on the platform)
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // this will always work and be machine-independent).
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 class Bytecode: public ThisRelativeObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
79 u_char byte_at(int offset) const { return *addr_at(offset); }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 bool check_must_rewrite() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
84 address bcp() const { return addr_at(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 address next_bcp() const { return addr_at(0) + Bytecodes::length_at(bcp()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 Bytecodes::Code code() const { return Bytecodes::code_at(addr_at(0)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 bool must_rewrite() const { return Bytecodes::can_rewrite(code()) && check_must_rewrite(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 bool is_active_breakpoint() const { return Bytecodes::is_active_breakpoint_at(bcp()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int one_byte_index() const { return byte_at(1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 int two_byte_index() const { return (byte_at(1) << 8) + byte_at(2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 int offset() const { return (two_byte_index() << 16) >> 16; }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 address destination() const { return bcp() + offset(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int fast_index() const { return Bytes::get_native_u2(addr_at(1)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Attribute modification
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void set_code(Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void set_fast_index(int i);
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
103 inline friend Bytecode* Bytecode_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 };
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 inline Bytecode* Bytecode_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return (Bytecode*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Abstractions for lookupswitch bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 class LookupswitchPair: ThisRelativeObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
115 int _match;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 int _offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
119 int match() const { return java_signed_word_at(0 * jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 int offset() const { return java_signed_word_at(1 * jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 };
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 class Bytecode_lookupswitch: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void verify() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
129 int default_offset() const { return java_signed_word_at(aligned_offset(1 + 0*jintSize)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int number_of_pairs() const { return java_signed_word_at(aligned_offset(1 + 1*jintSize)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 LookupswitchPair* pair_at(int i) const { assert(0 <= i && i < number_of_pairs(), "pair index out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return (LookupswitchPair*)aligned_addr_at(1 + (1 + i)*2*jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
134 inline friend Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 };
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 inline Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 Bytecode_lookupswitch* b = (Bytecode_lookupswitch*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 class Bytecode_tableswitch: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
146 void verify() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
149 int default_offset() const { return java_signed_word_at(aligned_offset(1 + 0*jintSize)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 int low_key() const { return java_signed_word_at(aligned_offset(1 + 1*jintSize)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int high_key() const { return java_signed_word_at(aligned_offset(1 + 2*jintSize)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 int dest_offset_at(int i) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 int length() { return high_key()-low_key()+1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
156 inline friend Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 };
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 inline Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 Bytecode_tableswitch* b = (Bytecode_tableswitch*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Abstraction for invoke_{virtual, static, interface, special}
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 class Bytecode_invoke: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
170 methodHandle _method; // method containing the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
171 int _bci; // position of the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 Bytecode_invoke(methodHandle method, int bci) : _method(method), _bci(bci) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
179 methodHandle method() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 int bci() const { return _bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 address bcp() const { return _method->bcp_from(bci()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 int index() const; // the constant pool index for the invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
184 symbolOop name() const; // returns the name of the invoked method
a61af66fc99e Initial load
duke
parents:
diff changeset
185 symbolOop signature() const; // returns the signature of the invoked method
a61af66fc99e Initial load
duke
parents:
diff changeset
186 BasicType result_type(Thread *thread) const; // returns the result type of the invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 Bytecodes::Code code() const { return Bytecodes::code_at(bcp(), _method()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 Bytecodes::Code adjusted_invoke_code() const { return Bytecodes::java_code(code()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 methodHandle static_target(TRAPS); // "specified" method (from constant pool)
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // Testers
a61af66fc99e Initial load
duke
parents:
diff changeset
194 bool is_invokeinterface() const { return adjusted_invoke_code() == Bytecodes::_invokeinterface; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 bool is_invokevirtual() const { return adjusted_invoke_code() == Bytecodes::_invokevirtual; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 bool is_invokestatic() const { return adjusted_invoke_code() == Bytecodes::_invokestatic; }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 bool is_invokespecial() const { return adjusted_invoke_code() == Bytecodes::_invokespecial; }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 bool is_valid() const { return is_invokeinterface() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
200 is_invokevirtual() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
201 is_invokestatic() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
202 is_invokespecial(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
205 inline friend Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Like Bytecode_invoke_at. Instead it returns NULL if the bci is not at an invoke.
a61af66fc99e Initial load
duke
parents:
diff changeset
208 inline friend Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 };
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 inline Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 Bytecode_invoke* b = new Bytecode_invoke(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
214 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 inline Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
218 Bytecode_invoke* b = new Bytecode_invoke(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return b->is_valid() ? b : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // Abstraction for all field accesses (put/get field/static_
a61af66fc99e Initial load
duke
parents:
diff changeset
224 class Bytecode_field: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
226 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 int index() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 bool is_static() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
232 inline friend Bytecode_field* Bytecode_field_at(const methodOop method, address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 };
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 inline Bytecode_field* Bytecode_field_at(const methodOop method, address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 Bytecode_field* b = (Bytecode_field*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
238 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 // Abstraction for {get,put}static
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 class Bytecode_static: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
246 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // Returns the result type of the send by inspecting the field ref
a61af66fc99e Initial load
duke
parents:
diff changeset
249 BasicType result_type(methodOop method) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
252 inline friend Bytecode_static* Bytecode_static_at(const methodOop method, address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 };
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 inline Bytecode_static* Bytecode_static_at(const methodOop method, address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 Bytecode_static* b = (Bytecode_static*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Abstraction for checkcast
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 class Bytecode_checkcast: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
266 void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Returns index
a61af66fc99e Initial load
duke
parents:
diff changeset
269 long index() const { return java_hwrd_at(1); };
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
272 inline friend Bytecode_checkcast* Bytecode_checkcast_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 };
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 inline Bytecode_checkcast* Bytecode_checkcast_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 Bytecode_checkcast* b = (Bytecode_checkcast*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
278 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Abstraction for instanceof
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 class Bytecode_instanceof: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
286 void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Returns index
a61af66fc99e Initial load
duke
parents:
diff changeset
289 long index() const { return java_hwrd_at(1); };
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
292 inline friend Bytecode_instanceof* Bytecode_instanceof_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 };
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 inline Bytecode_instanceof* Bytecode_instanceof_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 Bytecode_instanceof* b = (Bytecode_instanceof*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 class Bytecode_new: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
304 void verify() const { assert(java_code() == Bytecodes::_new, "check new"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Returns index
a61af66fc99e Initial load
duke
parents:
diff changeset
307 long index() const { return java_hwrd_at(1); };
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
310 inline friend Bytecode_new* Bytecode_new_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 };
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 inline Bytecode_new* Bytecode_new_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 Bytecode_new* b = (Bytecode_new*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 class Bytecode_multianewarray: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
322 void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // Returns index
a61af66fc99e Initial load
duke
parents:
diff changeset
325 long index() const { return java_hwrd_at(1); };
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
328 inline friend Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 };
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 inline Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 Bytecode_multianewarray* b = (Bytecode_multianewarray*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
333 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
334 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 class Bytecode_anewarray: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
340 void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // Returns index
a61af66fc99e Initial load
duke
parents:
diff changeset
343 long index() const { return java_hwrd_at(1); };
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
346 inline friend Bytecode_anewarray* Bytecode_anewarray_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 };
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 inline Bytecode_anewarray* Bytecode_anewarray_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 Bytecode_anewarray* b = (Bytecode_anewarray*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // Abstraction for ldc, ldc_w and ldc2_w
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 class Bytecode_loadconstant: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
360 void verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 Bytecodes::Code stdc = Bytecodes::java_code(code());
a61af66fc99e Initial load
duke
parents:
diff changeset
362 assert(stdc == Bytecodes::_ldc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
363 stdc == Bytecodes::_ldc_w ||
a61af66fc99e Initial load
duke
parents:
diff changeset
364 stdc == Bytecodes::_ldc2_w, "load constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 int index() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 inline friend Bytecode_loadconstant* Bytecode_loadconstant_at(const methodOop method, address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 };
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 inline Bytecode_loadconstant* Bytecode_loadconstant_at(const methodOop method, address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
373 Bytecode_loadconstant* b = (Bytecode_loadconstant*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
375 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }