Bug 1064543 - Don't emit FilterTypeSet if it wouldn't remove any types. r=h4writer
authorJohannes Schulte <j_schulte@outlook.com>
Fri, 26 Feb 2016 16:30:47 +0100
changeset 286150 017122d17ff039ada9efdafc1582f530bbcfa0c4
parent 286149 90e6fc7313684e6f875500b6b6b9e4ec2fdda171
child 286151 47edc016cd4a5afeb579b0c4ec86292484916cdb
push id72675
push userryanvm@gmail.com
push dateTue, 01 Mar 2016 05:39:40 +0000
treeherdermozilla-inbound@47edc016cd4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1064543
milestone47.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 1064543 - Don't emit FilterTypeSet if it wouldn't remove any types. r=h4writer
js/src/jit/IonBuilder.cpp
js/src/vm/TypeInference.h
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -3533,18 +3533,25 @@ IonBuilder::tableSwitch(JSOp op, jssrcno
 }
 
 bool
 IonBuilder::replaceTypeSet(MDefinition* subject, TemporaryTypeSet* type, MTest* test)
 {
     if (type->unknown())
         return true;
 
-    if (subject->resultTypeSet() && type->equals(subject->resultTypeSet()))
-        return true;
+    // Don't emit MFilterTypeSet if it doesn't improve the typeset.
+    if (subject->resultTypeSet()) {
+        if (subject->resultTypeSet()->equals(type))
+            return true;
+    } else {
+        TemporaryTypeSet oldTypes(alloc_->lifoAlloc(), subject->type());
+        if (oldTypes.equals(type))
+            return true;
+    }
 
     MInstruction* replace = nullptr;
     MDefinition* ins;
 
     for (uint32_t i = 0; i < current->stackDepth(); i++) {
         ins = current->getSlot(i);
 
         // Instead of creating a new MFilterTypeSet, try to update the old one.
--- a/js/src/vm/TypeInference.h
+++ b/js/src/vm/TypeInference.h
@@ -658,16 +658,22 @@ class TemporaryTypeSet : public TypeSet
     TemporaryTypeSet() {}
     TemporaryTypeSet(LifoAlloc* alloc, Type type);
 
     TemporaryTypeSet(uint32_t flags, ObjectKey** objectSet) {
         this->flags = flags;
         this->objectSet = objectSet;
     }
 
+    TemporaryTypeSet(LifoAlloc* alloc, jit::MIRType type)
+      : TemporaryTypeSet(alloc, PrimitiveType(ValueTypeFromMIRType(type)))
+    {
+        MOZ_ASSERT(type != jit::MIRType_Value);
+    }
+
     /*
      * Constraints for JIT compilation.
      *
      * Methods for JIT compilation. These must be used when a script is
      * currently being compiled (see AutoEnterCompilation) and will add
      * constraints ensuring that if the return value change in the future due
      * to new type information, the script's jitcode will be discarded.
      */