Commit Graph

185 Commits

Author SHA1 Message Date
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
Joe Groff
abdb2a7640 Add block shim for void(^)(BOOL).
Fixes <rdar://problem/15931537>.

Swift SVN r13119
2014-01-29 21:50:51 +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
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
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
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
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
Doug Gregor
0d37bd3015 Switch the standard library from "static" to "type".
Swift SVN r12026
2014-01-08 01:09:56 +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 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
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
b3955c6d7a [stdlib] NewString.swift: work in progress
Swift SVN r10680
2013-11-28 16:45:21 +00:00
John McCall
b1bbbac19b Correct the mangling of SIL results to include the
ownership convention.

Swift SVN r10598
2013-11-20 18:05:05 +00:00
Doug Gregor
ba6362af8f Update VOID mangling for block shims.
Unbreaks the "Name That Tune" build.


Swift SVN r10593
2013-11-20 16:35:50 +00:00
John McCall
20e58dcf93 Change the type of function values in SIL to SILFunctionType.
Perform major abstraction remappings in SILGen.  Introduce
thunking functions as necessary to map between abstraction
patterns.

Swift SVN r10562
2013-11-19 22:55:09 +00:00
Dave Zarzycki
accb1652c8 15484346 Disable crashtracer for applications
Swift SVN r10532
2013-11-17 20:50:53 +00:00
Dave Zarzycki
f22377c3ef Fix a concurrency leak
Swift SVN r10531
2013-11-17 20:50:47 +00:00
Dave Zarzycki
727a0e4c69 Fix make build system
Swift SVN r10530
2013-11-17 20:50:41 +00:00
Joe Groff
562e2bfff6 Runtime: Add swift_once function.
For now, just shim over dispatch_once.

Swift SVN r10514
2013-11-16 03:11:17 +00:00
Joe Groff
7de9706403 IRGen/Runtime: Expose extra inhabitants of class protocol types.
This gives 'id?' and other optional class protocol types optimal representation consistent with class types.

Swift SVN r10346
2013-11-11 22:52:23 +00:00
Joe Groff
554abf2d7a IRGen/Runtime: Expose extra inhabitants of class types.
Start using null-page values as extra inhabitants when laying out single-payload enums that contain class pointers as their payload type. Don't use inhabitants that set the lowest bit, to avoid trampling potential ObjC tagged pointer representations. This means that 'T?' for class type T now has a null pointer representation. Enums with multiple empty cases, as well as nested enums like 'T??', should now have optimal representations for class type T as well.

Note that we don't yet expose extra inhabitants for aggregates that contain heap object references, such as structs with class fields, Swift function types, or class-bounded existentials (even when the existential has no witness tables).

Swift SVN r10061
2013-11-09 00:43:40 +00:00
Howard Hinnant
46f26de87b Inlined countLeadingZeros per Dmitri's suggestion.
Swift SVN r9970
2013-11-05 20:20:19 +00:00
Howard Hinnant
ec70f480a6 Set Dictionary up to use only power-of-2 bucket counts. Introduce countLeadingZeros helper to accomplish this. It would be really nice if we could figure out how to inline countLeadingZeros.
Swift SVN r9967
2013-11-05 18:52:44 +00:00
Joe Groff
bbddf41693 IRGen: Instantiate existential metadata through the runtime.
When we need a reference to protocol or protocol composition type metadata, ask for it through the runtime, instead of referencing statically-emitted protocol metadata.

Swift SVN r9871
2013-11-01 17:13:49 +00:00
Joe Groff
fe7ecec60c Runtime: Provide value witness implementations for class existentials.
Same deal as for opaque existentials--pre-instantiate a static witness table for one-witness-table types (the zero-witness-tables case is nicely handled by Builtin.ObjCPointer's value witness), and generate a vwtable using dynamic witness implementations for each different-sized container on demand as necessary.

Swift SVN r9850
2013-10-31 18:38:54 +00:00
Joe Groff
c38ad6458e Runtime: Expose assignExistentialWithCopy entry points.
The assign-with-copy operation on existentials is complex enough to be emitted as a function call, which is currently generated on-demand by IRGen for every existential layout. We can instead use the implementation out of the runtime. Provide entry points for zero, one, and any number of witness tables.

Swift SVN r9815
2013-10-30 21:58:36 +00:00
Joe Groff
922358797d Runtime: Provide a specialization for zero-witness-table existential container layout.
So compilers don't complain about nonstandard use of zero-sized arrays.

Swift SVN r9797
2013-10-30 17:07:04 +00:00
Chris Lattner
cb6cf87f1e revert r9785, it isn't correct.
Swift SVN r9793
2013-10-30 16:02:55 +00:00
Chris Lattner
9ed8986d12 silence a warning:
Metadata.cpp:1280:26: warning: zero size arrays are an extension [-Wzero-length-array]
  const void *_witnesses[NUM_VALUE_WITNESSES];
                         ^~~~~~~~~~~~~~~~~~~
Metadata.cpp:1366:12: note: in instantiation of member class
      '<anonymous>::OpaqueExistentialValueWitnesses<0>::Container' requested here
  /*size*/ Container::size(),
           ^
Metadata.cpp:1448:51: note: in instantiation of static data member '<anonymous
      namespace>::OpaqueExistentialValueWitnesses<0>::ValueWitnessTable' requested here
      return &OpaqueExistentialValueWitnesses<0>::ValueWitnessTable;
                                                  ^
1 warning generated.

As an aside, putting a template argument in ALL_CAPS is kinda wierd.



Swift SVN r9787
2013-10-30 13:49:43 +00:00
Joe Groff
45d0ae05f8 Runtime: Add value witness forwarders to Metadata type.
Add member functions to Metadata that call into the value witness table and pass 'self' automatically.

Swift SVN r9758
2013-10-29 16:07:22 +00:00
Joe Groff
47a77e1c8c Runtime: Provide implementations of opaque existential witnesses.
Instantiate static value witness implementations for the common zero- and one-witness-table cases, which correspond to the "Any" type protocol<> and to single-protocol types. For protocol compositions, instantiate a value witness table that uses the layout information from existential metadata to perform the value witness operations.

Swift SVN r9752
2013-10-29 03:08:21 +00:00
Joe Groff
37e652b2ba Runtime: Add swift_getExistentialMetadata entry point.
Set up a metadata cache for existential type metadata. Instantiate existential metadata by first sorting the protocol list, so that it is order invariant, precomputing the overall witness table count and class constraint of the composition so it can be cached in the existential metadata.

We still need to implement value witnesses for existential containers in the runtime before this is complete. We can at least test the uniquing and flags computations at this point.

Swift SVN r9727
2013-10-28 20:53:20 +00:00
Greg Parker
569f98de00 Fix Makefile build.
Swift SVN r9599
2013-10-22 21:33:30 +00:00
Joe Groff
2e0d554720 runtime: Minimal implementation of swift_conditionalFailure.
It'd be nice to eventually report some context information, maybe derived from the location info on the originating 'cond_fail' SIL instruction, but this is a start.

Swift SVN r9589
2013-10-22 15:53:06 +00:00
Greg Parker
c81077dfa6 Build FastEntryPoints.s using C compiler when generating for not-Xcode.
Swift SVN r9513
2013-10-19 00:59:46 +00:00
Greg Parker
fbd1c95292 Add support for iOS builds using cmake.
Swift SVN r9499
2013-10-18 21:52:37 +00:00
Dave Zarzycki
78406b4e51 14834091 swift_allocObject should not sleep when memory is unavailable
Swift SVN r9317
2013-10-14 17:39:41 +00:00
Dave Zarzycki
a73952a77b Abort if single threaded and the address space is exhausted
This is part of 14834091.

Swift SVN r9314
2013-10-14 16:50:06 +00:00
Joe Groff
b233f5fd2a runtime: Start class layout from superclass's size and alignment.
If we instantiate metadata for a generic class, start laying out its fields relative to its base class's fragile size and alignment.

Swift SVN r9300
2013-10-14 02:45:58 +00:00
Joe Groff
280fc60ce9 IRGen, runtime: Poke generic size and alignment into class metadata.
This should get us actually allocating and deallocating generic root class instances.

Swift SVN r9251
2013-10-12 03:34:27 +00:00
Joe Groff
43dd2f76d3 runtime: Add swift_initClassMetadata function.
Similar to swift_initStructMetadata, takes a vector of field type metadata and calculates the offsets of all of the fields.

Swift SVN r9237
2013-10-11 23:56:53 +00:00