diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-02-04 19:59:59 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-02-08 20:08:09 -0800 |
commit | 3ab49b1c822cf8c5748fa4de0ac970c948de6f8a (patch) | |
tree | 0696141de5cddb0755c91ff21befd313bf0b9e29 /libgo | |
parent | e52a683170877d140eebc9782731eaf11897db71 (diff) | |
download | gcc-3ab49b1c822cf8c5748fa4de0ac970c948de6f8a.tar.gz |
compiler, internal/abi: implement FuncPCABI0, FuncPCABIInternal
The Go 1.18 standard library uses an internal/abi package with two
functions that are implemented in the compiler. This patch implements
them in the gofrontend, to support the upcoming update to 1.18.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/383514
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/internal/abi/abi.go | 35 | ||||
-rw-r--r-- | libgo/go/runtime/proc.go | 11 | ||||
-rw-r--r-- | libgo/libgo-packages.txt | 1 |
3 files changed, 42 insertions, 5 deletions
diff --git a/libgo/go/internal/abi/abi.go b/libgo/go/internal/abi/abi.go new file mode 100644 index 00000000000..c4a108847ca --- /dev/null +++ b/libgo/go/internal/abi/abi.go @@ -0,0 +1,35 @@ +// Copyright 2020 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. + +package abi + +// FuncPC* intrinsics. +// +// CAREFUL: In programs with plugins, FuncPC* can return different values +// for the same function (because there are actually multiple copies of +// the same function in the address space). To be safe, don't use the +// results of this function in any == expression. It is only safe to +// use the result as an address at which to start executing code. + +// FuncPCABI0 returns the entry PC of the function f, which must be a +// direct reference of a function defined as ABI0. Otherwise it is a +// compile-time error. +// +// Implemented as a compile intrinsic. +func FuncPCABI0(f any) uintptr { + // The compiler should remove all calls. + panic("FuncPCABI0") +} + +// FuncPCABIInternal returns the entry PC of the function f. If f is a +// direct reference of a function, it must be defined as ABIInternal. +// Otherwise it is a compile-time error. If f is not a direct reference +// of a defined function, it assumes that f is a func value. Otherwise +// the behavior is undefined. +// +// Implemented as a compile intrinsic. +func FuncPCABIInternal(f any) uintptr { + // The compiler should remove all calls. + panic("FuncPCABIInternal") +} diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index 05342905ff1..343f13b40f0 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -5,6 +5,7 @@ package runtime import ( + "internal/abi" "internal/cpu" "runtime/internal/atomic" "runtime/internal/sys" @@ -4243,11 +4244,11 @@ func _GC() { _GC() } func _LostSIGPROFDuringAtomic64() { _LostSIGPROFDuringAtomic64() } func _VDSO() { _VDSO() } -var _SystemPC = funcPC(_System) -var _ExternalCodePC = funcPC(_ExternalCode) -var _LostExternalCodePC = funcPC(_LostExternalCode) -var _GCPC = funcPC(_GC) -var _LostSIGPROFDuringAtomic64PC = funcPC(_LostSIGPROFDuringAtomic64) +var _SystemPC = abi.FuncPCABIInternal(_System) +var _ExternalCodePC = abi.FuncPCABIInternal(_ExternalCode) +var _LostExternalCodePC = abi.FuncPCABIInternal(_LostExternalCode) +var _GCPC = abi.FuncPCABIInternal(_GC) +var _LostSIGPROFDuringAtomic64PC = abi.FuncPCABIInternal(_LostSIGPROFDuringAtomic64) // Called if we receive a SIGPROF signal. // Called by the signal handler, may run during STW. diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt index 4fc8c843f02..f3097dc0a6a 100644 --- a/libgo/libgo-packages.txt +++ b/libgo/libgo-packages.txt @@ -113,6 +113,7 @@ image/internal/imageutil image/jpeg image/png index/suffixarray +internal/abi internal/buildcfg internal/bytealg internal/cfg |