145
|
1 /* PR ipa/88561 */
|
|
2 /* { dg-options "-O3 -fdump-tree-tracer-details -fdump-tree-dom3-details -fno-profile-values" } */
|
|
3
|
|
4 struct nsISupports
|
|
5 {
|
|
6 virtual int QueryInterface (const int &aIID, void **aInstancePtr) = 0;
|
|
7 virtual __attribute__((noinline, noclone)) unsigned AddRef (void) = 0;
|
|
8 virtual unsigned Release (void) = 0;
|
|
9 };
|
|
10
|
|
11 struct nsIObserver : public nsISupports
|
|
12 {
|
|
13 virtual int Observe (nsISupports * aSubject, const char *aTopic, const unsigned short *aData) = 0;
|
|
14 };
|
|
15
|
|
16 struct nsISupportsWeakReference : public nsISupports
|
|
17 {
|
|
18 virtual int GetWeakReference (void **_retval) = 0;
|
|
19 };
|
|
20
|
|
21 struct nsSupportsWeakReference : public nsISupportsWeakReference
|
|
22 {
|
|
23 nsSupportsWeakReference () : mProxy (0) {}
|
|
24 virtual int GetWeakReference (void **_retval) override { return 0; }
|
|
25 ~nsSupportsWeakReference () {}
|
|
26 void NoticeProxyDestruction () { mProxy = nullptr; }
|
|
27 void *mProxy;
|
|
28 void ClearWeakReferences ();
|
|
29 bool HasWeakReferences () const { return !!mProxy; }
|
|
30 };
|
|
31
|
|
32 struct mozIPersonalDictionary : public nsISupports
|
|
33 {
|
|
34 virtual int Load (void) = 0;
|
|
35 virtual int Save (void) = 0;
|
|
36 virtual int GetWordList (void **aWordList) = 0;
|
|
37 virtual int Check (const int &word, bool * _retval) = 0;
|
|
38 virtual int AddWord (const int &word) = 0;
|
|
39 virtual int RemoveWord (const int &word) = 0;
|
|
40 virtual int IgnoreWord (const int &word) = 0;
|
|
41 virtual int EndSession (void) = 0;
|
|
42 };
|
|
43
|
|
44 struct mozPersonalDictionary final
|
|
45 : public mozIPersonalDictionary, public nsIObserver, public nsSupportsWeakReference
|
|
46 {
|
|
47 virtual int QueryInterface (const int &aIID, void **aInstancePtr) override;
|
|
48 virtual __attribute__((noinline, noclone)) unsigned AddRef (void) override;
|
|
49 virtual unsigned Release (void) override;
|
|
50 unsigned long mRefCnt;
|
|
51 virtual int Load (void) override { return 0; }
|
|
52 virtual int Save (void) override { return 0; }
|
|
53 virtual int GetWordList (void **aWordList) override { return 0; }
|
|
54 virtual int Check (const int &word, bool * _retval) override { return 0; }
|
|
55 virtual int AddWord (const int &word) override { return 0; }
|
|
56 virtual int RemoveWord (const int &word) override { return 0; }
|
|
57 virtual int IgnoreWord (const int &word) override { return 0; }
|
|
58 virtual int EndSession (void) override { return 0; }
|
|
59 virtual int Observe (nsISupports * aSubject, const char *aTopic, const unsigned short *aData) override { return 0; }
|
|
60 mozPersonalDictionary () : mRefCnt(0) {}
|
|
61 int Init () { return 0; }
|
|
62 virtual ~mozPersonalDictionary () {}
|
|
63 bool mIsLoaded;
|
|
64 bool mSavePending;
|
|
65 void *mFile;
|
|
66 char mMonitor[96];
|
|
67 char mMonitorSave[96];
|
|
68 char mDictionaryTable[32];
|
|
69 char mIgnoreTable[32];
|
|
70 };
|
|
71
|
|
72 unsigned
|
|
73 mozPersonalDictionary::AddRef (void)
|
|
74 {
|
|
75 unsigned count = ++mRefCnt;
|
|
76 return count;
|
|
77 }
|
|
78
|
|
79 unsigned
|
|
80 mozPersonalDictionary::Release (void)
|
|
81 {
|
|
82 unsigned count = --mRefCnt;
|
|
83 if (count == 0)
|
|
84 {
|
|
85 mRefCnt = 1;
|
|
86 delete (this);
|
|
87 return 0;
|
|
88 }
|
|
89 return count;
|
|
90 }
|
|
91
|
|
92 int
|
|
93 mozPersonalDictionary::QueryInterface (const int &aIID, void **aInstancePtr)
|
|
94 {
|
|
95 nsISupports *foundInterface;
|
|
96 if (aIID == 122)
|
|
97 foundInterface = static_cast <mozIPersonalDictionary *>(this);
|
|
98 else
|
|
99 foundInterface = static_cast <nsISupportsWeakReference *>(this);
|
|
100 int status;
|
|
101 foundInterface->AddRef ();
|
|
102 *aInstancePtr = foundInterface;
|
|
103 return status;
|
|
104 }
|
|
105
|
|
106 __attribute__((noipa)) int
|
|
107 foo (nsISupports *p, const int &i)
|
|
108 {
|
|
109 void *q;
|
|
110 return p->QueryInterface (i, &q);
|
|
111 }
|
|
112
|
|
113 int
|
|
114 main ()
|
|
115 {
|
|
116 mozPersonalDictionary m;
|
|
117 int j = 123;
|
|
118 for (int i = 0; i < 100000; i++)
|
|
119 foo (static_cast <nsISupportsWeakReference *>(&m), j);
|
|
120 if (m.mRefCnt != 100000)
|
|
121 __builtin_abort ();
|
|
122 }
|
|
123
|
|
124 /* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn16" 1 "tracer" { target { lp64 || llp64 } } } } */
|
|
125 /* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::_ZThn8" 1 "tracer" { target ilp32 } } } */
|
|
126 /* { dg-final-use-not-autofdo { scan-tree-dump-times "folding virtual function call to virtual unsigned int mozPersonalDictionary::AddRef" 1 "tracer" } } */
|