Commit Graph

13406 Commits

Author SHA1 Message Date
Arnold Schwaighofer
e582a45a48 stdlib: Make ArrayBufferProtocol.init inlinable to facilitate specialization
SR-9284
2018-11-26 11:10:21 -08:00
Doug Gregor
39481149a3 [Runtime] Compute generic metadata cache info once per type.
Rather than scanning through the generic parameters and generic requirements
each time we form a key for the generic metadata cache, compute these
values once, when the cache itself is first initialized.
2018-11-26 10:46:42 -08:00
Michael Ilseman
8b9cc18003 Merge pull request #20621 from milseman/unsafe_unchecked_buffer_pointer
[stdlib] Unchecked subscript on UnsafeBufferPointer
2018-11-26 10:31:04 -08:00
Karoy Lorentey
66db9b40b8 [stdlib] _HashTable.copyContents: Fix buffer overrun 2018-11-26 18:24:23 +00:00
Doug Gregor
06807c2ea6 [Runtime] Only scan the type descriptor once for metadata cache entries.
Rather than scanning the type descriptor each time we perform a comparison
or hash of a metadata cache entry, do so only once to establish the number
of key parameters and the number of witness tables. Use those values to
more efficiently compare keys.
2018-11-25 22:10:04 -08:00
Saleem Abdulrasool
29dc89bd9b stdlib: broaden ucrt module
Add `process` to the ucrt module as this is used in the Foundation port
for Windows.
2018-11-24 20:57:46 -08:00
Arjun Nayini
a15ecd0039 PR Feedback 2018-11-24 13:51:48 -08:00
Arjun Nayini
300124460f [SR-7076] Make ContiguousArray Codable
Implements Encodable and Decodable for ContiguousArray.
2018-11-24 09:09:55 -08:00
Karoy Lorentey
545fa5e640 [stdlib] Re-add previously synthesized hashing definitions 2018-11-22 17:15:36 +00:00
Karoy Lorentey
8bd56509b2 [stdlib] Add hashing methods to RawRepresentable to match == 2018-11-22 17:14:56 +00:00
Saleem Abdulrasool
ab37099967 Merge pull request #20686 from compnerd/alignment
stdlib: pass along alignment for dealloc
2018-11-21 09:34:14 -08:00
Doug Gregor
32f577abf2 [Runtime] Perform “deep” comparisons of witness tables when uniquing metadata.
Metadata uniquing might encounter witness tables that were distinctly
generated but come from identical descriptors. Handle this case in metadata
uniquing be looking into the protocol conformance descriptors themselves.
2018-11-20 22:07:55 -08:00
Saleem Abdulrasool
381cae6df0 stdlib: pass along alignment for dealloc
Ensure that UnsafeMutablePointer.deallocate has the alignment that was
used when invoking UnsafeMutablePointer.allocate.  This is required to
ensure that the appropriate `free` function is invoked.  We would
previously fail on Windows as the allocation would use `malloc` and due
to the value being `-1`, use `_aligned_free` instead when deallocating.
2018-11-20 14:05:13 -08:00
Karoy Lorentey
694b153992 Merge pull request #20643 from lorentey/string-32-simple
[stdlib] _StringObject: Use a full 8-bit discriminator on 32-bit platforms
2018-11-20 17:50:53 +00:00
Karoy Lorentey
ef76bcf7cf [stdlib] Don’t change the 64-bit ABI 2018-11-20 12:11:34 +00:00
Mark Lacey
9e7d7d0b8e Merge pull request #20659 from rudkx/add-designated-types-for-logical-and-ranges
Update Policy.swift with designated types for logical and range operators.
2018-11-17 22:59:54 -08:00
Mark Lacey
b7626d7ccf [stdlib] Update Policy.swift with designated types for logical and range operators. 2018-11-17 20:18:28 -08:00
Doug Gregor
d9bb81bc20 [Runtime] Cache protocol conformance descriptors, not witness tables.
The conformance cache was caching the witness table for a conformance
`T: P`, where `T` is a concrete type and `P` is a protocol. However, it
essentially picked one of potentially many witness tables for that
conformance, because retroactive conformances might produce different results
from different modules.

Make the conformance cache what is says it is: a cache of the conformance
descriptor for a given `T: P`, potentially filtered by a module (when
requested). Clients of the conformance cache can choose how to interpret
the protocol conformance descriptor, e.g., by instantiating a witness table.

We can bring back a specific conformance cache for swift_conformsToProtocol()
if it is profitable.

(cherry picked from commit 0af2af00a739a4d912d2a9c3b196449e4164484f)
2018-11-16 22:26:40 -08:00
swift-ci
89950feea9 Merge pull request #20651 from milseman/spurious_inlinable 2018-11-16 19:16:20 -08:00
Lance Parker
8306ef322a Merge pull request #20585 from lancep/spotFixForStringCompCrash
[stdlib] properly promote stack buffer to heap buffer when necessary
2018-11-16 19:05:35 -08:00
Michael Ilseman
18e415b4c0 [String] CJK Grapheme breaking fast-paths for fullwidth
Add in grapheme breaking fast-paths for fullwidth forms and
punctuation. Extend non-combining kana fast-paths to include vowel
extender.
2018-11-16 16:27:20 -08:00
Mark Lacey
2c15dc2d1c Merge pull request #20625 from rudkx/designated-types-array
[ConstraintSystem] Add Array as a designated type for `+` and `+=`.
2018-11-16 15:28:34 -08:00
Michael Ilseman
8b1464a984 [String] Drop spurious @inlinable 2018-11-16 15:08:20 -08:00
Saleem Abdulrasool
a79c14164b Merge pull request #20633 from compnerd/weak-win
runtime: adjust LLVMSupport for Windows
2018-11-16 13:31:48 -08:00
Michael Ilseman
3a0ac0270d [stdlib] Unchecked subscript on UnsafeBufferPointer
Add a use an unchecked subscript on UnsafeBufferPointer, which skips
debugPrecondition checks (in case we're not inlined) as well as a
force-unwrap check.
2018-11-16 11:12:29 -08:00
Lance Parker
fc3341eddc fixup rebase 2018-11-16 11:07:30 -08:00
Mark Lacey
d3b660d907 [stdlib] Remove FIXMEs from Array extension. 2018-11-16 11:03:55 -08:00
Doug Gregor
d4fe6e9ff7 [Runtime] Fix a bug in handling multi-level generic environment substitutions. 2018-11-16 10:39:19 -08:00
Karoy Lorentey
3b748933f1 [stdlib] _StringObject: Use a full 8-bit discriminator on 32-bit platforms
We now have plenty of extra inhabitants in the variant enum, so we can get rid of the 7-bit hack.

It’d also be possible now to increase small string capacity to a spacious 11 bytes; however this needs a full overhaul of the 32-bit representation, so it needs a little bit more time in the oven.
2018-11-16 18:36:03 +00:00
Lance Parker
f9aa78761f Moar feedback 2018-11-16 10:21:33 -08:00
Lance Parker
12bf2978e3 Michael's feedback 2018-11-16 10:20:46 -08:00
Lance Parker
0009b21533 properly promote stack buffer to heap buffer when necessary 2018-11-16 10:19:48 -08:00
Doug Gregor
cc2ee165a1 [ABI] Use generic environment to handle mangled generic keypath types.
Always use mangled type names to represent type metadata in keypath patterns.
For generic types, use the generic environment to pull substituted types
from the instantiation arguments.

Finishes the type metadata part of rdar://problem/38038799.
2018-11-16 10:13:07 -08:00
Doug Gregor
cdd2928fec [Runtime] Generalize SubstGenericParametersFromMetadata slightly.
Only use the metadata and context information during initial setup, not
later on. NFC just yet.
2018-11-16 10:13:06 -08:00
Doug Gregor
f759296cc8 [Keypaths] Encode generic environment in the key-path pattern.
Extend the key-path pattern with a representation of the generic environment
of the key-path, which includes the generic parameters and generic
requirements of the environment.
2018-11-16 10:13:06 -08:00
Saleem Abdulrasool
6072d9f5df runtime: adjust LLVMSupport for Windows
Windows does not support weak linking.  Use an undocumented linker
feature to provide a default implementation for report_bad_alloc_error
in the case that we are not linking against LLVMSupport.
2018-11-16 08:42:10 -08:00
Mike Ash
68094fac75 Merge pull request #20608 from mikeash/fix-bundleForClass-nil
[Runtime] Accept Nil in the patched bundleForClass:.
2018-11-16 10:43:54 -05:00
John McCall
e169d32a4e Merge pull request #20624 from rjmccall/type-reference-to-protocols
Allow TypeReference to refer to protocol descriptors
2018-11-16 01:34:06 -05:00
Mark Lacey
d7cf830842 [ConstraintSystem] Add Array as a designated type for + and +=.
Also add overloads for these operators to an extension of Array.

This allows us to typecheck array concatenation quickly with
designated type support enabled and the remaining type checker hacks
disabled.
2018-11-15 21:42:33 -08:00
John McCall
ff6d031482 Allow TypeReference to refer to protocol descriptors.
We should also allow references via manglings just to cover the
general case if we need it, but this is useful on its own so that
we can emit a reference to any natively-declared Swift type.
2018-11-16 00:39:10 -05:00
Ben Cohen
f86fc100a5 Ditch the underscore 2018-11-15 20:55:10 -08:00
Ben Cohen
7df1587c27 Restore LazyCollection, but deprecated 2018-11-15 20:54:13 -08:00
Ben Cohen
1673c12d78 [stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)
* Replace "sanityCheck" with "internalInvariant"
2018-11-15 20:50:22 -08:00
swift-ci
f093925036 Merge pull request #20452 from Catfish-Man/stringtrampolines 2018-11-15 17:55:34 -08:00
swift-ci
126f9d7773 Merge pull request #20610 from DougGregor/abi-symbolic-accessor-ref-2-byte 2018-11-15 17:30:19 -08:00
swift-ci
f76d920709 Merge pull request #20612 from DougGregor/runtime-demangle-to-metadata-overriode 2018-11-15 17:16:29 -08:00
David Smith
8bb6b78e36 Use super trampolines to let us override several more NSString methods (-UTF8String, -cStringUsingEncoding:, and -getCString:maxLength:encoding:) for performance 2018-11-15 17:10:51 -08:00
Doug Gregor
986b8f3f9f [Runtime] Make swift_getTypeByMangled(Name|Node) overridable.
Rename the funnel points for demangling strings/nodes to metadata to
swift_getTypeByMangled(Name|Node) and make them overridable. This will let
us back-deploy mangling improvements and bug fixes.
2018-11-15 16:43:38 -08:00
Doug Gregor
723b56e64f [Standard library] Simplify _getTypeByMangledName.
Simplify the signature of the internal _getTypeByMangledName() used by the
standard library to what we actually (currently) use. Drop it as a
compatibility override, because it’s not a useful place to introduce
customization.
2018-11-15 16:10:11 -08:00
Doug Gregor
cd6d6be64d [Runtime] Consolidate runtime functions used for demangle-to-metadata.
Clean up the interfaces used to go from a mangled name or demangle tree to
metadata. Parameterize these interfaces for generic parameter substitutions
(already in use) and dependent conformance substitutions (speculative).
2018-11-15 15:57:44 -08:00