2 /* { dg-options "-O3 -fdump-tree-tracer-details -fdump-tree-dom3-details -fno-profile-values" } */
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;
11 struct nsIObserver : public nsISupports
13 virtual int Observe (nsISupports * aSubject, const char *aTopic, const unsigned short *aData) = 0;
16 struct nsISupportsWeakReference : public nsISupports
18 virtual int GetWeakReference (void **_retval) = 0;
21 struct nsSupportsWeakReference : public nsISupportsWeakReference
23 nsSupportsWeakReference () : mProxy (0) {}
24 virtual int GetWeakReference (void **_retval) override { return 0; }
25 ~nsSupportsWeakReference () {}
26 void NoticeProxyDestruction () { mProxy = nullptr; }
28 void ClearWeakReferences ();
29 bool HasWeakReferences () const { return !!mProxy; }
32 struct mozIPersonalDictionary : public nsISupports
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;
44 struct mozPersonalDictionary final
45 : public mozIPersonalDictionary, public nsIObserver, public nsSupportsWeakReference
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 () {}
67 char mMonitorSave[96];
68 char mDictionaryTable[32];
69 char mIgnoreTable[32];
73 mozPersonalDictionary::AddRef (void)
75 unsigned count = ++mRefCnt;
80 mozPersonalDictionary::Release (void)
82 unsigned count = --mRefCnt;
93 mozPersonalDictionary::QueryInterface (const int &aIID, void **aInstancePtr)
95 nsISupports *foundInterface;
97 foundInterface = static_cast <mozIPersonalDictionary *>(this);
99 foundInterface = static_cast <nsISupportsWeakReference *>(this);
101 foundInterface->AddRef ();
102 *aInstancePtr = foundInterface;
106 __attribute__((noipa)) int
107 foo (nsISupports *p, const int &i)
110 return p->QueryInterface (i, &q);
116 mozPersonalDictionary m;
118 for (int i = 0; i < 100000; i++)
119 foo (static_cast <nsISupportsWeakReference *>(&m), j);
120 if (m.mRefCnt != 100000)
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" } } */