Commit Graph

4650 Commits

Author SHA1 Message Date
Ling Wang
bb7119f4ae Add O(1) contains() implementation for Range with Comparable Element 2016-01-01 19:43:01 -06:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Joe Groff
d0be84e1f3 Runtime: Refactor conformance cache initialization to include installation of the dyld callbacks.
This more cleanly groups together the initialization steps needed to warm up the conformance cache, so redundant work doesn't need to be done by other interested parties (such as the type-by-name lookup @lhoward's working on).
2015-12-31 17:11:17 -08:00
Dave Abrahams
e210532690 Merge pull request #825 from kballard/collectiontype-lazy-first
[Stdlib] Optimize CollectionType.first
2015-12-31 16:41:05 -08:00
Joe Groff
15c9d2b130 Runtime: Remove unused once_flag. 2015-12-31 16:36:51 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Kevin Ballard
dee1c7a05c [Stdlib] Add notes to lazy collection doc comments about complexity
Many lazy collections don't offer O(1) performance for `startIndex`,
`first`, or any method that depends on `startIndex`.
`LazyFilterCollection` already had a note to this effect (which I
tweaked a bit), but `FlattenCollection` didn't.

Related to SR-425.
2015-12-31 13:35:52 -08:00
Kevin Ballard
6ae85cea26 [Stdlib] Optimize CollectionType.first
For lazy collections, `isEmpty` and `startIndex` may be O(N) operations.
The old implementation ended up being potentially O(2N) instead of O(1).
In particular, accessing `col.lazy.filter(pred).first` would evaluate
the predicate on elements twice, once to determine the result of
`isEmpty` and once to determine `startIndex`.
2015-12-31 13:30:11 -08:00
Joe Groff
8f55d99173 stdlib: Reduce code size of tuple comparators.
We can define the operations for N+1-tuples in terms of the ones for N-tuples, which reduces an x86-64 stdlib by about 4KB:

-rwxr-xr-x  1 jgroff  staff  5172856 Dec 30 10:54 lib/swift/macosx/libswiftCore.before.dylib
-rwxr-xr-x  1 jgroff  staff  5168752 Dec 30 11:59 lib/swift/macosx/libswiftCore.after.dylib

The optimizer should still be able to inline all the calls together in release builds.
2015-12-30 13:42:33 -08:00
Dmitri Gribenko
f9c2cd13f9 Merge pull request #804 from raylillywhite/patch-1
[stdlib] Add documentation for `===`
2015-12-30 09:23:25 +02:00
John McCall
8f30faa4c1 Include access functions for the metadata and witness tables
of associated types in protocol witness tables.

We use the global access functions when the result isn't
dependent, and a simple accessor when the result can be cheaply
recovered from the conforming metadata.  Otherwise, we add a
cache slot to a private section of the witness table, forcing
an instantiation per conformance.  Like generic type metadata,
concrete instantiations of generic conformances are memoized.

There's a fair amount of code in this patch that can't be
dynamically tested at the moment because of the widespread
reliance on recursive expansion of archetypes / dependent
types.  That's something we're now theoretically in a position
to change, and as we do so, we'll test more of this code.

This speculatively re-applies 7576a91009,
i.e. reverts commit 11ab3d537f.
We have not been able to duplicate the build failure in
independent testing; it might have been spurious or unrelated.
2015-12-29 12:14:40 -08:00
Ray Lillywhite
4f90ba129e [stdlib] Add documentation for === 2015-12-29 10:45:46 -08:00
Michael Gottesman
14a3ab61cb Use dynamic runtime instrumentation for dtrace instead of static instrumentation.
When I originally added this I did not understand how dtrace worked well enough.
Turns out we do not need any of this runtime instrumentation and we can just
dynamically instrument the calls.

This commit rips out the all of the static calls and replaces the old
runtime_statistics dtrace file with a new one that does the dynamic
instrumentation for you. To do this one does the following:

sudo dtrace -s ./swift/utils/runtime_statistics.d -c "$CMD"

The statistics are currently focused around dynamic retain/release counts.
2015-12-28 18:17:12 -06:00
practicalswift
d89b4d45e1 Fix typos in code (non-comment typos). 2015-12-27 13:05:01 +01:00
Dmitri Gribenko
acab96b977 Merge pull request #770 from SemperIdem/stdlib-sdk-simplify
[stdlib]Replace NSMutableSet with Set
2015-12-26 13:38:40 +01:00
practicalswift
ce760cff66 Fix typos. 2015-12-26 12:43:52 +01:00
Chris Lattner
c26f97fa78 Merge pull request #772 from practicalswift/xmas-typos
Fix typos 🎁
2015-12-25 21:35:15 -08:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
Patrick Pijnappel
f181a6eca3 [stdlib] Remove return comments 2015-12-26 11:18:22 +11:00
Patrick Pijnappel
4c894b97a0 [stdlib] Fix comment
Amendment to my own commit.
2015-12-26 11:13:54 +11:00
Chris Lattner
12e670a5b7 Merge pull request #464 from nielsandriesse/patch-6
Make local variable name more expressive
2015-12-25 16:07:10 -08:00
Dmitri Gribenko
a954ebeb3e Merge pull request #713 from dcci/stdlib
[stdlib] Initial FreeBSD port.
2015-12-25 09:28:02 -08:00
Dmitri Gribenko
11ab3d537f Revert "Include access functions for the metadata and witness tables"
This reverts commit 7576a91009.
It broke the testsuite for swift-corelibs-foundation.
2015-12-25 19:17:50 +02:00
semper_idem
6aa415f8a7 [stdlib] indentation fix
[stdlib] indentation fix
2015-12-25 17:19:49 +08:00
semper_idem
c8dd8ab73f [stdlib]Replace NSMutableSet with Set
1. I think replace the NSMutableSet with Set<UIView>(and Set<NSView>)
could make the operations more Swift-like.

These code works fine in my Playground, and I also pass the test. But
I’m not quite sure it’s ok to use Set here rather than NSSet.

2. I also simplify the read-only computed property in “UIKit.swift”
2015-12-25 17:06:48 +08:00
John McCall
7576a91009 Include access functions for the metadata and witness tables
of associated types in protocol witness tables.

We use the global access functions when the result isn't
dependent, and a simple accessor when the result can be cheaply
recovered from the conforming metadata.  Otherwise, we add a
cache slot to a private section of the witness table, forcing
an instantiation per conformance.  Like generic type metadata,
concrete instantiations of generic conformances are memoized.

There's a fair amount of code in this patch that can't be
dynamically tested at the moment because of the widespread
reliance on recursive expansion of archetypes / dependent
types.  That's something we're now theoretically in a position
to change, and as we do so, we'll test more of this code.

This reverts commit 6528ec2887, i.e.
it reapplies b1e3120a28, with a fix
to unbreak release builds.
2015-12-24 20:21:17 -08:00
Dmitri Gribenko
480c5c307d Merge pull request #769 from PatrickPijnappel/patch-4
[stdlib] Fix punctuation in doc comment
2015-12-24 15:30:12 -08:00
Dmitri Gribenko
7fa7d186a9 Merge pull request #767 from frootloops/rename-params
Availability: refactoring and tests
2015-12-24 14:47:56 -08:00
Patrick Pijnappel
1a88207fe4 [stdlib] Fix punctuation in doc comment 2015-12-25 09:36:09 +11:00
Dmitri Gribenko
0b0043ddea Merge pull request #765 from SemperIdem/master
[stdlib]Remove the get keyword of read-only computed property
2015-12-24 13:42:55 -08:00
Arsen Gasparyan
d202c2c92b Availability: refactoring and tests 2015-12-25 00:22:18 +03:00
Dmitri Gribenko
ab581fe9c5 Merge pull request #762 from modocache/pep8-compliant-python-headers
[python] Use PEP-0008 compliant code headers
2015-12-24 13:14:17 -08:00
Joe Groff
2201c99a32 IRGen/Runtime: Open-code respondsToSelector: checks for AnyObject lookup.
Emit the respondsToSelector: msgSend inline instead of relying on a runtime call.
2015-12-24 09:00:43 -08:00
Brian Gesiak
a45a4260d8 [python] Use PEP-0008 compliant code headers
Running the Python style guide checker
[`pep8`](https://pypi.python.org/pypi/pep8) on the Python code headers
in this repository results in the following error being emitted:

    $ pep8 utils/build-script
    utils/build-script:1:1: E265 block comment should start with '# '
    utils/build-script:3:1: E266 too many leading '#' for block comment
    utils/build-script:5:1: E266 too many leading '#' for block comment
    utils/build-script:6:1: E266 too many leading '#' for block comment
    utils/build-script:8:1: E266 too many leading '#' for block comment
    utils/build-script:9:1: E266 too many leading '#' for block comment
    utils/build-script:11:1: E265 block comment should start with '# '
    utils/build-script:11:80: E501 line too long (80 > 79 characters)

The problem is that the code header used in most Python files in the
repository:

1. Do not place a space in between `#` and the rest of the comment.
2. Contains some lines that just barely exceed the recommend length
   limit.

In addition, not all code headers in the repository follow the same
template.

This commit moves all Python code headers to the following template:

    # subfolder/file_name.py - Very brief description -*- python -*--
    #
    # This source file is part of the Swift.org open source project
    #
    # Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
    # Licensed under Apache License v2.0 with Runtime Library Exception
    #
    # See http://swift.org/LICENSE.txt for license information
    # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
    #
    # -----------------------------------------------------------------------------
    #
    # This file contains stuff that I am describing here in the header and will
    # be sure to keep up to date.
    #
    # ----------------------------------------------------------------------------
2015-12-24 11:35:53 -05:00
semper_idem
c5c63519e5 [stdlib]Remove the get keyword of read-only computed property
Simplify the read-only computed property by removing the
non-@_transparent “get” keyword
2015-12-24 20:59:34 +08:00
Dmitri Gribenko
64cd87d40c Merge pull request #763 from frootloops/rename-params
Rename params
2015-12-24 02:28:18 -08:00
Dmitri Gribenko
9b15d03b73 StdlibUnittest: don't pass the name of the executable on the command line
Also, add a test for the command line of the child process.
2015-12-24 02:27:57 -08:00
Slava Pestov
ed8ca25fb7 Runtime: Clean up logic for setting Objective-C name of generic classes
We're not currently doing it, but we will soon be able to use
swift_initializeSuperclass() for class layouts which are not
dependent on generic parameters. In this case, we still need
to set the Objective-C class name.

On the other hand, if we're doing resilient layout for a
non-generic class, we don't need to set the Objective-C class
name.

NFC since this isn't hooked up completely yet.
2015-12-24 02:11:15 -08:00
Arsen Gasparyan
862a117864 Rename params 2015-12-24 12:58:45 +03:00
Arsen Gasparyan
9203f36630 Refactoring 2015-12-24 12:18:59 +03:00
Arsen Gasparyan
31750a1690 Pass env variable through StdlibUnittest 2015-12-24 11:55:01 +03:00
Slava Pestov
27e38fa4ee stdlib: Remove non-ASCII characters from Tuple.swift.gyb
SourceKit tests were checking that the generated interface
only contains ASCII characters.
2015-12-23 20:17:04 -08:00
Dave Abrahams
3576996543 Merge pull request #408 from kballard/tuple-comparison-ops
Implement tuple comparison operators
2015-12-23 18:28:29 -08:00
Kevin Ballard
b61c7a5004 [Stdlib] Implement comparison operators for tuples
Implement == and != for tuples up to arity 6 where each component type
is Equatable.

Implement <, <=, >, and >= for tuples up to arity 6 where each component
type is Comparable.
2015-12-23 18:25:31 -08:00
Dmitri Gribenko
78137e2c12 Merge pull request #755 from frootloops/bool
Simplifying the Bool creation with NSNumber
2015-12-23 17:48:01 -08:00
Joe Groff
9af439b87e Runtime: Rename reportMissingMethod to deletedMethodError.
The runtime entry doesn't just report the error, unlike the other report* functions, it also does the crashing.

Reapplying independent of unrelated reverted patches.
2015-12-23 16:01:21 -08:00
Sean Callanan
6528ec2887 Revert "Include access functions for the metadata and witness tables"
This reverts commit b1e3120a28.

Reverting because this patch uses WitnessTableBuilder::PI in NDEBUG code.
That field only exists when NDEBUG is not defined, but now NextCacheIndex, a
field that exists regardless, is being updated based on information from PI.

This problem means that Release builds do not work.
2015-12-23 15:42:10 -08:00
Sean Callanan
09f48ee2b4 Revert "Runtime: Rename reportMissingMethod to deletedMethodError."
This reverts commit bdffe703b0.
Required to revert b1e3120a28.
2015-12-23 15:41:06 -08:00
Joe Groff
d366089df7 Runtime: Change getInstancePositiveExtents methods to return both extents.
A bit of future-proofing, since we plan to be able to grow class instances in both directions relative to their object header.
2015-12-23 15:39:53 -08:00
Joe Groff
583f5bdb6f Runtime: Rename class property lookup functions with consistent naming scheme.
Getting a superclass, instance extents, and whether a class is native-refcounted are all useful type API. De-underscore these functions and give them a consistent `swift[_objc]_class*` naming scheme.
2015-12-23 15:04:27 -08:00