-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] fix return type of getNumRuntimeFunctionCounters #24182
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
[stdlib] fix return type of getNumRuntimeFunctionCounters #24182
Conversation
f401981
to
3a43aa2
Compare
CC: @airspeedswift |
@compnerd It didn't compile without the Int() casts, so I decided to just add the casts to get it working. Should I try keeping it as UInt64, then? |
I think that if it doesn't bleed into any public interfaces, we should try to switch over the types since that would prevent truncation. |
@compnerd The number of runtime counters is used to index into an array. Array indices must be Int, so there's no point keeping it UInt64. Here's the compile error if I remove the Int() casts: |
Sounds good |
@swift-ci please test |
The return type of getNumRuntimeFunctionCounters is defined as uint64_t in RuntimeInvocationsTracking.cpp, but it has return type Int in RuntimeFunctionCounters.swift. Found when compiling the stdlib for WebAssembly, as WebAssembly validates return types. uint64_t corresponds to i64, but Int is i32, so the program fails validation.
3a43aa2
to
c94e876
Compare
@compnerd conflicts have been fixed, would you be able to have another look please? |
@swift-ci please test |
@swiftix would we rather fix this by having the cpp funds return long? Can these ever overflow 32b, and if they do is it desired that the conversion to |
@stephentyrone are there any changes needed here based on the review of #24181? |
These are indices, not counts, so trapping |
The return type of these functions are uint64_t in Stubs.cpp but UInt in the Swift code; this changes the Swift code to match the C++ return type.
Found when compiling the stdlib for WebAssembly, which requires that all return types match: UInt maps to i32 while uint64_t maps to i64, so functions calling these functions fail the validation.