summaryrefslogtreecommitdiff
path: root/compiler/optimizing/intrinsic_objects.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2023-11-12 21:10:16 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2023-11-17 11:02:27 +0000
commitcac08ecc868cc9b0b378cf380b1a18185708f4ca (patch)
tree50e2a527acf1f160c02279e16ca46b75ca658a62 /compiler/optimizing/intrinsic_objects.h
parentd36e307dbf3e71f03aab1ccbcfdac35234d4e7a9 (diff)
Put all cached boxed values into boot_image_live_objects.
Test: test.py Change-Id: I16dc434207334aad4768e26704ce20dc98a31f6a
Diffstat (limited to 'compiler/optimizing/intrinsic_objects.h')
-rw-r--r--compiler/optimizing/intrinsic_objects.h58
1 files changed, 46 insertions, 12 deletions
diff --git a/compiler/optimizing/intrinsic_objects.h b/compiler/optimizing/intrinsic_objects.h
index 1cc8f4dbc3..61f4825224 100644
--- a/compiler/optimizing/intrinsic_objects.h
+++ b/compiler/optimizing/intrinsic_objects.h
@@ -21,11 +21,12 @@
#include "base/bit_utils.h"
#include "base/macros.h"
#include "base/mutex.h"
+#include "obj_ptr.h"
+#include "offsets.h"
namespace art HIDDEN {
class ClassLinker;
-template <class MirrorType> class ObjPtr;
class MemberOffset;
class Thread;
@@ -34,6 +35,20 @@ class Object;
template <class T> class ObjectArray;
} // namespace mirror
+#define BOXED_TYPES(V) \
+ V(Byte, -128, 127, DataType::Type::kInt8, 0) \
+ V(Short, -128, 127, DataType::Type::kInt16, kByteCacheLastIndex) \
+ V(Character, 0, 127, DataType::Type::kUint16, kShortCacheLastIndex) \
+ V(Integer, -128, 127, DataType::Type::kInt32, kCharacterCacheLastIndex)
+
+#define DEFINE_BOXED_CONSTANTS(name, low, high, primitive_type, start_index) \
+ static constexpr size_t k ##name ##CacheLastIndex = start_index + (high - low + 1); \
+ static constexpr size_t k ##name ##CacheFirstIndex = start_index;
+ BOXED_TYPES(DEFINE_BOXED_CONSTANTS)
+
+ static constexpr size_t kNumberOfBoxedCaches = kIntegerCacheLastIndex;
+#undef DEFINE_BOXED_CONSTANTS
+
class IntrinsicObjects {
public:
enum class PatchType {
@@ -56,25 +71,44 @@ class IntrinsicObjects {
return IndexField::Decode(intrinsic_data);
}
- // Functions for retrieving data for Integer.valueOf().
- EXPORT static ObjPtr<mirror::ObjectArray<mirror::Object>> LookupIntegerCache()
- REQUIRES_SHARED(Locks::mutator_lock_);
- EXPORT static ObjPtr<mirror::ObjectArray<mirror::Object>> GetIntegerValueOfCache(
- ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects)
- REQUIRES_SHARED(Locks::mutator_lock_);
- EXPORT static ObjPtr<mirror::Object> GetIntegerValueOfObject(
- ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects,
- uint32_t index) REQUIRES_SHARED(Locks::mutator_lock_);
- EXPORT static MemberOffset GetIntegerValueOfArrayDataOffset(
- ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects)
+ // Helpers returning addresses of objects, suitable for embedding in generated code.
+#define DEFINE_BOXED_ACCESSES(name, _, __, ___, start_index) \
+ static ObjPtr<mirror::Object> Get ##name ##ValueOfObject( \
+ ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects, \
+ uint32_t index) REQUIRES_SHARED(Locks::mutator_lock_) { \
+ return GetValueOfObject(boot_image_live_objects, k ##name ##CacheFirstIndex, index); \
+ } \
+ static MemberOffset Get ##name ##ValueOfArrayDataOffset( \
+ ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects) \
+ REQUIRES_SHARED(Locks::mutator_lock_) { \
+ return GetValueOfArrayDataOffset(boot_image_live_objects, k ##name ##CacheFirstIndex); \
+ }
+ BOXED_TYPES(DEFINE_BOXED_ACCESSES)
+#undef DEFINED_BOXED_ACCESSES
+
+ EXPORT static void FillIntrinsicObjects(
+ ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects, size_t start_index)
REQUIRES_SHARED(Locks::mutator_lock_);
+ static size_t GetNumberOfIntrinsicObjects() {
+ return kNumberOfBoxedCaches;
+ }
+
private:
static constexpr size_t kPatchTypeBits =
MinimumBitsToStore(static_cast<uint32_t>(PatchType::kLast));
static constexpr size_t kIndexBits = BitSizeOf<uint32_t>() - kPatchTypeBits;
using PatchTypeField = BitField<uint32_t, 0u, kPatchTypeBits>;
using IndexField = BitField<uint32_t, kPatchTypeBits, kIndexBits>;
+
+ EXPORT static ObjPtr<mirror::Object> GetValueOfObject(
+ ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects,
+ size_t start_index,
+ uint32_t index) REQUIRES_SHARED(Locks::mutator_lock_);
+
+ EXPORT static MemberOffset GetValueOfArrayDataOffset(
+ ObjPtr<mirror::ObjectArray<mirror::Object>> boot_image_live_objects,
+ size_t start_index) REQUIRES_SHARED(Locks::mutator_lock_);
};
} // namespace art