From e037e5ab922b8aeab7794f8233a8d10fcc541104 Mon Sep 17 00:00:00 2001 From: Aakash Patel Date: Thu, 2 Jan 2025 16:54:07 -0800 Subject: [PATCH] Avoid SmallSet in Proxy/HostObject cases Summary: These were using `SmallSet` when the keys were just integers, but `SmallSet` is backed by `std::set` instead of `DenseSet`. Switch to DenseSet and keep determinism by using `SmallSetVector` if necessary. Reviewed By: tmikov Differential Revision: D67548060 fbshipit-source-id: f5666fa8ab7cb250bbb151652784bfc05b49933e --- lib/VM/JSObject.cpp | 4 ++-- lib/VM/JSProxy.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/VM/JSObject.cpp b/lib/VM/JSObject.cpp index fcb80018b92..1c5c340d5ae 100644 --- a/lib/VM/JSObject.cpp +++ b/lib/VM/JSObject.cpp @@ -17,7 +17,7 @@ #include "hermes/VM/Operations.h" #include "hermes/VM/PropertyAccessor.h" -#include "llvh/ADT/SmallSet.h" +#include "llvh/ADT/DenseSet.h" namespace hermes { namespace vm { @@ -396,7 +396,7 @@ CallResult> JSObject::getOwnPropertyKeys( size_t hostObjectSymbolCount = 0; // If current object is a host object we need to deduplicate its properties - llvh::SmallSet dedupSet; + llvh::SmallDenseSet dedupSet; // Output index. uint32_t index = 0; diff --git a/lib/VM/JSProxy.cpp b/lib/VM/JSProxy.cpp index 79570b85c54..ebb0c62637c 100644 --- a/lib/VM/JSProxy.cpp +++ b/lib/VM/JSProxy.cpp @@ -14,7 +14,7 @@ #include "hermes/VM/JSMapImpl.h" #include "hermes/VM/PropertyAccessor.h" -#include "llvh/ADT/SmallSet.h" +#include "llvh/ADT/SetVector.h" namespace hermes { namespace vm { @@ -1455,7 +1455,7 @@ CallResult> JSProxy::ownPropertyKeys( // 13. Assert: targetKeys contains no duplicate entries. // 14. Let targetConfigurableKeys be a new empty List. // 15. Let targetNonconfigurableKeys be a new empty List. - llvh::SmallSet nonConfigurable; + llvh::SmallSetVector nonConfigurable; MutableHandle tmpPropNameStorage{runtime}; // 16. For each element key of targetKeys, do GCScopeMarkerRAII marker{runtime};