Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/constantPoolKlass.cpp @ 2264:a97fd181b813
Merge
author | kvn |
---|---|
date | Wed, 23 Feb 2011 11:18:16 -0800 |
parents | 183658a2d0b3 |
children | b099aaf51bf8 |
comparison
equal
deleted
inserted
replaced
2263:5841dc1964f0 | 2264:a97fd181b813 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
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 |
80 // Note: because we may be in this "conc_unsafe" state when allocating | |
81 // t_oop below, which may in turn cause a GC, it is imperative that our | |
82 // size be correct, consistent and henceforth stable, at this stage. | |
83 assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable"); | |
84 assert(size == pool->size(), "size() is wrong"); | |
85 | |
74 // initialize tag array | 86 // initialize tag array |
75 // Note: cannot introduce constant pool handle before since it is not | |
76 // completely initialized (no class) -> would cause assertion failure | |
77 constantPoolHandle pool (THREAD, c); | |
78 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); | 87 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); |
79 typeArrayHandle tags (THREAD, t_oop); | 88 typeArrayHandle tags (THREAD, t_oop); |
80 for (int index = 0; index < length; index++) { | 89 for (int index = 0; index < length; index++) { |
81 tags()->byte_at_put(index, JVM_CONSTANT_Invalid); | 90 tags()->byte_at_put(index, JVM_CONSTANT_Invalid); |
82 } | 91 } |
83 pool->set_tags(tags()); | 92 pool->set_tags(tags()); |
84 | 93 |
94 // Check that our size was stable at its old value. | |
95 assert(size == pool->size(), "size() changed"); | |
85 return pool(); | 96 return pool(); |
86 } | 97 } |
87 | 98 |
88 klassOop constantPoolKlass::create_klass(TRAPS) { | 99 klassOop constantPoolKlass::create_klass(TRAPS) { |
89 constantPoolKlass o; | 100 constantPoolKlass o; |
266 } | 277 } |
267 PSParallelCompact::adjust_pointer(cp->tags_addr()); | 278 PSParallelCompact::adjust_pointer(cp->tags_addr()); |
268 PSParallelCompact::adjust_pointer(cp->cache_addr()); | 279 PSParallelCompact::adjust_pointer(cp->cache_addr()); |
269 PSParallelCompact::adjust_pointer(cp->operands_addr()); | 280 PSParallelCompact::adjust_pointer(cp->operands_addr()); |
270 PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); | 281 PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); |
271 return cp->object_size(); | |
272 } | |
273 | |
274 int | |
275 constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
276 HeapWord* beg_addr, HeapWord* end_addr) { | |
277 assert (obj->is_constantPool(), "obj must be constant pool"); | |
278 constantPoolOop cp = (constantPoolOop) obj; | |
279 | |
280 // If the tags array is null we are in the middle of allocating this constant | |
281 // pool. | |
282 if (cp->tags() != NULL) { | |
283 oop* base = (oop*)cp->base(); | |
284 oop* const beg_oop = MAX2((oop*)beg_addr, base); | |
285 oop* const end_oop = MIN2((oop*)end_addr, base + cp->length()); | |
286 const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*)); | |
287 const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*)); | |
288 for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) { | |
289 if (cp->is_pointer_entry(int(cur_idx))) { | |
290 PSParallelCompact::adjust_pointer(base); | |
291 } | |
292 } | |
293 } | |
294 | |
295 oop* p; | |
296 p = cp->tags_addr(); | |
297 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
298 p = cp->cache_addr(); | |
299 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
300 p = cp->operands_addr(); | |
301 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
302 p = cp->pool_holder_addr(); | |
303 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
304 | |
305 return cp->object_size(); | 282 return cp->object_size(); |
306 } | 283 } |
307 | 284 |
308 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | 285 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
309 assert(obj->is_constantPool(), "should be constant pool"); | 286 assert(obj->is_constantPool(), "should be constant pool"); |