Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not make CLR register-based? #4775

Closed
ygc369 opened this issue Dec 11, 2015 · 6 comments
Closed

Why not make CLR register-based? #4775

ygc369 opened this issue Dec 11, 2015 · 6 comments

Comments

@ygc369
Copy link

ygc369 commented Dec 11, 2015

CLR is a kind of Virtual Machine(VM), which is stack-based. I think that register-based VM is more effective, that is why android use it. So why not rewrite CLR to make it register-based?

@mikedn
Copy link
Contributor

mikedn commented Dec 11, 2015

I think that register-based VM is more effective

Why?

So why not rewrite CLR to make it register-based?

Why rewrite the CLR instead of improving what's already there?

@ygc369
Copy link
Author

ygc369 commented Dec 11, 2015

Many tests show that register-based VM is more effective.

@mikedn
Copy link
Contributor

mikedn commented Dec 11, 2015

Many tests show that register-based VM is more effective.

Well, show some of those test results here. And be sure that they're not taken out of context.

@jakobbotsch
Copy link
Member

Changing the VM to be register-based would be an extremely breaking change, considering that all code assemblies contains CIL and the CIL spec right now dictates the stack-based format. It's so breaking that I think this is very unrealistic, regardless of performance differences.

@canton7
Copy link

canton7 commented Dec 11, 2015

Also remember that CIL is not executed directly on a VM. The JIT turns it into (register-based) machine code, which is executed by the CPU. So the question is not "is a register-based VM more efficient to run than a stack-based VM?", it's "can a JIT turn a register-based intermediate language into machine code more efficiently than it can a stack-based intermediate language?". My strong suspicion is that no, no it can't.

This would also break so much compatibility that I can't even begin to comprehend it all...

@mikedn
Copy link
Contributor

mikedn commented Dec 11, 2015

Also remember that CIL is not executed directly on a VM.

Indeed, that's why I was hoping to see some relevant test results. Register base representations are more likely to help interpreters rather than compilers. This is because register based representations tend to use fewer instructions and thus an interpreter has less work to do.

For compilers the situation isn't as clear cut. A register based representation may make reading the representation faster (for the same reason it helps interpreters) but it may introduce issues in later compilation stages.

Android's VM isn't really representative in this regard, AFAIK it started life as an interpreter. Besides, most Android devices run on ARM and that may help a register based implementation because the number of hardware registers is known in advance.

@ygc369 ygc369 closed this as completed Dec 13, 2015
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants