Stream: t-compiler

Topic: const-exprs-unfication


Christian Poveda (Oct 22 2018 at 12:51, on Zulip):

I was wondering what else needs to be done to add unification of constant expressions for const-generics

Christian Poveda (Oct 22 2018 at 12:52, on Zulip):

Everyone told me that @Oli is the right person to discuss this :)

oli (Oct 22 2018 at 12:53, on Zulip):

can you link the tracking issue? I don't have anything about this in the cache right now ;)

Christian Poveda (Oct 22 2018 at 12:56, on Zulip):

I think there is no issue for this. It is mentioned on the const-generics RFC but nothing else

oli (Oct 22 2018 at 13:04, on Zulip):

iirc we need at least lazy normalization so that we can start mixing type parameters into the value of constants

Christian Poveda (Oct 22 2018 at 13:09, on Zulip):

When you say normalization, whose evaluation are we talking about?

oli (Oct 22 2018 at 13:10, on Zulip):

the evaluation of types

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

const generics are essentially types

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

I mean someone implemented const generics in typenum

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

we just want to make that efficient and give it first class support afaik

Christian Poveda (Oct 22 2018 at 13:13, on Zulip):

Even then, eventually you'll need some kind of unification for constants to decide when two types are equal, right?

oli (Oct 22 2018 at 13:16, on Zulip):

right... which is easy if everything can be evaluated

oli (Oct 22 2018 at 13:16, on Zulip):

but not if there are type variables left

oli (Oct 22 2018 at 13:16, on Zulip):

Like we know X - X == 0 for X: usize, but the compiler won' t eval it if we don't know the value

Christian Poveda (Oct 22 2018 at 13:17, on Zulip):

Shoudn't constant expression evaluation take care of that?

oli (Oct 22 2018 at 13:17, on Zulip):

not if we don't know X yet

oli (Oct 22 2018 at 13:17, on Zulip):

it might be T::X

oli (Oct 22 2018 at 13:17, on Zulip):

and T might be a generic parameter of the current function

Christian Poveda (Oct 22 2018 at 13:18, on Zulip):

jmmm

Christian Poveda (Oct 22 2018 at 13:26, on Zulip):

but not if there are type variables left

Is there any chance that after normalization there are some type variables hanging around?

Christian Poveda (Oct 22 2018 at 13:26, on Zulip):

Or all the constant parameters will be a bunch of constant values?

oli (Oct 22 2018 at 13:28, on Zulip):

there will always be some left

oli (Oct 22 2018 at 13:28, on Zulip):

if your function is generic and public, you need to keep it generic

Christian Poveda (Oct 22 2018 at 13:30, on Zulip):

Well, let's say normalization happened somehow. Now what's the next step?

oli (Oct 22 2018 at 13:32, on Zulip):

not sure, that's about the extend that I have explored

Christian Poveda (Oct 22 2018 at 13:34, on Zulip):

any speculations?

Christian Poveda (Oct 22 2018 at 13:36, on Zulip):

@eddyb told me the other day that the best point to do unification will be after miri's constant evaluation

oli (Oct 22 2018 at 13:38, on Zulip):

after?

Christian Poveda (Oct 22 2018 at 13:38, on Zulip):

yeah, after

oli (Oct 22 2018 at 13:38, on Zulip):

hmm... I've brought this up multiple times, but we could implement a symbolic execution mode for miri

oli (Oct 22 2018 at 13:39, on Zulip):

then we can just evaluate these "unknown" (generic) values

oli (Oct 22 2018 at 13:39, on Zulip):

the idea has had mixed reception :D

Christian Poveda (Oct 22 2018 at 13:40, on Zulip):

hahahahaha

Christian Poveda (Oct 22 2018 at 13:43, on Zulip):

I had some questions about that part. After constant evaluation, we'll end up with a bunch of MIR code for each constant expression. My question was, how simple would that code be?

oli (Oct 22 2018 at 13:45, on Zulip):

const eval doesn't produce MIR code, it produces a graph of Allocation objects

Christian Poveda (Oct 22 2018 at 13:46, on Zulip):

then we can just evaluate these "unknown" (generic) values

And what will happen if after symbolic evaluation you don't have enough constraints over a generic value?

oli (Oct 22 2018 at 13:48, on Zulip):

you error out if you can't prove something

oli (Oct 22 2018 at 13:48, on Zulip):

mostly array length equality I guess

Christian Poveda (Oct 22 2018 at 13:51, on Zulip):

why are there "mixed receptions", what are the drawbacks?

oli (Oct 22 2018 at 14:05, on Zulip):

Well... symbolic miri is definitely nontrivial

Christian Poveda (Oct 22 2018 at 14:11, on Zulip):

so is just a "there are other things that need attention right now" situation?

oli (Oct 22 2018 at 14:13, on Zulip):

oh definitely

oli (Oct 22 2018 at 14:14, on Zulip):

like const eval needing another N rounds of cleanups :D

Christian Poveda (Oct 22 2018 at 14:14, on Zulip):

hahaha

Christian Poveda (Oct 22 2018 at 14:14, on Zulip):

what if you had an ingnorant with enough initiative?

oli (Oct 22 2018 at 14:15, on Zulip):

idk... seems really big. It took me 3 months of dedicated work to get existential type mostly working. Lazy normalization seems like a whole other level

oli (Oct 22 2018 at 14:16, on Zulip):

The problem is I don't know where to start

oli (Oct 22 2018 at 14:16, on Zulip):

or what small preps we could start doing to make it easier in the future to do the big ones

Christian Poveda (Oct 22 2018 at 14:17, on Zulip):

:(

oli (Oct 22 2018 at 14:17, on Zulip):

I think doing full chalkification is definitely a prerquisite

oli (Oct 22 2018 at 14:17, on Zulip):

so you can probably look at chalk's bugtracker and https://github.com/rust-lang/rust/issues/48049 to see what needs to be done to get that into the compiler

oli (Oct 22 2018 at 14:18, on Zulip):

without chalk I'm fairly certain there's two groups of people: those who don't dare touch lazy normalization and those who could do it but don't see the point without chalk first :D

Christian Poveda (Oct 22 2018 at 14:22, on Zulip):

How much time do you think it will take to do all of this working full-time on it?

Christian Poveda (Oct 22 2018 at 14:22, on Zulip):

well.. having someone working full-time on this

oli (Oct 22 2018 at 14:25, on Zulip):

I don't think this is a one-person job. in FTEs it's probably a year or two, and that is counting in superscalar speedup of multiple people working on it

Christian Poveda (Oct 22 2018 at 14:34, on Zulip):

and of course there is no way to invest several people's time
to work on such a long term project i guess

oli (Oct 22 2018 at 14:35, on Zulip):

there is, but it'll need some companies motivated to pay ppl for compiler work

oli (Oct 22 2018 at 14:35, on Zulip):

I mean https://www.fastly.com/about/jobs/apply?gh_jid=1320541 is a good start

Christian Poveda (Oct 22 2018 at 14:45, on Zulip):

I don't think i'd qualify for that job haha :(

oli (Oct 22 2018 at 14:53, on Zulip):

I wonder how many job offers don't get good applicants because they are written in a way that they scare away many applicants

Christian Poveda (Oct 22 2018 at 14:55, on Zulip):

Well anyway, thank you for the discussion

oli (Oct 22 2018 at 14:59, on Zulip):

I hope I didn't scare you away... I'm not sure why fingers were pointed at me for being of help on const generics.

oli (Oct 22 2018 at 14:59, on Zulip):

But if you want to help out, as said before, chalk is probably the best way to do that right now

Christian Poveda (Oct 22 2018 at 15:02, on Zulip):

I'm not scared at all, I was just wondering if i could do of this my Master's Thesis, but I'll need a shorter project for that. Even though I'd love to help on it

oli (Oct 22 2018 at 15:20, on Zulip):

@Christian Poveda I found the issue I was thinking about: https://github.com/rust-lang/rust/issues/44580

Christian Poveda (Oct 22 2018 at 15:21, on Zulip):

The issue for the RFC?

oli (Oct 22 2018 at 15:28, on Zulip):

yes

Christian Poveda (Oct 22 2018 at 15:32, on Zulip):

I thought that it was blocked until varkor's PR gets merged

Christian Poveda (Oct 22 2018 at 15:36, on Zulip):

This one https://github.com/rust-lang/rust/pull/53645

Christian Poveda (Oct 22 2018 at 15:58, on Zulip):

If you see that any small advance could be done somehow you can count on me :P

Last update: Nov 22 2019 at 04:30UTC