Răsfoiți Sursa

Add a pool dedicated to 8-byte values (`double`/`int64_t`/`uint64_t`)

This new pool replaced the "extension" slot where a secondary variant slot was used to store 8-byte values.
Benoit Blanchon 4 luni în urmă
părinte
comite
db2eec46c7

+ 1 - 0
CHANGELOG.md

@@ -7,6 +7,7 @@ HEAD
 * Don't store string literals by pointer anymore (issue #2189)
   Version 7.3 introduced a new way to detect string literals, but it fails in some edge cases.
   I could not find a way to fix it, so I chose to remove the optimization rather than keep it broken.
+* Replace the "extension slots" mechanism with a memory pool dedicated to 8-byte values.
 
 > ### BREAKING CHANGES
 >

+ 1 - 1
extras/conf_test/avr.cpp

@@ -12,7 +12,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
 
 static_assert(ARDUINOJSON_USE_DOUBLE == 0, "ARDUINOJSON_USE_DOUBLE");
 
-static_assert(ArduinoJson::detail::ResourceManager::slotSize == 6, "slot size");
+static_assert(sizeof(ArduinoJson::detail::VariantData) == 6, "slot size");
 
 void setup() {}
 void loop() {}

+ 1 - 1
extras/conf_test/esp8266.cpp

@@ -10,7 +10,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
 
 static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
 
-static_assert(ArduinoJson::detail::ResourceManager::slotSize == 8, "slot size");
+static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size");
 
 void setup() {}
 void loop() {}

+ 1 - 2
extras/conf_test/x64.cpp

@@ -10,7 +10,6 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
 
 static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
 
-static_assert(ArduinoJson::detail::ResourceManager::slotSize == 16,
-              "slot size");
+static_assert(sizeof(ArduinoJson::detail::VariantData) == 16, "slot size");
 
 int main() {}

+ 1 - 1
extras/conf_test/x86.cpp

@@ -10,6 +10,6 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN");
 
 static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE");
 
-static_assert(ArduinoJson::detail::ResourceManager::slotSize == 8, "slot size");
+static_assert(sizeof(ArduinoJson::detail::VariantData) == 8, "slot size");
 
 int main() {}

+ 2 - 2
extras/tests/Helpers/Allocators.hpp

@@ -269,10 +269,10 @@ inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) {
   return sizeof(MemoryPool<VariantData>) * n;
 }
 
+template <typename T = ArduinoJson::detail::VariantData>
 inline size_t sizeofPool(
     ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
-  using namespace ArduinoJson::detail;
-  return MemoryPool<VariantData>::slotsToBytes(n);
+  return ArduinoJson::detail::MemoryPool<T>::slotsToBytes(n);
 }
 
 inline size_t sizeofStringBuffer(size_t iteration = 1) {

+ 3 - 2
extras/tests/JsonArray/add.cpp

@@ -8,7 +8,7 @@
 #include "Allocators.hpp"
 #include "Literals.hpp"
 
-using ArduinoJson::detail::sizeofArray;
+using namespace ArduinoJson::detail;
 
 TEST_CASE("JsonArray::add(T)") {
   SpyingAllocator spy;
@@ -33,7 +33,8 @@ TEST_CASE("JsonArray::add(T)") {
     REQUIRE(array[0].is<double>());
     REQUIRE_FALSE(array[0].is<bool>());
     REQUIRE(spy.log() == AllocatorLog{
-                             Allocate(sizeofPool()),
+                             Allocate(sizeofPool<VariantData>()),
+                             Allocate(sizeofPool<EightByteValue>()),
                          });
   }
 

+ 7 - 3
extras/tests/JsonDeserializer/array.cpp

@@ -7,7 +7,7 @@
 
 #include "Allocators.hpp"
 
-using ArduinoJson::detail::sizeofArray;
+using namespace ArduinoJson::detail;
 
 TEST_CASE("deserialize JSON array") {
   SpyingAllocator spy;
@@ -92,8 +92,12 @@ TEST_CASE("deserialize JSON array") {
       REQUIRE(arr[0].as<double>() == Approx(4.2123456));
       REQUIRE(arr[1] == -7E89);
       REQUIRE(spy.log() == AllocatorLog{
-                               Allocate(sizeofPool()),
-                               Reallocate(sizeofPool(), sizeofPool(4)),
+                               Allocate(sizeofPool<VariantData>()),
+                               Allocate(sizeofPool<EightByteValue>()),
+                               Reallocate(sizeofPool<VariantData>(),
+                                          sizeofPool<VariantData>(2)),
+                               Reallocate(sizeofPool<EightByteValue>(),
+                                          sizeofPool<EightByteValue>(2)),
                            });
     }
 

+ 1 - 1
extras/tests/JsonDeserializer/errors.cpp

@@ -121,7 +121,7 @@ TEST_CASE("deserializeJson() returns NoMemory if string length overflows") {
   }
 }
 
-TEST_CASE("deserializeJson() returns NoMemory if extension allocation fails") {
+TEST_CASE("deserializeJson() returns NoMemory if 8-bit slot allocation fails") {
   JsonDocument doc(FailingAllocator::instance());
 
   SECTION("uint32_t should pass") {

+ 18 - 19
extras/tests/JsonVariant/set.cpp

@@ -8,8 +8,7 @@
 #include "Allocators.hpp"
 #include "Literals.hpp"
 
-using ArduinoJson::detail::sizeofObject;
-using ArduinoJson::detail::sizeofString;
+using namespace ArduinoJson::detail;
 
 enum ErrorCode { ERROR_01 = 1, ERROR_10 = 10 };
 
@@ -183,11 +182,11 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
     REQUIRE(result == true);
     REQUIRE(variant.is<double>() == true);
     REQUIRE(variant.as<double>() == 1.2);
-    REQUIRE(spy.log() ==
-            AllocatorLog{
-                Allocate(sizeofPool()),
-                Reallocate(sizeofPool(), sizeofPool(1)),  // one extension slot
-            });
+    REQUIRE(spy.log() == AllocatorLog{
+                             Allocate(sizeofPool<EightByteValue>()),
+                             Reallocate(sizeofPool<EightByteValue>(),
+                                        sizeofPool<EightByteValue>(1)),
+                         });
   }
 
   SECTION("int32_t") {
@@ -206,11 +205,11 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
     REQUIRE(result == true);
     REQUIRE(variant.is<int64_t>() == true);
     REQUIRE(variant.as<int64_t>() == -2147483649LL);
-    REQUIRE(spy.log() ==
-            AllocatorLog{
-                Allocate(sizeofPool()),
-                Reallocate(sizeofPool(), sizeofPool(1)),  // one extension slot
-            });
+    REQUIRE(spy.log() == AllocatorLog{
+                             Allocate(sizeofPool<EightByteValue>()),
+                             Reallocate(sizeofPool<EightByteValue>(),
+                                        sizeofPool<EightByteValue>(1)),
+                         });
   }
 
   SECTION("uint32_t") {
@@ -229,11 +228,11 @@ TEST_CASE("JsonVariant::set() when there is enough memory") {
     REQUIRE(result == true);
     REQUIRE(variant.is<uint64_t>() == true);
     REQUIRE(variant.as<uint64_t>() == 4294967296);
-    REQUIRE(spy.log() ==
-            AllocatorLog{
-                Allocate(sizeofPool()),
-                Reallocate(sizeofPool(), sizeofPool(1)),  // one extension slot
-            });
+    REQUIRE(spy.log() == AllocatorLog{
+                             Allocate(sizeofPool<EightByteValue>()),
+                             Reallocate(sizeofPool<EightByteValue>(),
+                                        sizeofPool<EightByteValue>(1)),
+                         });
   }
 
   SECTION("JsonDocument") {
@@ -350,7 +349,7 @@ TEST_CASE("JsonVariant::set() releases the previous value") {
   }
 
   SECTION("float") {
-    v.set(1.2);
+    v.set(1.2f);
     REQUIRE(spy.log() == AllocatorLog{
                              Deallocate(sizeofString("world")),
                          });
@@ -365,7 +364,7 @@ TEST_CASE("JsonVariant::set() releases the previous value") {
   }
 }
 
-TEST_CASE("JsonVariant::set() reuses extension slot") {
+TEST_CASE("JsonVariant::set() reuses 8-bit slot") {
   SpyingAllocator spy;
   JsonDocument doc(&spy);
   JsonVariant variant = doc.to<JsonVariant>();

+ 1 - 1
src/ArduinoJson/Array/ArrayImpl.hpp

@@ -73,7 +73,7 @@ inline bool ArrayData::addValue(const T& value, ResourceManager* resources) {
 
 // Returns the size (in bytes) of an array with n elements.
 constexpr size_t sizeofArray(size_t n) {
-  return n * ResourceManager::slotSize;
+  return n * sizeof(VariantData);
 }
 
 ARDUINOJSON_END_PRIVATE_NAMESPACE

+ 2 - 2
src/ArduinoJson/Configuration.hpp

@@ -274,9 +274,9 @@
 #endif
 
 #if ARDUINOJSON_USE_LONG_LONG || ARDUINOJSON_USE_DOUBLE
-#  define ARDUINOJSON_USE_EXTENSIONS 1
+#  define ARDUINOJSON_USE_8_BYTE_POOL 1
 #else
-#  define ARDUINOJSON_USE_EXTENSIONS 0
+#  define ARDUINOJSON_USE_8_BYTE_POOL 0
 #endif
 
 #if defined(nullptr)

+ 20 - 14
src/ArduinoJson/Memory/ResourceManager.hpp

@@ -18,22 +18,16 @@ class VariantData;
 class VariantWithId;
 
 class ResourceManager {
-  union SlotData {
-    VariantData variant;
-#if ARDUINOJSON_USE_EXTENSIONS
-    VariantExtension extension;
-#endif
-  };
-
  public:
-  constexpr static size_t slotSize = sizeof(SlotData);
-
   ResourceManager(Allocator* allocator = DefaultAllocator::instance())
       : allocator_(allocator), overflowed_(false) {}
 
   ~ResourceManager() {
     stringPool_.clear(allocator_);
     variantPools_.clear(allocator_);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    eightBytePools_.clear(allocator_);
+#endif
   }
 
   ResourceManager(const ResourceManager&) = delete;
@@ -42,6 +36,9 @@ class ResourceManager {
   friend void swap(ResourceManager& a, ResourceManager& b) {
     swap(a.stringPool_, b.stringPool_);
     swap(a.variantPools_, b.variantPools_);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    swap(a.eightBytePools_, b.eightBytePools_);
+#endif
     swap_(a.allocator_, b.allocator_);
     swap_(a.overflowed_, b.overflowed_);
   }
@@ -62,10 +59,10 @@ class ResourceManager {
   void freeVariant(Slot<VariantData> slot);
   VariantData* getVariant(SlotId id) const;
 
-#if ARDUINOJSON_USE_EXTENSIONS
-  Slot<VariantExtension> allocExtension();
-  void freeExtension(SlotId slot);
-  VariantExtension* getExtension(SlotId id) const;
+#if ARDUINOJSON_USE_8_BYTE_POOL
+  Slot<EightByteValue> allocEightByte();
+  void freeEightByte(SlotId slot);
+  EightByteValue* getEightByte(SlotId id) const;
 #endif
 
   template <typename TAdaptedString>
@@ -115,17 +112,26 @@ class ResourceManager {
     variantPools_.clear(allocator_);
     overflowed_ = false;
     stringPool_.clear(allocator_);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    eightBytePools_.clear(allocator_);
+#endif
   }
 
   void shrinkToFit() {
     variantPools_.shrinkToFit(allocator_);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    eightBytePools_.shrinkToFit(allocator_);
+#endif
   }
 
  private:
   Allocator* allocator_;
   bool overflowed_;
   StringPool stringPool_;
-  MemoryPoolList<SlotData> variantPools_;
+  MemoryPoolList<VariantData> variantPools_;
+#if ARDUINOJSON_USE_8_BYTE_POOL
+  MemoryPoolList<EightByteValue> eightBytePools_;
+#endif
 };
 
 ARDUINOJSON_END_PRIVATE_NAMESPACE

+ 17 - 16
src/ArduinoJson/Memory/ResourceManagerImpl.hpp

@@ -12,40 +12,41 @@
 ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
 
 inline Slot<VariantData> ResourceManager::allocVariant() {
-  auto p = variantPools_.allocSlot(allocator_);
-  if (!p) {
+  auto slot = variantPools_.allocSlot(allocator_);
+  if (!slot) {
     overflowed_ = true;
     return {};
   }
-  return {new (&p->variant) VariantData, p.id()};
+  new (slot.ptr()) VariantData();
+  return slot;
 }
 
-inline void ResourceManager::freeVariant(Slot<VariantData> variant) {
-  variant->clear(this);
-  variantPools_.freeSlot({alias_cast<SlotData*>(variant.ptr()), variant.id()});
+inline void ResourceManager::freeVariant(Slot<VariantData> slot) {
+  slot->clear(this);
+  variantPools_.freeSlot(slot);
 }
 
 inline VariantData* ResourceManager::getVariant(SlotId id) const {
   return reinterpret_cast<VariantData*>(variantPools_.getSlot(id));
 }
 
-#if ARDUINOJSON_USE_EXTENSIONS
-inline Slot<VariantExtension> ResourceManager::allocExtension() {
-  auto p = variantPools_.allocSlot(allocator_);
-  if (!p) {
+#if ARDUINOJSON_USE_8_BYTE_POOL
+inline Slot<EightByteValue> ResourceManager::allocEightByte() {
+  auto slot = eightBytePools_.allocSlot(allocator_);
+  if (!slot) {
     overflowed_ = true;
     return {};
   }
-  return {&p->extension, p.id()};
+  return slot;
 }
 
-inline void ResourceManager::freeExtension(SlotId id) {
-  auto p = getExtension(id);
-  variantPools_.freeSlot({reinterpret_cast<SlotData*>(p), id});
+inline void ResourceManager::freeEightByte(SlotId id) {
+  auto p = getEightByte(id);
+  eightBytePools_.freeSlot({p, id});
 }
 
-inline VariantExtension* ResourceManager::getExtension(SlotId id) const {
-  return &variantPools_.getSlot(id)->extension;
+inline EightByteValue* ResourceManager::getEightByte(SlotId id) const {
+  return eightBytePools_.getSlot(id);
 }
 #endif
 

+ 1 - 1
src/ArduinoJson/Object/ObjectImpl.hpp

@@ -86,7 +86,7 @@ inline VariantData* ObjectData::addPair(VariantData** value,
 
 // Returns the size (in bytes) of an object with n members.
 constexpr size_t sizeofObject(size_t n) {
-  return 2 * n * ResourceManager::slotSize;
+  return 2 * n * sizeof(VariantData);
 }
 
 ARDUINOJSON_END_PRIVATE_NAMESPACE

+ 8 - 5
src/ArduinoJson/Variant/VariantContent.hpp

@@ -16,8 +16,8 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
 enum class VariantTypeBits : uint8_t {
   OwnedStringBit = 0x01,  // 0000 0001
   NumberBit = 0x08,       // 0000 1000
-#if ARDUINOJSON_USE_EXTENSIONS
-  ExtensionBit = 0x10,  // 0001 0000
+#if ARDUINOJSON_USE_8_BYTE_POOL
+  EightByteBit = 0x10,  // 0001 0000
 #endif
   CollectionMask = 0x60,
 };
@@ -55,7 +55,7 @@ union VariantContent {
   bool asBoolean;
   uint32_t asUint32;
   int32_t asInt32;
-#if ARDUINOJSON_USE_EXTENSIONS
+#if ARDUINOJSON_USE_8_BYTE_POOL
   SlotId asSlotId;
 #endif
   ArrayData asArray;
@@ -65,8 +65,8 @@ union VariantContent {
   char asTinyString[tinyStringMaxLength + 1];
 };
 
-#if ARDUINOJSON_USE_EXTENSIONS
-union VariantExtension {
+#if ARDUINOJSON_USE_8_BYTE_POOL
+union EightByteValue {
 #  if ARDUINOJSON_USE_LONG_LONG
   uint64_t asUint64;
   int64_t asInt64;
@@ -75,6 +75,9 @@ union VariantExtension {
   double asDouble;
 #  endif
 };
+
+static_assert(sizeof(EightByteValue) == 8,
+              "sizeof(EightByteValue) must be 8 bytes");
 #endif
 
 ARDUINOJSON_END_PRIVATE_NAMESPACE

+ 24 - 24
src/ArduinoJson/Variant/VariantData.hpp

@@ -53,8 +53,8 @@ class VariantData {
   template <typename TVisitor>
   typename TVisitor::result_type accept(
       TVisitor& visit, const ResourceManager* resources) const {
-#if ARDUINOJSON_USE_EXTENSIONS
-    auto extension = getExtension(resources);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    auto eightByteValue = getEightByte(resources);
 #else
     (void)resources;  // silence warning
 #endif
@@ -64,7 +64,7 @@ class VariantData {
 
 #if ARDUINOJSON_USE_DOUBLE
       case VariantType::Double:
-        return visit.visit(extension->asDouble);
+        return visit.visit(eightByteValue->asDouble);
 #endif
 
       case VariantType::Array:
@@ -92,10 +92,10 @@ class VariantData {
 
 #if ARDUINOJSON_USE_LONG_LONG
       case VariantType::Int64:
-        return visit.visit(extension->asInt64);
+        return visit.visit(eightByteValue->asInt64);
 
       case VariantType::Uint64:
-        return visit.visit(extension->asUint64);
+        return visit.visit(eightByteValue->asUint64);
 #endif
 
       case VariantType::Boolean:
@@ -142,8 +142,8 @@ class VariantData {
   }
 
   bool asBoolean(const ResourceManager* resources) const {
-#if ARDUINOJSON_USE_EXTENSIONS
-    auto extension = getExtension(resources);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    auto eightByteValue = getEightByte(resources);
 #else
     (void)resources;  // silence warning
 #endif
@@ -157,14 +157,14 @@ class VariantData {
         return content_.asFloat != 0;
 #if ARDUINOJSON_USE_DOUBLE
       case VariantType::Double:
-        return extension->asDouble != 0;
+        return eightByteValue->asDouble != 0;
 #endif
       case VariantType::Null:
         return false;
 #if ARDUINOJSON_USE_LONG_LONG
       case VariantType::Uint64:
       case VariantType::Int64:
-        return extension->asUint64 != 0;
+        return eightByteValue->asUint64 != 0;
 #endif
       default:
         return true;
@@ -190,8 +190,8 @@ class VariantData {
   template <typename T>
   T asFloat(const ResourceManager* resources) const {
     static_assert(is_floating_point<T>::value, "T must be a floating point");
-#if ARDUINOJSON_USE_EXTENSIONS
-    auto extension = getExtension(resources);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    auto eightByteValue = getEightByte(resources);
 #else
     (void)resources;  // silence warning
 #endif
@@ -205,9 +205,9 @@ class VariantData {
         return static_cast<T>(content_.asInt32);
 #if ARDUINOJSON_USE_LONG_LONG
       case VariantType::Uint64:
-        return static_cast<T>(extension->asUint64);
+        return static_cast<T>(eightByteValue->asUint64);
       case VariantType::Int64:
-        return static_cast<T>(extension->asInt64);
+        return static_cast<T>(eightByteValue->asInt64);
 #endif
       case VariantType::TinyString:
         str = content_.asTinyString;
@@ -219,7 +219,7 @@ class VariantData {
         return static_cast<T>(content_.asFloat);
 #if ARDUINOJSON_USE_DOUBLE
       case VariantType::Double:
-        return static_cast<T>(extension->asDouble);
+        return static_cast<T>(eightByteValue->asDouble);
 #endif
       default:
         return 0.0;
@@ -232,8 +232,8 @@ class VariantData {
   template <typename T>
   T asIntegral(const ResourceManager* resources) const {
     static_assert(is_integral<T>::value, "T must be an integral type");
-#if ARDUINOJSON_USE_EXTENSIONS
-    auto extension = getExtension(resources);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+    auto eightByteValue = getEightByte(resources);
 #else
     (void)resources;  // silence warning
 #endif
@@ -247,9 +247,9 @@ class VariantData {
         return convertNumber<T>(content_.asInt32);
 #if ARDUINOJSON_USE_LONG_LONG
       case VariantType::Uint64:
-        return convertNumber<T>(extension->asUint64);
+        return convertNumber<T>(eightByteValue->asUint64);
       case VariantType::Int64:
-        return convertNumber<T>(extension->asInt64);
+        return convertNumber<T>(eightByteValue->asInt64);
 #endif
       case VariantType::TinyString:
         str = content_.asTinyString;
@@ -261,7 +261,7 @@ class VariantData {
         return convertNumber<T>(content_.asFloat);
 #if ARDUINOJSON_USE_DOUBLE
       case VariantType::Double:
-        return convertNumber<T>(extension->asDouble);
+        return convertNumber<T>(eightByteValue->asDouble);
 #endif
       default:
         return 0;
@@ -301,8 +301,8 @@ class VariantData {
     }
   }
 
-#if ARDUINOJSON_USE_EXTENSIONS
-  const VariantExtension* getExtension(const ResourceManager* resources) const;
+#if ARDUINOJSON_USE_8_BYTE_POOL
+  const EightByteValue* getEightByte(const ResourceManager* resources) const;
 #endif
 
   VariantData* getElement(size_t index,
@@ -365,7 +365,7 @@ class VariantData {
   template <typename T>
   bool isInteger(const ResourceManager* resources) const {
 #if ARDUINOJSON_USE_LONG_LONG
-    auto extension = getExtension(resources);
+    auto eightByteValue = getEightByte(resources);
 #else
     (void)resources;  // silence warning
 #endif
@@ -378,10 +378,10 @@ class VariantData {
 
 #if ARDUINOJSON_USE_LONG_LONG
       case VariantType::Uint64:
-        return canConvertNumber<T>(extension->asUint64);
+        return canConvertNumber<T>(eightByteValue->asUint64);
 
       case VariantType::Int64:
-        return canConvertNumber<T>(extension->asInt64);
+        return canConvertNumber<T>(eightByteValue->asInt64);
 #endif
 
       default:

+ 20 - 20
src/ArduinoJson/Variant/VariantImpl.hpp

@@ -44,9 +44,9 @@ inline void VariantData::clear(ResourceManager* resources) {
   if (type_ & VariantTypeBits::OwnedStringBit)
     resources->dereferenceString(content_.asStringNode->data);
 
-#if ARDUINOJSON_USE_EXTENSIONS
-  if (type_ & VariantTypeBits::ExtensionBit)
-    resources->freeExtension(content_.asSlotId);
+#if ARDUINOJSON_USE_8_BYTE_POOL
+  if (type_ & VariantTypeBits::EightByteBit)
+    resources->freeEightByte(content_.asSlotId);
 #endif
 
   auto collection = asCollection();
@@ -56,12 +56,12 @@ inline void VariantData::clear(ResourceManager* resources) {
   type_ = VariantType::Null;
 }
 
-#if ARDUINOJSON_USE_EXTENSIONS
-inline const VariantExtension* VariantData::getExtension(
+#if ARDUINOJSON_USE_8_BYTE_POOL
+inline const EightByteValue* VariantData::getEightByte(
     const ResourceManager* resources) const {
-  return type_ & VariantTypeBits::ExtensionBit
-             ? resources->getExtension(content_.asSlotId)
-             : nullptr;
+  return type_ & VariantTypeBits::EightByteBit
+             ? resources->getEightByte(content_.asSlotId)
+             : 0;
 }
 #endif
 
@@ -78,12 +78,12 @@ enable_if_t<sizeof(T) == 8, bool> VariantData::setFloat(
     type_ = VariantType::Float;
     content_.asFloat = valueAsFloat;
   } else {
-    auto extension = resources->allocExtension();
-    if (!extension)
+    auto slot = resources->allocEightByte();
+    if (!slot)
       return false;
     type_ = VariantType::Double;
-    content_.asSlotId = extension.id();
-    extension->asDouble = value;
+    content_.asSlotId = slot.id();
+    slot->asDouble = value;
   }
 #else
   type_ = VariantType::Float;
@@ -104,12 +104,12 @@ enable_if_t<is_signed<T>::value, bool> VariantData::setInteger(
   }
 #if ARDUINOJSON_USE_LONG_LONG
   else {
-    auto extension = resources->allocExtension();
-    if (!extension)
+    auto slot = resources->allocEightByte();
+    if (!slot)
       return false;
     type_ = VariantType::Int64;
-    content_.asSlotId = extension.id();
-    extension->asInt64 = value;
+    content_.asSlotId = slot.id();
+    slot->asInt64 = value;
   }
 #endif
   return true;
@@ -127,12 +127,12 @@ enable_if_t<is_unsigned<T>::value, bool> VariantData::setInteger(
   }
 #if ARDUINOJSON_USE_LONG_LONG
   else {
-    auto extension = resources->allocExtension();
-    if (!extension)
+    auto slot = resources->allocEightByte();
+    if (!slot)
       return false;
     type_ = VariantType::Uint64;
-    content_.asSlotId = extension.id();
-    extension->asUint64 = value;
+    content_.asSlotId = slot.id();
+    slot->asUint64 = value;
   }
 #endif
   return true;