Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 // Test01.cpp
3 #include "nsIDOMNode.h"
4 #include "nsCOMPtr.h"
5 #include "nsString.h"
7 NS_DEF_PTR(nsIDOMNode);
9 /*
10 This test file compares the generated code size of similar functions between raw
11 COM interface pointers (|AddRef|ing and |Release|ing by hand) and |nsCOMPtr|s.
13 Function size results were determined by examining dissassembly of the generated code.
14 mXXX is the size of the generated code on the Macintosh. wXXX is the size on Windows.
15 For these tests, all reasonable optimizations were enabled and exceptions were
16 disabled (just as we build for release).
18 The tests in this file explore only the simplest functionality: assigning a pointer
19 to be reference counted into a [raw, nsCOMPtr] object; ensuring that it is
20 |AddRef|ed and |Release|d appropriately; calling through the pointer to a function
21 supplied by the underlying COM interface.
23 Windows:
24 raw_optimized 31 bytes
25 raw, nsCOMPtr* 34
26 nsCOMPtr_optimized* 38
27 nsCOMPtr_optimized 42
28 nsCOMPtr 46
30 Macintosh:
31 raw_optimized, nsCOMPtr_optimized 112 bytes (1.0000)
32 nsCOMPtr 120 (1.0714) i.e., 7.14% bigger than raw_optimized et al
33 raw 140 (1.2500)
35 The overall difference in size between Windows and Macintosh is caused by the
36 the PowerPC RISC architecture where every instruction is 4 bytes.
38 On Macintosh, nsCOMPtr generates out-of-line destructors which are
39 not referenced, and which can be stripped by the linker.
40 */
42 void
43 Test01_raw( nsIDOMNode* aDOMNode, nsString* aResult )
44 // m140, w34
45 {
46 /*
47 This test is designed to be more like a typical large function where,
48 because you are working with several resources, you don't just return when
49 one of them is |nullptr|. Similarly: |Test01_nsCOMPtr00|, and |Test01_nsIPtr00|.
50 */
52 nsIDOMNode* node = aDOMNode;
53 NS_IF_ADDREF(node);
55 if ( node )
56 node->GetNodeName(*aResult);
58 NS_IF_RELEASE(node);
59 }
61 void
62 Test01_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
63 // m112, w31
64 {
65 /*
66 This test simulates smaller functions where you _do_ just return
67 |nullptr| at the first sign of trouble. Similarly: |Test01_nsCOMPtr01|,
68 and |Test01_nsIPtr01|.
69 */
71 /*
72 This test produces smaller code that |Test01_raw| because it avoids
73 the three tests: |NS_IF_...|, and |if ( node )|.
74 */
76 // -- the following code is assumed, but is commented out so we compare only
77 // the relevent generated code
79 // if ( !aDOMNode )
80 // return;
82 nsIDOMNode* node = aDOMNode;
83 NS_ADDREF(node);
84 node->GetNodeName(*aResult);
85 NS_RELEASE(node);
86 }
88 void
89 Test01_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult )
90 // m120, w46/34
91 {
92 nsCOMPtr<nsIDOMNode> node = aDOMNode;
94 if ( node )
95 node->GetNodeName(*aResult);
96 }
98 void
99 Test01_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
100 // m112, w42/38
101 {
102 // if ( !aDOMNode )
103 // return;
105 nsCOMPtr<nsIDOMNode> node = aDOMNode;
106 node->GetNodeName(*aResult);
107 }