Bug 1405991 - rm unused FastInvoke and FastCallGuard. r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 05 Oct 2017 12:20:13 +0200
changeset 384683 20a732c189563f151377a6719f0447a9332ecd3d
parent 384682 df08c7645b1a855e6c68b30387f34cd680bb28c0
child 384684 41e1afcd3bd1f5c71765228accfb5c3854efe067
push id32634
push userkwierso@gmail.com
push dateFri, 06 Oct 2017 19:55:44 +0000
treeherdermozilla-central@2d7b8b5dd174 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1405991
milestone58.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 1405991 - rm unused FastInvoke and FastCallGuard. r=nbp
js/src/jit/Ion.cpp
js/src/jit/Ion.h
js/src/vm/Interpreter-inl.h
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -2741,43 +2741,16 @@ jit::Recompile(JSContext* cx, HandleScri
         if (status == Method_CantCompile)
             ForbidCompilation(cx, script);
         return status;
     }
 
     return Method_Compiled;
 }
 
-MethodStatus
-jit::CanEnterUsingFastInvoke(JSContext* cx, HandleScript script, uint32_t numActualArgs)
-{
-    MOZ_ASSERT(jit::IsIonEnabled(cx));
-
-    // Skip if the code is expected to result in a bailout.
-    if (!script->hasIonScript() || script->ionScript()->bailoutExpected())
-        return Method_Skipped;
-
-    // Don't handle arguments underflow, to make this work we would have to pad
-    // missing arguments with |undefined|.
-    if (numActualArgs < script->functionNonDelazifying()->nargs())
-        return Method_Skipped;
-
-    if (!cx->compartment()->ensureJitCompartmentExists(cx))
-        return Method_Error;
-
-    // This can GC, so afterward, script->ion is not guaranteed to be valid.
-    if (!cx->runtime()->jitRuntime()->enterIon())
-        return Method_Error;
-
-    if (!script->hasIonScript())
-        return Method_Skipped;
-
-    return Method_Compiled;
-}
-
 static JitExecStatus
 EnterIon(JSContext* cx, EnterJitData& data)
 {
     if (!CheckRecursionLimit(cx))
         return JitExec_Aborted;
 
     MOZ_ASSERT(jit::IsIonEnabled(cx));
     MOZ_ASSERT(!data.osrFrame);
@@ -2904,63 +2877,16 @@ jit::IonCannon(JSContext* cx, RunState& 
     JitExecStatus status = EnterIon(cx, data);
 
     if (status == JitExec_Ok)
         state.setReturnValue(data.result);
 
     return status;
 }
 
-JitExecStatus
-jit::FastInvoke(JSContext* cx, HandleFunction fun, CallArgs& args)
-{
-    if (!CheckRecursionLimit(cx))
-        return JitExec_Error;
-
-    RootedScript script(cx, fun->nonLazyScript());
-
-    if (!Debugger::checkNoExecute(cx, script))
-        return JitExec_Error;
-
-#ifdef DEBUG
-    // See comment in EnterBaseline.
-    mozilla::Maybe<JS::AutoAssertNoGC> nogc;
-    nogc.emplace(cx);
-#endif
-
-    IonScript* ion = script->ionScript();
-    JitCode* code = ion->method();
-    void* jitcode = code->raw();
-
-    MOZ_ASSERT(jit::IsIonEnabled(cx));
-    MOZ_ASSERT(!ion->bailoutExpected());
-
-    ActivationEntryMonitor entryMonitor(cx, CalleeToToken(script));
-    JitActivation activation(cx);
-
-    EnterJitCode enter = cx->runtime()->jitRuntime()->enterIon();
-    void* calleeToken = CalleeToToken(fun, /* constructing = */ false);
-
-    RootedValue result(cx, Int32Value(args.length()));
-    MOZ_ASSERT(args.length() >= fun->nargs());
-
-#ifdef DEBUG
-    nogc.reset();
-#endif
-    CALL_GENERATED_CODE(enter, jitcode, args.length() + 1, args.array() - 1, /* osrFrame = */nullptr,
-                        calleeToken, /* envChain = */ nullptr, 0, result.address());
-
-    MOZ_ASSERT(!cx->hasIonReturnOverride());
-
-    args.rval().set(result);
-
-    MOZ_ASSERT_IF(result.isMagic(), result.isMagic(JS_ION_ERROR));
-    return result.isMagic() ? JitExec_Error : JitExec_Ok;
-}
-
 static void
 InvalidateActivation(FreeOp* fop, const JitActivationIterator& activations, bool invalidateAll)
 {
     JitSpew(JitSpew_IonInvalidate, "BEGIN invalidating activation");
 
 #ifdef CHECK_OSIPOINT_REGISTERS
     if (JitOptions.checkOsiPointRegisters)
         activations->asJit()->setCheckRegs(false);
--- a/js/src/jit/Ion.h
+++ b/js/src/jit/Ion.h
@@ -93,17 +93,16 @@ JitContext* MaybeGetJitContext();
 
 void SetJitContext(JitContext* ctx);
 
 bool CanIonCompileScript(JSContext* cx, JSScript* script, bool osr);
 
 MOZ_MUST_USE bool IonCompileScriptForBaseline(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
 
 MethodStatus CanEnter(JSContext* cx, RunState& state);
-MethodStatus CanEnterUsingFastInvoke(JSContext* cx, HandleScript script, uint32_t numActualArgs);
 
 MethodStatus
 Recompile(JSContext* cx, HandleScript script, BaselineFrame* osrFrame, jsbytecode* osrPc,
           bool force);
 
 enum JitExecStatus
 {
     // The method call had to be aborted due to a stack limit check. This
@@ -126,19 +125,16 @@ IsErrorStatus(JitExecStatus status)
 
 struct EnterJitData;
 
 MOZ_MUST_USE bool SetEnterJitData(JSContext* cx, EnterJitData& data, RunState& state,
                                   MutableHandle<GCVector<Value>> vals);
 
 JitExecStatus IonCannon(JSContext* cx, RunState& state);
 
-// Used to enter Ion from C++ natives like Array.map. Called from FastInvokeGuard.
-JitExecStatus FastInvoke(JSContext* cx, HandleFunction fun, CallArgs& args);
-
 // Walk the stack and invalidate active Ion frames for the invalid scripts.
 void Invalidate(TypeZone& types, FreeOp* fop,
                 const RecompileInfoVector& invalid, bool resetUses = true,
                 bool cancelOffThread = true);
 void Invalidate(JSContext* cx, const RecompileInfoVector& invalid, bool resetUses = true,
                 bool cancelOffThread = true);
 void Invalidate(JSContext* cx, JSScript* script, bool resetUses = true,
                 bool cancelOffThread = true);
--- a/js/src/vm/Interpreter-inl.h
+++ b/js/src/vm/Interpreter-inl.h
@@ -822,95 +822,11 @@ ReportIfNotFunction(JSContext* cx, Handl
 {
     if (v.isObject() && v.toObject().is<JSFunction>())
         return &v.toObject().as<JSFunction>();
 
     ReportIsNotFunction(cx, v, -1, construct);
     return nullptr;
 }
 
-/*
- * FastCallGuard is used to optimize calls to JS functions from natives written
- * in C++, e.g. Array.prototype.map.  If the callee is not Ion-compiled, this
- * will just call js::Call.  If the callee has a valid IonScript, however, it
- * will enter Ion directly.
- */
-class FastCallGuard
-{
-    InvokeArgs args_;
-    RootedFunction fun_;
-    RootedScript script_;
-
-    // Constructing a JitContext is pretty expensive due to the TLS access,
-    // so only do this if we have to.
-    bool useIon_;
-
-  public:
-    FastCallGuard(JSContext* cx, const Value& fval)
-      : args_(cx)
-      , fun_(cx)
-      , script_(cx)
-      , useIon_(jit::IsIonEnabled(cx))
-    {
-        initFunction(fval);
-    }
-
-    void initFunction(const Value& fval) {
-        if (fval.isObject() && fval.toObject().is<JSFunction>()) {
-            JSFunction* fun = &fval.toObject().as<JSFunction>();
-            if (fun->isInterpreted())
-                fun_ = fun;
-        }
-    }
-
-    InvokeArgs& args() {
-        return args_;
-    }
-
-    bool call(JSContext* cx, HandleValue callee, HandleValue thisv, MutableHandleValue rval) {
-        args_.CallArgs::setCallee(callee);
-        args_.CallArgs::setThis(thisv);
-
-        if (useIon_ && fun_) {
-            if (!script_) {
-                script_ = JSFunction::getOrCreateScript(cx, fun_);
-                if (!script_)
-                    return false;
-            }
-            MOZ_ASSERT(fun_->nonLazyScript() == script_);
-
-            jit::MethodStatus status = jit::CanEnterUsingFastInvoke(cx, script_, args_.length());
-            if (status == jit::Method_Error)
-                return false;
-            if (status == jit::Method_Compiled) {
-                jit::JitExecStatus result = jit::FastInvoke(cx, fun_, args_);
-                if (IsErrorStatus(result))
-                    return false;
-
-                MOZ_ASSERT(result == jit::JitExec_Ok);
-                rval.set(args_.CallArgs::rval());
-                return true;
-            }
-
-            MOZ_ASSERT(status == jit::Method_Skipped);
-
-            if (script_->canIonCompile()) {
-                // This script is not yet hot. Since calling into Ion is much
-                // faster here, bump the warm-up counter a bit to account for this.
-                script_->incWarmUpCounter(5);
-            }
-        }
-
-        if (!InternalCallOrConstruct(cx, args_, NO_CONSTRUCT))
-            return false;
-
-        rval.set(args_.CallArgs::rval());
-        return true;
-    }
-
-  private:
-    FastCallGuard(const FastCallGuard& other) = delete;
-    void operator=(const FastCallGuard& other) = delete;
-};
-
 }  /* namespace js */
 
 #endif /* vm_Interpreter_inl_h */