Skip to content

Conversation

@harlanhaskins
Copy link
Contributor

@harlanhaskins harlanhaskins commented Sep 10, 2018

This patch adds support to the AST printer for printing the bodies of inlinable functions.

Still left to do:

  • Add more tests
  • Get tests passing and ensure NFC to other bits of the printer
  • Add serialization/deserialization of body text to binary module format
  • Add parser support for mixed inlinable/non-inlinable accessors

Copy link
Contributor

Choose a reason for hiding this comment

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

I know this isn't ready for review yet, but this should be able to go into the anonymous union below, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, good call!

@harlanhaskins harlanhaskins force-pushed the extremely-inline branch 2 times, most recently from 252bbfd to 9889a12 Compare September 11, 2018 04:18
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm. Aren't these going to be mutually exclusive, like they are for default argument values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I should add BodyKind::Deserialized to cover that, but yes it should be mutually exclusive. The check for this would have to be outside of Parsed/TypeChecked

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment needs fixing.

@harlanhaskins harlanhaskins changed the title [WIP] [DNM] Print bodies of inlinable functions in textual interfaces Print bodies of inlinable functions in textual interfaces Sep 12, 2018
@harlanhaskins harlanhaskins changed the title Print bodies of inlinable functions in textual interfaces [InterfaceGen] Print bodies of inlinable functions in textual interfaces Sep 12, 2018
Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Looks pretty good! Only minor comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

This one doesn't seem right; subscripts don't have bodies.

Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be in the top bucket, since "Deserialized" is closest to "None" rather than "Unparsed".

lib/AST/Decl.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be a switch?

Copy link
Contributor

Choose a reason for hiding this comment

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

This one won't actually ever appear in the SIL namespace, so you don't need to add it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@slavapestov, this is the correct check for inlinable functions of any kind, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

David would probably say to add "maybe…" or "…IfNeeded" to the name of this method, since it doesn't always do anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a CHECK-NEXT for the close brace?

Copy link
Contributor

Choose a reason for hiding this comment

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

We're planning to change this to always use get {, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, should I go ahead and roll that into this patch?

Copy link
Contributor

Choose a reason for hiding this comment

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

A follow-up is fine; just wanted to have it on record.

@harlanhaskins
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d61216717d75a2b8d473b2fa70a8484b0284915a

@harlanhaskins
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d61216717d75a2b8d473b2fa70a8484b0284915a

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d61216717d75a2b8d473b2fa70a8484b0284915a

@slavapestov
Copy link
Contributor

@harlanhaskins Why do we need to serialize the inlinable body text? I thought it was for swiftinterface files only

@harlanhaskins
Copy link
Contributor Author

@slavapestov We need to be able to compile an interface file into a binary swiftmodule, which means recompiling inlinable bodies

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably just never print @objc on deinit in textual interfaces. Somehow. But that can happen later; this is clever.

@jrose-apple
Copy link
Contributor

Ah, that's not really it: it's when you do a non-whole-module build but still want to generate a textual interface. In that case you pass through the partial module stage.

@jrose-apple
Copy link
Contributor

By the way, Slava, here's the question I originally tagged you in on:
#19224 (comment)

@harlanhaskins
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0c448652b4ee52f0c173675c2eb3478d87f0de8e

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0c448652b4ee52f0c173675c2eb3478d87f0de8e

@harlanhaskins
Copy link
Contributor Author

@harlanhaskins harlanhaskins merged commit 665db87 into swiftlang:master Sep 14, 2018
dcci pushed a commit that referenced this pull request Sep 17, 2018
…ces (#19224)

* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
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