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

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

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