97 } 98 99 // When String table needs to rehash 100 unsigned int oopDesc::new_hash(juint seed) { 101 EXCEPTION_MARK; 102 ResourceMark rm; 103 int length; 104 jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD); 105 if (chars != NULL) { 106 // Use alternate hashing algorithm on the string 107 return AltHashing::murmur3_32(seed, chars, length); 108 } else { 109 vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash"); 110 return 0; 111 } 112 } 113 114 // used only for asserts and guarantees 115 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) { 116 if (!Universe::heap()->is_oop(obj)) { 117 assert(obj->klass()->is_value(), "Only value type can be outside of the Java heap"); 118 VTBufferChunk* chunk = VTBufferChunk::chunk(obj); 119 assert(chunk->is_valid(), "if not in the heap, should a buffered VT"); 120 if (!VTBuffer::is_in_vt_buffer(obj)) return false; 121 } 122 123 // Header verification: the mark is typically non-NULL. If we're 124 // at a safepoint, it must not be null. 125 // Outside of a safepoint, the header could be changing (for example, 126 // another thread could be inflating a lock on this object). 127 if (ignore_mark_word) { 128 return true; 129 } 130 if (obj->mark_raw() != NULL) { 131 return true; 132 } 133 return !SafepointSynchronize::is_at_safepoint() 134 || (obj->klass()->is_value() && VTBuffer::is_in_vt_buffer(obj)) ; 135 } 136 137 // used only for asserts and guarantees 138 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) { 139 return obj == NULL ? true : is_oop(obj, ignore_mark_word); 140 } 141 142 #ifndef PRODUCT 143 // used only for asserts 144 bool oopDesc::is_unlocked_oop() const { 145 if (!Universe::heap()->is_in_reserved(this)) return false; 146 return mark()->is_unlocked(); 147 } 148 #endif // PRODUCT 149 150 VerifyOopClosure VerifyOopClosure::verify_oop; 151 152 template <class T> void VerifyOopClosure::do_oop_work(T* p) { 153 oop obj = RawAccess<>::oop_load(p); 154 guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj)); | 97 } 98 99 // When String table needs to rehash 100 unsigned int oopDesc::new_hash(juint seed) { 101 EXCEPTION_MARK; 102 ResourceMark rm; 103 int length; 104 jchar* chars = java_lang_String::as_unicode_string(this, length, THREAD); 105 if (chars != NULL) { 106 // Use alternate hashing algorithm on the string 107 return AltHashing::murmur3_32(seed, chars, length); 108 } else { 109 vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash"); 110 return 0; 111 } 112 } 113 114 // used only for asserts and guarantees 115 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) { 116 if (!Universe::heap()->is_oop(obj)) { 117 return false; 118 } 119 120 // Header verification: the mark is typically non-NULL. If we're 121 // at a safepoint, it must not be null. 122 // Outside of a safepoint, the header could be changing (for example, 123 // another thread could be inflating a lock on this object). 124 if (ignore_mark_word) { 125 return true; 126 } 127 if (obj->mark_raw() != NULL) { 128 return true; 129 } 130 return !SafepointSynchronize::is_at_safepoint() ; 131 } 132 133 // used only for asserts and guarantees 134 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) { 135 return obj == NULL ? true : is_oop(obj, ignore_mark_word); 136 } 137 138 #ifndef PRODUCT 139 // used only for asserts 140 bool oopDesc::is_unlocked_oop() const { 141 if (!Universe::heap()->is_in_reserved(this)) return false; 142 return mark()->is_unlocked(); 143 } 144 #endif // PRODUCT 145 146 VerifyOopClosure VerifyOopClosure::verify_oop; 147 148 template <class T> void VerifyOopClosure::do_oop_work(T* p) { 149 oop obj = RawAccess<>::oop_load(p); 150 guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj)); |