annotate src/share/vm/ci/ciObject.hpp @ 14518:d8041d695d19

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