10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CI_CIOBJECT_HPP
26 #define SHARE_VM_CI_CIOBJECT_HPP
27
28 #include "ci/ciBaseObject.hpp"
29 #include "ci/ciClassList.hpp"
30 #include "memory/allocation.hpp"
31 #include "runtime/handles.hpp"
32 #include "runtime/jniHandles.hpp"
33
34 // ciObject
35 //
36 // This class represents an oop in the HotSpot virtual machine.
37 // Its subclasses are structured in a hierarchy which mirrors
38 // an aggregate of the VM's oop and klass hierarchies (see
39 // oopHierarchy.hpp). Each instance of ciObject holds a handle
40 // to a corresponding oop on the VM side and provides routines
41 // for accessing the information in its oop. By using the ciObject
42 // hierarchy for accessing oops in the VM, the compiler ensures
43 // that it is safe with respect to garbage collection; that is,
44 // GC and compilation can proceed independently without
45 // interference.
46 //
47 // Within the VM, the oop and klass hierarchies are separate.
48 // The compiler interface does not preserve this separation --
49 // the distinction between `Klass*' and `Klass' are not
52 class ciObject : public ciBaseObject {
53 CI_PACKAGE_ACCESS
54 friend class ciEnv;
55
56 private:
57 // A JNI handle referring to an oop in the VM. This
58 // handle may, in a small set of cases, correctly be NULL.
59 jobject _handle;
60 ciKlass* _klass;
61
62 protected:
63 ciObject();
64 ciObject(oop o);
65 ciObject(Handle h);
66 ciObject(ciKlass* klass);
67
68 jobject handle() const { return _handle; }
69 // Get the VM oop that this object holds.
70 oop get_oop() const {
71 assert(_handle != NULL, "null oop");
72 return JNIHandles::resolve_non_null(_handle);
73 }
74
75 void init_flags_from(oop x);
76
77 // Virtual behavior of the print() method.
78 virtual void print_impl(outputStream* st) {}
79
80 virtual const char* type_string() { return "ciObject"; }
81
82 public:
83 // The klass of this ciObject.
84 ciKlass* klass();
85
86 // Are two ciObjects equal?
87 bool equals(ciObject* obj);
88
89 // A hash value for the convenience of compilers.
90 int hash();
91
92 // Tells if this oop has an encoding as a constant.
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_CI_CIOBJECT_HPP
26 #define SHARE_VM_CI_CIOBJECT_HPP
27
28 #include "ci/ciBaseObject.hpp"
29 #include "ci/ciClassList.hpp"
30 #include "gc/shared/barrierSet.hpp"
31 #include "memory/allocation.hpp"
32 #include "runtime/handles.hpp"
33 #include "runtime/jniHandles.hpp"
34
35 // ciObject
36 //
37 // This class represents an oop in the HotSpot virtual machine.
38 // Its subclasses are structured in a hierarchy which mirrors
39 // an aggregate of the VM's oop and klass hierarchies (see
40 // oopHierarchy.hpp). Each instance of ciObject holds a handle
41 // to a corresponding oop on the VM side and provides routines
42 // for accessing the information in its oop. By using the ciObject
43 // hierarchy for accessing oops in the VM, the compiler ensures
44 // that it is safe with respect to garbage collection; that is,
45 // GC and compilation can proceed independently without
46 // interference.
47 //
48 // Within the VM, the oop and klass hierarchies are separate.
49 // The compiler interface does not preserve this separation --
50 // the distinction between `Klass*' and `Klass' are not
53 class ciObject : public ciBaseObject {
54 CI_PACKAGE_ACCESS
55 friend class ciEnv;
56
57 private:
58 // A JNI handle referring to an oop in the VM. This
59 // handle may, in a small set of cases, correctly be NULL.
60 jobject _handle;
61 ciKlass* _klass;
62
63 protected:
64 ciObject();
65 ciObject(oop o);
66 ciObject(Handle h);
67 ciObject(ciKlass* klass);
68
69 jobject handle() const { return _handle; }
70 // Get the VM oop that this object holds.
71 oop get_oop() const {
72 assert(_handle != NULL, "null oop");
73 oop obj = JNIHandles::resolve_non_null(_handle);
74 assert(obj == oopDesc::bs()->resolve_and_maybe_copy_oop(obj), "expect to-space copy");
75 return obj;
76 }
77
78 void init_flags_from(oop x);
79
80 // Virtual behavior of the print() method.
81 virtual void print_impl(outputStream* st) {}
82
83 virtual const char* type_string() { return "ciObject"; }
84
85 public:
86 // The klass of this ciObject.
87 ciKlass* klass();
88
89 // Are two ciObjects equal?
90 bool equals(ciObject* obj);
91
92 // A hash value for the convenience of compilers.
93 int hash();
94
95 // Tells if this oop has an encoding as a constant.
|