Bug 1480426 - Avoid allowing memory changes when restoring checkpoints, r=froydnj.

--HG--
extra : rebase_source : c6bfdf52e467cfd2ca13822501941a2a7b874f35
This commit is contained in:
Brian Hackett 2018-08-02 17:18:17 +00:00
Родитель 2805a16972
Коммит 239efbe15d
2 изменённых файлов: 16 добавлений и 15 удалений

Просмотреть файл

@ -1340,8 +1340,7 @@ void
RestoreMemoryToLastSavedCheckpoint() RestoreMemoryToLastSavedCheckpoint()
{ {
MOZ_RELEASE_ASSERT(Thread::CurrentIsMainThread()); MOZ_RELEASE_ASSERT(Thread::CurrentIsMainThread());
MOZ_RELEASE_ASSERT(!gMemoryInfo->mMemoryChangesAllowed);
AutoDisallowMemoryChanges disallow;
// Restore all dirty regions that have been modified since the last // Restore all dirty regions that have been modified since the last
// checkpoint was saved/restored. // checkpoint was saved/restored.
@ -1357,10 +1356,9 @@ void
RestoreMemoryToLastSavedDiffCheckpoint() RestoreMemoryToLastSavedDiffCheckpoint()
{ {
MOZ_RELEASE_ASSERT(Thread::CurrentIsMainThread()); MOZ_RELEASE_ASSERT(Thread::CurrentIsMainThread());
MOZ_RELEASE_ASSERT(!gMemoryInfo->mMemoryChangesAllowed);
MOZ_RELEASE_ASSERT(gMemoryInfo->mActiveDirty.empty()); MOZ_RELEASE_ASSERT(gMemoryInfo->mActiveDirty.empty());
AutoDisallowMemoryChanges disallow;
// Wait while the snapshot threads restore all pages modified since the diff // Wait while the snapshot threads restore all pages modified since the diff
// snapshot was recorded. // snapshot was recorded.
gMemoryInfo->mSnapshotThreadsShouldRestore.ActivateBegin(); gMemoryInfo->mSnapshotThreadsShouldRestore.ActivateBegin();

Просмотреть файл

@ -83,16 +83,19 @@ RestoreCheckpointAndResume(const CheckpointId& aCheckpoint)
double start = CurrentTime(); double start = CurrentTime();
// Rewind heap memory to the target checkpoint, which must have been saved. {
CheckpointId newCheckpoint = gRewindInfo->mSavedCheckpoints.back().mCheckpoint; // Rewind heap memory to the target checkpoint, which must have been saved.
RestoreMemoryToLastSavedCheckpoint(); AutoDisallowMemoryChanges disallow;
while (CheckpointPrecedes(aCheckpoint, newCheckpoint)) { CheckpointId newCheckpoint = gRewindInfo->mSavedCheckpoints.back().mCheckpoint;
gRewindInfo->mSavedCheckpoints.back().ReleaseContents(); RestoreMemoryToLastSavedCheckpoint();
gRewindInfo->mSavedCheckpoints.popBack(); while (CheckpointPrecedes(aCheckpoint, newCheckpoint)) {
RestoreMemoryToLastSavedDiffCheckpoint(); gRewindInfo->mSavedCheckpoints.back().ReleaseContents();
newCheckpoint = gRewindInfo->mSavedCheckpoints.back().mCheckpoint; gRewindInfo->mSavedCheckpoints.popBack();
RestoreMemoryToLastSavedDiffCheckpoint();
newCheckpoint = gRewindInfo->mSavedCheckpoints.back().mCheckpoint;
}
MOZ_RELEASE_ASSERT(newCheckpoint == aCheckpoint);
} }
MOZ_RELEASE_ASSERT(newCheckpoint == aCheckpoint);
FixupFreeRegionsAfterRewind(); FixupFreeRegionsAfterRewind();
@ -100,8 +103,8 @@ RestoreCheckpointAndResume(const CheckpointId& aCheckpoint)
PrintSpew("Restore #%d:%d -> #%d:%d %.2fs\n", PrintSpew("Restore #%d:%d -> #%d:%d %.2fs\n",
(int) gRewindInfo->mLastCheckpoint.mNormal, (int) gRewindInfo->mLastCheckpoint.mNormal,
(int) gRewindInfo->mLastCheckpoint.mTemporary, (int) gRewindInfo->mLastCheckpoint.mTemporary,
(int) newCheckpoint.mNormal, (int) aCheckpoint.mNormal,
(int) newCheckpoint.mTemporary, (int) aCheckpoint.mTemporary,
(end - start) / 1000000.0); (end - start) / 1000000.0);
// Finally, let threads restore themselves to their stacks at the checkpoint // Finally, let threads restore themselves to their stacks at the checkpoint