Bug 909490, part 1 - Add per-zone data for use by embedder. r=billm
authorAndrew McCreight <continuation@gmail.com>
Mon, 25 Nov 2013 14:58:21 -0800
changeset 167555 27315aeda9dc3c66c630cd06736aeac82bbe6367
parent 167554 fd450b08821876736fe86b35d13ecac6f1bb2465
child 167556 b86f2eb6c0728a9ba3152740338091dd9eec16ba
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs909490
milestone27.0a2
Bug 909490, part 1 - Add per-zone data for use by embedder. r=billm
js/src/gc/Zone.cpp
js/src/gc/Zone.h
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/gc/Zone.cpp
+++ b/js/src/gc/Zone.cpp
@@ -34,16 +34,17 @@ JS::Zone::Zone(JSRuntime *rt)
     gcTriggerBytes(0),
     gcHeapGrowthFactor(3.0),
     isSystem(false),
     usedByExclusiveThread(false),
     scheduledForDestruction(false),
     maybeAlive(true),
     gcMallocBytes(0),
     gcGrayRoots(),
+    data(nullptr),
     types(this)
 {
     /* Ensure that there are no vtables to mess us up here. */
     JS_ASSERT(reinterpret_cast<JS::shadow::Zone *>(this) ==
               static_cast<JS::shadow::Zone *>(this));
 
     setGCMaxMallocBytes(rt->gcMaxMallocBytes * 0.9);
 }
--- a/js/src/gc/Zone.h
+++ b/js/src/gc/Zone.h
@@ -247,16 +247,19 @@ struct Zone : public JS::shadow::Zone,
      * gcMaxMallocBytes down to zero. This counter should be used only when it's
      * not possible to know the size of a free.
      */
     ptrdiff_t                    gcMallocBytes;
 
     /* This compartment's gray roots. */
     js::Vector<js::GrayRoot, 0, js::SystemAllocPolicy> gcGrayRoots;
 
+    /* Per-zone data for use by an embedder. */
+    void *data;
+
     Zone(JSRuntime *rt);
     ~Zone();
     bool init(JSContext *cx);
 
     void findOutgoingEdges(js::gc::ComponentFinder<JS::Zone> &finder);
 
     void discardJitCode(js::FreeOp *fop);
 
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1056,16 +1056,28 @@ JS_SetCompartmentPrivate(JSCompartment *
 }
 
 JS_PUBLIC_API(void *)
 JS_GetCompartmentPrivate(JSCompartment *compartment)
 {
     return compartment->data;
 }
 
+JS_PUBLIC_API(void)
+JS_SetZoneUserData(JS::Zone *zone, void *data)
+{
+    zone->data = data;
+}
+
+JS_PUBLIC_API(void *)
+JS_GetZoneUserData(JS::Zone *zone)
+{
+    return zone->data;
+}
+
 JS_PUBLIC_API(bool)
 JS_WrapObject(JSContext *cx, MutableHandleObject objp)
 {
     AssertHeapIsIdle(cx);
     CHECK_REQUEST(cx);
     if (objp)
         JS::ExposeGCThingToActiveJS(objp, JSTRACE_OBJECT);
     return cx->compartment()->wrap(cx, objp);
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1677,16 +1677,22 @@ JS_SetWrapObjectCallbacks(JSRuntime *rt,
                           JSPreWrapCallback precallback);
 
 extern JS_PUBLIC_API(void)
 JS_SetCompartmentPrivate(JSCompartment *compartment, void *data);
 
 extern JS_PUBLIC_API(void *)
 JS_GetCompartmentPrivate(JSCompartment *compartment);
 
+extern JS_PUBLIC_API(void)
+JS_SetZoneUserData(JS::Zone *zone, void *data);
+
+extern JS_PUBLIC_API(void *)
+JS_GetZoneUserData(JS::Zone *zone);
+
 extern JS_PUBLIC_API(bool)
 JS_WrapObject(JSContext *cx, JS::MutableHandleObject objp);
 
 extern JS_PUBLIC_API(bool)
 JS_WrapValue(JSContext *cx, JS::MutableHandleValue vp);
 
 extern JS_PUBLIC_API(bool)
 JS_WrapId(JSContext *cx, jsid *idp);