Commit Graph

21665 Commits

Author SHA1 Message Date
Dave Zarzycki
2c24ee6a29 Switch integer min/max static funcs to static vars
Swift SVN r10533
2013-11-17 22:42:54 +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
Dmitri Hrybenko
81dc5deee8 Change 'def' keyword back to 'func'
Swift SVN r10522
2013-11-17 07:45:28 +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
Anna Zaks
3e8fa762ec Dynamically and statically dianose a conversion of a negative integer to an unsigned int.
Swift SVN r10513
2013-11-16 01:26:54 +00:00
Anna Zaks
0f390c9c54 Add dynamic checking for sign errors(overflows) during signed <-> unsigned conversions for integers of the same type.
Add unsafe alternatives to allow unsafe conversions:
 - asUnsigned()
 - asSigned()

Swift SVN r10476
2013-11-15 00:16:18 +00:00
Dave Zarzycki
16f2b951e6 15466633 _getBuiltinArrayBoundValue should be @transparent
Swift SVN r10459
2013-11-14 08:11:40 +00:00
Chris Lattner
3f0976677f secondary cleanups now that bool is a struct: we can directly access .value
to convert a Bool to i1 and can use the Bool ctor to convert i1 to Bool.



Swift SVN r10437
2013-11-13 23:39:26 +00:00
Anna Zaks
b687c3ce9c Add runtime integer truncation checking to the conversion constructors
Add new builtins(by generalizing, renaming, and extending the builtins used for compile time integer literal checking). These new builtins truncate integers and check for overflow/truncation errors at runtime. Use these for FixedPoint conversion constructors.

Fix a routine in stdlib's String implementation and a test that relied on bitwise behavior of the constructors (and triggered overflows).

TODO:
- Teach CCP about these to get static checking.
- Add special builtins for same size signed <-> unsigned conversions.

Swift SVN r10432
2013-11-13 21:54:34 +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
Anna Zaks
084bdfd05f Change the signature of the trunc builtins to return a tuple containing teh overflow bit as well as the result.
This is a first step in generalizing the builtin to handle non-constant int to int truncations.

Swift SVN r10341
2013-11-11 21:20:04 +00:00
Dmitri Hrybenko
e36ebb217c Remove empty files
Swift SVN r10074
2013-11-09 08:01:08 +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
Dave Abrahams
38b9e6808f [stdlib] CharacterEncoding.swift => Unicode.swift
Also enshrine the tests in the test suite

Swift SVN r10057
2013-11-08 22:17:50 +00:00
Dave Abrahams
645ce0b664 [stdlib] Add support for bound protocols
Protocols with associated types can't currently be used as existential
types.  Combined with the inability to create type constraints on
generic functions nested in generic types based on the outer type and
the inability to create closures of generic type and the inability to
create protocol constraints that require generic functions and the
inability to create protocols with init() requirements... and this is
what we get.

Swift SVN r10034
2013-11-08 06:29:29 +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
Chris Lattner
50054458e7 remove SIMD vector support from the stdlib. I think we all really want this,
but we don't have time right now to make it great.  This shrinks the stdlib
by 9000 lines :-)


Swift SVN r9902
2013-11-03 16:10:57 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Dave Abrahams
21d196a9ef [stdlib] Implement basic transcoding of UTF8 and UTF16
Swift SVN r9896
2013-11-02 01:32:49 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +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
Greg Parker
beaa56d8e9 Add Builtin.Word and use it to implement swift.Word.
Swift SVN r9864
2013-11-01 00:11:22 +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
Greg Parker
b342f68392 Fix Float80 suppression.
Swift SVN r9838
2013-10-31 01:47:27 +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
Dmitri Hrybenko
c216a848b9 stdlib/FloatingPoint: port floating point implementation to gyb
No changes in functionality intended.


Swift SVN r9799
2013-10-30 17:14:12 +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
Dmitri Hrybenko
462bc95c6a stdlib/FixedPoint: use camel case names in generator script
Swift SVN r9796
2013-10-30 17:06:55 +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
5711ec1626 stdlib: Trap overflows with condfail instead of if { trap }.
Swift SVN r9594
2013-10-22 16:08:33 +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
Dave Abrahams
3a09877034 [stdlib] Remove unintended flotsam
Swift SVN r9508
2013-10-19 00:17:36 +00:00
Dave Abrahams
f3053a8bea [stdlib] WIP: prototype the basic data structure of the new string design.
Nothing is tested yet, but it all compiles

Swift SVN r9507
2013-10-19 00:10:02 +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
62d3b16cd8 Workaround 15254902 -- Simple generic functions aren't inlined
Swift SVN r9464
2013-10-17 21:21:59 +00:00
Jordan Rose
9a4528c904 Move gyb from tools/ to utils/
For consistency with the vague idea that things that are only useful for
compiler developers should go in utils/, not tools/. Unless they need
build system support.

Swift SVN r9433
2013-10-17 00:08:48 +00:00
Howard Hinnant
b78fefdf0b Vector is dead. Long live Array.
Swift SVN r9432
2013-10-16 23:57:29 +00:00
Dmitri Hrybenko
13b834c9c0 stdlib/FixedPoint: move more @transparent annotations to extensions, as
suggested by Anna


Swift SVN r9431
2013-10-16 23:57:16 +00:00
Dmitri Hrybenko
2aed708565 stdlib/FixedPoint, stdlib/Float: mark constructors and comparison functions as @transparent
Swift SVN r9430
2013-10-16 23:35:11 +00:00
Dmitri Hrybenko
381d6ffec2 stdlib/FixedPoint: Fix coding style
Swift SVN r9416
2013-10-16 19:29:21 +00:00
Anna Zaks
740fc0a9d9 Revert "Revert "Reimplement integer arithmetic overflow checking to use special, error on overflow builtins""
(This only fails under -DSWIFT_OPTIMIZED=NO; most likely due to an llvm bug.)

We've decided that it's best to specialize each arithmetic builtin that could overflow, instead of calling a separate generic "staticReport" builtin and passing it enough info to produce the message. The main advantage of this approach is that it would be possible for the compiler to customize the message and better link it to the builtin that overflows. For example, the constants that participated in the computation could be printed. In addition, less code will be generated and the compiler could, in the future, automatically emit the overflow diagnostics/trap at runtime.

This patch introduces new versions of op_with_overflow swift builtins. Which are lowered to llvm.op_with_overflow builtins in IRGen after the static diagnostics. If the last argument to the builtins evaluates to true, the overflow is unintentional. CCP uses the builtins to diagnose the overflow detectable at compile time. FixedPoint is changed to rely on these in implementation of primitive arithmetic operations.

Swift SVN r9328
2013-10-14 21:42:33 +00:00