comparison src/share/vm/oops/constantPoolKlass.cpp @ 2229:183658a2d0b3

7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes Summary: 6912621 used a raw oop in the newly added assert following an allocation attempt that could result in a GC. Reviewed-by: jmasa
author ysr
date Thu, 10 Feb 2011 14:48:07 -0800
parents e5383553fd4e
children b099aaf51bf8
comparison
equal deleted inserted replaced
2228:59e20a452a2a 2229:183658a2d0b3
53 #endif 53 #endif
54 54
55 constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { 55 constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) {
56 int size = constantPoolOopDesc::object_size(length); 56 int size = constantPoolOopDesc::object_size(length);
57 KlassHandle klass (THREAD, as_klassOop()); 57 KlassHandle klass (THREAD, as_klassOop());
58 constantPoolOop c = 58 assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work");
59 (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); 59 constantPoolHandle pool;
60 60 {
61 c->set_length(length); 61 constantPoolOop c =
62 c->set_tags(NULL); 62 (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
63 c->set_cache(NULL); 63 assert(c->klass_or_null() != NULL, "Handlizing below won't work");
64 c->set_operands(NULL); 64 pool = constantPoolHandle(THREAD, c);
65 c->set_pool_holder(NULL); 65 }
66 c->set_flags(0); 66
67 pool->set_length(length);
68 pool->set_tags(NULL);
69 pool->set_cache(NULL);
70 pool->set_operands(NULL);
71 pool->set_pool_holder(NULL);
72 pool->set_flags(0);
67 // only set to non-zero if constant pool is merged by RedefineClasses 73 // only set to non-zero if constant pool is merged by RedefineClasses
68 c->set_orig_length(0); 74 pool->set_orig_length(0);
69 // if constant pool may change during RedefineClasses, it is created 75 // if constant pool may change during RedefineClasses, it is created
70 // unsafe for GC concurrent processing. 76 // unsafe for GC concurrent processing.
71 c->set_is_conc_safe(is_conc_safe); 77 pool->set_is_conc_safe(is_conc_safe);
72 // all fields are initialized; needed for GC 78 // all fields are initialized; needed for GC
73 79
74 // Note: because we may be in this "conc_unsafe" state when allocating 80 // Note: because we may be in this "conc_unsafe" state when allocating
75 // t_oop below, which may in turn cause a GC, it is imperative that our 81 // t_oop below, which may in turn cause a GC, it is imperative that our
76 // size be correct, consistent and henceforth stable, at this stage. 82 // size be correct, consistent and henceforth stable, at this stage.
77 assert(c->is_parsable(), "Else size() below is unreliable"); 83 assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable");
78 DEBUG_ONLY(int sz = c->size();) 84 assert(size == pool->size(), "size() is wrong");
79 85
80 // initialize tag array 86 // initialize tag array
81 // Note: cannot introduce constant pool handle before since it is not
82 // completely initialized (no class) -> would cause assertion failure
83 constantPoolHandle pool (THREAD, c);
84 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); 87 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL);
85 typeArrayHandle tags (THREAD, t_oop); 88 typeArrayHandle tags (THREAD, t_oop);
86 for (int index = 0; index < length; index++) { 89 for (int index = 0; index < length; index++) {
87 tags()->byte_at_put(index, JVM_CONSTANT_Invalid); 90 tags()->byte_at_put(index, JVM_CONSTANT_Invalid);
88 } 91 }
89 pool->set_tags(tags()); 92 pool->set_tags(tags());
90 93
91 // Check that our size was stable at its old value. 94 // Check that our size was stable at its old value.
92 assert(sz == c->size(), "size() changed"); 95 assert(size == pool->size(), "size() changed");
93 return pool(); 96 return pool();
94 } 97 }
95 98
96 klassOop constantPoolKlass::create_klass(TRAPS) { 99 klassOop constantPoolKlass::create_klass(TRAPS) {
97 constantPoolKlass o; 100 constantPoolKlass o;