Mercurial > hg > truffle
comparison src/share/vm/oops/constantPool.cpp @ 12285:7c29904fdfa2
8014956: nashorn/api/javaaccess/MethodAccessTest.java test fails on sparc-solaris 64
Summary: reference_map[] array had uninitialized junk that was causing a bogus bootstrap method to be found.
Reviewed-by: hseigel, dcubed, sspitsyn
author | coleenp |
---|---|
date | Fri, 20 Sep 2013 18:34:00 -0400 |
parents | e0c9a1d29eb4 |
children | a7609ec351d6 |
comparison
equal
deleted
inserted
replaced
12282:f201713502e0 | 12285:7c29904fdfa2 |
---|---|
106 // to map it back for resolving and some unlikely miscellaneous uses. | 106 // to map it back for resolving and some unlikely miscellaneous uses. |
107 // The objects created by invokedynamic are appended to this list. | 107 // The objects created by invokedynamic are appended to this list. |
108 void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data, | 108 void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data, |
109 intStack reference_map, | 109 intStack reference_map, |
110 int constant_pool_map_length, | 110 int constant_pool_map_length, |
111 TRAPS) { | 111 TRAPS) { |
112 // Initialized the resolved object cache. | 112 // Initialized the resolved object cache. |
113 int map_length = reference_map.length(); | 113 int map_length = reference_map.length(); |
114 if (map_length > 0) { | 114 if (map_length > 0) { |
115 // Only need mapping back to constant pool entries. The map isn't used for | 115 // Only need mapping back to constant pool entries. The map isn't used for |
116 // invokedynamic resolved_reference entries. The constant pool cache index | 116 // invokedynamic resolved_reference entries. For invokedynamic entries, |
117 // has the mapping back to both the constant pool and to the resolved | 117 // the constant pool cache index has the mapping back to both the constant |
118 // reference index. | 118 // pool and to the resolved reference index. |
119 if (constant_pool_map_length > 0) { | 119 if (constant_pool_map_length > 0) { |
120 Array<u2>* om = MetadataFactory::new_array<u2>(loader_data, map_length, CHECK); | 120 Array<u2>* om = MetadataFactory::new_array<u2>(loader_data, constant_pool_map_length, CHECK); |
121 | 121 |
122 for (int i = 0; i < constant_pool_map_length; i++) { | 122 for (int i = 0; i < constant_pool_map_length; i++) { |
123 int x = reference_map.at(i); | 123 int x = reference_map.at(i); |
124 assert(x == (int)(jushort) x, "klass index is too big"); | 124 assert(x == (int)(jushort) x, "klass index is too big"); |
125 om->at_put(i, (jushort)x); | 125 om->at_put(i, (jushort)x); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 int ConstantPool::cp_to_object_index(int cp_index) { | 183 int ConstantPool::cp_to_object_index(int cp_index) { |
184 // this is harder don't do this so much. | 184 // this is harder don't do this so much. |
185 for (int i = 0; i< reference_map()->length(); i++) { | 185 int i = reference_map()->find(cp_index); |
186 if (reference_map()->at(i) == cp_index) return i; | 186 // We might not find the index for jsr292 call. |
187 // Zero entry is divider between constant pool indices for strings, | 187 return (i < 0) ? _no_index_sentinel : i; |
188 // method handles and method types. After that the index is a constant | |
189 // pool cache index for invokedynamic. Stop when zero (which can never | |
190 // be a constant pool index) | |
191 if (reference_map()->at(i) == 0) break; | |
192 } | |
193 // We might not find the index. | |
194 return _no_index_sentinel; | |
195 } | 188 } |
196 | 189 |
197 Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) { | 190 Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) { |
198 // A resolved constantPool entry will contain a Klass*, otherwise a Symbol*. | 191 // A resolved constantPool entry will contain a Klass*, otherwise a Symbol*. |
199 // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and | 192 // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and |
864 | 857 |
865 oop ConstantPool::string_at_impl(constantPoolHandle this_oop, int which, int obj_index, TRAPS) { | 858 oop ConstantPool::string_at_impl(constantPoolHandle this_oop, int which, int obj_index, TRAPS) { |
866 // If the string has already been interned, this entry will be non-null | 859 // If the string has already been interned, this entry will be non-null |
867 oop str = this_oop->resolved_references()->obj_at(obj_index); | 860 oop str = this_oop->resolved_references()->obj_at(obj_index); |
868 if (str != NULL) return str; | 861 if (str != NULL) return str; |
869 | 862 Symbol* sym = this_oop->unresolved_string_at(which); |
870 Symbol* sym = this_oop->unresolved_string_at(which); | |
871 str = StringTable::intern(sym, CHECK_(NULL)); | 863 str = StringTable::intern(sym, CHECK_(NULL)); |
872 this_oop->string_at_put(which, obj_index, str); | 864 this_oop->string_at_put(which, obj_index, str); |
873 assert(java_lang_String::is_instance(str), "must be string"); | 865 assert(java_lang_String::is_instance(str), "must be string"); |
874 return str; | 866 return str; |
875 } | 867 } |