comparison src/share/vm/graal/graalCodeInstaller.cpp @ 7742:9f8bf17b2d33

Remove hardcoding of x86 registers in the Graal code installer.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 07 Feb 2013 18:01:08 +0100
parents a7a93887b4c4
children 62bcf515831d
comparison
equal deleted inserted replaced
7741:e72cdc425cf4 7742:9f8bf17b2d33
29 #include "graal/graalCodeInstaller.hpp" 29 #include "graal/graalCodeInstaller.hpp"
30 #include "graal/graalJavaAccess.hpp" 30 #include "graal/graalJavaAccess.hpp"
31 #include "graal/graalCompilerToVM.hpp" 31 #include "graal/graalCompilerToVM.hpp"
32 #include "graal/graalVmIds.hpp" 32 #include "graal/graalVmIds.hpp"
33 #include "graal/graalRuntime.hpp" 33 #include "graal/graalRuntime.hpp"
34 #include "asm/register.hpp"
34 #include "classfile/vmSymbols.hpp" 35 #include "classfile/vmSymbols.hpp"
35 #include "vmreg_x86.inline.hpp" 36 #include "code/vmreg.hpp"
36 37
37 38 #ifdef TARGET_ARCH_x86
38 // TODO this should be handled in a more robust way - not hard coded... 39 # include "vmreg_x86.inline.hpp"
39 Register CPU_REGS[] = { rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15 }; 40 #endif
40 bool OOP_ALLOWED[] = {true, true, true, true, false, false, true, true, true, true, false, true, true, true, true, true}; 41 #ifdef TARGET_ARCH_sparc
41 const static int NUM_CPU_REGS = sizeof(CPU_REGS) / sizeof(Register); 42 # include "vmreg_sparc.inline.hpp"
42 XMMRegister XMM_REGS[] = { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 }; 43 #endif
43 const static int NUM_XMM_REGS = sizeof(XMM_REGS) / sizeof(XMMRegister); 44 #ifdef TARGET_ARCH_zero
44 const static int NUM_REGS = NUM_CPU_REGS + NUM_XMM_REGS; 45 # include "vmreg_zero.inline.hpp"
45 const static jlong NO_REF_MAP = 0x8000000000000000L; 46 #endif
47 #ifdef TARGET_ARCH_arm
48 # include "vmreg_arm.inline.hpp"
49 #endif
50 #ifdef TARGET_ARCH_ppc
51 # include "vmreg_ppc.inline.hpp"
52 #endif
46 53
47 // convert Graal register indices (as used in oop maps) to HotSpot registers 54 // convert Graal register indices (as used in oop maps) to HotSpot registers
48 VMReg get_hotspot_reg(jint graal_reg) { 55 VMReg get_hotspot_reg(jint graal_reg) {
49 56 if (graal_reg < RegisterImpl::number_of_registers) {
50 assert(graal_reg >= 0 && graal_reg < NUM_REGS, "invalid register number"); 57 return as_Register(graal_reg)->as_VMReg();
51 if (graal_reg < NUM_CPU_REGS) {
52 return CPU_REGS[graal_reg]->as_VMReg();
53 } else { 58 } else {
54 return XMM_REGS[graal_reg - NUM_CPU_REGS]->as_VMReg(); 59 int remainder = graal_reg - RegisterImpl::number_of_registers;
60 #ifdef TARGET_ARCH_x86
61 if (remainder < XMMRegisterImpl::number_of_registers) {
62 return as_XMMRegister(remainder)->as_VMReg();
63 }
64 #endif
65 ShouldNotReachHere();
55 } 66 }
56 } 67 }
57 68
58 const int MapWordBits = 64; 69 const int MapWordBits = 64;
59 70
75 OopMap* map = new OopMap(total_frame_size, parameter_count); 86 OopMap* map = new OopMap(total_frame_size, parameter_count);
76 oop register_map = (oop) DebugInfo::registerRefMap(debug_info); 87 oop register_map = (oop) DebugInfo::registerRefMap(debug_info);
77 oop frame_map = (oop) DebugInfo::frameRefMap(debug_info); 88 oop frame_map = (oop) DebugInfo::frameRefMap(debug_info);
78 89
79 if (register_map != NULL) { 90 if (register_map != NULL) {
80 for (jint i = 0; i < NUM_CPU_REGS; i++) { 91 for (jint i = 0; i < RegisterImpl::number_of_registers; i++) {
81 bool is_oop = is_bit_set(register_map, i); 92 bool is_oop = is_bit_set(register_map, i);
82 VMReg reg = get_hotspot_reg(i); 93 VMReg reg = get_hotspot_reg(i);
83 if (is_oop) { 94 if (is_oop) {
84 assert(OOP_ALLOWED[i], "this register may never be an oop, register map misaligned?");
85 map->set_oop(reg); 95 map->set_oop(reg);
86 } else { 96 } else {
87 map->set_value(reg); 97 map->set_value(reg);
88 } 98 }
89 } 99 }
155 // this seems weird, but the same value is used in c1_LinearScan 165 // this seems weird, but the same value is used in c1_LinearScan
156 locationType = Location::normal; 166 locationType = Location::normal;
157 } else { 167 } else {
158 locationType = Location::dbl; 168 locationType = Location::dbl;
159 } 169 }
170 #ifdef TARGET_ARCH_x86
160 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_XMMRegister(number - 16)->as_VMReg())); 171 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_XMMRegister(number - 16)->as_VMReg()));
161 if (type == T_DOUBLE) { 172 if (type == T_DOUBLE) {
162 second = value; 173 second = value;
163 } 174 }
164 return value; 175 return value;
176 #else
177 ShouldNotReachHere("Platform currently does not support floating point values.");
178 #endif
165 } 179 }
166 } else if (value->is_a(StackSlot::klass())) { 180 } else if (value->is_a(StackSlot::klass())) {
167 if (type == T_DOUBLE) { 181 if (type == T_DOUBLE) {
168 locationType = Location::dbl; 182 locationType = Location::dbl;
169 } else if (type == T_LONG) { 183 } else if (type == T_LONG) {