Commit cd86f977 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[d8] Add the --stress-snapshot flag

When enabled, this flag triggers a serialize-deserialize-verify pass
after script execution completes.

Bug: v8:10416
Change-Id: I377b8387762495eba07c807229fa464b00485bae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2172426
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67527}
parent 987ada7b
......@@ -49,6 +49,7 @@
#include "src/parsing/scanner-character-streams.h"
#include "src/profiler/profile-generator.h"
#include "src/sanitizer/msan.h"
#include "src/snapshot/snapshot.h"
#include "src/trap-handler/trap-handler.h"
#include "src/utils/ostreams.h"
#include "src/utils/utils.h"
......@@ -2846,6 +2847,13 @@ bool Shell::SetOptions(int argc, char* argv[]) {
strcmp(argv[i], "--no-stress-opt") == 0) {
options.stress_opt = false;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--stress-snapshot") == 0) {
options.stress_snapshot = true;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--nostress-snapshot") == 0 ||
strcmp(argv[i], "--no-stress-snapshot") == 0) {
options.stress_snapshot = false;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--noalways-opt") == 0 ||
strcmp(argv[i], "--no-always-opt") == 0) {
// No support for stressing if we can't use --always-opt.
......@@ -3038,6 +3046,12 @@ int Shell::RunMain(Isolate* isolate, bool last_run) {
DisposeModuleEmbedderData(context);
}
WriteLcovData(isolate, options.lcov_file);
if (options.stress_snapshot) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::Context> i_context = Utils::OpenHandle(*context);
i::Snapshot::SerializeDeserializeAndVerifyForTesting(i_isolate,
i_context);
}
}
CollectGarbage(isolate);
for (int i = 1; i < options.num_isolates; ++i) {
......
......@@ -268,6 +268,7 @@ class ShellOptions {
bool wait_for_wasm = true;
bool stress_opt = false;
int stress_runs = 1;
bool stress_snapshot = false;
bool interactive_shell = false;
bool test_shell = false;
bool expected_to_throw = false;
......
......@@ -74,7 +74,7 @@ class Snapshot : public AllStatic {
// current isolate and context into a snapshot, deserializes the snapshot into
// a new isolate and context, and finally runs VerifyHeap on the fresh
// isolate.
static void SerializeDeserializeAndVerifyForTesting(
V8_EXPORT_PRIVATE static void SerializeDeserializeAndVerifyForTesting(
Isolate* isolate, Handle<Context> default_context);
// ---------------- Helper methods ------------------------------------------
......
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