-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: adjust frame pointer on stack copy on ARM64
Frame pointer is enabled on ARM64. When copying stacks, the saved frame pointers need to be adjusted. Updates #39524, #40044. Fixes #58432. Change-Id: I73651fdfd1a6cccae26a5ce02e7e86f6c2fb9bf7 Reviewed-on: https://go-review.googlesource.com/c/go/+/241158 Reviewed-by: Felix Geisendörfer <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
- Loading branch information
Showing
5 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build amd64 || arm64 | ||
|
||
package main | ||
|
||
import "unsafe" | ||
|
||
func init() { | ||
register("FramePointerAdjust", FramePointerAdjust) | ||
} | ||
|
||
func FramePointerAdjust() { framePointerAdjust1(0) } | ||
|
||
//go:noinline | ||
func framePointerAdjust1(x int) { | ||
argp := uintptr(unsafe.Pointer(&x)) | ||
fp := *getFP() | ||
if !(argp-0x100 <= fp && fp <= argp+0x100) { | ||
print("saved FP=", fp, " &x=", argp, "\n") | ||
panic("FAIL") | ||
} | ||
|
||
// grow the stack | ||
grow(10000) | ||
|
||
// check again | ||
argp = uintptr(unsafe.Pointer(&x)) | ||
fp = *getFP() | ||
if !(argp-0x100 <= fp && fp <= argp+0x100) { | ||
print("saved FP=", fp, " &x=", argp, "\n") | ||
panic("FAIL") | ||
} | ||
} | ||
|
||
func grow(n int) { | ||
if n > 0 { | ||
grow(n - 1) | ||
} | ||
} | ||
|
||
func getFP() *uintptr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "textflag.h" | ||
|
||
TEXT ·getFP(SB), NOSPLIT|NOFRAME, $0-8 | ||
MOVQ BP, ret+0(FP) | ||
RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
#include "textflag.h" | ||
|
||
TEXT ·getFP(SB), NOSPLIT|NOFRAME, $0-8 | ||
MOVD R29, ret+0(FP) | ||
RET |