comparison src/cpu/x86/vm/graalCodeInstaller_x86.hpp @ 10684:6ff467cdb105

Code installer changes for SPARC.
author twisti
date Tue, 09 Jul 2013 14:39:34 -0700
parents d71c56c67921
children 4e1db4c9d4c5
comparison
equal deleted inserted replaced
10683:ae4c79ee71d1 10684:6ff467cdb105
54 fatal("unsupported type of instruction for call site"); 54 fatal("unsupported type of instruction for call site");
55 return 0; 55 return 0;
56 } 56 }
57 } 57 }
58 58
59 inline void CodeInstaller::pd_site_DataPatch(oop constant, oop kind, bool inlined, 59 inline void CodeInstaller::pd_site_DataPatch(int pc_offset, oop site) {
60 address instruction, int alignment, char typeChar) { 60 oop constant = CompilationResult_DataPatch::constant(site);
61 int alignment = CompilationResult_DataPatch::alignment(site);
62 bool inlined = CompilationResult_DataPatch::inlined(site) == JNI_TRUE;
63
64 oop kind = Constant::kind(constant);
65 char typeChar = Kind::typeChar(kind);
66
67 address pc = _instructions->start() + pc_offset;
68
61 switch (typeChar) { 69 switch (typeChar) {
62 case 'z': 70 case 'z':
63 case 'b': 71 case 'b':
64 case 's': 72 case 's':
65 case 'c': 73 case 'c':
68 break; 76 break;
69 case 'f': 77 case 'f':
70 case 'j': 78 case 'j':
71 case 'd': { 79 case 'd': {
72 if (inlined) { 80 if (inlined) {
73 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); 81 address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
74 *((jlong*) operand) = Constant::primitive(constant); 82 *((jlong*) operand) = Constant::primitive(constant);
75 } else { 83 } else {
76 address operand = Assembler::locate_operand(instruction, Assembler::disp32_operand); 84 address operand = Assembler::locate_operand(pc, Assembler::disp32_operand);
77 address next_instruction = Assembler::locate_next_instruction(instruction); 85 address next_instruction = Assembler::locate_next_instruction(pc);
78 int size = _constants->size(); 86 int size = _constants->size();
79 if (alignment > 0) { 87 if (alignment > 0) {
80 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); 88 guarantee(alignment <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin");
81 size = align_size_up(size, alignment); 89 size = align_size_up(size, alignment);
82 } 90 }
83 // we don't care if this is a long/double/etc., the primitive field contains the right bits 91 // we don't care if this is a long/double/etc., the primitive field contains the right bits
84 address dest = _constants->start() + size; 92 address dest = _constants->start() + size;
85 _constants->set_end(dest + BytesPerLong); 93 _constants->set_end(dest);
86 *(jlong*) dest = Constant::primitive(constant); 94 uint64_t value = Constant::primitive(constant);
95 _constants->emit_int64(value);
87 96
88 long disp = dest - next_instruction; 97 long disp = dest - next_instruction;
89 assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); 98 assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
90 *((jint*) operand) = (jint) disp; 99 *((jint*) operand) = (jint) disp;
91 100
92 _instructions->relocate(instruction, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); 101 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand);
93 TRACE_graal_3("relocating (%c) at %p/%p with destination at %p (%d)", typeChar, instruction, operand, dest, size); 102 TRACE_graal_3("relocating (%c) at %p/%p with destination at %p (%d)", typeChar, pc, operand, dest, size);
94 } 103 }
95 break; 104 break;
96 } 105 }
97 case 'a': { 106 case 'a': {
98 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand); 107 address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
99 Handle obj = Constant::object(constant); 108 Handle obj = Constant::object(constant);
100 109
101 jobject value = JNIHandles::make_local(obj()); 110 jobject value = JNIHandles::make_local(obj());
102 *((jobject*) operand) = value; 111 *((jobject*) operand) = value;
103 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); 112 _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
104 TRACE_graal_3("relocating (oop constant) at %p/%p", instruction, operand); 113 TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand);
105 break; 114 break;
106 } 115 }
107 default: 116 default:
108 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); 117 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar));
109 break; 118 break;