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: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66967}
This commit is contained in:
Michael Lippautz 2020-04-02 16:44:38 +02:00 committed by Commit Bot
parent 3b4b736a90
commit f00a02bb8d
2 changed files with 61 additions and 0 deletions

View File

@ -352,6 +352,10 @@ config("cppgc_base_config") {
if (is_clang) {
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") {
if (is_clang) {
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 = [

View File

@ -0,0 +1,53 @@
// 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