Commit Graph

39 Commits

Author SHA1 Message Date
Anthony Latsis
af66096847 Gardening: Migrate test suite to GH issues: Interpreter 2022-09-01 06:35:57 +03:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Slava Pestov
2fa1d03f53 Re-enable test/Interpreter/class_resilience.swift test 2019-04-19 16:50:29 -04:00
Xi Ge
643676d0d5 test: temporarily disable Interpreter/objc_class_resilience.swift for CI issue. rdar://49026933 2019-03-19 11:24:16 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
John McCall
7f55a4a4f0 Always give known-empty class properties a zero offset in the static layout.
Field offset vectors are always filled out with either zero or the static layout's offset, depending on the metadata initialization strategy.  This change means that the static layout's offset will only be non-zero for properties with a statically-known layout.  Existing runtimes doing dynamic class layout assign class properties a zero offset if the field offset vector entry is zero and the property is zero-sized.  So this effectively brings the compiler into accord with the runtime (for all newly-compiled Swift code, which will eventually be all Swift code because the current public releases of Swift 5 are not yet considered ABI-stable) and guarantees a zero value for the offset everywhere.

Since the runtime will agree with the compiler about the zero value of the offset, the compiler can continue to emit such offset variables as constant.  The exception to this rule is if the class has non-fragile ObjC ancestry, in which case the ObjC runtime (which is not aware of this special rule for empty fields) will attempt to slide it along with everything else.

Fixes rdar://48031465, in which the `FixedClassMetadataBuilder` for a class with a legacy-fixed layout was writing a non-zero offset for an empty field into the field offset vector, causing the runtime to not apply the special case and thus to compute a non-zero offset, which it then attempted to copy into the global field offset variable, which the compiler had emitted as a true-constant zero.
2019-02-20 00:53:11 -05:00
Slava Pestov
b64db715a8 IRGen: Remove -enable-class-resilience staging flag 2019-02-08 14:22:00 -05:00
Mike Ash
60f51bfedb [Tests] Disable a few tests that hit bugs on macOS 10.9.
rdar://problem/47053588
2019-01-23 18:15:51 -05:00
Saleem Abdulrasool
d77801abaf test: define and use %target-rpath
Create a new capturing substitution for adding a rpath to a target
library.  This is needed as Windows doesn't really support the concept
of a rpath.  This also makes it possible to remove the parameter from
the command line on windows.
2018-12-12 19:51:08 -08:00
Saleem Abdulrasool
ed1ec54958 test: make %target-library-name work in captures
Thanks to @jrose for the hint about the substitution ordering, the new
substitution now works even inside the capture group.  Replace the
remaining uses to the new macro.
2018-12-12 10:09:58 -08:00
Saleem Abdulrasool
8968fcad5f test: create and use target-library-name 2018-12-12 08:37:59 -08:00
Saleem Abdulrasool
b212229db1 test: add and use prefix substitutions for libraries
The naming convention is different on Windows than on Unix-like
environments.  In order to follow the convention we need to substitute
the prefix and the suffix.  Take the opportunity to rename the
`target-dylib-extension` to the CMake-like variable
`target-shared-library-suffix` and introduce
`target-shared-library-prefix`.  This helps linking the test suite
binaries on Windows.
2018-12-11 15:56:06 -08:00
Slava Pestov
ff09603f30 IRGen: @_fixed_layout classes still have resilient metadata 2018-11-29 23:20:02 -05:00
Slava Pestov
4da47823a5 Runtime/IRGen: Add new initialization pattern for classes with backward deployment layout
If a class has a backward deployment layout:

- We still want to emit it using the FixedClassMetadataBuilder.

- We still want it to appear in the objc_classes section, and get an
  OBJC_CLASS_$_ symbol if its @objc.

- However, we want to use the singleton metadata initialization pattern
  in the metadata accessor.

- We want to emit metadata for all field types, and call the
  swift_updateClassMetadata() function to initialize the class
  metadata.

For now, this function just performs the idempotent initialization of
invoking a static method on the class, causing it to be realized with
the Objective-C runtime.
2018-09-23 21:26:46 -07:00
Arnold Schwaighofer
6eca97add6 Codesign test/Interpreter 2018-08-10 06:58:40 -07:00
Slava Pestov
cfd5ac0798 Small fixes for fragile class layout
- Narrow the fix to classes with @objc ancestry only

- Pass -enable-class-resilience in class resilience executable test so that
  we exercise resilience there

- Only enable fragile layout if the class has @objc ancestry

- Add an IRGen test
2018-04-10 00:00:45 -07:00
Jordan Rose
52e6c1fe12 [test] Fix Interpreter/class_resilience.swift to test the right thing (#14136)
...and to not fail when the Apple-internal on-device testing tool
decided to clear out unused files.

rdar://problem/36830081
2018-01-24 15:54:53 -08:00
Slava Pestov
9de7b86bb0 Enable part of class_resilience test that works now 2018-01-03 19:30:30 -08:00
Slava Pestov
8024b81594 IRGen: Preliminary implementation of resilient method overrides
This is not the final mechanism, because it does not allow
re-ordering superclass methods, but at least it works if
you don't do that.
2018-01-03 19:30:30 -08:00
Slava Pestov
0e8fe3d382 Executable resilience tests re-build library under a new name now
Building a new dylib with the same name wasn't breaking some internal bots.

Fixes <rdar://problem/34148403>.
2017-10-02 19:11:13 -07:00
Slava Pestov
41d0503164 Fix resilience tests to pass dylibs on command line 2017-09-29 18:26:45 -07:00
Slava Pestov
afe9ad3b27 Fix some resilience tests for device testing
- Pass -install_name @executable_path/libfoo.dylib to the linker
- Pass dylib as an argument to the binary

Fixes <rdar://problem/34148403>.
2017-09-29 00:25:26 -06:00
Slava Pestov
f61c241edd Get resilience tests working on iOS again 2017-09-05 18:29:35 -07:00
Michael Ilseman
4dd3c82b2d Un-break resilience tests on non-mac platforms 2017-09-01 10:21:42 -07:00
Michael Ilseman
18df98e8ac Disable failing test. <rdar://problem/34148403> 2017-08-30 11:07:31 -07:00
Slava Pestov
f8766fa2e3 Fix resilience tests on Linux 2017-08-29 02:13:55 -07:00
Slava Pestov
194b80049c Sema: Lazy property setters should not be transparent
A lazy property setter stores a value to the underlying storage
of the lazy property. The underlying storage is private, and it
is not proper for a public transparent function body to reference
a private member.

In practice, this only failed if the private member had a
non-constant offset, which only occurs with subclasses of @objc
classes, and resilient classes.

For @objc classes we already had a workaround where no accessors
for stored properties are ever transparent. I put this in to fix
this very issue with lazy properties, but now I realize it was
the wrong workaround, because we still had this problem with
resilient classes.

Note that I'm keeping the logic which made @objc accessors
non-transparent in place, because there's a good chance we will
decide that field offset globals should always be private.

Also, to make this issue reproducible in the test, I changed the
resilience execution tests to build the resilient library as a
dylib and link against that instead of just linking .o files
together. This is because .o files can see each other's internal
symbols, so I was not able to reproduce the original failure
this way. I went ahead and updated the other resilient tests to
do this as well. Also, each test now builds in WMO and non-WMO
mode, to exercise different SIL linking behavior. Again, the
WMO variant was needed to reproduce the issue fixed by this
commit, because without WMO we currently discard serialized SIL,
so no cross-module inlining of the lazy property setter was
taking place.
2017-08-29 01:22:11 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Slava Pestov
49c54870c1 Serialization: Auto-linking recursively walks modules imported from -sil-serialize-all modules 2016-04-01 12:21:36 -07:00
Dmitri Gribenko
5c9214329d Annotate tests as executable 2016-02-04 09:42:26 -08:00
Slava Pestov
5a53ac6078 Better tests for _typeByName()
These catch a regression I introduced with my previous patch that I reverted:

<65dd0e7b93>
2016-01-29 00:05:10 -08:00
Erik Eckstein
adef0368bb tests: add import statements to workaround linker errors in all relevant tests.
This is needed if we compile StdlibUnittest with -sil-serialize-all
So far I added the imports only in files which needed them. But this may change, depending on the optimizer (inlining).
Adding them in all files doesn't harm and avoids confusion if someone makes an unrelated change which would result in such a linker error.
2016-01-21 09:59:50 -08:00
Slava Pestov
32bd7705bf IRGen: Test emission of conformances for concrete subclasses of generic classes
This was fixed by Luke Howard as part of some other changes in the
following patch:

<b5880f386b>

After rebasing my fix, I noticed most of it disappeared.
However, it's still worth checking in the tests.

Fixes <rdar://problem/24183374>.
2016-01-15 21:34:53 -08:00
Luke Howard
b5880f386b allow name lookup to work with resilient types
cleanup from review comments
2016-01-16 09:38:35 +11:00
Slava Pestov
c45dc6dad9 More resilient class layout tests
Looks like subclassing classes with resiliently-sized properties works,
as long as the subclass is @_fixed_layout, so let's ensure that's tested.

We don't want @_fixed_layout classes to be a thing though, and we still
can't handle changes to the number of stored properties in a base class,
so a couple of tests are disabled until I land some more patches.
2016-01-07 06:52:39 -08:00
Slava Pestov
2a27acd5e8 IRGen: Fix resilient class layout on Linux
When there's no Objective-C runtime, we have to store the field offset
globals ourselves.
2016-01-06 12:24:28 -07:00
Slava Pestov
800821f980 IRGen: Layout of root classes containing resiliently-sized fields
Now that all the machinery is in place, the ClassMetadataBuilder
can (more accurately) query the ClassLayout instead of trying to
re-derive whether the field offset vector is dependent, etc.

Apart from performing dynamic layout for resiliently-sized fields
in concrete classes, this also lets us *skip* dynamic layout
if we have a generic class without any dependent fields.

I haven't tested subclassing with resilient field layout yet, but
getting that working is the next step and should not be too much
work.

Also, swift_initClassMetadata_UniversalStrategy() only stores
the computed field offsets in the field offset globals when the
Objective-C runtime is available, because it gets the offset
pointers from the Objective-C class rodata. On Linux, we will
need to emit code to copy from the field offset vector into
field offset globals in IRGen. This is pretty easy, but I'll do
it in a follow-up patch so for now the new execution test is
XFAIL'd on Linux.
2015-12-24 02:54:56 -08:00