Commit Graph

24 Commits

Author SHA1 Message Date
John McCall
f3dc58667d Improve the typing of materializeForSet callbacks to
use a thin function type.

We still need thin-function-to-RawPointer conversions
for generic code, but that's fixable with some sort of
partial_apply_thin_recoverable instruction.

Swift SVN r24364
2015-01-11 21:13:35 +00:00
John McCall
6a91f7a172 Various improvements to the function-type ABI.
Teach IRGen and the runtime about the extra inhabitants
of function pointers, and take advantage of that in
thin and thick function types.

Also add runtime entrypoints for thin function type
metadata.

Swift SVN r24346
2015-01-10 01:45:37 +00:00
Dmitri Hrybenko
fd7ce02a51 Runtime: emit BridgeObject metadata on all platforms
Per Joe, a low level retained-pointer-with-user-controlled-spare-bits
type would still be useful for space efficiency even on platforms that
don't need ObjC interop.

Swift SVN r22943
2014-10-25 21:37:41 +00:00
Dmitri Hrybenko
44ca2ea31f Runtime: suppress BridgeObject metadata on platforms without ObjC
interop

Swift SVN r22942
2014-10-25 08:26:28 +00:00
Joe Groff
fc369ce734 Give Builtin.BridgeObject nil as an extra inhabitant.
Reserve the other low pointer values for potential internal use.

Swift SVN r22881
2014-10-23 00:49:14 +00:00
Joe Groff
5a2f48e3be Add a Builtin.BridgeObject type.
This is a type that has ownership of a reference while allowing access to the
spare bits inside the pointer, but which can also safely hold an ObjC tagged pointer
reference (with no spare bits of course). It additionally blesses one
Foundation-coordinated bit with the meaning of "has swift refcounting" in order
to get a faster short-circuit to native refcounting. It supports the following
builtin operations:

- Builtin.castToBridgeObject<T>(ref: T, bits: Builtin.Word) ->
  Builtin.BridgeObject

  Creates a BridgeObject that contains the bitwise-OR of the bit patterns of
  "ref" and "bits". It is the user's responsibility to ensure "bits" doesn't
  interfere with the reference identity of the resulting value. In other words,
  it is undefined behavior unless:

    castReferenceFromBridgeObject(castToBridgeObject(ref, bits)) === ref

  This means "bits" must be zero if "ref" is a tagged pointer. If "ref" is a real
  object pointer, "bits" must not have any non-spare bits set (unless they're
  already set in the pointer value). The native discriminator bit may only be set
  if the object is Swift-refcounted.

- Builtin.castReferenceFromBridgeObject<T>(bo: Builtin.BridgeObject) -> T

  Extracts the reference from a BridgeObject.

- Builtin.castBitPatternFromBridgeObject(bo: Builtin.BridgeObject) -> Builtin.Word

  Presents the bit pattern of a BridgeObject as a Word.

BridgeObject's bits are set up as follows on the various platforms:

i386, armv7:

  No ObjC tagged pointers
  Swift native refcounting flag bit: 0x0000_0001
  Other available spare bits:        0x0000_0002

x86_64:

  Reserved for ObjC tagged pointers: 0x8000_0000_0000_0001
  Swift native refcounting flag bit: 0x0000_0000_0000_0002
  Other available spare bits:        0x7F00_0000_0000_0004

arm64:

  Reserved for ObjC tagged pointers: 0x8000_0000_0000_0000
  Swift native refcounting flag bit: 0x4000_0000_0000_0000
  Other available spare bits:        0x3F00_0000_0000_0007

TODO: BridgeObject doesn't present any extra inhabitants. It ought to at least provide null as an extra inhabitant for Optional.

Swift SVN r22880
2014-10-23 00:09:23 +00:00
Dmitri Hrybenko
872a02f205 Runtime: don't use metadata for Builtin.UnknownObject when
!SWIFT_OBJC_INTEROP

Swift SVN r22510
2014-10-03 23:43:01 +00:00
Dmitri Hrybenko
34a81f0618 Runtime: allow some runtime code to compile when !SWIFT_OBJC_INTEROP
Swift SVN r22341
2014-09-28 18:57:01 +00:00
Dmitri Hrybenko
26ea0b0040 Remove a workaround for an old compiler bug that is not needed now
Swift SVN r22322
2014-09-28 01:31:07 +00:00
John McCall
77ea35ab46 Introduce a flag to mark classes with Swift-native
refcounting and take advantage of it.

Also, set the Swift1 flag in classes we generate.

Also, initialize a global cache of the non-pointer-isa
mask and use that instead of object_getClass, at least
within the runtime.

Also, centralize the runtime on a _swift_getSuperclass
function and make that use a direct access while we
await word from Greg on the desired ABI requirements.

Swift SVN r21077
2014-08-06 21:51:45 +00:00
John McCall
584795e505 Replace the typeOf value witness with an
initializeBufferWithTakeOfBuffer value witness.

Attempt to use initializeBufferWithTakeOfBuffer in
some appropriate places.

There are some changes enabled by this which are
coming in a follow-up patch.

Swift SVN r20741
2014-07-30 08:24:12 +00:00
John McCall
934527a029 Eliminate all uses of the typeof value witness.
Swift SVN r20734
2014-07-30 04:40:58 +00:00
Greg Parker
1121b2c132 Revert r16666 because I think my test configuration was wrong.
Swift SVN r16667
2014-04-22 22:24:57 +00:00
Greg Parker
629e7f59b4 Prevent direct ObjC isa dereference when using ObjCClassWrapperMetadata.
This fixes several tests on arm64.


Swift SVN r16666
2014-04-22 22:14:35 +00:00
John McCall
85a6cc1309 Make it really easy to generate value witness tables
from C++ types and aggregates thereof.

Swift SVN r16139
2014-04-10 00:01:34 +00:00
John McCall
9490da8a1f Inform the runtime that metatype values have extra inhabitants.
Swift SVN r15665
2014-03-31 05:49:18 +00:00
Joe Groff
4f2656cc7c Runtime: Prefab metadata for Builtin.Int128 (and for similar-sized Float* types).
Swift SVN r15259
2014-03-20 02:02:28 +00:00
Dave Zarzycki
a85b2a3d78 Runtime: Rename Alloc.* to HeapObject.* (NFC)
Swift SVN r14228
2014-02-21 20:12:07 +00:00
Joe Groff
7de9706403 IRGen/Runtime: Expose extra inhabitants of class protocol types.
This gives 'id?' and other optional class protocol types optimal representation consistent with class types.

Swift SVN r10346
2013-11-11 22:52:23 +00:00
Joe Groff
554abf2d7a IRGen/Runtime: Expose extra inhabitants of class types.
Start using null-page values as extra inhabitants when laying out single-payload enums that contain class pointers as their payload type. Don't use inhabitants that set the lowest bit, to avoid trampling potential ObjC tagged pointer representations. This means that 'T?' for class type T now has a null pointer representation. Enums with multiple empty cases, as well as nested enums like 'T??', should now have optimal representations for class type T as well.

Note that we don't yet expose extra inhabitants for aggregates that contain heap object references, such as structs with class fields, Swift function types, or class-bounded existentials (even when the existential has no witness tables).

Swift SVN r10061
2013-11-09 00:43:40 +00:00
Joe Groff
fe7ecec60c Runtime: Provide value witness implementations for class existentials.
Same deal as for opaque existentials--pre-instantiate a static witness table for one-witness-table types (the zero-witness-tables case is nicely handled by Builtin.ObjCPointer's value witness), and generate a vwtable using dynamic witness implementations for each different-sized container on demand as necessary.

Swift SVN r9850
2013-10-31 18:38:54 +00:00
Joe Groff
46fd1c91b3 IRGen: Emit metadata and value witness tables for nongeneric unions.
And remove the hokey hardcoded metadata for Bool from the runtime.

Swift SVN r7541
2013-08-23 23:09:26 +00:00
Jordan Rose
674a03b085 Replace "oneof" with "union"...everywhere.
We haven't fully updated references to union cases, and enums still are not
their own thing yet, but "oneof" is gone. Long live "union"!

Swift SVN r6783
2013-07-31 21:33:33 +00:00
Dmitri Hrybenko
ea43c46262 Splitting the standard library: move runtime -> stdlib/runtime
Swift SVN r5887
2013-06-28 22:41:38 +00:00