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
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
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
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
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
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
The hack to get the LLVM build system to do what we want is to define a
custom build rule for "XYZ.o" and then add "XYZ" as a dummy source file
to the SOURCES variable, which the LLVM Makefile system uses. To make it
clear that something unusual is going on here, I've changed all existing
instances of this to use "XYZ.o" in SOURCES, rather than having that name
be derived from "XYZ.swift" or whatever.
The actual Swift source files go in SWIFT_SOURCES for the time being
(and possibly forever, since Swift sources will always be built together).
Swift SVN r11058
Since our build system isn't really set up to cope with
multi-sourcefile-modules, dump all Foundation support directly into
Foundation.swift
Swift SVN r11049
Because we're using a "brute-force" combination of conversion to
NSString and forwarding, this code will continue to work when String
is replaced by NewString. It may not be fast yet, but at least it
will flesh out the experience for Cocoa programmers
Swift SVN r11034
Instead of letting swift_NSStringToString leak malloced memory, use swift_allocPOD to allocate storage for the converted String, and stash the heap object into the created string.
Swift SVN r7872
This ended up being easiest with a runtime function. I couldn't push this
into the standard library because the standard library doesn't know about
NSObject, and I couldn't compile the ObjectiveC module as -parse-stdlib
because it uses standard library types and doesn't otherwise know how to
find the "swift" module.
Swift SVN r7581
...rather than as a separate step. This avoids duplicating Parse and Sema
work for these. (This is the new and correct version of r7377.)
Also, remove leftover code for building "swift.swift" and friends in lieu
of proper modules. We're not going back to those days. :-)
Swift SVN r7420
It's used for class-bounded protocols, not just Foundation objects.
No test because I couldn't figure out how to write a non-compilation test.
Swift SVN r7367