Bug 1322093 part 9 - Minor cleanup. r=evilpie
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 21 Dec 2016 17:37:48 +0100
changeset 452484 c845f579be3a952e01f3eb586529c174c086b4f0
parent 452483 308412053019c9379eb899378ef575e903d64cbe
child 452485 732bfa4cc97a919ea20fbb438cbb190fdb82b698
push id39415
push usermozilla@noorenberghe.ca
push dateWed, 21 Dec 2016 20:49:14 +0000
reviewersevilpie
bugs1322093
milestone53.0a1
Bug 1322093 part 9 - Minor cleanup. r=evilpie
js/src/jit/BaselineIC.cpp
js/src/jit/CacheIR.cpp
js/src/jit/CacheIR.h
js/src/jit/CacheIRCompiler.cpp
js/src/jit/CacheIRCompiler.h
js/src/jit/SharedIC.cpp
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -958,17 +958,17 @@ DoGetElemFallback(JSContext* cx, Baselin
         stub->noteUnoptimizableAccess();
         attached = true;
     }
 
     bool isTemporarilyUnoptimizable = false;
     if (!attached && !JitOptions.disableCacheIR) {
         ICStubEngine engine = ICStubEngine::Baseline;
         GetPropIRGenerator gen(cx, pc, engine, CacheKind::GetElem, &isTemporarilyUnoptimizable,
-                               lhs, rhs, res);
+                               lhs, rhs);
         if (gen.tryAttachStub()) {
             ICStub* newStub = AttachBaselineCacheIRStub(cx, gen.writerRef(), gen.cacheKind(),
                                                         engine, info.outerScript(cx), stub);
             if (newStub) {
                 JitSpew(JitSpew_BaselineIC, "  Attached CacheIR stub");
                 attached = true;
                 if (gen.shouldNotePreliminaryObjectStub())
                     newStub->toCacheIR_Monitored()->notePreliminaryObject();
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -16,24 +16,22 @@
 using namespace js;
 using namespace js::jit;
 
 using mozilla::Maybe;
 
 GetPropIRGenerator::GetPropIRGenerator(JSContext* cx, jsbytecode* pc, ICStubEngine engine,
                                        CacheKind cacheKind,
                                        bool* isTemporarilyUnoptimizable,
-                                       HandleValue val, HandleValue idVal,
-                                       MutableHandleValue res)
+                                       HandleValue val, HandleValue idVal)
   : writer(cx),
     cx_(cx),
     pc_(pc),
     val_(val),
     idVal_(idVal),
-    res_(res),
     engine_(engine),
     cacheKind_(cacheKind),
     isTemporarilyUnoptimizable_(isTemporarilyUnoptimizable),
     preliminaryObjectAction_(PreliminaryObjectAction::None)
 {}
 
 static void
 EmitLoadSlotResult(CacheIRWriter& writer, ObjOperandId holderOp, NativeObject* holder,
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -362,22 +362,25 @@ class MOZ_RAII CacheIRWriter : public JS
     bool stubDataEquals(const uint8_t* stubData) const;
 
     bool operandIsDead(uint32_t operandId, uint32_t currentInstruction) const {
         if (operandId >= operandLastUsed_.length())
             return false;
         return currentInstruction > operandLastUsed_[operandId];
     }
     const uint8_t* codeStart() const {
+        MOZ_ASSERT(!failed());
         return buffer_.buffer();
     }
     const uint8_t* codeEnd() const {
+        MOZ_ASSERT(!failed());
         return buffer_.buffer() + buffer_.length();
     }
     uint32_t codeLength() const {
+        MOZ_ASSERT(!failed());
         return buffer_.length();
     }
 
     ObjOperandId guardIsObject(ValOperandId val) {
         writeOpWithOperandId(CacheOp::GuardIsObject, val);
         return ObjOperandId(val.id());
     }
     StringOperandId guardIsString(ValOperandId val) {
@@ -656,17 +659,16 @@ class MOZ_RAII CacheIRReader
 // GetPropIRGenerator generates CacheIR for a GetProp IC.
 class MOZ_RAII GetPropIRGenerator
 {
     CacheIRWriter writer;
     JSContext* cx_;
     jsbytecode* pc_;
     HandleValue val_;
     HandleValue idVal_;
-    MutableHandleValue res_;
     ICStubEngine engine_;
     CacheKind cacheKind_;
     bool* isTemporarilyUnoptimizable_;
 
     enum class PreliminaryObjectAction { None, Unlink, NotePreliminary };
     PreliminaryObjectAction preliminaryObjectAction_;
 
     bool tryAttachNative(HandleObject obj, ObjOperandId objId, HandleId id);
@@ -705,17 +707,17 @@ class MOZ_RAII GetPropIRGenerator
     void maybeEmitIdGuard(jsid id);
 
     GetPropIRGenerator(const GetPropIRGenerator&) = delete;
     GetPropIRGenerator& operator=(const GetPropIRGenerator&) = delete;
 
   public:
     GetPropIRGenerator(JSContext* cx, jsbytecode* pc, ICStubEngine engine, CacheKind cacheKind,
                        bool* isTemporarilyUnoptimizable,
-                       HandleValue val, HandleValue idVal, MutableHandleValue res);
+                       HandleValue val, HandleValue idVal);
 
     bool tryAttachStub();
 
     bool shouldUnlinkPreliminaryObjectStubs() const {
         return preliminaryObjectAction_ == PreliminaryObjectAction::Unlink;
     }
     bool shouldNotePreliminaryObjectStub() const {
         return preliminaryObjectAction_ == PreliminaryObjectAction::NotePreliminary;
--- a/js/src/jit/CacheIRCompiler.cpp
+++ b/js/src/jit/CacheIRCompiler.cpp
@@ -562,16 +562,18 @@ static void
 InitGCPtr(uintptr_t* ptr, V val)
 {
     AsGCPtr<T>(ptr)->init(mozilla::BitwiseCast<T>(val));
 }
 
 void
 CacheIRWriter::copyStubData(uint8_t* dest) const
 {
+    MOZ_ASSERT(!failed());
+
     uintptr_t* destWords = reinterpret_cast<uintptr_t*>(dest);
 
     for (const StubField& field : stubFields_) {
         switch (field.type()) {
           case StubField::Type::RawWord:
             *destWords = field.asWord();
             break;
           case StubField::Type::Shape:
@@ -603,16 +605,18 @@ CacheIRWriter::copyStubData(uint8_t* des
         }
         destWords += StubField::sizeInBytes(field.type()) / sizeof(uintptr_t);
     }
 }
 
 bool
 CacheIRWriter::stubDataEquals(const uint8_t* stubData) const
 {
+    MOZ_ASSERT(!failed());
+
     const uintptr_t* stubDataWords = reinterpret_cast<const uintptr_t*>(stubData);
 
     for (const StubField& field : stubFields_) {
         if (field.sizeIsWord()) {
             if (field.asWord() != *stubDataWords)
                 return false;
             stubDataWords++;
             continue;
--- a/js/src/jit/CacheIRCompiler.h
+++ b/js/src/jit/CacheIRCompiler.h
@@ -350,17 +350,19 @@ class MOZ_RAII CacheIRCompiler
     CacheRegisterAllocator allocator;
     Vector<FailurePath, 4, SystemAllocPolicy> failurePaths;
 
     CacheIRCompiler(JSContext* cx, const CacheIRWriter& writer)
       : cx_(cx),
         reader(writer),
         writer_(writer),
         allocator(writer_)
-    {}
+    {
+        MOZ_ASSERT(!writer.failed());
+    }
 
     MOZ_MUST_USE bool addFailurePath(FailurePath** failure);
 
     void emitFailurePath(size_t index);
 
 #define DEFINE_SHARED_OP(op) MOZ_MUST_USE bool emit##op();
     CACHE_IR_SHARED_OPS(DEFINE_SHARED_OP)
 #undef DEFINE_SHARED_OP
--- a/js/src/jit/SharedIC.cpp
+++ b/js/src/jit/SharedIC.cpp
@@ -2320,17 +2320,17 @@ DoGetPropFallback(JSContext* cx, void* p
             return false;
         stub->addNewStub(newStub);
         attached = true;
     }
 
     if (!attached && !JitOptions.disableCacheIR) {
         RootedValue idVal(cx, StringValue(name));
         GetPropIRGenerator gen(cx, pc, engine, CacheKind::GetProp, &isTemporarilyUnoptimizable,
-                               val, idVal, res);
+                               val, idVal);
         if (gen.tryAttachStub()) {
             ICStub* newStub = AttachBaselineCacheIRStub(cx, gen.writerRef(), gen.cacheKind(),
                                                         engine, info.outerScript(cx), stub);
             if (newStub) {
                 JitSpew(JitSpew_BaselineIC, "  Attached CacheIR stub");
                 attached = true;
                 if (gen.shouldNotePreliminaryObjectStub())
                     newStub->toCacheIR_Monitored()->notePreliminaryObject();