Mercurial > hg > truffle
comparison src/share/vm/oops/constantPoolOop.cpp @ 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 | a61af66fc99e |
children | ad8c8ca4ab0f 2328d1d3f8cf |
comparison
equal
deleted
inserted
replaced
430:4d20a3aaf1ab | 431:a45484ea312d |
---|---|
23 */ | 23 */ |
24 | 24 |
25 # include "incls/_precompiled.incl" | 25 # include "incls/_precompiled.incl" |
26 # include "incls/_constantPoolOop.cpp.incl" | 26 # include "incls/_constantPoolOop.cpp.incl" |
27 | 27 |
28 void constantPoolOopDesc::set_flag_at(FlagBit fb) { | |
29 const int MAX_STATE_CHANGES = 2; | |
30 for (int i = MAX_STATE_CHANGES + 10; i > 0; i--) { | |
31 int oflags = _flags; | |
32 int nflags = oflags | (1 << (int)fb); | |
33 if (Atomic::cmpxchg(nflags, &_flags, oflags) == oflags) | |
34 return; | |
35 } | |
36 assert(false, "failed to cmpxchg flags"); | |
37 _flags |= (1 << (int)fb); // better than nothing | |
38 } | |
39 | |
28 klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) { | 40 klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) { |
29 // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop. | 41 // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop. |
30 // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and | 42 // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and |
31 // tag is not updated atomicly. | 43 // tag is not updated atomicly. |
32 oop entry = *(this_oop->obj_at_addr(which)); | 44 oop entry = *(this_oop->obj_at_addr(which)); |
331 char* constantPoolOopDesc::string_at_noresolve(int which) { | 343 char* constantPoolOopDesc::string_at_noresolve(int which) { |
332 // Test entry type in case string is resolved while in here. | 344 // Test entry type in case string is resolved while in here. |
333 oop entry = *(obj_at_addr(which)); | 345 oop entry = *(obj_at_addr(which)); |
334 if (entry->is_symbol()) { | 346 if (entry->is_symbol()) { |
335 return ((symbolOop)entry)->as_C_string(); | 347 return ((symbolOop)entry)->as_C_string(); |
348 } else if (java_lang_String::is_instance(entry)) { | |
349 return java_lang_String::as_utf8_string(entry); | |
336 } else { | 350 } else { |
337 return java_lang_String::as_utf8_string(entry); | 351 return (char*)"<pseudo-string>"; |
338 } | 352 } |
339 } | 353 } |
340 | 354 |
341 | 355 |
342 symbolOop constantPoolOopDesc::name_ref_at(int which) { | 356 symbolOop constantPoolOopDesc::name_ref_at(int which) { |
383 assert(java_lang_String::is_instance(entry), "must be string"); | 397 assert(java_lang_String::is_instance(entry), "must be string"); |
384 return entry; | 398 return entry; |
385 } | 399 } |
386 | 400 |
387 | 401 |
402 bool constantPoolOopDesc::is_pseudo_string_at(int which) { | |
403 oop entry = *(obj_at_addr(which)); | |
404 if (entry->is_symbol()) | |
405 // Not yet resolved, but it will resolve to a string. | |
406 return false; | |
407 else if (java_lang_String::is_instance(entry)) | |
408 return false; // actually, it might be a non-interned or non-perm string | |
409 else | |
410 // truly pseudo | |
411 return true; | |
412 } | |
413 | |
414 | |
388 bool constantPoolOopDesc::klass_name_at_matches(instanceKlassHandle k, | 415 bool constantPoolOopDesc::klass_name_at_matches(instanceKlassHandle k, |
389 int which) { | 416 int which) { |
390 // Names are interned, so we can compare symbolOops directly | 417 // Names are interned, so we can compare symbolOops directly |
391 symbolOop cp_name = klass_name_at(which); | 418 symbolOop cp_name = klass_name_at(which); |
392 return (cp_name == k->name()); | 419 return (cp_name == k->name()); |