uint32_t jit::ExceptionHandlerBailout(JSContext* cx, const InlineFrameIterator& frame, ResumeFromException* rfe, const ExceptionBailoutInfo& excInfo, bool* overrecursed) { // We can be propagating debug mode exceptions without there being an // actual exception pending. For instance, when we return false from an // operation callback like a timeout handler. MOZ_ASSERT_IF(!excInfo.propagatingIonExceptionForDebugMode(), cx->isExceptionPending()); cx->runtime()->jitTop = FAKE_JIT_TOP_FOR_BAILOUT; gc::AutoSuppressGC suppress(cx); JitActivationIterator jitActivations(cx->runtime()); BailoutFrameInfo bailoutData(jitActivations, frame.frame()); JitFrameIterator iter(jitActivations); CommonFrameLayout* currentFramePtr = iter.current(); BaselineBailoutInfo* bailoutInfo = nullptr; uint32_t retval = BailoutIonToBaseline(cx, bailoutData.activation(), iter, true, &bailoutInfo, &excInfo); if (retval == BAILOUT_RETURN_OK) { MOZ_ASSERT(bailoutInfo); // Overwrite the kind so HandleException after the bailout returns // false, jumping directly to the exception tail. if (excInfo.propagatingIonExceptionForDebugMode()) bailoutInfo->bailoutKind = Bailout_IonExceptionDebugMode; rfe->kind = ResumeFromException::RESUME_BAILOUT; rfe->target = cx->runtime()->jitRuntime()->getBailoutTail()->raw(); rfe->bailoutInfo = bailoutInfo; } else { // Bailout failed. If there was a fatal error, clear the // exception to turn this into an uncatchable error. If the // overrecursion check failed, continue popping all inline // frames and have the caller report an overrecursion error. MOZ_ASSERT(!bailoutInfo); if (!excInfo.propagatingIonExceptionForDebugMode()) cx->clearPendingException(); if (retval == BAILOUT_RETURN_OVERRECURSED) *overrecursed = true; else MOZ_ASSERT(retval == BAILOUT_RETURN_FATAL_ERROR); } // Make the frame being bailed out the top profiled frame. if (cx->runtime()->jitRuntime()->isProfilerInstrumentationEnabled(cx->runtime())) cx->runtime()->jitActivation->setLastProfilingFrame(currentFramePtr); return retval; }
uint32_t jit::ExceptionHandlerBailout(JSContext *cx, const InlineFrameIterator &frame, ResumeFromException *rfe, const ExceptionBailoutInfo &excInfo, bool *overrecursed) { // We can be propagating debug mode exceptions without there being an // actual exception pending. For instance, when we return false from an // operation callback like a timeout handler. MOZ_ASSERT_IF(!excInfo.propagatingIonExceptionForDebugMode(), cx->isExceptionPending()); cx->mainThread().ionTop = nullptr; JitActivationIterator jitActivations(cx->runtime()); IonBailoutIterator iter(jitActivations, frame.frame()); JitActivation *activation = jitActivations.activation()->asJit(); BaselineBailoutInfo *bailoutInfo = nullptr; uint32_t retval = BailoutIonToBaseline(cx, activation, iter, true, &bailoutInfo, &excInfo); if (retval == BAILOUT_RETURN_OK) { MOZ_ASSERT(bailoutInfo); // Overwrite the kind so HandleException after the bailout returns // false, jumping directly to the exception tail. if (excInfo.propagatingIonExceptionForDebugMode()) bailoutInfo->bailoutKind = Bailout_IonExceptionDebugMode; rfe->kind = ResumeFromException::RESUME_BAILOUT; rfe->target = cx->runtime()->jitRuntime()->getBailoutTail()->raw(); rfe->bailoutInfo = bailoutInfo; } else { // Bailout failed. If there was a fatal error, clear the // exception to turn this into an uncatchable error. If the // overrecursion check failed, continue popping all inline // frames and have the caller report an overrecursion error. MOZ_ASSERT(!bailoutInfo); if (!excInfo.propagatingIonExceptionForDebugMode()) cx->clearPendingException(); if (retval == BAILOUT_RETURN_OVERRECURSED) *overrecursed = true; else MOZ_ASSERT(retval == BAILOUT_RETURN_FATAL_ERROR); } return retval; }
uint32_t ion::ExceptionHandlerBailout(JSContext *cx, const InlineFrameIterator &frame, const ExceptionBailoutInfo &excInfo, BaselineBailoutInfo **bailoutInfo) { JS_ASSERT(cx->isExceptionPending()); cx->mainThread().ionTop = NULL; JitActivationIterator jitActivations(cx->runtime()); IonBailoutIterator iter(jitActivations, frame.frame()); JitActivation *activation = jitActivations.activation()->asJit(); *bailoutInfo = NULL; uint32_t retval = BailoutIonToBaseline(cx, activation, iter, true, bailoutInfo, &excInfo); JS_ASSERT(retval == BAILOUT_RETURN_OK || retval == BAILOUT_RETURN_FATAL_ERROR || retval == BAILOUT_RETURN_OVERRECURSED); JS_ASSERT((retval == BAILOUT_RETURN_OK) == (*bailoutInfo != NULL)); return retval; }
uint32_t jit::ExceptionHandlerBailout(JSContext* cx, const InlineFrameIterator& frame, ResumeFromException* rfe, const ExceptionBailoutInfo& excInfo, bool* overrecursed) { // We can be propagating debug mode exceptions without there being an // actual exception pending. For instance, when we return false from an // operation callback like a timeout handler. MOZ_ASSERT_IF(!excInfo.propagatingIonExceptionForDebugMode(), cx->isExceptionPending()); JitActivation* act = cx->activation()->asJit(); uint8_t* prevExitFP = act->exitFP(); auto restoreExitFP = mozilla::MakeScopeExit([&]() { act->setExitFP(prevExitFP); }); act->setExitFP(FAKE_EXITFP_FOR_BAILOUT); gc::AutoSuppressGC suppress(cx); JitActivationIterator jitActivations(cx); BailoutFrameInfo bailoutData(jitActivations, frame.frame()); JitFrameIterator iter(jitActivations); CommonFrameLayout* currentFramePtr = iter.current(); BaselineBailoutInfo* bailoutInfo = nullptr; uint32_t retval; { // Currently we do not tolerate OOM here so as not to complicate the // exception handling code further. AutoEnterOOMUnsafeRegion oomUnsafe; retval = BailoutIonToBaseline(cx, bailoutData.activation(), iter, true, &bailoutInfo, &excInfo); if (retval == BAILOUT_RETURN_FATAL_ERROR && cx->isThrowingOutOfMemory()) oomUnsafe.crash("ExceptionHandlerBailout"); } if (retval == BAILOUT_RETURN_OK) { MOZ_ASSERT(bailoutInfo); // Overwrite the kind so HandleException after the bailout returns // false, jumping directly to the exception tail. if (excInfo.propagatingIonExceptionForDebugMode()) bailoutInfo->bailoutKind = Bailout_IonExceptionDebugMode; rfe->kind = ResumeFromException::RESUME_BAILOUT; rfe->target = cx->runtime()->jitRuntime()->getBailoutTail()->raw(); rfe->bailoutInfo = bailoutInfo; } else { // Bailout failed. If the overrecursion check failed, clear the // exception to turn this into an uncatchable error, continue popping // all inline frames and have the caller report the error. MOZ_ASSERT(!bailoutInfo); if (retval == BAILOUT_RETURN_OVERRECURSED) { *overrecursed = true; if (!excInfo.propagatingIonExceptionForDebugMode()) cx->clearPendingException(); } else { MOZ_ASSERT(retval == BAILOUT_RETURN_FATAL_ERROR); // Crash for now so as not to complicate the exception handling code // further. MOZ_CRASH(); } } // Make the frame being bailed out the top profiled frame. if (cx->runtime()->jitRuntime()->isProfilerInstrumentationEnabled(cx->runtime())) cx->jitActivation->setLastProfilingFrame(currentFramePtr); return retval; }