Bug 1349298 - Add a stub limit to Baseline's TypeOf IC. r=h4writer a=gchang
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 24 Mar 2017 11:47:19 +0100
changeset 379294 cedc5c3f53b5409f3059e656baf4e5bfc5fd5ec7
parent 379293 1411f6a2c16364b7faa46b13d97abbc86ed30a96
child 379295 5ab83d9424cdb60ccbbdcb2849f640f06e4fd9a8
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer, gchang
bugs1349298
milestone53.0
Bug 1349298 - Add a stub limit to Baseline's TypeOf IC. r=h4writer a=gchang
js/src/jit-test/tests/baseline/bug1349298.js
js/src/jit/BaselineIC.cpp
js/src/jit/BaselineIC.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/baseline/bug1349298.js
@@ -0,0 +1,2 @@
+for (var i=0; i<40; i++)
+    assertEq(typeof objectEmulatingUndefined(), "undefined");
--- a/js/src/jit/BaselineIC.cpp
+++ b/js/src/jit/BaselineIC.cpp
@@ -6032,16 +6032,19 @@ DoTypeOfFallback(JSContext* cx, Baseline
                  MutableHandleValue res)
 {
     FallbackICSpew(cx, stub, "TypeOf");
     JSType type = js::TypeOfValue(val);
     RootedString string(cx, TypeName(type, cx->names()));
 
     res.setString(string);
 
+    if (stub->numOptimizedStubs() >= ICTypeOf_Fallback::MAX_OPTIMIZED_STUBS)
+        return true;
+
     MOZ_ASSERT(type != JSTYPE_NULL);
     if (type != JSTYPE_OBJECT && type != JSTYPE_FUNCTION) {
         // Create a new TypeOf stub.
         JitSpew(JitSpew_BaselineIC, "  Generating TypeOf stub for JSType (%d)", (int) type);
         ICTypeOf_Typed::Compiler compiler(cx, type, string);
         ICStub* typeOfStub = compiler.getStub(compiler.getStubSpace(frame->script()));
         if (!typeOfStub)
             return false;
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -2266,16 +2266,18 @@ class ICTypeOf_Fallback : public ICFallb
 {
     friend class ICStubSpace;
 
     explicit ICTypeOf_Fallback(JitCode* stubCode)
       : ICFallbackStub(ICStub::TypeOf_Fallback, stubCode)
     { }
 
   public:
+    static const uint32_t MAX_OPTIMIZED_STUBS = 6;
+
     class Compiler : public ICStubCompiler {
       protected:
         MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
 
       public:
         explicit Compiler(JSContext* cx)
           : ICStubCompiler(cx, ICStub::TypeOf_Fallback, Engine::Baseline)
         { }