-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
8 changed files
with
57 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from cmr
at dotdash@765a290
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging dotdash/rust/self_indirection = 765a290 into auto
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotdash/rust/self_indirection = 765a290 merged ok, testing candidate = ea89b660
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
http://buildbot.rust-lang.org/builders/auto-linux-32-nopt/builds/176
http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/173
http://buildbot.rust-lang.org/builders/auto-linux-64-nopt/builds/175
http://buildbot.rust-lang.org/builders/auto-linux-64-opt-vg/builds/171
http://buildbot.rust-lang.org/builders/auto-linux-all-opt/builds/173
http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/155
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from cmr
at dotdash@765a290
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging dotdash/rust/self_indirection = 765a290 into auto
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dotdash/rust/self_indirection = 765a290 merged ok, testing candidate = df39932
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/157
http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/157
http://buildbot.rust-lang.org/builders/auto-mac-64-nopt/builds/162
http://buildbot.rust-lang.org/builders/auto-mac-64-opt-vg/builds/154
http://buildbot.rust-lang.org/builders/auto-mac-all-opt/builds/158
http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/178
http://buildbot.rust-lang.org/builders/auto-linux-32-nopt/builds/180
http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/177
http://buildbot.rust-lang.org/builders/auto-linux-64-nopt/builds/179
http://buildbot.rust-lang.org/builders/auto-linux-64-opt-vg/builds/175
http://buildbot.rust-lang.org/builders/auto-linux-all-opt/builds/177
http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/159
http://buildbot.rust-lang.org/builders/auto-win-32-nopt/builds/175
765a290
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = df39932