Commit Graph

9 Commits

Author SHA1 Message Date
Andrew Trick
2ed7ca9426 Fix convenience_init_peer_delegation.swift; avoid specialization.
Fixes rdar://133393259
(Swift CI: test: Interpreter/convenience_init_peer_delegation.swift)
2024-09-13 20:13:44 -07:00
Kavon Farvardin
c88858d928 Test: disable only in optimized mode 2024-08-14 13:45:45 -07:00
Kavon Farvardin
fd29cd7c65 Test: fix convenience_init_peer_delegation.swift
There's no reason to avoid importing Foundation with an
obscure compiler flag.

resolves rdar://133393259
2024-08-13 16:22:19 -07:00
Kavon Farvardin
05a280bb3a Test: try to re-enable
resolves rdar://92102119
2024-08-05 11:55:11 -07:00
Artem Chikin
f6402836e1 Disable failing convenience_init_peer_delegation.swift test. 2022-04-25 09:42:42 -07:00
Michael Gottesman
d4e09b0944 [silgen] Add an extra swift-version 5 run to initializer tests.
We currently run these in swift-version 4 by default. This caused us to miss
some bugs that only occur in swift-version 5 due to initializer changes
happening in swift 5. This at least will allow us to catch such issues in the
future.

NOTE: I am also going to change objc_throwing_initializers.swift in the same
way, but after I fix the bugs that adding -swift-version 5 exposes therein
(which is actually <rdar://problem/59830255>)
2020-05-19 11:47:08 -07:00
Kuba Mracek
1bd425da67 [arm64e] Test changes to support arm64e 2020-02-27 16:10:48 -08:00
Jordan Rose
80ef1f519f [test] Tweak new convenience init test for swift_test_mode=optimize
The optimizer was smart enough to stack-promote the test objects I was
using, which foiled my interposition on swift_allocObject. Change the
tests to "escape" each allocation by returning it.

rdar://problem/47266149
2019-01-14 16:16:38 -08:00
Jordan Rose
425c190086 Restore initializing entry points for @objc convenience initializers (#21815)
This undoes some of Joe's work in 8665342 to add a guarantee: if an
@objc convenience initializer only calls other @objc initializers that
eventually call a designated initializer, it won't result in an extra
allocation. While Objective-C /allows/ returning a different object
from an initializer than the allocation you were given, doing so
doesn't play well with some very hairy implementation details of
compiled nib files (or NSCoding archives with cyclic references in
general).

This guarantee only applies to
(1) calling `self.init`
(2) where the delegated-to initializer is @objc
because convenience initializers must do dynamic dispatch when they
delegate, and Swift only stores allocating entry points for
initializers in a class's vtable. To dynamically find an initializing
entry point, ObjC dispatch must be used instead.

(It's worth noting that this patch does NOT check that the calling
initializer is a convenience initializer when deciding whether to use
ObjC dispatch for `self.init`. If we ever add peer delegation to
designated initializers, which is totally a valid feature, that should
use static dispatch and therefore should not go through objc_msgSend.)

This change doesn't /always/ result in fewer allocations; if the
delegated-to initializer ends up returning a different object after
all, the original allocation was wasted. Objective-C has the same
problem (one of the reasons why factory methods exist for things like
NSNumber and NSArray).

We do still get most of the benefits of Joe's original change. In
particular, vtables only ever contain allocating initializer entry
points, never the initializing ones, and never /both/ (which was a
thing that could happen with 'required' before).

rdar://problem/46823518
2019-01-14 13:06:50 -08:00