author | roland |
Mon, 09 Feb 2015 13:45:59 +0100 | |
changeset 28933 | a11a29cf06d5 |
parent 14477 | 95e66ea71f71 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CI_CIOBJECT_HPP |
26 |
#define SHARE_VM_CI_CIOBJECT_HPP |
|
27 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
28 |
#include "ci/ciBaseObject.hpp" |
7397 | 29 |
#include "ci/ciClassList.hpp" |
30 |
#include "memory/allocation.hpp" |
|
31 |
#include "runtime/handles.hpp" |
|
32 |
#include "runtime/jniHandles.hpp" |
|
33 |
||
1 | 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 -- |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
49 |
// the distinction between `Klass*' and `Klass' are not |
1 | 50 |
// reflected in the interface and instead the Klass hierarchy |
51 |
// is directly modeled as the subclasses of ciKlass. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
52 |
class ciObject : public ciBaseObject { |
1 | 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 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
75 |
void init_flags_from(oop x); |
1 | 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 |
||
3908 | 92 |
// Tells if this oop has an encoding as a constant. |
9959
a6730101c2d0
7048030: is_scavengable changes causing compiler to embed more constants
kvn
parents:
8921
diff
changeset
|
93 |
// True if is_perm is true. |
3908 | 94 |
// Also true if ScavengeRootsInCode is non-zero. |
1 | 95 |
// If it does not have an encoding, the compiler is responsible for |
96 |
// making other arrangements for dealing with the oop. |
|
3908 | 97 |
// See ciEnv::make_array |
98 |
bool can_be_constant(); |
|
99 |
||
100 |
// Tells if this oop should be made a constant. |
|
9959
a6730101c2d0
7048030: is_scavengable changes causing compiler to embed more constants
kvn
parents:
8921
diff
changeset
|
101 |
// True if is_perm is true or ScavengeRootsInCode > 1. |
3908 | 102 |
bool should_be_constant(); |
1 | 103 |
|
3908 | 104 |
// Might this object possibly move during a scavenge operation? |
105 |
// If the answer is true and ScavengeRootsInCode==0, the oop cannot be embedded in code. |
|
106 |
bool is_scavengable() { return (_ident & SCAVENGABLE_FLAG) != 0; } |
|
107 |
||
1 | 108 |
// The address which the compiler should embed into the |
109 |
// generated code to represent this oop. This address |
|
110 |
// is not the true address of the oop -- it will get patched |
|
111 |
// during nmethod creation. |
|
112 |
// |
|
113 |
// Usage note: no address arithmetic allowed. Oop must |
|
114 |
// be registered with the oopRecorder. |
|
3908 | 115 |
jobject constant_encoding(); |
1 | 116 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
117 |
virtual bool is_object() const { return true; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
118 |
|
1 | 119 |
// What kind of ciObject is this? |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
120 |
virtual bool is_null_object() const { return false; } |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
121 |
virtual bool is_call_site() const { return false; } |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
122 |
virtual bool is_cpcache() const { return false; } |
1 | 123 |
virtual bool is_instance() { return false; } |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
124 |
virtual bool is_member_name() const { return false; } |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
125 |
virtual bool is_method_handle() const { return false; } |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
126 |
virtual bool is_method_type() const { return false; } |
1 | 127 |
virtual bool is_array() { return false; } |
128 |
virtual bool is_obj_array() { return false; } |
|
129 |
virtual bool is_type_array() { return false; } |
|
130 |
||
131 |
// Is this a type or value which has no associated class? |
|
132 |
// It is true of primitive types and null objects. |
|
133 |
virtual bool is_classless() const { return false; } |
|
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
13929
diff
changeset
|
134 |
virtual void dump_replay_data(outputStream* st) { /* do nothing */ } |
1 | 135 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
136 |
// Note: some ciObjects refer to oops which have yet to be created. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
137 |
// We refer to these as "unloaded". Specifically, there are |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
138 |
// unloaded instances of java.lang.Class, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
139 |
// java.lang.invoke.MethodHandle, and java.lang.invoke.MethodType. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
140 |
// By convention the ciNullObject is considered loaded, and |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
141 |
// primitive types are considered loaded. |
1 | 142 |
bool is_loaded() const { |
143 |
return handle() != NULL || is_classless(); |
|
144 |
} |
|
145 |
||
146 |
// Subclass casting with assertions. |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
147 |
ciNullObject* as_null_object() { |
1 | 148 |
assert(is_null_object(), "bad cast"); |
149 |
return (ciNullObject*)this; |
|
150 |
} |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
151 |
ciCallSite* as_call_site() { |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
152 |
assert(is_call_site(), "bad cast"); |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
153 |
return (ciCallSite*)this; |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
154 |
} |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
155 |
ciInstance* as_instance() { |
1 | 156 |
assert(is_instance(), "bad cast"); |
157 |
return (ciInstance*)this; |
|
158 |
} |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
159 |
ciMemberName* as_member_name() { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
160 |
assert(is_member_name(), "bad cast"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
161 |
return (ciMemberName*)this; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
162 |
} |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
163 |
ciMethodHandle* as_method_handle() { |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
164 |
assert(is_method_handle(), "bad cast"); |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
165 |
return (ciMethodHandle*)this; |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
166 |
} |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
167 |
ciMethodType* as_method_type() { |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
168 |
assert(is_method_type(), "bad cast"); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
169 |
return (ciMethodType*)this; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
170 |
} |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
171 |
ciArray* as_array() { |
1 | 172 |
assert(is_array(), "bad cast"); |
173 |
return (ciArray*)this; |
|
174 |
} |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
175 |
ciObjArray* as_obj_array() { |
1 | 176 |
assert(is_obj_array(), "bad cast"); |
177 |
return (ciObjArray*)this; |
|
178 |
} |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
179 |
ciTypeArray* as_type_array() { |
1 | 180 |
assert(is_type_array(), "bad cast"); |
181 |
return (ciTypeArray*)this; |
|
182 |
} |
|
183 |
||
184 |
// Print debugging output about this ciObject. |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
185 |
void print(outputStream* st); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9959
diff
changeset
|
186 |
void print() { print(tty); } // GDB cannot handle default arguments |
1 | 187 |
|
188 |
// Print debugging output about the oop this ciObject represents. |
|
189 |
void print_oop(outputStream* st = tty); |
|
190 |
}; |
|
7397 | 191 |
|
192 |
#endif // SHARE_VM_CI_CIOBJECT_HPP |