diff options
Diffstat (limited to 'deps/v8/src/roots/roots.cc')
-rw-r--r-- | deps/v8/src/roots/roots.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/deps/v8/src/roots/roots.cc b/deps/v8/src/roots/roots.cc index 1f798c94b5..d76360f97a 100644 --- a/deps/v8/src/roots/roots.cc +++ b/deps/v8/src/roots/roots.cc @@ -4,9 +4,11 @@ #include "src/roots/roots.h" +#include "src/common/globals.h" #include "src/objects/elements-kind.h" #include "src/objects/objects-inl.h" #include "src/objects/visitors.h" +#include "src/roots/static-roots.h" namespace v8 { namespace internal { @@ -34,7 +36,7 @@ void ReadOnlyRoots::VerifyNameForProtectors() { Name prev; for (RootIndex root_index = RootIndex::kFirstNameForProtector; root_index <= RootIndex::kLastNameForProtector; ++root_index) { - Name current = Name::cast(Object(at(root_index))); + Name current = Name::cast(object_at(root_index)); DCHECK(IsNameForProtector(current)); if (root_index != RootIndex::kFirstNameForProtector) { // Make sure the objects are adjacent in memory. @@ -56,5 +58,31 @@ READ_ONLY_ROOT_LIST(ROOT_TYPE_CHECK) #undef ROOT_TYPE_CHECK #endif +Handle<HeapNumber> ReadOnlyRoots::FindHeapNumber(double value) { + auto bits = base::bit_cast<uint64_t>(value); + for (auto pos = RootIndex::kFirstHeapNumberRoot; + pos <= RootIndex::kLastHeapNumberRoot; ++pos) { + auto root = HeapNumber::cast(object_at(pos)); + if (base::bit_cast<uint64_t>(root.value()) == bits) { + return Handle<HeapNumber>(GetLocation(pos)); + } + } + return Handle<HeapNumber>(); +} + +void ReadOnlyRoots::InitFromStaticRootsTable(Address cage_base) { + CHECK(V8_STATIC_ROOTS_BOOL); +#if V8_STATIC_ROOTS_BOOL + RootIndex pos = RootIndex::kFirstReadOnlyRoot; + for (auto element : StaticReadOnlyRootsPointerTable) { + auto ptr = V8HeapCompressionScheme::DecompressTagged(cage_base, element); + DCHECK(!is_initialized(pos)); + read_only_roots_[static_cast<size_t>(pos)] = ptr; + ++pos; + } + DCHECK_EQ(static_cast<int>(pos) - 1, RootIndex::kLastReadOnlyRoot); +#endif // V8_STATIC_ROOTS_BOOL +} + } // namespace internal } // namespace v8 |