Commit Graph

21665 Commits

Author SHA1 Message Date
Jordan Rose
c9a83d782c [swift2objc] Add a Clang module as a kind of prefix for generated headers.
Every Swift module starts with an implicit "import swift", so why not use
that to hold all of the runtime info we need?

This only gets us copying the header (and its module map) into include/swift/.
It doesn't actually use it yet.

Swift SVN r13617
2014-02-07 01:54:54 +00:00
Chris Lattner
b149c746b3 convert the stdlib to use the new inout syntax.
Swift SVN r13561
2014-02-06 04:54:35 +00:00
Greg Parker
be878f2503 [build] Remove redundant dependency.
Swift SVN r13522
2014-02-05 23:23:08 +00:00
Dave Zarzycki
29af221df9 stdlib: we have sizeof() now. Drop *Int*.bitSize()
Swift SVN r13482
2014-02-05 07:11:46 +00:00
Jordan Rose
335ceb2f57 Re-enable the new Swift driver.
This re-applies r13380, reverted in r13406. I don't think this actually
caused any harm (r13400 was the primary culprit), but if it did I'd
like to actually see the buildbots or someone else's machine fail on it.

Swift SVN r13456
2014-02-05 00:09:00 +00:00
Dave Abrahams
01e9139944 Revert "Enable the new Swift driver!"
This reverts r13380, which broke the build

Swift SVN r13406
2014-02-04 06:13:58 +00:00
Jordan Rose
16b5a57838 Enable the new Swift driver!
This substitutes swift_driver in as the new "swift". Tests that currently
test "%swift" will invoke "swift -frontend", much like "clang -cc1".
Most command-line interaction will look the same, except that Swift can
now emit linked libraries (using -emit-library) and executables (using
-emit-executable, or by not passing a mode option at all).

If you are working with @transparent functions, note that they will not be
properly inlined across file boundaries unless you use
-force-single-frontend-invocation, which emulates the old swift binary.
There are Radars for this already: <rdar://problem/15366167&15693042>

The name 'swift_driver' is now a symlink for 'swift'. This will be removed
next week.

The old 'swift' is still available as 'swift_old', though it is not being
tested at all. This will be removed in two weeks.

Clean CMake builds will get this immediately.

Incremental CMake builds will not get the new driver unless you explicitly
enable the SWIFT_NEW_DRIVER option (-DSWIFT_NEW_DRIVER=ON on the command line).
This option will go away in a week.

Makefile builds will get this immediately because I didn't want to work out
how to maintain both modes.

Much credit to Connor for bringing up the entire driver and for doing much
of the work in ensuring that all the tests continue to pass.

Swift SVN r13380
2014-02-03 22:48:39 +00:00
Adrian Prantl
dc3c6e845a silence warning
Swift SVN r13365
2014-02-03 19:32:44 +00:00
Michael Gottesman
cc6783cc85 Control whether or not benchmarks are run via CMake/Make argument SWIFT_ENABLE_BENCHMARKS.
This will help to prevent errors like committing a patch that re-enables the
benchmarks for everyone.

Swift SVN r13343
2014-02-03 06:42:34 +00:00
Dave Zarzycki
7fada455b1 stdlib: add ++/-- operators to floating point
<rdar://problem/15866685> cannot increment floating point values

Swift SVN r13309
2014-02-01 23:17:27 +00:00
Dave Zarzycki
a9b2c22857 stdlib: Make shift operator asserts cheaper in debug builds
Swift SVN r13307
2014-02-01 22:00:58 +00:00
Jordan Rose
579798393a Replace "-sdk=", "-triple=", etc. with separated options in the build systems.
Part of the migration to the new driver.

Swift SVN r13264
2014-02-01 01:19:57 +00:00
Dave Zarzycki
d20a525ebd 15866696 Files in the stdlib should use the llvm header
Swift SVN r13258
2014-02-01 00:40:20 +00:00
Dave Zarzycki
5ca3df0940 15876164 shifting by negative/"too big" amounts should trap
Swift SVN r13251
2014-01-31 23:22:44 +00:00
Joe Groff
a0a2c1014a Runtime: Preserve the linked list of metadata cache entries.
This is easier for out-of-process clients like LLDB or DTrace to understand, and will let us mess with the runtime metadata cache data structure without forcing churn on the debugger team.

Swift SVN r13221
2014-01-31 17:33:10 +00:00
Joe Groff
418dee24a0 runtime: Use hashtables for metadata caches (again).
Using a linked list for metadata caches is pretty lame. Pull in llvm::DenseMap and hash_combine_range and use them to index instantiated metadata.

The previous attempt at this failed because tuple type metadata was laid out in a way that smashed the metadata cache key. Cache keys used to be laid out like this:

CacheEntry struct
-----------------
cache key
-----------------
variable-sized payload

And TupleTypeMetadata tried to tail-emplace its element array immediately after the main CacheEntry, forgetting the cache key was there. When we actually try to use that cache key to implement a hash table, bad things happen. Rearrange cache entries into the less error-prone layout:

cache key
-----------------
CacheEntry struct
-----------------
variable-sized payload

This also nicely avoids the need for a dynamic offset from the CacheEntry struct to its payload. A tail-allocated payload is likely to be more hot than the cache key, which is only needed at instantiation and lookup time.

Swift SVN r13205
2014-01-31 06:21:07 +00:00
Dave Zarzycki
0e833a326e 15936764 swift.sin is ambiguous with Darwin.sin
Swift SVN r13180
2014-01-30 23:17:12 +00:00
Greg Parker
95c2fc43f8 Clena up some 32/64 mismatches. Remove some dead posix stubs.
Swift SVN r13144
2014-01-30 09:34:26 +00:00
Greg Parker
e4c7b48d1c [build] Fix FixedPoint[32|64].swift in Makefile build, again.
Swift SVN r13121
2014-01-29 22:12:10 +00:00
Joe Groff
abdb2a7640 Add block shim for void(^)(BOOL).
Fixes <rdar://problem/15931537>.

Swift SVN r13119
2014-01-29 21:50:51 +00:00
Greg Parker
1a87098af0 Replace Word[32|64].swift with FixedPoint[32|64].swift in makefile build.
Swift SVN r13118
2014-01-29 21:13:53 +00:00
Greg Parker
b2846b546b Make Int a word-size type.
- Int and UInt are now struct types backed by Builtin.Word. Previously they
were typealiases for Int64; Int and Int64 are now distinct types.
- Mangled names 'i' and 'u' are now Int and UInt. Int64 is mangled longhand.
- Word is a typealias for Int. It is expected to go away in the future.
- Builtin.Word is unchanged.
- CLong and CUnsignedLong are typealiases for Int and UInt.
- FixedPoint.swift is now FixedPoint32.swift and FixedPoint64.swift. 
Reunifying these requires better builtins, especially for checked 
conversions (rdar://15472770).
- Updated many tests, mostly because Int is no longer spelled Int64 in sil.
- One check was removed from test decl/operator/operators.swift 
because it changed behavior when Int became a non-typealias 
type (rdar://15934688).



Swift SVN r13109
2014-01-29 12:21:19 +00:00
Doug Gregor
6b8f6a2a9a Use an ugly series of builtins to eliminate swift_makeUnsafeNil().
Swift SVN r13104
2014-01-29 08:17:15 +00:00
Doug Gregor
eaf3e5c68d Move nil/_Nil into the core library and add UnsafePointer<T> support.
Fixes <rdar://problem/15933510>.


Swift SVN r13094
2014-01-29 06:30:28 +00:00
Dave Abrahams
376cdefeed [stdlib] Segregate the String bridging API
Core and Foundation now communicate through StringBridge.swift

Swift SVN r13033
2014-01-28 02:05:42 +00:00
Dave Abrahams
6165b71316 [build] clobber freed objects by default in non-optimized builds
When SWIFT_OPTIMIZED is not set, add a little extra memory debugging,
which doesn't seem to slow anything down noticeably and can be disabled
as needed.

This change only affects the CMake build because that's the only place
where SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS is supported already.  We may
want to extend this to the Makefile build.

Swift SVN r13008
2014-01-27 22:09:18 +00:00
Joe Groff
1bfa0202d2 Revert "runtime: Use hashtables for metadata caches."
This reverts commit r12998. It breaks the "fast" buildbot.

Swift SVN r12999
2014-01-27 19:26:00 +00:00
Joe Groff
c93e44a5f3 runtime: Use hashtables for metadata caches.
Using a linked list for metadata caches is pretty lame. Pull in llvm::DenseMap and hash_combine_range and use them to index instantiated metadata.

Swift SVN r12998
2014-01-27 19:08:33 +00:00
Dave Abrahams
bd85cf7d94 [stdlib] Implement a sane assert/fatal error check system
The facility we had before was not very usable in core elements of the
standard library because it relied too much on those elements itself.
The result could be some spectacular infinite recursions and general
erosion of certainty, and was making development of Swift's String very
difficult.

In this commit we use extremely low-level primitives to avoid the recursion
problem.  Also, because the purpose of all the older assertion functions
was unclear and there was a great deal of overlap in terms of
functionality, we clarify naming and consolidate functions.

As much as possible, the semantics of all existing tests in the face of
Asserts-enabled/-disabled build configuration changes has been
preserved, but the new naming makes it obvious in some cases that the
semantics may not have been well-chosen, which speaks well for the new
names. (**)

The two forms of "assert()" are completely enabled or
disabled--including evaluation of the condition--based on build
configuration.  This follows the usual semantics from C, with the
differences being:

  * No multiple evaluation badness from preprocessor macros, of course
  * When a condition is supplied, assert accepts an optional message
  * When no condition is supplied, fires unconditionally and requires a
    message

The other functions are always enabled and only differ between build
configurations in how much information they attempt to deliver through
non-core-dump channels.  When assertions are disabled and these
functions fire, they invoke a debugger trap, and do nothing else.

(**) It also opens some questions about policy.  For example, should we
consider overflow and underflow to be securityChecks, as we do now, even
though they do not directly cause a memory safety issue?  We could wait
for e.g. bounds checking on arrays to catch those problems before they
become memory safety issues, and gain a little speed in the regular
arithmetic path.

Swift SVN r12854
2014-01-23 06:47:18 +00:00
Joe Groff
378f18c430 IRGen/Runtime: Provide getGenericMetadata[1-4] entry points.
This lets IRGen avoid emitting an alloca for common generic metadata instantiations. These entry points can also be marked "readnone", and the general getGenericMetadata entry point can be "readonly", giving LLVM's optimizer a fighting chance on unspecialized generic code.

Swift SVN r12789
2014-01-22 21:54:58 +00:00
Greg Parker
d9fbea1eff [stdlib] Commit file deletions that were left out of r12732.
Swift SVN r12734
2014-01-22 08:43:27 +00:00
Greg Parker
71c3beb7af [stdlib] Fix ObjCBool definition selection: 32-bit iOS uses BOOL=char.
Swift SVN r12732
2014-01-22 08:28:04 +00:00
Greg Parker
5d12af1b8e [stdlib] Speculatively fix Makefile build of ObjectiveC.swiftmodule.
Swift SVN r12728
2014-01-22 07:34:19 +00:00
Greg Parker
eea5037662 [stdlib] Make definition of ObjCBool platform-specific. NFC on OS X.
Swift SVN r12703
2014-01-22 05:49:03 +00:00
Dave Abrahams
f51fc320ca [stdlib] Add StringCore
The core datastructure of the revised and optimized String Design Redux,
Part Trois.  Completely untested and not wired into anything, so NFC.

Swift SVN r12701
2014-01-22 05:09:20 +00:00
Jordan Rose
02e2018197 Fix many extra trailing underscores in block shim symbols.
...which would of course prevent them from being used. Sadly, this includes
the one I just added, since I didn't actually test it against the original
project until now.

Add a regression test that all block shims have valid manglings without
any unmangled suffixes.

Swift SVN r12672
2014-01-21 23:45:06 +00:00
Jordan Rose
e71e3bb887 Fix typo in block shim comment.
Swift SVN r12671
2014-01-21 23:45:04 +00:00
Jordan Rose
b48309716f [runtime] Add a block shim for (NSAnimationContext) -> Void
...which is used for the first argument to
+[NSAnimationContext runAnimationGroup:completionHandler:].

Also, use the existing shims for NSFileCoordinator's NSURL-taking blocks;
they are equivalent to the shims that take id.

We really need to figure out how to do this (a) more generically (i.e. all
id-compatible types are treated the same), and (b) on the fly for the more
esoteric block types.

<rdar://problem/15864611>

Swift SVN r12668
2014-01-21 23:13:29 +00:00
Michael Gottesman
47bba086fa Remove empty performance hack file.
Swift SVN r12664
2014-01-21 22:06:08 +00:00
Chris Lattner
59e35ee8a0 add a file to hold performance hacks. First up, make preincrement of integers
actually be trivial.  This works around:
<rdar://problem/15866569> [string perf] ++ is not getting deabstracted and inlined fully



Swift SVN r12634
2014-01-21 05:02:44 +00:00
Dave Abrahams
21186b5dc1 [stdlib] Break String source into manageable pieces
Swift SVN r12453
2014-01-17 01:47:29 +00:00
John McCall
4121191fe0 Remove Failure.cpp from the Makefile build.
Swift SVN r12346
2014-01-15 21:01:00 +00:00
Joe Groff
677576cffb IRGen: Use a shared bb for condfail instructions and kill the runtime call.
Swift SVN r12339
2014-01-15 19:33:01 +00:00
Dave Abrahams
586ccabbb0 [stdlib] Rework String bridging
Going through an @objc protocol for bridging Cocoa strings to Swift
String was working, but it had several disadvantages, including the cost
of invoking objc_msgsend and the need to viciously cast away type-safety
to get past swift's ObjC bridging restrictions.

Instead, Swift's core stdlib now contains a couple of "function
pointers" (variables of Optional<some-Swift-function-type>) that are set
when Foundation is loaded.  We use C++ dynamic initialization to set up
these variables, which is probably not the right long-term answer, but
works for now.

These functions, instead of invoking objc methods on NSString, go
through CFStringXXX functions, which have a fast path that avoids
objc_msgsend in Cocoa's common cases, and since they're not @objc
methods, they can use Swift's full type vocabulary.

It would still be nice to avoid any dynamic dispatch and checking
overheads for going through these optional function variables, but this
ought to be a lot better than where we were, and it keeps Foundation
decoupled from the core standard library.

Along the way, a fair amount of needless code bulk was shed.  Shedding
FTW!

Swift SVN r12327
2014-01-15 11:29:23 +00:00
Nadav Rotem
c3a1f09ca1 Move the string benchmark into Benchmark.swift
We can now run it from the repl:

Welcome to swift.  Type ':help' for assistance.
(swift) benchStrings()
8808796493 nanoseconds on x86
(swift) 




Swift SVN r12242
2014-01-13 20:10:29 +00:00
Dave Zarzycki
a1d3bcdd42 Add temporary String benchmark
C++:     ~231326 ns
 ObjC:     ~750604 ns
Swift: ~5827396474 ns == 25191x slower than C++!

The problems are all over the place. For example: while there are lots
of failures to inline generics, there is work in the runtime as well to
fix some cases where we call calloc() instead of use the swift cache.

Swift SVN r12225
2014-01-13 09:40:03 +00:00
Nadav Rotem
da3ed8d324 Add the RC4 benchmark to stdlib.
We will remove this benchmark as soon as we fix rdar://14747929, that will allow us to optimize basic stdlib routines.



Swift SVN r12134
2014-01-10 21:01:44 +00:00
John McCall
e933d421b0 Add UncheckedOptional<T> to the standard library.
Swift SVN r12127
2014-01-10 19:13:49 +00:00
Dave Abrahams
fb70778e35 [stdlib] Remove Obsolete CodePoints type
CodePoints was built upon StringByteData, a UTF-8 String
representation.  Its replacement is UTF16Scalars.

Swift SVN r12111
2014-01-10 01:24:25 +00:00
Dave Abrahams
bf3ca81ee7 [stdlib] File renames associated with protocol name changes
Swift SVN r12063
2014-01-08 20:06:29 +00:00