Uh oh!
There was an error while loading. Please reload this page.
Get rid of ConstValue::ScalarPair - #55392
Conversation
rust-highfive
commented
Oct 26, 2018
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
oli-obk
commented
Oct 26, 2018
This can potentially have adverse effects on performance @bors try |
bors
commented
Oct 26, 2018
⌛ Trying commit 8ee3e22d801ed63af310d87ba0bbb0b1913c2c1d with merge a08ddc905730cc7c3a758585abcdd8f0608cdfff... |
oli-obk
commented
Oct 26, 2018
@rust-timer build a08ddc905730cc7c3a758585abcdd8f0608cdfff |
rust-timer
commented
Oct 26, 2018
Success: Queued a08ddc905730cc7c3a758585abcdd8f0608cdfff with parent 694cf75, comparison URL. |
oli-obk
commented
Oct 26, 2018
r? @RalfJung |
bors
commented
Oct 26, 2018
☀️ Test successful - status-travis |
rust-timer
commented
Oct 26, 2018
Finished benchmarking try commit a08ddc905730cc7c3a758585abcdd8f0608cdfff |
oli-obk
commented
Oct 26, 2018
Small gains for tuple-stress and ucd, big losses for coercions. Kinda expected. This is a very naive impl: even though str and slices are now ByRef, if they are used in another constant an "optimization" kicks in and converts it back to Value::ScalarPair only to then write it back into memory. |
Seems this got out of sync with its base PR? I wanted to look at oli-obk/rust@self_managing_allocations...oli-obk:scalar_single to see what is actually new, but that looks like it still contains #55293. Could you rebase? |
jkordish
commented
Nov 7, 2018
Ping from triage. @oli-obk checking for a status update if you have time. thanks! |
oli-obk
commented
Nov 8, 2018
This PR is blocked on #55293 (which in turn is blocked, too) |
oli-obk
commented
Nov 25, 2018
@RalfJung do you think it would be reasonable to not read a Kindof adding a |
RalfJung
commented
Nov 25, 2018
I don't know what you mean -- by either of your two paragraphs.^^
|
oli-obk
commented
Nov 25, 2018
So... scalar pairs are let _1 = "foo";// read `ScalarPair` from `ByRef` constantlet _2 = "bar";// read `ScalarPair` from `ByRef` constantlet _3 = [_1, _2];// write `ScalarPair` to `ByRef` localI want to skip the |
rust-highfive
commented
Nov 28, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Nov 29, 2018
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
bors
commented
Nov 29, 2018
☔ The latest upstream changes (presumably #56340) made this pull request unmergeable. Please resolve the merge conflicts. |
RalfJung
commented
Dec 3, 2018
@oli-obk I still don't get it. Are you suggesting we change something in the miri engine? That seems unnecessary, the issue here is just about how to communicate the results of computation to the rest of the compiler. But if you do, could you spell out which miri engine types/operations you intent to change how? The way I see it, we have |
oli-obk
commented
Dec 3, 2018
I agree, but what I'm suggesting is to do this the first time we actually try to read an immediate from that local and not do any work before that. I have (since writing #55392 (comment)) implemented a scheme that skips even that step. Instead of creating a This is basically a step all the way back to As a next step I am considering doing the same for |
Yes that's exactly what I was saying? When you need to do work on something, you convert it to an immediate form. The entire rest of the codebase doesn't even have no know that this form exists.
I am increasingly confused. The goal, I thought, was to remove variants from
But what about subslices...? You lost me entirely, I'm afraid. |
oli-obk
commented
Dec 3, 2018
No, you want to convert it the moment you read from the global to a local. I want to convert it the first time someone wants to read an immediate from that local. So where we currently move from But as I said, I have moved to a different scheme.
That's not gonna work out of performance reasons. I tried, and each time the perf results were quite clear that we e.g. don't want to have to read array lengths from
Currently a non-issue, so I left it out of the implementation. |
Wait, why are we talking about locals? Inside miri, everything already works.
Okay. So now we are talking about another scheme I don't understand either. Hooray :D
There is no reason that Instead of guessing in Another invariant we fail to encode in the type is that
What does this mean? |
oli-obk
commented
Dec 4, 2018
that... makes so much more sense than any of the crazyness I have come up with and failed to make nice.
Encoding fat pointers in constants by using |
RalfJung
commented
Dec 4, 2018
Ah I see. Where does that happen though? And can we do something similar to what I proposed for array lengths there? |
oli-obk
commented
Dec 4, 2018
I don't think so, every constant in MIR can possibly be a @eddyb suggested once to do some constant folding during |
Those constants are only ever accessed for codegen, right? The only difference between what we do now and what we would do then is we would access the EDIT: Okay, there's also |
RalfJung
commented
Dec 4, 2018
But until we have figured that out, here's how I imagine things could look: enumLazyConstValue<'tcx,T>{Unevaluated(DefId,&'tcxSubsts<'tcx>),Evaluated(T),}enumConstValue<'tcx>{Scalar(Scalar),ScalarPair(Scalar,Scalar),Indirect(AllocId,&'tcxAllocation,Size),}
Does that make sense? |
oli-obk
commented
Dec 4, 2018
Yes, this is a 1:1 copy of what I prototyped on the train this morning :D |
eddyb
commented
Dec 4, 2018
@RalfJung While that's nicer to work with, it's a bit sad, because it means |
oli-obk
commented
Dec 4, 2018
We have two ways that I can come up with off the top of my head to have our cake and eat it, too:
|
based on #55293 (only the last commit is part of this PR)