既做C#编译器和JIT做什么优化? [英] What kind of optimizations do both the C# compiler and the JIT do?

查看:611
本文介绍了既做C#编译器和JIT做什么优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继续我的C#编译器编译我的班我的工作。此刻,我几乎在我的课本上的编译器优化的章节结束。

I'm continuing my work on my C# compiler for my Compilers Class. At the moment I'm nearly finished with the chapters on Compiler Optimizations in my textbook.

在大多数情况下,我的课本没有考虑到即时编译时,它被写,我很好奇的各种静态,预-jit优化的C#编译器执行与在JIT过程中它做什么?

For the most part, my textbook didn't have Just-In-Time compilation in mind when it was written and I'm curious about the kinds of static, pre-jit optimizations the C# compiler performs versus what it does during the JIT process?

当我跟人有关编译对CLR,我通常听到这样的话:大多数该优化是由JIT完成。

When I talk to people about compiling against the CLR, I typically hear things like, "Most of the optimizations are done by the JIT".

事情像循环展开,常量折叠/传播,指令交织完成预日新通过的C#编译器或抖动处理?如果他们没有被抖动,然后处理不抖动做什么样的优化是唯一一个刚刚即时编译器?

Are things like loop unrolling, constant folding/propagation, instruction interweaving done pre-Jit by C#'s compiler or handled by the jitter? If they aren't handled by the jitter, then what kind of optimizations does the jitter do that are unique to a just-in-time compiler?

推荐答案

我可以想像那里是一个数字,是独一无二的JIT优化;具体而言,这取决于应用程序在运行的环境/背景下的优化。(请注意,以下都是假设的,我不知道肯定,这或任何这些实际执行)

I can imagine there being a number of optimizations that are unique to JIT; specifically, any optimization that depends on the environment/context that the application runs in. (Note, all the following are hypothetical, I do not know for sure, which or if any of these are actually performed)

最无聊的:在JIT可以根据32位/ 64位的底层操作系统,甚至可能取决于具体的处理器架构优化

Most boring: the JIT can optimize depending on 32-bit/64-bit underlying OS, or even potentially depending on the exact processor architecture.

不适用: 更有趣:在JIT可以优化任何东西,只有在调试模式(例如某些条件代码)运行时,该应用程序是不是一个调试环境中运行

最有意思:JIT可以优化出一类条件分支,只有在只读字段依赖,因为至少在理论上该值将永远类的执行过程中发生改变。

Most interesting: the JIT could optimize out conditional branches in a class that depend only on a readonly field, because at least theoretically that value will never change during the execution of the class.

基本上,我会想象,延迟优化,直到JIT一般会是要走的路,因为JIT时候有关于代码的实际运行中,使更多的有意义的优化可能的范围内提供最多的信息。

Basically I'd imagine that deferring optimizations until JIT would generally be the way to go, because at JIT time there is the most information available about the context the code is actually running in, making more meaningful optimizations possible.

这篇关于既做C#编译器和JIT做什么优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆