comparison src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp @ 13576:4e679d50ba9a

Move data section building code to Java.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 09 Jan 2014 13:09:44 +0100
parents d49f00604347
children e14198669e5c
comparison
equal deleted inserted replaced
13575:55a8ca3f49f7 13576:4e679d50ba9a
40 return 0; 40 return 0;
41 } 41 }
42 } 42 }
43 43
44 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) { 44 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) {
45 oop constant = CompilationResult_DataPatch::constant(site); 45 oop inlineData = CompilationResult_DataPatch::inlineData(site);
46 int alignment = CompilationResult_DataPatch::alignment(site);
47 bool inlined = CompilationResult_DataPatch::inlined(site) == JNI_TRUE;
48
49 oop kind = Constant::kind(constant);
50 char typeChar = Kind::typeChar(kind);
51
52 address pc = _instructions->start() + pc_offset; 46 address pc = _instructions->start() + pc_offset;
53 47
54 switch (typeChar) { 48 if (inlineData != NULL) {
55 case 'z': 49 oop kind = Constant::kind(inlineData);
56 case 'b': 50 char typeChar = Kind::typeChar(kind);
57 case 's': 51
58 case 'c': 52 switch (typeChar) {
59 case 'i': 53 case 'z':
60 fatal("int-sized values not expected in DataPatch"); 54 case 'b':
61 break; 55 case 's':
62 case 'f': 56 case 'c':
63 case 'j': 57 case 'i':
64 case 'd': { 58 fatal("int-sized values not expected in DataPatch");
65 if (inlined) { 59 break;
60 case 'f':
61 case 'j':
62 case 'd': {
66 NativeMovConstReg* move = nativeMovConstReg_at(pc); 63 NativeMovConstReg* move = nativeMovConstReg_at(pc);
67 uint64_t value = Constant::primitive(constant); 64 uint64_t value = Constant::primitive(inlineData);
68 move->set_data(value); 65 move->set_data(value);
69 } else { 66 break;
70 int size = _constants->size();
71 if (alignment > 0) {
72 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin");
73 size = align_size_up(size, alignment);
74 }
75 // we don't care if this is a long/double/etc., the primitive field contains the right bits
76 address dest = _constants->start() + size;
77 _constants->set_end(dest);
78 uint64_t value = Constant::primitive(constant);
79 _constants->emit_int64(value);
80
81 NativeMovRegMem* load = nativeMovRegMem_at(pc);
82 int disp = _constants_size + pc_offset - size - BytesPerInstWord;
83 load->set_offset(-disp);
84 } 67 }
85 break; 68 case 'a': {
86 }
87 case 'a': {
88 if (inlined) {
89 NativeMovConstReg* move = nativeMovConstReg_at(pc); 69 NativeMovConstReg* move = nativeMovConstReg_at(pc);
90 Handle obj = Constant::object(constant); 70 Handle obj = Constant::object(inlineData);
91 jobject value = JNIHandles::make_local(obj()); 71 jobject value = JNIHandles::make_local(obj());
92 move->set_data((intptr_t) value); 72 move->set_data((intptr_t) value);
93 73
94 // We need two relocations: one on the sethi and one on the add. 74 // We need two relocations: one on the sethi and one on the add.
95 int oop_index = _oop_recorder->find_index(value); 75 int oop_index = _oop_recorder->find_index(value);
96 RelocationHolder rspec = oop_Relocation::spec(oop_index); 76 RelocationHolder rspec = oop_Relocation::spec(oop_index);
97 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); 77 _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec);
98 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); 78 _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec);
99 } else { 79 break;
100 int size = _constants->size(); 80 }
101 if (alignment > 0) { 81 default:
102 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); 82 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar));
103 size = align_size_up(size, alignment); 83 break;
104 } 84 }
105 address dest = _constants->start() + size; 85 } else {
106 _constants->set_end(dest); 86 oop dataRef = CompilationResult_DataPatch::externalData(site);
107 Handle obj = Constant::object(constant); 87 jint offset = HotSpotCompiledCode_HotSpotData::offset(dataRef);
108 jobject value = JNIHandles::make_local(obj());
109 _constants->emit_address((address) value);
110 88
111 NativeMovRegMem* load = nativeMovRegMem_at(pc); 89 NativeMovRegMem* load = nativeMovRegMem_at(pc);
112 int disp = _constants_size + pc_offset - size - BytesPerInstWord; 90 int disp = _constants_size + pc_offset - offset - BytesPerInstWord;
113 load->set_offset(-disp); 91 load->set_offset(-disp);
114
115 int oop_index = _oop_recorder->find_index(value);
116 _constants->relocate(dest, oop_Relocation::spec(oop_index));
117 }
118 break;
119 }
120 default:
121 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar));
122 break;
123 } 92 }
124 } 93 }
125 94
126 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { 95 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
127 fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp"); 96 fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp");