5 #include "include/v8.h" 6 #include "src/frame-constants.h" 7 #include "src/globals.h" 16 const i::byte* pc_as_byte =
reinterpret_cast<i::byte*
>(pc);
17 const i::byte* start =
reinterpret_cast<const i::byte*
>(code_range.start);
18 const i::byte* end = start + code_range.length_in_bytes;
19 return pc_as_byte >= start && pc_as_byte < end;
22 bool IsInUnsafeJSEntryRange(
const v8::JSEntryStub& js_entry_stub,
void* pc) {
23 return PCIsInCodeRange(js_entry_stub.code, pc);
32 return *
reinterpret_cast<i::Address*
>(address);
35 void* GetReturnAddressFromFP(
void* fp) {
36 return reinterpret_cast<void*
>(
37 Load(reinterpret_cast<i::Address>(fp) +
38 i::CommonFrameConstants::kCallerPCOffset));
41 void* GetCallerFPFromFP(
void* fp) {
42 return reinterpret_cast<void*
>(
43 Load(reinterpret_cast<i::Address>(fp) +
44 i::CommonFrameConstants::kCallerFPOffset));
47 void* GetCallerSPFromFP(
void* fp) {
48 return reinterpret_cast<void*
>(
reinterpret_cast<i::Address>(fp) +
49 i::CommonFrameConstants::kCallerSPOffset);
54 bool Unwinder::TryUnwindV8Frames(
const UnwindState& unwind_state,
55 RegisterState* register_state,
56 const void* stack_base) {
57 void* pc = register_state->pc;
58 if (PCIsInV8(unwind_state, pc) &&
59 !IsInUnsafeJSEntryRange(unwind_state.js_entry_stub, pc)) {
60 void* current_fp = register_state->fp;
64 void* next_pc = GetReturnAddressFromFP(current_fp);
65 while (PCIsInV8(unwind_state, next_pc)) {
66 current_fp = GetCallerFPFromFP(current_fp);
67 next_pc = GetReturnAddressFromFP(current_fp);
70 register_state->sp = GetCallerSPFromFP(current_fp);
71 register_state->fp = GetCallerFPFromFP(current_fp);
72 register_state->pc = next_pc;
78 bool Unwinder::PCIsInV8(
const UnwindState& unwind_state,
void* pc) {
79 return pc && (PCIsInCodeRange(unwind_state.code_range, pc) ||
80 PCIsInCodeRange(unwind_state.embedded_code_range, pc));