Commit Graph

2952 Commits

Author SHA1 Message Date
Dmitri Gribenko
6985b958fd Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-04 11:42:17 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Slava Pestov
9ce9784180 Runtime: Tweak Mirrors for resilience
Make _MagicMirrorData @_fixed_layout, but not the concrete mirror
implementations.

To make the calling convention work in resilient builds, make the
runtime entry points into top-level functions that take a
_MagicMirrorData, instead of adding @_silgen_name attributes on
methods.

This involves changing the convention on the 'owner' parameter
from +0 to +1.

Also, there was a memory leak in the old enum code that I noticed
by inspection. We would copy the enum value into a box, strip
the enum tag bits, take the box contents but never free the box
itself.

The fix isn't very satisfying either -- we have to modify the
source enum in-place to strip tag bits, then we copy it into a
box having the right payload type, and add the tag bits back.
At least this way, we can free the box after.
2016-04-04 00:05:01 -07:00
Slava Pestov
4b304f7d24 stdlib: Missed a couple of @_versioned for resilience
Discovered this with some uncommitted patches that add new asserts
while fixing test failures when stdlib is built with -enable-resilience.
2016-04-04 00:04:19 -07:00
Dmitri Gribenko
260611e670 Merge pull request #2046 from danra/array_body_comment
Fix outdated comment (NFC)
2016-04-03 18:15:15 -07:00
Dmitri Gribenko
d6d6f4f880 Merge pull request #1922 from rintaro/float-tostring
[stdlib] Return constant for infinity and NaN to string conversion
2016-04-03 18:08:36 -07:00
Dan Raviv
47ad1d153f Fix outdated comment 2016-04-04 00:24:42 +02:00
Dmitri Gribenko
d26b257b34 stdlib: add a FIXME to the Slice implementation 2016-04-02 02:57:57 -07:00
Dmitri Gribenko
764b5bdd7a New indexing model: implement Slice*._failEarlyRangeCheck 2016-04-01 14:12:17 -07:00
Max Moiseev
171169b01f [stdlib][swift-3-indexing-model] fixing Arrays tests 2016-04-01 14:12:17 -07:00
Dmitri Gribenko
5b2527ebb1 stdlib: make _writeBackMutableSlice() callable from StdlibCollectionUnittest 2016-04-01 14:12:16 -07:00
Dmitri Gribenko
5a12349e9c Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-01 14:12:13 -07:00
Dmitri Gribenko
629a941130 Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-01 14:11:51 -07:00
Jordan Rose
6dd1f0a5f9 [stdlib] Apply @_fixed_layout to various stdlib and overlay types
This is a staging attribute that will eventually mean "fixed-contents"
for structs and "closed" for enums, as described in
docs/LibraryEvolution.rst.

This is pretty much the minimal set of types that must be fixed-layout,
because SILGen makes assumptions about their lowering.

If desired, some SILGen refactoring can allow some of these to be
resilient. For example, bridging value types could be made to work
with resilient types.
2016-04-01 13:07:18 -07:00
Slava Pestov
7b91cbd551 stdlib: Add @_versioned attributes needed for resilient build 2016-04-01 13:07:18 -07:00
Dmitri Gribenko
999aceb682 stdlib: correct fixits for 'func generator()'
rdar://problem/25492963
2016-04-01 10:48:48 -07:00
Erik Eckstein
b5d7411a4e stdlib: remove unnecessary empty return value. NFC 2016-03-31 19:25:23 -07:00
eeckstein
045ee83705 Merge pull request #1992 from eeckstein/onfastpath
introduce the onFastPath builtin
2016-03-31 17:41:26 -07:00
Arnold Schwaighofer
308ce091b7 Actually return the result from the _withUnsafeGuaranteed closure call 2016-03-31 16:43:46 -07:00
Erik Eckstein
7094653409 stdlib: use _onFastPath instead of @inline(__always) in ManagedBuffer.
This recovers most of the performance regression introduced with the recent inliner changes.
2016-03-31 12:53:44 -07:00
Erik Eckstein
a47a62d644 A new onFastPath built-in.
It is a hint to the optimizer that the code, where this builtin is called, is on the fast path.
Specifically, the inliner takes it into account and increases the assumed benefit for code where the builtin is located.

Compared to the fastPath/slowPath builtins, this builtin can be placed into plain linear code and doesn't need to be used in conditions.
Compared to the @inline(__always) attribute, this builtin has also an effect on the caller function. Let's assume
	foo() calls bar() contains onFastPath
and both foo and bar are small functions. Then if bar gets inlined into foo, the builtin also increases the chances that foo gets inlined.
This would not be the case if @inline(__always) is used just for bar.
2016-03-31 12:53:44 -07:00
Dmitri Gribenko
495cade645 Drop the libbsd dependency
We were only using arc4random, and now we use C++ <random> instead.  See
also PR #1939.
2016-03-30 17:37:21 -06:00
Nadav Rotem
151d76f397 Merge pull request #1943 from nadavrot/remove_transp
[CodeSize] remove transparent attribute from bridgeing function.
2016-03-30 09:09:46 -07:00
swift-ci
2833e66ece Merge pull request #1941 from gonzoua/freebsd 2016-03-29 22:19:45 -07:00
Nadav Rotem
dcd98a783c [CodeSize] remove transparent attribute from bridgeing function.
It increases code size and it is slow enough that inlining won't be meaningful
for performance.
2016-03-29 17:48:59 -07:00
Dmitri Gribenko
6942857e30 New indexing model: re-calculate start and end index after mutating a range replaceable collection slice 2016-03-29 17:21:11 -07:00
Oleksandr Tymoshenko
33eb95490b Link with libexecinfo on FreeBSD
backtrace_symbols is defined in libexecinfo on FreeBSD
2016-03-29 16:46:39 -07:00
Dmitri Gribenko
26961ab11e New indexing model: extract a helper function into gyb_stdlib_support.py 2016-03-29 16:46:24 -07:00
Dmitri Gribenko
df73cd2f5d New indexing model: reorder preconditions to make more sense 2016-03-29 16:34:55 -07:00
Erik Eckstein
c0964a492d Re-instate "stdlib: Add some inlining attributes to help the optimizer getting the right inlining decisions."
This re-instates commit 8b0e36779e
2016-03-29 16:33:47 -07:00
swift-ci
12593eff13 Merge pull request #1924 from natecook1000/nc-array-rrc 2016-03-29 13:42:34 -07:00
Nate Cook
bec13fd02f Make Array's conformance to RangeReplaceableCollection visible 2016-03-29 12:26:02 -05:00
Rintaro Ishizaki
4cddc522f2 [stdlib] Manually handle infinity and NaN to String conversion. 2016-03-30 02:03:11 +09:00
Dave Abrahams
8e4f85277b Merge remote-tracking branch 'refs/remotes/origin/master' into merge 2016-03-29 09:19:34 -07:00
Slava Pestov
bd8459c433 stdlib: Add some @inline(__always) annotations to make optimizer tests pass when the library is built without -sil-serialize-all 2016-03-28 20:08:12 -07:00
Slava Pestov
be1aedb505 stdlib: add @_versioned to some internal types referenced from inlineable functions 2016-03-28 20:08:12 -07:00
Slava Pestov
4a34aa7895 Re-apply "stdlib: Add minimum set of @_versioned attributes to build without -sil-serialize-all"
This reverts commit 22864721ca.
2016-03-28 20:08:12 -07:00
Dave Abrahams
a5c3c63c3d [stdlib] Indexing model: nix RangeOfStrideable
Instead, use CountableRange which is constrained to have a Strideable
Bound whose Stride conforms to Integer.
2016-03-28 17:06:09 -07:00
practicalswift
c015b6eb47 Merge pull request #1906 from practicalswift/gardening-20160328b
[gardening] Remove unused code, fix PEP 8 regression, fix typos.
2016-03-28 23:16:28 +02:00
Dave Abrahams
25baede4bb [stdlib] indexing model: add formIndex 2016-03-28 13:47:40 -07:00
Dave Abrahams
a95cea9868 Merge branch 'swift-3-indexing-model' of github.com:apple/swift into swift-3-indexing-model 2016-03-28 13:35:30 -07:00
Dave Abrahams
da5c4036ac func index(n: IndexDistance, stepsFrom i: Index)
M-x findr-query-replace

\<func advance(\([^(),]*\|[^(),]+([^()]*)[^(),]*\)\(,[
]*\)by \([^(),]*\|[^(),]+([^()]*)[^(),]*\)

func index(\3\2stepsFrom \1
2016-03-28 13:23:04 -07:00
Dave Abrahams
81d3e8ca83 limit: => limitedBy:, pt 2
M-x findr-query-replace

\<limit: \([^(),]*\|[^(),]+([^()]*)[^(),]*\))\( *\(?:[^ -]\|-[^>]\)\)

limitedBy: \1)\2
2016-03-28 13:12:02 -07:00
Dave Abrahams
4d651f8fc0 limit: => limitedBy:, pt 1
M-x findr-query-replace

\(,[
]*\)limit: \([^(),]*\|[^(),]+([^()]*)[^(),]*\)) ->

\1limitedBy limit: \2) ->
2016-03-28 13:03:59 -07:00
Joe Groff
ddaaf7aa5d Merge pull request #1795 from compnerd/fp80-windows
stdlib: disable FP80 on Windows
2016-03-28 12:59:51 -07:00
practicalswift
9323761788 [gardening] Fix recently introduced typo: "unmanged" → "unmanaged" 2016-03-28 21:52:03 +02:00
Erik Eckstein
be8faad792 Revert my recent inliner commits.
There are some failures in the tests.
2016-03-28 11:11:25 -07:00
Erik Eckstein
8b0e36779e stdlib: Add some inlining attributes to help the optimizer getting the right inlining decisions.
This is more or less a workaround for some optimizations (mainly ARC opt) to avoid performance degradation with the upcoming inliner changes
In some situations it makes a big difference for ARC opt if a function is inlined or not, althought this shouldn't be the case.
2016-03-27 10:59:29 -07:00
Arnold Schwaighofer
d454c936f7 Add _withUnsafeGuaranteedRef to Unmanaged
This is an internal method that will go away in the future.

Get the value of the unmanaged referenced as a managed reference without
consuming an unbalanced retain of it and pass it to the closure. Asserts
that there is some other reference ('the owning reference') to the
unmanaged reference that guarantees the lifetime of the unmanaged reference
for the duration of the '_withUnsafeGuaranteedRef' call.

  var owningReference = Instance()
  ...
  withExtendedLifetime(owningReference) {
    let u = Unmanaged.passUnretained(owningReference)

    for i in 0 ..< 100 {

      // Assert that the reference in 'u' is kept alive by another storage
      // location or value that holds the same reference.
      u._withUnsafeGuaranteedRef {
        $0.doSomething()
      }

    }
  } // owningReference's lifetime (reference count > 0) is guaranteed
    // for this scope.

rdar://25129935
2016-03-27 06:47:16 -07:00
Nate Cook
502137e174 [stdlib][swift-3-indexing-model] Implement _writeBackMutableSlice 2016-03-26 19:26:50 -05:00