From dc5230379902826a8748f04cbd32a2afab89816a Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 17 Apr 2024 21:25:30 +0200 Subject: [PATCH] [js] Simplify tracing of arguments in MarkThisAndArguments. --- js/src/jit/JitFrames.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/src/jit/JitFrames.cpp b/js/src/jit/JitFrames.cpp index 7ee9b24eab..65b0e8abfb 100644 --- a/js/src/jit/JitFrames.cpp +++ b/js/src/jit/JitFrames.cpp @@ -1049,31 +1049,31 @@ MarkThisAndArguments(JSTracer* trc, const JitFrameIterator& frame) if (!CalleeTokenIsFunction(layout->calleeToken())) return; - size_t nargs = layout->numActualArgs(); - size_t nformals = 0; - JSFunction* fun = CalleeTokenToFunction(layout->calleeToken()); - if (!frame.isExitFrameLayout() && - !fun->nonLazyScript()->mayReadFrameArgsDirectly()) - { - nformals = fun->nargs(); - } + size_t numFormals = fun->nargs(); + size_t numArgs = Max(layout->numActualArgs(), numFormals); + size_t firstArg = 0; - size_t newTargetOffset = Max(nargs, fun->nargs()); + if (!frame.isExitFrameLayout() && + !fun->nonLazyScript()->mayReadFrameArgsDirectly()) { + firstArg = numFormals; + } Value* argv = layout->argv(); // Trace |this|. TraceRoot(trc, argv, "ion-thisv"); - // Trace actual arguments beyond the formals. Note + 1 for thisv. - for (size_t i = nformals + 1; i < nargs + 1; i++) - TraceRoot(trc, &argv[i], "ion-argv"); + // Trace arguments. Note + 1 for thisv. + for (size_t i = firstArg; i < numArgs; i++) { + TraceRoot(trc, &argv[i + 1], "ion-argv"); + } // Always mark the new.target from the frame. It's not in the snapshots. // +1 to pass |this| - if (CalleeTokenIsConstructing(layout->calleeToken())) - TraceRoot(trc, &argv[1 + newTargetOffset], "ion-newTarget"); + if (CalleeTokenIsConstructing(layout->calleeToken())) { + TraceRoot(trc, &argv[1 + numArgs], "ion-newTarget"); + } } #ifdef JS_NUNBOX32