Skip to content

Try using a faster class check #23732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stdlib/public/core/Builtin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ internal func _branchHint(_ actual: Bool, expected: Bool) -> Bool {
@usableFromInline
@_silgen_name("_swift_objcClassUsesNativeSwiftReferenceCounting")
internal func _usesNativeSwiftReferenceCounting(_ theClass: AnyClass) -> Bool

/// Returns the class of a non-tagged-pointer Objective-C object
@_effects(readonly)
@_silgen_name("_swift_classOfObjCHeapObject")
internal func _swift_classOfObjCHeapObject(_ object: AnyObject) -> AnyClass
#else
@inlinable
@inline(__always)
Expand Down
7 changes: 1 addition & 6 deletions stdlib/public/core/StringBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ private var kCFStringEncodingUTF8 : _swift_shims_CFStringEncoding {
@inline(__always) get { return 0x8000100 }
}

@_effects(readonly)
private func _unsafeAddressOfCocoaStringClass(_ str: _CocoaString) -> UInt {
return _swift_stdlib_unsafeAddressOfClass(str)
}

internal enum _KnownCocoaString {
case storage
case shared
Expand All @@ -148,7 +143,7 @@ internal enum _KnownCocoaString {
}
#endif

switch _unsafeAddressOfCocoaStringClass(str) {
switch unsafeBitCast(_swift_classOfObjCHeapObject(str), to: UInt.self) {
case unsafeBitCast(__StringStorage.self, to: UInt.self):
self = .storage
case unsafeBitCast(__SharedStringStorage.self, to: UInt.self):
Expand Down
5 changes: 5 additions & 0 deletions stdlib/public/runtime/SwiftObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ static Class _swift_getObjCClassOfAllocated(const void *object) {
class_getInstanceSize(cls), mask));
}

SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API
Class _swift_classOfObjCHeapObject(OpaqueValue *value) {
return _swift_getObjCClassOfAllocated(value);
}

SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API
NSString *swift_stdlib_getDescription(OpaqueValue *value,
const Metadata *type);
Expand Down