comparison src/share/vm/graal/graalCodeInstaller.cpp @ 17024:4e2d34d7715b

[SPARC/AMD64] Splitting up oopmap generation for Intel XMM and SPARC Floatingpoint registers
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Tue, 02 Sep 2014 17:16:26 -0700
parents 6ea6d4c260c8
children 26f5733fb645
comparison
equal deleted inserted replaced
17023:586c1bdd73b8 17024:4e2d34d7715b
55 Method* getMethodFromHotSpotMethod(oop hotspot_method) { 55 Method* getMethodFromHotSpotMethod(oop hotspot_method) {
56 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity"); 56 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity");
57 return asMethod(HotSpotResolvedJavaMethod::metaspaceMethod(hotspot_method)); 57 return asMethod(HotSpotResolvedJavaMethod::metaspaceMethod(hotspot_method));
58 } 58 }
59 59
60 // convert Graal register indices (as used in oop maps) to HotSpot registers
61 VMReg get_hotspot_reg(jint graal_reg) {
62 if (graal_reg < RegisterImpl::number_of_registers) {
63 return as_Register(graal_reg)->as_VMReg();
64 } else {
65 int remainder = graal_reg - RegisterImpl::number_of_registers;
66 #ifdef TARGET_ARCH_x86
67 if (remainder < XMMRegisterImpl::number_of_registers) {
68 return as_XMMRegister(remainder)->as_VMReg();
69 }
70 #endif
71 #ifdef TARGET_ARCH_sparc
72 if (remainder < FloatRegisterImpl::number_of_registers) {
73 return as_FloatRegister(remainder)->as_VMReg();
74 }
75 #endif
76 ShouldNotReachHere();
77 return NULL;
78 }
79 }
80
81 const int MapWordBits = 64; 60 const int MapWordBits = 64;
82 61
83 static bool is_bit_set(oop bitset, int i) { 62 static bool is_bit_set(oop bitset, int i) {
84 jint words_idx = i / MapWordBits; 63 jint words_idx = i / MapWordBits;
85 arrayOop words = (arrayOop) BitSet::words(bitset); 64 arrayOop words = (arrayOop) BitSet::words(bitset);
153 objArrayOop registers = (objArrayOop) RegisterSaveLayout::registers(callee_save_info); 132 objArrayOop registers = (objArrayOop) RegisterSaveLayout::registers(callee_save_info);
154 arrayOop slots = (arrayOop) RegisterSaveLayout::slots(callee_save_info); 133 arrayOop slots = (arrayOop) RegisterSaveLayout::slots(callee_save_info);
155 for (jint i = 0; i < slots->length(); i++) { 134 for (jint i = 0; i < slots->length(); i++) {
156 oop graal_reg = registers->obj_at(i); 135 oop graal_reg = registers->obj_at(i);
157 jint graal_reg_number = code_Register::number(graal_reg); 136 jint graal_reg_number = code_Register::number(graal_reg);
158 VMReg hotspot_reg = get_hotspot_reg(graal_reg_number); 137 VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(graal_reg_number);
159 // HotSpot stack slots are 4 bytes 138 // HotSpot stack slots are 4 bytes
160 jint graal_slot = ((jint*) slots->base(T_INT))[i]; 139 jint graal_slot = ((jint*) slots->base(T_INT))[i];
161 jint hotspot_slot = graal_slot * VMRegImpl::slots_per_word; 140 jint hotspot_slot = graal_slot * VMRegImpl::slots_per_word;
162 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); 141 VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot);
163 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); 142 map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg);
225 BasicType type = GraalRuntime::kindToBasicType(Kind::typeChar(platformKind)); 204 BasicType type = GraalRuntime::kindToBasicType(Kind::typeChar(platformKind));
226 205
227 if (value->is_a(RegisterValue::klass())) { 206 if (value->is_a(RegisterValue::klass())) {
228 oop reg = RegisterValue::reg(value); 207 oop reg = RegisterValue::reg(value);
229 jint number = code_Register::number(reg); 208 jint number = code_Register::number(reg);
230 jint encoding = code_Register::encoding(reg); 209 VMReg hotspotRegister = get_hotspot_reg(number);
231 oop registerCategory = code_Register::registerCategory(reg); 210 if (is_general_purpose_reg(hotspotRegister)) {
232 jint referenceMapOffset = RegisterCategory::referenceMapOffset(registerCategory);
233 if (number < RegisterImpl::number_of_registers) {
234 Location::Type locationType; 211 Location::Type locationType;
235 if (type == T_INT) { 212 if (type == T_INT) {
236 locationType = reference ? Location::narrowoop : Location::int_in_long; 213 locationType = reference ? Location::narrowoop : Location::int_in_long;
237 } else if(type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { 214 } else if(type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) {
238 locationType = Location::int_in_long; 215 locationType = Location::int_in_long;
242 locationType = reference ? Location::oop : Location::lng; 219 locationType = reference ? Location::oop : Location::lng;
243 } else { 220 } else {
244 assert(type == T_OBJECT && reference, "unexpected type in cpu register"); 221 assert(type == T_OBJECT && reference, "unexpected type in cpu register");
245 locationType = Location::oop; 222 locationType = Location::oop;
246 } 223 }
247 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_Register(number)->as_VMReg())); 224 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister));
248 if (type == T_LONG && !reference) { 225 if (type == T_LONG && !reference) {
249 second = value; 226 second = value;
250 } 227 }
251 return value; 228 return value;
252 } else { 229 } else {
257 locationType = Location::normal; 234 locationType = Location::normal;
258 } else { 235 } else {
259 locationType = Location::dbl; 236 locationType = Location::dbl;
260 } 237 }
261 assert(!reference, "unexpected type in floating point register"); 238 assert(!reference, "unexpected type in floating point register");
262 jint floatRegisterNumber = number - referenceMapOffset; 239 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister));
263 #ifdef TARGET_ARCH_x86
264 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_XMMRegister(floatRegisterNumber)->as_VMReg()));
265 if (type == T_DOUBLE) { 240 if (type == T_DOUBLE) {
266 second = value; 241 second = value;
267 } 242 }
268 return value; 243 return value;
269 #else
270 #ifdef TARGET_ARCH_sparc
271 floatRegisterNumber += MAX2(0, floatRegisterNumber-32); // Beginning with f32, only every second register is going to be addressed
272 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_FloatRegister(floatRegisterNumber)->as_VMReg()));
273 if (type == T_DOUBLE) {
274 second = value;
275 }
276 return value;
277 #else
278 ShouldNotReachHere("Platform currently does not support floating point values.");
279 #endif
280 #endif
281 } 244 }
282 } else if (value->is_a(StackSlot::klass())) { 245 } else if (value->is_a(StackSlot::klass())) {
283 Location::Type locationType; 246 Location::Type locationType;
284 if (type == T_LONG) { 247 if (type == T_LONG) {
285 locationType = reference ? Location::oop : Location::lng; 248 locationType = reference ? Location::oop : Location::lng;