Mercurial > hg > graal-jvmci-8
comparison src/share/vm/jvmci/jvmciCodeInstaller.cpp @ 22590:3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 21 Sep 2015 15:01:13 +0200 |
parents | 6821ef65ef4c |
children | 5fade64c1b5f |
comparison
equal
deleted
inserted
replaced
22589:ca8e46278bae | 22590:3f6488b29c1a |
---|---|
138 } | 138 } |
139 } | 139 } |
140 return map; | 140 return map; |
141 } | 141 } |
142 | 142 |
143 static void record_metadata_reference(oop obj, jlong prim, jboolean compressed, OopRecorder* oop_recorder) { | 143 Metadata* CodeInstaller::record_metadata_reference(Handle& constant) { |
144 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); | |
144 if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { | 145 if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { |
145 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); | 146 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); |
146 if (compressed) { | 147 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), err_msg("unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass))); |
147 assert(Klass::decode_klass((narrowKlass) prim) == klass, err_msg("%s @ " INTPTR_FORMAT " != " PTR64_FORMAT, klass->name()->as_C_string(), p2i(klass), prim)); | 148 int index = _oop_recorder->find_index(klass); |
148 } else { | 149 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
149 assert((Klass*) prim == klass, err_msg("%s @ " INTPTR_FORMAT " != " PTR64_FORMAT, klass->name()->as_C_string(), p2i(klass), prim)); | 150 return klass; |
150 } | |
151 int index = oop_recorder->find_index(klass); | |
152 TRACE_jvmci_3("metadata[%d of %d] = %s", index, oop_recorder->metadata_count(), klass->name()->as_C_string()); | |
153 } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { | 151 } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { |
154 Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); | 152 Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); |
155 assert(!compressed, err_msg("unexpected compressed method pointer %s @ " INTPTR_FORMAT " = " PTR64_FORMAT, method->name()->as_C_string(), p2i(method), prim)); | 153 assert(!HotSpotMetaspaceConstantImpl::compressed(constant), err_msg("unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method))); |
156 int index = oop_recorder->find_index(method); | 154 int index = _oop_recorder->find_index(method); |
157 TRACE_jvmci_3("metadata[%d of %d] = %s", index, oop_recorder->metadata_count(), method->name()->as_C_string()); | 155 TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); |
156 return method; | |
158 } else { | 157 } else { |
159 assert(java_lang_String::is_instance(obj), | 158 fatal(err_msg("unexpected metadata reference for constant of type %s", obj->klass()->name()->as_C_string())); |
160 err_msg("unexpected metadata reference (%s) for constant " JLONG_FORMAT " (" PTR64_FORMAT ")", obj->klass()->name()->as_C_string(), prim, prim)); | 159 } |
161 } | 160 } |
162 } | 161 |
163 | 162 #ifdef _LP64 |
164 // Records any Metadata values embedded in a Constant (e.g., the value returned by HotSpotResolvedObjectTypeImpl.klass()). | 163 narrowKlass CodeInstaller::record_narrow_metadata_reference(Handle& constant) { |
165 static void record_metadata_in_constant(oop constant, OopRecorder* oop_recorder) { | 164 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); |
166 if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { | 165 assert(HotSpotMetaspaceConstantImpl::compressed(constant), err_msg("unexpected uncompressed pointer")); |
167 oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); | 166 assert(obj->is_a(HotSpotResolvedObjectTypeImpl::klass()), err_msg("unexpected compressed pointer of type %s", obj->klass()->name()->as_C_string())); |
168 jlong raw = HotSpotMetaspaceConstantImpl::rawValue(constant); | 167 |
169 assert(obj != NULL, "must have an object"); | 168 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); |
170 assert(raw != 0, "must have a raw value"); | 169 int index = _oop_recorder->find_index(klass); |
171 | 170 TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
172 record_metadata_reference(obj, raw, false, oop_recorder); | 171 return Klass::encode_klass(klass); |
173 } | 172 } |
174 } | 173 #endif |
175 | |
176 static void record_metadata_in_patch(Handle& constant, OopRecorder* oop_recorder) { | |
177 record_metadata_reference(HotSpotMetaspaceConstantImpl::metaspaceObject(constant), HotSpotMetaspaceConstantImpl::rawValue(constant), HotSpotMetaspaceConstantImpl::compressed(constant), oop_recorder); | |
178 } | |
179 | 174 |
180 Location::Type CodeInstaller::get_oop_type(oop value) { | 175 Location::Type CodeInstaller::get_oop_type(oop value) { |
181 oop lirKind = Value::lirKind(value); | 176 oop lirKind = Value::lirKind(value); |
182 oop platformKind = LIRKind::platformKind(lirKind); | 177 oop platformKind = LIRKind::platformKind(lirKind); |
183 assert(LIRKind::referenceMask(lirKind) == 1, "unexpected referenceMask"); | 178 assert(LIRKind::referenceMask(lirKind) == 1, "unexpected referenceMask"); |
249 if (type == T_DOUBLE || type == T_LONG) { | 244 if (type == T_DOUBLE || type == T_LONG) { |
250 second = value; | 245 second = value; |
251 } | 246 } |
252 return value; | 247 return value; |
253 } else if (value->is_a(JavaConstant::klass())) { | 248 } else if (value->is_a(JavaConstant::klass())) { |
254 record_metadata_in_constant(value, _oop_recorder); | |
255 if (value->is_a(PrimitiveConstant::klass())) { | 249 if (value->is_a(PrimitiveConstant::klass())) { |
256 if (value->is_a(RawConstant::klass())) { | 250 if (value->is_a(RawConstant::klass())) { |
257 jlong prim = PrimitiveConstant::primitive(value); | 251 jlong prim = PrimitiveConstant::primitive(value); |
258 return new ConstantLongValue(prim); | 252 return new ConstantLongValue(prim); |
259 } else { | 253 } else { |
543 for (int i = 0; i < data_section_patches()->length(); i++) { | 537 for (int i = 0; i < data_section_patches()->length(); i++) { |
544 Handle patch = data_section_patches()->obj_at(i); | 538 Handle patch = data_section_patches()->obj_at(i); |
545 Handle reference = CompilationResult_DataPatch::reference(patch); | 539 Handle reference = CompilationResult_DataPatch::reference(patch); |
546 assert(reference->is_a(CompilationResult_ConstantReference::klass()), err_msg("patch in data section must be a ConstantReference")); | 540 assert(reference->is_a(CompilationResult_ConstantReference::klass()), err_msg("patch in data section must be a ConstantReference")); |
547 Handle constant = CompilationResult_ConstantReference::constant(reference); | 541 Handle constant = CompilationResult_ConstantReference::constant(reference); |
542 address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); | |
548 if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { | 543 if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
549 record_metadata_in_patch(constant, _oop_recorder); | 544 if (HotSpotMetaspaceConstantImpl::compressed(constant)) { |
545 #ifdef _LP64 | |
546 *((narrowKlass*) dest) = record_narrow_metadata_reference(constant); | |
547 #else | |
548 fatal("unexpected compressed Klass* in 32-bit mode"); | |
549 #endif | |
550 } else { | |
551 *((Metadata**) dest) = record_metadata_reference(constant); | |
552 } | |
550 } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { | 553 } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
551 Handle obj = HotSpotObjectConstantImpl::object(constant); | 554 Handle obj = HotSpotObjectConstantImpl::object(constant); |
552 jobject value = JNIHandles::make_local(obj()); | 555 jobject value = JNIHandles::make_local(obj()); |
553 int oop_index = _oop_recorder->find_index(value); | 556 int oop_index = _oop_recorder->find_index(value); |
554 | 557 |
555 address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); | |
556 if (HotSpotObjectConstantImpl::compressed(constant)) { | 558 if (HotSpotObjectConstantImpl::compressed(constant)) { |
557 #ifdef _LP64 | 559 #ifdef _LP64 |
558 _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); | 560 _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); |
559 #else | 561 #else |
560 fatal("unexpected compressed oop in 32-bit mode"); | 562 fatal("unexpected compressed oop in 32-bit mode"); |
897 if (reference->is_a(CompilationResult_ConstantReference::klass())) { | 899 if (reference->is_a(CompilationResult_ConstantReference::klass())) { |
898 Handle constant = CompilationResult_ConstantReference::constant(reference); | 900 Handle constant = CompilationResult_ConstantReference::constant(reference); |
899 if (constant->is_a(HotSpotObjectConstantImpl::klass())) { | 901 if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
900 pd_patch_OopConstant(pc_offset, constant); | 902 pd_patch_OopConstant(pc_offset, constant); |
901 } else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { | 903 } else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
902 record_metadata_in_patch(constant, _oop_recorder); | 904 pd_patch_MetaspaceConstant(pc_offset, constant); |
903 } else { | 905 } else { |
904 fatal("unknown constant type in data patch"); | 906 fatal("unknown constant type in data patch"); |
905 } | 907 } |
906 } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) { | 908 } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) { |
907 int data_offset = CompilationResult_DataSectionReference::offset(reference); | 909 int data_offset = CompilationResult_DataSectionReference::offset(reference); |