comparison src/share/vm/oops/constantPoolOop.hpp @ 431:a45484ea312d

6653858: dynamic languages need to be able to load anonymous classes Summary: low-level privileged sun.misc.Unsafe.defineAnonymousClass Reviewed-by: kvn
author jrose
date Wed, 12 Nov 2008 22:33:26 -0800
parents d1605aabd0a1
children 0af8b0718fc9
comparison
equal deleted inserted replaced
430:4d20a3aaf1ab 431:a45484ea312d
39 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast 39 friend class BytecodeInterpreter; // Directly extracts an oop in the pool for fast instanceof/checkcast
40 private: 40 private:
41 typeArrayOop _tags; // the tag array describing the constant pool's contents 41 typeArrayOop _tags; // the tag array describing the constant pool's contents
42 constantPoolCacheOop _cache; // the cache holding interpreter runtime information 42 constantPoolCacheOop _cache; // the cache holding interpreter runtime information
43 klassOop _pool_holder; // the corresponding class 43 klassOop _pool_holder; // the corresponding class
44 int _flags; // a few header bits to describe contents for GC
44 int _length; // number of elements in the array 45 int _length; // number of elements in the array
45 // only set to non-zero if constant pool is merged by RedefineClasses 46 // only set to non-zero if constant pool is merged by RedefineClasses
46 int _orig_length; 47 int _orig_length;
47 48
48 void set_tags(typeArrayOop tags) { oop_store_without_check((oop*)&_tags, tags); } 49 void set_tags(typeArrayOop tags) { oop_store_without_check((oop*)&_tags, tags); }
49 void tag_at_put(int which, jbyte t) { tags()->byte_at_put(which, t); } 50 void tag_at_put(int which, jbyte t) { tags()->byte_at_put(which, t); }
50 void release_tag_at_put(int which, jbyte t) { tags()->release_byte_at_put(which, t); } 51 void release_tag_at_put(int which, jbyte t) { tags()->release_byte_at_put(which, t); }
52
53 enum FlagBit {
54 FB_has_pseudo_string = 2
55 };
56
57 int flags() const { return _flags; }
58 void set_flags(int f) { _flags = f; }
59 bool flag_at(FlagBit fb) const { return (_flags & (1 << (int)fb)) != 0; }
60 void set_flag_at(FlagBit fb);
61 // no clear_flag_at function; they only increase
51 62
52 private: 63 private:
53 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(constantPoolOopDesc)); } 64 intptr_t* base() const { return (intptr_t*) (((char*) this) + sizeof(constantPoolOopDesc)); }
54 oop* tags_addr() { return (oop*)&_tags; } 65 oop* tags_addr() { return (oop*)&_tags; }
55 oop* cache_addr() { return (oop*)&_cache; } 66 oop* cache_addr() { return (oop*)&_cache; }
79 return (jdouble*) &base()[which]; 90 return (jdouble*) &base()[which];
80 } 91 }
81 92
82 public: 93 public:
83 typeArrayOop tags() const { return _tags; } 94 typeArrayOop tags() const { return _tags; }
95
96 bool has_pseudo_string() const { return flag_at(FB_has_pseudo_string); }
97 void set_pseudo_string() { set_flag_at(FB_has_pseudo_string); }
84 98
85 // Klass holding pool 99 // Klass holding pool
86 klassOop pool_holder() const { return _pool_holder; } 100 klassOop pool_holder() const { return _pool_holder; }
87 void set_pool_holder(klassOop k) { oop_store_without_check((oop*)&_pool_holder, (oop) k); } 101 void set_pool_holder(klassOop k) { oop_store_without_check((oop*)&_pool_holder, (oop) k); }
88 oop* pool_holder_addr() { return (oop*)&_pool_holder; } 102 oop* pool_holder_addr() { return (oop*)&_pool_holder; }
270 oop string_at(int which, TRAPS) { 284 oop string_at(int which, TRAPS) {
271 constantPoolHandle h_this(THREAD, this); 285 constantPoolHandle h_this(THREAD, this);
272 return string_at_impl(h_this, which, CHECK_NULL); 286 return string_at_impl(h_this, which, CHECK_NULL);
273 } 287 }
274 288
289 // A "pseudo-string" is an non-string oop that has found is way into
290 // a String entry.
291 // Under AnonymousClasses this can happen if the user patches a live
292 // object into a CONSTANT_String entry of an anonymous class.
293 // Method oops internally created for method handles may also
294 // use pseudo-strings to link themselves to related metaobjects.
295
296 bool is_pseudo_string_at(int which);
297
298 oop pseudo_string_at(int which) {
299 assert(tag_at(which).is_string(), "Corrupted constant pool");
300 return *obj_at_addr(which);
301 }
302
303 void pseudo_string_at_put(int which, oop x) {
304 assert(AnonymousClasses, "");
305 set_pseudo_string(); // mark header
306 assert(tag_at(which).is_string() || tag_at(which).is_unresolved_string(), "Corrupted constant pool");
307 string_at_put(which, x); // this works just fine
308 }
309
275 // only called when we are sure a string entry is already resolved (via an 310 // only called when we are sure a string entry is already resolved (via an
276 // earlier string_at call. 311 // earlier string_at call.
277 oop resolved_string_at(int which) { 312 oop resolved_string_at(int which) {
278 assert(tag_at(which).is_string(), "Corrupted constant pool"); 313 assert(tag_at(which).is_string(), "Corrupted constant pool");
279 // Must do an acquire here in case another thread resolved the klass 314 // Must do an acquire here in case another thread resolved the klass
291 326
292 // Returns an UTF8 for a CONSTANT_String entry at a given index. 327 // Returns an UTF8 for a CONSTANT_String entry at a given index.
293 // UTF8 char* representation was chosen to avoid conversion of 328 // UTF8 char* representation was chosen to avoid conversion of
294 // java_lang_Strings at resolved entries into symbolOops 329 // java_lang_Strings at resolved entries into symbolOops
295 // or vice versa. 330 // or vice versa.
331 // Caller is responsible for checking for pseudo-strings.
296 char* string_at_noresolve(int which); 332 char* string_at_noresolve(int which);
297 333
298 jint name_and_type_at(int which) { 334 jint name_and_type_at(int which) {
299 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool"); 335 assert(tag_at(which).is_name_and_type(), "Corrupted constant pool");
300 return *int_at_addr(which); 336 return *int_at_addr(which);