Commit Graph

1960 Commits

Author SHA1 Message Date
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
swift-ci
fba0ac6bb0 Merge remote-tracking branch 'origin/master' into master-next 2018-02-01 10:29:09 -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
swift-ci
44156b68c3 Merge remote-tracking branch 'origin/master' into master-next 2018-02-01 09:09:10 -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
swift-ci
8b7428ea10 Merge remote-tracking branch 'origin/master' into master-next 2018-02-01 08:49:10 -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
swift-ci
ea2b437528 Merge remote-tracking branch 'origin/master' into master-next 2018-01-30 18:49:14 -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
swift-ci
3ccf673496 Merge remote-tracking branch 'origin/master' into master-next 2018-01-30 15:09:14 -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
Mike Ash
146833c9b5 [Runtime] Fix unowned refcount overflow to side table during deinit.
32-bit has a 7-bit inline unowned refcount, then 31 bits in the side table. Overflowing the inline count in deinit on an object that didn't already have a side table would crash, because the code assumed that creating a side table in deinit was not allowed.

(64-bit has 31 bits inline and in the side table. Overflowing the inline count immediately overflows the side table as well, so there's no change in behavior there.)

rdar://problem/33765960
2018-01-30 15:38:08 -05:00
swift-ci
9ea6b52e9a Merge remote-tracking branch 'origin/master' into master-next 2018-01-30 07:09:19 -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
328391d927 Merge remote-tracking branch 'origin/master' into master-next 2018-01-29 13:42:47 -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
swift-ci
0cecb325dc Merge remote-tracking branch 'origin/master' into master-next 2018-01-29 12:50:53 -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
swift-ci
8e3f46b601 Merge remote-tracking branch 'origin/master' into master-next 2018-01-24 17:11:19 -08: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
Davide Italiano
59aea90ef3 Merge pull request #14138 from dcci/hotfixes
[Master-next] Update after recent breaking changes
2018-01-24 15:21:04 -08:00
Davide Italiano
1e67e76502 [runtime] Provide a stub for report_bad_alloc_error.
ADT uses report_bad_alloc_error to report an error when it can't allocate
elements for a data structure. The swift runtime uses ADT without linking
against libSupport, so here we provide a stub to make sure we don't fail
to link. Give it `weak` linkage so, in case the `strong` definition of
the function is available, that gets precedence.
2018-01-24 15:16:22 -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
Arnold Schwaighofer
17cd95efa4 Rename swift3 section and global names to swift5
Such that old and new runtimes can co-exists
rdar://36363251
2018-01-22 10:04:46 -08:00
Doug Gregor
ef90f87d65 Merge pull request #14038 from DougGregor/nominal-type-access-function-imported-types
Emit nominal type access functions for imported types.
2018-01-21 21:35:27 -08:00
Michael Ilseman
c7eefc1ca5 Merge pull request #14046 from milseman/string_guts_squash
StringGuts: New 2-word representation for String
2018-01-21 21:28:15 -08:00
Karoy Lorentey
f2a96496a0 [StringGuts] Support for 32-bit platforms
Add 32-bit support to the new StringGuts.
2018-01-21 12:36:09 -08:00
Doug Gregor
2c9ad900ae [Mangled name -> metadata] Handle import-as-member types.
When import-as-member takes a C type and imports it as a nested type,
we end up with a nominal type descriptor for a nested type, but the
mangled name remains "flat". Cope with inconsistency to allow
_typeByMangledName() to handle such nested types.
2018-01-19 23:32:51 -08:00
Mike Ash
406ebaddfc [Runtime] Implement overflow check for weak refcounts (#14023)
* Check for overflow in incrementWeak().

This mirrors what is currently done for unowned reference counts, where overflowing the side table field produces a fatal error. Without this, the count silently wrapped from 2^31-1 to 0, which then caused breakage when the balancing releases happened (possibly including use-after-free bugs).

* Fix the implementation of RefCounts::getWeakCount().

The previous implementation was only appropriate for heap objects, but not side tables. This resulted in the weak count always returning 0 or 1. This change specializes the implementation for the two different cases and returns the correct count for side tables.

* Test large weak retain counts.

This tests the largest allowed weak retain count, as well as the overflow check when that count is exceeded.
2018-01-19 19:13:47 -08:00
Doug Gregor
764cb7003d [ABI] Record proper number of requirements in protocol descriptor.
The prior refactoring to add the protocol conformance descriptor into
witness tables offset the # of requirements stored in the witness
table by 1. Address this oddity in the metadata by ensuring that the #
of requirements (and # of mandatory requirements) in the protocol
descriptor is accurate.
2018-01-18 21:34:31 -08:00
Doug Gregor
40283f9b73 [ABI] Add the protocol conformance descriptor into a witness table.
Extend witness tables with a pointer to the protocol conformance
descriptor from which the witness table was generated. This will allow
us to determine (for example) whether two witness tables were
generated from the same (or equivalent) conformances in the future, as
well as discover more information about the witness table itself.

Fixes rdar://problem/36287959.
2018-01-18 17:13:13 -08:00
Doug Gregor
e766473ed9 [ABI] Emit separate symbols for protocol conformance descriptors.
Emit protocol conformance descriptors as separate symbols, rather than
inlining them within the section for protocol conformance records. We
want separate symbols for protocol conformances both because it is easier
to make them variable-length (as required for conditional
conformances) and because we want to reference them from witness
tables (both of which are coming up).
2018-01-17 10:35:16 -08:00
Doug Gregor
663d6af063 [ABI] Factor out the protocol conformance flags (again).
Protocol conformance records are becoming richer and more interesting;
separate out the "flags" word and add the various other fields that we
want there (is-retroactive, is-synthesized-nonunique, # of conditional
requirements).
2018-01-17 10:06:07 -08:00
Doug Gregor
59c98e6ecf [Mangled name -> type metadata] Support arbitrary # of generic args.
Now that we have a suitable calling convention for the access function
of a generic nominal type descriptor with > 3 arguments, add support
for calling with an arbitrary number of generic arguments.
2018-01-13 22:34:51 -08:00
Doug Gregor
d0b73b85d0 [Type decoder] Generalize the canonicalization of nominal type decl references.
Various TypeDecoder clients will depend on having the "bare" nominal
type declaration demangled node for looking up nominal type descriptors,
so move the generic argument-stripping code into TypeDecoder.
2018-01-12 15:35:12 -08:00
Doug Gregor
a2d97719d3 [Runtime] Support nested generic types in mangled name -> type metadata. 2018-01-12 15:35:12 -08:00