comparison src/share/vm/graal/graalVMEntries.cpp @ 3638:e53cfcb230a7

Fixed an issue with the runtime queried escape analysis field array.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 16 Nov 2011 01:52:31 +0100
parents ff6a991c6e3c
children a8021a9f2a14
comparison
equal deleted inserted replaced
3637:ff6a991c6e3c 3638:e53cfcb230a7
772 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiType_1fields(JNIEnv *, jobject, jobject klass) { 772 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_RiType_1fields(JNIEnv *, jobject, jobject klass) {
773 TRACE_graal_3("VMEntries::RiType_fields"); 773 TRACE_graal_3("VMEntries::RiType_fields");
774 VM_ENTRY_MARK; 774 VM_ENTRY_MARK;
775 775
776 instanceKlassHandle k = java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass)); 776 instanceKlassHandle k = java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(klass));
777 objArrayHandle field_array = oopFactory::new_objArray(SystemDictionary::RiField_klass(), k->fields()->length() / instanceKlass::next_offset, CHECK_NULL);
778 class MyFieldClosure : public FieldClosure { 777 class MyFieldClosure : public FieldClosure {
779 public: 778 public:
780 instanceKlassHandle _holder; 779 instanceKlassHandle _holder;
781 Handle _resolved_type_holder; 780 Handle _resolved_type_holder;
782 objArrayHandle _field_array; 781 GrowableArray<Handle> _field_array;
783 int _current; 782
784 783 MyFieldClosure(instanceKlassHandle& holder, Handle resolved_type_holder) : _holder(holder), _resolved_type_holder(resolved_type_holder) { }
785 MyFieldClosure(instanceKlassHandle& holder, Handle resolved_type_holder, objArrayHandle field_array) : _holder(holder), _resolved_type_holder(resolved_type_holder), _field_array(field_array), _current(0) { }
786 784
787 virtual void do_field(fieldDescriptor* fd) { 785 virtual void do_field(fieldDescriptor* fd) {
788 if (!Thread::current()->has_pending_exception()) { 786 if (!Thread::current()->has_pending_exception()) {
789 if (fd->field_holder() == _holder()) { 787 if (fd->field_holder() == _holder()) {
790 Handle type = GraalCompiler::get_RiTypeFromSignature(fd->constants(), fd->signature_index(), fd->field_holder(), Thread::current()); 788 Handle type = GraalCompiler::get_RiTypeFromSignature(fd->constants(), fd->signature_index(), fd->field_holder(), Thread::current());
791 Handle field = VMExits::createRiField(_resolved_type_holder, VmIds::toString<Handle>(fd->name(), Thread::current()), type, fd->offset(), fd->access_flags().as_int(), Thread::current()); 789 Handle field = VMExits::createRiField(_resolved_type_holder, VmIds::toString<Handle>(fd->name(), Thread::current()), type, fd->offset(), fd->access_flags().as_int(), Thread::current());
792 _field_array->obj_at_put(_current++, field()); 790 _field_array.append(field());
793 } 791 }
794 } 792 }
795 } 793 }
796 }; 794 };
797 MyFieldClosure closure(k, JNIHandles::resolve(klass), field_array); 795 MyFieldClosure closure(k, JNIHandles::resolve(klass));
798 k->do_nonstatic_fields(&closure); 796 k->do_nonstatic_fields(&closure);
797 objArrayHandle field_array = oopFactory::new_objArray(SystemDictionary::RiField_klass(), closure._field_array.length(), CHECK_NULL);
798 for (int i=0; i<closure._field_array.length(); ++i) {
799 field_array->obj_at_put(i, closure._field_array.at(i)());
800 }
799 return JNIHandles::make_local(field_array()); 801 return JNIHandles::make_local(field_array());
800 } 802 }
801 803
802 // public RiType getPrimitiveArrayType(CiKind kind); 804 // public RiType getPrimitiveArrayType(CiKind kind);
803 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_getPrimitiveArrayType(JNIEnv *env, jobject, jobject kind) { 805 JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_getPrimitiveArrayType(JNIEnv *env, jobject, jobject kind) {