-
Notifications
You must be signed in to change notification settings - Fork 351
Let SwiftLanguageRuntime depend on a Swift language runtime being present #536
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
Let SwiftLanguageRuntime depend on a Swift language runtime being present #536
Conversation
lldb/source/Core/Mangled.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may look like a regression at first glance, but this avoids an extra copy of the string, since we need to pass it to a Swift API that takes a const char *.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow. A few questions:
- Should SwiftLanguageRuntime::IsSwiftMangledName() take a StringRef?
- The comment in cstring_is_mangled implies that ConstString::GetStringRef() doesn't always return a null-terminated string. Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwiftLanguageRuntime::IsSwiftMangledName() calls into a Swift API that takes a const char *; so changing that to a StringRef would incur an extra copy to ensure the NUL-terminator. ConstStrings are — to my knowledge — always NUL-terminated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't understand what calling AsCString() instead of GetStringRef() fixes. Given cstring_is_mangled() takes a StringRef, what this achieves is creating a temporary one which will need to strlen the passed char*. What am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. I was confused.
|
My apologies for the enormous patch. |
fb428f1 to
b755ba5
Compare
|
This patch also fixes the last test failure on the branch. |
dcci
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need a little time to review this patch properly -- I think I'll get to it by the end of today.
I have a meta comment, so I'll drop it here before I forget. One of the main nuisances of the current model is the inability of detecting whether stdlib failed to load and expressions keep going and fail in fairly non-obvious way.
My understanding is that this is kind of the first step towards a world where if stdlib isn't found and loaded correctly, expressions just can't be run. Is this correct?
dcci
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you commit the NFC/cosmetic changes first -- so we can review the meat of this PR better? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are lots of changes that are just cosmetics, and can be separated. Like this.
…sent. This patch moves the bulk of SwiftLanguageRuntime into a private implementation class that is only initialized after libSwiftCore has been loaded. This delay is necessary because SwiftLanguageRuntime communicates with the in-process Swift language runtime via global symbols and can't be properly initialized before the runtime was loaded. Before the runtime was loaded all queries go to the SwiftLanguageRuntimeStub, which prints an error message for most queries. In addition this patch re-enables the expression evaluator loading libSwiftCore manually. This was previously disabled to prevent problems with statically linked runtimes on Darwin, howver, since ABI stabiklity statically linking the runtime is no longer an option on Darwin. <rdar://problem/58352018> <rdar://problem/58117895>
b755ba5 to
3997229
Compare
No, when the stdlib isn't loaded, after this patch, SwiftUserExpression will dlopen libSwiftCore itself. |
The bulk of the patch is moving around function bodies into different classes, so this isn't going to work quite as nicely as we'd hope. |
I guess my question is: "what happens if |
Then SwiftLanguageRuntimeImpl will not be loaded (since no libswiftCore.dylib is in the loaded images) and all queries go to the stub instead. |
|
... which will log an error. Note that this is a highly unlikely scenario. You could run into it on Linux by doing |
dcci
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The swift override of `IsSymbolARuntimeThunk` was unintentionally removed in #536. This restores it. rdar://65681037
This patch moves the bulk of SwiftLanguageRuntime into a private
implementation class that is only initialized after libSwiftCore has
been loaded. This delay is necessary because SwiftLanguageRuntime
communicates with the in-process Swift language runtime via global
symbols and can't be properly initialized before the runtime was
loaded. Before the runtime was loaded all queries go to the
SwiftLanguageRuntimeStub, which prints an error message for most
queries.
In addition this patch re-enables the expression evaluator loading
libSwiftCore manually. This was previously disabled to prevent
problems with statically linked runtimes on Darwin, howver, since ABI
stabiklity statically linking the runtime is no longer an option on
Darwin.
rdar://problem/58352018
rdar://problem/58117895