第7章高水準プログラミング言語
Assemblyアセンブル
Most compilers generate assembly language that must subsequently be processed by an assembler to create an object file. The process of converting a low-level assembly language of the compiler into machine language that the computer can execute in binary form is called assembly. Assembly language is a very low-level language that has a strong correspondence with the machine language but is still humanly readable, as visible in Figure 4.7. Post-compilation assembly has some distinct advantages, such as expediting debugging so that the language is easier to read while making sharing possible among compilers. It also isolates the compiler from changes needed in the format of machine language files; for example, when computer chips change, only the assembler must be changed.
英語のヒント
多くのコンパイラーはアセンブリー言語を生成し、その後、アセンブラーが処理してオブジェクトファイルを作成する必要がある。コンパイラーが出力した低水準のアセンブリー言語を、コンピューターが二進形式で実行できる機械語へ変換する処理を、アセンブルという。アセンブリー言語は、機械語との対応が強い、非常に低水準な言語だが、図4.7に見られるように、人間にも読める。コンパイル後にアセンブルを行うことには、はっきりした利点がある。たとえば、言語を読みやすくしてデバッグを速めるとともに、複数のコンパイラーで共有できるようにする。また、機械語ファイルの形式に必要な変更を、コンパイラーから切り離せる。たとえばコンピューターチップが変わっても、変更する必要があるのはアセンブラーだけである。
A computer’s hardware does not implement the assembly-level instruction set; it is run by the interpreter. The interpreter is written in low-level instructions (microcode or firmware). These items are housed in read-only memory and executed by the hardware.
英語のヒント
コンピューターのハードウェアは、アセンブリー水準の命令セットを実装しているわけではなく、それはインタープリターによって実行される。そのインタープリターは、低水準の命令(マイクロコードまたはファームウェア)で書かれている。これらは読み出し専用メモリに格納され、ハードウェアによって実行される。
Linkingリンク
Language implementations that are intended for the construction of large programs support separate compilation where pieces of the program can be compiled and built independently. Once compilation is complete, these pieces called compilation units are rejoined by a linker.
英語のヒント
大規模なプログラムの構築を目的とする言語実装は、プログラムの部分を独立にコンパイルし、構築できる、分割コンパイルを支える。コンパイルが終わると、コンパイル単位と呼ばれるこれらの部分を、リンカーが再び結合する。
An important function of the linker is to join modules of precompiled libraries of subroutines, such as those in the language API or precompiled user defined functions, into the final program so that they can be separately compiled. If the program draws from a library, it will still need to be linked. Additionally, a static linker produces an executable object file by completing its tasks prior to the program running, while a dynamic linker allows the program to be carried over to memory for execution after it runs.
英語のヒント
リンカーの重要な役割は、言語のAPIや、あらかじめコンパイルした利用者定義関数などの、コンパイル済みサブルーチンライブラリーのモジュールを、最終的なプログラムへ結合することである。これにより、各部分を別々にコンパイルできる。プログラムがライブラリーを利用する場合も、リンクは必要である。また、静的リンカーは、プログラムが動く前に作業を終え、実行可能なオブジェクトファイルを生成する。一方、動的リンカーは、自分が動いた後で、プログラムを実行用のメモリへ移せるようにする。
Runtime Program Management実行時のプログラム管理
The runtime system refers to the set of libraries that the language implementation depends upon for correct operation. The compiler generates program-specific metadata, data about data, that the runtime must inspect to do its job. It is recommended that the compiler and runtime system be developed together to avoid some of the following issues:
英語のヒント
ランタイムシステムとは、言語の実装が正しく動作するために依存する、ライブラリーの集合を指す。コンパイラーは、そのプログラムに固有のメタデータ、すなわちデータについてのデータを生成し、ランタイムは仕事をするためにそれを調べる必要がある。次のような問題を避けるため、コンパイラーとランタイムシステムは一緒に開発することが勧められる。
• Garbage collection: the ability to dynamically destroy program objects when no longer needed and recover their memory
• ガベージコレクション:不要になったプログラムのオブジェクトを動的に破棄し、そのメモリを回収する能力。
• Variable numbers of arguments: for languages that allow differing numbers and types for function arguments only encountered at runtime; languages support function overriding, such as Java, C++, and C#
英語のヒント
• 引数の数の可変性:関数の引数の数や型が異なることを認め、それらに実行時になって初めて出会う言語に関わる。Java、C++、C#などの言語は、関数のオーバーライドを支えている。
• Exception handling: recovery implemented when a program encounters a runtime error or exception
• 例外処理:プログラムが実行時エラーや例外に出会ったときに実施する回復処理。
• Event handling: the ability to respond to runtime occurrences such as a button click or other unpredictable event
英語のヒント
• イベント処理:ボタンのクリックや、ほかの予測できないイベントなど、実行時の出来事へ応答する能力。
• Coroutine and thread implementation: languages where implement can handle concurrency and parallelism
英語のヒント
• コルーチンとスレッドの実装:実装によって並行性と並列性を扱える言語に関わる。
Virtual Machines仮想マシン
A virtual machine (VM) provides a complete program execution environment that is the reproduction of a computer architecture. Many modern languages employ virtual machines as their runtime environment. In general computer science, VMs can refer to a system VM as supplied by such vendors as VMware, which provide all the hardware facilities needed to run a standard OS so that programs built for one OS can run on another.
英語のヒント
仮想マシン(VM)は、コンピューターアーキテクチャーを再現した、完全なプログラム実行環境を提供する。現代の多くの言語は、実行環境として仮想マシンを使う。コンピューターサイエンス全般では、VMは、VMwareなどの企業が提供するシステムVMを指す場合がある。これは、標準的なOSを動かすために必要なハードウェア機能をすべて提供し、あるOS向けに作られたプログラムを、別のOS上で動かせるようにする。
However, with HLLs we make another distinct type of VM called a process VM which provides the environment needed by a single user-level process. Perhaps the first and best example is the Java virtual machine (JVM) because its purpose was to elegantly and efficiently meet a main design goal of the language, which was hardware and OS independence.
英語のヒント
しかし、高水準言語では、別の種類であるプロセスVMを作る。これは、一つの利用者水準のプロセスが必要とする環境を提供する。最初の、そして最もよい例は、Java仮想マシン(JVM)かもしれない。その目的は、この言語の主要な設計目標、つまりハードウェアとOSに依存しないことを、巧みに、効率よく実現することだったからである。
The JVM is a complete runtime manager and interpreter. As we have learned, the Java compiler generates as output an intermediate form of code known as bytecode which is placed in object files with a .class extension. This bytecode is identical for every platform and OS on which Java may be run. The JVM is designed to take the last step of interpreting the bytecode into the machine language and the OS instruction set of the target architecture. It is also the runtime manager for the process. A more recent invention is the Java JIT compiler, which may call for more speed than a JVM interpreter can produce. Figure 7.26 illustrates these principles.
英語のヒント
JVMは、完全な実行時管理機構であり、インタープリターでもある。これまで学んだように、Javaコンパイラーは、バイトコードと呼ばれる中間形式のコードを出力し、それは.class拡張子のオブジェクトファイルに格納される。このバイトコードは、Javaを動かせるすべてのプラットフォームとOSで同一である。JVMは、バイトコードを対象のアーキテクチャーの機械語とOSの命令セットへ解釈する、最後の段階を担うように設計されている。また、そのプロセスの実行時管理も行う。より新しいものとしてJava JITコンパイラーがあり、JVMのインタープリターが実現できる以上の速度を求める場合に使われる。図7.26に、これらの原理を示す。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 7.26 The translation of a code snippet of assembly language into binary machine language. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図7.26 アセンブリー言語の短いコードを、二進の機械語へ翻訳する。(出典:著作権 Rice University、OpenStax、CC BY 4.0ライセンス)
A JVM manages the runtime as well as provides storage management functionality that embraces features, including class structures (metadata), heaps, register sets, thread stacks, and code storage.
英語のヒント
JVMは実行時の管理に加え、記憶領域を管理する機能も提供する。この機能には、クラス構造(メタデータ)、ヒープ、レジスター集合、スレッドのスタック、コードの格納領域などが含まれる。
The Microsoft CLR is a similar animal but directed for the Microsoft .NET platform and all its component languages. CLR and JVM share features including multithreading and stack-based VMs, and both have garbage collection. Additionally, both use platform-independence, are self-descriptive, and contain bytecode notation.
英語のヒント
MicrosoftのCLRも同じような仕組みだが、Microsoft .NETプラットフォームと、それを構成するすべての言語を対象とする。CLRとJVMは、マルチスレッドやスタックに基づくVMなどの特徴を共有し、どちらもガベージコレクションを持つ。さらに、どちらもプラットフォームへの非依存性を利用し、自己記述的で、バイトコード表記を含んでいる。