Stream: t-compiler/const-eval

Topic: places-tracking-size


RalfJ (Oct 18 2018 at 11:08, on Zulip):

@Oli while explaining someone places and value on miri over lunch, I had an epiphany: I think we should change the meta field in MemPlace from Option<Scalar> to Size. A place refers to a piece of memory, and it seems perfectly sensible to say that we must know location and size of that piece. It also completes a nice symmetry because we already have an Align in there.

oli (Oct 18 2018 at 11:08, on Zulip):

but the meta field can also be other things, like a vtable pointer

RalfJ (Oct 18 2018 at 11:09, on Zulip):

we only ever need it to compute the size of the place, right?

oli (Oct 18 2018 at 11:09, on Zulip):

oh

oli (Oct 18 2018 at 11:09, on Zulip):

hm

RalfJ (Oct 18 2018 at 11:09, on Zulip):

as in, size_and_align_of

oli (Oct 18 2018 at 11:09, on Zulip):

MemPlace is already "monomorphized", right?

RalfJ (Oct 18 2018 at 11:09, on Zulip):

moreover, we might then want to change memory such that all access happens through a MemPlace. That would group some arguments together nicely, and it'd also have prevented some bugs in my stacked borrows implementation where I accessed memory without doing a value-to-place conversion first, which stacked borrows assume always happens (@Nicole Mazzuca will like this)

RalfJ (Oct 18 2018 at 11:10, on Zulip):

"monomorphized"?

oli (Oct 18 2018 at 11:10, on Zulip):

I remember you wrote some code for what happens during a deref of a fat pointer

oli (Oct 18 2018 at 11:11, on Zulip):

so that the MemPlace's pointer already points to the beginning of a slice's memory

oli (Oct 18 2018 at 11:11, on Zulip):

or in case of a trait object, points to the beginning of the object

RalfJ (Oct 18 2018 at 11:12, on Zulip):

ah no that was something else

RalfJ (Oct 18 2018 at 11:12, on Zulip):

that was for MPlaceTy

RalfJ (Oct 18 2018 at 11:12, on Zulip):

monomorphizing the type

RalfJ (Oct 18 2018 at 11:12, on Zulip):

it is also all gone again because it made no sense

RalfJ (Oct 18 2018 at 11:13, on Zulip):

computing the monomorphized type is sometimes hard (like, in Rc<Debug> we'd have to adapt the subst), and sometimes that type doesn't even exist (what is the type of a str with length 10?)

oli (Oct 18 2018 at 11:13, on Zulip):

right

RalfJ (Oct 18 2018 at 11:15, on Zulip):

I have to say this idea right now excites me quite a bit :)

RalfJ (Oct 18 2018 at 11:15, on Zulip):

we already pass ptr-size-align to memory

RalfJ (Oct 18 2018 at 11:15, on Zulip):

now finally we'd close the gap between that are the MemPlace abstraction

oli (Oct 18 2018 at 11:16, on Zulip):

I just checked, but the only place where I thought we'd have run into trouble is https://github.com/rust-lang/rust/blob/2d81989974a134025be733115574bee8084095b4/src/librustc_mir/interpret/place.rs#L932 and that seems fine

RalfJ (Oct 18 2018 at 11:21, on Zulip):

@Oli hm... no actually that's not fine

RalfJ (Oct 18 2018 at 11:21, on Zulip):

I'll have to see where that gets called

RalfJ (Oct 18 2018 at 11:22, on Zulip):

with this, a MemPlace has less information than the reference did

RalfJ (Oct 18 2018 at 11:22, on Zulip):

which, uh, also kills the ref-place-roundrip. so maybe this doesn't work... :/

oli (Oct 18 2018 at 11:23, on Zulip):

but with the instance you should be able to reconstruct everything?

RalfJ (Oct 18 2018 at 11:23, on Zulip):

but I wouldnt have the instance?

RalfJ (Oct 18 2018 at 11:24, on Zulip):

also reconstructing the length of a Rc<[u8]> seems rather hard

RalfJ (Oct 18 2018 at 11:25, on Zulip):

so I think adding Size makes sense, and then we could use MemPlace for the memory interface, but we'd have to keep the meta around to be able to turn a place into a reference again...

RalfJ (Oct 18 2018 at 11:30, on Zulip):

that ends up making a place larger though, not smaller. and memory really doesn't need that metadata

RalfJ (Oct 18 2018 at 11:30, on Zulip):

hm... so maybe we should first try to get rid of the Local optimization, see if that hurts; that frees the name Place because we dont need places referring to locals any more. then MemPlace could be ptr+size+align, and Place could be MemPlace+meta

RalfJ (Oct 18 2018 at 11:32, on Zulip):

and then all memory accesses have to happen through a MemPlace

oli (Oct 18 2018 at 11:51, on Zulip):

I'm currently busy with experimenting with making AllocId an enum to get rid of global ids for allocations

oli (Oct 18 2018 at 11:51, on Zulip):

but I can take nuking Locals next

RalfJ (Oct 18 2018 at 11:53, on Zulip):

let's see who gets there first, and let's avoid race conditions?^^

Last update: Nov 15 2019 at 20:00UTC