7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "classfile/javaClasses.hpp"
27 #include "compiler/compileLog.hpp"
28 #include "gc/shared/barrierSet.hpp"
29 #include "gc/shared/c2/barrierSetC2.hpp"
30 #include "gc/shared/tlab_globals.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/objArrayKlass.hpp"
34 #include "opto/addnode.hpp"
35 #include "opto/arraycopynode.hpp"
36 #include "opto/cfgnode.hpp"
37 #include "opto/compile.hpp"
38 #include "opto/connode.hpp"
39 #include "opto/convertnode.hpp"
40 #include "opto/loopnode.hpp"
41 #include "opto/machnode.hpp"
42 #include "opto/matcher.hpp"
43 #include "opto/memnode.hpp"
44 #include "opto/mempointer.hpp"
45 #include "opto/mulnode.hpp"
46 #include "opto/narrowptrnode.hpp"
2044 // just return a prior value, which is done by Identity calls.
2045 if (can_see_stored_value(prev_mem, phase)) {
2046 // Make ready for step (d):
2047 set_req_X(MemNode::Memory, prev_mem, phase);
2048 return this;
2049 }
2050 }
2051
2052 if (!can_reshape) {
2053 phase->record_for_igvn(this);
2054 }
2055
2056 return nullptr;
2057 }
2058
2059 // Helper to recognize certain Klass fields which are invariant across
2060 // some group of array types (e.g., int[] or all T[] where T < Object).
2061 const Type*
2062 LoadNode::load_array_final_field(const TypeKlassPtr *tkls,
2063 ciKlass* klass) const {
2064 assert(!UseCompactObjectHeaders || tkls->offset() != in_bytes(Klass::prototype_header_offset()),
2065 "must not happen");
2066
2067 if (tkls->isa_instklassptr() && tkls->offset() == in_bytes(InstanceKlass::access_flags_offset())) {
2068 // The field is InstanceKlass::_access_flags. Return its (constant) value.
2069 assert(Opcode() == Op_LoadUS, "must load an unsigned short from _access_flags");
2070 ciInstanceKlass* iklass = tkls->is_instklassptr()->instance_klass();
2071 return TypeInt::make(iklass->access_flags());
2072 }
2073 if (tkls->offset() == in_bytes(Klass::misc_flags_offset())) {
2074 // The field is Klass::_misc_flags. Return its (constant) value.
2075 assert(Opcode() == Op_LoadUB, "must load an unsigned byte from _misc_flags");
2076 return TypeInt::make(klass->misc_flags());
2077 }
2078 if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) {
2079 // The field is Klass::_layout_helper. Return its constant value if known.
2080 assert(Opcode() == Op_LoadI, "must load an int from _layout_helper");
2081 return TypeInt::make(klass->layout_helper());
2082 }
2083
2084 // No match.
2225 assert(adr->Opcode() == Op_LoadP, "must load an oop from _java_mirror");
2226 assert(Opcode() == Op_LoadP, "must load an oop from _java_mirror");
2227 return TypeInstPtr::make(klass->java_mirror());
2228 }
2229 }
2230 }
2231
2232 const TypeKlassPtr *tkls = tp->isa_klassptr();
2233 if (tkls != nullptr) {
2234 if (tkls->is_loaded() && tkls->klass_is_exact()) {
2235 ciKlass* klass = tkls->exact_klass();
2236 // We are loading a field from a Klass metaobject whose identity
2237 // is known at compile time (the type is "exact" or "precise").
2238 // Check for fields we know are maintained as constants by the VM.
2239 if (tkls->offset() == in_bytes(Klass::super_check_offset_offset())) {
2240 // The field is Klass::_super_check_offset. Return its (constant) value.
2241 // (Folds up type checking code.)
2242 assert(Opcode() == Op_LoadI, "must load an int from _super_check_offset");
2243 return TypeInt::make(klass->super_check_offset());
2244 }
2245 if (UseCompactObjectHeaders) {
2246 if (tkls->offset() == in_bytes(Klass::prototype_header_offset())) {
2247 // The field is Klass::_prototype_header. Return its (constant) value.
2248 assert(this->Opcode() == Op_LoadX, "must load a proper type from _prototype_header");
2249 return TypeX::make(klass->prototype_header());
2250 }
2251 }
2252 // Compute index into primary_supers array
2253 juint depth = (tkls->offset() - in_bytes(Klass::primary_supers_offset())) / sizeof(Klass*);
2254 // Check for overflowing; use unsigned compare to handle the negative case.
2255 if( depth < ciKlass::primary_super_limit() ) {
2256 // The field is an element of Klass::_primary_supers. Return its (constant) value.
2257 // (Folds up type checking code.)
2258 assert(Opcode() == Op_LoadKlass, "must load a klass from _primary_supers");
2259 ciKlass *ss = klass->super_of_depth(depth);
2260 return ss ? TypeKlassPtr::make(ss, Type::trust_interfaces) : TypePtr::NULL_PTR;
2261 }
2262 const Type* aift = load_array_final_field(tkls, klass);
2263 if (aift != nullptr) return aift;
2264 }
2265
|
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include "classfile/javaClasses.hpp"
27 #include "code/aotCodeCache.hpp"
28 #include "compiler/compileLog.hpp"
29 #include "gc/shared/barrierSet.hpp"
30 #include "gc/shared/c2/barrierSetC2.hpp"
31 #include "gc/shared/tlab_globals.hpp"
32 #include "memory/allocation.inline.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "oops/objArrayKlass.hpp"
35 #include "opto/addnode.hpp"
36 #include "opto/arraycopynode.hpp"
37 #include "opto/cfgnode.hpp"
38 #include "opto/compile.hpp"
39 #include "opto/connode.hpp"
40 #include "opto/convertnode.hpp"
41 #include "opto/loopnode.hpp"
42 #include "opto/machnode.hpp"
43 #include "opto/matcher.hpp"
44 #include "opto/memnode.hpp"
45 #include "opto/mempointer.hpp"
46 #include "opto/mulnode.hpp"
47 #include "opto/narrowptrnode.hpp"
2045 // just return a prior value, which is done by Identity calls.
2046 if (can_see_stored_value(prev_mem, phase)) {
2047 // Make ready for step (d):
2048 set_req_X(MemNode::Memory, prev_mem, phase);
2049 return this;
2050 }
2051 }
2052
2053 if (!can_reshape) {
2054 phase->record_for_igvn(this);
2055 }
2056
2057 return nullptr;
2058 }
2059
2060 // Helper to recognize certain Klass fields which are invariant across
2061 // some group of array types (e.g., int[] or all T[] where T < Object).
2062 const Type*
2063 LoadNode::load_array_final_field(const TypeKlassPtr *tkls,
2064 ciKlass* klass) const {
2065 assert(!UseCompactObjectHeaders ||
2066 AOTCodeCache::is_on_for_dump() ||
2067 tkls->offset() != in_bytes(Klass::prototype_header_offset()),
2068 "must not happen");
2069
2070 if (tkls->isa_instklassptr() && tkls->offset() == in_bytes(InstanceKlass::access_flags_offset())) {
2071 // The field is InstanceKlass::_access_flags. Return its (constant) value.
2072 assert(Opcode() == Op_LoadUS, "must load an unsigned short from _access_flags");
2073 ciInstanceKlass* iklass = tkls->is_instklassptr()->instance_klass();
2074 return TypeInt::make(iklass->access_flags());
2075 }
2076 if (tkls->offset() == in_bytes(Klass::misc_flags_offset())) {
2077 // The field is Klass::_misc_flags. Return its (constant) value.
2078 assert(Opcode() == Op_LoadUB, "must load an unsigned byte from _misc_flags");
2079 return TypeInt::make(klass->misc_flags());
2080 }
2081 if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) {
2082 // The field is Klass::_layout_helper. Return its constant value if known.
2083 assert(Opcode() == Op_LoadI, "must load an int from _layout_helper");
2084 return TypeInt::make(klass->layout_helper());
2085 }
2086
2087 // No match.
2228 assert(adr->Opcode() == Op_LoadP, "must load an oop from _java_mirror");
2229 assert(Opcode() == Op_LoadP, "must load an oop from _java_mirror");
2230 return TypeInstPtr::make(klass->java_mirror());
2231 }
2232 }
2233 }
2234
2235 const TypeKlassPtr *tkls = tp->isa_klassptr();
2236 if (tkls != nullptr) {
2237 if (tkls->is_loaded() && tkls->klass_is_exact()) {
2238 ciKlass* klass = tkls->exact_klass();
2239 // We are loading a field from a Klass metaobject whose identity
2240 // is known at compile time (the type is "exact" or "precise").
2241 // Check for fields we know are maintained as constants by the VM.
2242 if (tkls->offset() == in_bytes(Klass::super_check_offset_offset())) {
2243 // The field is Klass::_super_check_offset. Return its (constant) value.
2244 // (Folds up type checking code.)
2245 assert(Opcode() == Op_LoadI, "must load an int from _super_check_offset");
2246 return TypeInt::make(klass->super_check_offset());
2247 }
2248 // Class encoding in prototype header may change between runs.
2249 // Force loading prototype header when AOT code is generated.
2250 if (UseCompactObjectHeaders && !AOTCodeCache::is_on_for_dump()) {
2251 if (tkls->offset() == in_bytes(Klass::prototype_header_offset())) {
2252 // The field is Klass::_prototype_header. Return its (constant) value.
2253 assert(this->Opcode() == Op_LoadX, "must load a proper type from _prototype_header");
2254 return TypeX::make(klass->prototype_header());
2255 }
2256 }
2257 // Compute index into primary_supers array
2258 juint depth = (tkls->offset() - in_bytes(Klass::primary_supers_offset())) / sizeof(Klass*);
2259 // Check for overflowing; use unsigned compare to handle the negative case.
2260 if( depth < ciKlass::primary_super_limit() ) {
2261 // The field is an element of Klass::_primary_supers. Return its (constant) value.
2262 // (Folds up type checking code.)
2263 assert(Opcode() == Op_LoadKlass, "must load a klass from _primary_supers");
2264 ciKlass *ss = klass->super_of_depth(depth);
2265 return ss ? TypeKlassPtr::make(ss, Type::trust_interfaces) : TypePtr::NULL_PTR;
2266 }
2267 const Type* aift = load_array_final_field(tkls, klass);
2268 if (aift != nullptr) return aift;
2269 }
2270
|