インタプリタ

出典: フリー百科事典『ウィキペディア(Wikipedia)』

: interpreter[1]



(一)

(二)

(三)[ 1]



CPU

[]


: x86bin

[]


: instruction body[2] ADD2 C push(pop() + pop()) 

[]


: dispatch[2][3]SwitchJumpJump

[]


2

1





1+#

1990





[ 2]

[]






EDSAC The Preparation of Programs for an Electronic Digital Computer  chapter 2  § 2-22 Interpretive subroutines [4]

 Lisp  IBM 704 Lisp [5][6][7]

1960Javap

[]

[]




REPLReadEvalPrintLoopBASIC

[]


AOT

JITJITWebHTML

[]


AOT1JIT

[]


JIT

[]




1

×

CPU[8]2000CPU2010CPU: x86 Haswell[9]

 LISP  BASIC 1使PBASIC 516361018 BASIC 






バリエーション[編集]

スレッデッドコード[編集]

それ自体はインタプリタの手法とも言えるしコンパイラの手法とも言える。そのどちらと言うよりも、中間表現の1種類というべきかもしれない。仮想関数テーブルテーブルジャンプによるフロー制御に似ていなくもない。

スレッデッドコードは、呼び出されるべきサブルーチンのアドレスのみが順番に羅列されたものである。「直接スレッディング」の場合は、そのアドレスが指す先は機械語のサブルーチンである。他にもいくつかのバリエーションがある。「サブルーチン・スレッディング」は最も違うタイプのバリエーションで、アドレスのみではなく、機械語のCALL命令として羅列するので、ハードウェアのプロセッサで直接実行できる。これは実行のオーバーヘッドは極小だが、メモリ効率は悪い[注 3]。サブルーチン・スレッディング以外のスレッデッドコードは、きわめて単純なインタプリタで実行できる。Forthでは「内部インタプリタ」と呼んでいる(これは、Forth言語自体を実装しているインタプリタである「外部インタプリタ」と対になっている)。

バイトコード[編集]


Java  .NET Framework 使使

 Emacs Lisp LISP  C Open Firmware 使 Forth 使FP


[]


1 (AST) 使[10]1AST[11]AST

AST[12]CRuby 1.81.9 YARV 

[]


 (JIT) AST使1980 Smalltalk 使[13]

Java.NET FrameworkJavaScript  JIT 

[]


 CoffeeScript  JavaScript JavaScript 

[]


使

 LISP 

使

: 

[]


CCMS-DOSC-TerpC/C++CINTCh

[]


IBM 550 Numeric Interpreter (1930)  IBM 557 Alphabetic Interpreter (1954) 

プログラミング言語[編集]

インタプリタとコンパイラ方式が併用のもの[編集]

「共通言語ランタイム」のバイナリー・コードにコンパイルされるもの[編集]

Erlang VM」(BEAM)のバイナリー・コードにコンパイルされるもの[編集]

Java仮想機械」のバイナリー・コードにコンパイルされるもの[編集]

JavaScript に変換されるもの[編集]

Lua VM」のバイナリー・コードにコンパイルされるもの[編集]

「Pコードマシン」のバイナリー・コードにコンパイルされるもの[編集]

Parrot」のバイナリー・コードにコンパイルされるもの[編集]

Smalltalk VM」のバイナリー・コードにコンパイルされるもの[編集]

VBAのPコードにコンパイルされるもの[編集]

脚注[編集]

注釈[編集]

  1. ^ この意味では、CPUは機械語インタプリタであると見ることができる。
  2. ^ 現在では、「インタプリタ / コンパイラ」という区分に関しては状況が変わっており、[誰?]に言わせると『だが、それらは必ずしも相互排他的に2つに分類できるわけではない。なぜなら多くのインタプリタ方式の処理系は、コンパイラが行っているような変換も内部で行っているからだ。[要出典]」とも言われ、『「インタプリタ言語」あるいは「コンパイラ言語」といった呼称も見掛けることがあるが、これらは単にその言語の規範的実装がインタプリタかコンパイラかを示しているに過ぎない(実際、詳しく調べれば、実験的な程度の実装まで含めれば両方ともあるということも多い)。』という見解も出てくることになる。高水準言語は基本的に抽象であり、(理想的には)特定の実装からは独立している。しかし、動的プログラミング言語のようにインタプリタでの実装が向いている方向性の言語、あるいはその逆もあるということは確かである。
  3. ^ つまり、近年では高速化にはキャッシュのほうが重要なので、高速化に有利か否かはわからない。

出典[編集]



(一)^ bit bit 199081519ISBN 4-320-02526-1 

(二)^ ab"An interpreter dispatches a virtual instruction body to emulate each virtual instruction in turn." Zaleski (2007). YETI: a GraduallY Extensible Trace Interpreter. University of Toronto.

(三)^ "we defined dispatch as the mechanism used by a high level language virtual machine to transfer control from the code to emulate one virtual instruction to the next." Zaleski (2007). YETI: a GraduallY Extensible Trace Interpreter. University of Toronto.

(四)^ 

(五)^ Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I 

(六)^ History of Lisp §3 S.R. Russell noticed that eval could serve as an interpreter for LISP, promptly hand coded it, and we now had a programming language with an interpreter. () The unexpected appearance of an interpreter ...()

(七)^ Hackers & Painters185 eval  eval  eval  IBM 704  LISP  LISP 

(八)^ "Conventional wisdom states that this indirect jump incurs a major performance degradation on deeply pipelined architectures because it is hardly predictable" Rohou, et al. (2015). Branch Prediction and the Performance of Interpreters - Dont Trust Folklore. International Symposium on Code Generation and Optimization, Feb 2015, Burlingame, United States.

(九)^ "we show that the accuracy of indirect branch prediction is no longer critical for interpreters." Rohou, et al. (2015). Branch Prediction and the Performance of Interpreters - Dont Trust Folklore. International Symposium on Code Generation and Optimization, Feb 2015, Burlingame, United States.

(十)^ AST intermediate representations  Lambda the Ultimate forum

(11)^ A Tree-Based Alternative to Java Byte-Codes  

(12)^ Annoucing SquirelFish

(13)^ L. A. Efficient implementation of the Smalltalk-80 systemProceedings of 11th POPL symposium1984

関連項目[編集]

外部リンク[編集]

この記事は2008年11月1日以前にFree On-line Dictionary of Computingから取得した項目の資料を元に、GFDL バージョン1.3以降の「RELICENSING」(再ライセンス) 条件に基づいて組み込まれている。