3 // { dg-options "-O -g" }
7 struct StripConst { typedef T result; };
8 class TempAllocPolicy {};
13 template <class, class, class>
14 friend class HashTable;
16 void setLive (unsigned hn) { keyHash = hn; }
18 template <class T, class HashPolicy, class>
21 typedef typename HashPolicy::KeyType Key;
22 typedef typename HashPolicy::Lookup Lookup;
23 typedef HashTableEntry <T> Entry;
28 bool empty () { return false; }
29 T front () { return T (); }
31 struct Enum : public Range
36 Enum (Map map) : Range (map.all ()), table (map.impl), removed () {}
37 void rekeyFront (Lookup l, Key)
40 table.putNewInfallible (l, t);
42 void rekeyFront (Key k)
48 unsigned sCollisionBit;
49 unsigned prepareHash (Lookup l)
51 unsigned keyHash (HashPolicy::hash (l));
52 return keyHash & sCollisionBit;
55 Entry *findFreeEntry (unsigned) { return entryp; }
56 void putNewInfallible (Lookup l, T)
58 unsigned keyHash = prepareHash (l);
59 Entry *entry = findFreeEntry (keyHash);
60 entry->setLive (keyHash);
65 struct HashMapEntry { Key key; };
66 template <class Key, class Value, class HashPolicy = DebugOnly, class AllocPolicy = TempAllocPolicy>
69 typedef HashMapEntry <Key> Entry;
70 struct MapHashPolicy : HashPolicy
74 typedef HashTable <Entry, MapHashPolicy, AllocPolicy> Impl;
76 typedef typename Impl::Range Range;
77 Range all () { return Range (); }
78 typedef typename Impl::Enum Enum;
81 struct AllocationSiteKey;
82 typedef HashMap <AllocationSiteKey, DebugOnly, AllocationSiteKey, TempAllocPolicy> AllocationSiteTable;
83 struct TypeCompartment
85 AllocationSiteTable *allocationSiteTable;
86 void sweep (FreeOp *);
88 struct JSScript { unsigned *code; };
89 bool IsScriptMarked (JSScript **);
90 struct AllocationSiteKey
95 typedef AllocationSiteKey Lookup;
96 static unsigned hash (AllocationSiteKey key) { return (long (key.script->code + key.offset)) ^ key.kind; }
99 TypeCompartment::sweep (FreeOp *)
101 for (AllocationSiteTable::Enum e (*allocationSiteTable); !e.empty ();)
103 AllocationSiteKey key = e.front ().key;
104 IsScriptMarked (&key.script);