[static-roots] Rename --static-roots to --generate-static-roots

Rename the flag in order to avoid confusion with `V8_STATIC_ROOTS_BOOL`.
The flag is used by `./mksnapshot` to generate a new static-roots.h
file.

Bug: v8:13466
Change-Id: Ieb5af89b9839673fd2b8aeef197c104aa3c580aa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4111933
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Olivier Flückiger <olivf@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85030}
This commit is contained in:
Olivier Flückiger 2022-12-28 13:33:27 +00:00 committed by V8 LUCI CQ
parent 0f3036ce09
commit be9c39d3d9
5 changed files with 12 additions and 12 deletions

View File

@ -4148,15 +4148,14 @@ VirtualMemoryCage* Isolate::GetPtrComprCodeCageForTesting() {
return V8_EXTERNAL_CODE_SPACE_BOOL ? heap_.code_range() : GetPtrComprCage();
}
// If this check fails mksnapshot needs to be built without static roots and
// then called with --static-roots to re-regenerate the static-roots.h file.
void Isolate::VerifyStaticRoots() {
#if V8_STATIC_ROOTS_BOOL
static_assert(ReadOnlyHeap::IsReadOnlySpaceShared(),
"Static read only roots are only supported when there is one "
"shared read only space per cage");
#define STATIC_ROOTS_FAILED_MSG \
"Run `tools/dev/gen-static-roots.py` to update static-roots.h."
#define STATIC_ROOTS_FAILED_MSG \
"Read-only heap layout changed. Run `tools/dev/gen-static-roots.py` to " \
"update static-roots.h."
static_assert(static_cast<int>(RootIndex::kReadOnlyRootsCount) ==
StaticReadOnlyRootsPointerTable.size(),
STATIC_ROOTS_FAILED_MSG);

View File

@ -2020,8 +2020,9 @@ DEFINE_STRING(embedded_src, nullptr,
DEFINE_STRING(
embedded_variant, nullptr,
"Label to disambiguate symbols in embedded data file. (mksnapshot only)")
DEFINE_STRING(static_roots, nullptr,
"Path for writing static-roots.h. (mksnapshot only)")
DEFINE_STRING(static_roots_src, nullptr,
"Path for writing a fresh static-roots.h. (mksnapshot only, "
"build without static roots only)")
DEFINE_STRING(startup_src, nullptr,
"Write V8 startup as C++ src. (mksnapshot only)")
DEFINE_STRING(startup_blob, nullptr,

View File

@ -231,7 +231,7 @@ int main(int argc, char** argv) {
std::string usage = "Usage: " + std::string(argv[0]) +
" [--startup-src=file]" + " [--startup-blob=file]" +
" [--embedded-src=file]" + " [--embedded-variant=label]" +
" [--static-roots=file]" + " [--target-arch=arch]" +
" [--static-roots-src=file]" + " [--target-arch=arch]" +
" [--target-os=os] [extras]\n\n";
int result = i::FlagList::SetFlagsFromCommandLine(
&argc, argv, true, HelpOptions(HelpOptions::kExit, usage.c_str()));
@ -291,8 +291,8 @@ int main(int argc, char** argv) {
// That's fine as far as the embedded file writer is concerned.
WriteEmbeddedFile(&embedded_writer);
if (i::v8_flags.static_roots) {
i::StaticRootsTableGen::write(i_isolate, i::v8_flags.static_roots);
if (i::v8_flags.static_roots_src) {
i::StaticRootsTableGen::write(i_isolate, i::v8_flags.static_roots_src);
}
}

View File

@ -16,8 +16,8 @@ namespace internal {
void StaticRootsTableGen::write(Isolate* isolate, const char* file) {
CHECK_WITH_MSG(!V8_STATIC_ROOTS_BOOL,
"--static-roots is only supported in builds with "
"v8_enable_static_roots disabled");
"Re-generating the table of roots is only supported in builds "
"with v8_enable_static_roots disabled");
CHECK(file);
static_assert(static_cast<int>(RootIndex::kFirstReadOnlyRoot) == 0);

View File

@ -116,7 +116,7 @@ for target in [args.configuration]:
gn_args = config["gn_args"]
build_path = build(build_dir, gn_args)
out_file = Path(tempfile.gettempdir()) / f"static-roots-{target}.h"
run([build_path / "mksnapshot", "--static-roots", out_file])
run([build_path / "mksnapshot", "--static-roots-src", out_file])
target_file = v8_path / config["target"]
if not filecmp.cmp(out_file, target_file):
shutil.move(out_file, target_file)