Commit Graph

4650 Commits

Author SHA1 Message Date
Nate Cook
5849e167dd [stdlib] Fix a spate of typos.
Fix bulleted list formatting in Unsafe(Mutable)Pointer.
Fix incorrect type mentions on CustomPlaygroundQuickLookable.
Use 'An' instead of 'A' before '8-bit (un)signed integer.
Fix error in Range sample code.
Fix typo in Dictionary.updateValue(_:forKey:) doc comment.
Remove extra documentation in Mirror.AncestorRepresentation.
Fix improper case for operators and methods in IntegerArithmeticType.
2016-02-11 11:39:39 -06:00
Peter Friese
888d0f3fa6 [gardening] Fix typo: "nul-terminated" → "null-terminated" 2016-02-11 11:03:38 +00:00
Peter Friese
723484ef24 [gardening] Fix typo: "nul-terminated" → "null-terminated" 2016-02-11 10:11:02 +00:00
Max Moiseev
55fde4c923 making tests pass 2016-02-10 16:08:40 -08:00
Dmitri Gribenko
410a34e078 Merge pull request #1255 from modocache/fix-minor-typos
[stdlib] Fix extra "it" typo
2016-02-10 10:44:36 -08:00
Brian Gesiak
a69507d493 [stdlib] Fix extra "it" typo 2016-02-10 13:40:05 -05:00
Jordan Rose
a4a4a80ac4 [CMake] Don't pass -sil-serialize-all under SWIFT_STDLIB_ENABLE_RESILIENCE.
Thanks, Slava!
2016-02-10 10:29:01 -08:00
Nadav Rotem
422764545c [Runtime] Improve the metadata hashing function.
The inputs to the hash function is pointers that have a predictable patten. The
hashes that we were generating and using for the metadata caches were not very
good, and as a result we generated very deep search trees. A small change that
improved the utilization of the 'length' field and another bit-rotate round
improved the quality of the hash function.

I am going to attach to the github commit two pictures. The first picture is the
binary with the old hash. The first tree is very deep and sparse. The second
picture is with the new hash function and the tree is very wide and uniform.  I
used the benchmark 'TypeFlood' in debug mode to generate huge amounts of
metadata.
2016-02-10 00:07:42 -08:00
Joe Groff
32872cb74a IRGen/Runtime: Relative-reference the nominal type descriptor and parent type from metadata.
Save a couple relocations per concrete value type, leaving only the value witness table as an absolute symbol.
2016-02-09 15:17:03 -08:00
Chris Lattner
b5dfb1e613 Merge pull request #1247 from practicalswift/typo-fixes-20160209
[gardening] Fix recently introduced typos: "overrideable" → "overridable", "collission(s)" → "collision(s)"
2016-02-09 14:09:02 -08:00
Chris Lattner
5bad3ba49a Warn about implicit tuple splat in a parameter list. 2016-02-09 14:01:50 -08:00
practicalswift
71ae776039 [gardening] Fix recently introduced typo: "collission" → "collision" 2016-02-09 22:47:08 +01:00
Nadav Rotem
93d4e93655 Fix a bug in the protocol conformance code.
Before this commit we only checked the conformance of the first protocol that
matched the conformance entry, which is incorrect. We need to check all of the
entries that match the key before deciding that a type does not conform to a
protocol.

This commit fixes repl_conformance_lookup.swift
2016-02-08 22:57:51 -08:00
Nadav Rotem
cdbf839f6c [Runtime Mem] Convert the metadata map from open to closed hash map.
This change cuts the number of mallocs() in the metadata caches in half.

The current metadata cache data structure uses a linked list for each entry in
the tree to handle collissions.  This means that we need at least two memory
allocations for each entry, one for the tree node and one for the linked list
node.

This commit changes the map used by the metadata caches from an open hash map
(that embeds a linked list at each entry) into an closed map that uses a
different hash value for each entry. With this change we no longer accept
collissions and it is now the responsibility of the user to prevent collissions.
The new get/trySet API makes this responsibility explicit. The new design also
goes well with the current design where hashing is done externally and the fact
that we don't save the full key, just the hash and the value to save memory.

This change reduces the number of allocated objects per entry in half. Instead
of allocating two 32-byte objects (one for the tree node and one for the linked
list) we just allocate a single entry that contains the hash and the value.

Unfortunately, values that are made of two 64-bit pointers (like protocol
conformance entries) are now too big for the 32-byte tree entry and are rounded
up to 48 bytes. In practice this is not a big deal because malloc has 48-byte pool
entries.
2016-02-08 22:57:50 -08:00
Xin Tong
d4a95eead5 Turn a function internal to preemptively avoid conflict 2016-02-08 13:35:24 -08:00
Dmitri Gribenko
76fbef8b45 Merge pull request #1233 from practicalswift/fix-header
[gardening] Fix file header formatting for recently added file.
2016-02-08 12:55:42 -08:00
Xin Tong
be9fec315a Add a caller to _Prespecialize._specializeArrays() and _Prespecialize._specializeRanges() to keep them alive
We now run a dead function elim before running any generic specializer. generic specializer generates some
prespecialized functions and explicitly keep them alive (i.e. make them not removeable by dead function elim)

However, the recently added dead function elimination gets rid of the calls which the prespecialization uses
to generate the prespecialization.

Create a caller with special name (avoid conflict) to make sure the specialization does happen.

Hopefully, eventually we will be able to move to a cleaner approach to do prespecialization.

rdar://24543234
2016-02-08 12:53:19 -08:00
practicalswift
6e23e99006 [gardening] Fix file header formatting for recently added file. 2016-02-08 20:04:00 +01:00
Joe Groff
f7291b21ec Runtime: Build with -fvisibility=hidden.
...and explicitly mark symbols we export, either for use by executables or for runtime-stdlib interaction. Until the stdlib supports resilience we have to allow programs to link to these SPI symbols.
2016-02-08 08:06:02 -08:00
David Farler
95b4abc9fb Pin the reflection data sections on Linux
These had similar problems to the protocol conformance sections during
Linux bringup. There are relative offsets from the main reflection
section to the two string sections, so their position relative to each
other must remain fixed.
2016-02-07 21:40:09 -08:00
Dmitri Gribenko
ab12335041 Merge pull request #1211 from natecook1000/natecook-utf16-randomaccess
Add 'ExtraStringAPIs.swift' to make list.
2016-02-07 20:04:48 -08:00
Michael Gottesman
c684568042 [upstream-fix] llvm::RoundUpToAlignment was renamed to llvm::alignTo. 2016-02-06 11:22:27 -08:00
Kevin Ballard
ed03745c75 Add @noescape to SequenceType.flatMap 2016-02-05 12:35:00 -08:00
Doug Gregor
42bb2528dd [Overload resolution] Prefer functions with fewer defaulted/variadic arguments.
When comparing two functions for overload resolution, break apart the
parameter lists to compare individual parameters rather than comparing
the tuples. This allows us to prefer functions with fewer arguments to
ones with more, defaulted or variadic arguments. That preference was
already encoded in the constraint optimizer, which led to some strange
behavior where the preference was expressed for function calls but not
for calls to initializers. Fixes rdar://problem/24128153.

The standard library change tweaks the anachronistic, unavailable
"print" variants somewhat. The only behavior change here is a slight
regression for cases like:

  print(a: 1, b: 2)

where we used to produce a diagnostic:

  Please wrap your tuple argument in parentheses: 'print((...))'

but we now get:

  argument labels '(a:, b:)' do not match any available overloads

However, this regression will happen at some point *anyway*, if
SE-0029 (or anything else that removes the implicit tuple splat
operation) goes through.
2016-02-05 11:41:01 -08:00
Nate Cook
428bbbe603 Add 'ExtraStringAPIs.swift' to make list. 2016-02-05 11:03:44 -06:00
Slava Pestov
3624b1fc6b Runtime: Support for resiliently adding protocol requirements with default implementations
This is the first patch in a series that will allow new protocol
requirements to be added resiliently, with the runtime filling in
default implementations in witness tables.

First, this adds a new flag to the protocol descriptor indicating
that the protocol is resilient. In this case, there are two
additional fields, MinimumWitnessTableSizeInWords and
DefaultWitnessTableSizeInWords, followed by tail-allocated
default witnesses.

The swift_getGenericWitnessTable() entry point now fills in the
default witnesses from the protocol if the given witness table
template is smaller than the expected witness table size.

This also changes the layout of instantiated witness tables to move
the address point to the end of private data. Previously the private
data came after the requirements, but this meant that adding new
requirements would require sliding the private data at runtime and
accessing it indirectly. It is much simpler to access it from
negative offsets instead.

I updated IRGen to emit the new metadata, but currently all protocols
are flagged as not resilient, and default witnesses are not emitted;
this will come in a subsequent patch once some more plumbing is
in place.

To avoid generating GOT entries for references to protocols defined
in the current module, I had to add some hacks to the existing hack
for this. I'll hopefully clean this up in a principled manner later.
2016-02-04 17:34:55 -08:00
Max Moiseev
39fdbca8d0 making Swift build succesfully after the merge 2016-02-04 16:48:14 -08:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Chris Lattner
0619e57a61 Switch the stdlib to use #file instead of __FILE__, and deprecate the __FILE__ identifiers.
This also updates the tests that would otherwise fail.
2016-02-04 15:08:31 -08:00
Dmitri Gribenko
b2ca7712f6 Merge pull request #929 from kballard/remove-reundant-locking-from-print
[Stdlib] Remove all redundant stdout locking when printing
2016-02-04 09:15:24 -08:00
Xin Tong
19869d4fb5 Minor code refactoring and changing an enum of 2 fields to an Optional 2016-02-03 15:01:46 -08:00
Xin Tong
d2a1cb90f5 Fix a swift argument initialization bug - swift argument should be initialized
after argc and argv are initialized.

The problem before is that the argument function is a global_init which can be moved
by the GlobalOpt optimization and thus broke the data dependence on argc and argv.

rdar://24250684
2016-02-03 14:02:31 -08:00
Jordan Rose
b0f54ff202 Merge pull request #1174 from harlanhaskins/fatalError-stack-trace-leak
[runtime] Fix leak in backtrace demangling
2016-02-02 15:47:17 -08:00
Harlan Haskins
7bd071ca6c [runtime] Fix leak in backtrace demangling 2016-02-02 15:44:34 -08:00
Michael Gottesman
cc1c6f7077 [runtime] Mark some readonly unicode functions as being pure.
These come in two categories of functions:

1. Comparison.
  - swift_stdlib_unicode_compare_utf16_utf16
  - swift_stdlib_unicode_compare_utf8_utf16
  - swift_stdlib_unicode_compare_utf8_utf8

2. Hashing.
  - swift_stdlib_unicode_hash
  - swift_stdlib_unicode_hash_ascii
2016-02-02 15:39:15 -08:00
Michael Gottesman
25ee4b9e83 [runtime] Mark swift_stdlib_malloc_size as being readnone.
This entry point /does/ read memory but this is not memory that is
visible to the compiler.
2016-02-02 15:39:15 -08:00
Michael Gottesman
27b5f930d8 [gardening] Fix two small indentation issues. NFC. 2016-02-02 15:39:14 -08:00
Arnold Schwaighofer
ebfb504415 Don't use generators in array equality comparisons
This is easier to read and faster if we don't specialize away the generator
code.
2016-02-02 14:58:23 -08:00
Kevin Ballard
ac1996000e [Stdlib] Remove all redundant stdout locking when printing
* Switch to calling `putchar_unlocked()` instead of `putchar()` for
  actual printing. We're already locking stdout with `flockfile()`, so
  there's no need for the redundant lock that `putchar()` uses.
* Add an explicit lock to the output stream in `dump()`. This means the
  entire dump is printed with the lock held, which will prevent the
  output of `dump()` from mixing with prints on other threads.
* Use `_debugPrint_unlocked()` instead of `debugPrint()` in
  `_adHocPrint()`. The output stream is already locked while this
  function is executing. Rename the function to `_adHocPrint_unlocked()`
  to make this explicit.
* Use `targetStream.write()` and `_print_unlocked()` instead of
  `print()` in `_dumpObject()`. This removes the redundant locking, and
  also eliminates the creation of intermediate strings. Rename the
  function to `_dumpObject_unlocked()` to make this explicit.
* Use `targetStream.write()`, `_print_unlocked()`, and
  `_debugPrint_unlocked()` in `_dumpSuperclass()`. This removes the
  redundant locking, and also eliminates the creation of intermediate
  strings. Rename the function to `_dumpSuperclass_unlocked()` to make
  this explicit.
* Use `_debugPrint_unlocked()` instead of `debugPrint()` in
  `String.init(reflecting:)`. This shouldn't really make much of a
  difference but it matches the usage of `_print_unlocked()` in
  `String.init(_:)`.

The net result is that all printing is still covered under locks like
before, but stdout is never recursively locked. This should result in
slightly faster printing. In addition, `dump()` is now covered under a
single lock so it can't mix its output with prints from other threads.
2016-02-02 13:40:55 -08:00
Dmitri Gribenko
34b00e25b1 stdlib: fix coding guideline violations 2016-01-31 23:42:05 -08:00
Dmitri Gribenko
81ce88847c stdlib: remove dead code 2016-01-31 21:57:06 -08:00
David Farler
b67c5fea77 Build fix: Stray var param in AssetsLibrary overlay 2016-01-30 14:35:20 -08:00
David Farler
8a5ed405bf Make var parameters an error for Swift 3
This finishes up revisions to SE-0003 - only var function parameters
are disallowed for Swift 3.
2016-01-30 12:39:17 -08:00
David Farler
d45aa36e85 Clean up some things that sneaked into var reverts
- Remove an overload that came back in after rebase
- Minor formatting issues
2016-01-30 10:03:53 -08:00
Dmitri Gribenko
dc11ccded4 Merge pull request #1122 from harlanhaskins/fatalError-stack-trace
Add backtrace reporting on fatalError
2016-01-30 04:07:07 -08:00
Dmitri Gribenko
a385779e41 stdlib: define a custom mirror for DictionaryGenerator and SetGenerator
The default mirror tries to access implementation details of the
generator, accessing the 'description' property of the storage, which is
an NSDictionary subclass.  The default implementation of -[NSDictionary
description] tries to print the dictionary contents.  But if the
Swift.Dictionary can't be bridged to NSDictionary, that causes a runtime
trap.

rdar://problem/24238609
2016-01-30 02:09:45 -08:00
Dmitri Gribenko
27f422fe39 StdlibUnittest: move logging wrappers for collections to StdlibCollectionUnittest 2016-01-29 19:38:37 -07:00
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Harlan Haskins
b55d8d9c3c [Runtime] Add backtrace reporting on fatalError in debug builds 2016-01-29 13:42:06 -08:00
Dmitri Gribenko
cf7e3f6df4 stdlib: Range.contains: fix coding style and make the function public
... so that it actually has a chance to get referenced in the witness
table.

But since the function is in a constrained extension, it can't be.
2016-01-29 13:24:59 -08:00