mirror of
https://github.com/apple/swift.git
synced 2026-06-27 12:25:55 +02:00
4b1fea06b5
* Allow serialization of larger generic functions. So far we only serialized very small generic functions. However, it's important for performance to serialize more generic functions. * Allow serialization of functions which call another function which is already marked as serializable. This can e.g. happen for default argument functions. https://github.com/swiftlang/swift/issues/88441 rdar://174659028
99 lines
1.8 KiB
Swift
99 lines
1.8 KiB
Swift
import Submodule
|
|
import PrivateCModule
|
|
|
|
public func incrementByThree(_ x: Int) -> Int {
|
|
return incrementByOne(x) + 2
|
|
}
|
|
|
|
package func pkgFunc(_ x: Int) -> Int {
|
|
return subPkgFunc(x) + 2
|
|
}
|
|
|
|
public func incrementByThreeWithCall(_ x: Int) -> Int {
|
|
return incrementByOneNoCMO(x) + 2
|
|
}
|
|
|
|
package func pkgFuncNoCMO(_ x: Int) -> Int {
|
|
return subPkgFuncNoCMO(x) + 2
|
|
}
|
|
|
|
public func submoduleKlassMember() -> Int {
|
|
let k = SubmoduleKlass()
|
|
return k.i
|
|
}
|
|
|
|
package func pkgSubmoduleKlassMember() -> Int {
|
|
let k = PkgSubmoduleKlass()
|
|
return k.i
|
|
}
|
|
|
|
public final class ModuleKlass {
|
|
public var i: Int
|
|
|
|
public init() {
|
|
i = 27
|
|
}
|
|
}
|
|
|
|
public func moduleKlassMember() -> Int {
|
|
let k = ModuleKlass()
|
|
return k.i
|
|
}
|
|
|
|
package final class PkgModuleKlass {
|
|
package var i: Int
|
|
|
|
package init() {
|
|
i = 27
|
|
}
|
|
}
|
|
|
|
package func pkgModuleKlassMember() -> Int {
|
|
let k = PkgModuleKlass()
|
|
return k.i
|
|
}
|
|
|
|
public struct ModuleStruct {
|
|
public static var publicFunctionPointer: (Int) -> (Int) = incrementByThree
|
|
public static var privateFunctionPointer: (Int) -> (Int) = { $0 }
|
|
}
|
|
|
|
package struct PkgModuleStruct {
|
|
package static var funcPointer: (Int) -> (Int) = pkgFunc
|
|
package static var closurePointer: (Int) -> (Int) = { $0 }
|
|
}
|
|
|
|
public func callPrivateCFunc() -> Int {
|
|
return Int(privateCFunc())
|
|
}
|
|
|
|
public func usePrivateCVar() -> Int {
|
|
return Int(privateCVar);
|
|
}
|
|
|
|
public struct S {
|
|
@usableFromInline
|
|
final class C {
|
|
@usableFromInline var p: UnsafeMutableRawPointer
|
|
|
|
init(p: UnsafeMutableRawPointer) { self.p = p }
|
|
}
|
|
|
|
@usableFromInline var c: C
|
|
|
|
public let b: Bool
|
|
|
|
public init(p: UnsafeMutableRawPointer, b: Bool) {
|
|
self.c = C(p: p)
|
|
self.b = b
|
|
}
|
|
|
|
public func load<T>(t: T.Type, i: Int) -> T {
|
|
if b {
|
|
return c.p.advanced(by: i).loadUnaligned(as: T.self)
|
|
}
|
|
return c.p.advanced(by: i).load(as: T.self)
|
|
}
|
|
}
|
|
|