[ptr-compr] Use only Tagged_t part when comparing Object values

... as it uniquely idenifies object inside an Isolate.
This also allows comparisons between full tagged values ([Maybe]Object)
and potentially compressed tagged values ([Strong]TaggedValue).

As a side effect with this change we should generate a bit less code.

Bug: v8:7703
Change-Id: I822df24e03653fa73314e0a6f81f0fa7b5c61eba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643433
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61998}
This commit is contained in:
Igor Sheludko 2019-06-04 18:59:32 +02:00 committed by Commit Bot
parent f2823886ba
commit da31c71b6a
2 changed files with 16 additions and 6 deletions

View File

@ -22,7 +22,9 @@ class Heap;
// objects.
class HeapObject : public Object {
public:
bool is_null() const { return ptr() == kNullAddress; }
bool is_null() const {
return static_cast<Tagged_t>(ptr()) == static_cast<Tagged_t>(kNullAddress);
}
// [map]: Contains a map which contains the object's reflective
// information.

View File

@ -40,16 +40,24 @@ class TaggedImpl {
// Make clang on Linux catch what MSVC complains about on Windows:
operator bool() const = delete;
constexpr bool operator==(TaggedImpl other) const {
return ptr_ == other.ptr_;
template <typename U>
constexpr bool operator==(TaggedImpl<kRefType, U> other) const {
static_assert(
std::is_same<U, Address>::value || std::is_same<U, Tagged_t>::value,
"U must be either Address or Tagged_t");
return static_cast<Tagged_t>(ptr_) == static_cast<Tagged_t>(other.ptr());
}
constexpr bool operator!=(TaggedImpl other) const {
return ptr_ != other.ptr_;
template <typename U>
constexpr bool operator!=(TaggedImpl<kRefType, U> other) const {
static_assert(
std::is_same<U, Address>::value || std::is_same<U, Tagged_t>::value,
"U must be either Address or Tagged_t");
return static_cast<Tagged_t>(ptr_) != static_cast<Tagged_t>(other.ptr());
}
// For using in std::set and std::map.
constexpr bool operator<(TaggedImpl other) const {
return ptr_ < other.ptr();
return static_cast<Tagged_t>(ptr_) < static_cast<Tagged_t>(other.ptr());
}
constexpr StorageType ptr() const { return ptr_; }