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 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef perf_jsperf_h
7 #define perf_jsperf_h
9 #include "jstypes.h"
11 #include "js/TypeDecls.h"
12 #include "js/Utility.h"
14 namespace JS {
16 /*
17 * JS::PerfMeasurement is a generic way to access detailed performance
18 * measurement APIs provided by your operating system. The details of
19 * exactly how this works and what can be measured are highly
20 * system-specific, but this interface is (one hopes) implementable
21 * on top of all of them.
22 *
23 * To use this API, create a PerfMeasurement object, passing its
24 * constructor a bitmask indicating which events you are interested
25 * in. Thereafter, Start() zeroes all counters and starts timing;
26 * Stop() stops timing again; and the counters for the events you
27 * requested are available as data values after calling Stop(). The
28 * object may be reused for many measurements.
29 */
30 class JS_FRIEND_API(PerfMeasurement)
31 {
32 protected:
33 // Implementation-specific data, if any.
34 void* impl;
36 public:
37 /*
38 * Events that may be measured. Taken directly from the list of
39 * "generalized hardware performance event types" in the Linux
40 * perf_event API, plus some of the "software events".
41 */
42 enum EventMask {
43 CPU_CYCLES = 0x00000001,
44 INSTRUCTIONS = 0x00000002,
45 CACHE_REFERENCES = 0x00000004,
46 CACHE_MISSES = 0x00000008,
47 BRANCH_INSTRUCTIONS = 0x00000010,
48 BRANCH_MISSES = 0x00000020,
49 BUS_CYCLES = 0x00000040,
50 PAGE_FAULTS = 0x00000080,
51 MAJOR_PAGE_FAULTS = 0x00000100,
52 CONTEXT_SWITCHES = 0x00000200,
53 CPU_MIGRATIONS = 0x00000400,
55 ALL = 0x000007ff,
56 NUM_MEASURABLE_EVENTS = 11
57 };
59 /*
60 * Bitmask of events that will be measured when this object is
61 * active (between Start() and Stop()). This may differ from the
62 * bitmask passed to the constructor if the platform does not
63 * support measuring all of the requested events.
64 */
65 const EventMask eventsMeasured;
67 /*
68 * Counters for each measurable event.
69 * Immediately after one of these objects is created, all of the
70 * counters for enabled events will be zero, and all of the
71 * counters for disabled events will be uint64_t(-1).
72 */
73 uint64_t cpu_cycles;
74 uint64_t instructions;
75 uint64_t cache_references;
76 uint64_t cache_misses;
77 uint64_t branch_instructions;
78 uint64_t branch_misses;
79 uint64_t bus_cycles;
80 uint64_t page_faults;
81 uint64_t major_page_faults;
82 uint64_t context_switches;
83 uint64_t cpu_migrations;
85 /*
86 * Prepare to measure the indicated set of events. If not all of
87 * the requested events can be measured on the current platform,
88 * then the eventsMeasured bitmask will only include the subset of
89 * |toMeasure| corresponding to the events that can be measured.
90 */
91 PerfMeasurement(EventMask toMeasure);
93 /* Done with this set of measurements, tear down OS-level state. */
94 ~PerfMeasurement();
96 /* Start a measurement cycle. */
97 void start();
99 /*
100 * End a measurement cycle, and for each enabled counter, add the
101 * number of measured events of that type to the appropriate
102 * visible variable.
103 */
104 void stop();
106 /* Reset all enabled counters to zero. */
107 void reset();
109 /*
110 * True if this platform supports measuring _something_, i.e. it's
111 * not using the stub implementation.
112 */
113 static bool canMeasureSomething();
114 };
116 /* Inject a Javascript wrapper around the above C++ class into the
117 * Javascript object passed as an argument (this will normally be a
118 * global object). The JS-visible API is identical to the C++ API.
119 */
120 extern JS_FRIEND_API(JSObject*)
121 RegisterPerfMeasurement(JSContext *cx, JS::HandleObject global);
123 /*
124 * Given a Value which contains an instance of the aforementioned
125 * wrapper class, extract the C++ object. Returns nullptr if the
126 * Value is not an instance of the wrapper.
127 */
128 extern JS_FRIEND_API(PerfMeasurement*)
129 ExtractPerfMeasurement(Value wrapper);
131 } // namespace JS
133 #endif /* perf_jsperf_h */