Commit 6a604c81 authored by yangguo's avatar yangguo Committed by Commit bot

[serializer] make snapshot reproducible.

R=ulan@chromium.org
BUG=v8:4886
LOG=N

Review URL: https://codereview.chromium.org/1859063003

Cr-Commit-Position: refs/heads/master@{#35266}
parent b527ec11
......@@ -5369,6 +5369,10 @@ void Heap::SetStackLimits() {
(isolate_->stack_guard()->real_jslimit() & ~kSmiTagMask) | kSmiTag);
}
void Heap::ClearStackLimits() {
roots_[kStackLimitRootIndex] = Smi::FromInt(0);
roots_[kRealStackLimitRootIndex] = Smi::FromInt(0);
}
void Heap::PrintAlloctionsHash() {
uint32_t hash = StringHasher::GetHashCore(raw_allocations_hash_);
......
......@@ -1004,6 +1004,10 @@ class Heap {
// jslimit_/real_jslimit_ variable in the StackGuard.
void SetStackLimits();
// The stack limit is thread-dependent. To be able to reproduce the same
// snapshot blob, we need to reset it before serializing.
void ClearStackLimits();
// Generated code can treat direct references to this root as constant.
bool RootCanBeTreatedAsConstant(RootListIndex root_index);
......
......@@ -139,7 +139,8 @@ int main(int argc, char** argv) {
// By default, log code create information in the snapshot.
i::FLAG_log_code = true;
i::FLAG_logfile_per_isolate = false;
// Make mksnapshot runs predictable to create reproducible snapshots.
i::FLAG_predictable = true;
// Print the usage if an error occurs when parsing the command line
// flags or if the help flag is set.
int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
......
......@@ -113,7 +113,12 @@ void StartupSerializer::SerializeStrongReferences() {
CHECK(HasNotExceededFirstPageOfEachSpace());
serializing_immortal_immovables_roots_ = false;
// Visit the rest of the strong roots.
// Clear the stack limits to make the snapshot reproducible.
// Reset it again afterwards.
isolate->heap()->ClearStackLimits();
isolate->heap()->IterateSmiRoots(this);
isolate->heap()->SetStackLimits();
isolate->heap()->IterateStrongRoots(this,
VISIT_ONLY_STRONG_FOR_SERIALIZATION);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment