comparison src/share/vm/oops/constantPoolOop.hpp @ 726:be93aad57795

6655646: dynamic languages need dynamically linked call sites Summary: invokedynamic instruction (JSR 292 RI) Reviewed-by: twisti, never
author jrose
date Tue, 21 Apr 2009 23:21:04 -0700
parents 0fbdb4381b99
children 389049f3f393
comparison
equal deleted inserted replaced
725:928912ce8438 726:be93aad57795
51 void set_tags(typeArrayOop tags) { oop_store_without_check((oop*)&_tags, tags); } 51 void set_tags(typeArrayOop tags) { oop_store_without_check((oop*)&_tags, tags); }
52 void tag_at_put(int which, jbyte t) { tags()->byte_at_put(which, t); } 52 void tag_at_put(int which, jbyte t) { tags()->byte_at_put(which, t); }
53 void release_tag_at_put(int which, jbyte t) { tags()->release_byte_at_put(which, t); } 53 void release_tag_at_put(int which, jbyte t) { tags()->release_byte_at_put(which, t); }
54 54
55 enum FlagBit { 55 enum FlagBit {
56 FB_has_invokedynamic = 1,
56 FB_has_pseudo_string = 2 57 FB_has_pseudo_string = 2
57 }; 58 };
58 59
59 int flags() const { return _flags; } 60 int flags() const { return _flags; }
60 void set_flags(int f) { _flags = f; } 61 void set_flags(int f) { _flags = f; }
94 95
95 public: 96 public:
96 typeArrayOop tags() const { return _tags; } 97 typeArrayOop tags() const { return _tags; }
97 98
98 bool has_pseudo_string() const { return flag_at(FB_has_pseudo_string); } 99 bool has_pseudo_string() const { return flag_at(FB_has_pseudo_string); }
100 bool has_invokedynamic() const { return flag_at(FB_has_invokedynamic); }
99 void set_pseudo_string() { set_flag_at(FB_has_pseudo_string); } 101 void set_pseudo_string() { set_flag_at(FB_has_pseudo_string); }
102 void set_invokedynamic() { set_flag_at(FB_has_invokedynamic); }
100 103
101 // Klass holding pool 104 // Klass holding pool
102 klassOop pool_holder() const { return _pool_holder; } 105 klassOop pool_holder() const { return _pool_holder; }
103 void set_pool_holder(klassOop k) { oop_store_without_check((oop*)&_pool_holder, (oop) k); } 106 void set_pool_holder(klassOop k) { oop_store_without_check((oop*)&_pool_holder, (oop) k); }
104 oop* pool_holder_addr() { return (oop*)&_pool_holder; } 107 oop* pool_holder_addr() { return (oop*)&_pool_holder; }
336 jint name_and_type_at(int which) { 339 jint name_and_type_at(int which) {
337 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool"); 340 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool");
338 return *int_at_addr(which); 341 return *int_at_addr(which);
339 } 342 }
340 343
341 // The following methods (klass_ref_at, klass_ref_at_noresolve, name_ref_at, 344 // The following methods (name/signature/klass_ref_at, klass_ref_at_noresolve,
342 // signature_ref_at, klass_ref_index_at, name_and_type_ref_index_at, 345 // name_and_type_ref_index_at) all expect constant pool indices
343 // name_ref_index_at, signature_ref_index_at) all expect constant pool indices
344 // from the bytecodes to be passed in, which are actually potentially byte-swapped 346 // from the bytecodes to be passed in, which are actually potentially byte-swapped
345 // contstant pool cache indices. See field_or_method_at. 347 // or rewritten constant pool cache indices. They all call map_instruction_operand_to_index.
348 int map_instruction_operand_to_index(int operand);
349
350 // There are also "uncached" versions which do not map the operand index; see below.
346 351
347 // Lookup for entries consisting of (klass_index, name_and_type index) 352 // Lookup for entries consisting of (klass_index, name_and_type index)
348 klassOop klass_ref_at(int which, TRAPS); 353 klassOop klass_ref_at(int which, TRAPS);
349 symbolOop klass_ref_at_noresolve(int which); 354 symbolOop klass_ref_at_noresolve(int which);
350 symbolOop name_ref_at(int which); 355 symbolOop name_ref_at(int which) { return impl_name_ref_at(which, false); }
351 symbolOop signature_ref_at(int which); // the type descriptor 356 symbolOop signature_ref_at(int which) { return impl_signature_ref_at(which, false); }
352 357
353 int klass_ref_index_at(int which); 358 int klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, false); }
354 int name_and_type_ref_index_at(int which); 359 int name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, false); }
355 360
356 // Lookup for entries consisting of (name_index, signature_index) 361 // Lookup for entries consisting of (name_index, signature_index)
357 int name_ref_index_at(int which); 362 int name_ref_index_at(int which_nt); // == low-order jshort of name_and_type_at(which_nt)
358 int signature_ref_index_at(int which); 363 int signature_ref_index_at(int which_nt); // == high-order jshort of name_and_type_at(which_nt)
364 symbolOop nt_name_ref_at(int which_nt) { return symbol_at(name_ref_index_at(which_nt)); }
365 symbolOop nt_signature_ref_at(int which_nt) { return symbol_at(signature_ref_index_at(which_nt)); }
359 366
360 BasicType basic_type_for_signature_at(int which); 367 BasicType basic_type_for_signature_at(int which);
361 368
362 // Resolve string constants (to prevent allocation during compilation) 369 // Resolve string constants (to prevent allocation during compilation)
363 void resolve_string_constants(TRAPS) { 370 void resolve_string_constants(TRAPS) {
395 static klassOop klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int which, TRAPS); 402 static klassOop klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int which, TRAPS);
396 403
397 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the 404 // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
398 // future by other Java code. These take constant pool indices rather than possibly-byte-swapped 405 // future by other Java code. These take constant pool indices rather than possibly-byte-swapped
399 // constant pool cache indices as do the peer methods above. 406 // constant pool cache indices as do the peer methods above.
400 symbolOop uncached_name_ref_at(int which); 407 symbolOop uncached_name_ref_at(int which) { return impl_name_ref_at(which, true); }
401 symbolOop uncached_signature_ref_at(int which); 408 symbolOop uncached_signature_ref_at(int which) { return impl_signature_ref_at(which, true); }
402 int uncached_klass_ref_index_at(int which); 409 int uncached_klass_ref_index_at(int which) { return impl_klass_ref_index_at(which, true); }
403 int uncached_name_and_type_ref_index_at(int which); 410 int uncached_name_and_type_ref_index_at(int which) { return impl_name_and_type_ref_index_at(which, true); }
404 411
405 // Sharing 412 // Sharing
406 int pre_resolve_shared_klasses(TRAPS); 413 int pre_resolve_shared_klasses(TRAPS);
407 void shared_symbols_iterate(OopClosure* closure0); 414 void shared_symbols_iterate(OopClosure* closure0);
408 void shared_tags_iterate(OopClosure* closure0); 415 void shared_tags_iterate(OopClosure* closure0);
411 // Debugging 418 // Debugging
412 const char* printable_name_at(int which) PRODUCT_RETURN0; 419 const char* printable_name_at(int which) PRODUCT_RETURN0;
413 420
414 private: 421 private:
415 422
423 symbolOop impl_name_ref_at(int which, bool uncached);
424 symbolOop impl_signature_ref_at(int which, bool uncached);
425 int impl_klass_ref_index_at(int which, bool uncached);
426 int impl_name_and_type_ref_index_at(int which, bool uncached);
427
416 // Takes either a constant pool cache index in possibly byte-swapped 428 // Takes either a constant pool cache index in possibly byte-swapped
417 // byte order (which comes from the bytecodes after rewriting) or, 429 // byte order (which comes from the bytecodes after rewriting) or,
418 // if "uncached" is true, a vanilla constant pool index 430 // if "uncached" is true, a vanilla constant pool index
419 jint field_or_method_at(int which, bool uncached) { 431 jint field_or_method_at(int which, bool uncached) {
420 int i = -1; 432 int i = which;
421 if (uncached || cache() == NULL) { 433 if (!uncached && cache() != NULL) {
422 i = which;
423 } else {
424 // change byte-ordering and go via cache 434 // change byte-ordering and go via cache
425 i = cache()->entry_at(Bytes::swap_u2(which))->constant_pool_index(); 435 i = map_instruction_operand_to_index(which);
426 } 436 }
427 assert(tag_at(i).is_field_or_method(), "Corrupted constant pool"); 437 assert(tag_at(i).is_field_or_method(), "Corrupted constant pool");
428 return *int_at_addr(i); 438 return *int_at_addr(i);
429 } 439 }
430 440