
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.
26 строки
995 Б
LLVM
26 строки
995 Б
LLVM
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64--linux"
|
|
|
|
%runtime.typecodeID = type { %runtime.typecodeID*, i64, %runtime.interfaceMethodInfo* }
|
|
%runtime.interfaceMethodInfo = type { i8*, i64 }
|
|
|
|
@main.v1 = global i1 0
|
|
@"reflect/types.type:named:main.foo" = private constant %runtime.typecodeID { %runtime.typecodeID* @"reflect/types.type:basic:int", i64 0, %runtime.interfaceMethodInfo* null }
|
|
@"reflect/types.type:basic:int" = external constant %runtime.typecodeID
|
|
|
|
|
|
declare i1 @runtime.typeAssert(i64, %runtime.typecodeID*, i8*, i8*)
|
|
|
|
define void @runtime.initAll() unnamed_addr {
|
|
entry:
|
|
call void @main.init()
|
|
ret void
|
|
}
|
|
|
|
define internal void @main.init() unnamed_addr {
|
|
entry:
|
|
; Test type asserts.
|
|
%typecode = call i1 @runtime.typeAssert(i64 ptrtoint (%runtime.typecodeID* @"reflect/types.type:named:main.foo" to i64), %runtime.typecodeID* @"reflect/types.type:named:main.foo", i8* undef, i8* null)
|
|
store i1 %typecode, i1* @main.v1
|
|
ret void
|
|
}
|