Mercurial > hg > graal-jvmci-8
comparison src/cpu/x86/vm/graalCodeInstaller_x86.hpp @ 14561:e14198669e5c
Make data patch system use vm specific NarrowOop kind.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 17 Mar 2014 11:53:51 +0100 |
parents | 343541fb3b49 |
children | 6bab029d6e3a |
comparison
equal
deleted
inserted
replaced
14560:570910f5412b | 14561:e14198669e5c |
---|---|
57 fatal("unsupported type of instruction for call site"); | 57 fatal("unsupported type of instruction for call site"); |
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 bool check_metaspace_data(address pc, oop data) { |
63 oop inlineData = CompilationResult_DataPatch::inlineData(site); | 63 jlong value = MetaspaceData::value(data); |
64 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); | |
65 if (MetaspaceData::compressed(data)) { | |
66 assert(*((jint*) operand) == value, err_msg("wrong compressed metaspace pointer: %p != %p", *((jint*) operand), value)); | |
67 } else { | |
68 assert(*((jlong*) operand) == value, err_msg("wrong metaspace pointer: %p != %p", *((jlong*) operand), value)); | |
69 } | |
70 return true; | |
71 } | |
72 | |
73 inline void CodeInstaller::pd_patch_OopData(int pc_offset, oop data) { | |
64 address pc = _instructions->start() + pc_offset; | 74 address pc = _instructions->start() + pc_offset; |
65 | 75 |
66 if (inlineData != NULL) { | 76 Handle obj = OopData::object(data); |
67 oop kind = Constant::kind(inlineData); | 77 jobject value = JNIHandles::make_local(obj()); |
68 char typeChar = Kind::typeChar(kind); | 78 if (OopData::compressed(data)) { |
69 | 79 address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); |
70 switch (typeChar) { | 80 int oop_index = _oop_recorder->find_index(value); |
71 case 'z': | 81 _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand); |
72 case 'b': | 82 TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand); |
73 case 's': | 83 } else { |
74 case 'c': | 84 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); |
75 case 'i': | 85 *((jobject*) operand) = value; |
76 fatal("int-sized values not expected in DataPatch"); | 86 _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); |
77 break; | 87 TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand); |
78 case 'n': { | 88 } |
79 address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); | 89 } |
80 Handle obj = Constant::object(inlineData); | 90 |
81 | 91 inline void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, oop data) { |
82 jobject value = JNIHandles::make_local(obj()); | 92 address pc = _instructions->start() + pc_offset; |
83 int oop_index = _oop_recorder->find_index(value); | 93 jint offset = DataSectionReference::offset(data); |
84 _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand); | 94 |
85 TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand); | 95 address operand = Assembler::locate_operand(pc, Assembler::disp32_operand); |
86 break; | 96 address next_instruction = Assembler::locate_next_instruction(pc); |
87 } | 97 address dest = _constants->start() + offset; |
88 case 'f': | 98 |
89 case 'j': | 99 long disp = dest - next_instruction; |
90 case 'd': | 100 assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); |
91 case '*': { | 101 *((jint*) operand) = (jint) disp; |
92 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); | 102 |
93 *((jlong*) operand) = Constant::primitive(inlineData); | 103 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); |
94 break; | 104 TRACE_graal_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, offset); |
95 } | |
96 case 'a': { | |
97 address operand = Assembler::locate_operand(pc, Assembler::imm_operand); | |
98 Handle obj = Constant::object(inlineData); | |
99 | |
100 jobject value = JNIHandles::make_local(obj()); | |
101 *((jobject*) operand) = value; | |
102 _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); | |
103 TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand); | |
104 break; | |
105 } | |
106 default: | |
107 fatal(err_msg("unexpected Kind (%d) in DataPatch", typeChar)); | |
108 break; | |
109 } | |
110 } else { | |
111 oop dataRef = CompilationResult_DataPatch::externalData(site); | |
112 jint offset = HotSpotCompiledCode_HotSpotData::offset(dataRef); | |
113 address operand = Assembler::locate_operand(pc, Assembler::disp32_operand); | |
114 address next_instruction = Assembler::locate_next_instruction(pc); | |
115 address dest = _constants->start() + offset; | |
116 | |
117 long disp = dest - next_instruction; | |
118 assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); | |
119 *((jint*) operand) = (jint) disp; | |
120 | |
121 _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); | |
122 TRACE_graal_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, offset); | |
123 } | |
124 } | 105 } |
125 | 106 |
126 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { | 107 inline void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { |
127 if (cb->is_nmethod()) { | 108 if (cb->is_nmethod()) { |
128 nmethod* nm = (nmethod*) cb; | 109 nmethod* nm = (nmethod*) cb; |