Commit 4be9de90 authored by ishell@chromium.org's avatar ishell@chromium.org Committed by V8 LUCI CQ

[api] Add v8::CrashKeyId::kCodeRangeBaseAddress

... when the code range is created. This key should be more helpful
than the existing kCodeSpaceFirstPageAddress crash key, especially
for the cases when snapshot does not contain Code objects and thus
the code space is not created during Isolate initialization.

The mid-term plan is to remove the latter in favour of the former
since the default configuration does not imply creation of the code
space.

Bug: v8:11880
Change-Id: Icdea38723c7ed73605c2df6589ec01193571d55c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3849038Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82667}
parent 3094a923
......@@ -238,6 +238,7 @@ enum class CrashKeyId {
kIsolateAddress,
kReadonlySpaceFirstPageAddress,
kMapSpaceFirstPageAddress,
kCodeRangeBaseAddress,
kCodeSpaceFirstPageAddress,
kDumpType,
kSnapshotChecksumCalculated,
......
......@@ -3965,11 +3965,18 @@ void Isolate::AddCrashKeysForIsolateAndHeapPointers() {
ToHexString(map_space_firstpage_address));
}
const uintptr_t code_space_firstpage_address =
heap()->code_space()->FirstPageAddress();
add_crash_key_callback_(v8::CrashKeyId::kCodeSpaceFirstPageAddress,
ToHexString(code_space_firstpage_address));
if (heap()->code_range_base()) {
const uintptr_t code_range_base_address = heap()->code_range_base();
add_crash_key_callback_(v8::CrashKeyId::kCodeRangeBaseAddress,
ToHexString(code_range_base_address));
}
if (!V8_REMOVE_BUILTINS_CODE_OBJECTS || heap()->code_space()->first_page()) {
const uintptr_t code_space_firstpage_address =
heap()->code_space()->FirstPageAddress();
add_crash_key_callback_(v8::CrashKeyId::kCodeSpaceFirstPageAddress,
ToHexString(code_space_firstpage_address));
}
const v8::StartupData* data = Snapshot::DefaultSnapshotBlob();
// TODO(cbruni): Implement strategy to infrequently collect this.
const uint32_t v8_snapshot_checkum_calculated = 0;
......
......@@ -188,7 +188,10 @@ class V8_EXPORT_PRIVATE Space : public BaseSpace {
FreeList* free_list() { return free_list_.get(); }
Address FirstPageAddress() const { return first_page()->address(); }
Address FirstPageAddress() const {
DCHECK_NOT_NULL(first_page());
return first_page()->address();
}
#ifdef DEBUG
virtual void Print() = 0;
......
......@@ -134,19 +134,37 @@ TEST_F(IncumbentContextTest, Basic) {
}
namespace {
thread_local std::map<v8::CrashKeyId, std::string> crash_keys;
thread_local std::multimap<v8::CrashKeyId, std::string> crash_keys;
void CrashKeyCallback(v8::CrashKeyId id, const std::string& value) {
EXPECT_EQ(crash_keys.count(id), 0u);
crash_keys[id] = value;
crash_keys.insert({id, value});
}
} // namespace
TEST_F(IsolateTest, SetAddCrashKeyCallback) {
isolate()->SetAddCrashKeyCallback(CrashKeyCallback);
internal::Isolate* i_isolate =
reinterpret_cast<internal::Isolate*>(isolate());
const bool has_map_space = i_isolate->heap()->map_space() != nullptr;
EXPECT_EQ(crash_keys.size(), has_map_space ? 6u : 5u);
i::Isolate* i_isolate = reinterpret_cast<internal::Isolate*>(isolate());
i::Heap* heap = i_isolate->heap();
size_t expected_keys_count = 4;
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kIsolateAddress), 1u);
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kReadonlySpaceFirstPageAddress),
1u);
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kSnapshotChecksumCalculated), 1u);
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kSnapshotChecksumExpected), 1u);
if (heap->map_space()) {
++expected_keys_count;
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kMapSpaceFirstPageAddress), 1u);
}
if (heap->code_range_base()) {
++expected_keys_count;
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kCodeRangeBaseAddress), 1u);
}
if (heap->code_space()->first_page()) {
++expected_keys_count;
EXPECT_EQ(crash_keys.count(v8::CrashKeyId::kCodeSpaceFirstPageAddress), 1u);
}
EXPECT_EQ(crash_keys.size(), expected_keys_count);
}
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment