compiler: decouple func lowering from interface type codes

There is no good reason for func values to refer to interface type
codes. The only thing they need is a stable identifier for function
signatures, which is easily created as a new kind of globals. Decoupling
makes it easier to change interface related code.
This commit is contained in:
Ayke van Laethem
2021-04-11 02:00:01 +02:00
committed by Ron Evans
parent 8383552552
commit 57271d7eaa
8 changed files with 48 additions and 45 deletions
+3 -3
View File
@@ -16,13 +16,13 @@ type funcValue struct {
// funcValueWithSignature is used before the func lowering pass.
type funcValueWithSignature struct {
funcPtr uintptr // ptrtoint of the actual function pointer
signature *typecodeID // pointer to identify this signature (the value is undef)
funcPtr uintptr // ptrtoint of the actual function pointer
signature *uint8 // external *i8 with a name identifying the function signature
}
// getFuncPtr is a dummy function that may be used if the func lowering pass is
// not used. It is generally too slow but may be a useful fallback to debug the
// func lowering pass.
func getFuncPtr(val funcValue, signature *typecodeID) uintptr {
func getFuncPtr(val funcValue, signature *uint8) uintptr {
return (*funcValueWithSignature)(unsafe.Pointer(val.id)).funcPtr
}