1 /*
2 * Copyright (c) 2005, 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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "c1/c1_Compilation.hpp"
27 #include "c1/c1_FrameMap.hpp"
28 #include "c1/c1_Instruction.hpp"
29 #include "c1/c1_LIRAssembler.hpp"
30 #include "c1/c1_LIRGenerator.hpp"
31 #include "c1/c1_Runtime1.hpp"
32 #include "c1/c1_ValueStack.hpp"
33 #include "ci/ciArray.hpp"
34 #include "ci/ciObjArrayKlass.hpp"
35 #include "ci/ciTypeArrayKlass.hpp"
36 #include "gc/shared/c1/barrierSetC1.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #include "vmreg_x86.inline.hpp"
40
41 #ifdef ASSERT
42 #define __ gen()->lir(__FILE__, __LINE__)->
43 #else
44 #define __ gen()->lir()->
45 #endif
46
47 // Item will be loaded into a byte register; Intel only
48 void LIRItem::load_byte_item() {
49 load_item();
50 LIR_Opr res = result();
51
52 if (!res->is_virtual() || !_gen->is_vreg_flag_set(res, LIRGenerator::byte_reg)) {
53 // make sure that it is a byte register
54 assert(!value()->type()->is_float() && !value()->type()->is_double(),
55 "can't load floats in byte register");
253 __ add(left, tmp, result);
254 return true;
255 }
256 }
257 return false;
258 }
259
260
261 void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
262 BasicType type = item->type();
263 __ store(item, new LIR_Address(FrameMap::rsp_opr, in_bytes(offset_from_sp), type));
264 }
265
266 void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) {
267 LIR_Opr tmp1 = new_register(objectType);
268 LIR_Opr tmp2 = new_register(objectType);
269 LIR_Opr tmp3 = new_register(objectType);
270 __ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci);
271 }
272
273 //----------------------------------------------------------------------
274 // visitor functions
275 //----------------------------------------------------------------------
276
277 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
278 assert(x->is_pinned(),"");
279 LIRItem obj(x->obj(), this);
280 obj.load_item();
281
282 set_no_result(x);
283
284 // "lock" stores the address of the monitor stack slot, so this is not an oop
285 LIR_Opr lock = new_register(T_INT);
286 // Need a scratch register for biased locking on x86
287 LIR_Opr scratch = LIR_OprFact::illegalOpr;
288 if (UseBiasedLocking) {
289 scratch = new_register(T_INT);
290 }
291
292 CodeEmitInfo* info_for_exception = NULL;
293 if (x->needs_null_check()) {
294 info_for_exception = state_for(x);
295 }
296 // this CodeEmitInfo must not have the xhandlers because here the
297 // object is already locked (xhandlers expect object to be unlocked)
298 CodeEmitInfo* info = state_for(x, x->state(), true);
299 monitor_enter(obj.result(), lock, syncTempOpr(), scratch,
300 x->monitor_no(), info_for_exception, info);
301 }
302
303
304 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
305 assert(x->is_pinned(),"");
306
307 LIRItem obj(x->obj(), this);
308 obj.dont_load_item();
309
310 LIR_Opr lock = new_register(T_INT);
311 LIR_Opr obj_temp = new_register(T_INT);
312 set_no_result(x);
313 monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
314 }
315
316
317 // _ineg, _lneg, _fneg, _dneg
318 void LIRGenerator::do_NegateOp(NegateOp* x) {
319 LIRItem value(x->x(), this);
320 value.set_destroys_register();
1204 assert(result->is_virtual(), "result must be virtual register");
1205 set_result(x, result);
1206 }
1207
1208
1209 void LIRGenerator::do_NewInstance(NewInstance* x) {
1210 print_if_not_loaded(x);
1211
1212 CodeEmitInfo* info = state_for(x, x->state());
1213 LIR_Opr reg = result_register_for(x->type());
1214 new_instance(reg, x->klass(), x->is_unresolved(),
1215 FrameMap::rcx_oop_opr,
1216 FrameMap::rdi_oop_opr,
1217 FrameMap::rsi_oop_opr,
1218 LIR_OprFact::illegalOpr,
1219 FrameMap::rdx_metadata_opr, info);
1220 LIR_Opr result = rlock_result(x);
1221 __ move(reg, result);
1222 }
1223
1224
1225 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1226 CodeEmitInfo* info = state_for(x, x->state());
1227
1228 LIRItem length(x->length(), this);
1229 length.load_item_force(FrameMap::rbx_opr);
1230
1231 LIR_Opr reg = result_register_for(x->type());
1232 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1233 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1234 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1235 LIR_Opr tmp4 = reg;
1236 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1237 LIR_Opr len = length.result();
1238 BasicType elem_type = x->elt_type();
1239
1240 __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
1241
1242 CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
1243 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
1251 LIRItem length(x->length(), this);
1252 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1253 // and therefore provide the state before the parameters have been consumed
1254 CodeEmitInfo* patching_info = NULL;
1255 if (!x->klass()->is_loaded() || PatchALot) {
1256 patching_info = state_for(x, x->state_before());
1257 }
1258
1259 CodeEmitInfo* info = state_for(x, x->state());
1260
1261 const LIR_Opr reg = result_register_for(x->type());
1262 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1263 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1264 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1265 LIR_Opr tmp4 = reg;
1266 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1267
1268 length.load_item_force(FrameMap::rbx_opr);
1269 LIR_Opr len = length.result();
1270
1271 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
1272 ciKlass* obj = (ciKlass*) ciObjArrayKlass::make(x->klass());
1273 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1274 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1275 }
1276 klass2reg_with_patching(klass_reg, obj, patching_info);
1277 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
1278
1279 LIR_Opr result = rlock_result(x);
1280 __ move(reg, result);
1281 }
1282
1283
1284 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1285 Values* dims = x->dims();
1286 int i = dims->length();
1287 LIRItemList* items = new LIRItemList(i, i, NULL);
1288 while (i-- > 0) {
1289 LIRItem* size = new LIRItem(dims->at(i), this);
1290 items->at_put(i, size);
1291 }
1292
1293 // Evaluate state_for early since it may emit code.
1294 CodeEmitInfo* patching_info = NULL;
1295 if (!x->klass()->is_loaded() || PatchALot) {
1296 patching_info = state_for(x, x->state_before());
1297
1336 // nothing to do for now
1337 }
1338
1339
1340 void LIRGenerator::do_CheckCast(CheckCast* x) {
1341 LIRItem obj(x->obj(), this);
1342
1343 CodeEmitInfo* patching_info = NULL;
1344 if (!x->klass()->is_loaded() || (PatchALot && !x->is_incompatible_class_change_check() && !x->is_invokespecial_receiver_check())) {
1345 // must do this before locking the destination register as an oop register,
1346 // and before the obj is loaded (the latter is for deoptimization)
1347 patching_info = state_for(x, x->state_before());
1348 }
1349 obj.load_item();
1350
1351 // info for exceptions
1352 CodeEmitInfo* info_for_exception =
1353 (x->needs_exception_state() ? state_for(x) :
1354 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1355
1356 CodeStub* stub;
1357 if (x->is_incompatible_class_change_check()) {
1358 assert(patching_info == NULL, "can't patch this");
1359 stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1360 } else if (x->is_invokespecial_receiver_check()) {
1361 assert(patching_info == NULL, "can't patch this");
1362 stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1363 } else {
1364 stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
1365 }
1366 LIR_Opr reg = rlock_result(x);
1367 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1368 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1369 tmp3 = new_register(objectType);
1370 }
1371 __ checkcast(reg, obj.result(), x->klass(),
1372 new_register(objectType), new_register(objectType), tmp3,
1373 x->direct_compare(), info_for_exception, patching_info, stub,
1374 x->profiled_method(), x->profiled_bci());
1375 }
1376
1377
1378 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1379 LIRItem obj(x->obj(), this);
1380
1381 // result and test object may not be in same register
1382 LIR_Opr reg = rlock_result(x);
1383 CodeEmitInfo* patching_info = NULL;
1384 if ((!x->klass()->is_loaded() || PatchALot)) {
1385 // must do this before locking the destination register as an oop register
1386 patching_info = state_for(x, x->state_before());
1387 }
1388 obj.load_item();
1389 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1390 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1391 tmp3 = new_register(objectType);
1392 }
1393 __ instanceof(reg, obj.result(), x->klass(),
1394 new_register(objectType), new_register(objectType), tmp3,
|
1 /*
2 * Copyright (c) 2005, 2019, 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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "c1/c1_Compilation.hpp"
27 #include "c1/c1_FrameMap.hpp"
28 #include "c1/c1_Instruction.hpp"
29 #include "c1/c1_LIRAssembler.hpp"
30 #include "c1/c1_LIRGenerator.hpp"
31 #include "c1/c1_Runtime1.hpp"
32 #include "c1/c1_ValueStack.hpp"
33 #include "ci/ciArray.hpp"
34 #include "ci/ciObjArrayKlass.hpp"
35 #include "ci/ciTypeArrayKlass.hpp"
36 #include "ci/ciValueKlass.hpp"
37 #include "gc/shared/c1/barrierSetC1.hpp"
38 #include "runtime/sharedRuntime.hpp"
39 #include "runtime/stubRoutines.hpp"
40 #include "vmreg_x86.inline.hpp"
41
42 #ifdef ASSERT
43 #define __ gen()->lir(__FILE__, __LINE__)->
44 #else
45 #define __ gen()->lir()->
46 #endif
47
48 // Item will be loaded into a byte register; Intel only
49 void LIRItem::load_byte_item() {
50 load_item();
51 LIR_Opr res = result();
52
53 if (!res->is_virtual() || !_gen->is_vreg_flag_set(res, LIRGenerator::byte_reg)) {
54 // make sure that it is a byte register
55 assert(!value()->type()->is_float() && !value()->type()->is_double(),
56 "can't load floats in byte register");
254 __ add(left, tmp, result);
255 return true;
256 }
257 }
258 return false;
259 }
260
261
262 void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
263 BasicType type = item->type();
264 __ store(item, new LIR_Address(FrameMap::rsp_opr, in_bytes(offset_from_sp), type));
265 }
266
267 void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) {
268 LIR_Opr tmp1 = new_register(objectType);
269 LIR_Opr tmp2 = new_register(objectType);
270 LIR_Opr tmp3 = new_register(objectType);
271 __ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci);
272 }
273
274 void LIRGenerator::flattened_array_store_check(LIR_Opr value, ciKlass* element_klass, CodeEmitInfo* store_check_info) {
275 LIR_Opr tmp1 = new_register(T_METADATA);
276 LIR_Opr tmp2 = LIR_OprFact::illegalOpr;
277
278 #ifdef _LP64
279 if (!UseCompressedClassPointers) {
280 tmp2 = new_register(T_METADATA);
281 __ metadata2reg(element_klass->constant_encoding(), tmp2);
282 }
283 #endif
284
285 __ flattened_store_check(value, element_klass, tmp1, tmp2, store_check_info);
286 }
287
288 //----------------------------------------------------------------------
289 // visitor functions
290 //----------------------------------------------------------------------
291
292 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
293 assert(x->is_pinned(),"");
294 LIRItem obj(x->obj(), this);
295 obj.load_item();
296
297 set_no_result(x);
298
299 // "lock" stores the address of the monitor stack slot, so this is not an oop
300 LIR_Opr lock = new_register(T_INT);
301 // Need a scratch register for biased locking on x86
302 LIR_Opr scratch = LIR_OprFact::illegalOpr;
303 if (UseBiasedLocking || x->maybe_valuetype()) {
304 scratch = new_register(T_INT);
305 }
306
307 CodeEmitInfo* info_for_exception = NULL;
308 if (x->needs_null_check()) {
309 info_for_exception = state_for(x);
310 }
311
312 CodeStub* throw_imse_stub = x->maybe_valuetype() ?
313 new SimpleExceptionStub(Runtime1::throw_illegal_monitor_state_exception_id,
314 LIR_OprFact::illegalOpr, state_for(x))
315 : NULL;
316
317 // this CodeEmitInfo must not have the xhandlers because here the
318 // object is already locked (xhandlers expect object to be unlocked)
319 CodeEmitInfo* info = state_for(x, x->state(), true);
320 monitor_enter(obj.result(), lock, syncTempOpr(), scratch,
321 x->monitor_no(), info_for_exception, info, throw_imse_stub);
322 }
323
324
325 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
326 assert(x->is_pinned(),"");
327
328 LIRItem obj(x->obj(), this);
329 obj.dont_load_item();
330
331 LIR_Opr lock = new_register(T_INT);
332 LIR_Opr obj_temp = new_register(T_INT);
333 set_no_result(x);
334 monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
335 }
336
337
338 // _ineg, _lneg, _fneg, _dneg
339 void LIRGenerator::do_NegateOp(NegateOp* x) {
340 LIRItem value(x->x(), this);
341 value.set_destroys_register();
1225 assert(result->is_virtual(), "result must be virtual register");
1226 set_result(x, result);
1227 }
1228
1229
1230 void LIRGenerator::do_NewInstance(NewInstance* x) {
1231 print_if_not_loaded(x);
1232
1233 CodeEmitInfo* info = state_for(x, x->state());
1234 LIR_Opr reg = result_register_for(x->type());
1235 new_instance(reg, x->klass(), x->is_unresolved(),
1236 FrameMap::rcx_oop_opr,
1237 FrameMap::rdi_oop_opr,
1238 FrameMap::rsi_oop_opr,
1239 LIR_OprFact::illegalOpr,
1240 FrameMap::rdx_metadata_opr, info);
1241 LIR_Opr result = rlock_result(x);
1242 __ move(reg, result);
1243 }
1244
1245 void LIRGenerator::do_NewValueTypeInstance (NewValueTypeInstance* x) {
1246 // Mapping to do_NewInstance (same code)
1247 CodeEmitInfo* info = state_for(x, x->state());
1248 x->set_to_object_type();
1249 LIR_Opr reg = result_register_for(x->type());
1250 new_instance(reg, x->klass(), x->is_unresolved(),
1251 FrameMap::rcx_oop_opr,
1252 FrameMap::rdi_oop_opr,
1253 FrameMap::rsi_oop_opr,
1254 LIR_OprFact::illegalOpr,
1255 FrameMap::rdx_metadata_opr, info);
1256 LIR_Opr result = rlock_result(x);
1257 __ move(reg, result);
1258
1259 }
1260
1261 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1262 CodeEmitInfo* info = state_for(x, x->state());
1263
1264 LIRItem length(x->length(), this);
1265 length.load_item_force(FrameMap::rbx_opr);
1266
1267 LIR_Opr reg = result_register_for(x->type());
1268 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1269 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1270 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1271 LIR_Opr tmp4 = reg;
1272 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1273 LIR_Opr len = length.result();
1274 BasicType elem_type = x->elt_type();
1275
1276 __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
1277
1278 CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
1279 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
1287 LIRItem length(x->length(), this);
1288 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1289 // and therefore provide the state before the parameters have been consumed
1290 CodeEmitInfo* patching_info = NULL;
1291 if (!x->klass()->is_loaded() || PatchALot) {
1292 patching_info = state_for(x, x->state_before());
1293 }
1294
1295 CodeEmitInfo* info = state_for(x, x->state());
1296
1297 const LIR_Opr reg = result_register_for(x->type());
1298 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1299 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1300 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1301 LIR_Opr tmp4 = reg;
1302 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1303
1304 length.load_item_force(FrameMap::rbx_opr);
1305 LIR_Opr len = length.result();
1306
1307 ciKlass* obj = (ciKlass*) x->exact_type();
1308 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info, x->is_never_null());
1309 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1310 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1311 }
1312 klass2reg_with_patching(klass_reg, obj, patching_info);
1313 if (x->is_never_null()) {
1314 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_VALUETYPE, klass_reg, slow_path);
1315 } else {
1316 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
1317 }
1318
1319 LIR_Opr result = rlock_result(x);
1320 __ move(reg, result);
1321 }
1322
1323
1324 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1325 Values* dims = x->dims();
1326 int i = dims->length();
1327 LIRItemList* items = new LIRItemList(i, i, NULL);
1328 while (i-- > 0) {
1329 LIRItem* size = new LIRItem(dims->at(i), this);
1330 items->at_put(i, size);
1331 }
1332
1333 // Evaluate state_for early since it may emit code.
1334 CodeEmitInfo* patching_info = NULL;
1335 if (!x->klass()->is_loaded() || PatchALot) {
1336 patching_info = state_for(x, x->state_before());
1337
1376 // nothing to do for now
1377 }
1378
1379
1380 void LIRGenerator::do_CheckCast(CheckCast* x) {
1381 LIRItem obj(x->obj(), this);
1382
1383 CodeEmitInfo* patching_info = NULL;
1384 if (!x->klass()->is_loaded() || (PatchALot && !x->is_incompatible_class_change_check() && !x->is_invokespecial_receiver_check())) {
1385 // must do this before locking the destination register as an oop register,
1386 // and before the obj is loaded (the latter is for deoptimization)
1387 patching_info = state_for(x, x->state_before());
1388 }
1389 obj.load_item();
1390
1391 // info for exceptions
1392 CodeEmitInfo* info_for_exception =
1393 (x->needs_exception_state() ? state_for(x) :
1394 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1395
1396 if (x->is_never_null()) {
1397 __ null_check(obj.result(), new CodeEmitInfo(info_for_exception));
1398 }
1399
1400 CodeStub* stub;
1401 if (x->is_incompatible_class_change_check()) {
1402 assert(patching_info == NULL, "can't patch this");
1403 stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1404 } else if (x->is_invokespecial_receiver_check()) {
1405 assert(patching_info == NULL, "can't patch this");
1406 stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1407 } else {
1408 stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
1409 }
1410 LIR_Opr reg = rlock_result(x);
1411 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1412 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1413 tmp3 = new_register(objectType);
1414 }
1415 __ checkcast(reg, obj.result(), x->klass(),
1416 new_register(objectType), new_register(objectType), tmp3,
1417 x->direct_compare(), info_for_exception, patching_info, stub,
1418 x->profiled_method(), x->profiled_bci(), x->is_never_null());
1419 }
1420
1421
1422 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1423 LIRItem obj(x->obj(), this);
1424
1425 // result and test object may not be in same register
1426 LIR_Opr reg = rlock_result(x);
1427 CodeEmitInfo* patching_info = NULL;
1428 if ((!x->klass()->is_loaded() || PatchALot)) {
1429 // must do this before locking the destination register as an oop register
1430 patching_info = state_for(x, x->state_before());
1431 }
1432 obj.load_item();
1433 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1434 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1435 tmp3 = new_register(objectType);
1436 }
1437 __ instanceof(reg, obj.result(), x->klass(),
1438 new_register(objectType), new_register(objectType), tmp3,
|