Created
February 19, 2024 17:52
-
-
Save deepak1556/4dd8533d90c7ba3a44a683bb879ab5b0 to your computer and use it in GitHub Desktop.
Dump EPT contents for an isolate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2024 the V8 project authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
#include "src/sandbox/external-pointer-table-tracer.h" | |
#include <iostream> | |
#include "src/common/globals.h" | |
#include "src/execution/isolate.h" | |
#include "src/sandbox/external-entity-table-inl.h" | |
#include "src/sandbox/external-pointer-table.h" | |
#include "src/utils/ostreams.h" | |
namespace v8 { | |
namespace internal { | |
// static | |
void EPTTracer::Print(IsolateForSandbox ifs) { | |
//ExternalPointerTable& ept = ifs.isolate()->external_pointer_table(); | |
ExternalPointerTable& shared_ept = ifs.isolate()->shared_external_pointer_table(); | |
StdoutStream os; | |
/*if (reinterpret_cast<ExternalPointerTableEntry*>(ept.base()) != nullptr) { | |
os << "External Pointer Table Layout" << std::endl; | |
os << "Base address: 0x" << std::hex << ept.base() << std::endl; | |
}*/ | |
if (reinterpret_cast<ExternalPointerTableEntry*>(shared_ept.base()) != nullptr) { | |
os << "Shared External Pointer Table Layout" << std::endl; | |
os << "Base address: 0x" << std::hex << shared_ept.base() << std::endl; | |
auto* space = ifs.isolate()->shared_external_pointer_space(); | |
DCHECK(space->BelongsTo(&shared_ept)); | |
base::MutexGuard guard(&space->mutex_); | |
if (!space->is_empty()) { | |
os << "Number of segments in the space: " << space->num_segments() << std::endl; | |
for (auto segment : space->segments_) { | |
os << "Segment: " << segment.number() << std::endl; | |
uint32_t first = segment.first_entry(); | |
uint32_t last = segment.last_entry(); | |
os << "| Index | Marked | Encoded Address | Description |" << std::endl; | |
for (uint32_t i = first; i < last; i++) { | |
auto& entry = reinterpret_cast<ExternalPointerTableEntry*>(shared_ept.base())[i]; | |
bool is_freelist = entry.GetRawPayload().ContainsFreelistLink(); | |
if (is_freelist) | |
continue; | |
bool is_marked = entry.GetRawPayload().HasMarkBitSet(); | |
os << "| " << i << " | " << is_marked << " | "; | |
uint64_t value = static_cast<uint64_t>(entry.GetRawPayload().encoded_word()); | |
for (int i = 63; i >= 0; --i) { | |
if (value & (1ULL << i)) { | |
os << '1'; | |
} else { | |
os << '0'; | |
} | |
} | |
if (is_freelist) { | |
//uint32_t next_free_entry = entry.GetRawPayload().ExtractFreelistLink(); | |
//os << " | Next free entry index: " << next_free_entry << " |" << std::endl; | |
} else { | |
os << " | External pointer object |" << std::endl; | |
} | |
} | |
} | |
} | |
} | |
os << std::endl << std::flush; | |
} | |
} // namespace internal | |
} // namespace v8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
demohan@Deepaks-MacBook-Pro v8 % ./out/Release/d8 --expose-gc --expose-externalize-string ./test/mjsunit/large-external-string.js | |
Address of resource data to validate: 0x600002afcb91 | |
Shared External Pointer Table Layout | |
Base address: 0x340000000 | |
Number of segments in the space: 1 | |
Segment: 1 | |
| Index | Marked | Encoded Address | Description | | |
| 1000 | 1 | 0100000000010111011000000000000000000000000111111100001010000000 | External pointer object | | |
| 1001 | 1 | 0100000000011011011000000000000000000010101011111100101110010001 | External pointer object | | |
Address of resource to validate: 0x6000001fc280 | |
Address of resource data to validate: 0x125705171 | |
Shared External Pointer Table Layout | |
Base address: 0x340000000 | |
Number of segments in the space: 1 | |
Segment: 1 | |
| Index | Marked | Encoded Address | Description | | |
| 1000 | 1 | 0100000000010111011000000000000000000000000111111100001010000000 | External pointer object | | |
| 1001 | 1 | 0100000000011011011000000000000000000010101011111100101110010001 | External pointer object | | |
| 1002 | 1 | 0100000000010111011000000000000000000000000111111100001010100000 | External pointer object | | |
| 1003 | 1 | 0100000000011011000000000000000100100101011100000101000101110001 | External pointer object | | |
Address of resource to validate: 0x6000001fc2a0 | |
Address of resource data to validate: 0x1181c0000 | |
Shared External Pointer Table Layout | |
Base address: 0x340000000 | |
Number of segments in the space: 1 | |
Segment: 1 | |
| Index | Marked | Encoded Address | Description | | |
| 1000 | 1 | 0100000000010111011000000000000000000000000111111100001010000000 | External pointer object | | |
| 1001 | 1 | 0100000000011011011000000000000000000010101011111100101110010001 | External pointer object | | |
| 1002 | 1 | 0100000000010111011000000000000000000000000111111100001010100000 | External pointer object | | |
| 1003 | 1 | 0100000000011011000000000000000100100101011100000101000101110001 | External pointer object | | |
| 1004 | 1 | 0100000000010111011000000000000000000000000111101000100001000000 | External pointer object | | |
| 1005 | 1 | 0100000000011011000000000000000100011000000111000000000000000000 | External pointer object | | |
demohan@Deepaks-MacBook-Pro v8 % |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Table layout with separate space for double pointer-sized word entries