Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dfc9c86

Browse filesBrowse files
committed
deps: V8: cherry-pick de9a5de2274f
Original commit message: Ignore flags implied by --predictable during hash computation https://chromium-review.googlesource.com/c/v8/v8/+/4681766 added code to ignore --predictable during hash computation of flags in order to produce reproducible code cache. This turns out to be not enough since the flags implied by --predictable also need to be ignored for it to work. This patch makes sure that they are ignored. Change-Id: Ifa36641efe3ca105706fd293be46fc974055d2d4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4851287 Commit-Queue: Joyee Cheung <joyee@igalia.com> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Patrick Thier <pthier@chromium.org> Cr-Commit-Position: refs/heads/main@{#90022} Refs: v8/v8@de9a5de PR-URL: #49639 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 186b36e commit dfc9c86
Copy full SHA for dfc9c86

File tree

Expand file treeCollapse file tree

3 files changed

+81
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+81
-2
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.9',
39+
'v8_embedder_string': '-node.10',
4040

4141
##### V8 defaults for Node.js #####
4242

Collapse file

‎deps/v8/src/flags/flag-definitions.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/flags/flag-definitions.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,6 @@ DEFINE_BOOL(log_all, false, "Log all events to the log file.")
25432543
DEFINE_BOOL(log_internal_timer_events, false, "See --log-timer-events")
25442544
DEFINE_BOOL(log_timer_events, false,
25452545
"Log timer events (incl. console.time* and Date.now).")
2546-
DEFINE_IMPLICATION(log_timer_events, log_timer_events)
25472546

25482547
DEFINE_BOOL(log_source_code, false, "Log source code.")
25492548
DEFINE_BOOL(log_source_position, false, "Log detailed source information.")
Collapse file

‎deps/v8/src/flags/flags.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/flags/flags.cc
+80Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cstdlib>
1111
#include <cstring>
1212
#include <iomanip>
13+
#include <set>
1314
#include <sstream>
1415

1516
#include "src/base/functional.h"
@@ -103,7 +104,12 @@ struct Flag {
103104
const char* cmt_; // A comment about the flags purpose.
104105
bool owns_ptr_; // Does the flag own its string value?
105106
SetBy set_by_ = SetBy::kDefault;
107+
// Name of the flag implying this flag, if any.
106108
const char* implied_by_ = nullptr;
109+
#ifdef DEBUG
110+
// Pointer to the flag implying this flag, if any.
111+
const Flag* implied_by_ptr_ = nullptr;
112+
#endif
107113

108114
FlagType type() const { return type_; }
109115

@@ -113,6 +119,17 @@ struct Flag {
113119

114120
bool PointsTo(const void* ptr) const { return valptr_ == ptr; }
115121

122+
#ifdef DEBUG
123+
bool ImpliedBy(const void* ptr) const {
124+
const Flag* current = this->implied_by_ptr_;
125+
while (current != nullptr) {
126+
if (current->PointsTo(ptr)) return true;
127+
current = current->implied_by_ptr_;
128+
}
129+
return false;
130+
}
131+
#endif
132+
116133
bool bool_variable() const { return GetValue<TYPE_BOOL, bool>(); }
117134

118135
void set_bool_variable(bool value, SetBy set_by) {
@@ -333,6 +350,15 @@ struct Flag {
333350
if (IsAnyImplication(new_set_by)) {
334351
DCHECK_NOT_NULL(implied_by);
335352
implied_by_ = implied_by;
353+
#ifdef DEBUG
354+
// This only works when implied_by is a flag_name or !flag_name, but it
355+
// can also be a condition e.g. flag_name > 3. Since this is only used for
356+
// checks in DEBUG mode, we will just ignore the more complex conditions
357+
// for now - that will just lead to a nullptr which won't be followed.
358+
implied_by_ptr_ = static_cast<Flag*>(
359+
FindFlagByName(implied_by[0] == '!' ? implied_by + 1 : implied_by));
360+
DCHECK_NE(implied_by_ptr_, this);
361+
#endif
336362
}
337363
return change_flag;
338364
}
@@ -534,17 +560,71 @@ uint32_t ComputeFlagListHash() {
534560
std::ostringstream modified_args_as_string;
535561
if (COMPRESS_POINTERS_BOOL) modified_args_as_string << "ptr-compr";
536562
if (DEBUG_BOOL) modified_args_as_string << "debug";
563+
564+
#ifdef DEBUG
565+
// These two sets are used to check that we don't leave out any flags
566+
// implied by --predictable in the list below.
567+
std::set<const char*> flags_implied_by_predictable;
568+
std::set<const char*> flags_ignored_because_of_predictable;
569+
#endif
570+
537571
for (const Flag& flag : flags) {
538572
if (flag.IsDefault()) continue;
573+
#ifdef DEBUG
574+
if (flag.ImpliedBy(&v8_flags.predictable)) {
575+
flags_implied_by_predictable.insert(flag.name());
576+
}
577+
#endif
539578
// We want to be able to flip --profile-deserialization without
540579
// causing the code cache to get invalidated by this hash.
541580
if (flag.PointsTo(&v8_flags.profile_deserialization)) continue;
542581
// Skip v8_flags.random_seed and v8_flags.predictable to allow predictable
543582
// code caching.
544583
if (flag.PointsTo(&v8_flags.random_seed)) continue;
545584
if (flag.PointsTo(&v8_flags.predictable)) continue;
585+
586+
// The following flags are implied by --predictable (some negated).
587+
if (flag.PointsTo(&v8_flags.concurrent_sparkplug) ||
588+
flag.PointsTo(&v8_flags.concurrent_recompilation) ||
589+
#ifdef V8_ENABLE_MAGLEV
590+
flag.PointsTo(&v8_flags.maglev_deopt_data_on_background) ||
591+
flag.PointsTo(&v8_flags.maglev_build_code_on_background) ||
592+
#endif
593+
flag.PointsTo(&v8_flags.parallel_scavenge) ||
594+
flag.PointsTo(&v8_flags.concurrent_marking) ||
595+
flag.PointsTo(&v8_flags.concurrent_array_buffer_sweeping) ||
596+
flag.PointsTo(&v8_flags.parallel_marking) ||
597+
flag.PointsTo(&v8_flags.concurrent_sweeping) ||
598+
flag.PointsTo(&v8_flags.parallel_compaction) ||
599+
flag.PointsTo(&v8_flags.parallel_pointer_update) ||
600+
flag.PointsTo(&v8_flags.parallel_weak_ref_clearing) ||
601+
flag.PointsTo(&v8_flags.memory_reducer) ||
602+
flag.PointsTo(&v8_flags.cppheap_concurrent_marking) ||
603+
flag.PointsTo(&v8_flags.cppheap_incremental_marking) ||
604+
flag.PointsTo(&v8_flags.single_threaded_gc)) {
605+
#ifdef DEBUG
606+
if (flag.ImpliedBy(&v8_flags.predictable)) {
607+
flags_ignored_because_of_predictable.insert(flag.name());
608+
}
609+
#endif
610+
continue;
611+
}
546612
modified_args_as_string << flag;
547613
}
614+
615+
#ifdef DEBUG
616+
for (const char* name : flags_implied_by_predictable) {
617+
if (flags_ignored_because_of_predictable.find(name) ==
618+
flags_ignored_because_of_predictable.end()) {
619+
PrintF(
620+
"%s should be added to the list of "
621+
"flags_ignored_because_of_predictable\n",
622+
name);
623+
UNREACHABLE();
624+
}
625+
}
626+
#endif
627+
548628
std::string args(modified_args_as_string.str());
549629
// Generate a hash that is not 0.
550630
uint32_t hash = static_cast<uint32_t>(base::hash_range(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.