]> git.lizzy.rs Git - rust.git/commit
auto merge of #7452 : dotdash/rust/self_indirection, r=cmr
authorbors <bors@rust-lang.org>
Sat, 29 Jun 2013 23:46:32 +0000 (16:46 -0700)
committerbors <bors@rust-lang.org>
Sat, 29 Jun 2013 23:46:32 +0000 (16:46 -0700)
commitdf39932090887086c2d7ce6aa8d30827ab458fd1
treef9fb7d5101731c4d7f8088e1c3277ee2aef19329
parent439b13f071a4a884ea8645670df83162ffcf129f
parent765a2901d58625f5995c9cf4a32c85b6573e12b0
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
src/librustc/middle/trans/meth.rs
src/librustc/middle/typeck/check/method.rs