29#define ADD_ROOT(_, value, CamelName) \
31 Tagged_t ptr = V8HeapCompressionScheme::CompressObject( \
32 ro_roots.unchecked_##value().ptr()); \
33 sorted_roots_[ptr].push_back(pos); \
34 camel_names_[RootIndex::k##CamelName] = #CamelName; \
55 "Re-generating the table of roots is only supported in builds "
56 "with v8_enable_static_roots disabled");
61 std::ofstream out(file, std::ios::binary);
63 out <<
"// Copyright 2022 the V8 project authors. All rights reserved.\n"
64 <<
"// Use of this source code is governed by a BSD-style license "
66 <<
"// found in the LICENSE file.\n"
68 <<
"// This file is automatically generated by "
69 "`tools/dev/gen-static-roots.py`. Do\n// not edit manually.\n"
71 <<
"#ifndef V8_ROOTS_STATIC_ROOTS_H_\n"
72 <<
"#define V8_ROOTS_STATIC_ROOTS_H_\n"
74 <<
"#include \"src/common/globals.h\"\n"
76 <<
"#if V8_STATIC_ROOTS_BOOL\n"
78 <<
"#include \"src/roots/roots.h\"\n"
80 <<
"// Disabling Wasm or Intl invalidates the contents of "
82 <<
"// TODO(olivf): To support static roots for multiple build "
84 <<
"// will need to generate target specific versions of "
86 <<
"static_assert(V8_ENABLE_WEBASSEMBLY);\n"
87 <<
"static_assert(V8_INTL_SUPPORT);\n"
90 <<
"namespace internal {\n"
92 <<
"struct StaticReadOnlyRoot {\n";
99 for (
auto& entry :
gen.sorted_roots()) {
102 const std::list<RootIndex>& roots = entry.second;
105 static const char* kPreString =
" static constexpr Tagged_t k";
106 const std::string& name =
gen.camel_name(root);
107 size_t ptr_len = ceil(log2(ptr) / 4.0);
109 size_t len = strlen(kPreString) + name.length() + 5 + ptr_len + 1;
110 out << kPreString << name <<
" =";
111 if (len > 80) out <<
"\n ";
112 out <<
" 0x" << std::hex << ptr << std::dec <<
";\n";
117 out <<
" static constexpr Tagged_t kFirstAllocatedRoot = 0x" << std::hex
118 <<
gen.sorted_roots().cbegin()->first << std::dec <<
";\n";
119 out <<
" static constexpr Tagged_t kLastAllocatedRoot = 0x" << std::hex
120 <<
gen.sorted_roots().crbegin()->first << std::dec <<
";\n";
124 out <<
"\nstatic constexpr std::array<Tagged_t, " << size
125 <<
"> StaticReadOnlyRootsPointerTable = {\n";
128#define ENTRY(_1, _2, CamelName) \
129 out << " StaticReadOnlyRoot::k" << #CamelName << ",\n";
135 <<
"} // namespace internal\n"
136 <<
"} // namespace v8\n"
137 <<
"#endif // V8_STATIC_ROOTS_BOOL\n"
138 <<
"#endif // V8_ROOTS_STATIC_ROOTS_H_\n";
constexpr int kRegularPageSize
const std::map< Tagged_t, std::list< RootIndex > > & sorted_roots()
const std::string & camel_name(RootIndex idx)
std::map< Tagged_t, std::list< RootIndex > > sorted_roots_
StaticRootsTableGenImpl(Isolate *isolate)
std::unordered_map< RootIndex, std::string > camel_names_
static void write(Isolate *isolate, const char *file)
#define V8_STATIC_ROOTS_GENERATION_BOOL
#define READ_ONLY_ROOT_LIST(V)
#define CHECK_LT(lhs, rhs)
#define CHECK_WITH_MSG(condition, message)
#define ADD_ROOT(_, value, CamelName)
#define V8_STATIC_ROOTS_BOOL