Commit Graph

1073 Commits

Author SHA1 Message Date
Michael Gottesman
68e2e708d0 [runtime] Add a dumping method to HeapObject when asserts are enabled.
Given any heap object, this method dumps:

* The pointer address of the heap object.
* The pointer address of the heap metadata of the object.
* The strong reference count.
* The unowned reference count.
* The weak reference count.
* Whether or not the value is in the deinit state.
* Whether or not the heap object uses swift_retain or objc_retain.
* The address of the object's side table if one exists.

This makes it really easy when debugging quickly to get all of the information
that you could possibly need from a HeapObject.
2018-02-07 11:54:48 -08:00
Arnold Schwaighofer
d981bb1d96 Mangling: noescape functions will be trivial and no longer compatible with escape function types.
Mangle escapeness as part of the type.

Part of:
SR-5441
rdar://36116691
2018-02-06 08:51:43 -08:00
Pavel Yaskevich
caf73113ea [Runtime/Metadata] Add ownership information to _getTypeByMangledName
`_typeByMangledName` could encounter types which have ownership attributes
associated with them which are not representable by the metadata object
but nevertheless are important, so such ownership information should be
returned along with metadata itself from the call.
2018-02-05 15:26:11 -08:00
Saleem Abdulrasool
83c4df8045 Merge pull request #14358 from compnerd/remove-SWIFT_USE_SWIFTCALL
stdlib: remove vestigial SWIFT_USE_SWIFTCALL
2018-02-04 09:53:27 -08:00
swift-ci
87f7b4e5fb Merge pull request #14368 from DougGregor/se-0143-runtime-conditional-conformances 2018-02-02 17:29:26 -08:00
swift-ci
5663b4487d Merge pull request #14378 from compnerd/windows-runtime-initializer 2018-02-02 17:17:13 -08:00
Doug Gregor
81f15746b6 [Runtime] Always cache conformance results based on the type metadata. 2018-02-02 16:41:28 -08:00
Doug Gregor
93442cf11f [Runtime] SE-0143: Evaluate conditional conformances at runtime.
When evaluating whether a given type conforms to a protocol, evaluate the
conditional requirements and pass the results to the witness table
accessor function. This provides the ability to query conditional
conformances at runtime, and is the last major part of implementing
SE-0143.

The newly-added unlock/lock dance in the conformance lookup code is a
temporary stub. We have some ideas to do this better.

Fixes rdar://problem/34944655.
2018-02-02 16:41:27 -08:00
Saleem Abdulrasool
76d7bfd8ed runtime: ensure that the module constructor element is RO
The default attribute on the section is read/write.  This would cause
the section to have different attributes when compiled.  The linker
would then preserve the section rather than merge it into the right
location.  This was noticed when linking with `link.exe`.
2018-02-02 15:01:44 -08:00
Saleem Abdulrasool
bb55044f38 runtime: add missing sw5prt to the section list
The Windows constructor was not populated properly, with the protocol
list being dropped.  Ensure that all the fields are initialised
properly.  Thanks to clang's `-Wmissing-field-initializers` warning to
help catch this.
2018-02-02 15:00:34 -08:00
Saleem Abdulrasool
bc950fd41a runtime: mark the section markers with the correct attributes
On windows, we create synthetic markers with grouping identifiers to
ensure that the markers are sorted properly and merged.  We would
previously mark the section as read/write rather than read-only causing
warnings when linking.  Correct the attributes.  This ensures the proper
linking of the modules.
2018-02-02 14:56:23 -08:00
troughton
e156826984 Remove _swift_allocBox_ function pointers. 2018-02-03 10:20:57 +13:00
troughton
cf28ff448c Remove TwoWordPair and use SwiftCC instead. 2018-02-03 09:43:00 +13:00
Saleem Abdulrasool
0fa8ac062c stdlib: remove vestigial SWIFT_USE_SWIFTCALL
Remove the last vestiges of `SWIFT_USE_SWIFTCALL`.  Building without
SwiftCC is no longer supported.
2018-02-01 22:52:17 -08:00
swift-ci
5dd3572dbf Merge pull request #14351 from DougGregor/demangle-to-metadata-class-constraints 2018-02-01 18:59:56 -08:00
Doug Gregor
ef1dfdfc42 [Runtime] Stub out the same-conformance requirement check.
The compiler doesn't generate these yet, and we don't really have a
good way to use or test them. For now, ignore them.
2018-02-01 17:40:17 -08:00
Doug Gregor
90afecfda8 [Runtime] Dynamically evaluate superclass constraints. 2018-02-01 17:35:47 -08:00
Doug Gregor
9445839208 [Runtime] Evaluate layout constraints at runtime. 2018-02-01 17:20:44 -08:00
Doug Gregor
5c59e81480 [Runtime] Evaluate same-type requirements at runtime.
Extend the runtime's ability for evaluating generic requirements to
handle same-type requirements, demangling/substituting the name from
the generic requirement metadata.
2018-02-01 17:00:51 -08:00
Doug Gregor
6dc429af43 Merge pull request #14327 from DougGregor/demangle-to-metadata-generic-reqs
Check generic requirements in `_typeByMangledName`.
2018-02-01 16:07:29 -08:00
swift-ci
13d6d9b67b Merge pull request #14344 from gottesmm/pr-3795434d15ca181c9da1f232ce9a3f23e936f94c 2018-02-01 15:37:39 -08:00
swift-ci
1b7f76f0f2 Merge pull request #14343 from gottesmm/pr-4ae52c548d2f9133a74b620859eb1ed0640f60cf 2018-02-01 14:53:12 -08:00
Doug Gregor
f8c769c4ae [Demangle-to-type] Handle type arguments and requirements for nested generics.
Extend the support for mangled-name-to-type-metadata's handling of generic
types to handle nested types, including gathering type arguments from
parent contents and checking generic requirements.
2018-02-01 14:45:13 -08:00
Doug Gregor
8c4d86c74a [Mangled name -> metadata] Check generic protocol conformance requirements.
Extend support for mapping a mangled name -> type metadata to include
support for checking protocol conformance requirements, using the
encoding of generic requirements that is now available within context
descriptors. For example, this allows
_typeByMangledName(mangled-name-of-Set<Int>) to construct proper type
metadata, filling in the Int: Hashable requirement as appropriate.
2018-02-01 14:43:24 -08:00
Doug Gregor
82259e11f1 [Runtime] Make type context descriptor accessor for TargetTypeMetadataRecord robust.
Don't assert if we have an unexpected kind; return null so the caller
can handle it.
2018-02-01 14:41:53 -08:00
Michael Gottesman
2a7a2fb2f0 [runtime] Add support for verifying that all known protocol conformance descriptors are valid.
rdar://34222540
2018-02-01 14:02:20 -08:00
Michael Gottesman
6ac81e5489 [metadata] Add dump to Metadata.
We dump the following information:

1. The Kind.
2. Pointer to the value witnesses.
3. Pointer to the class object if one is available.
4. Pointer the type context description if one is available.
5. Pointer to the generic arguments if one is available.

This makes it significantly easier to poke around Metadata.

rdar://34222540
2018-02-01 13:29:08 -08:00
Michael Gottesman
0d4cbc4296 [+0-all-args] Fix const_cast issue.
This is hidden behind the +0 preprocessor flag, so it only affected me.

NFC.

rdar://34120147
2018-02-01 09:42:11 -08:00
Michael Gottesman
8e4024328e [runtime] Add support for dumping ProtocolDescriptor/ProtocolDescriptorFlags.
This is only enabled when the runtime is compiled with assertions. This will
make it easier to debug the runtime.

rdar://34222540
2018-02-01 08:53:33 -08:00
Michael Gottesman
e3342c753c [runtime] Add support for verifying at runtime that a protocol descriptive has a valid type kind/conformance kind.
This is useful when trying to track down data corruption in the runtime. I am
currently running into such issues with the +0-all-arg work, so I am adding
stuff like this to help debug this issue and future such issues.

rdar://34222540
2018-02-01 08:53:13 -08:00
Joe Groff
d974ee4acc Runtime: Wrap the metadata access function pointer in a functor that calls it properly.
Provide a bit of type safety for parts of the runtime that may want to invoke it, and centralize the logic for handling its calling convention.
2018-01-31 20:37:05 -08:00
Michael Gottesman
2e6bda0663 [+0-all-args] Document the swift exposed functions in Reflection.mm as being either methods or free functions.
Some of the free functions have method like names, so it is impossible to know
whether or not the given functions use the method convention or the thin
convention. At least now it is documented.

rdar://34222540
2018-01-30 18:29:27 -08:00
Joe Groff
9b1d8ff6db Merge pull request #14284 from jckarter/leaks-ntd-update
Runtime: Update Leaks.mm for context descriptors change.
2018-01-30 14:51:10 -08:00
Joe Groff
864933eb13 Runtime: Update Leaks.mm for context descriptors change. 2018-01-30 13:08:01 -08:00
Joe Groff
a7a3b17597 Replace nominal type descriptors with a hierarchy of context descriptors.
This new format more efficiently represents existing information, while
more accurately encoding important information about nested generic
contexts with same-type and layout constraints that need to be evaluated
at runtime. It's also designed with an eye to forward- and
backward-compatible expansion for ABI stability with future Swift
versions.
2018-01-29 16:19:25 -08:00
swift-ci
04630a3d0b Merge pull request #14240 from gottesmm/pr-2abaee5940120b3316efe10c560537953bf60d60 2018-01-29 13:27:31 -08:00
Greg Parker
e223f1fc9b [IRGen][runtime] Simplify runtime CCs and entry point ABIs (#14175)
* Remove RegisterPreservingCC. It was unused.
* Remove DefaultCC from the runtime. The distinction between C_CC and DefaultCC
  was unused and inconsistently applied. Separate C_CC and DefaultCC are
  still present in the compiler.
* Remove function pointer indirection from runtime functions except those
  that are used by Instruments. The remaining Instruments interface is
  expected to change later due to function pointer liability.
* Remove swift_rt_ wrappers. Function pointers are an ABI liability that we
  don't want, and there are better ways to get nonlazy binding if we need it.
  The fully custom wrappers were only needed for RegisterPreservingCC and
  for optimizing the Instruments function pointers.
2018-01-29 13:22:30 -08:00
Mike Ash
5e2b11d42d Merge pull request #14157 from mikeash/conditionally-disable-runtimefunctioncounters
[Runtime] Remove RuntimeFunctionCounters in no-assert builds.
2018-01-29 15:48:32 -05:00
Michael Gottesman
ce0c40e40b [+0-all] Update more runtime files for +0 normal arguments.
This is NFC when --enable-guaranteed-normal-arguments isn't passed into
build-script.

rdar://34222540
2018-01-29 12:13:45 -08:00
Michael Gottesman
1b37cc7acc [+0-all-args] Fixup more of Reflection.mm.
This mainly was just removing #if{,n}def in favor of SWIFT_CC_* macros. But I
did add a missing retain needed in swift_StructMirror_subscript since owner is
no longer passed at +1 and mirrors consume the owner.

rdar://34222540
2018-01-29 11:44:39 -08:00
Greg Parker
eec25f33aa Update RuntimeInvocationsTracking.h 2018-01-25 18:43:20 -08:00
Mike Ash
f48bd293cb [Runtime] Remove RuntimeFunctionCounters in no-assert builds.
A build option to include or exclude RuntimeFunctionCounters. By default, it's enabled when assertions are enabled.

rdar://problem/35864525
2018-01-25 12:18:25 -05:00
Michael Gottesman
4683663cae [cmake] Make sure that we use SWIFT_RUNTIME_ENABLE_GUARANTEED_NORMAL_ARGUMENTS for /all/ of the runtime.
This includes the private stdlib sources since there are some parts of stdlib
unittest that I need to make conditionally +0.

rdar://34222540
2018-01-24 16:50:42 -08:00
Pavel Yaskevich
b1251b349f Merge pull request #14125 from xedin/metaprogam-bultin-meta
[Mangled name -> metadata] Add built-in types support
2018-01-24 14:53:32 -08:00
Pavel Yaskevich
86916cf4d8 [Mangled name -> metadata] Add built-in types support 2018-01-24 00:29:24 -08:00
Pavel Yaskevich
eda032db21 [Demangler] Add support for demangling of known Builtin types from metadata 2018-01-23 23:45:54 -08:00
Pavel Yaskevich
07534a6464 [Runtime] NFC: Create a .def file with all supported built-in types 2018-01-23 23:40:13 -08:00
Michael Ilseman
62409922b7 [string] 32-bit String is still 3 words 2018-01-23 13:57:34 -08:00
Greg Parker
7b9224794e [runtime] Reinstate TwoWordPair hack for swiftcall returns. (#14079)
clang is miscompiling some swiftcall functions on armv7s.
Stop using swiftcall in some places until it is fixed.

Reverts c5bf2ec (#13299).

rdar://35973477
2018-01-23 01:04:01 -08:00
Arnold Schwaighofer
8e71f34517 One more place I missed in the swift5 rename 2018-01-22 10:23:51 -08:00