Skip to content

Commit

Permalink
Avoid SmallSet in Proxy/HostObject cases
Browse files Browse the repository at this point in the history
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
  • Loading branch information
avp authored and facebook-github-bot committed Jan 3, 2025
1 parent 2bb1073 commit e037e5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/VM/JSObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -396,7 +396,7 @@ CallResult<Handle<JSArray>> JSObject::getOwnPropertyKeys(
size_t hostObjectSymbolCount = 0;

// If current object is a host object we need to deduplicate its properties
llvh::SmallSet<SymbolID::RawType, 16> dedupSet;
llvh::SmallDenseSet<SymbolID::RawType, 16> dedupSet;

// Output index.
uint32_t index = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/VM/JSProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1455,7 +1455,7 @@ CallResult<PseudoHandle<JSArray>> 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<uint32_t, 8> nonConfigurable;
llvh::SmallSetVector<uint32_t, 8> nonConfigurable;
MutableHandle<SymbolID> tmpPropNameStorage{runtime};
// 16. For each element key of targetKeys, do
GCScopeMarkerRAII marker{runtime};
Expand Down

0 comments on commit e037e5a

Please sign in to comment.