Skip to content

Commit 9c5eed7

Browse files
santiaboyCommit Bot
authored andcommitted
[unwinder] Delete the old unwinder API
The new one was created in https://chromium-review.googlesource.com/c/v8/v8/+/1969900, and the old API was deprecated in https://chromium-review.googlesource.com/c/v8/v8/+/2110015, so now we can remove it. Bug: v8:8116 Change-Id: Ia839279609b412c36f1f17368acef23fe07e7c61 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2369174 Reviewed-by: Peter Marshall <petermarshall@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org> Cr-Commit-Position: refs/heads/master@{#69536}
1 parent 58f047a commit 9c5eed7

6 files changed

Lines changed: 10 additions & 855 deletions

File tree

‎include/v8.h‎

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,14 +2260,6 @@ struct JSEntryStub {
22602260
MemoryRange code;
22612261
};
22622262

2263-
struct UnwindState {
2264-
MemoryRange code_range;
2265-
MemoryRange embedded_code_range;
2266-
JSEntryStub js_entry_stub;
2267-
JSEntryStub js_construct_entry_stub;
2268-
JSEntryStub js_run_microtasks_entry_stub;
2269-
};
2270-
22712263
struct JSEntryStubs {
22722264
JSEntryStub js_entry_stub;
22732265
JSEntryStub js_construct_entry_stub;
@@ -9325,13 +9317,6 @@ class V8_EXPORT Isolate {
93259317
*/
93269318
void GetCodeRange(void** start, size_t* length_in_bytes);
93279319

9328-
/**
9329-
* Returns the UnwindState necessary for use with the Unwinder API.
9330-
*/
9331-
// TODO(petermarshall): Remove this API.
9332-
V8_DEPRECATED("Use entry_stubs + code_pages version.")
9333-
UnwindState GetUnwindState();
9334-
93359320
/**
93369321
* Returns the JSEntryStubs necessary for use with the Unwinder API.
93379322
*/
@@ -10689,12 +10674,14 @@ class V8_EXPORT Unwinder {
1068910674
*
1069010675
* The unwinder also needs the virtual memory range of all possible V8 code
1069110676
* objects. There are two ranges required - the heap code range and the range
10692-
* for code embedded in the binary. The V8 API provides all required inputs
10693-
* via an UnwindState object through the Isolate::GetUnwindState() API. These
10694-
* values will not change after Isolate initialization, so the same
10695-
* |unwind_state| can be used for multiple calls.
10677+
* for code embedded in the binary.
10678+
*
10679+
* Available on x64, ARM64 and ARM32.
1069610680
*
10697-
* \param unwind_state Input state for the Isolate that the stack comes from.
10681+
* \param code_pages A list of all of the ranges in which V8 has allocated
10682+
* executable code. The caller should obtain this list by calling
10683+
* Isolate::CopyCodePages() during the same interrupt/thread suspension that
10684+
* captures the stack.
1069810685
* \param register_state The current registers. This is an in-out param that
1069910686
* will be overwritten with the register values after unwinding, on success.
1070010687
* \param stack_base The resulting stack pointer and frame pointer values are
@@ -10705,41 +10692,20 @@ class V8_EXPORT Unwinder {
1070510692
*
1070610693
* \return True on success.
1070710694
*/
10708-
// TODO(petermarshall): Remove this API
10709-
V8_DEPRECATED("Use entry_stubs + code_pages version.")
10710-
static bool TryUnwindV8Frames(const UnwindState& unwind_state,
10711-
RegisterState* register_state,
10712-
const void* stack_base);
10713-
10714-
/**
10715-
* The same as above, but is available on x64, ARM64 and ARM32.
10716-
*
10717-
* \param code_pages A list of all of the ranges in which V8 has allocated
10718-
* executable code. The caller should obtain this list by calling
10719-
* Isolate::CopyCodePages() during the same interrupt/thread suspension that
10720-
* captures the stack.
10721-
*/
1072210695
static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
1072310696
size_t code_pages_length,
1072410697
const MemoryRange* code_pages,
1072510698
RegisterState* register_state,
1072610699
const void* stack_base);
1072710700

1072810701
/**
10729-
* Whether the PC is within the V8 code range represented by code_range or
10730-
* embedded_code_range in |unwind_state|.
10702+
* Whether the PC is within the V8 code range represented by code_pages.
1073110703
*
1073210704
* If this returns false, then calling UnwindV8Frames() with the same PC
1073310705
* and unwind_state will always fail. If it returns true, then unwinding may
1073410706
* (but not necessarily) be successful.
10735-
*/
10736-
// TODO(petermarshall): Remove this API
10737-
V8_DEPRECATED("Use code_pages version.")
10738-
static bool PCIsInV8(const UnwindState& unwind_state, void* pc);
10739-
10740-
/**
10741-
* The same as above, but is available on x64, ARM64 and ARM32. See the
10742-
* comment on TryUnwindV8Frames.
10707+
*
10708+
* Available on x64, ARM64 and ARM32
1074310709
*/
1074410710
static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
1074510711
void* pc);

‎src/api/api.cc‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8933,33 +8933,6 @@ void Isolate::GetCodeRange(void** start, size_t* length_in_bytes) {
89338933
*length_in_bytes = code_range.size();
89348934
}
89358935

8936-
UnwindState Isolate::GetUnwindState() {
8937-
UnwindState unwind_state;
8938-
void* code_range_start;
8939-
GetCodeRange(&code_range_start, &unwind_state.code_range.length_in_bytes);
8940-
unwind_state.code_range.start = code_range_start;
8941-
8942-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8943-
unwind_state.embedded_code_range.start =
8944-
reinterpret_cast<const void*>(isolate->embedded_blob_code());
8945-
unwind_state.embedded_code_range.length_in_bytes =
8946-
isolate->embedded_blob_code_size();
8947-
8948-
std::array<std::pair<i::Builtins::Name, JSEntryStub*>, 3> entry_stubs = {
8949-
{{i::Builtins::kJSEntry, &unwind_state.js_entry_stub},
8950-
{i::Builtins::kJSConstructEntry, &unwind_state.js_construct_entry_stub},
8951-
{i::Builtins::kJSRunMicrotasksEntry,
8952-
&unwind_state.js_run_microtasks_entry_stub}}};
8953-
for (auto& pair : entry_stubs) {
8954-
i::Code js_entry = isolate->heap()->builtin(pair.first);
8955-
pair.second->code.start =
8956-
reinterpret_cast<const void*>(js_entry.InstructionStart());
8957-
pair.second->code.length_in_bytes = js_entry.InstructionSize();
8958-
}
8959-
8960-
return unwind_state;
8961-
}
8962-
89638936
JSEntryStubs Isolate::GetJSEntryStubs() {
89648937
JSEntryStubs entry_stubs;
89658938

‎src/diagnostics/unwinder.cc‎

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ bool PCIsInCodePages(size_t code_pages_length, const MemoryRange* code_pages,
4646
return it->start <= pc && pc < CalculateEnd(it->start, it->length_in_bytes);
4747
}
4848

49-
bool IsInJSEntryRange(const UnwindState& unwind_state, void* pc) {
50-
return PCIsInCodeRange(unwind_state.js_entry_stub.code, pc) ||
51-
PCIsInCodeRange(unwind_state.js_construct_entry_stub.code, pc) ||
52-
PCIsInCodeRange(unwind_state.js_run_microtasks_entry_stub.code, pc);
53-
}
54-
55-
bool IsInUnsafeJSEntryRange(const UnwindState& unwind_state, void* pc) {
56-
return IsInJSEntryRange(unwind_state, pc);
57-
58-
// TODO(petermarshall): We can be more precise by checking whether we are
59-
// in JSEntry but after frame setup and before frame teardown, in which case
60-
// we are safe to unwind the stack. For now, we bail out if the PC is anywhere
61-
// within JSEntry.
62-
}
63-
6449
bool IsInJSEntryRange(const JSEntryStubs& entry_stubs, void* pc) {
6550
return PCIsInCodeRange(entry_stubs.js_entry_stub.code, pc) ||
6651
PCIsInCodeRange(entry_stubs.js_construct_entry_stub.code, pc) ||
@@ -80,19 +65,6 @@ i::Address Load(i::Address address) {
8065
return *reinterpret_cast<i::Address*>(address);
8166
}
8267

83-
void* GetReturnAddressFromFP(void* fp, void* pc,
84-
const v8::UnwindState& unwind_state) {
85-
int caller_pc_offset = i::CommonFrameConstants::kCallerPCOffset;
86-
#ifdef V8_TARGET_ARCH_ARM64
87-
if (IsInJSEntryRange(unwind_state, pc)) {
88-
caller_pc_offset = i::EntryFrameConstants::kDirectCallerPCOffset;
89-
}
90-
#endif
91-
i::Address ret_addr =
92-
Load(reinterpret_cast<i::Address>(fp) + caller_pc_offset);
93-
return reinterpret_cast<void*>(i::PointerAuthentication::StripPAC(ret_addr));
94-
}
95-
9668
void* GetReturnAddressFromFP(void* fp, void* pc,
9769
const JSEntryStubs& entry_stubs) {
9870
int caller_pc_offset = i::CommonFrameConstants::kCallerPCOffset;
@@ -106,18 +78,6 @@ void* GetReturnAddressFromFP(void* fp, void* pc,
10678
return reinterpret_cast<void*>(i::PointerAuthentication::StripPAC(ret_addr));
10779
}
10880

109-
void* GetCallerFPFromFP(void* fp, void* pc,
110-
const v8::UnwindState& unwind_state) {
111-
int caller_fp_offset = i::CommonFrameConstants::kCallerFPOffset;
112-
#ifdef V8_TARGET_ARCH_ARM64
113-
if (IsInJSEntryRange(unwind_state, pc)) {
114-
caller_fp_offset = i::EntryFrameConstants::kDirectCallerFPOffset;
115-
}
116-
#endif
117-
return reinterpret_cast<void*>(
118-
Load(reinterpret_cast<i::Address>(fp) + caller_fp_offset));
119-
}
120-
12181
void* GetCallerFPFromFP(void* fp, void* pc, const JSEntryStubs& entry_stubs) {
12282
int caller_fp_offset = i::CommonFrameConstants::kCallerFPOffset;
12383
#ifdef V8_TARGET_ARCH_ARM64
@@ -129,18 +89,6 @@ void* GetCallerFPFromFP(void* fp, void* pc, const JSEntryStubs& entry_stubs) {
12989
Load(reinterpret_cast<i::Address>(fp) + caller_fp_offset));
13090
}
13191

132-
void* GetCallerSPFromFP(void* fp, void* pc,
133-
const v8::UnwindState& unwind_state) {
134-
int caller_sp_offset = i::CommonFrameConstants::kCallerSPOffset;
135-
#ifdef V8_TARGET_ARCH_ARM64
136-
if (IsInJSEntryRange(unwind_state, pc)) {
137-
caller_sp_offset = i::EntryFrameConstants::kDirectCallerSPOffset;
138-
}
139-
#endif
140-
return reinterpret_cast<void*>(reinterpret_cast<i::Address>(fp) +
141-
caller_sp_offset);
142-
}
143-
14492
void* GetCallerSPFromFP(void* fp, void* pc, const JSEntryStubs& entry_stubs) {
14593
int caller_sp_offset = i::CommonFrameConstants::kCallerSPOffset;
14694
#ifdef V8_TARGET_ARCH_ARM64
@@ -159,46 +107,6 @@ bool AddressIsInStack(const void* address, const void* stack_base,
159107

160108
} // namespace
161109

162-
bool Unwinder::TryUnwindV8Frames(const UnwindState& unwind_state,
163-
RegisterState* register_state,
164-
const void* stack_base) {
165-
const void* stack_top = register_state->sp;
166-
167-
void* pc = register_state->pc;
168-
if (PCIsInV8(unwind_state, pc) && !IsInUnsafeJSEntryRange(unwind_state, pc)) {
169-
void* current_fp = register_state->fp;
170-
if (!AddressIsInStack(current_fp, stack_base, stack_top)) return false;
171-
172-
// Peek at the return address that the caller pushed. If it's in V8, then we
173-
// assume the caller frame is a JS frame and continue to unwind.
174-
void* next_pc = GetReturnAddressFromFP(current_fp, pc, unwind_state);
175-
while (PCIsInV8(unwind_state, next_pc)) {
176-
current_fp = GetCallerFPFromFP(current_fp, pc, unwind_state);
177-
if (!AddressIsInStack(current_fp, stack_base, stack_top)) return false;
178-
pc = next_pc;
179-
next_pc = GetReturnAddressFromFP(current_fp, pc, unwind_state);
180-
}
181-
182-
void* final_sp = GetCallerSPFromFP(current_fp, pc, unwind_state);
183-
if (!AddressIsInStack(final_sp, stack_base, stack_top)) return false;
184-
register_state->sp = final_sp;
185-
186-
// We don't check that the final FP value is within the stack bounds because
187-
// this is just the rbp value that JSEntryStub pushed. On platforms like
188-
// Win64 this is not used as a dedicated FP register, and could contain
189-
// anything.
190-
void* final_fp = GetCallerFPFromFP(current_fp, pc, unwind_state);
191-
register_state->fp = final_fp;
192-
193-
register_state->pc = next_pc;
194-
195-
// Link register no longer valid after unwinding.
196-
register_state->lr = nullptr;
197-
return true;
198-
}
199-
return false;
200-
}
201-
202110
bool Unwinder::TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
203111
size_t code_pages_length,
204112
const MemoryRange* code_pages,
@@ -242,11 +150,6 @@ bool Unwinder::TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
242150
return false;
243151
}
244152

245-
bool Unwinder::PCIsInV8(const UnwindState& unwind_state, void* pc) {
246-
return pc && (PCIsInCodeRange(unwind_state.code_range, pc) ||
247-
PCIsInCodeRange(unwind_state.embedded_code_range, pc));
248-
}
249-
250153
bool Unwinder::PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
251154
void* pc) {
252155
return pc && PCIsInCodePages(code_pages_length, code_pages, pc);

‎test/cctest/BUILD.gn‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ v8_source_set("cctest_sources") {
267267
"test-unboxed-doubles.cc",
268268
"test-unscopables-hidden-prototype.cc",
269269
"test-unwinder-code-pages.cc",
270-
"test-unwinder.cc",
271270
"test-usecounters.cc",
272271
"test-utils.cc",
273272
"test-version.cc",

‎test/cctest/test-api.cc‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26692,42 +26692,6 @@ TEST(BigIntAPI) {
2669226692
}
2669326693
}
2669426694

26695-
TEST(TestGetUnwindState) {
26696-
LocalContext env;
26697-
v8::Isolate* isolate = env->GetIsolate();
26698-
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
26699-
26700-
// Ignore deprecation warnings so that we can keep the tests for now.
26701-
// TODO(petermarshall): Remove this once the deprecated API is gone.
26702-
#if __clang__
26703-
#pragma clang diagnostic push
26704-
#pragma clang diagnostic ignored "-Wdeprecated"
26705-
#endif
26706-
v8::UnwindState unwind_state = isolate->GetUnwindState();
26707-
#if __clang__
26708-
#pragma clang diagnostic pop
26709-
#endif
26710-
v8::MemoryRange builtins_range = unwind_state.embedded_code_range;
26711-
26712-
// Check that each off-heap builtin is within the builtins code range.
26713-
for (int id = 0; id < i::Builtins::builtin_count; id++) {
26714-
if (!i::Builtins::IsIsolateIndependent(id)) continue;
26715-
i::Code builtin = i_isolate->builtins()->builtin(id);
26716-
i::Address start = builtin.InstructionStart();
26717-
i::Address end = start + builtin.InstructionSize();
26718-
26719-
i::Address builtins_start =
26720-
reinterpret_cast<i::Address>(builtins_range.start);
26721-
CHECK(start >= builtins_start &&
26722-
end < builtins_start + builtins_range.length_in_bytes);
26723-
}
26724-
26725-
v8::JSEntryStub js_entry_stub = unwind_state.js_entry_stub;
26726-
26727-
CHECK_EQ(i_isolate->heap()->builtin(i::Builtins::kJSEntry).InstructionStart(),
26728-
reinterpret_cast<i::Address>(js_entry_stub.code.start));
26729-
}
26730-
2673126695
TEST(GetJSEntryStubs) {
2673226696
LocalContext env;
2673326697
v8::Isolate* isolate = env->GetIsolate();

0 commit comments

Comments
 (0)