C与抽象机之间的确切关系是什么? [英] What is the precise relationship between C and it's abstract machine?

查看:68
本文介绍了C与抽象机之间的确切关系是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读简而言之C",并且有很多类似的句子:

I am reading "C in a nutshell" and there are alot of sentences similar to this one:

一条语句指定要执行的一个或多个动作,例如为变量分配值,将控制权传递给函数,或跳转到另一条语句.

A statement specifies one or more actions to be performed such as assigning a value to a variable, passing control to a function, or jumping to another statement.

我的问题是执行"这些操作的是什么?

My question is what is the thing that "performs" these actions?

我在这里已经读到C定义为在抽象机上运行,所以我的猜测是抽象机器应该执行这些操作,而像gcc这样的实际编译器的工作是确保如果您根据抽象机的工作方式对程序进行心理评估,那么您将获得与实际使用时相同的结果运行由编译器生成的目标文件(当然,在大多数情况下,不可能在心理上评估程序,但是我正在讲理论上在这里).

I have read here and there that C was defined to run on an abstract machine, so my guess is that the abstract machine is supposed to perform these actions, and the job of actual compilers like gcc is to ensure that if you evaluate a program mentally based on the way the abstract machine works then you would get the same result as when you actually run the object file generated by the compiler (ofcourse evaluating a program mentally is not possible in most cases, but I am speaking theoretically here).

那么抽象机器应该直接在预处理之后解释C代码吗?C应该被翻译成一些吗抽象机解释的中间代码?抽象机和C之间的确切关系是什么?

So is the abstract machine supposed to interpret C code (after preprocessing) directly? Is C supposed to be translated to some intermediate code that the abstract machine interprets? What exactly is the relationship between the abstract machine and C?

什么是程序可见的抽象机状态?只有主存?如果抽象机真的真的直接解释了C代码,那评估声明,它们如何更改抽象机的状态?这最后一系列问题仅是为了给您了解C和抽象机之间的精确关系是什么意思.

What is the state of the abstract machine visible to programs? Only the main memory? If the abstract machine really interprets C code directly, how are declarations evaluated, how do they change the state of the abstract machine? This last series of questions only serves the purpose of giving you an idea of what I mean by precise relationship between C and it's abstract machine.

推荐答案

抽象机器不存在-毕竟,它实际上是抽象(存在于思想中或作为想法,但没有实际或具体的存在".抽象机器是一种完全遵循标准规则的假想机器.

The abstract machine does not exist - it is, after all, literally abstract ("existing in thought or as an idea but not having a physical or concrete existence"). The abstract machine is an imaginary machine precisely follows the rules of the standard.

C程序由编译器编译为一台具体的机器,该机器可能(通常确实)具有与抽象机器不同的语义.实际的机器可能具有推测执行,乱序执行和并行性之类的东西.

The C program is compiled by a compiler to a concrete machine which might (and usually does) have semantics distinct from that of the abstract machine. The actual machine might have things like speculative execution, out-of-order execution and parallelism.

兼容的编译器必须生成一个可执行文件,该可执行文件在运行时将具有 可观察到的行为 为如果 ,则该程序是在遵循标准规则的所述抽象机中执行的.

A compliant compiler must produce an executable that when run, will have the observable behaviour as if the program was executed in the said abstract machine following the rules of the standard.

这篇关于C与抽象机之间的确切关系是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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