Commit Graph

21434 Commits

Author SHA1 Message Date
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
Doug Gregor
0d37bd3015 Switch the standard library from "static" to "type".
Swift SVN r12026
2014-01-08 01:09:56 +00:00
Dave Zarzycki
6e7bb68279 15763917 stdlib/POSIX should probably be removed
Foundation vends wrappers for most of this stuff anyway. We should
duplicate or "innovate" here.

Swift SVN r12002
2014-01-07 19:10:42 +00:00
Dave Abrahams
212f39e307 [stdlib] Rename Indexable.swift => Container.swift
Now that the protocol name changed, get the filename straightened out
too.

Swift SVN r11959
2014-01-06 22:30:27 +00:00
Doug Gregor
1ee513e7e8 Use Builtin.Word for array lengths, string literal lengths, etc.
This eliminates a number of 64-bit integer/64-bit pointer assumptions
in the type checker and SILGen.


Swift SVN r11863
2014-01-03 18:53:01 +00:00
Dave Zarzycki
632264cbd1 stdlib: checkpoint 15612767: Int should become a separate, platform-sized type
1) Abstract away assumptions about all LLVM types being prefixed by 'Int'.
2) Thread through the ability to create a "word" sized type. This is
   blocked by a couple bugs.
3) Fix a bug where Int8/UInt8 did not conform to ArrayBounds.
   (This bug dates back to when FixedPoint.swift was hand maintained.)

Swift SVN r11858
2014-01-03 07:50:08 +00:00
Dave Abrahams
b86ebcc042 [stdlib] Rename Char.swift => UnicodeScalar.swift
Swift SVN r11846
2014-01-03 01:37:33 +00:00
Dave Abrahams
0ca0b46065 [stdlib] Rename NewString.swift -> String.swift
Swift SVN r11845
2014-01-03 01:32:20 +00:00
Dave Abrahams
dc26363d29 [stdlib] Remove String.swift
It was only serving up a single typealias

Swift SVN r11832
2014-01-02 22:09:08 +00:00
Dave Abrahams
8eb7129b9c [stdlib] Replace String with NewString
This change is as minimal as possible, which means leaving obsolete
functionality in place (e.g. StringByteData) and even keeping the
"NewString" name in many places.  The obsolete functionality was useful
for testing my changes, but expect immediate cleanup commits
addressing all those issues to follow.

* All String bridging now happens in pure Swift code.

* Because String no longer owns an array of UInt8, some assumptions and
  assertions are no longer valid.  As a result, some code was deleted
  and all the code that produces null-terminated strings had to be
  rewritten

* test/Constraints/construction.swift had to have one test commented out
  because it relied on an element of the String interface that I did not
  port forward.  It seems to me that this test should declare its own
  types and not rely on the stdlib, if it's still valid.

* One test in /test/stdlib/Algorithm.swift had to be disabled pending
  <rdar://problem/15736729> and <rdar://problem/15733855>

* This change revealed that test/Interpreter/repl.swift is sensitive to
  type-alias names; I had to change a "NewString" to "String" there.
  This may indicate a bug somewhere?

Swift SVN r11830
2014-01-02 20:16:59 +00:00
Dave Zarzycki
d24e2454de stdlib: add overflow checking to div and rem
Swift SVN r11783
2014-01-01 03:32:01 +00:00
Dave Zarzycki
0228f019c1 stdlib: make unary + generic over SignedNumbers
Swift SVN r11774
2013-12-31 20:16:13 +00:00
Dave Zarzycki
3feaac40c6 stdlib: drop IEEE from type/protocol names
Swift SVN r11768
2013-12-31 05:28:57 +00:00
Dave Zarzycki
a38ce8d8ef stdlib: move related NumericOperations out of Policy.swift
Swift SVN r11762
2013-12-31 03:41:30 +00:00
Dave Zarzycki
44269cc01d stdlib: Move IEEE754 support into its own file
Swift SVN r11761
2013-12-31 02:42:16 +00:00
Dave Zarzycki
f4e60d11b3 stdlib: Move the LogicValue implementation into its own file
Swift SVN r11759
2013-12-31 02:31:01 +00:00
Dave Zarzycki
c550e75954 stdlib: consolidate compiler protocols into a dedicated file
Annotating each protocol with "NOTE: ..." doesn't scale.

Swift SVN r11758
2013-12-31 02:08:59 +00:00
Dave Zarzycki
669ca06213 stdlib: mark SignedNumber methods as @transparent
Swift SVN r11757
2013-12-31 01:54:11 +00:00
Dave Zarzycki
9bfa643933 stdlib: abs() should use Builtin.*fabs* on floats
Swift SVN r11745
2013-12-30 21:42:22 +00:00
Doug Gregor
8383a25989 Remove the __less__ hack; use < instead.
Note that we have to work around <rdar://problem/14432081> a bit.

Swift SVN r11726
2013-12-29 21:05:16 +00:00
Doug Gregor
d1054b9e86 Eliminate the __equal__ protocol requirement; use == directly.
This is DaveA's patch, slightly tweaked, which works properly now that
<rdar://problem/15715996> is fixed.

Swift SVN r11725
2013-12-29 20:45:25 +00:00
Chris Lattner
4f4c698ed6 Change 'self' to be an rvalue instead of an lvalue in non-@mutating
struct methods.  This does not including properties and subscripts,
but covers the bulk of the change.  The implication of this is that
the compiler now rejects mutations of self in a non-@mutating method,
and rejects attempts to call a @mutating method from a non-@mutating
method.

Along with this:
 - Fix a refcounting bug in SILGenExpr where I emitted multiple releases
   in the rvalue member_ref_expr case, which was exposed by the 
   testsuite now that rvalues are being used a lot more.
 - Change a few native binding things in objc/Foundation to understand
   that String is passed by value now when calling size() and that
   you can't take the address of self in a non-mutating method (this
   should probably pass the components by value instead of passing
   &self, for better performance).  I filed rdar://15726720 to track
   this.
 - Update a ton of testcases.  We now don't materialize nearly as much
   as we used to.
 - Brutalize the test/stdlib/Getopt.swift testcase to work, now that
   the "GetoptLongOptions().noArgument("foo")" builder pattern doesn't
   work anymore (noArgument is a @mutating method, which isn't allowed
   on an rvalue temporary).



Swift SVN r11662
2013-12-26 17:38:03 +00:00
Joe Groff
3e30cbcfef SILGen/IRGen: Don't emit top_level_code for libraries.
If there's no script-mode file in a module, don't produce a top_level_code SILFunction for it, and don't consider emitting an LLVM global_ctor for it. We should never emit static constructors from user code anymore.

Swift SVN r11644
2013-12-26 00:18:29 +00:00
Dave Abrahams
afbbbd1287 [stdlib] Add a facility for calling "C" functions that take va_list arguments
This code has only been tested on x86_64, but is designed to work on
the other platforms supported by Apple.

Swift SVN r11561
2013-12-22 02:37:33 +00:00
Joe Groff
3c192269d0 Runtime: Remove debug noise from swift_getExistentialMetadata.
Swift SVN r11524
2013-12-20 23:06:14 +00:00
John McCall
c5aa41ffd1 Change around some manglings to make them carry more
information and be easier to demangle.

Swift SVN r11423
2013-12-18 08:33:52 +00:00
Dave Abrahams
85511c09b1 Remove mistakenly-committed file
Swift SVN r11329
2013-12-15 03:18:08 +00:00
Dave Abrahams
90f13d55b4 [stdlib] NSStringAPI: add a couple of missing .AutoReleased annotations
Swift SVN r11328
2013-12-15 03:13:10 +00:00
Doug Gregor
1ecccd8f47 Remove unused static function.
Swift SVN r11264
2013-12-13 21:19:53 +00:00
Dave Abrahams
eea35fd745 BlockShims: correct a mangled name
Where did the triple underscore come from?  Are the other ones wrong,
too?  We should at least have a trivial test for each of these.

Swift SVN r11255
2013-12-13 16:18:43 +00:00
Dave Abrahams
5c24f790c8 [stdlib] NSStringAPI: create missing block shim
Now we can actually link the implementation of
enumerateLinguisticTagsInRange

Swift SVN r11221
2013-12-12 23:47:07 +00:00
Dave Abrahams
68c47c7121 [stdlib] Remove ObjectPointer.swift; it was not ready for prime-time
Swift SVN r11131
2013-12-11 17:20:06 +00:00