Skip to content

[Reflection] Support OpaqueExistential in RecordTypeInfo::readExtraInhabitantIndex #35433

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

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Jan 14, 2021

Support OpaqueExistential in RecordTypeInfo::readExtraInhabitantIndex().

This missing support was identified when calling projectEnumValue() with a type of Any?. In that case, the projectEnumValue was returning false because readExtraInhabitantIndex returned false. For OpaqueExistentials, readExtraInhabitantIndex should look at the type field (named "metadata"), and use that to determine extra inhabitants.

Unblocks rdar://68171421

@kastiglione kastiglione requested a review from a team as a code owner January 14, 2021 20:56
@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 14, 2021

This is an initial working version for macOS x86-64, in a specific case I was debugging in lldb. Still todo are:

  • Verify other platform support (!macOS || !x86-64)
  • Verify opaque existential + nested optional (Any?? etc)

@kastiglione
Copy link
Contributor Author

@swift-ci test

@tbkka
Copy link
Contributor

tbkka commented Jan 14, 2021

Nice! This is simpler than I thought it would be. (To be honest, I've not looked at this code in a little while...). I see a couple of other unimplemented cases that we might be able to fill in fairly quickly.

I'll sketch out some test cases this afternoon to help push this forward.

@kastiglione
Copy link
Contributor Author

test cases sound great, thanks

@kastiglione kastiglione force-pushed the Reflection-Support-OpaqueExistential-in-RecordTypeInfo-readExtraInhabitantIndex branch from 95b9897 to 1e58387 Compare January 15, 2021 01:04
@kastiglione kastiglione changed the base branch from release/5.4 to main January 15, 2021 01:04
@kastiglione
Copy link
Contributor Author

I've changed the base branch to main now, as requested.

@kastiglione
Copy link
Contributor Author

I'm hoping to merge this soon, and then to cherry pick it to release/5.4. Are you ok with doing the other cases in a separate change because of this? I can add some tests for this case. Based on #30635, is validation-test/Reflection still the place to write reflection tests?

Authored by Tim Kientzle @tbkka
@kastiglione
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 340b85f

@tbkka
Copy link
Contributor

tbkka commented Jan 19, 2021

Ugh. Looks like I made a lot of obvious dump copy/paste errors in the 32-bit version. I'll work on that this afternoon...

@tbkka
Copy link
Contributor

tbkka commented Jan 19, 2021

I'm surprised that Linux passed here. I'll have to double-check, but I thought Linux only had 4k extra inhabitants in 64-bit pointers, where macOS has 4G.

kastiglione and others added 3 commits January 19, 2021 12:27
…readExtraInhabitantIndex' of https://github.com/apple/swift into Reflection-Support-OpaqueExistential-in-RecordTypeInfo-readExtraInhabitantIndex
@tbkka
Copy link
Contributor

tbkka commented Jan 19, 2021

@swift-ci Please test macOS

@kastiglione
Copy link
Contributor Author

I did some fixes in 7ed7122, and I'll run the tests locally to iterate on them faster.

@kastiglione
Copy link
Contributor Author

I see we're both on it haha

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7f8bebb

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 19, 2021

looking

@tbkka
Copy link
Contributor

tbkka commented Jan 19, 2021

@swift-ci Please test macOS

Copy link
Contributor

@tbkka tbkka left a comment

Choose a reason for hiding this comment

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

This looks right to me. "Just" need to finish filling out the test suite for it.

Thanks for pushing this forward...

@kastiglione
Copy link
Contributor Author

This looks right to me.

Thanks!

"Just" need to finish filling out the test suite for it.

@tbkka Are you intending for "filling out the test suite" to be done in this PR or in a follow up?

Thanks for pushing this forward…

thanks for your guidance.

@kastiglione
Copy link
Contributor Author

@swift-ci test Linux

@tbkka
Copy link
Contributor

tbkka commented Jan 20, 2021

Sorry, I probably should have said "get this test suite to pass." I think the test we have is sufficient coverage, but it may still have some warts. More tests can follow in a subsequent PR, I think.

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 20, 2021

The new test you wrote pass for the different architectures:

PASS: Swift(macosx-x86_64) :: Reflection/reflect_Optional_Any.swift (678 of 14039)
PASS: Swift(iphonesimulator-i386) :: Reflection/reflect_Optional_Any.swift (679 of 14039)
PASS: Swift(iphonesimulator-x86_64) :: Reflection/reflect_Optional_Any.swift (679 of 14039)
PASS: Swift(watchsimulator-i386) :: Reflection/reflect_Optional_Any.swift (679 of 14039)

@tbkka tbkka removed the request for review from a team January 20, 2021 00:33
@tbkka
Copy link
Contributor

tbkka commented Jan 20, 2021

Removed swift5-branch-managers from reviewers list; you don't need their review for merging into main

@kastiglione kastiglione merged commit e843c72 into main Jan 20, 2021
@kastiglione kastiglione deleted the Reflection-Support-OpaqueExistential-in-RecordTypeInfo-readExtraInhabitantIndex branch January 20, 2021 04:17
@davezarzycki
Copy link
Contributor

@rjmccall and @jckarter – Is there any reason why different Linux platforms would have different extra inhabitant counts? This new test isn't passing on my Fedora 33 (x86-64) box and the test seems to assume that the maximum number of extra inhabitants for 64-bit platforms are all the same (which isn't true).

@davezarzycki
Copy link
Contributor

Now I'm wondering if the tests are executed on the Linux build bots at all (as opposed to just my "unified build" setup). Let's find out: #35512

@davezarzycki
Copy link
Contributor

davezarzycki commented Jan 20, 2021

Ding. This test isn't triggering on the Linux bots but it is on my cmake / unified build:

$ curl https://ci.swift.org/job/swift-PR-Linux/25240/consoleText 2>/dev/null|grep reflect_Optional_Any
UNSUPPORTED: Swift(linux-x86_64) :: Reflection/reflect_Optional_Any.swift (617 of 14002)

I'm going to commit a workaround that unbreaks unified builds: #35513

@tbkka
Copy link
Contributor

tbkka commented Jan 20, 2021

@swift-ci Please test Linux

@tbkka
Copy link
Contributor

tbkka commented Jan 20, 2021

On Linux, pointers only have 4096 extra inhabitants. that requires some finessing of the test. I'll work on that.

@davezarzycki
Copy link
Contributor

Thanks. Do you think you'll have a fix soon or should I merge the workaround?

@adrian-prantl
Copy link
Contributor

Ding. This test isn't triggering on the Linux bots but it is on my cmake / unified build:

Just in case this is something obvious — AFAIK the reflection tests are part of the validation tests. Is your bot running these?

@davezarzycki
Copy link
Contributor

Yes, my bot always runs the validation tests. (They just take a few seconds.) I thought some of the Swift bots run the validation tests. Is that still true?

@tbkka
Copy link
Contributor

tbkka commented Jan 20, 2021

I thought that "swift-ci test" ran validation tests "swift-ci smoke test" did not. But I may have misunderstood.

Please merge a workaround for now. I may not get a fix ready until tomorrow.

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