Bug 1529298 - Inline the contents of a fresh |if (true) { ... }| in ArrayBufferObject::createForContent. r=sfink
authorJeff Walden <jwalden@mit.edu>
Wed, 20 Feb 2019 13:33:16 -0800
changeset 519503 f4101f4427821666a773c683fc893e977c81946b
parent 519502 870a5571096968b606babc8eb1f7c495c18ddf1c
child 519504 a06864bc83520a544a3412f81b5d3ef0e930138b
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1529298
milestone67.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 1529298 - Inline the contents of a fresh |if (true) { ... }| in ArrayBufferObject::createForContent. r=sfink
js/src/vm/ArrayBufferObject.cpp
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -1254,42 +1254,40 @@ ArrayBufferObject* ArrayBufferObject::cr
   }
 
   // Some |contents| kinds need to store extra data in the ArrayBuffer beyond a
   // data pointer.  If needed for the particular kind, add extra fixed slots to
   // the ArrayBuffer for use as raw storage to store such information.
   size_t reservedSlots = JSCLASS_RESERVED_SLOTS(&class_);
 
   size_t nslots = reservedSlots;
-  if (true) {
-    if (contents.kind() == USER_OWNED) {
-      // No accounting to do in this case.
-    } else if (contents.kind() == EXTERNAL) {
-      // Store the FreeInfo in the inline data slots so that we
-      // don't use up slots for it in non-refcounted array buffers.
-      size_t freeInfoSlots = JS_HOWMANY(sizeof(FreeInfo), sizeof(Value));
-      MOZ_ASSERT(reservedSlots + freeInfoSlots <= NativeObject::MAX_FIXED_SLOTS,
-                 "FreeInfo must fit in inline slots");
-      nslots += freeInfoSlots;
+  if (contents.kind() == USER_OWNED) {
+    // No accounting to do in this case.
+  } else if (contents.kind() == EXTERNAL) {
+    // Store the FreeInfo in the inline data slots so that we
+    // don't use up slots for it in non-refcounted array buffers.
+    size_t freeInfoSlots = JS_HOWMANY(sizeof(FreeInfo), sizeof(Value));
+    MOZ_ASSERT(reservedSlots + freeInfoSlots <= NativeObject::MAX_FIXED_SLOTS,
+               "FreeInfo must fit in inline slots");
+    nslots += freeInfoSlots;
+  } else {
+    // The ABO is taking ownership, so account the bytes against the zone.
+    size_t nAllocated = nbytes;
+    if (contents.kind() == MAPPED) {
+      nAllocated = JS_ROUNDUP(nbytes, js::gc::SystemPageSize());
     } else {
-      // The ABO is taking ownership, so account the bytes against the zone.
-      size_t nAllocated = nbytes;
-      if (contents.kind() == MAPPED) {
-        nAllocated = JS_ROUNDUP(nbytes, js::gc::SystemPageSize());
-      } else {
-        MOZ_ASSERT(contents.kind() == MALLOCED,
-                   "should have handled all possible callers' kinds");
-      }
+      MOZ_ASSERT(contents.kind() == MALLOCED,
+                 "should have handled all possible callers' kinds");
+    }
 
-      // "mapped" bytes are fed into a "malloc" counter because (bug 1037358)
-      // this counter constitutes an input to the "when do we GC?" subsystem.
-      // Arguably it deserves renaming to something that doesn't narrowly cabin
-      // it to just "malloc" stuff, if we're going to use it this way.
-      cx->updateMallocCounter(nAllocated);
-    }
+    // "mapped" bytes are fed into a "malloc" counter because (bug 1037358) this
+    // counter constitutes an input to the "when do we GC?" subsystem.  Arguably
+    // it deserves renaming to something that doesn't narrowly cabin it to just
+    // "malloc" stuff, if we're going to use it this way.
+    cx->updateMallocCounter(nAllocated);
   }
 
   MOZ_ASSERT(!(class_.flags & JSCLASS_HAS_PRIVATE));
   gc::AllocKind allocKind = gc::GetGCObjectKind(nslots);
 
   AutoSetNewObjectMetadata metadata(cx);
   Rooted<ArrayBufferObject*> buffer(
       cx, NewObjectWithClassProto<ArrayBufferObject>(cx, nullptr, allocKind,