Mercurial > hg > graal-compiler
comparison src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @ 6948:e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Nov 2012 23:14:12 +0100 |
parents | 8e47bac5643a |
children | 46f6f063b272 |
comparison
equal
deleted
inserted
replaced
6711:ae13cc658b80 | 6948:e522a00b91aa |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
751 } | 751 } |
752 | 752 |
753 LIR_Opr addr = new_pointer_register(); | 753 LIR_Opr addr = new_pointer_register(); |
754 LIR_Address* a; | 754 LIR_Address* a; |
755 if(offset.result()->is_constant()) { | 755 if(offset.result()->is_constant()) { |
756 #ifdef _LP64 | |
757 jlong c = offset.result()->as_jlong(); | |
758 if ((jlong)((jint)c) == c) { | |
759 a = new LIR_Address(obj.result(), | |
760 (jint)c, | |
761 as_BasicType(type)); | |
762 } else { | |
763 LIR_Opr tmp = new_register(T_LONG); | |
764 __ move(offset.result(), tmp); | |
765 a = new LIR_Address(obj.result(), | |
766 tmp, | |
767 as_BasicType(type)); | |
768 } | |
769 #else | |
756 a = new LIR_Address(obj.result(), | 770 a = new LIR_Address(obj.result(), |
757 NOT_LP64(offset.result()->as_constant_ptr()->as_jint()) LP64_ONLY((int)offset.result()->as_constant_ptr()->as_jlong()), | 771 offset.result()->as_jint(), |
758 as_BasicType(type)); | 772 as_BasicType(type)); |
773 #endif | |
759 } else { | 774 } else { |
760 a = new LIR_Address(obj.result(), | 775 a = new LIR_Address(obj.result(), |
761 offset.result(), | 776 offset.result(), |
762 LIR_Address::times_1, | 777 LIR_Address::times_1, |
763 0, | 778 0, |
1000 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci()); | 1015 tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci()); |
1001 } | 1016 } |
1002 #endif | 1017 #endif |
1003 CodeEmitInfo* info = state_for(x, x->state()); | 1018 CodeEmitInfo* info = state_for(x, x->state()); |
1004 LIR_Opr reg = result_register_for(x->type()); | 1019 LIR_Opr reg = result_register_for(x->type()); |
1005 LIR_Opr klass_reg = new_register(objectType); | |
1006 new_instance(reg, x->klass(), | 1020 new_instance(reg, x->klass(), |
1007 FrameMap::rcx_oop_opr, | 1021 FrameMap::rcx_oop_opr, |
1008 FrameMap::rdi_oop_opr, | 1022 FrameMap::rdi_oop_opr, |
1009 FrameMap::rsi_oop_opr, | 1023 FrameMap::rsi_oop_opr, |
1010 LIR_OprFact::illegalOpr, | 1024 LIR_OprFact::illegalOpr, |
1011 FrameMap::rdx_oop_opr, info); | 1025 FrameMap::rdx_metadata_opr, info); |
1012 LIR_Opr result = rlock_result(x); | 1026 LIR_Opr result = rlock_result(x); |
1013 __ move(reg, result); | 1027 __ move(reg, result); |
1014 } | 1028 } |
1015 | 1029 |
1016 | 1030 |
1023 LIR_Opr reg = result_register_for(x->type()); | 1037 LIR_Opr reg = result_register_for(x->type()); |
1024 LIR_Opr tmp1 = FrameMap::rcx_oop_opr; | 1038 LIR_Opr tmp1 = FrameMap::rcx_oop_opr; |
1025 LIR_Opr tmp2 = FrameMap::rsi_oop_opr; | 1039 LIR_Opr tmp2 = FrameMap::rsi_oop_opr; |
1026 LIR_Opr tmp3 = FrameMap::rdi_oop_opr; | 1040 LIR_Opr tmp3 = FrameMap::rdi_oop_opr; |
1027 LIR_Opr tmp4 = reg; | 1041 LIR_Opr tmp4 = reg; |
1028 LIR_Opr klass_reg = FrameMap::rdx_oop_opr; | 1042 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr; |
1029 LIR_Opr len = length.result(); | 1043 LIR_Opr len = length.result(); |
1030 BasicType elem_type = x->elt_type(); | 1044 BasicType elem_type = x->elt_type(); |
1031 | 1045 |
1032 __ oop2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); | 1046 __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg); |
1033 | 1047 |
1034 CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); | 1048 CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info); |
1035 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); | 1049 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path); |
1036 | 1050 |
1037 LIR_Opr result = rlock_result(x); | 1051 LIR_Opr result = rlock_result(x); |
1053 const LIR_Opr reg = result_register_for(x->type()); | 1067 const LIR_Opr reg = result_register_for(x->type()); |
1054 LIR_Opr tmp1 = FrameMap::rcx_oop_opr; | 1068 LIR_Opr tmp1 = FrameMap::rcx_oop_opr; |
1055 LIR_Opr tmp2 = FrameMap::rsi_oop_opr; | 1069 LIR_Opr tmp2 = FrameMap::rsi_oop_opr; |
1056 LIR_Opr tmp3 = FrameMap::rdi_oop_opr; | 1070 LIR_Opr tmp3 = FrameMap::rdi_oop_opr; |
1057 LIR_Opr tmp4 = reg; | 1071 LIR_Opr tmp4 = reg; |
1058 LIR_Opr klass_reg = FrameMap::rdx_oop_opr; | 1072 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr; |
1059 | 1073 |
1060 length.load_item_force(FrameMap::rbx_opr); | 1074 length.load_item_force(FrameMap::rbx_opr); |
1061 LIR_Opr len = length.result(); | 1075 LIR_Opr len = length.result(); |
1062 | 1076 |
1063 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info); | 1077 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info); |
1064 ciObject* obj = (ciObject*) ciObjArrayKlass::make(x->klass()); | 1078 ciKlass* obj = (ciKlass*) ciObjArrayKlass::make(x->klass()); |
1065 if (obj == ciEnv::unloaded_ciobjarrayklass()) { | 1079 if (obj == ciEnv::unloaded_ciobjarrayklass()) { |
1066 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error"); | 1080 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error"); |
1067 } | 1081 } |
1068 jobject2reg_with_patching(klass_reg, obj, patching_info); | 1082 klass2reg_with_patching(klass_reg, obj, patching_info); |
1069 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path); | 1083 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path); |
1070 | 1084 |
1071 LIR_Opr result = rlock_result(x); | 1085 LIR_Opr result = rlock_result(x); |
1072 __ move(reg, result); | 1086 __ move(reg, result); |
1073 } | 1087 } |
1101 size->load_nonconstant(); | 1115 size->load_nonconstant(); |
1102 | 1116 |
1103 store_stack_parameter(size->result(), in_ByteSize(i*4)); | 1117 store_stack_parameter(size->result(), in_ByteSize(i*4)); |
1104 } | 1118 } |
1105 | 1119 |
1106 LIR_Opr reg = result_register_for(x->type()); | 1120 LIR_Opr klass_reg = FrameMap::rax_metadata_opr; |
1107 jobject2reg_with_patching(reg, x->klass(), patching_info); | 1121 klass2reg_with_patching(klass_reg, x->klass(), patching_info); |
1108 | 1122 |
1109 LIR_Opr rank = FrameMap::rbx_opr; | 1123 LIR_Opr rank = FrameMap::rbx_opr; |
1110 __ move(LIR_OprFact::intConst(x->rank()), rank); | 1124 __ move(LIR_OprFact::intConst(x->rank()), rank); |
1111 LIR_Opr varargs = FrameMap::rcx_opr; | 1125 LIR_Opr varargs = FrameMap::rcx_opr; |
1112 __ move(FrameMap::rsp_opr, varargs); | 1126 __ move(FrameMap::rsp_opr, varargs); |
1113 LIR_OprList* args = new LIR_OprList(3); | 1127 LIR_OprList* args = new LIR_OprList(3); |
1114 args->append(reg); | 1128 args->append(klass_reg); |
1115 args->append(rank); | 1129 args->append(rank); |
1116 args->append(varargs); | 1130 args->append(varargs); |
1131 LIR_Opr reg = result_register_for(x->type()); | |
1117 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), | 1132 __ call_runtime(Runtime1::entry_for(Runtime1::new_multi_array_id), |
1118 LIR_OprFact::illegalOpr, | 1133 LIR_OprFact::illegalOpr, |
1119 reg, args, info); | 1134 reg, args, info); |
1120 | 1135 |
1121 LIR_Opr result = rlock_result(x); | 1136 LIR_Opr result = rlock_result(x); |
1149 } else { | 1164 } else { |
1150 stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); | 1165 stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception); |
1151 } | 1166 } |
1152 LIR_Opr reg = rlock_result(x); | 1167 LIR_Opr reg = rlock_result(x); |
1153 LIR_Opr tmp3 = LIR_OprFact::illegalOpr; | 1168 LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
1154 if (!x->klass()->is_loaded() || UseCompressedOops) { | 1169 if (!x->klass()->is_loaded() || UseCompressedKlassPointers) { |
1155 tmp3 = new_register(objectType); | 1170 tmp3 = new_register(objectType); |
1156 } | 1171 } |
1157 __ checkcast(reg, obj.result(), x->klass(), | 1172 __ checkcast(reg, obj.result(), x->klass(), |
1158 new_register(objectType), new_register(objectType), tmp3, | 1173 new_register(objectType), new_register(objectType), tmp3, |
1159 x->direct_compare(), info_for_exception, patching_info, stub, | 1174 x->direct_compare(), info_for_exception, patching_info, stub, |
1171 // must do this before locking the destination register as an oop register | 1186 // must do this before locking the destination register as an oop register |
1172 patching_info = state_for(x, x->state_before()); | 1187 patching_info = state_for(x, x->state_before()); |
1173 } | 1188 } |
1174 obj.load_item(); | 1189 obj.load_item(); |
1175 LIR_Opr tmp3 = LIR_OprFact::illegalOpr; | 1190 LIR_Opr tmp3 = LIR_OprFact::illegalOpr; |
1176 if (!x->klass()->is_loaded() || UseCompressedOops) { | 1191 if (!x->klass()->is_loaded() || UseCompressedKlassPointers) { |
1177 tmp3 = new_register(objectType); | 1192 tmp3 = new_register(objectType); |
1178 } | 1193 } |
1179 __ instanceof(reg, obj.result(), x->klass(), | 1194 __ instanceof(reg, obj.result(), x->klass(), |
1180 new_register(objectType), new_register(objectType), tmp3, | 1195 new_register(objectType), new_register(objectType), tmp3, |
1181 x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); | 1196 x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci()); |
1343 } else { | 1358 } else { |
1344 __ move(data, addr); | 1359 __ move(data, addr); |
1345 } | 1360 } |
1346 } | 1361 } |
1347 } | 1362 } |
1363 | |
1364 void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { | |
1365 BasicType type = x->basic_type(); | |
1366 LIRItem src(x->object(), this); | |
1367 LIRItem off(x->offset(), this); | |
1368 LIRItem value(x->value(), this); | |
1369 | |
1370 src.load_item(); | |
1371 value.load_item(); | |
1372 off.load_nonconstant(); | |
1373 | |
1374 LIR_Opr dst = rlock_result(x, type); | |
1375 LIR_Opr data = value.result(); | |
1376 bool is_obj = (type == T_ARRAY || type == T_OBJECT); | |
1377 LIR_Opr offset = off.result(); | |
1378 | |
1379 assert (type == T_INT || (!x->is_add() && is_obj) LP64_ONLY( || type == T_LONG ), "unexpected type"); | |
1380 LIR_Address* addr; | |
1381 if (offset->is_constant()) { | |
1382 #ifdef _LP64 | |
1383 jlong c = offset->as_jlong(); | |
1384 if ((jlong)((jint)c) == c) { | |
1385 addr = new LIR_Address(src.result(), (jint)c, type); | |
1386 } else { | |
1387 LIR_Opr tmp = new_register(T_LONG); | |
1388 __ move(offset, tmp); | |
1389 addr = new LIR_Address(src.result(), tmp, type); | |
1390 } | |
1391 #else | |
1392 addr = new LIR_Address(src.result(), offset->as_jint(), type); | |
1393 #endif | |
1394 } else { | |
1395 addr = new LIR_Address(src.result(), offset, type); | |
1396 } | |
1397 | |
1398 if (data != dst) { | |
1399 __ move(data, dst); | |
1400 data = dst; | |
1401 } | |
1402 if (x->is_add()) { | |
1403 __ xadd(LIR_OprFact::address(addr), data, dst, LIR_OprFact::illegalOpr); | |
1404 } else { | |
1405 if (is_obj) { | |
1406 // Do the pre-write barrier, if any. | |
1407 pre_barrier(LIR_OprFact::address(addr), LIR_OprFact::illegalOpr /* pre_val */, | |
1408 true /* do_load */, false /* patch */, NULL); | |
1409 } | |
1410 __ xchg(LIR_OprFact::address(addr), data, dst, LIR_OprFact::illegalOpr); | |
1411 if (is_obj) { | |
1412 // Seems to be a precise address | |
1413 post_barrier(LIR_OprFact::address(addr), data); | |
1414 } | |
1415 } | |
1416 } |