1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
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 *
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 *
4134
4135 for (uint i = 0; i < n->outcnt(); i++) {
4136 address* constant_addr = &jump_table_base[i];
4137 assert(*constant_addr == (((address) n) + i), "all jump-table entries must contain adjusted node pointer: " INTPTR_FORMAT " == " INTPTR_FORMAT, p2i(*constant_addr), p2i(((address) n) + i));
4138 *constant_addr = cb.consts()->target(*labels.at(i), (address) constant_addr);
4139 cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type);
4140 }
4141 }
4142
4143 //----------------------------static_subtype_check-----------------------------
4144 // Shortcut important common cases when superklass is exact:
4145 // (0) superklass is java.lang.Object (can occur in reflective code)
4146 // (1) subklass is already limited to a subtype of superklass => always ok
4147 // (2) subklass does not overlap with superklass => always fail
4148 // (3) superklass has NO subtypes and we can check with a simple compare.
4149 int Compile::static_subtype_check(ciKlass* superk, ciKlass* subk) {
4150 if (StressReflectiveCode || superk == NULL || subk == NULL) {
4151 return SSC_full_test; // Let caller generate the general case.
4152 }
4153
4154 if (!EnableMVT && !EnableValhalla && superk == env()->Object_klass()) {
4155 return SSC_always_true; // (0) this test cannot fail
4156 }
4157
4158 ciType* superelem = superk;
4159 if (superelem->is_array_klass())
4160 superelem = superelem->as_array_klass()->base_element_type();
4161
4162 if (!subk->is_interface()) { // cannot trust static interface types yet
4163 if (subk->is_subtype_of(superk)) {
4164 return SSC_always_true; // (1) false path dead; no dynamic test needed
4165 }
4166 if (!(superelem->is_klass() && superelem->as_klass()->is_interface()) &&
4167 !superk->is_subtype_of(subk)) {
4168 return SSC_always_false;
4169 }
4170 }
4171
4172 // If casting to an instance klass, it must have no subtypes
4173 if (superk->is_interface()) {
4174 // Cannot trust interfaces yet.
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
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 *
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 *
4134
4135 for (uint i = 0; i < n->outcnt(); i++) {
4136 address* constant_addr = &jump_table_base[i];
4137 assert(*constant_addr == (((address) n) + i), "all jump-table entries must contain adjusted node pointer: " INTPTR_FORMAT " == " INTPTR_FORMAT, p2i(*constant_addr), p2i(((address) n) + i));
4138 *constant_addr = cb.consts()->target(*labels.at(i), (address) constant_addr);
4139 cb.consts()->relocate((address) constant_addr, relocInfo::internal_word_type);
4140 }
4141 }
4142
4143 //----------------------------static_subtype_check-----------------------------
4144 // Shortcut important common cases when superklass is exact:
4145 // (0) superklass is java.lang.Object (can occur in reflective code)
4146 // (1) subklass is already limited to a subtype of superklass => always ok
4147 // (2) subklass does not overlap with superklass => always fail
4148 // (3) superklass has NO subtypes and we can check with a simple compare.
4149 int Compile::static_subtype_check(ciKlass* superk, ciKlass* subk) {
4150 if (StressReflectiveCode || superk == NULL || subk == NULL) {
4151 return SSC_full_test; // Let caller generate the general case.
4152 }
4153
4154 if (!EnableValhalla && superk == env()->Object_klass()) {
4155 return SSC_always_true; // (0) this test cannot fail
4156 }
4157
4158 ciType* superelem = superk;
4159 if (superelem->is_array_klass())
4160 superelem = superelem->as_array_klass()->base_element_type();
4161
4162 if (!subk->is_interface()) { // cannot trust static interface types yet
4163 if (subk->is_subtype_of(superk)) {
4164 return SSC_always_true; // (1) false path dead; no dynamic test needed
4165 }
4166 if (!(superelem->is_klass() && superelem->as_klass()->is_interface()) &&
4167 !superk->is_subtype_of(subk)) {
4168 return SSC_always_false;
4169 }
4170 }
4171
4172 // If casting to an instance klass, it must have no subtypes
4173 if (superk->is_interface()) {
4174 // Cannot trust interfaces yet.
|