Skip to content

[AST] Increase size of type variable id field to 20 bits #25666

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

Merged
merged 4 commits into from
Jun 24, 2019

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jun 21, 2019

Currently id field is only 12 bits long which is a lot smaller
than graph index which is 28 bits and creates problems with
large collections of literals since id is going to overflow
pretty quickly (4096 elements max). Let's change it so both
fields have the same 20 bits which is big enough.

Resolves: SR-10914
Resolves: rdar://problem/51616307

xedin added 2 commits June 21, 2019 09:21
Currently `id` field is only 12 bits long which is a lot smaller
than `graph index` which is 28 bits and creates problems with
large collections of literals since `id` is going to overflow
pretty quickly (4096 elements max). Let's change it so both
fields have the same 20 bits which is big enough.

Resolves: [SR-10914](https://bugs.swift.org/browse/SR-10914)
Resolves: rdar://problem/51616307
@xedin xedin requested a review from slavapestov June 21, 2019 19:31
@xedin
Copy link
Contributor Author

xedin commented Jun 21, 2019

@swift-ci please test

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@xedin
Copy link
Contributor Author

xedin commented Jun 21, 2019

@swift-ci please test

@swiftlang swiftlang deleted a comment from swift-ci Jun 21, 2019
@xedin
Copy link
Contributor Author

xedin commented Jun 21, 2019

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Jun 21, 2019

@swift-ci please test source compatibility

@xedin
Copy link
Contributor Author

xedin commented Jun 24, 2019

@swift-ci please smoke test

@davezarzycki
Copy link
Contributor

This change makes the TypeVariableType bitfield very sensitive to TypeBase bitfield experiments. Can we add a comment suggesting what one should do? Perhaps dial back the graph index to 19? If that's the advice, can we just automate it? For example:

@@ -341,18 +341,19 @@ protected:
     : NumPadBits,
     NumProtocols : 16
   );
 
-  SWIFT_INLINE_BITFIELD_FULL(TypeVariableType, TypeBase, 20+4+20,
+  SWIFT_INLINE_BITFIELD_FULL(TypeVariableType, TypeBase, 20+4,
     /// The unique number assigned to this type variable.
     ID : 20,
 
     /// Type variable options.
     Options : 4,
 
     ///  Index into the list of type variables, as used by the
     ///  constraint graph.
-    GraphIndex : 20
+    GraphIndex : NumPadBits;
+    static_assert(NumPadBits >= 16, "TypeVariableType bitfield needs refactoring")
   );
 
   SWIFT_INLINE_BITFIELD(SILFunctionType, TypeBase, NumSILExtInfoBits+3+1+2,
     ExtInfo : NumSILExtInfoBits,

@davezarzycki
Copy link
Contributor

See #25818

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.

4 participants