comparison src/share/vm/ci/ciStreams.cpp @ 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
184 constantPoolHandle cpool(_method->get_methodOop()->constants()); 184 constantPoolHandle cpool(_method->get_methodOop()->constants());
185 return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder); 185 return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder);
186 } 186 }
187 187
188 // ------------------------------------------------------------------ 188 // ------------------------------------------------------------------
189 // ciBytecodeStream::get_constant_index 189 // ciBytecodeStream::get_constant_raw_index
190 // 190 //
191 // If this bytecode is one of the ldc variants, get the index of the 191 // If this bytecode is one of the ldc variants, get the index of the
192 // referenced constant. 192 // referenced constant.
193 int ciBytecodeStream::get_constant_index() const { 193 int ciBytecodeStream::get_constant_raw_index() const {
194 switch(cur_bc()) { 194 // work-alike for Bytecode_loadconstant::raw_index()
195 switch (cur_bc()) {
195 case Bytecodes::_ldc: 196 case Bytecodes::_ldc:
196 return get_index_u1(); 197 return get_index_u1();
197 case Bytecodes::_ldc_w: 198 case Bytecodes::_ldc_w:
198 case Bytecodes::_ldc2_w: 199 case Bytecodes::_ldc2_w:
199 return get_index_u2(); 200 return get_index_u2();
200 default: 201 default:
201 ShouldNotReachHere(); 202 ShouldNotReachHere();
202 return 0; 203 return 0;
203 } 204 }
204 } 205 }
206
207 // ------------------------------------------------------------------
208 // ciBytecodeStream::get_constant_pool_index
209 // Decode any CP cache index into a regular pool index.
210 int ciBytecodeStream::get_constant_pool_index() const {
211 // work-alike for Bytecode_loadconstant::pool_index()
212 int index = get_constant_raw_index();
213 if (has_cache_index()) {
214 return get_cpcache()->get_pool_index(index);
215 }
216 return index;
217 }
218
219 // ------------------------------------------------------------------
220 // ciBytecodeStream::get_constant_cache_index
221 // Return the CP cache index, or -1 if there isn't any.
222 int ciBytecodeStream::get_constant_cache_index() const {
223 // work-alike for Bytecode_loadconstant::cache_index()
224 return has_cache_index() ? get_constant_raw_index() : -1;
225 }
226
205 // ------------------------------------------------------------------ 227 // ------------------------------------------------------------------
206 // ciBytecodeStream::get_constant 228 // ciBytecodeStream::get_constant
207 // 229 //
208 // If this bytecode is one of the ldc variants, get the referenced 230 // If this bytecode is one of the ldc variants, get the referenced
209 // constant. 231 // constant.
210 ciConstant ciBytecodeStream::get_constant() { 232 ciConstant ciBytecodeStream::get_constant() {
233 int pool_index = get_constant_raw_index();
234 int cache_index = -1;
235 if (has_cache_index()) {
236 cache_index = pool_index;
237 pool_index = -1;
238 }
211 VM_ENTRY_MARK; 239 VM_ENTRY_MARK;
212 constantPoolHandle cpool(_method->get_methodOop()->constants()); 240 constantPoolHandle cpool(_method->get_methodOop()->constants());
213 return CURRENT_ENV->get_constant_by_index(cpool, get_constant_index(), _holder); 241 return CURRENT_ENV->get_constant_by_index(cpool, pool_index, cache_index, _holder);
214 } 242 }
215 243
216 // ------------------------------------------------------------------ 244 // ------------------------------------------------------------------
217 bool ciBytecodeStream::is_unresolved_string() const { 245 // ciBytecodeStream::get_constant_pool_tag
218 return CURRENT_ENV->is_unresolved_string(_holder, get_constant_index()); 246 //
219 } 247 // If this bytecode is one of the ldc variants, get the referenced
220 248 // constant.
221 // ------------------------------------------------------------------ 249 constantTag ciBytecodeStream::get_constant_pool_tag(int index) const {
222 bool ciBytecodeStream::is_unresolved_klass() const { 250 VM_ENTRY_MARK;
223 return CURRENT_ENV->is_unresolved_klass(_holder, get_klass_index()); 251 return _method->get_methodOop()->constants()->tag_at(index);
224 } 252 }
225 253
226 // ------------------------------------------------------------------ 254 // ------------------------------------------------------------------
227 // ciBytecodeStream::get_field_index 255 // ciBytecodeStream::get_field_index
228 // 256 //
376 return cpool->signature_ref_index_at(name_and_type_index); 404 return cpool->signature_ref_index_at(name_and_type_index);
377 } 405 }
378 406
379 // ------------------------------------------------------------------ 407 // ------------------------------------------------------------------
380 // ciBytecodeStream::get_cpcache 408 // ciBytecodeStream::get_cpcache
381 ciCPCache* ciBytecodeStream::get_cpcache() { 409 ciCPCache* ciBytecodeStream::get_cpcache() const {
382 VM_ENTRY_MARK; 410 if (_cpcache == NULL) {
383 // Get the constant pool. 411 VM_ENTRY_MARK;
384 constantPoolOop cpool = _holder->get_instanceKlass()->constants(); 412 // Get the constant pool.
385 constantPoolCacheOop cpcache = cpool->cache(); 413 constantPoolOop cpool = _holder->get_instanceKlass()->constants();
386 414 constantPoolCacheOop cpcache = cpool->cache();
387 return CURRENT_ENV->get_object(cpcache)->as_cpcache(); 415
416 *(ciCPCache**)&_cpcache = CURRENT_ENV->get_object(cpcache)->as_cpcache();
417 }
418 return _cpcache;
388 } 419 }
389 420
390 // ------------------------------------------------------------------ 421 // ------------------------------------------------------------------
391 // ciBytecodeStream::get_call_site 422 // ciBytecodeStream::get_call_site
392 ciCallSite* ciBytecodeStream::get_call_site() { 423 ciCallSite* ciBytecodeStream::get_call_site() {