From 76c92ac73eeda2582caee39dd427ca035caf172b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 17 Sep 2015 15:39:16 +0100 Subject: [PATCH] Optimizing: Allow storing value objects in containers. Change-Id: Ic9c6b62e36706e571fd71c18d24d8e76ae2d5c7b --- compiler/optimizing/locations.h | 4 ++-- compiler/optimizing/nodes.h | 2 +- runtime/base/macros.h | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/optimizing/locations.h b/compiler/optimizing/locations.h index cc3b35b46..2162ab928 100644 --- a/compiler/optimizing/locations.h +++ b/compiler/optimizing/locations.h @@ -35,7 +35,7 @@ std::ostream& operator<<(std::ostream& os, const Location& location); * A Location is an abstraction over the potential location * of an instruction. It could be in register or stack. */ -class Location { +class Location : public ValueObject { public: enum OutputOverlap { kOutputOverlap, @@ -69,7 +69,7 @@ class Location { kUnallocated = 10, }; - Location() : value_(kInvalid) { + Location() : ValueObject(), value_(kInvalid) { // Verify that non-constant location kinds do not interfere with kConstant. static_assert((kInvalid & kLocationConstantMask) != kConstant, "TagError"); static_assert((kUnallocated & kLocationConstantMask) != kConstant, "TagError"); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 33c0d88f3..8acde40e7 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -1243,7 +1243,7 @@ class HUseIterator : public ValueObject { // instructions they use and pointers to the corresponding HUseListNodes kept // by the used instructions. template -class HUserRecord { +class HUserRecord : public ValueObject { public: HUserRecord() : instruction_(nullptr), use_node_(nullptr) {} explicit HUserRecord(HInstruction* instruction) : instruction_(instruction), use_node_(nullptr) {} diff --git a/runtime/base/macros.h b/runtime/base/macros.h index 1d5dee23f..dc692d2b7 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -68,9 +68,12 @@ template ART_FRIEND_TEST(test_set_name, individual_test) DISALLOW_COPY_AND_ASSIGN(TypeName) // A macro to disallow new and delete operators for a class. It goes in the private: declarations. +// NOTE: Providing placement new (and matching delete) for constructing container elements. #define DISALLOW_ALLOCATION() \ public: \ NO_RETURN ALWAYS_INLINE void operator delete(void*, size_t) { UNREACHABLE(); } \ + ALWAYS_INLINE void* operator new(size_t, void* ptr) noexcept { return ptr; } \ + ALWAYS_INLINE void operator delete(void*, void*) noexcept { } \ private: \ void* operator new(size_t) = delete -- 2.11.0