cppgc: Conservative stack scanning for arm64

Bug: chromium:1056170
Change-Id: I1d6f28f6bc569af75f6d378041f2c6fe94a538c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2135635
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67023}
This commit is contained in:
Michael Lippautz 2020-04-06 16:50:12 +02:00 committed by Commit Bot
parent 043ac205ec
commit ba4e864422
2 changed files with 51 additions and 1 deletions

View File

@ -351,7 +351,8 @@ config("cppgc_base_config") {
# Assume is_clang = false means GCC or other compilers that are compatible
# with gas inline assembly on non-Windows builds.
if (is_clang || !is_win) {
if (target_cpu == "x64" || target_cpu == "x86" || target_cpu == "arm") {
if (target_cpu == "x64" || target_cpu == "x86" || target_cpu == "arm" ||
target_cpu == "arm64") {
defines = [ "CPPGC_SUPPORTS_CONSERVATIVE_STACK_SCAN" ]
}
}
@ -3976,6 +3977,8 @@ v8_source_set("cppgc_base") {
sources += [ "src/heap/cppgc/asm/ia32/push_registers_asm.cc" ]
} else if (target_cpu == "arm") {
sources += [ "src/heap/cppgc/asm/arm/push_registers_asm.cc" ]
} else if (target_cpu == "arm64") {
sources += [ "src/heap/cppgc/asm/arm64/push_registers_asm.cc" ]
}
}

View File

@ -0,0 +1,47 @@
// 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.
// We maintain 16-byte alignment.
//
// Calling convention source:
// https://en.wikipedia.org/wiki/Calling_convention#ARM_(A64)
asm(
#ifdef _WIN64
".globl _PushAllRegistersAndIterateStack \n"
"_PushAllRegistersAndIterateStack: \n"
#else // !_WIN64
".globl PushAllRegistersAndIterateStack \n"
".hidden PushAllRegistersAndIterateStack \n"
"PushAllRegistersAndIterateStack: \n"
#endif // !_WIN64
// x19-x29 are callee-saved.
" stp x19, x20, [sp, #-16]! \n"
" stp x21, x22, [sp, #-16]! \n"
" stp x23, x24, [sp, #-16]! \n"
" stp x25, x26, [sp, #-16]! \n"
" stp x27, x28, [sp, #-16]! \n"
" stp fp, lr, [sp, #-16]! \n"
// Maintain frame pointer.
" mov fp, sp \n"
// Pass 1st parameter (x0) unchanged (Stack*).
// Pass 2nd parameter (x1) unchanged (StackVisitor*).
// Save 3rd parameter (x2; IterateStackCallback)
" mov x7, x2 \n"
// Pass 3rd parameter as sp (stack pointer).
" mov x2, sp \n"
" blr x7 \n"
// Load return address.
" ldr lr, [sp, #8] \n"
// Restore frame pointer and pop all callee-saved registers.
" ldr fp, [sp], #96 \n"
" ret \n");