Bug 1223954 - don't use implicitJSContext for readHeapSnapshot and saveHeapSnapshot; r=bz
authorTom Tromey <tom@tromey.com>
Thu, 12 Nov 2015 08:51:00 +0100
changeset 272936 7a4d7900e8795e3b77b0dd4dafd00ebf3802905b
parent 272935 12b1bc4e72200e28ab3994901909344579deb5b0
child 272937 3df44184a432e2efb5e5fa9c957577e6d1d92cfc
push id29688
push userkwierso@gmail.com
push dateTue, 17 Nov 2015 21:10:09 +0000
treeherdermozilla-central@eed903a7e4e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1223954
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1223954 - don't use implicitJSContext for readHeapSnapshot and saveHeapSnapshot; r=bz
devtools/shared/heapsnapshot/HeapSnapshot.cpp
dom/base/ChromeUtils.h
dom/bindings/Bindings.conf
--- a/devtools/shared/heapsnapshot/HeapSnapshot.cpp
+++ b/devtools/shared/heapsnapshot/HeapSnapshot.cpp
@@ -1336,17 +1336,16 @@ getCoreDumpOutputStream(ErrorResult& rv,
 
 namespace dom {
 
 using namespace JS;
 using namespace devtools;
 
 /* static */ void
 ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
-                                        JSContext* cx,
                                         const HeapSnapshotBoundaries& boundaries,
                                         nsAString& outFilePath,
                                         ErrorResult& rv)
 {
   auto start = TimeStamp::Now();
 
   bool wantNames = true;
   ZoneSet zones;
@@ -1355,16 +1354,17 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(
 
   nsCOMPtr<nsIOutputStream> outputStream = getCoreDumpOutputStream(rv, start, outFilePath);
   if (NS_WARN_IF(rv.Failed()))
     return;
 
   ZeroCopyNSIOutputStream zeroCopyStream(outputStream);
   ::google::protobuf::io::GzipOutputStream gzipStream(&zeroCopyStream);
 
+  JSContext* cx = global.Context();
   StreamWriter writer(cx, gzipStream, wantNames);
   if (NS_WARN_IF(!writer.init())) {
     rv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   {
     Maybe<AutoCheckCannotGC> maybeNoGC;
@@ -1400,17 +1400,16 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(
   Telemetry::Accumulate(Telemetry::DEVTOOLS_HEAP_SNAPSHOT_NODE_COUNT,
                         nodeCount);
   Telemetry::Accumulate(Telemetry::DEVTOOLS_HEAP_SNAPSHOT_EDGE_COUNT,
                         edgeCount);
 }
 
 /* static */ already_AddRefed<HeapSnapshot>
 ThreadSafeChromeUtils::ReadHeapSnapshot(GlobalObject& global,
-                                        JSContext* cx,
                                         const nsAString& filePath,
                                         ErrorResult& rv)
 {
   auto start = TimeStamp::Now();
 
   UniquePtr<char[]> path(ToNewCString(filePath));
   if (!path) {
     rv.Throw(NS_ERROR_OUT_OF_MEMORY);
@@ -1418,17 +1417,18 @@ ThreadSafeChromeUtils::ReadHeapSnapshot(
   }
 
   AutoMemMap mm;
   rv = mm.init(path.get());
   if (rv.Failed())
     return nullptr;
 
   RefPtr<HeapSnapshot> snapshot = HeapSnapshot::Create(
-      cx, global, reinterpret_cast<const uint8_t*>(mm.address()), mm.size(), rv);
+      global.Context(), global, reinterpret_cast<const uint8_t*>(mm.address()),
+      mm.size(), rv);
 
   if (!rv.Failed())
     Telemetry::AccumulateTimeDelta(Telemetry::DEVTOOLS_READ_HEAP_SNAPSHOT_MS,
                                    start);
 
   return snapshot.forget();
 }
 
--- a/dom/base/ChromeUtils.h
+++ b/dom/base/ChromeUtils.h
@@ -20,24 +20,22 @@ class HeapSnapshot;
 
 namespace dom {
 
 class ThreadSafeChromeUtils
 {
 public:
   // Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
   static void SaveHeapSnapshot(GlobalObject& global,
-                               JSContext* cx,
                                const HeapSnapshotBoundaries& boundaries,
                                nsAString& filePath,
                                ErrorResult& rv);
 
   // Implemented in devtools/shared/heapsnapshot/HeapSnapshot.cpp
   static already_AddRefed<devtools::HeapSnapshot> ReadHeapSnapshot(GlobalObject& global,
-                                                                   JSContext* cx,
                                                                    const nsAString& filePath,
                                                                    ErrorResult& rv);
 
   static void NondeterministicGetWeakMapKeys(GlobalObject& aGlobal,
                                              JS::Handle<JS::Value> aMap,
                                              JS::MutableHandle<JS::Value> aRetval,
                                              ErrorResult& aRv);
 };
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1335,17 +1335,16 @@ DOMInterfaces = {
     'implicitJSContext': ['send']
 },
 
 'ThreadSafeChromeUtils': {
     # The codegen is dumb, and doesn't understand that this interface is only a
     # collection of static methods, so we have this `concrete: False` hack.
     'concrete': False,
     'headerFile': 'mozilla/dom/ChromeUtils.h',
-    'implicitJSContext': ['readHeapSnapshot', 'saveHeapSnapshot']
 },
 
 'TouchList': {
     'headerFile': 'mozilla/dom/TouchEvent.h',
 },
 
 'TreeColumn': {
     'nativeType': 'nsTreeColumn',