Commit Graph

19474 Commits

Author SHA1 Message Date
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
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
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
Jordi Boggiano
a0c31ece9d Remove unused variable 2013-06-29 01:00:13 -04:00
Daniel Micay
28a3613a1d fix zsh completion for lint and debug flags
this correctly makes them accept 1 argument, and auto-completes the
comma-separated list of lint flags
2013-06-29 00:58:24 -04:00
Brian Anderson
22b7eb3802 Rename #[mutable] to #[no_freeze] 2013-06-29 00:56:36 -04:00
Brian Anderson
4af7ebcd8f Rename #[non_sendable] to #[no_send] 2013-06-29 00:56:36 -04:00
bors
d681bccb6a auto merge of #7471 : msullivan/rust/default-methods, r=graydon
This fixes a bunch of default method bugs and restructures how vtable resolutions are represented.

(It also adds a depth counter to llvm::type_to_str as a hacky work around for our circular llvm types. This is related in the sense that I needed to do it to make debug tracing not cause rustc to crash after running out of stack space.)
2013-06-28 20:16:56 -07:00
Michael Sullivan
9340fd5ce0 Add tests for some default method things. 2013-06-28 18:09:02 -07:00
Michael Sullivan
c05165bf93 Drop the impl_id field from fn_ctxt. 2013-06-28 18:09:02 -07:00
Michael Sullivan
5943118728 Drop an unused field from param_substs. 2013-06-28 18:09:02 -07:00
Michael Sullivan
0252693db2 Improve handling of trait bounds on a trait in default methods.
This is work on #7460.
It does not properly handle certain cross crate situations,
because we don't properly export vtable resolution information.
2013-06-28 18:09:02 -07:00
bors
e23934645a auto merge of #7466 : thestinger/rust/passes, r=cmr 2013-06-28 16:49:49 -07:00
Michael Sullivan
649b26f7c6 Rework vtable_res to not be flattened. It is now a list of the resolutions for each param. 2013-06-28 16:12:08 -07:00
Michael Sullivan
57ee34c2bf Actually resolve trait bounds on impls. Closes #7266. 2013-06-28 16:12:08 -07:00
Michael Sullivan
817f98085f Make calling methods parameterized on the trait work from default methods.
This is done by adding a new notion of "vtable_self".
We do not yet properly handle super traits.

Closes #7183.
2013-06-28 16:12:08 -07:00
Michael Sullivan
a9e51f5f70 Make default method handling not choke on self region params. Closes #7341. 2013-06-28 16:12:08 -07:00
Michael Sullivan
050d0e6b29 Add a depth counter to llvm::type_to_str to work around infinite llvm types. 2013-06-28 16:12:04 -07:00
Michael Sullivan
47afb33981 Add Float to llvm::type_to_str. 2013-06-28 16:12:04 -07:00
Daniel Micay
2bdc88b652 copy the optimization passes from clang 2013-06-28 18:18:09 -04:00
bors
5d2e565bb1 auto merge of #7437 : brson/rust/winver, r=brson
r? @graydon (or anybody)
2013-06-28 14:14:03 -07:00
bors
f44b951a1e auto merge of #7451 : cmr/rust/rewrite-each-path, r=pcwalton 2013-06-28 12:05:12 -07:00
Corey Richardson
4f044891a5 Fix merge fallout 2013-06-28 14:10:06 -04:00
Corey Richardson
d600601162 Add each_parent to WindowsPath 2013-06-28 10:47:59 -04:00
Corey Richardson
8f5cb92f89 Fix threadring 2013-06-28 10:47:59 -04:00
James Miller
fae4a9e5ba Rename Const/Owned in more places 2013-06-28 10:47:59 -04:00
Patrick Walton
10bcb60e8f librustc: Fix even *MORE* merge fallout! 2013-06-28 10:47:59 -04:00
Patrick Walton
f25f466afe librustc: Fix even *more* merge fallout! 2013-06-28 10:47:59 -04:00
Patrick Walton
f6a27cbda2 libextra: Fix even more merge fallout. 2013-06-28 10:47:56 -04:00
Patrick Walton
3625781cfe librustc: Fix more merge fallout. 2013-06-28 10:44:17 -04:00
Patrick Walton
bb830558d1 librustc: Fix merge fallout and test cases. 2013-06-28 10:44:17 -04:00
Patrick Walton
e015bee286 Rewrite each_path to allow performance improvements in the future.
Instead of determining paths from the path tag, we iterate through
modules' children recursively in the metadata. This will allow for
lazy external module resolution.
2013-06-28 10:44:16 -04:00
Patrick Walton
89eb995195 librustc: Fix merge fallout. 2013-06-28 10:44:16 -04:00