Skip to content
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

[SR-13459] type metadata accessor for private swift-native class should be a single memory access #55901

Closed
dabrahams opened this issue Aug 27, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@dabrahams
Copy link
Collaborator

Previous ID SR-13459
Radar None
Original Reporter @dabrahams
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 5dfac902494d755369487814799729ee

relates to:

  • SR-13469 Call to objc_opt_self slows access to non-generic class metadata

Issue Description:

Instead it compiles into two function calls

private class X {}
func disassembleMe() -> Any.Type {
  return X.self
}

becomes:

x.disassembleMe() -> Any.Type:
    pushq   %rbp
    movq    %rsp, %rbp
    xorl    %edi, %edi
    popq    %rbp
    jmp type metadata accessor for x.(X in _613077CFEB536AFE339AC751B60607CD)

    .p2align    4, 0x90
type metadata accessor for x.(X in _613077CFEB536AFE339AC751B60607CD):
    pushq   %rax
    leaq    full type metadata for x.(X in _613077CFEB536AFE339AC751B60607CD)+16(%rip), %rdi
    callq   _objc_opt_self
    xorl    %edx, %edx
    popq    %rcx
    retq

/cc @eeckstein

@dabrahams
Copy link
Collaborator Author

We can't eliminate the call because of objc interop 🙁.
Best we could do is store the result in a `static let`, but I can do that manually.

@dabrahams
Copy link
Collaborator Author

FWIW, for my use case, the `static let`is a significant speedup.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant