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

Runtime: define get_return_address for WebAssembly #31693

Closed
wants to merge 1 commit into from

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented May 10, 2020

WebAssembly/WASI doesn't support stack traces and return addresses. To make it possible to compile exclusivity code for this platform, it seems to make the most sense for the get_return_address() to return a zero value. Since it's only used for diagnostics, this shouldn't cause any issues when targeting WASI.

Related to SR-9307.

(cc @compnerd)

#else
#error missing implementation for get_return_address
#define get_return_address() ((void*) 0)
#endif

using namespace swift;

#if defined(__wasm__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be __wasi__, because this is not related to the object file format?

@compnerd
Copy link
Member

CC: @gottesmm @mikeash

@MaxDesiatov MaxDesiatov changed the title Runtime: disable exclisivity checking for WebAssembly Runtime: disable exclusivity checking for WebAssembly May 10, 2020
@MaxDesiatov MaxDesiatov requested a review from compnerd May 10, 2020 21:34
@compnerd
Copy link
Member

Id like to get @gottesmm's opinion on this as well

@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

@swift-ci please test Windows platform

@atrick
Copy link
Contributor

atrick commented May 14, 2020

What does exclusivity checking have to do with threads? Other than the implementation needing to be thread-safe, which is trivial if there are no threads.

@MaxDesiatov MaxDesiatov changed the title Runtime: disable exclusivity checking for WebAssembly Runtime: define get_return_address for WebAssembly May 14, 2020
@MaxDesiatov
Copy link
Contributor Author

Great point, sorry I missed that. I've re-enabled it, now the only thing left in this PR is defining get_return_address.

@MaxDesiatov
Copy link
Contributor Author

@compnerd could you have another look please?

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not break other things as you cannot get the return address? This may let it compile but can cause correctness issues.

@karwa
Copy link
Contributor

karwa commented Aug 25, 2020

@compnerd @MaxDesiatov

Just looking in to this. It seems that WASI does not support getting the return address right now (see also: WebAssemblyTargetLowering::LowerRETURNADDR). AFAICT this is only used for diagnostics, so it shouldn’t be a big deal to leave it out.

The other option (besides returning a null pointer), would be to omit the “PC” field from the “Access” type on WASI. Would you prefer that approach?

@MaxDesiatov MaxDesiatov changed the base branch from master to main September 24, 2020 08:41
@MaxDesiatov
Copy link
Contributor Author

@compnerd get_return_address() is only used in SwiftTLSContext::get().accessSet.insert call, which as far as I understand exists for diagnostics. In my understanding the worst that can happen is that AccessSet will have a zero value in the pc field. That isn't dereferenced, and is only used for diagnostic output.

@MaxDesiatov MaxDesiatov requested a review from compnerd August 8, 2021 14:07
@MaxDesiatov
Copy link
Contributor Author

@swift-ci please test

@MaxDesiatov MaxDesiatov requested a review from atrick August 8, 2021 14:08
@MaxDesiatov
Copy link
Contributor Author

@swift-ci please smoke test

@compnerd
Copy link
Member

compnerd commented Aug 8, 2021

I think that it may be better to disable the larger portions of Swift for WASM until the get return address can be implemented. Note that the else path would still prevent you from progressing, which this is undoing.

@kateinoigakukun
Copy link
Member

Close due to the merge of #42097

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants