Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/runtime/VirtualBaseConstructor.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 | f6f3bb0ee072 |
children |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2000, 2011, 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. |
45 public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName, Class unknownTypeHandler) { | 45 public VirtualBaseConstructor(TypeDataBase db, Type baseType, String packageName, Class unknownTypeHandler) { |
46 this.db = (HotSpotTypeDataBase)db; | 46 this.db = (HotSpotTypeDataBase)db; |
47 map = new HashMap(); | 47 map = new HashMap(); |
48 this.baseType = baseType; | 48 this.baseType = baseType; |
49 this.unknownTypeHandler = unknownTypeHandler; | 49 this.unknownTypeHandler = unknownTypeHandler; |
50 if (packageName != null) { | |
50 // Try to find mirror types for each of the types. If there isn't | 51 // Try to find mirror types for each of the types. If there isn't |
51 // a direct mirror then try to find an instantiable superclass and | 52 // a direct mirror then try to find an instantiable superclass and |
52 // treat it as that. | 53 // treat it as that. |
53 for (Iterator iter = db.getTypes(); iter.hasNext(); ) { | 54 for (Iterator iter = db.getTypes(); iter.hasNext(); ) { |
54 Type t = (Type) iter.next(); | 55 Type t = (Type) iter.next(); |
71 } | 72 } |
72 map.put(t.getName(), c); | 73 map.put(t.getName(), c); |
73 } | 74 } |
74 } | 75 } |
75 } | 76 } |
77 } | |
78 | |
79 /** Adds a mapping from the given C++ type name to the given Java | |
80 class. The latter must be a subclass of | |
81 sun.jvm.hotspot.runtime.VMObject. Returns false if there was | |
82 already a class for this type name in the map. */ | |
83 public boolean addMapping(String cTypeName, Class clazz) { | |
84 if (map.get(cTypeName) != null) { | |
85 return false; | |
86 } | |
87 | |
88 map.put(cTypeName, clazz); | |
89 return true; | |
90 } | |
76 | 91 |
77 /** Instantiate the most-precisely typed wrapper object available | 92 /** Instantiate the most-precisely typed wrapper object available |
78 for the type of the given Address. If no type in the mapping | 93 for the type of the given Address. If no type in the mapping |
79 matched the type of the Address, throws a WrongTypeException. | 94 matched the type of the Address, throws a WrongTypeException. |
80 Returns null for a null address (similar behavior to | 95 Returns null for a null address (similar behavior to |
81 VMObjectFactory). */ | 96 VMObjectFactory). */ |
82 public VMObject instantiateWrapperFor(Address addr) throws WrongTypeException { | 97 public T instantiateWrapperFor(Address addr) throws WrongTypeException { |
83 if (addr == null) { | 98 if (addr == null) { |
84 return null; | 99 return null; |
85 } | 100 } |
86 | 101 |
87 Type type = db.findDynamicTypeForAddress(addr, baseType); | 102 Type type = db.findDynamicTypeForAddress(addr, baseType); |
88 if (type != null) { | 103 if (type != null) { |
89 return (VMObject) VMObjectFactory.newObject((Class) map.get(type.getName()), addr); | 104 return (T) VMObjectFactory.newObject((Class) map.get(type.getName()), addr); |
90 } else if (unknownTypeHandler != null) { | 105 } else if (unknownTypeHandler != null) { |
91 return (VMObject) VMObjectFactory.newObject(unknownTypeHandler, addr); | 106 return (T) VMObjectFactory.newObject(unknownTypeHandler, addr); |
92 } | 107 } |
93 | 108 |
94 throw newWrongTypeException(addr); | 109 throw newWrongTypeException(addr); |
95 } | 110 } |
96 } | 111 } |