zoukankan      html  css  js  c++  java
  • 软件体系结构第三章之解释器风格

    我所查到的解释器的定义如下

    解释器:一个解释器通常包括完成解释工作的解释引擎,一个包含将被解释的代码的存储区,一个记录解释引擎当前工作状态的数据结构,以及一个记录源代码被解释执行的进度的数据结构。 

    具有解释器风格的软件中含有一个虚拟机,可以仿真硬件的执行过程和一些关键应用;解释器通常被用来建立一种虚拟机以祢合程序语义与硬件语义之间的差异。

    缺点是执行效率较低   

     

    基本构件:

    –An interpretation engine to do the work (解释器引擎)

    –A memory that contains (存储区):
    •The pseudo-code to be interpreted (被解释的源代码)

    •A representation of the control state of the interpretation engine (解释器引擎当前的内部控制状态的表示:在某个时刻需要执行哪些指令)

    •A representation of the current state of the program being simulated. (程序当前执行状态的表示)

    连接器:
    –Data access (对存储区的数据访问)

    解释器的三种策略


    1)传统解释器

    解释器直接读取源代码并加以执行;
    –ASP

    –Excel

    –JavaScript

    –MATLAB

    –etc

    2)字节码解释器

    在该类解释器下,源代码首先被“编译”为高度压缩和优化的字节码,但并不是真正的机器目标代码,因而与硬件平台无关;

    编译后得到的字节码然后被解释器加以解释;


    例如:
    –Java

    –Perl

    –PHP

    –Python

    –etc

    3)实时编译

    Just-in-time compilation (JIT), refers to a technique where bytecode is compiled to native machine code at runtime (实时编译JIT中,字节码在运行时被编译为本机的目标代码)
    –In a JIT environment, bytecode compilation is the first step, reducing source code to a portable and optimizable intermediate representation. (第一步是编译得到字节码)

    –The bytecode is deployed onto the target system. (字节码被配置到目标系统中)

    –When the code is executed, the runtime environment‘s compiler translates it into native machine code. (当字节码被执行时,运行环境下的编译器将其翻译为本地机器码)


    It has gained attention in recent years, which further blurs thedistinction between interpreters, byte-code interpreters and compilation. (JIT模糊了解释器、字节码解释器和编译器之间的边界与区分)

  • 相关阅读:
    PHP 速度测试函数
    ajax的简单应用之快速入门
    PHP漏洞详解
    jQuery Ajax 实例 全解析
    2007年最后的一天
    近来心情格外的郁闷
    使用 Ajax 实现 lightbox
    GridView删除,编辑应用
    完美的wsus客户端注册表文件
    VISTA桌面显示Internet Explorer
  • 原文地址:https://www.cnblogs.com/vikkii/p/5278576.html
Copyright © 2011-2022 走看看