src/share/vm/ci/ciObject.hpp

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 3969
1d7922586cf6
child 4133
f6b0eb4e44cf
permissions
-rw-r--r--

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>

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CI_CIOBJECT_HPP
stefank@2314 26 #define SHARE_VM_CI_CIOBJECT_HPP
stefank@2314 27
coleenp@4037 28 #include "ci/ciBaseObject.hpp"
stefank@2314 29 #include "ci/ciClassList.hpp"
stefank@2314 30 #include "memory/allocation.hpp"
stefank@2314 31 #include "runtime/handles.hpp"
stefank@2314 32 #include "runtime/jniHandles.hpp"
stefank@2314 33
duke@435 34 // ciObject
duke@435 35 //
duke@435 36 // This class represents an oop in the HotSpot virtual machine.
duke@435 37 // Its subclasses are structured in a hierarchy which mirrors
duke@435 38 // an aggregate of the VM's oop and klass hierarchies (see
duke@435 39 // oopHierarchy.hpp). Each instance of ciObject holds a handle
duke@435 40 // to a corresponding oop on the VM side and provides routines
duke@435 41 // for accessing the information in its oop. By using the ciObject
duke@435 42 // hierarchy for accessing oops in the VM, the compiler ensures
duke@435 43 // that it is safe with respect to garbage collection; that is,
duke@435 44 // GC and compilation can proceed independently without
duke@435 45 // interference.
duke@435 46 //
duke@435 47 // Within the VM, the oop and klass hierarchies are separate.
duke@435 48 // The compiler interface does not preserve this separation --
coleenp@4037 49 // the distinction between `Klass*' and `Klass' are not
duke@435 50 // reflected in the interface and instead the Klass hierarchy
duke@435 51 // is directly modeled as the subclasses of ciKlass.
coleenp@4037 52 class ciObject : public ciBaseObject {
duke@435 53 CI_PACKAGE_ACCESS
duke@435 54 friend class ciEnv;
duke@435 55
duke@435 56 private:
duke@435 57 // A JNI handle referring to an oop in the VM. This
duke@435 58 // handle may, in a small set of cases, correctly be NULL.
duke@435 59 jobject _handle;
duke@435 60 ciKlass* _klass;
duke@435 61
duke@435 62 protected:
duke@435 63 ciObject();
duke@435 64 ciObject(oop o);
duke@435 65 ciObject(Handle h);
duke@435 66 ciObject(ciKlass* klass);
duke@435 67
duke@435 68 jobject handle() const { return _handle; }
duke@435 69 // Get the VM oop that this object holds.
duke@435 70 oop get_oop() const {
duke@435 71 assert(_handle != NULL, "null oop");
duke@435 72 return JNIHandles::resolve_non_null(_handle);
duke@435 73 }
duke@435 74
coleenp@4037 75 void init_flags_from(oop x);
duke@435 76
duke@435 77 // Virtual behavior of the print() method.
duke@435 78 virtual void print_impl(outputStream* st) {}
duke@435 79
duke@435 80 virtual const char* type_string() { return "ciObject"; }
duke@435 81
duke@435 82 public:
duke@435 83 // The klass of this ciObject.
duke@435 84 ciKlass* klass();
duke@435 85
duke@435 86 // Are two ciObjects equal?
duke@435 87 bool equals(ciObject* obj);
duke@435 88
duke@435 89 // A hash value for the convenience of compilers.
duke@435 90 int hash();
duke@435 91
jrose@1424 92 // Tells if this oop has an encoding as a constant.
kvn@2933 93 // True if is_perm is true.
jrose@1424 94 // Also true if ScavengeRootsInCode is non-zero.
duke@435 95 // If it does not have an encoding, the compiler is responsible for
duke@435 96 // making other arrangements for dealing with the oop.
jrose@1424 97 // See ciEnv::make_array
jrose@1424 98 bool can_be_constant();
jrose@1424 99
jrose@1424 100 // Tells if this oop should be made a constant.
kvn@2933 101 // True if is_perm is true or ScavengeRootsInCode > 1.
jrose@1424 102 bool should_be_constant();
duke@435 103
jrose@1424 104 // Might this object possibly move during a scavenge operation?
jrose@1424 105 // If the answer is true and ScavengeRootsInCode==0, the oop cannot be embedded in code.
jrose@1424 106 bool is_scavengable() { return (_ident & SCAVENGABLE_FLAG) != 0; }
jrose@1424 107
duke@435 108 // The address which the compiler should embed into the
duke@435 109 // generated code to represent this oop. This address
duke@435 110 // is not the true address of the oop -- it will get patched
duke@435 111 // during nmethod creation.
duke@435 112 //
duke@435 113 // Usage note: no address arithmetic allowed. Oop must
duke@435 114 // be registered with the oopRecorder.
jrose@1424 115 jobject constant_encoding();
duke@435 116
coleenp@4037 117 virtual bool is_object() const { return true; }
coleenp@4037 118
duke@435 119 // What kind of ciObject is this?
twisti@3969 120 virtual bool is_null_object() const { return false; }
twisti@3969 121 virtual bool is_call_site() const { return false; }
twisti@3969 122 virtual bool is_cpcache() const { return false; }
duke@435 123 virtual bool is_instance() { return false; }
twisti@3969 124 virtual bool is_member_name() const { return false; }
twisti@3969 125 virtual bool is_method_handle() const { return false; }
duke@435 126 virtual bool is_array() { return false; }
duke@435 127 virtual bool is_obj_array() { return false; }
duke@435 128 virtual bool is_type_array() { return false; }
duke@435 129
duke@435 130 // Is this a type or value which has no associated class?
duke@435 131 // It is true of primitive types and null objects.
duke@435 132 virtual bool is_classless() const { return false; }
duke@435 133
coleenp@4037 134 // Note: some ciObjects refer to oops which have yet to be created.
coleenp@4037 135 // We refer to these as "unloaded". Specifically, there are
coleenp@4037 136 // unloaded instances of java.lang.Class,
coleenp@4037 137 // java.lang.invoke.MethodHandle, and java.lang.invoke.MethodType.
coleenp@4037 138 // By convention the ciNullObject is considered loaded, and
coleenp@4037 139 // primitive types are considered loaded.
duke@435 140 bool is_loaded() const {
duke@435 141 return handle() != NULL || is_classless();
duke@435 142 }
duke@435 143
duke@435 144 // Subclass casting with assertions.
duke@435 145 ciNullObject* as_null_object() {
duke@435 146 assert(is_null_object(), "bad cast");
duke@435 147 return (ciNullObject*)this;
duke@435 148 }
twisti@1573 149 ciCallSite* as_call_site() {
twisti@1573 150 assert(is_call_site(), "bad cast");
twisti@1573 151 return (ciCallSite*) this;
twisti@1573 152 }
duke@435 153 ciInstance* as_instance() {
duke@435 154 assert(is_instance(), "bad cast");
duke@435 155 return (ciInstance*)this;
duke@435 156 }
twisti@3969 157 ciMemberName* as_member_name() {
twisti@3969 158 assert(is_member_name(), "bad cast");
twisti@3969 159 return (ciMemberName*)this;
twisti@3969 160 }
twisti@1573 161 ciMethodHandle* as_method_handle() {
twisti@1573 162 assert(is_method_handle(), "bad cast");
twisti@1573 163 return (ciMethodHandle*) this;
twisti@1573 164 }
duke@435 165 ciArray* as_array() {
duke@435 166 assert(is_array(), "bad cast");
duke@435 167 return (ciArray*)this;
duke@435 168 }
duke@435 169 ciObjArray* as_obj_array() {
duke@435 170 assert(is_obj_array(), "bad cast");
duke@435 171 return (ciObjArray*)this;
duke@435 172 }
duke@435 173 ciTypeArray* as_type_array() {
duke@435 174 assert(is_type_array(), "bad cast");
duke@435 175 return (ciTypeArray*)this;
duke@435 176 }
duke@435 177
duke@435 178 // Print debugging output about this ciObject.
twisti@3969 179 void print(outputStream* st);
twisti@3969 180 void print() { print(tty); } // GDB cannot handle default arguments
duke@435 181
duke@435 182 // Print debugging output about the oop this ciObject represents.
duke@435 183 void print_oop(outputStream* st = tty);
duke@435 184 };
stefank@2314 185
stefank@2314 186 #endif // SHARE_VM_CI_CIOBJECT_HPP

mercurial