Bug 1505574 - Clean out MObjectState r=iain
authorMatthew Gaudet <mgaudet@mozilla.com>
Fri, 22 Mar 2019 15:34:23 +0000
changeset 465725 136b21be1299f0ee657a4e6c4e95e626f706ea78
parent 465724 a19a0fc91ddcf99695e8cd25f7b85d0170bb3994
child 465726 89945a066c6602a8089a30a02d1e945a778428d8
push id35746
push usershindli@mozilla.com
push dateSat, 23 Mar 2019 09:46:24 +0000
treeherdermozilla-central@02b7484f316b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersiain
bugs1505574
milestone68.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 1505574 - Clean out MObjectState r=iain Differential Revision: https://phabricator.services.mozilla.com/D24250
js/src/jit/MIR.cpp
js/src/jit/MIR.h
js/src/jit/ScalarReplacement.cpp
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -4577,37 +4577,33 @@ bool MCreateThisWithTemplate::canRecover
   MOZ_ASSERT(
       !templateObject()->as<PlainObject>().denseElementsAreCopyOnWrite());
   return true;
 }
 
 MObjectState::MObjectState(MObjectState* state)
     : MVariadicInstruction(classOpcode),
       numSlots_(state->numSlots_),
-      numFixedSlots_(state->numFixedSlots_),
-      operandIndex_(state->operandIndex_) {
+      numFixedSlots_(state->numFixedSlots_) {
   // This instruction is only used as a summary for bailout paths.
   setResultType(MIRType::Object);
   setRecoveredOnBailout();
 }
 
-MObjectState::MObjectState(JSObject* templateObject,
-                           OperandIndexMap* operandIndex)
+MObjectState::MObjectState(JSObject* templateObject)
     : MVariadicInstruction(classOpcode) {
   // This instruction is only used as a summary for bailout paths.
   setResultType(MIRType::Object);
   setRecoveredOnBailout();
 
   MOZ_ASSERT(templateObject->is<NativeObject>());
 
   NativeObject* nativeObject = &templateObject->as<NativeObject>();
   numSlots_ = nativeObject->slotSpan();
   numFixedSlots_ = nativeObject->numFixedSlots();
-
-  operandIndex_ = operandIndex;
 }
 
 JSObject* MObjectState::templateObjectOf(MDefinition* obj) {
   if (obj->isNewObject()) {
     return obj->toNewObject()->templateObject();
   } else if (obj->isCreateThisWithTemplate()) {
     return obj->toCreateThisWithTemplate()->templateObject();
   } else if (obj->isNewCallObject()) {
@@ -4656,17 +4652,17 @@ bool MObjectState::initFromTemplateObjec
 
   return true;
 }
 
 MObjectState* MObjectState::New(TempAllocator& alloc, MDefinition* obj) {
   JSObject* templateObject = templateObjectOf(obj);
   MOZ_ASSERT(templateObject, "Unexpected object creation.");
 
-  MObjectState* res = new (alloc) MObjectState(templateObject, nullptr);
+  MObjectState* res = new (alloc) MObjectState(templateObject);
   if (!res || !res->init(alloc, obj)) {
     return nullptr;
   }
   return res;
 }
 
 MObjectState* MObjectState::Copy(TempAllocator& alloc, MObjectState* state) {
   MObjectState* res = new (alloc) MObjectState(state);
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -2488,22 +2488,19 @@ struct OperandIndexMap : public TempObje
 };
 
 // Represent the content of all slots of an object.  This instruction is not
 // lowered and is not used to generate code.
 class MObjectState : public MVariadicInstruction,
                      public NoFloatPolicyAfter<1>::Data {
  private:
   uint32_t numSlots_;
-  uint32_t numFixedSlots_;         // valid if isUnboxed() == false.
-  OperandIndexMap* operandIndex_;  // valid if isUnboxed() == true.
-
-  bool isUnboxed() const { return operandIndex_ != nullptr; }
-
-  MObjectState(JSObject* templateObject, OperandIndexMap* operandIndex);
+  uint32_t numFixedSlots_;
+
+  explicit MObjectState(JSObject* templateObject);
   explicit MObjectState(MObjectState* state);
 
   MOZ_MUST_USE bool init(TempAllocator& alloc, MDefinition* obj);
 
   void initSlot(uint32_t slot, MDefinition* def) { initOperand(slot + 1, def); }
 
  public:
   INSTRUCTION_HEADER(ObjectState)
@@ -2517,17 +2514,16 @@ class MObjectState : public MVariadicIns
   static MObjectState* Copy(TempAllocator& alloc, MObjectState* state);
 
   // As we might do read of uninitialized properties, we have to copy the
   // initial values from the template object.
   MOZ_MUST_USE bool initFromTemplateObject(TempAllocator& alloc,
                                            MDefinition* undefinedVal);
 
   size_t numFixedSlots() const {
-    MOZ_ASSERT(!isUnboxed());
     return numFixedSlots_;
   }
   size_t numSlots() const { return numSlots_; }
 
   MDefinition* getSlot(uint32_t slot) const { return getOperand(slot + 1); }
   void setSlot(uint32_t slot, MDefinition* def) {
     replaceOperand(slot + 1, def);
   }
@@ -2549,29 +2545,16 @@ class MObjectState : public MVariadicIns
   }
   MDefinition* getDynamicSlot(uint32_t slot) const {
     return getSlot(slot + numFixedSlots());
   }
   void setDynamicSlot(uint32_t slot, MDefinition* def) {
     setSlot(slot + numFixedSlots(), def);
   }
 
-  // Interface reserved for unboxed objects.
-  bool hasOffset(uint32_t offset) const {
-    MOZ_ASSERT(isUnboxed());
-    return offset < operandIndex_->map.length() &&
-           operandIndex_->map[offset] != 0;
-  }
-  MDefinition* getOffset(uint32_t offset) const {
-    return getOperand(operandIndex_->map[offset]);
-  }
-  void setOffset(uint32_t offset, MDefinition* def) {
-    replaceOperand(operandIndex_->map[offset], def);
-  }
-
   MOZ_MUST_USE bool writeRecoverData(
       CompactBufferWriter& writer) const override;
   bool canRecoverOnBailout() const override { return true; }
 };
 
 // Represent the contents of all elements of an array.  This instruction is not
 // lowered and is not used to generate code.
 class MArrayState : public MVariadicInstruction,
--- a/js/src/jit/ScalarReplacement.cpp
+++ b/js/src/jit/ScalarReplacement.cpp
@@ -311,18 +311,16 @@ class ObjectMemoryView : public MDefinit
   void visitLoadSlot(MLoadSlot* ins);
   void visitGuardShape(MGuardShape* ins);
   void visitGuardObjectGroup(MGuardObjectGroup* ins);
   void visitFunctionEnvironment(MFunctionEnvironment* ins);
   void visitLambda(MLambda* ins);
   void visitLambdaArrow(MLambdaArrow* ins);
 
  private:
-  void storeOffset(MInstruction* ins, size_t offset, MDefinition* value);
-  void loadOffset(MInstruction* ins, size_t offset);
   void visitObjectGuard(MInstruction* ins, MDefinition* operand);
 };
 
 /* static */ const char ObjectMemoryView::phaseName[] =
     "Scalar Replacement of Object";
 
 ObjectMemoryView::ObjectMemoryView(TempAllocator& alloc, MInstruction* obj)
     : alloc_(alloc),
@@ -670,42 +668,16 @@ void ObjectMemoryView::visitLambda(MLamb
 void ObjectMemoryView::visitLambdaArrow(MLambdaArrow* ins) {
   if (ins->environmentChain() != obj_) {
     return;
   }
 
   ins->setIncompleteObject();
 }
 
-void ObjectMemoryView::storeOffset(MInstruction* ins, size_t offset,
-                                   MDefinition* value) {
-  // Clone the state and update the slot value.
-  MOZ_ASSERT(state_->hasOffset(offset));
-  state_ = BlockState::Copy(alloc_, state_);
-  if (!state_) {
-    oom_ = true;
-    return;
-  }
-
-  state_->setOffset(offset, value);
-  ins->block()->insertBefore(ins, state_);
-
-  // Remove original instruction.
-  ins->block()->discard(ins);
-}
-
-void ObjectMemoryView::loadOffset(MInstruction* ins, size_t offset) {
-  // Replace load by the slot value.
-  MOZ_ASSERT(state_->hasOffset(offset));
-  ins->replaceAllUsesWith(state_->getOffset(offset));
-
-  // Remove original instruction.
-  ins->block()->discard(ins);
-}
-
 static bool IndexOf(MDefinition* ins, int32_t* res) {
   MOZ_ASSERT(ins->isLoadElement() || ins->isStoreElement());
   MDefinition* indexDef = ins->getOperand(1);  // ins->index();
   if (indexDef->isSpectreMaskIndex()) {
     indexDef = indexDef->toSpectreMaskIndex()->index();
   }
   if (indexDef->isBoundsCheck()) {
     indexDef = indexDef->toBoundsCheck()->index();