author | vlivanov |
Mon, 13 Feb 2017 23:58:00 +0300 | |
changeset 43951 | c23519aaccc1 |
parent 38030 | 93f24e7b3c43 |
child 46271 | 979ebd346ecf |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
19770
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, 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:
4571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
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:
4571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "ci/ciConstant.hpp" |
|
27 |
#include "ci/ciField.hpp" |
|
28 |
#include "ci/ciInstance.hpp" |
|
29 |
#include "ci/ciInstanceKlass.hpp" |
|
30 |
#include "ci/ciUtilities.hpp" |
|
31 |
#include "classfile/systemDictionary.hpp" |
|
32 |
#include "oops/oop.inline.hpp" |
|
1 | 33 |
|
34 |
// ciInstance |
|
35 |
// |
|
36 |
// This class represents an instanceOop in the HotSpot virtual |
|
37 |
// machine. |
|
38 |
||
39 |
// ------------------------------------------------------------------ |
|
40 |
// ciObject::java_mirror_type |
|
41 |
ciType* ciInstance::java_mirror_type() { |
|
42 |
VM_ENTRY_MARK; |
|
43 |
oop m = get_oop(); |
|
44 |
// Return NULL if it is not java.lang.Class. |
|
4571 | 45 |
if (m == NULL || m->klass() != SystemDictionary::Class_klass()) { |
1 | 46 |
return NULL; |
47 |
} |
|
48 |
// Return either a primitive type or a klass. |
|
49 |
if (java_lang_Class::is_primitive(m)) { |
|
50 |
return ciType::make(java_lang_Class::primitive_type(m)); |
|
51 |
} else { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9123
diff
changeset
|
52 |
Klass* k = java_lang_Class::as_Klass(m); |
1 | 53 |
assert(k != NULL, ""); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9123
diff
changeset
|
54 |
return CURRENT_THREAD_ENV->get_klass(k); |
1 | 55 |
} |
56 |
} |
|
57 |
||
58 |
// ------------------------------------------------------------------ |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
59 |
// ciInstance::field_value_impl |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
60 |
ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) { |
9123
4c7a8da5653b
7035161: assert(!o->is_null_object()) failed: null object not yet handled here.
never
parents:
8725
diff
changeset
|
61 |
Handle obj = get_oop(); |
4c7a8da5653b
7035161: assert(!o->is_null_object()) failed: null object not yet handled here.
never
parents:
8725
diff
changeset
|
62 |
assert(!obj.is_null(), "bad oop"); |
1 | 63 |
switch(field_btype) { |
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
64 |
case T_BYTE: return ciConstant(field_btype, obj->byte_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
65 |
case T_CHAR: return ciConstant(field_btype, obj->char_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
66 |
case T_SHORT: return ciConstant(field_btype, obj->short_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
67 |
case T_BOOLEAN: return ciConstant(field_btype, obj->bool_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
68 |
case T_INT: return ciConstant(field_btype, obj->int_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
69 |
case T_FLOAT: return ciConstant(obj->float_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
70 |
case T_DOUBLE: return ciConstant(obj->double_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
71 |
case T_LONG: return ciConstant(obj->long_field(offset)); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
72 |
case T_OBJECT: // fall through |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
73 |
case T_ARRAY: { |
1 | 74 |
oop o = obj->obj_field(offset); |
75 |
||
76 |
// A field will be "constant" if it is known always to be |
|
77 |
// a non-null reference to an instance of a particular class, |
|
78 |
// or to a particular array. This can happen even if the instance |
|
79 |
// or array is not perm. In such a case, an "unloaded" ciArray |
|
80 |
// or ciInstance is created. The compiler may be able to use |
|
81 |
// information about the object's class (which is exact) or length. |
|
82 |
||
83 |
if (o == NULL) { |
|
84 |
return ciConstant(field_btype, ciNullObject::make()); |
|
85 |
} else { |
|
86 |
return ciConstant(field_btype, CURRENT_ENV->get_object(o)); |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
90 |
fatal("no field value: %s", type2name(field_btype)); |
1 | 91 |
return ciConstant(); |
92 |
} |
|
93 |
||
94 |
// ------------------------------------------------------------------ |
|
38030
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
95 |
// ciInstance::field_value |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
96 |
// |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
97 |
// Constant value of a field. |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
98 |
ciConstant ciInstance::field_value(ciField* field) { |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
99 |
assert(is_loaded(), "invalid access - must be loaded"); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
100 |
assert(field->holder()->is_loaded(), "invalid access - holder must be loaded"); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
101 |
assert(field->is_static() || klass()->is_subclass_of(field->holder()), "invalid access - must be subclass"); |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
102 |
|
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
103 |
GUARDED_VM_ENTRY(return field_value_impl(field->type()->basic_type(), field->offset());) |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
104 |
} |
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
105 |
|
93f24e7b3c43
8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents:
22234
diff
changeset
|
106 |
// ------------------------------------------------------------------ |
1 | 107 |
// ciInstance::field_value_by_offset |
108 |
// |
|
109 |
// Constant value of a field at the specified offset. |
|
110 |
ciConstant ciInstance::field_value_by_offset(int field_offset) { |
|
111 |
ciInstanceKlass* ik = klass()->as_instance_klass(); |
|
112 |
ciField* field = ik->get_field_by_offset(field_offset, false); |
|
19770
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19715
diff
changeset
|
113 |
if (field == NULL) |
7cb9f982ea81
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
19715
diff
changeset
|
114 |
return ciConstant(); // T_ILLEGAL |
1 | 115 |
return field_value(field); |
116 |
} |
|
117 |
||
118 |
// ------------------------------------------------------------------ |
|
119 |
// ciInstance::print_impl |
|
120 |
// |
|
121 |
// Implementation of the print method. |
|
122 |
void ciInstance::print_impl(outputStream* st) { |
|
123 |
st->print(" type="); |
|
124 |
klass()->print(st); |
|
125 |
} |
|
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
126 |
|
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
127 |
|
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
128 |
ciKlass* ciInstance::java_lang_Class_klass() { |
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
129 |
VM_ENTRY_MARK; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9123
diff
changeset
|
130 |
return CURRENT_ENV->get_metadata(java_lang_Class::as_Klass(get_oop()))->as_klass(); |
8725
8c1e3dd5fe1b
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
7397
diff
changeset
|
131 |
} |