src/share/vm/ci/ciObject.cpp

Wed, 18 Mar 2009 13:25:02 -0700

author
kvn
date
Wed, 18 Mar 2009 13:25:02 -0700
changeset 1081
039a914095f4
parent 435
a61af66fc99e
child 1424
148e5441d916
permissions
-rw-r--r--

6772368: REGRESSION:tomcat crashed twice with JDK 7
Summary: Call make_block_at() with the original handler limits.
Reviewed-by: never

duke@435 1 /*
duke@435 2 * Copyright 1999-2007 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_ciObject.cpp.incl"
duke@435 27
duke@435 28 // ciObject
duke@435 29 //
duke@435 30 // This class represents an oop in the HotSpot virtual machine.
duke@435 31 // Its subclasses are structured in a hierarchy which mirrors
duke@435 32 // an aggregate of the VM's oop and klass hierarchies (see
duke@435 33 // oopHierarchy.hpp). Each instance of ciObject holds a handle
duke@435 34 // to a corresponding oop on the VM side and provides routines
duke@435 35 // for accessing the information in its oop. By using the ciObject
duke@435 36 // hierarchy for accessing oops in the VM, the compiler ensures
duke@435 37 // that it is safe with respect to garbage collection; that is,
duke@435 38 // GC and compilation can proceed independently without
duke@435 39 // interference.
duke@435 40 //
duke@435 41 // Within the VM, the oop and klass hierarchies are separate.
duke@435 42 // The compiler interface does not preserve this separation --
duke@435 43 // the distinction between `klassOop' and `Klass' are not
duke@435 44 // reflected in the interface and instead the Klass hierarchy
duke@435 45 // is directly modeled as the subclasses of ciKlass.
duke@435 46
duke@435 47 // ------------------------------------------------------------------
duke@435 48 // ciObject::ciObject
duke@435 49 ciObject::ciObject(oop o) {
duke@435 50 ASSERT_IN_VM;
duke@435 51 if (ciObjectFactory::is_initialized()) {
duke@435 52 _handle = JNIHandles::make_local(o);
duke@435 53 } else {
duke@435 54 _handle = JNIHandles::make_global(o);
duke@435 55 }
duke@435 56 _klass = NULL;
duke@435 57 _ident = 0;
duke@435 58 }
duke@435 59
duke@435 60 // ------------------------------------------------------------------
duke@435 61 // ciObject::ciObject
duke@435 62 //
duke@435 63 ciObject::ciObject(Handle h) {
duke@435 64 ASSERT_IN_VM;
duke@435 65 if (ciObjectFactory::is_initialized()) {
duke@435 66 _handle = JNIHandles::make_local(h());
duke@435 67 } else {
duke@435 68 _handle = JNIHandles::make_global(h);
duke@435 69 }
duke@435 70 _klass = NULL;
duke@435 71 _ident = 0;
duke@435 72 }
duke@435 73
duke@435 74 // ------------------------------------------------------------------
duke@435 75 // ciObject::ciObject
duke@435 76 //
duke@435 77 // Unloaded klass/method variant. `klass' is the klass of the unloaded
duke@435 78 // klass/method, if that makes sense.
duke@435 79 ciObject::ciObject(ciKlass* klass) {
duke@435 80 ASSERT_IN_VM;
duke@435 81 assert(klass != NULL, "must supply klass");
duke@435 82 _handle = NULL;
duke@435 83 _klass = klass;
duke@435 84 _ident = 0;
duke@435 85 }
duke@435 86
duke@435 87 // ------------------------------------------------------------------
duke@435 88 // ciObject::ciObject
duke@435 89 //
duke@435 90 // NULL variant. Used only by ciNullObject.
duke@435 91 ciObject::ciObject() {
duke@435 92 ASSERT_IN_VM;
duke@435 93 _handle = NULL;
duke@435 94 _klass = NULL;
duke@435 95 _ident = 0;
duke@435 96 }
duke@435 97
duke@435 98 // ------------------------------------------------------------------
duke@435 99 // ciObject::klass
duke@435 100 //
duke@435 101 // Get the ciKlass of this ciObject.
duke@435 102 ciKlass* ciObject::klass() {
duke@435 103 if (_klass == NULL) {
duke@435 104 if (_handle == NULL) {
duke@435 105 // When both _klass and _handle are NULL, we are dealing
duke@435 106 // with the distinguished instance of ciNullObject.
duke@435 107 // No one should ask it for its klass.
duke@435 108 assert(is_null_object(), "must be null object");
duke@435 109 ShouldNotReachHere();
duke@435 110 return NULL;
duke@435 111 }
duke@435 112
duke@435 113 GUARDED_VM_ENTRY(
duke@435 114 oop o = get_oop();
duke@435 115 _klass = CURRENT_ENV->get_object(o->klass())->as_klass();
duke@435 116 );
duke@435 117 }
duke@435 118 return _klass;
duke@435 119 }
duke@435 120
duke@435 121 // ------------------------------------------------------------------
duke@435 122 // ciObject::set_ident
duke@435 123 //
duke@435 124 // Set the unique identity number of a ciObject.
duke@435 125 void ciObject::set_ident(uint id) {
duke@435 126 assert((_ident >> FLAG_BITS) == 0, "must only initialize once");
duke@435 127 assert( id < ((uint)1 << (BitsPerInt-FLAG_BITS)), "id too big");
duke@435 128 _ident = _ident + (id << FLAG_BITS);
duke@435 129 }
duke@435 130
duke@435 131 // ------------------------------------------------------------------
duke@435 132 // ciObject::ident
duke@435 133 //
duke@435 134 // Report the unique identity number of a ciObject.
duke@435 135 uint ciObject::ident() {
duke@435 136 uint id = _ident >> FLAG_BITS;
duke@435 137 assert(id != 0, "must be initialized");
duke@435 138 return id;
duke@435 139 }
duke@435 140
duke@435 141 // ------------------------------------------------------------------
duke@435 142 // ciObject::equals
duke@435 143 //
duke@435 144 // Are two ciObjects equal?
duke@435 145 bool ciObject::equals(ciObject* obj) {
duke@435 146 return (this == obj);
duke@435 147 }
duke@435 148
duke@435 149 // ------------------------------------------------------------------
duke@435 150 // ciObject::hash
duke@435 151 //
duke@435 152 // A hash value for the convenience of compilers.
duke@435 153 //
duke@435 154 // Implementation note: we use the address of the ciObject as the
duke@435 155 // basis for the hash. Use the _ident field, which is well-behaved.
duke@435 156 int ciObject::hash() {
duke@435 157 return ident() * 31;
duke@435 158 }
duke@435 159
duke@435 160 // ------------------------------------------------------------------
duke@435 161 // ciObject::encoding
duke@435 162 //
duke@435 163 // The address which the compiler should embed into the
duke@435 164 // generated code to represent this oop. This address
duke@435 165 // is not the true address of the oop -- it will get patched
duke@435 166 // during nmethod creation.
duke@435 167 //
duke@435 168 //
duke@435 169 //
duke@435 170 // Implementation note: we use the handle as the encoding. The
duke@435 171 // nmethod constructor resolves the handle and patches in the oop.
duke@435 172 //
duke@435 173 // This method should be changed to return an generified address
duke@435 174 // to discourage use of the JNI handle.
duke@435 175 jobject ciObject::encoding() {
duke@435 176 assert(is_null_object() || handle() != NULL, "cannot embed null pointer");
duke@435 177 assert(has_encoding(), "oop must be NULL or perm");
duke@435 178 return handle();
duke@435 179 }
duke@435 180
duke@435 181 // ------------------------------------------------------------------
duke@435 182 // ciObject::has_encoding
duke@435 183 bool ciObject::has_encoding() {
duke@435 184 return handle() == NULL || is_perm();
duke@435 185 }
duke@435 186
duke@435 187
duke@435 188 // ------------------------------------------------------------------
duke@435 189 // ciObject::print
duke@435 190 //
duke@435 191 // Print debugging output about this ciObject.
duke@435 192 //
duke@435 193 // Implementation note: dispatch to the virtual print_impl behavior
duke@435 194 // for this ciObject.
duke@435 195 void ciObject::print(outputStream* st) {
duke@435 196 st->print("<%s", type_string());
duke@435 197 GUARDED_VM_ENTRY(print_impl(st);)
duke@435 198 st->print(" ident=%d %s address=0x%x>", ident(),
duke@435 199 is_perm() ? "PERM" : "",
duke@435 200 (address)this);
duke@435 201 }
duke@435 202
duke@435 203 // ------------------------------------------------------------------
duke@435 204 // ciObject::print_oop
duke@435 205 //
duke@435 206 // Print debugging output about the oop this ciObject represents.
duke@435 207 void ciObject::print_oop(outputStream* st) {
duke@435 208 if (is_null_object()) {
duke@435 209 st->print_cr("NULL");
duke@435 210 } else if (!is_loaded()) {
duke@435 211 st->print_cr("UNLOADED");
duke@435 212 } else {
duke@435 213 GUARDED_VM_ENTRY(get_oop()->print_on(st);)
duke@435 214 }
duke@435 215 }

mercurial