8199781: Don't use naked == for comparing oops

Reviewed-by: coleenp, eosterlund, jrose
This commit is contained in:
Roman Kennke 2018-04-03 13:15:27 +02:00
parent 8b50176bdc
commit b938ae51ce
36 changed files with 1484 additions and 1282 deletions

View file

@ -26,6 +26,7 @@
#define SHARE_VM_UTILITIES_GROWABLEARRAY_HPP
#include "memory/allocation.hpp"
#include "oops/oop.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ostream.hpp"
@ -211,6 +212,15 @@ template<class E> class GrowableArray : public GenericGrowableArray {
void print();
inline static bool safe_equals(oop obj1, oop obj2) {
return oopDesc::equals(obj1, obj2);
}
template <class X>
inline static bool safe_equals(X i1, X i2) {
return i1 == i2;
}
int append(const E& elem) {
check_nesting();
if (_len == _max) grow(_len);
@ -295,7 +305,7 @@ template<class E> class GrowableArray : public GenericGrowableArray {
bool contains(const E& elem) const {
for (int i = 0; i < _len; i++) {
if (_data[i] == elem) return true;
if (safe_equals(_data[i], elem)) return true;
}
return false;
}