annotate gcc/testsuite/g++.dg/opt/pr55717.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // PR debug/55717
kono
parents:
diff changeset
2 // { dg-do compile }
kono
parents:
diff changeset
3 // { dg-options "-O -g" }
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 struct DebugOnly {};
kono
parents:
diff changeset
6 template <class T>
kono
parents:
diff changeset
7 struct StripConst { typedef T result; };
kono
parents:
diff changeset
8 class TempAllocPolicy {};
kono
parents:
diff changeset
9 template <class T>
kono
parents:
diff changeset
10 class HashTableEntry
kono
parents:
diff changeset
11 {
kono
parents:
diff changeset
12 unsigned keyHash;
kono
parents:
diff changeset
13 template <class, class, class>
kono
parents:
diff changeset
14 friend class HashTable;
kono
parents:
diff changeset
15 T t;
kono
parents:
diff changeset
16 void setLive (unsigned hn) { keyHash = hn; }
kono
parents:
diff changeset
17 };
kono
parents:
diff changeset
18 template <class T, class HashPolicy, class>
kono
parents:
diff changeset
19 struct HashTable
kono
parents:
diff changeset
20 {
kono
parents:
diff changeset
21 typedef typename HashPolicy::KeyType Key;
kono
parents:
diff changeset
22 typedef typename HashPolicy::Lookup Lookup;
kono
parents:
diff changeset
23 typedef HashTableEntry <T> Entry;
kono
parents:
diff changeset
24 struct Range
kono
parents:
diff changeset
25 {
kono
parents:
diff changeset
26 Range () {}
kono
parents:
diff changeset
27 Entry *cur, end;
kono
parents:
diff changeset
28 bool empty () { return false; }
kono
parents:
diff changeset
29 T front () { return T (); }
kono
parents:
diff changeset
30 };
kono
parents:
diff changeset
31 struct Enum : public Range
kono
parents:
diff changeset
32 {
kono
parents:
diff changeset
33 HashTable table;
kono
parents:
diff changeset
34 bool removed;
kono
parents:
diff changeset
35 template <class Map>
kono
parents:
diff changeset
36 Enum (Map map) : Range (map.all ()), table (map.impl), removed () {}
kono
parents:
diff changeset
37 void rekeyFront (Lookup l, Key)
kono
parents:
diff changeset
38 {
kono
parents:
diff changeset
39 T t = this->cur->t;
kono
parents:
diff changeset
40 table.putNewInfallible (l, t);
kono
parents:
diff changeset
41 }
kono
parents:
diff changeset
42 void rekeyFront (Key k)
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 rekeyFront (k, k);
kono
parents:
diff changeset
45 }
kono
parents:
diff changeset
46 };
kono
parents:
diff changeset
47 unsigned entryCount;
kono
parents:
diff changeset
48 unsigned sCollisionBit;
kono
parents:
diff changeset
49 unsigned prepareHash (Lookup l)
kono
parents:
diff changeset
50 {
kono
parents:
diff changeset
51 unsigned keyHash (HashPolicy::hash (l));
kono
parents:
diff changeset
52 return keyHash & sCollisionBit;
kono
parents:
diff changeset
53 }
kono
parents:
diff changeset
54 static Entry *entryp;
kono
parents:
diff changeset
55 Entry *findFreeEntry (unsigned) { return entryp; }
kono
parents:
diff changeset
56 void putNewInfallible (Lookup l, T)
kono
parents:
diff changeset
57 {
kono
parents:
diff changeset
58 unsigned keyHash = prepareHash (l);
kono
parents:
diff changeset
59 Entry *entry = findFreeEntry (keyHash);
kono
parents:
diff changeset
60 entry->setLive (keyHash);
kono
parents:
diff changeset
61 entryCount++;
kono
parents:
diff changeset
62 }
kono
parents:
diff changeset
63 };
kono
parents:
diff changeset
64 template <class Key>
kono
parents:
diff changeset
65 struct HashMapEntry { Key key; };
kono
parents:
diff changeset
66 template <class Key, class Value, class HashPolicy = DebugOnly, class AllocPolicy = TempAllocPolicy>
kono
parents:
diff changeset
67 struct HashMap
kono
parents:
diff changeset
68 {
kono
parents:
diff changeset
69 typedef HashMapEntry <Key> Entry;
kono
parents:
diff changeset
70 struct MapHashPolicy : HashPolicy
kono
parents:
diff changeset
71 {
kono
parents:
diff changeset
72 typedef Key KeyType;
kono
parents:
diff changeset
73 };
kono
parents:
diff changeset
74 typedef HashTable <Entry, MapHashPolicy, AllocPolicy> Impl;
kono
parents:
diff changeset
75 Impl impl;
kono
parents:
diff changeset
76 typedef typename Impl::Range Range;
kono
parents:
diff changeset
77 Range all () { return Range (); }
kono
parents:
diff changeset
78 typedef typename Impl::Enum Enum;
kono
parents:
diff changeset
79 };
kono
parents:
diff changeset
80 class FreeOp;
kono
parents:
diff changeset
81 struct AllocationSiteKey;
kono
parents:
diff changeset
82 typedef HashMap <AllocationSiteKey, DebugOnly, AllocationSiteKey, TempAllocPolicy> AllocationSiteTable;
kono
parents:
diff changeset
83 struct TypeCompartment
kono
parents:
diff changeset
84 {
kono
parents:
diff changeset
85 AllocationSiteTable *allocationSiteTable;
kono
parents:
diff changeset
86 void sweep (FreeOp *);
kono
parents:
diff changeset
87 };
kono
parents:
diff changeset
88 struct JSScript { unsigned *code; };
kono
parents:
diff changeset
89 bool IsScriptMarked (JSScript **);
kono
parents:
diff changeset
90 struct AllocationSiteKey
kono
parents:
diff changeset
91 {
kono
parents:
diff changeset
92 JSScript *script;
kono
parents:
diff changeset
93 unsigned offset : 24;
kono
parents:
diff changeset
94 int kind;
kono
parents:
diff changeset
95 typedef AllocationSiteKey Lookup;
kono
parents:
diff changeset
96 static unsigned hash (AllocationSiteKey key) { return (long (key.script->code + key.offset)) ^ key.kind; }
kono
parents:
diff changeset
97 };
kono
parents:
diff changeset
98 void
kono
parents:
diff changeset
99 TypeCompartment::sweep (FreeOp *)
kono
parents:
diff changeset
100 {
kono
parents:
diff changeset
101 for (AllocationSiteTable::Enum e (*allocationSiteTable); !e.empty ();)
kono
parents:
diff changeset
102 {
kono
parents:
diff changeset
103 AllocationSiteKey key = e.front ().key;
kono
parents:
diff changeset
104 IsScriptMarked (&key.script);
kono
parents:
diff changeset
105 e.rekeyFront (key);
kono
parents:
diff changeset
106 }
kono
parents:
diff changeset
107 }