[SM91] Update to Spidermonkey 91.1.3 APIs
[0ad.git] / libraries / source / spidermonkey / include-win32-release / js / Zone.h
blob8763d794d90217c3d84be7d071ee3a5d6e1552f7
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* JavaScript API. */
9 #ifndef js_Zone_h
10 #define js_Zone_h
12 #include "jspubtd.h"
13 #include "js/Context.h"
15 // [SMDOC] Nested GC Data Structures (Compartments and Zones)
17 // The GC has two nested data structures, Zones and Compartents. Each has
18 // distint responsibilities. Zones contain compartments, along with other GC
19 // resources used by a tab. Compartments contain realms, which are specification
20 // defined.
22 // See also the SMDoc on Realms.
24 // Compartment
25 // -----------
26 // Security membrane; when an object from compartment A is used in compartment
27 // B, a cross-compartment wrapper (a kind of proxy) is used. In the browser,
28 // same-origin realms can share a compartment.
30 // Zone
31 // ----
32 // A Zone is a group of compartments that share GC resources (arenas, strings,
33 // etc) for memory usage and performance reasons. Zone is the GC unit: the GC
34 // can operate on one or more zones at a time. The browser uses roughly one zone
35 // per tab.
37 using JSDestroyZoneCallback = void (*)(JSFreeOp*, JS::Zone*);
39 using JSDestroyCompartmentCallback = void (*)(JSFreeOp*, JS::Compartment*);
41 using JSSizeOfIncludingThisCompartmentCallback =
42 size_t (*)(mozilla::MallocSizeOf, JS::Compartment*);
44 extern JS_PUBLIC_API void JS_SetDestroyZoneCallback(
45 JSContext* cx, JSDestroyZoneCallback callback);
47 extern JS_PUBLIC_API void JS_SetDestroyCompartmentCallback(
48 JSContext* cx, JSDestroyCompartmentCallback callback);
50 extern JS_PUBLIC_API void JS_SetSizeOfIncludingThisCompartmentCallback(
51 JSContext* cx, JSSizeOfIncludingThisCompartmentCallback callback);
53 extern JS_PUBLIC_API void JS_SetCompartmentPrivate(JS::Compartment* compartment,
54 void* data);
56 extern JS_PUBLIC_API void* JS_GetCompartmentPrivate(
57 JS::Compartment* compartment);
59 extern JS_PUBLIC_API void JS_SetZoneUserData(JS::Zone* zone, void* data);
61 extern JS_PUBLIC_API void* JS_GetZoneUserData(JS::Zone* zone);
63 extern JS_PUBLIC_API bool JS_RefreshCrossCompartmentWrappers(
64 JSContext* cx, JS::Handle<JSObject*> obj);
66 /**
67 * Mark a jsid after entering a new compartment. Different zones separately
68 * mark the ids in a runtime, and this must be used any time an id is obtained
69 * from one compartment and then used in another compartment, unless the two
70 * compartments are guaranteed to be in the same zone.
72 extern JS_PUBLIC_API void JS_MarkCrossZoneId(JSContext* cx, jsid id);
74 /**
75 * If value stores a jsid (an atomized string or symbol), mark that id as for
76 * JS_MarkCrossZoneId.
78 extern JS_PUBLIC_API void JS_MarkCrossZoneIdValue(JSContext* cx,
79 const JS::Value& value);
81 #endif // js_Zone_h