Bug 1658279 - Part 3: Don't create a template object for String when not constructing. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 14 Aug 2020 10:38:16 +0000
changeset 544637 37746b10f75c9940cf2d034f2b6f276b79cd2877
parent 544636 5e227e32ff865a2dd22d411666fd9ef5e623a14a
child 544638 9bfa6276ddc55be311c681960647e96317589a0d
push id37699
push usercbrindusan@mozilla.com
push dateFri, 14 Aug 2020 15:46:48 +0000
treeherdermozilla-central@9bfa6276ddc5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1658279
milestone81.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 1658279 - Part 3: Don't create a template object for String when not constructing. r=jandem Calling `String()` shouldn't create a template object. Differential Revision: https://phabricator.services.mozilla.com/D86534
js/src/jit/CacheIR.cpp
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -8804,16 +8804,18 @@ bool CallIRGenerator::getTemplateObjectF
     return true;
   }
 
   if (!calleeFunc->hasJitInfo() ||
       calleeFunc->jitInfo()->type() != JSJitInfo::InlinableNative) {
     return true;
   }
 
+  bool isConstructing = IsConstructOp(op_);
+
   // Check for natives to which template objects can be attached. This is
   // done to provide templates to Ion for inlining these natives later on.
   switch (calleeFunc->jitInfo()->inlinableNative) {
     case InlinableNative::Array: {
       // Note: the template array won't be used if its length is inaccurately
       // computed here.  (We allocate here because compilation may occur on a
       // separate thread where allocation is impossible.)
 
@@ -8855,16 +8857,20 @@ bool CallIRGenerator::getTemplateObjectF
         return true;
       }
 
       res.set(NewFullyAllocatedArrayTryReuseGroup(cx_, obj, 0, TenuredObject));
       return !!res;
     }
 
     case InlinableNative::String: {
+      if (!isConstructing) {
+        return true;
+      }
+
       RootedString emptyString(cx_, cx_->runtime()->emptyString);
       res.set(StringObject::create(cx_, emptyString, /* proto = */ nullptr,
                                    TenuredObject));
       return !!res;
     }
 
     default:
       return true;