diff options
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/internal/abi/abi.go | 35 | ||||
-rw-r--r-- | libgo/go/runtime/proc.go | 11 |
2 files changed, 41 insertions, 5 deletions
diff --git a/libgo/go/internal/abi/abi.go b/libgo/go/internal/abi/abi.go new file mode 100644 index 0000000..c4a1088 --- /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 0534290..343f13b 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. |