Skip to content

Commit 82d5ffc

Browse files
committed
---
yaml --- r: 286718 b: refs/heads/master-next c: cd0c1e7 h: refs/heads/master
1 parent af9e1a7 commit 82d5ffc

File tree

65 files changed

+481
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+481
-556
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: a67ffadd758dfc7a0f10a8afde063b8864663208
3-
refs/heads/master-next: 5fd09649048caa793a24951c7f6827362baae164
3+
refs/heads/master-next: cd0c1e715027482a5cec80c4c91fed72741621d4
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,13 @@ function(_add_variant_c_compile_flags)
230230

231231
if("${CFLAGS_SDK}" STREQUAL "WINDOWS")
232232
# MSVC doesn't support -Xclang. We don't need to manually specify
233-
# -D_MD or D_MDd either, as CMake does this automatically.
233+
# the dependent libraries as `cl` does so.
234234
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
235235
list(APPEND result -Xclang;--dependent-lib=oldnames)
236236
# TODO(compnerd) handle /MT, /MTd
237237
if("${CFLAGS_BUILD_TYPE}" STREQUAL "Debug")
238-
list(APPEND result "-D_MDd")
239238
list(APPEND result -Xclang;--dependent-lib=msvcrtd)
240239
else()
241-
list(APPEND result "-D_MD")
242240
list(APPEND result -Xclang;--dependent-lib=msvcrt)
243241
endif()
244242
endif()
@@ -260,6 +258,7 @@ function(_add_variant_c_compile_flags)
260258
if("${CFLAGS_ARCH}" MATCHES arm)
261259
list(APPEND result "-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE")
262260
endif()
261+
list(APPEND result "-D_MT")
263262
# TODO(compnerd) handle /MT
264263
list(APPEND result "-D_DLL")
265264
# NOTE: We assume that we are using VS 2015 U2+
@@ -401,6 +400,12 @@ function(_add_variant_swift_compile_flags
401400
list(APPEND result "-D" "SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS")
402401
endif()
403402

403+
if(sdk STREQUAL WINDOWS)
404+
list(APPEND result "-Xcc" "-D_MT")
405+
# TODO(compnerd) handle /MT /MTd
406+
list(APPEND result "-Xcc" "-D_DLL")
407+
endif()
408+
404409
set("${result_var_name}" "${result}" PARENT_SCOPE)
405410
endfunction()
406411

branches/master-next/docs/LibraryEvolution.rst

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ are a few common reasons for this:
324324
save the overhead of a cross-library function call and allow further
325325
optimization of callers.
326326

327-
- The function accesses a frozen struct with non-public members; this
327+
- The function accesses a fixed-contents struct with non-public members; this
328328
allows the library author to preserve invariants while still allowing
329329
efficient access to the struct.
330330

@@ -345,12 +345,11 @@ Clients are not required to inline a function marked ``@inlinable``.
345345
understanding that it will not affect existing clients. This is the
346346
standard example of a `binary-compatible source-breaking change`.
347347

348-
Any local functions or closures within an inlinable function are treated as
349-
``@_alwaysEmitIntoClient`` (see below). A client that inlines the containing
350-
function must emit its own copy of the local functions or closures. This is
351-
important in case it is necessary to change the inlinable function later;
352-
existing clients should not be depending on internal details of the previous
353-
implementation.
348+
Any local functions or closures within an inlinable function are themselves
349+
treated as ``@inlinable``, and a client that inlines the containing function
350+
must emit its own copy of the local functions or closures. This is important in
351+
case it is necessary to change the inlinable function later; existing clients
352+
should not be depending on internal details of the previous implementation.
354353

355354
Removing the ``@inlinable`` attribute completely---say, to reference private
356355
implementation details that should not be `versioned <versioned entity>`---is a
@@ -409,28 +408,12 @@ bodies of inlinable functions have the following restrictions:
409408
guards.
410409

411410

412-
Always Emit Into Client
413-
-----------------------
414-
415-
A function, computed property or subscript annotated as ``@_alwaysEmitIntoClient``
416-
is similar to an ``@inlinable`` declaration, except the declaration is
417-
not part of the module's ABI, meaning that the client must always emit
418-
their own copy.
419-
420-
As a result, removing a declaration annotated as ``@_alwaysEmitIntoClient``
421-
is a binary-compatible source-breaking change.
422-
423-
.. admonition:: TODO
424-
425-
The implementation of ``@_alwaysEmitIntoClient`` is incomplete and
426-
should probably graduate to having its own evolution proposal.
427-
428411
Default Argument Expressions
429412
----------------------------
430413

431414
Default argument expressions for functions that are public, versioned, or
432-
inlinable are implicitly ``@_alwaysEmitIntoClient``. They are subject to
433-
similar restrictions:
415+
inlinable are implemented very similar to inlinable functions and thus are
416+
subject to similar restrictions:
434417

435418
- They may not define any local types.
436419

@@ -659,18 +642,14 @@ extension; unlike access control, entities within the extension may freely
659642
declare themselves to be either more or less available than what the extension
660643
provides.
661644

662-
We could also implement a ``@_alwaysEmitIntoClient`` attribute for conformances.
663-
This introduces its own challenges with runtime uniquing of witness tables now
664-
necessary for conformances.
665645

646+
Fixed-Contents Structs
647+
----------------------
666648

667-
Frozen Structs
668-
--------------
669-
670-
To opt out of this flexibility, a struct may be marked ``@frozen``.
649+
To opt out of this flexibility, a struct may be marked ``@fixedContents``.
671650
This promises that no stored properties will be added to or removed from the
672651
struct, even non-public ones. Additionally, all versioned instance stored
673-
properties in a ``@frozen`` struct are implicitly declared
652+
properties in a ``@fixedContents`` struct are implicitly declared
674653
``@inlinable`` (as described above for top-level variables). In effect:
675654

676655
- Reordering stored instance properties (public or non-public) is not permitted.
@@ -701,9 +680,14 @@ generic parameters and members of tuples.
701680
.. note::
702681

703682
The above restrictions do not apply to ``static`` properties of
704-
``@frozen`` structs. Static members effectively behave as top-level
683+
``@fixedContents`` structs. Static members effectively behave as top-level
705684
functions and variables.
706685

686+
.. note::
687+
688+
The name ``@fixedContents`` is intentionally awful to encourage us to come
689+
up with a better one.
690+
707691
While adding or removing stored properties is forbidden, existing properties may
708692
still be modified in limited ways:
709693

@@ -714,13 +698,13 @@ still be modified in limited ways:
714698
- A versioned ``internal`` property may be made ``public`` (without changing
715699
its version).
716700

717-
An initializer of a frozen struct may be declared ``@inlinable`` even
701+
An initializer of a fixed-contents struct may be declared ``@inlinable`` even
718702
if it does not delegate to another initializer, as long as the ``@inlinable``
719703
attribute, or the initializer itself, is not introduced earlier than the
720-
``@frozen`` attribute and the struct has no non-versioned stored
704+
``@fixedContents`` attribute and the struct has no non-versioned stored
721705
properties.
722706

723-
A ``@frozen`` struct is *not* guaranteed to use the same layout as a C
707+
A ``@fixedContents`` struct is *not* guaranteed to use the same layout as a C
724708
struct with a similar "shape". If such a struct is necessary, it should be
725709
defined in a C header and imported into Swift.
726710

@@ -733,7 +717,7 @@ defined in a C header and imported into Swift.
733717

734718
.. note::
735719

736-
Hypothetically, we could use a different model where a ``@frozen``
720+
Hypothetically, we could use a different model where a ``@fixedContents``
737721
struct only guarantees the "shape" of the struct, so to speak, while
738722
leaving all property accesses to go through function calls. This would
739723
allow stored properties to change their accessors, or (with the Behaviors
@@ -742,17 +726,17 @@ defined in a C header and imported into Swift.
742726
a simple C-like struct that groups together simple values, with only public
743727
stored properties and no observing accessors, and having to opt into direct
744728
access to those properties seems unnecessarily burdensome. The struct is
745-
being declared ``@frozen`` for a reason, after all: it's been
729+
being declared ``@fixedContents`` for a reason, after all: it's been
746730
discovered that its use is causing performance issues.
747731

748732
Consequently, as a first pass we may just require all stored properties in
749-
a ``@frozen`` struct, public or non-public, to have trivial
733+
a ``@fixedContents`` struct, public or non-public, to have trivial
750734
accessors, i.e. no observing accessors and no behaviors.
751735

752-
``@frozen`` is a `versioned attribute`. This is so that clients can
736+
``@fixedContents`` is a `versioned attribute`. This is so that clients can
753737
deploy against older versions of the library, which may have a different layout
754738
for the struct. (In this case the client must manipulate the struct as if the
755-
``@frozen`` attribute were absent.)
739+
``@fixedContents`` attribute were absent.)
756740

757741

758742
Enums
@@ -1187,14 +1171,19 @@ A Unifying Theme
11871171
~~~~~~~~~~~~~~~~
11881172

11891173
So far this document has talked about ways to give up flexibility for several
1190-
different kinds of declarations: namely ``@inlinable`` for functions, and
1191-
``@frozen`` for enums and structs. Each of these has a different set of
1174+
different kinds of declarations: ``@inlinable`` for functions,
1175+
``@fixedContents`` for structs, etc. Each of these has a different set of
11921176
constraints it enforces on the library author and promises it makes to clients.
1193-
However, they follow a common theme of giving up the flexibility of future
1177+
However, they all follow a common theme of giving up the flexibility of future
11941178
changes in exchange for improved performance and perhaps some semantic
1195-
guarantees. Therefore, these attributes are informally referred to as
1179+
guarantees. Therefore, all of these attributes are informally referred to as
11961180
"fragility attributes".
11971181

1182+
Given that these attributes share several characteristics, we could consider
1183+
converging on a single common attribute, say ``@fixed``, ``@inline``, or
1184+
``@fragile``. However, this may be problematic if the same declaration has
1185+
multiple kinds of flexibility.
1186+
11981187

11991188
Versioning Internal Declarations
12001189
================================
@@ -1244,7 +1233,7 @@ at run time if the source code is reorganized, which is unacceptable.
12441233
keep things simple we'll stick with the basics.
12451234

12461235
We could do away with the entire feature if we restricted inlinable functions
1247-
and frozen structs to only refer to public entities. However, this
1236+
and fixed-contents structs to only refer to public entities. However, this
12481237
removes one of the primary reasons to make something inlinable: to allow
12491238
efficient access to a type while still protecting its invariants.
12501239

@@ -1255,7 +1244,7 @@ efficient access to a type while still protecting its invariants.
12551244
*Backdating* refers to releasing a new version of a library that contains
12561245
changes, but pretending those changes were made in a previous version of the
12571246
library. For example, you might want to release version 1.2 of the "Magician"
1258-
library, but pretend that the "SpellIncantation" struct was frozen
1247+
library, but pretend that the "SpellIncantation" struct was fixed-contents
12591248
since its introduction in version 1.0.
12601249

12611250
**This is not safe.**
@@ -1264,8 +1253,9 @@ Backdating the availability a versioned entity that was previously non-public
12641253
is clearly not safe: older versions of the library will not expose the entity
12651254
as part of their ABI. What may be less obvious is that the fragility attributes
12661255
likewise are not safe to backdate, even if you know the attributes could have
1267-
been added in the past. To give one example, the presence of ``@frozen`` may
1268-
affect the layout and calling conventions for an enum or struct.
1256+
been added in the past. To give one example, the presence of ``@closed`` or
1257+
``@fixedContents`` may affect the layout and calling conventions for an enum
1258+
or struct.
12691259

12701260
.. note::
12711261

@@ -1480,7 +1470,7 @@ for verification. Important cases include but are not limited to:
14801470
- Unsafe `backdating <#backdating>`_.
14811471

14821472
- Unsafe modifications to entities marked with fragility attributes, such as
1483-
adding a stored property to a ``@frozen`` struct.
1473+
adding a stored property to a ``@fixedContents`` struct.
14841474

14851475
Wherever possible, this tool should also check for `binary-compatible
14861476
source-breaking changes <binary-compatible source-breaking change>`, such as
@@ -1637,22 +1627,19 @@ The following proposals (some currently in the process, some planned) will
16371627
affect the model described in this document, or concern the parts of this
16381628
document that affect language semantics:
16391629

1640-
- Non-exhaustive enums (`SE-0192 <SE0192>`_)
1641-
- Inlineable functions (`SE-0193 <SE0193>`_)
1642-
- Frozen structs and enums (`SE-0260 <SE0260>`_)
16431630
- (draft) `Overridable methods in extensions`_
16441631
- (planned) Restricting retroactive modeling (protocol conformances for types you don't own)
16451632
- (planned) `Generalized existentials (values of protocol type) <Generics>`_
1633+
- (planned) Frozen enums (building on `SE-0192 <SE0192>`_)
16461634
- (planned) Removing the "constant" guarantee for 'let' across module boundaries
1635+
- (planned) Syntax for declaring fixed-contents structs
16471636
- (future) Performance annotations for types
16481637
- (future) Attributes for stored property accessors
16491638
- (future) Stored properties in extensions
16501639

16511640
.. _Overridable methods in extensions: https://github.com/jrose-apple/swift-evolution/blob/overridable-members-in-extensions/proposals/nnnn-overridable-members-in-extensions.md
16521641
.. _Generics: https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#generalized-existentials
16531642
.. _SE0192: https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md
1654-
.. _SE0193: https://github.com/apple/swift-evolution/blob/master/proposals/0193-cross-module-inlining-and-specialization.md
1655-
.. _SE0260: https://github.com/apple/swift-evolution/blob/master/proposals/0260-library-evolution.md
16561643

16571644
This does not mean all of these proposals need to be accepted, only that their
16581645
acceptance or rejection will affect this document.

0 commit comments

Comments
 (0)