mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
compiler: merge runtime.typecodeID and runtime.typeInInterface
This distinction was useful before when reflect wasn't properly supported. Back then it made sense to only include method sets that were actually used in an interface. But now that it is possible to get to other values (for example, by extracting fields from structs) and it is possible to turn them back into interfaces, it is necessary to preserve all method sets that can possibly be used in the program in a type assert, interface assert or interface method call. In the future, this logic will need to be revisited again when reflect.New or reflect.Zero gets implemented. Code size increases a bit in some cases, but usually in a very limited way (except for one outlier in the drivers smoke tests). The next commit will improve the situation significantly.
This commit is contained in:
committed by
Ron Evans
parent
aa7c7b7bd9
commit
bbb2909283
@@ -11,7 +11,7 @@ import (
|
||||
type rawState uint8
|
||||
|
||||
//export llvm.coro.resume
|
||||
func (s *rawState) resume()
|
||||
func coroResume(*rawState)
|
||||
|
||||
type state struct{ *rawState }
|
||||
|
||||
@@ -20,7 +20,7 @@ func noopState() *rawState
|
||||
|
||||
// Resume the task until it pauses or completes.
|
||||
func (t *Task) Resume() {
|
||||
t.state.resume()
|
||||
coroResume(t.state.rawState)
|
||||
}
|
||||
|
||||
// setState is used by the compiler to set the state of the function at the beginning of a function call.
|
||||
|
||||
@@ -107,6 +107,8 @@ type typecodeID struct {
|
||||
|
||||
// The array length, for array types.
|
||||
length uintptr
|
||||
|
||||
methodSet *interfaceMethodInfo // nil or a GEP of an array
|
||||
}
|
||||
|
||||
// structField is used by the compiler to pass information to the interface
|
||||
@@ -118,15 +120,6 @@ type structField struct {
|
||||
embedded bool
|
||||
}
|
||||
|
||||
// Pseudo type used before interface lowering. By using a struct instead of a
|
||||
// function call, this is simpler to reason about during init interpretation
|
||||
// than a function call. Also, by keeping the method set around it is easier to
|
||||
// implement interfaceImplements in the interp package.
|
||||
type typeInInterface struct {
|
||||
typecode *typecodeID // element type, underlying type, or reference to struct fields
|
||||
methodSet *interfaceMethodInfo // nil or a GEP of an array
|
||||
}
|
||||
|
||||
// Pseudo function call used during a type assert. It is used during interface
|
||||
// lowering, to assign the lowest type numbers to the types with the most type
|
||||
// asserts. Also, it is replaced with const false if this type assert can never
|
||||
|
||||
Reference in New Issue
Block a user