Commit Graph

21434 Commits

Author SHA1 Message Date
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
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
Mon Ping Wang
00467ba953 Reintroduce "Add support for Axle library." from 9292. Added an dependency to prevent building the
core and axle core at the same time.


Swift SVN r9309
2013-10-14 07:51:19 +00:00
Dmitri Hrybenko
f40ba621a8 Make integer literals 2048-bit. This covers the whole Float64 range.
Swift SVN r9308
2013-10-14 05:18:55 +00:00
Dmitri Hrybenko
3d8e8d1e8f Remove fixed FIXMEs
Swift SVN r9304
2013-10-14 04:13:16 +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
cf457d2210 Revert "Add support for Axle library." It breaks the build.
This reverts commit r9292.

Swift SVN r9296
2013-10-13 22:38:22 +00:00
Mon Ping Wang
41aca3e7e6 Add support for Axle library. Please note that AxeBuiltins.gyb will be
expanded soon for the other graphics builtins.


Swift SVN r9294
2013-10-13 19:54:01 +00:00
Dmitri Hrybenko
011284e9c9 Make minus sign part of IntegerLiteralExpr and make integers literals 136-bits
wide

Currently integer literals are 64-bit.  In order to allow checking for overflow
while converting an integer literal to swift.UInt/Int* types we need at least
65 bits.  But floating point numbers (Float32, Float64, Float80) are
BuiltinIntegerLiteralConvertible.  In order to allow spelling large floating
point constants, we allow 136-bit literals.

Rationale: 128 bits are enough to represent the absolute value of min/max IEEE
Binary32, and we need 1 bit to represent the sign.  136 is 129 rounded to the
next 8 bits.

The plan is to have builtins that do the overflow check and convert 136-bit
numbers to the required width.  We need these builtins for both integers and
floating point numbers to ensure that 136-bit numbers are folded into sane
constants in SIL and don’t escape to LLVM IR.


Swift SVN r9253
2013-10-12 04:52:11 +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
Anna Zaks
1d646a8ba8 Implement overflow checking on integer literals (1 of 2)
- Added 2 new builtins strunc_with_overflow and utrunc_with_overflow
  that perform truncation and produce a compile time error when truncation
  overflows.

- Used these builtins instead of trunc to implement "_convertFromBuiltinIntegerLiteral".

- Currently, the builtins are converted to trunc in IRGen, but we should
  not be IRGenning code that uses them, since all uses of
  "_convertFromBuiltinIntegerLiteral" should be inlined and the arguments
  constant folded.

- I had to change a test and the implementation of operator '~' in the standard library
  because they assumed that '0xFF' is a valid signed Int8. It is questionable if we should
  allow this and if we should treat signed and unsigned integers differently depending on
  how they are spelled (decimal or hexadecimal).

* This patch will be further improved (Ex: will start finding overflows on Int64, better
  deal with '-128' after the negative integer literal patch is committed.)

Swift SVN r9226
2013-10-11 22:19:14 +00:00
Dave Abrahams
e2a8c60d94 [stdlib] GenericIVar is dead; long live "var _: T"!
Swift SVN r9217
2013-10-11 20:13:13 +00:00
Dave Abrahams
293bc08309 [stdlib] Enumerator is dead; long live Generator!
Swift SVN r9124
2013-10-10 01:40:57 +00:00
Joe Groff
ef58b853f7 runtime: Add a swift_initStructMetadata entry point.
Does what it says on the tin: lays out the fields, storing their offsets into the metadata, and initializes the size, flags, and stride of the value witness table.

Swift SVN r9120
2013-10-10 00:55:51 +00:00
Joe Groff
e88786b32c runtime: Factor out basic layout from getTupleTypeMetadata.
We'll want to use the same logic to lay out generic struct fields at runtime. While we're here, fix a bug where we weren't aligning field offsets prior to storing them in the tuple metadata.

Swift SVN r9117
2013-10-10 00:42:04 +00:00
John McCall
a79cee2c54 Revert "Reimplement integer arithmetic overflow checking to use special, error on overflow builtins"
This was causing massive failures at run-time.

This reverts commit 80081db973ccb7100741fea19ce8e8c116fc410f.

Conflicts:
	lib/SILPasses/ConstantPropagation.cpp
	test/SILPasses/constant_propagation.swift
	test/SILPasses/constant_propagation2.sil

Swift SVN r9050
2013-10-09 01:20:39 +00:00
Anna Zaks
ccc1dae7fd Reimplement integer arithmetic overflow checking to use special, error on overflow builtins
After talking to John, Joe, and Dave Z, 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 r9034
2013-10-08 23:07:56 +00:00
Doug Gregor
fdd08a42e4 Remove a pile of typealiases that can be deduced associated type witnesses.
We can't yet remove them all due to <rdar://problem/15168483>.


Swift SVN r8988
2013-10-07 20:51:28 +00:00
Chris Lattner
1e09725368 pass -module-name to the build command for the stdlib. Rearrange to pass -c at the end to make it easier to copy and paste the line for messing with sil.
Swift SVN r8952
2013-10-07 15:20:36 +00:00
Greg Parker
bca82ea688 Add block<->closure shims for most of Foundation's block object API.
Swift SVN r8942
2013-10-05 04:54:26 +00:00
Greg Parker
c4854a037b Add whitespace to @-based control structures in FixedPoint.gyb.
Swift SVN r8914
2013-10-04 05:39:44 +00:00
Greg Parker
98b8b160e7 Use @attribute syntax in FixedPoint.swift.
Swift SVN r8913
2013-10-04 05:34:27 +00:00
Greg Parker
ec31b01246 Remove incorrect optimization of dynamic casts of non-ObjC objects.
Swift SVN r8907
2013-10-04 04:17:26 +00:00
Greg Parker
b2f3b307fa Fix memory leak in NSString->String conversion.
Swift SVN r8872
2013-10-03 04:09:22 +00:00
Greg Parker
1a243380af Stop using swift-mangled names directly.
Swift SVN r8871
2013-10-03 04:08:28 +00:00
Dave Abrahams
b5842cb6b4 [stdlib] Initial implementation of Character
This type can't do much but store an arbitrary very short string right now, but it works

Swift SVN r8850
2013-10-02 18:56:19 +00:00
Doug Gregor
100bcdb9e6 Silence -Wunused warning in Release builds.
Swift SVN r8835
2013-10-02 04:51:48 +00:00
Greg Parker
05cbbf1229 Clean up BridgeNSString.mm. Fix bug in Unicode string conversion.
Swift SVN r8834
2013-10-02 03:18:31 +00:00
Anna Zaks
e136245676 [SIL] Add integer overflow warnings on simple arithmetic to swift.
- Adds transparent attribute to add/mult/sub on integer types.
 - Fix a bug in ConstantPropagation that ensures that the propagation is triggered on StructExtract, when struct is simplified.
 - Slightly improve the error message.

Swift SVN r8825
2013-10-01 23:02:35 +00:00
Greg Parker
720dab7b95 Separate non-String code from BridgeNSString.mm.
Swift SVN r8818
2013-10-01 21:49:03 +00:00