Mercurial > hg > truffle
comparison src/share/vm/ci/ciStreams.hpp @ 1602:136b78722a08
6939203: JSR 292 needs method handle constants
Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode.
Reviewed-by: twisti, never
author | jrose |
---|---|
date | Wed, 09 Jun 2010 18:50:45 -0700 |
parents | e9ff18c4ace7 |
children | f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1585:49fac4acd688 | 1602:136b78722a08 |
---|---|
44 return c; | 44 return c; |
45 } | 45 } |
46 | 46 |
47 ciMethod* _method; // the method | 47 ciMethod* _method; // the method |
48 ciInstanceKlass* _holder; | 48 ciInstanceKlass* _holder; |
49 ciCPCache* _cpcache; | |
49 address _bc_start; // Start of current bytecode for table | 50 address _bc_start; // Start of current bytecode for table |
50 address _was_wide; // Address past last wide bytecode | 51 address _was_wide; // Address past last wide bytecode |
51 jint* _table_base; // Aligned start of last table or switch | 52 jint* _table_base; // Aligned start of last table or switch |
52 | 53 |
53 address _start; // Start of bytecodes | 54 address _start; // Start of bytecodes |
56 Bytecodes::Code _bc; // Current bytecode | 57 Bytecodes::Code _bc; // Current bytecode |
57 Bytecodes::Code _raw_bc; // Current bytecode, raw form | 58 Bytecodes::Code _raw_bc; // Current bytecode, raw form |
58 | 59 |
59 void reset( address base, unsigned int size ) { | 60 void reset( address base, unsigned int size ) { |
60 _bc_start =_was_wide = 0; | 61 _bc_start =_was_wide = 0; |
61 _start = _pc = base; _end = base + size; } | 62 _start = _pc = base; _end = base + size; |
63 _cpcache = NULL; | |
64 } | |
62 | 65 |
63 void assert_wide(bool require_wide) const { | 66 void assert_wide(bool require_wide) const { |
64 if (require_wide) | 67 if (require_wide) |
65 { assert(is_wide(), "must be a wide instruction"); } | 68 { assert(is_wide(), "must be a wide instruction"); } |
66 else { assert(!is_wide(), "must not be a wide instruction"); } | 69 else { assert(!is_wide(), "must not be a wide instruction"); } |
134 } | 137 } |
135 | 138 |
136 bool is_wide() const { return ( _pc == _was_wide ); } | 139 bool is_wide() const { return ( _pc == _was_wide ); } |
137 | 140 |
138 // Does this instruction contain an index which refes into the CP cache? | 141 // Does this instruction contain an index which refes into the CP cache? |
139 bool uses_cp_cache() const { return Bytecodes::uses_cp_cache(cur_bc_raw()); } | 142 bool has_cache_index() const { return Bytecodes::uses_cp_cache(cur_bc_raw()); } |
140 | 143 |
141 int get_index_u1() const { | 144 int get_index_u1() const { |
142 return bytecode()->get_index_u1(cur_bc_raw()); | 145 return bytecode()->get_index_u1(cur_bc_raw()); |
146 } | |
147 | |
148 int get_index_u1_cpcache() const { | |
149 return bytecode()->get_index_u1_cpcache(cur_bc_raw()); | |
143 } | 150 } |
144 | 151 |
145 // Get a byte index following this bytecode. | 152 // Get a byte index following this bytecode. |
146 // If prefixed with a wide bytecode, get a wide index. | 153 // If prefixed with a wide bytecode, get a wide index. |
147 int get_index() const { | 154 int get_index() const { |
155 assert(!has_cache_index(), "else use cpcache variant"); | |
148 return (_pc == _was_wide) // was widened? | 156 return (_pc == _was_wide) // was widened? |
149 ? get_index_u2(true) // yes, return wide index | 157 ? get_index_u2(true) // yes, return wide index |
150 : get_index_u1(); // no, return narrow index | 158 : get_index_u1(); // no, return narrow index |
151 } | 159 } |
152 | 160 |
205 | 213 |
206 int get_dest_table( int index ) const { | 214 int get_dest_table( int index ) const { |
207 return cur_bci() + get_int_table(index); } | 215 return cur_bci() + get_int_table(index); } |
208 | 216 |
209 // --- Constant pool access --- | 217 // --- Constant pool access --- |
210 int get_constant_index() const; | 218 int get_constant_raw_index() const; |
219 int get_constant_pool_index() const; | |
220 int get_constant_cache_index() const; | |
211 int get_field_index(); | 221 int get_field_index(); |
212 int get_method_index(); | 222 int get_method_index(); |
213 | 223 |
214 // If this bytecode is a new, newarray, multianewarray, instanceof, | 224 // If this bytecode is a new, newarray, multianewarray, instanceof, |
215 // or checkcast, get the referenced klass. | 225 // or checkcast, get the referenced klass. |
216 ciKlass* get_klass(bool& will_link); | 226 ciKlass* get_klass(bool& will_link); |
217 int get_klass_index() const; | 227 int get_klass_index() const; |
218 | 228 |
219 // If this bytecode is one of the ldc variants, get the referenced | 229 // If this bytecode is one of the ldc variants, get the referenced |
220 // constant | 230 // constant. Do not attempt to resolve it, since that would require |
231 // execution of Java code. If it is not resolved, return an unloaded | |
232 // object (ciConstant.as_object()->is_loaded() == false). | |
221 ciConstant get_constant(); | 233 ciConstant get_constant(); |
222 // True if the ldc variant points to an unresolved string | 234 constantTag get_constant_pool_tag(int index) const; |
223 bool is_unresolved_string() const; | 235 |
224 // True if the ldc variant points to an unresolved klass | 236 // True if the klass-using bytecode points to an unresolved klass |
225 bool is_unresolved_klass() const; | 237 bool is_unresolved_klass() const { |
238 constantTag tag = get_constant_pool_tag(get_klass_index()); | |
239 return tag.is_unresolved_klass(); | |
240 } | |
226 | 241 |
227 // If this bytecode is one of get_field, get_static, put_field, | 242 // If this bytecode is one of get_field, get_static, put_field, |
228 // or put_static, get the referenced field. | 243 // or put_static, get the referenced field. |
229 ciField* get_field(bool& will_link); | 244 ciField* get_field(bool& will_link); |
230 | 245 |
236 ciMethod* get_method(bool& will_link); | 251 ciMethod* get_method(bool& will_link); |
237 ciKlass* get_declared_method_holder(); | 252 ciKlass* get_declared_method_holder(); |
238 int get_method_holder_index(); | 253 int get_method_holder_index(); |
239 int get_method_signature_index(); | 254 int get_method_signature_index(); |
240 | 255 |
241 ciCPCache* get_cpcache(); | 256 ciCPCache* get_cpcache() const; |
242 ciCallSite* get_call_site(); | 257 ciCallSite* get_call_site(); |
243 }; | 258 }; |
244 | 259 |
245 | 260 |
246 // ciSignatureStream | 261 // ciSignatureStream |