Bug 1531073: Inline ArrayIteratorPrototypeOptimizable with a constant when possible. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 27 Feb 2019 09:51:33 -0800
changeset 520634 14d519134002121d40c8fe43384c66d7070420b0
parent 520633 2a58c63890ccdbbeb846c45dea03cf35b566ebdc
child 520635 940349bea8e88038b8f3727ea225b6ad9aa2bbd2
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1531073
milestone67.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 1531073: Inline ArrayIteratorPrototypeOptimizable with a constant when possible. r=jandem
js/src/jit/InlinableNatives.h
js/src/jit/IonBuilder.h
js/src/jit/MCallOptimize.cpp
js/src/vm/SelfHosting.cpp
--- a/js/src/jit/InlinableNatives.h
+++ b/js/src/jit/InlinableNatives.h
@@ -131,16 +131,17 @@
   _(IntrinsicGetNextMapEntryForIterator)           \
                                                    \
   _(IntrinsicGuardToSetObject)                     \
   _(IntrinsicGetNextSetEntryForIterator)           \
                                                    \
   _(IntrinsicNewArrayIterator)                     \
   _(IntrinsicNewStringIterator)                    \
   _(IntrinsicNewRegExpStringIterator)              \
+  _(IntrinsicArrayIteratorPrototypeOptimizable)    \
                                                    \
   _(IntrinsicGuardToArrayBuffer)                   \
   _(IntrinsicArrayBufferByteLength)                \
   _(IntrinsicPossiblyWrappedArrayBufferByteLength) \
                                                    \
   _(IntrinsicGuardToSharedArrayBuffer)             \
                                                    \
   _(TypedArrayConstructor)                         \
--- a/js/src/jit/IonBuilder.h
+++ b/js/src/jit/IonBuilder.h
@@ -720,16 +720,17 @@ class IonBuilder : public MIRGenerator,
   InliningResult inlineArraySlice(CallInfo& callInfo);
   InliningResult inlineArrayJoin(CallInfo& callInfo);
 
   // Boolean natives.
   InliningResult inlineBoolean(CallInfo& callInfo);
 
   // Iterator intrinsics.
   InliningResult inlineNewIterator(CallInfo& callInfo, MNewIterator::Type type);
+  InliningResult inlineArrayIteratorPrototypeOptimizable(CallInfo& callInfo);
 
   // Math natives.
   InliningResult inlineMathAbs(CallInfo& callInfo);
   InliningResult inlineMathFloor(CallInfo& callInfo);
   InliningResult inlineMathCeil(CallInfo& callInfo);
   InliningResult inlineMathClz32(CallInfo& callInfo);
   InliningResult inlineMathRound(CallInfo& callInfo);
   InliningResult inlineMathSqrt(CallInfo& callInfo);
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -106,16 +106,18 @@ IonBuilder::InliningResult IonBuilder::i
     case InlinableNative::ArrayPush:
       return inlineArrayPush(callInfo);
     case InlinableNative::ArraySlice:
       return inlineArraySlice(callInfo);
 
     // Array intrinsics.
     case InlinableNative::IntrinsicNewArrayIterator:
       return inlineNewIterator(callInfo, MNewIterator::ArrayIterator);
+    case InlinableNative::IntrinsicArrayIteratorPrototypeOptimizable:
+      return inlineArrayIteratorPrototypeOptimizable(callInfo);
 
     // Atomic natives.
     case InlinableNative::AtomicsCompareExchange:
       return inlineAtomicsCompareExchange(callInfo);
     case InlinableNative::AtomicsExchange:
       return inlineAtomicsExchange(callInfo);
     case InlinableNative::AtomicsLoad:
       return inlineAtomicsLoad(callInfo);
@@ -1122,16 +1124,30 @@ IonBuilder::InliningResult IonBuilder::i
       MNewIterator::New(alloc(), constraints(), templateConst, type);
   current->add(ins);
   current->push(ins);
 
   MOZ_TRY(resumeAfter(ins));
   return InliningStatus_Inlined;
 }
 
+IonBuilder::InliningResult IonBuilder::inlineArrayIteratorPrototypeOptimizable(
+    CallInfo& callInfo) {
+  MOZ_ASSERT(!callInfo.constructing());
+  MOZ_ASSERT(callInfo.argc() == 0);
+
+  if (!ensureArrayIteratorPrototypeNextNotModified()) {
+    return InliningStatus_NotInlined;
+  }
+
+  callInfo.setImplicitlyUsedUnchecked();
+  pushConstant(BooleanValue(true));
+  return InliningStatus_Inlined;
+}
+
 IonBuilder::InliningResult IonBuilder::inlineMathAbs(CallInfo& callInfo) {
   if (callInfo.argc() != 1 || callInfo.constructing()) {
     trackOptimizationOutcome(TrackedOutcome::CantInlineNativeBadForm);
     return InliningStatus_NotInlined;
   }
 
   MIRType returnType = getInlineReturnType();
   MIRType argType = callInfo.getArg(0)->type();
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -2496,18 +2496,19 @@ static const JSFunctionSpec intrinsic_fu
                     intrinsic_UnsafeGetBooleanFromReservedSlot, 2, 0,
                     IntrinsicUnsafeGetBooleanFromReservedSlot),
 
     JS_INLINABLE_FN("IsPackedArray", intrinsic_IsPackedArray, 1, 0,
                     IntrinsicIsPackedArray),
 
     JS_INLINABLE_FN("NewArrayIterator", intrinsic_NewArrayIterator, 0, 0,
                     IntrinsicNewArrayIterator),
-    JS_FN("ArrayIteratorPrototypeOptimizable",
-          intrinsic_ArrayIteratorPrototypeOptimizable, 0, 0),
+    JS_INLINABLE_FN("ArrayIteratorPrototypeOptimizable",
+                    intrinsic_ArrayIteratorPrototypeOptimizable, 0, 0,
+                    IntrinsicArrayIteratorPrototypeOptimizable),
 
     JS_FN("CallArrayIteratorMethodIfWrapped",
           CallNonGenericSelfhostedMethod<Is<ArrayIteratorObject>>, 2, 0),
 
     JS_FN("_SetCanonicalName", intrinsic_SetCanonicalName, 2, 0),
 
     JS_INLINABLE_FN("GuardToArrayIterator",
                     intrinsic_GuardToBuiltin<ArrayIteratorObject>, 1, 0,