Bug 1395509 - Track malloc memory used by FileObject objects r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 11 Jun 2019 17:03:41 +0100
changeset 543790 f7088c17e4233adca92208d73394721c8c71308b
parent 543789 4b1b5ac830370c57e2cd5050fae28471e749990f
child 543791 109ccdeb96342a315b86ef0c7ebe76738308673b
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1395509
milestone69.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 1395509 - Track malloc memory used by FileObject objects r=sfink Differential Revision: https://phabricator.services.mozilla.com/D34555
js/src/gc/GCEnum.h
js/src/shell/OSObject.cpp
--- a/js/src/gc/GCEnum.h
+++ b/js/src/gc/GCEnum.h
@@ -123,17 +123,18 @@ enum class ZealMode {
   _(WasmInstanceExports)                   \
   _(WasmInstanceScopes)                    \
   _(WasmInstanceGlobals)                   \
   _(WasmInstanceInstance)                  \
   _(WasmMemoryObservers)                   \
   _(WasmGlobalCell)                        \
   _(WasmResolveResponseClosure)            \
   _(WasmModule)                            \
-  _(WasmTableTable)
+  _(WasmTableTable)                        \
+  _(FileObjectFile)
 
 #define JS_FOR_EACH_MEMORY_USE(_)  \
   JS_FOR_EACH_PUBLIC_MEMORY_USE(_) \
   JS_FOR_EACH_INTERNAL_MEMORY_USE(_)
 
 enum class MemoryUse : uint8_t {
 #define DEFINE_MEMORY_USE(Name) Name,
   JS_FOR_EACH_MEMORY_USE(DEFINE_MEMORY_USE)
--- a/js/src/shell/OSObject.cpp
+++ b/js/src/shell/OSObject.cpp
@@ -420,26 +420,26 @@ class FileObject : public NativeObject {
   static const js::Class class_;
 
   static FileObject* create(JSContext* cx, RCFile* file) {
     FileObject* obj = js::NewBuiltinClassInstance<FileObject>(cx);
     if (!obj) {
       return nullptr;
     }
 
-    obj->setRCFile(file);
+    InitReservedSlot(obj, FILE_SLOT, file, MemoryUse::FileObjectFile);
     file->acquire();
     return obj;
   }
 
   static void finalize(FreeOp* fop, JSObject* obj) {
     FileObject* fileObj = &obj->as<FileObject>();
     RCFile* file = fileObj->rcFile();
+    RemoveCellMemory(obj, sizeof(*file), MemoryUse::FileObjectFile);
     if (file->release()) {
-      fileObj->setRCFile(nullptr);
       fop->delete_(file);
     }
   }
 
   bool isOpen() {
     RCFile* file = rcFile();
     return file && file->isOpen();
   }
@@ -450,21 +450,16 @@ class FileObject : public NativeObject {
     }
     rcFile()->close();
   }
 
   RCFile* rcFile() {
     return reinterpret_cast<RCFile*>(
         js::GetReservedSlot(this, FILE_SLOT).toPrivate());
   }
-
- private:
-  void setRCFile(RCFile* file) {
-    js::SetReservedSlot(this, FILE_SLOT, PrivateValue(file));
-  }
 };
 
 static const js::ClassOps FileObjectClassOps = {
     nullptr,              /* addProperty */
     nullptr,              /* delProperty */
     nullptr,              /* enumerate */
     nullptr,              /* newEnumerate */
     nullptr,              /* resolve */