Bug 1599416 - Part 11: Remove constant parameters. r=mgaudet
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 27 Nov 2019 13:58:09 +0000
changeset 504061 27b601310b36bd37243a4b0e8600533d1f052e68
parent 504060 f98095b88847ac5ce7693dde47d1ff28528cce9a
child 504062 12b167e83eddd8a1542ccbca9c8b404e37dbc847
push id101711
push useraciure@mozilla.com
push dateWed, 27 Nov 2019 14:49:56 +0000
treeherderautoland@7a5a3cbc9b5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1599416
milestone72.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 1599416 - Part 11: Remove constant parameters. r=mgaudet The `length` parameter is always `1`. Differential Revision: https://phabricator.services.mozilla.com/D54715
js/src/builtin/TypedObject.cpp
js/src/builtin/TypedObject.h
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -1651,17 +1651,17 @@ TypedObject* TypedObject::createZeroed(J
   if (InlineTypedObject::canAccommodateType(descr)) {
     AutoSetNewObjectMetadata metadata(cx);
 
     InlineTypedObject* obj = InlineTypedObject::create(cx, descr, heap);
     if (!obj) {
       return nullptr;
     }
     JS::AutoCheckCannotGC nogc(cx);
-    descr->initInstances(cx->runtime(), obj->inlineTypedMem(nogc), 1);
+    descr->initInstance(cx->runtime(), obj->inlineTypedMem(nogc));
     return obj;
   }
 
   // Create unattached wrapper object.
   Rooted<OutlineTypedObject*> obj(
       cx, OutlineTypedObject::createUnattached(cx, descr, heap));
   if (!obj) {
     return nullptr;
@@ -1669,17 +1669,17 @@ TypedObject* TypedObject::createZeroed(J
 
   // Allocate and initialize the memory for this instance.
   size_t totalSize = descr->size();
   Rooted<ArrayBufferObject*> buffer(cx);
   buffer = ArrayBufferObject::createForTypedObject(cx, totalSize);
   if (!buffer) {
     return nullptr;
   }
-  descr->initInstances(cx->runtime(), buffer->dataPointer(), 1);
+  descr->initInstance(cx->runtime(), buffer->dataPointer());
   obj->attach(cx, *buffer, 0);
   return obj;
 }
 
 /* static */
 void OutlineTypedObject::obj_trace(JSTracer* trc, JSObject* object) {
   OutlineTypedObject& typedObj = object->as<OutlineTypedObject>();
 
@@ -1713,17 +1713,17 @@ void OutlineTypedObject::obj_trace(JSTra
                                         /* direct = */ false);
     }
   }
 
   if (!descr.opaque() || !typedObj.isAttached()) {
     return;
   }
 
-  descr.traceInstances(trc, newData, 1);
+  descr.traceInstance(trc, newData);
 }
 
 bool TypeDescr::hasProperty(const JSAtomState& names, jsid id) {
   switch (kind()) {
     case type::Scalar:
     case type::Reference:
       return false;
 
@@ -2180,17 +2180,17 @@ void InlineTypedObject::obj_trace(JSTrac
 
   // Inline transparent objects do not have references and do not need more
   // tracing. If there is an entry in the compartment's LazyArrayBufferTable,
   // tracing that reference will be taken care of by the table itself.
   if (typedObj.is<InlineTransparentTypedObject>()) {
     return;
   }
 
-  typedObj.typeDescr().traceInstances(trc, typedObj.inlineTypedMem(), 1);
+  typedObj.typeDescr().traceInstance(trc, typedObj.inlineTypedMem());
 }
 
 /* static */
 size_t InlineTypedObject::obj_moved(JSObject* dst, JSObject* src) {
   if (!IsInsideNursery(src)) {
     return 0;
   }
 
@@ -2781,34 +2781,24 @@ void MemoryInitVisitor::visitReference(R
       stringPtr->init(rt_->emptyString);
       return;
     }
   }
 
   MOZ_CRASH("Invalid kind");
 }
 
-void TypeDescr::initInstances(const JSRuntime* rt, uint8_t* mem,
-                              size_t length) {
-  MOZ_ASSERT(length >= 1);
-
+void TypeDescr::initInstance(const JSRuntime* rt, uint8_t* mem) {
   MemoryInitVisitor visitor(rt);
 
-  // Initialize the 0th instance
+  // Initialize the instance
   memset(mem, 0, size());
   if (opaque()) {
     visitReferences(*this, mem, visitor);
   }
-
-  // Stamp out N copies of later instances
-  uint8_t* target = mem;
-  for (size_t i = 1; i < length; i++) {
-    target += size();
-    memcpy(target, mem, size());
-  }
 }
 
 ///////////////////////////////////////////////////////////////////////////
 // Tracing instances
 
 namespace {
 
 class MemoryTracingVisitor {
@@ -2845,23 +2835,20 @@ void MemoryTracingVisitor::visitReferenc
       TraceNullableEdge(trace_, stringPtr, "reference-str");
       return;
     }
   }
 
   MOZ_CRASH("Invalid kind");
 }
 
-void TypeDescr::traceInstances(JSTracer* trace, uint8_t* mem, size_t length) {
+void TypeDescr::traceInstance(JSTracer* trace, uint8_t* mem) {
   MemoryTracingVisitor visitor(trace);
 
-  for (size_t i = 0; i < length; i++) {
-    visitReferences(*this, mem, visitor);
-    mem += size();
-  }
+  visitReferences(*this, mem, visitor);
 }
 
 namespace {
 
 struct TraceListVisitor {
   typedef Vector<int32_t, 0, SystemAllocPolicy> VectorType;
   VectorType stringOffsets, objectOffsets, valueOffsets;
 
--- a/js/src/builtin/TypedObject.h
+++ b/js/src/builtin/TypedObject.h
@@ -192,18 +192,18 @@ class TypeDescr : public NativeObject {
     return !getFixedSlot(JS_DESCR_SLOT_TRACE_LIST).isUndefined();
   }
   const uint32_t* traceList() const {
     MOZ_ASSERT(hasTraceList());
     return reinterpret_cast<uint32_t*>(
         getFixedSlot(JS_DESCR_SLOT_TRACE_LIST).toPrivate());
   }
 
-  void initInstances(const JSRuntime* rt, uint8_t* mem, size_t length);
-  void traceInstances(JSTracer* trace, uint8_t* mem, size_t length);
+  void initInstance(const JSRuntime* rt, uint8_t* mem);
+  void traceInstance(JSTracer* trace, uint8_t* mem);
 
   static void finalize(JSFreeOp* fop, JSObject* obj);
 };
 
 typedef Handle<TypeDescr*> HandleTypeDescr;
 
 class SimpleTypeDescr : public TypeDescr {};