comparison src/cpu/x86/vm/graalCodeInstaller_x86.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 4fc8c8bb4c32
children 343541fb3b49
comparison
equal deleted inserted replaced
13575:55a8ca3f49f7 13576:4e679d50ba9a
58 return 0; 58 return 0;
59 } 59 }
60 } 60 }
61 61
62 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) { 62 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) {
63 int alignment = CompilationResult_DataPatch::alignment(site); 63 oop inlineData = CompilationResult_DataPatch::inlineData(site);
64 bool inlined = CompilationResult_DataPatch::inlined(site) == JNI_TRUE;
65
66 address pc = _instructions->start() + pc_offset; 64 address pc = _instructions->start() + pc_offset;
67 65
68 oop constant = CompilationResult_DataPatch::constant(site); 66 if (inlineData != NULL) {
69 char typeChar; 67 oop kind = Constant::kind(inlineData);
70 if (constant != NULL) { 68 char typeChar = Kind::typeChar(kind);
71 oop kind = Constant::kind(constant); 69
72 typeChar = Kind::typeChar(kind); 70 switch (typeChar) {
73 } else { 71 case 'z':
74 assert(!inlined, "cannot inline raw constants"); 72 case 'b':
75 typeChar = '*'; 73 case 's':
76 } 74 case 'c':
77 75 fatal("int-sized values not expected in DataPatch");
78 switch (typeChar) { 76 break;
79 case 'z': 77 case 'i': {
80 case 'b': 78 address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand);
81 case 's': 79 Handle obj = Constant::object(inlineData);
82 case 'c': 80
83 fatal("int-sized values not expected in DataPatch"); 81 jobject value = JNIHandles::make_local(obj());
84 break; 82 int oop_index = _oop_recorder->find_index(value);
85 83 _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand);
86 case 'i': { 84 TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand);
87 address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); 85 break;
88 Handle obj = Constant::object(constant); 86 }
89 87 case 'f':
90 jobject value = JNIHandles::make_local(obj()); 88 case 'j':
91 int oop_index = _oop_recorder->find_index(value); 89 case 'd':
92 _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand); 90 case '*': {
93 TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand);
94 break;
95 }
96
97 case 'f':
98 case 'j':
99 case 'd':
100 case '*': {
101 if (inlined) {
102 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); 91 address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
103 *((jlong*) operand) = Constant::primitive(constant); 92 *((jlong*) operand) = Constant::primitive(inlineData);
104 } else { 93 break;
105 address operand = Assembler::locate_operand(pc, Assembler::disp32_operand);
106 address next_instruction = Assembler::locate_next_instruction(pc);
107 int size = _constants->size();
108 if (alignment > 0) {
109 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin");
110 size = align_size_up(size, alignment);
111 }
112 // we don't care if this is a long/double/etc., the primitive field contains the right bits
113 address dest = _constants->start() + size;
114 _constants->set_end(dest);
115 if (constant != NULL) {
116 uint64_t value = Constant::primitive(constant);
117 _constants->emit_int64(value);
118 } else {
119 arrayOop rawConstant = arrayOop(CompilationResult_DataPatch::rawConstant(site));
120 int8_t *ptr = (int8_t*) rawConstant->base(T_BYTE);
121 for (int i = rawConstant->length(); i > 0; i--, ptr++) {
122 _constants->emit_int8(*ptr);
123 }
124 }
125
126 long disp = dest - next_instruction;
127 assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
128 *((jint*) operand) = (jint) disp;
129
130 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand);
131 TRACE_graal_3("relocating (%c) at %p/%p with destination at %p (%d)", typeChar, pc, operand, dest, size);
132 } 94 }
133 break; 95 case 'a': {
134 } 96 address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
135 case 'a': { 97 Handle obj = Constant::object(inlineData);
136 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); 98
137 Handle obj = Constant::object(constant); 99 jobject value = JNIHandles::make_local(obj());
138 100 *((jobject*) operand) = value;
139 jobject value = JNIHandles::make_local(obj()); 101 _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
140 *((jobject*) operand) = value; 102 TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand);
141 _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); 103 break;
142 TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand); 104 }
143 break; 105 default:
144 } 106 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar));
145 default: 107 break;
146 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); 108 }
147 break; 109 } else {
110 oop dataRef = CompilationResult_DataPatch::externalData(site);
111 jint offset = HotSpotCompiledCode_HotSpotData::offset(dataRef);
112 address operand = Assembler::locate_operand(pc, Assembler::disp32_operand);
113 address next_instruction = Assembler::locate_next_instruction(pc);
114 address dest = _constants->start() + offset;
115
116 long disp = dest - next_instruction;
117 assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
118 *((jint*) operand) = (jint) disp;
119
120 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand);
121 TRACE_graal_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, offset);
148 } 122 }
149 } 123 }
150 124
151 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { 125 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) {
152 if (cb->is_nmethod()) { 126 if (cb->is_nmethod()) {