Request for review: 7046490 - Preallocated OOME objects should obey Throwable stack trace protocol

Krystal Mok rednaxelafx at gmail.com
Wed Jul 20 07:44:35 PDT 2011


Hi David,

Following the mailing list, moving the static fields from instanceKlass into java.lang.Class was a part of the recent steps to remove PermGen, as far as I understand.

Regards,
Kris Mok

On 2011-7-20, at 2:26, David Holmes <David.Holmes at oracle.com> wrote:

> Hi Tom,
> 
> Thomas Rodriguez said the following on 07/20/11 00:09:
>> You can use ik->java_mirror()->obj_field(offset) to read static fields. I don't know why the others are done as they are. maybe just history. 
> 
> Is there a different way to calculate the offset in this case? I tried this using the existing static_unassigned_stacktrace_offset and while I had no problems reading that value and setting it into the Throwable, as soon as I tried to access the stacktrace field containing that value I got a SEGV in LinkResolver::resolve_invokevirtual
> 
> I must admit I was a bit puzzled by your suggestion. The java_mirror() is the oop for the Class object, but I didn't think that we stored static fields as instance fields of the Class object ???
> 
> Thanks,
> David
> 
>> tom
>> On Jul 18, 2011, at 9:02 PM, David Holmes <David.Holmes at oracle.com> wrote:
>>> Paul Hohensee said the following on 07/19/11 13:32:
>>>> Looks good, except, could you use obj_field() in unassigned_stacktrace() instead of checking UseCompressedOops there?
>>> Thanks Paul.
>>> 
>>> I don't think I can use obj_field() as it is for accessing instances and this is a static field. I copied the code for reading the static field from the java.lang.ref functions:
>>> 
>>> 2286 // Support for java_lang_ref_Reference
>>> 2287 oop java_lang_ref_Reference::pending_list_lock() {
>>> 2288   instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
>>> 2289   address addr = ik->static_field_addr(static_lock_offset);
>>> 2290   if (UseCompressedOops) {
>>> 2291     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
>>> 2292   } else {
>>> 2293     return oopDesc::load_decode_heap_oop((oop*)addr);
>>> 2294   }
>>> 2295 }
>>> 2296
>>> 2297 HeapWord *java_lang_ref_Reference::pending_list_addr() {
>>> 2298   instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
>>> 2299   address addr = ik->static_field_addr(static_pending_offset);
>>> 2300   // XXX This might not be HeapWord aligned, almost rather be char *.
>>> 2301   return (HeapWord*)addr;
>>> 2302 }
>>> 2303
>>> 2304 oop java_lang_ref_Reference::pending_list() {
>>> 2305   char *addr = (char *)pending_list_addr();
>>> 2306   if (UseCompressedOops) {
>>> 2307     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
>>> 2308   } else {
>>> 2309     return oopDesc::load_decode_heap_oop((oop*)addr);
>>> 2310   }
>>> 2311 }
>>> 
>>> David
>>> -----
>>> 
>>>> Paul
>>>> On 7/7/11 1:25 AM, David Holmes wrote:
>>>>> http://cr.openjdk.java.net/~dholmes/7046490/webrev/
>>>>> 
>>>>> This is a simple fix in the VM to honour the Throwable immutability protocol that was defined for Java 7. Pre-allocated Throwable instances are normally immutable, but that is not the case for a group of pre-allocated OutOfMemoryError instances. To conform to the protocol, when we set the backtrace (VM representation of the stackTrace) we have to set the stackTrace field to the sentinel value stored in the static Throwable.UNASSIGNED_STACK field.
>>>>> 
>>>>> With this fix in place the workaround in Throwable.java, under 7045138, can be backed out.
>>>>> 
>>>>> Thanks,
>>>>> David
>>>>> 
>>>>> 
>>>>> 


More information about the hotspot-runtime-dev mailing list