Mercurial > hg > graal-jvmci-8
comparison agent/src/share/classes/sun/jvm/hotspot/utilities/RobustOopDeterminator.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 | c18cbe5936b8 |
children | 8e47bac5643a |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2000, 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. |
25 package sun.jvm.hotspot.utilities; | 25 package sun.jvm.hotspot.utilities; |
26 | 26 |
27 import java.util.*; | 27 import java.util.*; |
28 import sun.jvm.hotspot.debugger.*; | 28 import sun.jvm.hotspot.debugger.*; |
29 import sun.jvm.hotspot.memory.*; | 29 import sun.jvm.hotspot.memory.*; |
30 import sun.jvm.hotspot.oops.Metadata; | |
31 import sun.jvm.hotspot.oops.Klass; | |
30 import sun.jvm.hotspot.runtime.*; | 32 import sun.jvm.hotspot.runtime.*; |
31 import sun.jvm.hotspot.types.*; | 33 import sun.jvm.hotspot.types.*; |
32 | 34 |
33 /** This class determines to the best of its ability, and in a | 35 /** This class determines to the best of its ability, and in a |
34 reasonably robust fashion, whether a given pointer is an intact | 36 reasonably robust fashion, whether a given pointer is an intact |
36 metaclass hierarchy. This is only intended for use in the | 38 metaclass hierarchy. This is only intended for use in the |
37 debugging system. It may provide more resilience to unexpected VM | 39 debugging system. It may provide more resilience to unexpected VM |
38 states than the ObjectHeap code. */ | 40 states than the ObjectHeap code. */ |
39 | 41 |
40 public class RobustOopDeterminator { | 42 public class RobustOopDeterminator { |
41 private static OopField klassField; | 43 private static AddressField klassField; |
42 | 44 |
43 static { | 45 static { |
44 VM.registerVMInitializedObserver(new Observer() { | 46 VM.registerVMInitializedObserver(new Observer() { |
45 public void update(Observable o, Object data) { | 47 public void update(Observable o, Object data) { |
46 initialize(VM.getVM().getTypeDataBase()); | 48 initialize(VM.getVM().getTypeDataBase()); |
49 } | 51 } |
50 | 52 |
51 private static void initialize(TypeDataBase db) { | 53 private static void initialize(TypeDataBase db) { |
52 Type type = db.lookupType("oopDesc"); | 54 Type type = db.lookupType("oopDesc"); |
53 | 55 |
54 if (VM.getVM().isCompressedOopsEnabled()) { | 56 if (VM.getVM().isCompressedHeadersEnabled()) { |
55 klassField = type.getNarrowOopField("_metadata._compressed_klass"); | 57 // klassField = type.getNarrowOopField("_metadata._compressed_klass"); |
58 throw new InternalError("unimplemented"); | |
56 } else { | 59 } else { |
57 klassField = type.getOopField("_metadata._klass"); | 60 klassField = type.getAddressField("_metadata._klass"); |
58 } | 61 } |
59 } | 62 } |
60 | 63 |
61 public static boolean oopLooksValid(OopHandle oop) { | 64 public static boolean oopLooksValid(OopHandle oop) { |
62 if (oop == null) { | 65 if (oop == null) { |
64 } | 67 } |
65 if (!VM.getVM().getUniverse().isIn(oop)) { | 68 if (!VM.getVM().getUniverse().isIn(oop)) { |
66 return false; | 69 return false; |
67 } | 70 } |
68 try { | 71 try { |
69 for (int i = 0; i < 4; ++i) { | 72 // Try to instantiate the Klass |
70 OopHandle next = klassField.getValue(oop); | 73 Metadata.instantiateWrapperFor(klassField.getValue(oop)); |
71 if (next == null) { | |
72 return false; | |
73 } | |
74 if (next.equals(oop)) { | |
75 return true; | 74 return true; |
76 } | 75 } |
77 oop = next; | |
78 } | |
79 return false; | |
80 } | |
81 catch (AddressException e) { | 76 catch (AddressException e) { |
82 return false; | 77 return false; |
83 } | 78 } |
84 } | 79 } |
85 } | 80 } |