Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/java_lang_Class.java @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | e6b1331a51d2 |
children | 8e47bac5643a |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2011, 2012, 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. |
27 import java.util.*; | 27 import java.util.*; |
28 | 28 |
29 import sun.jvm.hotspot.debugger.*; | 29 import sun.jvm.hotspot.debugger.*; |
30 import sun.jvm.hotspot.memory.*; | 30 import sun.jvm.hotspot.memory.*; |
31 import sun.jvm.hotspot.runtime.*; | 31 import sun.jvm.hotspot.runtime.*; |
32 import sun.jvm.hotspot.types.AddressField; | |
32 import sun.jvm.hotspot.types.Type; | 33 import sun.jvm.hotspot.types.Type; |
33 import sun.jvm.hotspot.types.TypeDataBase; | 34 import sun.jvm.hotspot.types.TypeDataBase; |
34 import sun.jvm.hotspot.utilities.*; | 35 import sun.jvm.hotspot.utilities.*; |
35 import sun.jvm.hotspot.jdi.JVMTIThreadState; | 36 import sun.jvm.hotspot.jdi.JVMTIThreadState; |
36 | 37 |
38 | 39 |
39 // initialize fields for java.lang.Class | 40 // initialize fields for java.lang.Class |
40 public class java_lang_Class { | 41 public class java_lang_Class { |
41 | 42 |
42 // java.lang.Class fields | 43 // java.lang.Class fields |
43 static OopField klassField; | 44 static int klassOffset; |
44 static IntField oopSizeField; | 45 static IntField oopSizeField; |
45 | 46 |
46 static { | 47 static { |
47 VM.registerVMInitializedObserver(new Observer() { | 48 VM.registerVMInitializedObserver(new Observer() { |
48 public void update(Observable o, Object data) { | 49 public void update(Observable o, Object data) { |
53 | 54 |
54 private static synchronized void initialize(TypeDataBase db) { | 55 private static synchronized void initialize(TypeDataBase db) { |
55 // klass and oop_size are HotSpot magic fields and hence we can't | 56 // klass and oop_size are HotSpot magic fields and hence we can't |
56 // find them from InstanceKlass for java.lang.Class. | 57 // find them from InstanceKlass for java.lang.Class. |
57 Type jlc = db.lookupType("java_lang_Class"); | 58 Type jlc = db.lookupType("java_lang_Class"); |
58 int klassOffset = (int) jlc.getCIntegerField("_klass_offset").getValue(); | 59 klassOffset = (int) jlc.getCIntegerField("_klass_offset").getValue(); |
59 if (VM.getVM().isCompressedOopsEnabled()) { | |
60 klassField = new NarrowOopField(new NamedFieldIdentifier("klass"), klassOffset, true); | |
61 } else { | |
62 klassField = new OopField(new NamedFieldIdentifier("klass"), klassOffset, true); | |
63 } | |
64 int oopSizeOffset = (int) jlc.getCIntegerField("_oop_size_offset").getValue(); | 60 int oopSizeOffset = (int) jlc.getCIntegerField("_oop_size_offset").getValue(); |
65 oopSizeField = new IntField(new NamedFieldIdentifier("oop_size"), oopSizeOffset, true); | 61 oopSizeField = new IntField(new NamedFieldIdentifier("oop_size"), oopSizeOffset, true); |
66 } | 62 } |
67 | 63 |
68 /** get klassOop field at offset hc_klass_offset from a java.lang.Class object */ | 64 /** get Klass* field at offset hc_klass_offset from a java.lang.Class object */ |
69 public static Klass asKlass(Oop aClass) { | 65 public static Klass asKlass(Oop aClass) { |
70 return (Klass) java_lang_Class.klassField.getValue(aClass); | 66 if (VM.getVM().isCompressedHeadersEnabled()) { |
67 throw new InternalError("unimplemented"); | |
68 } else { | |
69 return (Klass)Metadata.instantiateWrapperFor(aClass.getHandle().getAddressAt(klassOffset)); | |
70 } | |
71 } | 71 } |
72 | 72 |
73 /** get oop_size field at offset oop_size_offset from a java.lang.Class object */ | 73 /** get oop_size field at offset oop_size_offset from a java.lang.Class object */ |
74 public static long getOopSize(Oop aClass) { | 74 public static long getOopSize(Oop aClass) { |
75 return java_lang_Class.oopSizeField.getValue(aClass); | 75 return java_lang_Class.oopSizeField.getValue(aClass); |