Commit f00a02bb authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

cppgc: Conservative stack scan for non-Windows ia32 on clang

The difference to Chromium is that we support frame pointers and thus
integrate better with debugging in e.g. gdb.

Bug: chromium:1056170
Change-Id: I2109744d07a7b3af158ed3e0fe731f890b192eee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2129630
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66967}
parent 3b4b736a
...@@ -352,6 +352,10 @@ config("cppgc_base_config") { ...@@ -352,6 +352,10 @@ config("cppgc_base_config") {
if (is_clang) { if (is_clang) {
defines = [ "CPPGC_SUPPORTS_CONSERVATIVE_STACK_SCAN" ] defines = [ "CPPGC_SUPPORTS_CONSERVATIVE_STACK_SCAN" ]
} }
} else if (target_cpu == "x86") {
if (is_clang && !is_win) {
defines = [ "CPPGC_SUPPORTS_CONSERVATIVE_STACK_SCAN" ]
}
} }
} }
...@@ -3967,6 +3971,10 @@ v8_source_set("cppgc_base") { ...@@ -3967,6 +3971,10 @@ v8_source_set("cppgc_base") {
if (is_clang) { if (is_clang) {
sources += [ "src/heap/cppgc/asm/x64/push_registers_clang.cc" ] sources += [ "src/heap/cppgc/asm/x64/push_registers_clang.cc" ]
} }
} else if (target_cpu == "x86") {
if (is_clang && !is_win) {
sources += [ "src/heap/cppgc/asm/ia32/push_registers_clang.cc" ]
}
} }
configs = [ configs = [
......
// Copyright 2020 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.
// Push all callee-saved registers to get them on the stack for conservative
// stack scanning.
//
// See asm/x64/push_registers_clang.cc for why the function is not generated
// using clang.
// Do not depend on V8_TARGET_OS_* defines as some embedders may override the
// GN toolchain (e.g. ChromeOS) and not provide them.
#ifdef _WIN32
#error "Not yet supported"
#else // !_WIN32
// We maintain 16-byte alignment at calls. There is an 4-byte return address
// on the stack and we push 28 bytes which maintains 16-byte stack alignment
// at the call.
//
// The following assumes cdecl calling convention.
// Source: https://en.wikipedia.org/wiki/X86_calling_conventions#cdecl
asm(".globl PushAllRegistersAndIterateStack \n"
".hidden PushAllRegistersAndIterateStack \n"
"PushAllRegistersAndIterateStack: \n"
// [ IterateStackCallback ]
// [ StackVisitor* ]
// [ Stack* ]
// [ ret ]
// ebp is callee-saved. Maintain proper frame pointer for debugging.
" push %ebp \n"
" movl %esp, %ebp \n"
" push %ebx \n"
" push %esi \n"
" push %edi \n"
// Save 3rd parameter (IterateStackCallback).
" movl 28(%esp), %ecx \n"
// Pass 3rd parameter as esp (stack pointer).
" push %esp \n"
// Pass 2nd parameter (StackVisitor*).
" push 28(%esp) \n"
// Pass 1st parameter (Stack*).
" push 28(%esp) \n"
" call *%ecx \n"
// Pop the callee-saved registers.
" addl $24, %esp \n"
// Restore rbp as it was used as frame pointer.
" pop %ebp \n"
" ret \n");
#endif // !_WIN32
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