From 80a89bf4ed9cefbaa6939f6b56439311f4dab09c Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Mon, 19 Nov 2018 14:09:33 -1000 Subject: [PATCH] Bug 1508314 Part 1 - Watch for hits at temporary checkpoint locations when searching backwards, r=mccr8. --HG-- extra : rebase_source : b160d94e2dc34bedd9517fd2e2b8014ee860430a --- toolkit/recordreplay/ipc/ChildNavigation.cpp | 37 +++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/toolkit/recordreplay/ipc/ChildNavigation.cpp b/toolkit/recordreplay/ipc/ChildNavigation.cpp index 45cc65c6a728..b3088f166fec 100644 --- a/toolkit/recordreplay/ipc/ChildNavigation.cpp +++ b/toolkit/recordreplay/ipc/ChildNavigation.cpp @@ -262,6 +262,9 @@ class FindLastHitPhase final : public NavigationPhase // Endpoint of the search, nothing if the endpoint is the next checkpoint. Maybe mEnd; + // Whether the endpoint itself is considered to be part of the search space. + bool mIncludeEnd; + // Counter that increases as we run forward, for ordering hits. size_t mCounter; @@ -283,11 +286,12 @@ class FindLastHitPhase final : public NavigationPhase InfallibleVector mTrackedPositions; const TrackedPosition& FindTrackedPosition(const BreakpointPosition& aPos); + void CheckForRegionEnd(const ExecutionPoint& aPoint); void OnRegionEnd(); public: // Note: this always rewinds. - void Enter(const CheckpointId& aStart, const Maybe& aEnd); + void Enter(const CheckpointId& aStart, const Maybe& aEnd, bool aIncludeEnd); void ToString(nsAutoCString& aStr) override { aStr.AppendPrintf("FindLastHit"); @@ -571,13 +575,13 @@ PausedPhase::Resume(bool aForward) MOZ_RELEASE_ASSERT(start.mTemporary); start.mTemporary--; } - gNavigation->mFindLastHitPhase.Enter(start, Some(mPoint)); + gNavigation->mFindLastHitPhase.Enter(start, Some(mPoint), /* aIncludeEnd = */ false); } else { // We can't rewind past the beginning of the replay. MOZ_RELEASE_ASSERT(mPoint.mCheckpoint != CheckpointId::First); CheckpointId start(mPoint.mCheckpoint - 1); - gNavigation->mFindLastHitPhase.Enter(start, Nothing()); + gNavigation->mFindLastHitPhase.Enter(start, Nothing(), /* aIncludeEnd = */ false); } Unreachable(); } @@ -907,12 +911,14 @@ ReachBreakpointPhase::PositionHit(const ExecutionPoint& aPoint) /////////////////////////////////////////////////////////////////////////////// void -FindLastHitPhase::Enter(const CheckpointId& aStart, const Maybe& aEnd) +FindLastHitPhase::Enter(const CheckpointId& aStart, const Maybe& aEnd, + bool aIncludeEnd) { MOZ_RELEASE_ASSERT(aEnd.isNothing() || aEnd.ref().HasPosition()); mStart = aStart; mEnd = aEnd; + mIncludeEnd = aIncludeEnd; mCounter = 0; mTrackedPositions.clear(); @@ -962,9 +968,8 @@ FindLastHitPhase::AfterCheckpoint(const CheckpointId& aCheckpoint) void FindLastHitPhase::PositionHit(const ExecutionPoint& aPoint) { - if (mEnd.isSome() && mEnd.ref() == aPoint) { - OnRegionEnd(); - Unreachable(); + if (!mIncludeEnd) { + CheckForRegionEnd(aPoint); } ++mCounter; @@ -976,6 +981,19 @@ FindLastHitPhase::PositionHit(const ExecutionPoint& aPoint) break; } } + + if (mIncludeEnd) { + CheckForRegionEnd(aPoint); + } +} + +void +FindLastHitPhase::CheckForRegionEnd(const ExecutionPoint& aPoint) +{ + if (mEnd.isSome() && mEnd.ref() == aPoint) { + OnRegionEnd(); + Unreachable(); + } } void @@ -1020,7 +1038,10 @@ FindLastHitPhase::OnRegionEnd() start.mTemporary--; ExecutionPoint end = gNavigation->LastTemporaryCheckpointLocation(); if (end.HasPosition()) { - gNavigation->mFindLastHitPhase.Enter(start, Some(end)); + // The temporary checkpoint comes immediately after its associated + // execution point. As we search backwards we need to look for hits at + // that execution point itself. + gNavigation->mFindLastHitPhase.Enter(start, Some(end), /* aIncludeEnd = */ true); Unreachable(); } else { // The last temporary checkpoint may be at the same execution point as