Skip to content

Commit d4cb7a4

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[vm] Fix COPY_FP_REGISTER for Windows x64, arm, arm64.
This should improve DumpStackTrace from assertion failures, though x64 still doesn't work for lack of frame pointers in the runtime code. TEST=manually add assertion failure. Change-Id: Ie632f79b21fd14a2ece3cde23736adc097938315 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419800 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent c5adfd2 commit d4cb7a4

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

runtime/vm/globals.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,27 +183,16 @@ static constexpr uword kZapUninitializedWord = 0xabababababababab;
183183
static constexpr intptr_t kAllocationCanary = 123;
184184

185185
// Macros to get the contents of the fp register.
186-
#if defined(DART_HOST_OS_WINDOWS)
187-
188-
// clang-format off
189-
#if defined(HOST_ARCH_IA32)
186+
#if __GNUC__
190187
#define COPY_FP_REGISTER(fp) \
191-
__asm { mov fp, ebp} \
192-
; // NOLINT
193-
// clang-format on
188+
fp = reinterpret_cast<uintptr_t>(__builtin_frame_address(0))
189+
#elif _MSC_VER
190+
#define COPY_FP_REGISTER(fp) \
191+
fp = reinterpret_cast<uintptr_t>(_AddressOfReturnAddress()) - kWordSize
194192
#else
195-
// Inline assembly is only available on x86; return the stack pointer instead.
196-
#define COPY_FP_REGISTER(fp) fp = OSThread::GetCurrentStackPointer();
193+
#define COPY_FP_REGISTER(fp) fp = 0
197194
#endif
198195

199-
#else // !defined(DART_HOST_OS_WINDOWS))
200-
201-
// Assume GCC-compatible builtins.
202-
#define COPY_FP_REGISTER(fp) \
203-
fp = reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
204-
205-
#endif // !defined(DART_HOST_OS_WINDOWS))
206-
207196
#if defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_ARM64) || \
208197
defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_RISCV32) || \
209198
defined(TARGET_ARCH_RISCV64)

0 commit comments

Comments
 (0)