Bug 1480524 - [Part 3] Move ICNewObject_Fallback out of SharedIC and remove non-CacheIR code generation r=jandem
authorMatthew Gaudet <mgaudet@mozilla.com>
Tue, 07 Aug 2018 15:31:19 -0400
changeset 431570 2e79db1588c29cf4767c92834e5e5ab1f250d07f
parent 431569 ab47d3f47325f9c3a1575a406c4b0748e0eed333
child 431571 c15aebdde5e38df3d203799b5d8a55c8250223d8
push id106482
push usermgaudet@mozilla.com
push dateTue, 14 Aug 2018 22:26:00 +0000
treeherdermozilla-inbound@2e79db1588c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1480524
milestone63.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 1480524 - [Part 3] Move ICNewObject_Fallback out of SharedIC and remove non-CacheIR code generation r=jandem
js/src/jit/BaselineIC.cpp
js/src/jit/BaselineIC.h
js/src/jit/SharedIC.cpp
js/src/jit/SharedIC.h
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -5183,11 +5183,76 @@ ICNewArray_Fallback::Compiler::generateS
 
     masm.push(R0.scratchReg()); // length
     masm.push(ICStubReg); // stub.
     masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
 
     return tailCallVM(DoNewArrayInfo, masm);
 }
 
+//
+// NewObject_Fallback
+//
+static bool
+DoNewObject(JSContext* cx, void* payload, ICNewObject_Fallback* stub, MutableHandleValue res)
+{
+    SharedStubInfo info(cx, payload, stub->icEntry());
+
+    FallbackICSpew(cx, stub, "NewObject");
+
+    RootedObject obj(cx);
+
+    RootedObject templateObject(cx, stub->templateObject());
+    if (templateObject) {
+        MOZ_ASSERT(!templateObject->group()->maybePreliminaryObjectsDontCheckGeneration());
+        obj = NewObjectOperationWithTemplate(cx, templateObject);
+    } else {
+        HandleScript script = info.script();
+        jsbytecode* pc = info.pc();
+        obj = NewObjectOperation(cx, script, pc);
+
+        if (obj && !obj->isSingleton() &&
+            !obj->group()->maybePreliminaryObjectsDontCheckGeneration())
+        {
+            templateObject = NewObjectOperation(cx, script, pc, TenuredObject);
+            if (!templateObject)
+                return false;
+
+            if (!JitOptions.disableCacheIR) {
+                bool attached = false;
+                RootedScript script(cx, info.outerScript(cx));
+                NewObjectIRGenerator gen(cx, script, pc, stub->state().mode(), JSOp(*pc), templateObject);
+                if (gen.tryAttachStub()) {
+                    ICStub* newStub = AttachBaselineCacheIRStub(cx, gen.writerRef(), gen.cacheKind(),
+                                                                BaselineCacheIRStubKind::Regular,
+                                                                ICStubEngine::Baseline , script, stub, &attached);
+                    if (newStub)
+                        JitSpew(JitSpew_BaselineIC, "  NewObject Attached CacheIR stub");
+                }
+            }
+            stub->setTemplateObject(templateObject);
+        }
+    }
+
+    if (!obj)
+        return false;
+
+    res.setObject(*obj);
+    return true;
+}
+
+typedef bool(*DoNewObjectFn)(JSContext*, void*, ICNewObject_Fallback*, MutableHandleValue);
+static const VMFunction DoNewObjectInfo =
+    FunctionInfo<DoNewObjectFn>(DoNewObject, "DoNewObject", TailCall);
+
+bool
+ICNewObject_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
+{
+    EmitRestoreTailCallReg(masm);
+
+    masm.push(ICStubReg); // stub.
+    pushStubPayload(masm, R0.scratchReg());
+
+    return tailCallVM(DoNewObjectInfo, masm);
+}
 
 } // namespace jit
 } // namespace js
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -1602,16 +1602,52 @@ class ICNewArray_Fallback : public ICFal
     }
 
     void setTemplateGroup(ObjectGroup* group) {
         templateObject_ = nullptr;
         templateGroup_ = group;
     }
 };
 
+
+// JSOP_NEWOBJECT
+
+class ICNewObject_Fallback : public ICFallbackStub
+{
+    friend class ICStubSpace;
+
+    GCPtrObject templateObject_;
+
+    explicit ICNewObject_Fallback(JitCode* stubCode)
+      : ICFallbackStub(ICStub::NewObject_Fallback, stubCode), templateObject_(nullptr)
+    {}
+
+  public:
+    class Compiler : public ICStubCompiler {
+        MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm) override;
+
+      public:
+        explicit Compiler(JSContext* cx, Engine engine)
+          : ICStubCompiler(cx, ICStub::NewObject_Fallback, engine)
+        {}
+
+        ICStub* getStub(ICStubSpace* space) override {
+            return newStub<ICNewObject_Fallback>(space, getStubCode());
+        }
+    };
+
+    GCPtrObject& templateObject() {
+        return templateObject_;
+    }
+
+    void setTemplateObject(JSObject* obj) {
+        templateObject_ = obj;
+    }
+};
+
 inline bool
 IsCacheableDOMProxy(JSObject* obj)
 {
     if (!obj->is<ProxyObject>())
         return false;
 
     const BaseProxyHandler* handler = obj->as<ProxyObject>().handler();
     return handler->family() == GetDOMProxyHandlerFamily();
--- a/js/src/jit/SharedIC.cpp
+++ b/js/src/jit/SharedIC.cpp
@@ -1180,126 +1180,10 @@ ICUpdatedStub::addUpdateStubForValue(JSC
                 stub, group.get());
 
         addOptimizedUpdateStub(stub);
     }
 
     return true;
 }
 
-//
-// NewObject_Fallback
-//
-
-// Unlike typical baseline IC stubs, the code for NewObject_WithTemplate is
-// specialized for the template object being allocated.
-static JitCode*
-GenerateNewObjectWithTemplateCode(JSContext* cx, JSObject* templateObject)
-{
-    JitContext jctx(cx, nullptr);
-    StackMacroAssembler masm;
-#ifdef JS_CODEGEN_ARM
-    masm.setSecondScratchReg(BaselineSecondScratchReg);
-#endif
-
-    Label failure;
-    Register objReg = R0.scratchReg();
-    Register tempReg = R1.scratchReg();
-    masm.branchIfPretenuredGroup(templateObject->group(), tempReg, &failure);
-    masm.branchPtr(Assembler::NotEqual, AbsoluteAddress(cx->realm()->addressOfMetadataBuilder()),
-                   ImmWord(0), &failure);
-    TemplateObject templateObj(templateObject);
-    masm.createGCObject(objReg, tempReg, templateObj, gc::DefaultHeap, &failure);
-    masm.tagValue(JSVAL_TYPE_OBJECT, objReg, R0);
-
-    EmitReturnFromIC(masm);
-    masm.bind(&failure);
-    EmitStubGuardFailure(masm);
-
-    Linker linker(masm);
-    AutoFlushICache afc("GenerateNewObjectWithTemplateCode");
-    return linker.newCode(cx, CodeKind::Baseline);
-}
-
-static bool
-DoNewObject(JSContext* cx, void* payload, ICNewObject_Fallback* stub, MutableHandleValue res)
-{
-    SharedStubInfo info(cx, payload, stub->icEntry());
-
-    FallbackICSpew(cx, stub, "NewObject");
-
-    RootedObject obj(cx);
-
-    RootedObject templateObject(cx, stub->templateObject());
-    if (templateObject) {
-        MOZ_ASSERT(!templateObject->group()->maybePreliminaryObjectsDontCheckGeneration());
-        obj = NewObjectOperationWithTemplate(cx, templateObject);
-    } else {
-        HandleScript script = info.script();
-        jsbytecode* pc = info.pc();
-        obj = NewObjectOperation(cx, script, pc);
-
-        if (obj && !obj->isSingleton() &&
-            !obj->group()->maybePreliminaryObjectsDontCheckGeneration())
-        {
-            templateObject = NewObjectOperation(cx, script, pc, TenuredObject);
-            if (!templateObject)
-                return false;
-
-            ICStubCompiler::Engine engine = info.engine();
-            if (engine ==  ICStubEngine::Baseline && !JitOptions.disableCacheIR) {
-                bool attached = false;
-                RootedScript script(cx, info.outerScript(cx));
-                NewObjectIRGenerator gen(cx, script, pc, stub->state().mode(), JSOp(*pc), templateObject);
-                if (gen.tryAttachStub()) {
-                    ICStub* newStub = AttachBaselineCacheIRStub(cx, gen.writerRef(), gen.cacheKind(),
-                                                                BaselineCacheIRStubKind::Regular,
-                                                                ICStubEngine::Baseline , script, stub, &attached);
-                    if (newStub)
-                        JitSpew(JitSpew_BaselineIC, "  NewObject Attached CacheIR stub");
-                }
-            } else {
-                if (!stub->invalid() &&
-                    (templateObject->is<UnboxedPlainObject>() ||
-                    !templateObject->as<PlainObject>().hasDynamicSlots()))
-                {
-                    JitCode* code = GenerateNewObjectWithTemplateCode(cx, templateObject);
-                    if (!code)
-                        return false;
-
-                    ICStubSpace* space =
-                        ICStubCompiler::StubSpaceForStub(/* makesGCCalls = */ false, script,
-                                                        ICStubCompiler::Engine::Baseline);
-                    ICStub* templateStub = ICStub::New<ICNewObject_WithTemplate>(cx, space, code);
-                    if (!templateStub)
-                        return false;
-
-                    stub->addNewStub(templateStub);
-                }
-            }
-            stub->setTemplateObject(templateObject);
-        }
-    }
-
-    if (!obj)
-        return false;
-
-    res.setObject(*obj);
-    return true;
-}
-
-typedef bool(*DoNewObjectFn)(JSContext*, void*, ICNewObject_Fallback*, MutableHandleValue);
-static const VMFunction DoNewObjectInfo =
-    FunctionInfo<DoNewObjectFn>(DoNewObject, "DoNewObject", TailCall);
-
-bool
-ICNewObject_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
-{
-    EmitRestoreTailCallReg(masm);
-
-    masm.push(ICStubReg); // stub.
-    pushStubPayload(masm, R0.scratchReg());
-
-    return tailCallVM(DoNewObjectInfo, masm);
-}
-
 } // namespace jit
 } // namespace js
--- a/js/src/jit/SharedIC.h
+++ b/js/src/jit/SharedIC.h
@@ -1774,56 +1774,12 @@ ScalarTypeFromSimpleTypeDescrKey(uint32_
 
 inline ReferenceType
 ReferenceTypeFromSimpleTypeDescrKey(uint32_t key)
 {
     MOZ_ASSERT(!SimpleTypeDescrKeyIsScalar(key));
     return ReferenceType(key >> 1);
 }
 
-// JSOP_NEWOBJECT
-
-class ICNewObject_Fallback : public ICFallbackStub
-{
-    friend class ICStubSpace;
-
-    GCPtrObject templateObject_;
-
-    explicit ICNewObject_Fallback(JitCode* stubCode)
-      : ICFallbackStub(ICStub::NewObject_Fallback, stubCode), templateObject_(nullptr)
-    {}
-
-  public:
-    class Compiler : public ICStubCompiler {
-        MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm) override;
-
-      public:
-        explicit Compiler(JSContext* cx, Engine engine)
-          : ICStubCompiler(cx, ICStub::NewObject_Fallback, engine)
-        {}
-
-        ICStub* getStub(ICStubSpace* space) override {
-            return newStub<ICNewObject_Fallback>(space, getStubCode());
-        }
-    };
-
-    GCPtrObject& templateObject() {
-        return templateObject_;
-    }
-
-    void setTemplateObject(JSObject* obj) {
-        templateObject_ = obj;
-    }
-};
-
-class ICNewObject_WithTemplate : public ICStub
-{
-    friend class ICStubSpace;
-
-    explicit ICNewObject_WithTemplate(JitCode* stubCode)
-      : ICStub(ICStub::NewObject_WithTemplate, stubCode)
-    {}
-};
-
 } // namespace jit
 } // namespace js
 
 #endif /* jit_SharedIC_h */