Commit 0d0e29f3 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

Reland "[d8] Use predictable platform if --predictable is passed"

This is a reland of e2016cf0. The fix is
in PS2, with a comment why it is needed.

Original change's description:
> [d8] Use predictable platform if --predictable is passed
>
> We currently only use the predictable platform if --verify-predictable
> is passed, which is confusing and not following the comment on the
> --predictable flag ("enable predictable mode").
>
> This CL fixes that and makes --verify-predictable imply --predictable to
> also allow to only pass --verify-predictable.
>
> R=ahaas@chromium.org
> CC=mlippautz@chromium.org
>
> Bug: v8:11879
> Change-Id: Ifb9683ddc4fab374ce519169533c90244175bb48
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3094010
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#76305}

Bug: v8:11879
Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_isolates_rel_ng
Change-Id: I7bb7a6af722ee1cc447bc668385543dd72fd309b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3097867
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76322}
parent d0e579f5
......@@ -82,7 +82,14 @@ class PredictablePlatform final : public Platform {
}
double MonotonicallyIncreasingTime() override {
return synthetic_time_in_sec_ += 0.00001;
// In predictable mode, there should be no (observable) concurrency, but we
// still run some tests that explicitly specify '--predictable' in the
// '--isolates' variant, where several threads run the same test in
// different isolates. To avoid TSan issues in that scenario we use atomic
// increments here.
uint64_t synthetic_time =
synthetic_time_.fetch_add(1, std::memory_order_relaxed);
return 1e-5 * synthetic_time;
}
double CurrentClockTimeMillis() override {
......@@ -96,7 +103,7 @@ class PredictablePlatform final : public Platform {
Platform* platform() const { return platform_.get(); }
private:
double synthetic_time_in_sec_ = 0.0;
std::atomic<uint64_t> synthetic_time_{0};
std::unique_ptr<Platform> platform_;
};
......
......@@ -5027,7 +5027,7 @@ int Shell::Main(int argc, char* argv[]) {
options.thread_pool_size, v8::platform::IdleTaskSupport::kEnabled,
in_process_stack_dumping, std::move(tracing));
g_default_platform = g_platform.get();
if (i::FLAG_verify_predictable) {
if (i::FLAG_predictable) {
g_platform = MakePredictablePlatform(std::move(g_platform));
}
if (options.stress_delay_tasks) {
......
......@@ -2116,6 +2116,7 @@ DEFINE_NEG_IMPLICATION(single_threaded_gc, stress_concurrent_allocation)
DEFINE_BOOL(verify_predictable, false,
"this mode is used for checking that V8 behaves predictably")
DEFINE_IMPLICATION(verify_predictable, predictable)
DEFINE_INT(dump_allocations_digest_at_alloc, -1,
"dump allocations digest each n-th allocation")
......
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