Commit Graph

2278 Commits

Author SHA1 Message Date
Jed Davis
c8c08763ec Add repr attributes in various places that need them. 2013-10-29 09:09:20 -07:00
Jed Davis
ac311ecaab Fix multiple mistakes in adt::is_ffi_safe 2013-10-29 09:09:20 -07:00
Jed Davis
25f953437d Lint non-FFI-safe enums. 2013-10-29 09:09:20 -07:00
Jed Davis
01740acd5a Initial implementation of enum discrimnant sizing.
Allows an enum with a discriminant to use any of the primitive integer
types to store it.  By default the smallest usable type is chosen, but
this can be overridden with an attribute: `#[repr(int)]` etc., or
`#[repr(C)]` to match the target's C ABI for the equivalent C enum.

This commit breaks a few things, due to transmutes that now no longer
match in size, or u8 enums being passed to C that expects int, or
reflection; later commits on this branch fix them.
2013-10-29 09:09:19 -07:00
Jed Davis
f1124a2f55 Add parser for #[repr(...)]; nothing uses it yet.
Also export enum attrs into metadata, and add a convenient interface for
obtaining the repr hint from either a local or remote definition.
2013-10-29 09:09:19 -07:00
bors
e6650c87a3 auto merge of #10142 : pythonesque/rust/issue-8263, r=catamorphism
This is, I think, the minimal change required.  I would have included a test but as far as I can tell there is currently no way to precisely test that the span for an error underlines the correct word.  I did verify it manually.
2013-10-29 07:41:48 -07:00
Joshua Yanovski
a71665798b #8263 part 2: Adding struct name. 2013-10-28 23:51:10 -07:00
Joshua Yanovski
01ab8542fb Field identifiers now include specific spans (Closes #8263). 2013-10-28 22:57:34 -07:00
bors
671ab42a3b auto merge of #10127 : thestinger/rust/cold, r=pcwalton
This allows a function to marked as infrequently called, resulting in
any branch calling it to be considered colder.
2013-10-28 22:51:51 -07:00
bors
8852cb7713 auto merge of #10113 : thestinger/rust/expect, r=cmr
LLVM is unable to determine this for most cases.

http://llvm-reviews.chandlerc.com/D2034 needs to land upstream before
this is going to have an effect. It's harmless to start generating the
expect hint now.
2013-10-28 16:07:14 -07:00
Daniel Micay
541e5f84d7 add support for the cold function attribute
This allows a function to marked as infrequently called, resulting in
any branch calling it to be considered colder.
2013-10-28 15:34:50 -04:00
Daniel Micay
dde8be6ad0 mark bounds check failures as the cold path
LLVM is unable to determine this for most cases.

http://llvm-reviews.chandlerc.com/D2034 needs to land upstream before
this is going to have an effect. It's harmless to start generating the
expect hint now.
2013-10-27 20:53:12 -04:00
Daniel Micay
1e4986ce56 make the bottom type immediate
Before:

    define void @_ZN3bar19h9d9b965357abc043af4v0.0E({}* noalias nocapture readnone sret, { i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone)

After:

    define void @_ZN3bar19h9d9b965357abc043af4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }* nocapture readnone)
2013-10-27 16:48:48 -04:00
bors
16b8a41531 auto merge of #10026 : luqmana/rust/mut-pat, r=pcwalton
Fixes #9792.
2013-10-27 09:51:21 -07:00
bors
dcdcd309fb auto merge of #10067 : sanxiyn/rust/addr-of-bot, r=thestinger
Fix #5500.
2013-10-25 12:56:20 -07:00
Seo Sanghyeon
f04886b6bf Allow taking address of bottom 2013-10-25 19:15:29 +09:00
bors
ac82d185b0 auto merge of #10061 : thestinger/rust/rustc, r=alexcrichton 2013-10-24 23:36:10 -07:00
Luqman Aden
26488b7465 librustc: Don't emit unused mut lint twice. 2013-10-25 01:50:57 -04:00
Luqman Aden
12308db3d2 libsyntax/librustc: Allow mut qualifier in patterns. 2013-10-25 01:21:07 -04:00
Daniel Micay
327878e628 remove some dead trans code 2013-10-24 21:58:47 -04:00
Daniel Micay
d497e6e954 stop trying to outsmart LLVM inline heuristics
Closes #10045
2013-10-24 20:41:23 -04:00
Alex Crichton
c4907cfd14 Remove std::io from ebml 2013-10-24 14:21:58 -07:00
Alex Crichton
61ed2cfb55 Remove even more of std::io
Big fish fried here:

    extra::json
    most of the compiler
    extra::io_util removed
    extra::fileinput removed

Fish left to fry

    extra::ebml
2013-10-24 14:21:57 -07:00
Daniel Micay
ce54c34f02 drop unused frame_address intrinsic
Closes #10001
2013-10-24 00:42:29 -04:00
Luqman Aden
af163579ed libsyntax/librustc: Allow specifying mut on ~self. 2013-10-22 21:22:19 -04:00
Luqman Aden
5754848f8c libsyntax/librustc: Allow specifying mut on by-value self. 2013-10-22 21:21:21 -04:00
Alex Crichton
daf5f5a4d1 Drop the '2' suffix from logging macros
Who doesn't like a massive renaming?
2013-10-22 08:09:56 -07:00
bors
c6337f2099 auto merge of #10003 : alexcrichton/rust/issue-fixes, r=brson
Commits have all the fun details.
2013-10-22 01:31:24 -07:00
Daniel Micay
462a28d003 fix the new floating point intrinsics 2013-10-21 14:26:07 -04:00
Alex Crichton
a25bbcc27f Propagate reachability through reexported impls
When re-exporting a trait/structure/enum, then we need to propagate the
reachability of the type through the methods that are defined on it.

Closes #9906
Closes #9968
2013-10-21 10:37:36 -07:00
Daniel Micay
4533432612 expose new floating point intrinsics
copysign, ring, nearbyint, round
2013-10-21 04:17:03 -04:00
bors
69e46f3aa9 auto merge of #9956 : sfackler/rust/more-more-visibility, r=alexcrichton 2013-10-19 14:01:10 -07:00
bors
31a209ca42 auto merge of #9834 : alexcrichton/rust/morestack, r=brson
This commit re-introduces the functionality of __morestack in a way that it was
not originally anticipated. Rust does not currently have segmented stacks,
rather just large stack segments. We do not detect when these stack segments are
overrun currently, but this commit leverages __morestack in order to check this.

This commit purges a lot of the old __morestack and stack limit C++
functionality, migrating the necessary chunks to rust. The stack limit is now
entirely maintained in rust, and the "main logic bits" of __morestack are now
also implemented in rust as well.

I put my best effort into validating that this currently builds and runs successfully on osx and linux 32/64 bit, but I was unable to get this working on windows. We never did have unwinding through __morestack frames, and although I tried poking at it for a bit, I was unable to understand why we don't get unwinding right now.

A focus of this commit is to implement as much of the logic in rust as possible. This involved some liberal usage of `no_split_stack` in various locations, along with some use of the `asm!` macro (scary). I modified a bit of C++ to stop calling `record_sp_limit` because this is no longer defined in C++, rather in rust.

Another consequence of this commit is that `thread_local_storage::{get, set}` must both be flagged with `#[rust_stack]`. I've briefly looked at the implementations on osx/linux/windows to ensure that they're pretty small stacks, and I'm pretty sure that they're definitely less than 20K stacks, so we probably don't have a lot to worry about.

Other things worthy of note:
* The default stack size is now 4MB instead of 2MB. This is so that when we request 2MB to call a C function you don't immediately overflow because you have consumed any stack at all.
* `asm!` is actually pretty cool, maybe we could actually define context switching with it?
* I wanted to add links to the internet about all this jazz of storing information in TLS, but I was only able to find a link for the windows implementation. Otherwise my suggestion is just "disassemble on that arch and see what happens"
* I put my best effort forward on arm/mips to tweak __morestack correctly, we have no ability to test this so an extra set of eyes would be useful on these spots.
* This is all really tricky stuff, so I tried to put as many comments as I thought were necessary, but if anything is still unclear (or I completely forgot to take something into account), I'm willing to write more!
2013-10-19 09:46:18 -07:00
Alex Crichton
6d8330afb6 Use __morestack to detect stack overflow
This commit resumes management of the stack boundaries and limits when switching
between tasks. This additionally leverages the __morestack function to run code
on "stack overflow". The current behavior is to abort the process, but this is
probably not the best behavior in the long term (for deails, see the comment I
wrote up in the stack exhaustion routine).
2013-10-19 09:43:31 -07:00
Steven Fackler
c18afcd83a Check unnecessary visibility for struct variants 2013-10-18 22:44:11 -07:00
bors
a9836e72dd auto merge of #9856 : alexcrichton/rust/privacy-errors, r=huonw
This stops labeling everything as "is private" when in fact the destination may
be public. Instead, the clause "is inaccessible" is used and the private part of
the flag is called out with a "is private" message.

Closes #9793
2013-10-18 17:11:25 -07:00
bors
d052912297 auto merge of #9851 : alexcrichton/rust/include_bin, r=huonw
Previously an ExprLit was created *per byte* causing a huge increase in memory
bloat. This adds a new `lit_binary` to contain a literal of binary data, which
is currently only used by the include_bin! syntax extension. This massively
speeds up compilation times of the shootout-k-nucleotide-pipes test

    before:
        time: 469s
        memory: 6GB
        assertion failure in LLVM (section too large)

    after:
        time: 2.50s
        memory: 124MB

Closes #2598
2013-10-18 09:41:33 -07:00
Alex Crichton
273784e9bf Optimize include_bin! for large inputs
Previously an ExprLit was created *per byte* causing a huge increase in memory
bloat. This adds a new `lit_binary` to contain a literal of binary data, which
is currently only used by the include_bin! syntax extension. This massively
speeds up compilation times of the shootout-k-nucleotide-pipes test

    before:
        time: 469s
        memory: 6GB
        assertion failure in LLVM (section too large)

    after:
        time: 2.50s
        memory: 124MB

Closes #2598
2013-10-18 09:20:08 -07:00
Eduard Burtescu
7ab0b0cd41 Handle inline asm outputs as write-only in liveness, borrowck and trans. 2013-10-18 08:02:56 +03:00
bors
3fd0e3a77b auto merge of #9902 : thestinger/rust/immediate, r=nikomatsakis
The code generation previously assumed a reference could not alter the
value in a way the destructor would notice. This is an incorrect
assumption for `&mut`, and is also incorrect for an `&` pointer to a
non-`Freeze` type.

Closes #7972
2013-10-17 13:56:23 -07:00
Daniel Micay
34ae5d70ac partially fix immediate rvalues
The code generation previously assumed a reference could not alter the
value in a way the destructor would notice. This is an incorrect
assumption for `&mut`, and is also incorrect for an `&` pointer to a
non-`Freeze` type.

Closes #7972
2013-10-17 16:50:07 -04:00
Chris Sainty
88ab38cf06 Removed the -Z once_fns compiler flag and added the new feature directive of the same name to replace it.
Changed the frame_address intrinsic to no longer be a once fn.
This removes the dependency on once_fns from std.
2013-10-17 06:22:48 +02:00
bors
c92f2168d4 auto merge of #9833 : alexcrichton/rust/fixes, r=brson
Commits have all the fun details
2013-10-16 18:11:22 -07:00
bors
9d6c251881 auto merge of #9885 : thestinger/rust/vector, r=brson
The goal here is to avoid requiring a division or multiplication to compare against the length. The bounds check previously used an incorrect micro-optimization to replace the division by a multiplication, but now neither is necessary *for slices*. Unique/managed vectors will have to do a division to get the length until they are reworked/replaced.
2013-10-16 15:21:35 -07:00
Daniel Micay
bd7610f3e3 introduce base_and_len fns for element length 2013-10-16 12:28:25 -04:00
Daniel Micay
ef3ec1fe97 rename base_and_len -> base_and_byte_len 2013-10-16 12:00:31 -04:00
Alex Crichton
a84c2999c9 Require module documentation with missing_doc
Closes #9824
2013-10-15 22:27:10 -07:00
Kevin Ballard
73d3d00ec4 path2: Replace the path module outright
Remove the old path.
Rename path2 to path.
Update all clients for the new path.

Also make some miscellaneous changes to the Path APIs to help the
adoption process.
2013-10-15 21:56:54 -07:00
Daniel Micay
e1a26ad271 use element count in slices, not size in bytes
This allows the indexing bounds check or other comparisons against an
element length to avoid a multiplication by the size.
2013-10-15 16:23:28 -04:00
Daniel Micay
aa93381e14 fix overflow on bounds checks
Closes #9020
2013-10-15 16:23:28 -04:00