Commit Graph

19511 Commits

Author SHA1 Message Date
bors
040ac2a932 auto merge of #7495 : thestinger/rust/exchange, r=cmr
With these changes, exchange allocator headers are never initialized, read or written to. Removing the header will now just involve updating the code in trans using an offset to only do it if the type contained is managed.

The only thing blocking removing the initialization of the last field in the header was ~fn since it uses it to store the dynamic size/types due to captures. I temporarily switched it to a `closure_exchange_alloc` lang item (it uses the same `exchange_free`) and #7496 is filed about removing that.

Since the `exchange_free` call is now inlined all over the codebase, I don't think we should have an assert for null. It doesn't currently ever happen, but it would be fine if we started generating code that did do it. The `exchange_free` function also had a comment declaring that it must not fail, but a regular assert would cause a failure. I also removed the atomic counter because valgrind can already find these leaks, and we have valgrind bots now.

Note that exchange free does not currently print an error an out-of-memory when it aborts, because our `io` code may allocate. We could probably get away with a `#[rust_stack]` call to a `stdio` function but it would be better to make a write system call.
2013-06-30 15:02:05 -07:00
Daniel Micay
4a29d6eb3f add a closure_exchange_malloc lang item
this makes the exchange allocation header completely unused, and leaves
it uninitialized
2013-06-30 16:24:47 -04:00
Daniel Micay
45e2582e09 stop copying the tydesc in unique box take glue
the only user of the tydesc is ~fn, and it doesn't use this glue code
2013-06-30 16:22:58 -04:00
Daniel Micay
7f3752c7f9 managed: rm RC_EXCHANGE_UNIQUE constant
this is no longer used, exchange allocations do not set ref_count
2013-06-30 16:22:58 -04:00
Daniel Micay
408eef0d89 stop initializing ref_count in exchange_alloc
this is never read anymore
2013-06-30 16:22:55 -04:00
Brian Anderson
ca835f482c rustpkg: Ignore a test that's failing on the dist-snap bot 2013-06-30 13:12:15 -07:00
bors
1790400335 auto merge of #7465 : alexcrichton/rust/issue-4432, r=cmr
This stems from trying to perform as few allocations as possible throughout the standard libraries.

This specializes the `ToStr` implementation for floats/ints separately because it's known that ints will have a maximum length (whereas floats could be very very large).

I also removed a `FIXME` to remove a malloc from the `to_str()` of floats in `repr.rs` because I think that this should be addressed elsewhere. I think that we may not be able to avoid it easily because floats can have such large representations, but regardless this should be a problem with the implementation of `float_to_str_bytes_common` now and not in the `Repr` module.
2013-06-30 09:32:01 -07:00
Alex Crichton
d3155faede Specialize to_str_common for floats/integers in strconv
This allows the integral paths to avoid allocations on the heap

Closes #4424, #4423
2013-06-30 09:19:25 -07:00
Alex Crichton
8fe6fc11de Change char::escape_{default,unicode} to take callbacks instead of allocating
strings
2013-06-30 09:19:02 -07:00
bors
2b3569a1b3 auto merge of #7374 : Jeaye/rust/func_highlight, r=cmr
This allows for highlighting of function calls
for free floating, member, and static functions.
2013-06-30 04:40:37 -07:00
bors
6fcd8bf567 auto merge of #7468 : cmr/rust/great_renaming, r=pcwalton 2013-06-30 01:19:38 -07:00
Daniel Micay
350a5c0b72 vec: use contains_managed instead of box header 2013-06-30 03:45:39 -04:00
Daniel Micay
b91416214e add a contains_managed intrinsic 2013-06-30 03:45:39 -04:00
Daniel Micay
b883d6a54c simplify the exchange allocator
* stop using an atomic counter, this has a significant cost and
  valgrind will already catch these leaks
* remove the extra layer of function calls
* remove the assert of non-null in free, freeing null is well defined
  but throwing a failure from free will not be
* stop initializing the `prev`/`next` pointers
* abort on out-of-memory, failing won't necessarily work
2013-06-30 03:45:36 -04:00
bors
b4bb36490d auto merge of #7490 : mozilla/rust/rollup, r=thestinger
603137c r=cmr
fe10db2 r=bstrie
2013-06-29 23:34:43 -07:00
bors
c6b0d4f516 auto merge of #7475 : Seldaek/rust/fixsplit, r=cmr
I almost got locked out of my machine because I misunderstood the purpose of the function and called it with a limit of uint::max_value, which turned this function into an almost endless loop.
2013-06-29 21:13:31 -07:00
bors
3017343232 auto merge of #7457 : Blei/rust/fix-ffi-floats, r=cmr
Also contains a fix to help ctag pick up macro definitions.
2013-06-29 18:40:33 -07:00
bors
df39932090 auto merge of #7452 : dotdash/rust/self_indirection, r=cmr
Currently we pass all "self" arguments by reference, for the pointer
variants this means that we end up with double indirection which causes
a unnecessary performance hit.

The fix itself is pretty straight-forward and just means that "self"
needs to be handled like any other argument, except for by-value "self"
which still needs to be passed by reference. This is because
non-pointer types can't just be stuffed into the environment slot which
is used to pass "self".

What made things tricky is that there was also a bug in the typechecker
where the method map entries are created. For type impls, that stored
the base type instead of the actual self-type in the method map, e.g.
Foo instead of &Foo for &self. That worked with pass-by-reference, but
fails with pass-by-value which needs the real type.

Code that makes use of methods seems to be about 10% faster with this
change. Also, build times are reduced by about 4%.

Fixes #4355, #4402, #5280, #4406 and #7285
2013-06-29 16:46:32 -07:00
Daniel Micay
052f28a808 minor vec cleanup
* hide the rustrt module in the docs
* remove the useless `traits` module wrapping the `Add` impl
2013-06-29 17:37:03 -04:00
Jordi Boggiano
eee7accedb Add -v/--version support to rust binary 2013-06-29 17:33:18 -04:00
Daniel Micay
d820355213 fix code block syntax in two docstrings 2013-06-29 17:33:18 -04:00
bors
439b13f071 auto merge of #7449 : yichoi/rust/std_test, r=cmr
adjust run.rs test for android to pass check std
2013-06-29 14:31:41 -07:00
bors
c86df3a65c auto merge of #7342 : alexcrichton/rust/assort-cleanup, r=cmr
This removes usage of `&const` throughout the standard libraries/compiler, and it removes some extraneous fields in the AST now that unique boxes always inherit their mutability.
2013-06-29 12:02:05 -07:00
Björn Steinbrink
765a2901d5 Avoid double indirection for the "self" arg in methods
Currently we pass all "self" arguments by reference, for the pointer
variants this means that we end up with double indirection which causes
a unnecessary performance hit.

The fix itself is pretty straight-forward and just means that "self"
needs to be handled like any other argument, except for by-value "self"
which still needs to be passed by reference. This is because
non-pointer types can't just be stuffed into the environment slot which
is used to pass "self".

What made things tricky is that there was also a bug in the typechecker
where the method map entries are created. For type impls, that stored
the base type instead of the actual self-type in the method map, e.g.
Foo instead of &Foo for &self. That worked with pass-by-reference, but
fails with pass-by-value which needs the real type.

Code that makes use of methods seems to be about 10% faster with this
change. Also, build times are reduced by about 4%.

Fixes #4355, #4402, #5280, #4406 and #7285
2013-06-29 19:27:40 +02:00
Björn Steinbrink
ba922a4027 Fix handling of temp cleanups for the "self" argument
The code that tried to revoke the cleanup for the self argument tried
to use "llself" to do so, but the cleanup might actually be registered
with a different ValueRef due to e.g. casting. Currently, this is
worked around by early revocation of the cleanup for self in
trans_self_arg.

To handle this correctly, we have to put the ValueRef for the cleanup
into the MethodData, so trans_call_inner can use it to revoke the
cleanup when it's actually supposed to.
2013-06-29 18:02:21 +02:00
Alex Crichton
3bad7129eb Remove mutability from unique boxes in the AST 2013-06-29 08:36:25 -07:00
Alex Crichton
b29c368674 Removing a lot of usage of '&const' 2013-06-29 08:35:48 -07:00
Corey Richardson
71b1c6ab60 Warning cleanup 2013-06-29 11:20:04 -04:00
Corey Richardson
95d22a3c81 Fix merge fallout 2013-06-29 11:20:04 -04:00
Corey Richardson
1662bd371c Great renaming: propagate throughout the rest of the codebase 2013-06-29 11:20:02 -04:00
bors
88830996d8 auto merge of #7442 : graydon/rust/clean-llvm-trigger, r=brson
This makes it possible for us to trigger the llvm-clean make-target by checking in a change that touches rustllvm/llvm-auto-clean-stamp. Most developers don't need to see or know about this, but when you push a change that "needs an LLVM rebuild", even if not otherwise obvious, this should give a mechanism to do it.
2013-06-29 08:17:01 -07:00
Björn Steinbrink
2a40c5db46 Avoid extra casts for "self" arguments
"self" is always passed as an opaque box, so there's no point in using
the concrete self type when translating the argument. All it does it
causing the value to be casted back to an opaque box right away.
2013-06-29 17:08:20 +02:00
Björn Steinbrink
08a5278bb5 Add missing argument to a debug! call in trans_arg_expr 2013-06-29 15:59:33 +02:00
bors
0326b0abed auto merge of #7441 : catamorphism/rust/testcases_2013-06-27, r=catamorphism 2013-06-29 06:19:46 -07:00
bors
132cfcdd88 auto merge of #7363 : bblum/rust/soundness, r=nikomatsakis
The commit f9a5453 is meant to be a temporary hold-over. Whether or not there is added a way for the compiler to "implicitly borrow" stack closures in this way, there should be a codegen optimization that prevents having to traverse possibly-very-many function pointers to find the function you ultimately wanted to call. I tried to separate out the changes so this particular commit could be straight-up reverted if auto-borrowing happens in the future.

r? @nikomatsakis
2013-06-29 04:22:53 -07:00
bors
c80e3bac3e auto merge of #7244 : bblum/rust/once, r=nikomatsakis
@graydon suggested that once closures not be part of the language for 1.0, but that they might be hidden behind a -Z compile flag as an "experimental feature" in case people decide they need them.

Regardless of whether ```-Z once-fns``` is set, this PR will parse the ```once``` keyword and will prevent closures labelled with it from being called more than once. It will also permit moving out of captured vars in heap closures, just to let the runtime writers stop using ```Cell``` sooner. Setting ```-Z once-fns``` only toggles whether the move-out-from-capture privilege is also given for stack closures.

r? @nikomatsakis
2013-06-29 02:34:43 -07:00
Ben Blum
d7544fe987 Add two tests for the case of the recurring closure. 2013-06-29 04:39:38 -04:00
Ben Blum
d4722e5333 Trade stack closure copyability for type soundness. 2013-06-29 04:39:37 -04:00
Ben Blum
98c169e4e5 Make librust satisfy noncopyable stack closures 2013-06-29 04:39:37 -04:00
Ben Blum
ff4ab9e147 'Borrow' stack closures rather than copying them (e.g., "|x|f(x)"), in prep for making them noncopyable. 2013-06-29 04:39:34 -04:00
Ben Blum
89110fdf55 Use more deriving(IterBytes) in librustc. 2013-06-29 03:58:50 -04:00
Ben Blum
75b80bad63 Use more deriving(IterBytes) in libsyntax. 2013-06-29 03:58:50 -04:00
Ben Blum
5784c0912f Change taskgroup key type to fn:Copy in prep for noncopyable stack closures. 2013-06-29 03:58:50 -04:00
Ben Blum
e0788c7f52 xfail-fast once fn run-pass tests 2013-06-29 03:54:09 -04:00
bors
a229c980c8 auto merge of #7439 : catamorphism/rust/cut-rustpkg-output, r=catamorphism
Closes #7250
2013-06-29 00:49:45 -07:00
bors
4e78c1e2a8 auto merge of #7479 : mozilla/rust/rollup, r=thestinger
22b7eb3 r=thestinger 
28a3613 r=cmr
a0c31ec r=bstrie
ee7307e r=thestinger
b9cf6a3 r=thestinger
2013-06-28 22:25:48 -07:00
Young-il Choi
21cc0ccea1 librustc: fix #7467 for android 2013-06-29 01:22:35 -04:00
Young-il Choi
51beba6cf9 libextra: unused import fix for android AGAIN 2013-06-29 01:22:29 -04:00
blake2-ppc
b9cf6a33d2 iterator: UnfoldrIterator::new should have function argument last
To match Rust conventions and enable use of `do` etc, make sure the
closure is the last argument to the `new` method.
2013-06-29 01:03:37 -04:00
Kevin Ballard
ee7307e6cb Smarter warning in extra::term::Terminal.reset()
Don't spew a warn!() in reset() if num_colors is 0, because
non-color-supporting terminals are legit. Use debug!() there instead.
Continue spewing warn!() if we believe the terminal to support colors.

Use a better warning when the `op` capability can't be found.
2013-06-29 01:02:07 -04:00