Loading...
--- dyld/dyld-1340/common/PerfectHash.h
+++ dyld/dyld-960/common/PerfectHash.h
@@ -32,19 +32,15 @@
#include "Array.h"
#include "Map.h"
-#if BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS || BUILDING_CACHE_BUILDER_UNIT_TESTS
+#if BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS
#include <unordered_map>
-#include <vector>
#endif
namespace objc {
+
uint64_t lookup8(const uint8_t *k, size_t length, uint64_t level);
-#if BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS || BUILDING_CACHE_BUILDER_UNIT_TESTS
-
-// An objc string is at a certain offset in to its buffer. Eg, a selector is a given offset
-// in to the selector strings buffer
-typedef std::pair<std::string_view, uint32_t> ObjCString;
+#if BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS
struct eqstr {
bool operator()(const char* s1, const char* s2) const {
@@ -75,6 +71,8 @@
// class name => (class vmaddress, dylib objc index)
typedef std::unordered_multimap<const char *, std::pair<uint64_t, uint16_t>, hashstr, eqstr> class_map;
+#endif // #if BUILDING_CACHE_BUILDER
+
struct VIS_HIDDEN PerfectHash {
uint32_t capacity = 0;
uint32_t occupied = 0;
@@ -88,10 +86,15 @@
/* representation of a key */
struct key
{
+#if BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS
uint8_t *name1_k; /* the actual key */
uint32_t len1_k; /* the length of the actual key */
uint8_t *name2_k; /* the actual key */
uint32_t len2_k; /* the length of the actual key */
+#else
+ uint8_t *name_k; /* the actual key */
+ uint32_t len_k; /* the length of the actual key */
+#endif
uint32_t hash_k; /* the initial hash value for this key */
/* beyond this point is mapping-dependent */
uint32_t a_k; /* a, of the key maps to (a,b) */
@@ -99,14 +102,16 @@
struct key *nextb_k; /* next key with this b */
};
- // For the shared cache builder swift maps
static void make_perfect(dyld3::OverflowSafeArray<key>& keys, PerfectHash& result);
+ // For dyld at runtime to create perfect hash tables in the PrebuiltObjC
+ static void make_perfect(const dyld3::OverflowSafeArray<const char*>& strings, objc::PerfectHash& phash);
+
+#if BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS
// For the shared cache builder selector/class/protocol maps
- static void make_perfect(const std::vector<ObjCString>& strings, objc::PerfectHash& phash);
+ static void make_perfect(const string_map& strings, objc::PerfectHash& phash);
+#endif
};
-
-#endif // BUILDING_CACHE_BUILDER || BUILDING_UNIT_TESTS || BUILDING_CACHE_BUILDER_UNIT_TESTS
} // namespace objc