JP4709394B2 - Method and apparatus for exception handling used in program code conversion - Google Patents

Method and apparatus for exception handling used in program code conversion Download PDF

Info

Publication number
JP4709394B2
JP4709394B2 JP2000614118A JP2000614118A JP4709394B2 JP 4709394 B2 JP4709394 B2 JP 4709394B2 JP 2000614118 A JP2000614118 A JP 2000614118A JP 2000614118 A JP2000614118 A JP 2000614118A JP 4709394 B2 JP4709394 B2 JP 4709394B2
Authority
JP
Japan
Prior art keywords
register
subject
abstract
abstract register
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
JP2000614118A
Other languages
Japanese (ja)
Other versions
JP2002543490A (en
Inventor
アラスデア ラウズソーン
ジョン ハロルド サンダーム
ジェイソン ソウログロウ
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
International Business Machines Corp
Original Assignee
International Business Machines Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from GB9909615A external-priority patent/GB2349486B/en
Application filed by International Business Machines Corp filed Critical International Business Machines Corp
Publication of JP2002543490A publication Critical patent/JP2002543490A/en
Application granted granted Critical
Publication of JP4709394B2 publication Critical patent/JP4709394B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/3017Runtime instruction translation, e.g. macros
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline, look ahead
    • G06F9/3861Recovery, e.g. branch miss-prediction, exception handling
    • G06F9/3863Recovery, e.g. branch miss-prediction, exception handling using multiple copies of the architectural state, e.g. shadow registers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators

Description

【0001】
【発明の属する技術分野】
本発明は、一般にはコンピュータシステムのプログラムコード変換の分野に関し、詳細には、限定はしないが、動的バイナリ変換を使用したエミュレーションの分野に関する。
【0002】
【従来の技術】
コンピュータプログラムはいくつかの異なる形態をとる。通例、プログラムはまず人間のプログラマが容易に理解できる高級言語で書かれる。プログラムは高級言語から、コンピュータのプロセッサおよび関連する構成要素の制御により適した低級言語へとコンパイルされる。
【0003】
しかし、プロセッサを機能させるために、プログラムコードは、ロード動作、シフト演算、加算演算、および記憶動作などプロセッサの基本動作を指示するマシン可読形態で提供しなければならない。
【0004】
より高速に作動するために、プロセッサには、それぞれが基本命令のシーケンスを表す拡張命令セットを使用するものもある。これは複雑命令セットコンピュータ(CISC)として知られる。しかし、第1のプロセッサ専用に書かれた(あるいはコンパイルされた)特定の命令セットを備えるプログラムコードは、各種プロセッサ用の命令セット間の違いのために、大半の場合は他のタイプのプロセッサでは実行することができない。
【0005】
エミュレータは、第1のタイプのプロセッサ(「サブジェクト」プロセッサ)のために書かれたプログラムコードを、第2タイプのプロセッサ(「ターゲット」プロセッサまたは「ホスト」プロセッサ)で実行することを可能にするものである。このエミュレーションプロセスの1形態は、サブジェクトプロセッサに適した実行可能バイナリコードを、ターゲットプロセッサに適した実行可能バイナリコードに変換することからバイナリ変換として知られている。
【0006】
静的バイナリ変換は、プログラム全体を変換してから変換済みプログラムをターゲットプロセッサで実行するものであるが、これにはかなりの遅延が伴う。したがって、ターゲットプロセッサで直ちに実行できるように、動的バイナリ変換を用いてソースプログラムの小セクションを変換するエミュレータが開発されている。
【0007】
ソースコードの大きなセクションは実際には使用されないか、まれにしか使用されないのでこれははるかに効率的である。動的変換システムを用いるエミュレータは、プログラム実行と平行して、需要に応じてソースプログラムの必要な部分だけを変換するために選択する。
【0008】
続いて、本発明の好ましい実施形態に用いることができるエミュレータ用の動的バイナリ変換を簡単に要約して説明する。動的バイナリ変換分野のより詳細な背景は、「PROGRAM CODE CONVERSION(プログラムコード変換)」という名称の本出願人の同時係属出願GB98 22075.9に与えられ、その内容は不用な重複を避けるために参照として本明細書に取り込む。
【0009】
動的バイナリ変換を実行する際、エミュレータはサブジェクトコードにとって、サブジェクトコードが適切なサブジェクトプロセッサで実行されているように見える。エミュレータは、エミュレータが仮想のサブジェクトマシンを提供するために、例えばサブジェクトプロセッサのレジスタを含めてサブジェクトマシンを複製する。エミュレートされたレジスタを本明細書では「抽象レジスタ」と称し、これはサブジェクトコードが使用するサブジェクトプロセッサのレジスタセットに対応する。
【0010】
好ましい動的変換プロセスでは、エミュレータはまずサブジェクトコードの所定の小セクションを、サブジェクトコードの命令を汎用フォーマットで表す中間表現に変換し、任意選択で中間表現の最適化を行い、次いで最適化した中間表現をターゲットプロセッサ用の実行可能バイナリコードに変換する。サブジェクトコードの小セクションは、一意の入口点にある第1の命令で開始し、かつ一意の出口点にある最後の命令で終了する「基本ブロック」に相当することが好ましい。通例、ブロックの最後の命令はジャンプ命令、コール命令または分岐命令(条件つきまたは無条件)である。
【0011】
バイナリ変換の分野では、例外処理に関連して問題が生じる。例外処理とは、それを処理しなければ処理を続けられない条件が発生することを指す。これには、サブジェクトコード中の命令として実行される明示的な例外処理(例えば、あるレジスタの値が第2のレジスタの値より大きい場合には例外が報告される)、および例えば現在使用できないメモリページに対するメモリ読み取り操作または書き込み操作の結果生じる例外処理が含まれる。どちらの場合も、サブジェクトコードに書かれた例外ハンドラに例外処理が報告されることが望ましい。
【0012】
しかし、多くのサブジェクトマシンアーキテクチャ定義では、所定の規則セットに従ってサブジェクトコード命令間の境界で例外処理を報告することを必要としている。例えば、サブジェクトアーキテクチャ定義は、例外処理が報告された場合、それより前のすべてのサブジェクト命令の効果が完了しており、実行されていないサブジェクトコードの最初の命令をその例外処理がポイントし、そのサブジェクト命令またはどの後続の命令からの効果もまだ生じていないことを必要とすることがある。さらに、特定プロセッサのアーキテクチャ定義は、異なるタイプの例外処理について異なる規則を有することもある。
【0013】
バイナリ変換のコンテキストでは、ターゲットプロセッサで実行される、例外処理を報告させるターゲット命令自体は、サブジェクトコードに書かれた例外ハンドラに例外処理を報告する条件を満たさないことは明白である。命令は大抵の場合、それに対応するサブジェクトコードブロック中の命令の順序と比較すると、ターゲットプロセッサでは異なる順序で実行される。これは、第1には、サブジェクトコードがそのために書かれたサブジェクトプロセッサの命令セットと、変換したターゲットコードを実行するターゲットプロセッサ間の違いが原因であり、第2には、通例は変換中に行われる中間表現の最適化が原因である。
【0014】
例外処理は、ターゲットプロセッサで変換済みターゲットコードを実行するのに応答して発生する可能性があり、またターゲットプロセッサでのエミュレータコードの実行中、すなわち変換中にも生じる可能性がある。例外処理をサブジェクト例外ハンドラに報告するために、サブジェクトプロセッサのレジスタの正確な状態を含めて、エミュレータによって表される仮想サブジェクトプロセッサの状態はサブジェクト例外ハンドラから入手可能でなければならない。
【0015】
この問題に対するアプローチの1つとしては、仮想サブジェクトマシンを、変換または実行しているコードセクションに入るときに適用された条件に戻すこと、すなわち仮想サブジェクトマシンを、変換または実行しているサブジェクトコード命令の現在のブロックへの入口点で用いられた(prevailing)条件に戻すことがある。係るアプローチでは例外ハンドラはソースコードブロックの命令を個々に順次ステップスルーして、例外処理を起こしている命令を識別することができる。
【0016】
米国特許第5832205号(Kelly他)は、各サブジェクトコードセクションのエミュレート中に「作業」レジスタのセットを使用するエミュレータを開示する。これら各作業レジスタの内容は、ゲート化したストアバッファを使用して、サブジェクトコードセクションの最後に「オフィシャル」の仮想サブジェクトレジスタセットにコピーされる。したがって、サブジェクトコードセクションのエミュレート中に例外処理が発生した場合、これは作業レジスタにしか影響せず、仮想サブジェクトマシンの状態は、そのサブジェクトコードセクションへの入口点で「オフィシャル」レジスタから回復することができる。
【0017】
しかしながら、上記従来技術のように、「作業」レジスタおよび「オフィシャル」レジスタを使用すると、各サブジェクトコードセクションの終わりに「作業」レジスタからそれに対応する「オフィシャル」レジスタに情報をコピーするため、ターゲットプロセッサにおけるエミュレーションプロセスのオーバーヘッドが著しく増してしまう。
【0018】
【発明が解決しようとする課題】
本発明の目的は、エミュレータ中でサブジェクトレジスタを表す方法を提供することであり、この方法はハンドラ規則に従って例外を正確にサブジェクト例外ハンドラに報告することを可能にし、同時にエミュレータ中のオーバーヘッドを最小限に抑える。本発明の他の目的は、サブジェクトレジスタを表すことにより正確な例外処理を可能にするエミュレーションの方法および装置を提供することである。
【0019】
【課題を解決するための手段】
本発明によると、エミュレータ中でサブジェクトレジスタを表す方法が提供され、この方法は、(a)サブジェクトマシンのサブジェクトレジスタを表す抽象レジスタを、ターゲットマシン内の第1の位置または第2の位置にマップするステップと、(b)第1の位置または第2の位置の一方の内容が、例外処理中にエミュレータが使用するための抽象レジスタの確定的なバージョンを表し、同時に第1の位置または第2の位置の他方が抽象レジスタの推測バージョンを表すように、第1の位置と第2の位置の間で抽象レジスタのマッピングを入れ替えるステップとからなる。
【0020】
サブジェクトコードの所定セクションについて、第1の位置または第2の位置の一方が、そのセクションに入ったときの抽象レジスタの確定値を保持し、かつ、第1の位置または第2の位置の他方が、そのセクション中に使用する抽象レジスタの推測現行値を保持することが好ましい。
【0021】
サブジェクトコードセクションの最後に達すると、第1の位置または第2の位置のそれまでとは逆の位置に抽象レジスタがマップされることが好ましい。そのサブジェクトコードセクションで例外が発生していないことが確認されると、推測バージョンが確定的なものになる。抽象レジスタの推測バージョンの内容が所定のサブジェクトコードセクション中に更新されている場合にのみ、マッピング変更ステップが行われることが理想的である。
【0022】
ステップ(a)は、(a1)それぞれがサブジェクトマシンのレジスタを表す複数の抽象レジスタを提供するステップと、(a2)複数のその抽象レジスタをそれぞれ、ターゲットマシン内の第1の位置セットの各位置か、または第2の位置セットの各位置にマップするステップを含むことが好ましい。ステップ(b)は、第1の位置セットと第2の位置セットそれぞれの間で、各抽象レジスタについてのマッピングを入れ替えるステップを含むことが好ましい。
【0023】
第1の位置および/または第2の位置は、ターゲットマシン内のメモリ位置であることが好ましい。あるいは、第1の位置および/または第2の位置がターゲットマシンのレジスタであることが好ましい。
【0024】
本発明に係る方法は、動的バイナリ変換を実行するエミュレータとともに使用することが好ましい。サブジェクトコードの所定のセクションが、サブジェクトコードの1つまたは複数の基本ブロックを表すと適当である。
【0025】
また本発明によると、サブジェクトプロセッサに適したサブジェクトコードとターゲットプロセッサに適したターゲットコードの間でプログラムコード変換を行うエミュレータが例外処理で使用する方法が提供される。
【0026】
この方法は、それぞれがサブジェクトプロセッサのレジスタを表す少なくとも1つの抽象レジスタ(X、Y)を提供するステップと、(b)前記1つの抽象レジスタまたは各抽象レジスタを、ターゲットプロセッサ内の対応する位置のペアにマップするステップと、(c)サブジェクトコードの所定のセクションについて、第1の位置または第2の位置の一方が、例外処理中にエミュレータが使用する、そのセクションに入ったときの抽象レジスタの確定値を保持し、一方、第1の位置または第2の位置の他方が、そのセクション中にエミュレータが更新を行うための抽象レジスタの推測現行値を保持するように、位置ペアの第1の位置と位置ペアの第2の位置の間で前記1つの抽象レジスタまたは各抽象レジスタのマッピングを入れ替えるステップを含む。
【0027】
さらに、本発明の他の態様によると、本明細書中の著述内容による方法を実行するためのエミュレータ方法およびエミュレータ装置が提供される。本発明はまた、本明細書中の任意の著述内容による方法を実行するようにプログラムした場合はコンピュータに、本明細書中の任意の著述内容による方法を実行するためのコンピュータプログラムに、および本明細書中の任意の著述内容による方法を実行するためのコンピュータ可読命令を含んだコンピュータプログラム製品にわたる。
【0028】
【発明の実施の形態】
本発明をよりよく理解するため、本発明の実施形態がどのように実施されるかを添付の概略図面を参照しつつ示す。
【0029】
図1を参照すると典型的な従来技術による配列が示され、これはサブジェクトプロセッサ11でサブジェクトコード10が直接実行されるサブジェクトマシンの構成を表している。このサブジェクトコードは実行可能バイナリコードであると適切である。しかし、当分野の技術者には知られているように、サブジェクトコードは、サブジェクトコード10とサブジェクトプロセッサ11の間に中間層(コンパイラなど)を有する任意の適切な言語で表すことが可能である。
【0030】
次いで図2を参照すると、典型的な従来技術による構成が示され、これはサブジェクトコード10をターゲットプロセッサ31が実行することを可能にする中間層としてバイナリ変換タイプエミュレータ20を使用する例を表している。本発明の好ましい実施形態は特に、サブジェクトコード10を、ターゲットプロセッサ31で実行可能なターゲットコード30に動的バイナリ変換するエミュレータ20とともに使用することを目的とする。
【0031】
次いで図3を参照すると、好ましい実施形態のエミュレータ20をより詳しく示しており、これはフロントエンド21、コア22、およびバックエンド23から構成される。
【0032】
フロントエンド21は、エミュレートするサブジェクトプロセッサ11固有の構成になっている。フロントエンド21は、サブジェクトコード10の命令を、サブジェクトコードの基本ブロックごとに総称的な中間表現に変換する。基本ブロックはそれぞれ、一意の入口点を表す最初の命令と、一意の出口点にある最後の命令(ジャンプ命令、コール命令、あるいは分岐命令など)との間に連続した命令のセットを含むことが適切である。特に好ましい実施形態では、エミュレータ20は、コード生成および最適化のために1つの単位として選択された2つ以上の基本ブロックからなるグループブロックを選択する。さらに、エミュレータ20は、異なる入口条件下で、サブジェクトコードの同一の基本ブロックを表すアイソブロックをサポートする。サブジェクトコード10の各所定セクションは中間表現のブロック(「IRブロック」)になる。
【0033】
コア22は、本明細書では詳細に説明する必要のない最適化技術を用いて、フロントエンド21が生成した各IRブロックを最適化する。バックエンド23は最適化済みのIRブロックをコア22から持って行き、ターゲットプロセッサ31で実行可能なターゲットコード30を生成する。
【0034】
図4に示すように、使用の際は、サブジェクトコード10の最初の所定セクションは例えば基本ブロック100として識別され、変換モードのターゲットプロセッサ31上で実行されるエミュレータ20によって変換される。ターゲットプロセッサ31は次いで、ターゲットコード30の対応する最適化済みかつ変換済みのブロック300を実行する。
【0035】
好ましいエミュレータ20は、図3のコア22に提供されると適切である複数の抽象レジスタを含み、これはサブジェクトプロセッサ11でサブジェクトコード10を実行するために使用される物理レジスタを表す。抽象レジスタは、サブジェクトプロセッサレジスタに対するサブジェクトコード命令の予測される効果を表すことにより、エミュレート中のサブジェクトプロセッサ11の状態を定義する。
【0036】
図5に示すように、好ましい実施形態では、ここでセットAおよびセットBと称する2セットの抽象レジスタが提供される。初期化時に、これら2セットのうち第1のセット、例えばセットAは「確定」値を保持している。すなわちセットAのレジスタは、エミュレートされるサブジェクトプロセッサ11の物理レジスタの予測される内容を表す、有効であると知られている初期値を保持するものと定義される。
【0037】
この例でセットBと称する抽象レジスタの第2のセットは、初め「推測」値を表すように定義される。すなわち、初期化時に抽象レジスタの第2セット(セットB)もサブジェクトプロセッサ11の物理レジスタの予測される初期内容を保持しているが、このセットBの値は有効であるとは信頼されない。
【0038】
変換プロセス中に、エミュレータ20は抽象レジスタの推測セット(すなわちセットB)を使用するが、この際その内容を更新して、サブジェクトコード10のブロック100の実行後のサブジェクトプロセッサ11の物理レジスタの予測状態を示す。最初のブロックの変換中には、抽象レジスタの確定セット(すなわちセットA)の内容は変更されない。
【0039】
基本ブロック100の変換中または実行中に例外が発生した場合、エミュレータ20はブロック100に入ると、確定データを保持しているとマークされた抽象レジスタ(すなわちセットA)を使用してサブジェクトレジスタの状態を直ちに回復する。すると例外ハンドラはソースコード10のブロック100の命令を順次ステップスルーして、その例外を引き起こしている命令を識別することができる。ここで、抽象レジスタの状態は各命令の後に更新される。したがって、その例外の原因となっているサブジェクトコード命令を識別すると、エミュレータによって表される仮想サブジェクトマシンの状態が、そのマシンの規則に従ってサブジェクトコード例外ハンドラに報告される。サブジェクトコード例外ハンドラは処理プロセスに従って例外を回復し、その例外に適したサブジェクトコード中のポイントに戻る。例えば、例外ハンドラが、エミュレータをソースコード10の次の未実行命令に戻すことが一般的である。変換プロセスまたは実行プロセスはそのポイントから継続させることができる。
【0040】
ターゲットコード300の変換済みブロックを正常に実行すると、推測値を保持するセット(すなわちセットB)のレジスタが更新され、サブジェクトコード10の基本ブロック100の終わりにおけるエミュレート中のサブジェクトプロセッサ11の対応レジスタの予測内容を保持することになる。この時点で、第1セット(すなわちセットA)の抽象レジスタは、サブジェクトコードのブロック100に入ったときのサブジェクトプロセッサの状態を保持しており、第2セット(すなわちセットB)の抽象レジスタは、ブロック100の終わりにおける状態を保持している。ブロック100は正常に変換および実行されているので、今度はセットBの抽象レジスタが確定値を保持していると定義され、セットAの抽象レジスタが推測値を保持していると定義される。
【0041】
セットAおよびセットBの抽象レジスタはレジスタペアを形成することが適切である。セットAの各レジスタは、セットBに対応するパートナレジスタを有する。ペアの一方がその抽象レジスタの確定値を保持し、他方が推測値を保持する。コードの各セクションの終わりにこれら2レジスタの定義を逆にし、次のコードセクション中にはペアの各レジスタが反対の機能を実行するようにする。各レジスタペアの2レジスタの機能を入れ替えることにより、現在のコードセクションについて入口条件を維持する単純で明快な方法が提供される。
【0042】
他の利点としては、各コードセクションを正常に完了した際に、すべての抽象レジスタの状態を更新しなくともよい。そのセクション中に変更されたレジスタだけを更新し、その新機能を示せばよい。特定の抽象レジスタの値がコードセクション中に変更されない場合、その値は次のセクション中もそのまま保たれ、同じ確定機能または推測機能を適宜実行する。
【0043】
次いで図5および図6を参照して、単純化した例示的実施形態を説明する。図5のステップ1で、サブジェクトプロセッサ11のレジスタXを表す第1抽象レジスタ(RegX)は確定値を保持し、第2抽象レジスタ(RegX)は推測値を保持している。抽象レジスタはメモリ位置内に保持されることが適当であり、レジスタXの作業マップは推測バージョンRegXの位置をポイントしている。同様に、この例のレジスタYについては、初めRegYが確定で、RegYが推測である。サブジェクトコード10のブロック100など1つまたは複数の命令の実行後、抽象レジスタのマッピングは図6に示すようにステップ2で更新される。この例では、推測レジスタYの内容が変わり、したがって今度はRegYが後続ブロックで使用される確定バージョンと見なされる。レジスタYのマップは更新され、RegYを推測バージョンとしてポイントする。それに対して、レジスタXはブロック100中の1つまたは複数の命令によっては影響されておらず、したがって、RegXは確定バージョンのままであり、RegXは推測バージョンのままである。
【0044】
コードセクション間でレジスタ内容の連続性を可能にするには、現在のコードセクション中に出会う最初の読み取り操作が、各特定抽象レジスタの確定バージョンを使用することが適切である。確定バージョンは、現在のコードセクションに入ったときのそのレジスタの状態を表しており、したがってそれより前のセクションとの連続性を維持する。その後の読み取り操作も、書き込み操作に出会うまで各抽象レジスタの確定バージョンを使用する。最初の書き込み操作は、各特定抽象レジスタの推測バージョンを使用する。したがって確定バージョンは変更されず、今度は推測バージョンが関連抽象レジスタの現行値を保持する。その後の読み取り操作および書き込み操作は、そのコードセクションの残りにわたって推測バージョンを使用する。
【0045】
上記のように、本発明の好ましい実施形態では、サブジェクトプロセッサ11の各物理レジスタに対応する抽象レジスタが提供され、この抽象レジスタは2つの所定位置にマップされている。抽象レジスタ位置の各ペアのうち1つは確定値を保持し、他方は推測値を保持する。これら2つの位置の機能を容易に逆転させ、確定的な内容を保持する位置を入れ換える。したがって時間のかかるコピー動作が回避される。
【0046】
好ましい実施形態では、各抽象レジスタの2つのバージョンは2セットのメモリ位置にマップすることによって実現され、確定バージョンと推測バージョンの入れ換えは、これら2つの位置間でメモリマッピングを入れ換えることによって実現される。サブジェクトプロセッサの物理レジスタを複製するためにターゲットマシン内に保持されている抽象レジスタのマップを更新することは、変換時に迅速かつ簡単に実行され、変換コードをおそらくは多数回実行する際にオーバーヘッドが生じない。
【0047】
別の好ましい実施形態では、メモリ位置のペアを使用する代わりに、抽象レジスタの確定バージョンおよび推測バージョンの一方または両方をターゲットマシンレジスタのペアに(十分な容量を持ったターゲットマシンに)記憶することができる。
【0048】
本発明の好ましい実施形態の一態様は、分岐、特にサブジェクトコードの現在のブロックから以前に変換されたブロックへの分岐(あるいはループ)間にわたってレジスタ参照を固定するという問題を扱う。コードブロック間の分岐は実際には一般的に見られるものであるが、しばしばサブジェクトコード内の複数の他の位置から同じコードブロックを参照することを伴い、それにより異なる入口条件を生成してしまう。解決法の1つは、抽象レジスタの確定バージョンから推測バージョンに内容をコピーし、これにより入口条件を、以前に変換したコードブロックが使用するのに適したものにすることである。例えば、ブロックを最初に変換したとき、第1のバージョンRegXは確定であった。したがって、変換したコードの同じブロックを後に再び使用することになり、抽象レジスタの第2バージョンRegXが確定である条件の下でそのブロックに達した場合、継続する前にレジスタXの内容をレジスタRegXにコピーしなければならない。これは、以前に変換したコードブロックへの分岐を実施する際にコピーオーバーヘッドを生じさせる。本発明の実施形態で用いる好ましい解決法は、ブロックを今度は分岐時に用いられていた条件で再度変換し、以前に変換したコードの複数のバージョンをそれぞれ入口条件の特定セットと関連付けた状態で存在させることによりこのコピー動作を回避している。より多くの変換作業が必要となるが、実行中のコピーオーバーヘッドは回避される。一般に、サブジェクトコードセクション(任意の数の基本ブロックを含む)をもう1度変換すると、そのループ中に奇数回更新された特定レジスタに必要とされていた補償コピーを行わずに済む。
【0049】
上記の実施形態は動的バイナリ変換を用いるエミュレータに関連するが、当方法は、大きなコードセクションを実行前に変換する静的変換にも応用することができる。静的変換では、変換のために選択されたコードセクションは通例、プログラム全体またはプログラムの大半部分を表す。それでも、コード変換および変換コードの実行中に生じる例外を処理し、少なくともそのコードセクションに入ったときの状態から例外処理を実行できるようにする上記の方法を使用することは都合がよい。さらに当方法は、サブジェクトマシンおよびターゲットマシンが、同一のまたは少なくとも互換性のある命令セットおよびアーキテクチャを有するプログラムコード最適化に応用することができる。
【0050】
本発明は、上記の方法を実行するようにプログラムされた場合はコンピュータに、上記の方法を実行するためのコンピュータプログラムに、および上記の方法を実行するためのコンピュータ可読命令を保持するコンピュータプログラム製品にわたる。
【0051】
読者の注意は、本願との関連で本明細書と同時にあるいは本明細書より以前に提出され、本明細書とともに公衆の便覧に公開されるすべての書類および文書に向けられ、これら書類および文書すべての内容は参照として本明細書に組み込む。
【0052】
本明細書(添付の請求項、要約、および図面を含む)に開示したすべてのフィーチャ、および/またはここに開示する方法またはプロセスのすべてのステップは、そのようなフィーチャおよび/またはステップの少なくとも一部が相互に排他的である組み合わせを除いて、どのような組み合わせで組み合わせてもよい。
【0053】
本明細書(添付請求項、要約、および図面を含む)に開示した各フィーチャは、特別に明確に述べない限り、同じ目的、同等の目的、あるいは類似の目的を満たす代替フィーチャで置き換えてもよい。したがって、特別に明確に述べない場合は、開示する各フィーチャは同等のフィーチャまたは類似のフィーチャの一般的なシリーズの一例にすぎない。
【0054】
本発明は、前述した実施形態(1つまたは複数)の詳細には限定しない。本発明は、本明細書(添付請求項、要約、および図面をいずれも含む)に開示するフィーチャの任意の新しいフィーチャ、または任意の新しい組み合わせ、またはここに開示する方法またはプロセスのステップの任意の新しいステップ、あるいは任意のその新しい組み合わせにわたる。
【図面の簡単な説明】
【図1】 従来技術による典型的なサブジェクトプロセッサの構成の図である。
【図2】 バイナリ変換を使用する典型的なエミュレータの図である。
【図3】 本発明の好ましい実施形態で使用可能なバイナリ変換を使用するエミュレータの構成を表す図である。
【図4】 使用される好ましいバイナリ変換タイプエミュレータの図である。
【図5】 例示的抽象レジスタセットの図である。
【図6】 例示的抽象レジスタセットの図である。
[0001]
BACKGROUND OF THE INVENTION
The present invention relates generally to the field of computer system program code conversion, and more particularly, but not exclusively, to the field of emulation using dynamic binary conversion.
[0002]
[Prior art]
A computer program takes several different forms. Typically, programs are first written in a high-level language that is easily understood by human programmers. The program is compiled from a high-level language into a low-level language that is more suitable for control of the computer's processor and related components.
[0003]
However, in order for the processor to function, the program code must be provided in a machine-readable form that directs the basic operations of the processor, such as load operations, shift operations, addition operations, and storage operations.
[0004]
In order to operate faster, some processors use an extended instruction set, each representing a sequence of basic instructions. This is known as a complex instruction set computer (CISC). However, program code with a specific instruction set written (or compiled) specifically for the first processor is most likely not available on other types of processors due to differences between instruction sets for different processors. Cannot be executed.
[0005]
An emulator allows program code written for a first type of processor (a “subject” processor) to be executed on a second type of processor (a “target” processor or a “host” processor) It is. One form of this emulation process is known as binary conversion because it converts executable binary code suitable for the subject processor into executable binary code suitable for the target processor.
[0006]
Static binary conversion involves converting the entire program and then executing the converted program on the target processor, but this involves considerable delay. Therefore, emulators have been developed that convert small sections of source programs using dynamic binary conversion so that they can be executed immediately on the target processor.
[0007]
This is much more efficient because large sections of the source code are not actually used or rarely used. An emulator using a dynamic conversion system selects to convert only the necessary part of the source program according to demand, in parallel with program execution.
[0008]
The following briefly summarizes and describes a dynamic binary conversion for an emulator that can be used in a preferred embodiment of the present invention. More detailed background on the field of dynamic binary conversion is given in Applicant's co-pending application GB98 22075.9 entitled “PROGRAM CODE CONVERSION”, the contents of which are to avoid unnecessary duplication. Incorporated herein by reference.
[0009]
When performing dynamic binary conversion, the emulator appears to the subject code as if the subject code is being executed by an appropriate subject processor. The emulator duplicates the subject machine, including, for example, a register of the subject processor, in order for the emulator to provide a virtual subject machine. The emulated registers are referred to herein as "abstract registers", which correspond to the subject processor register set used by the subject code.
[0010]
In the preferred dynamic conversion process, the emulator first converts a given subsection of the subject code into an intermediate representation that represents the subject code instructions in a general format, and optionally optimizes the intermediate representation, and then the optimized intermediate Convert the representation into executable binary code for the target processor. The sub-section of the subject code preferably corresponds to a “basic block” starting with the first instruction at the unique entry point and ending with the last instruction at the unique exit point. Typically, the last instruction in a block is a jump instruction, a call instruction or a branch instruction (conditional or unconditional).
[0011]
In the field of binary conversion, there are problems associated with exception handling. Exception handling refers to the occurrence of a condition in which processing cannot be continued unless it is handled. This includes explicit exception handling that is executed as an instruction in the subject code (eg, an exception is reported if the value of one register is greater than the value of the second register), and memory that is not currently available Includes exception handling resulting from memory read or write operations on the page. In either case, it is desirable to report exception handling to the exception handler written in the subject code.
[0012]
However, many subject machine architecture definitions require that exception handling be reported at the boundary between subject code instructions according to a predetermined set of rules. For example, in the subject architecture definition, if exception handling is reported, the effect of all previous subject instructions has been completed and the exception handling points to the first instruction of subject code that has not been executed. It may be necessary that the effect from the subject instruction or any subsequent instruction has not yet occurred. Furthermore, the architecture definition of a particular processor may have different rules for different types of exception handling.
[0013]
In the context of binary conversion, it is clear that the target instruction itself, which is executed by the target processor and reports exception handling, does not satisfy the condition for reporting exception handling to the exception handler written in the subject code. The instructions are often executed in a different order on the target processor when compared to the order of the instructions in the corresponding subject code block. This is primarily due to differences between the subject processor instruction set for which the subject code was written and the target processor executing the converted target code, and secondly, typically during conversion. This is due to the optimization of the intermediate representation performed.
[0014]
Exception handling can occur in response to executing the converted target code on the target processor, and can also occur during execution of the emulator code on the target processor, i.e. during conversion. In order to report exception handling to the subject exception handler, the state of the virtual subject processor represented by the emulator, including the exact state of the subject processor registers, must be available from the subject exception handler.
[0015]
One approach to this problem is to return the virtual subject machine to the conditions applied when entering the section of code being translated or executed, i.e., subject code instructions that are transforming or executing the virtual subject machine. May return to the prevailing condition at the entry point to the current block. In such an approach, the exception handler can step through the instructions of the source code block individually and identify the instruction causing the exception handling.
[0016]
US Pat. No. 5,832,205 (Kelly et al.) Discloses an emulator that uses a set of “work” registers during the emulation of each subject code section. The contents of each of these working registers is copied to the “official” virtual subject register set at the end of the subject code section using a gated store buffer. Thus, if exception handling occurs while emulating a subject code section, this only affects the working register, and the state of the virtual subject machine recovers from the “official” register at the entry point to that subject code section. be able to.
[0017]
However, as in the prior art described above, the use of the “work” and “official” registers copies information from the “work” register to the corresponding “official” register at the end of each subject code section. The overhead of the emulation process in the network will increase significantly.
[0018]
[Problems to be solved by the invention]
An object of the present invention is to provide a method for representing a subject register in an emulator, which allows exceptions to be accurately reported to the subject exception handler according to handler rules, while at the same time minimizing overhead in the emulator. Keep it down. It is another object of the present invention to provide an emulation method and apparatus that allows accurate exception handling by representing a subject register.
[0019]
[Means for Solving the Problems]
According to the present invention, a method for representing a subject register in an emulator is provided, the method comprising: (a) mapping an abstract register representing a subject register of a subject machine to a first location or a second location in a target machine. And (b) the contents of one of the first location or the second location represent a deterministic version of the abstract register for use by the emulator during exception handling, and at the same time the first location or second Swapping the abstract register mapping between the first position and the second position so that the other of the positions represents a speculative version of the abstract register.
[0020]
For a given section of subject code, one of the first position or the second position holds the definite value of the abstract register when entering the section, and the other of the first position or the second position is It is preferable to keep the speculative current value of the abstract register used in the section.
[0021]
When the end of the subject code section is reached, the abstract register is preferably mapped to a position opposite that of the first position or the second position. If it is confirmed that no exception has occurred in the subject code section, the speculative version becomes deterministic. Ideally, the mapping change step is performed only if the content of the speculative version of the abstract register has been updated in a given subject code section.
[0022]
Step (a) includes (a1) providing a plurality of abstract registers each representing a register of the subject machine; and (a2) each of the plurality of abstract registers for each position of the first position set in the target machine. Or preferably mapping to each position of the second set of positions. Step (b) preferably includes the step of swapping the mapping for each abstract register between the first position set and the second position set, respectively.
[0023]
The first location and / or the second location is preferably a memory location in the target machine. Alternatively, the first location and / or the second location is preferably a register of the target machine.
[0024]
The method according to the invention is preferably used with an emulator that performs dynamic binary conversion. Suitably, the predetermined section of the subject code represents one or more basic blocks of the subject code.
[0025]
Further, according to the present invention, there is provided a method for use in exception processing by an emulator that performs program code conversion between a subject code suitable for a subject processor and a target code suitable for a target processor.
[0026]
The method includes providing at least one abstract register (X, Y) each representing a register of a subject processor; and (b) placing the one or each abstract register at a corresponding location in a target processor. Mapping to a pair; and (c) for a given section of subject code, one of the first location or the second location is used by the emulator during exception handling to enter the section of the abstract register Hold the deterministic value, while the other of the first position or the second position holds the estimated current value of the abstract register for the emulator to update in that section. Swap the one abstract register or the mapping of each abstract register between a position and the second position of the position pair Including the step.
[0027]
Furthermore, according to another aspect of the present invention, there is provided an emulator method and an emulator apparatus for performing the method according to the written contents of this specification. The present invention also relates to a computer, when programmed to perform a method according to any written content herein, to a computer program for performing a method according to any written content, and to a book. A computer program product that includes computer readable instructions for performing a method according to any written content in the specification.
[0028]
DETAILED DESCRIPTION OF THE INVENTION
For a better understanding of the present invention, how the embodiments of the present invention are implemented will be described with reference to the accompanying schematic drawings.
[0029]
Referring to FIG. 1, a typical prior art arrangement is shown, which represents the configuration of a subject machine in which a subject code 10 is directly executed by a subject processor 11. The subject code is suitably executable binary code. However, as known to those skilled in the art, the subject code can be expressed in any suitable language having an intermediate layer (such as a compiler) between the subject code 10 and the subject processor 11. .
[0030]
Referring now to FIG. 2, a typical prior art configuration is shown, which represents an example of using the binary conversion type emulator 20 as an intermediate layer that allows the target processor 31 to execute the subject code 10. Yes. The preferred embodiment of the present invention is particularly intended for use with the emulator 20 that dynamically binary converts the subject code 10 into a target code 30 executable on the target processor 31.
[0031]
Referring now to FIG. 3, the emulator 20 of the preferred embodiment is shown in more detail and is comprised of a front end 21, a core 22, and a back end 23.
[0032]
The front end 21 has a configuration unique to the subject processor 11 to be emulated. The front end 21 converts the instructions of the subject code 10 into a generic intermediate representation for each basic block of the subject code. Each basic block may contain a set of consecutive instructions between the first instruction representing a unique entry point and the last instruction (such as a jump instruction, call instruction, or branch instruction) at a unique exit point. Is appropriate. In a particularly preferred embodiment, the emulator 20 selects a group block consisting of two or more basic blocks selected as a unit for code generation and optimization. Furthermore, the emulator 20 supports isoblocks representing the same basic block of subject code under different entry conditions. Each predetermined section of the subject code 10 becomes an intermediate representation block ("IR block").
[0033]
The core 22 optimizes each IR block generated by the front end 21 using optimization techniques that need not be described in detail herein. The back end 23 takes the optimized IR block from the core 22 and generates a target code 30 that can be executed by the target processor 31.
[0034]
As shown in FIG. 4, in use, the first predetermined section of the subject code 10 is identified, for example, as a basic block 100 and converted by the emulator 20 running on the target processor 31 in conversion mode. The target processor 31 then executes the corresponding optimized and transformed block 300 of the target code 30.
[0035]
The preferred emulator 20 includes a plurality of abstract registers that are appropriate when provided to the core 22 of FIG. 3, which represents physical registers used to execute the subject code 10 in the subject processor 11. The abstract register defines the state of the subject processor 11 being emulated by representing the expected effect of the subject code instruction on the subject processor register.
[0036]
As shown in FIG. 5, in the preferred embodiment, two sets of abstract registers, referred to herein as set A and set B, are provided. At initialization, the first of these two sets, eg, set A, holds a “determined” value. That is, the set A registers are defined as holding initial values known to be valid, representing the expected contents of the physical registers of the emulated subject processor 11.
[0037]
A second set of abstract registers, referred to as set B in this example, is initially defined to represent a “guess” value. That is, at initialization, the second set of abstract registers (set B) also holds the expected initial contents of the physical registers of the subject processor 11, but the value of this set B is not trusted to be valid.
[0038]
During the conversion process, the emulator 20 uses an inferred set of abstract registers (i.e., set B), updating its contents to predict the physical registers of the subject processor 11 after execution of the block 100 of subject code 10. Indicates the state. During the conversion of the first block, the contents of the definite set of abstract registers (ie, set A) are not changed.
[0039]
If an exception occurs during the conversion or execution of the basic block 100, the emulator 20 enters the block 100 and uses the abstract register (ie, set A) marked as holding deterministic data, and the subject register's Recover immediately. The exception handler can then step through the instructions in block 100 of source code 10 sequentially to identify the instruction causing the exception. Here, the state of the abstract register is updated after each instruction. Thus, once the subject code instruction causing the exception is identified, the state of the virtual subject machine represented by the emulator is reported to the subject code exception handler according to that machine's rules. The subject code exception handler recovers the exception according to the processing process and returns to the point in the subject code appropriate for the exception. For example, it is common for an exception handler to return the emulator to the next unexecuted instruction in the source code 10. The conversion process or execution process can continue from that point.
[0040]
Upon successful execution of the converted block of the target code 300, the register of the set holding the guess value (ie, set B) is updated and the corresponding register of the subject processor 11 being emulated at the end of the basic block 100 of the subject code 10 The prediction content of is retained. At this point, the first set (ie, set A) of abstract registers holds the state of the subject processor as it entered the block of subject code 100, and the second set (ie, set B) of abstract registers is: The state at the end of block 100 is retained. Since block 100 has been successfully converted and executed, it is now defined that the set B abstract register holds a definite value and the set A abstract register holds an inferred value.
[0041]
Suitably the set A and set B abstract registers form a register pair. Each register in set A has a partner register corresponding to set B. One of the pair holds the final value of its abstract register and the other holds the guess value. The definitions of these two registers are reversed at the end of each section of code so that each register of the pair performs the opposite function during the next code section. Swapping the function of the two registers in each register pair provides a simple and clear way to maintain entry conditions for the current code section.
[0042]
Another advantage is that the state of all abstract registers does not have to be updated upon successful completion of each code section. Only the registers that have changed during the section need to be updated to show the new functionality. If the value of a particular abstract register is not changed during a code section, that value is kept as is during the next section and performs the same deterministic or speculative function accordingly.
[0043]
A simplified exemplary embodiment will now be described with reference to FIGS. In step 1 of FIG. 5, the first abstract register (RegX) representing the register X of the subject processor 11. A ) Holds the final value and the second abstract register (RegX) B ) Holds the estimated value. The abstract register is suitably kept in a memory location, and the working map of register X is a speculative version RegX. B Point to the position. Similarly, for register Y in this example, initially RegY A Is confirmed, RegY B Is speculation. After execution of one or more instructions, such as block 100 of subject code 10, the abstract register mapping is updated in step 2 as shown in FIG. In this example, the contents of speculation register Y have changed, so this time RegY B Is considered the definitive version used in subsequent blocks. Register Y map is updated and RegY A Point to the guessed version. In contrast, register X is not affected by one or more instructions in block 100, and thus RegX A Remains a definitive version, RegX B Remains a speculative version.
[0044]
To allow continuity of register contents between code sections, it is appropriate that the first read operation encountered during the current code section uses a definitive version of each particular abstract register. The definitive version represents the state of that register when it enters the current code section, and therefore maintains continuity with previous sections. Subsequent read operations also use a definitive version of each abstract register until a write operation is encountered. The first write operation uses a speculative version of each specific abstract register. Thus, the definitive version is not changed, and the speculative version now holds the current value of the associated abstract register. Subsequent read and write operations use the speculative version throughout the rest of the code section.
[0045]
As described above, in the preferred embodiment of the present invention, an abstract register corresponding to each physical register of the subject processor 11 is provided, and this abstract register is mapped to two predetermined locations. One of each pair of abstract register locations holds a deterministic value and the other holds a guess value. The functions of these two positions are easily reversed and the positions holding deterministic contents are exchanged. Therefore, a time-consuming copy operation is avoided.
[0046]
In the preferred embodiment, the two versions of each abstract register are implemented by mapping to two sets of memory locations, and the swapping of the definite version and the speculative version is accomplished by swapping the memory mapping between these two locations. . Updating the abstract register map maintained in the target machine to replicate the subject processor's physical registers is done quickly and easily during the conversion, and overhead is incurred when the conversion code is executed many times. Absent.
[0047]
In another preferred embodiment, instead of using a pair of memory locations, one or both of a fixed version and an inferred version of the abstract register is stored in a target machine register pair (on a target machine with sufficient capacity). Can do.
[0048]
One aspect of the preferred embodiment of the present invention addresses the problem of fixing register references across branches, particularly branches (or loops) from the current block of subject code to a previously transformed block. Branches between code blocks are common in practice, but often involve referencing the same code block from multiple other locations in the subject code, thereby creating different entry conditions . One solution is to copy the contents from the definitive version of the abstract register to the speculative version, thereby making the entry condition suitable for use by previously converted code blocks. For example, when the block is first converted, the first version RegX A Was definite. Therefore, the same block of translated code will be used again later, and the second version of the abstract register RegX B If the block is reached under the condition that is definite, register X before continuing B The contents of register RegX A Must be copied to. This creates a copy overhead when performing a branch to a previously converted code block. The preferred solution used in the embodiment of the present invention is to re-transform the block, this time with the conditions used at the time of branching, with multiple versions of the previously translated code each associated with a specific set of entry conditions. This avoids this copying operation. More conversion work is required, but ongoing copy overhead is avoided. In general, transforming the subject code section (including any number of basic blocks) once again eliminates the compensation copy required for the particular register updated odd times during the loop.
[0049]
Although the above embodiments relate to emulators that use dynamic binary translation, the method can also be applied to static translations that transform large sections of code before execution. In static translation, the code section selected for translation typically represents the entire program or the majority of the program. Nevertheless, it is advantageous to use the above method that handles exceptions that occur during code conversion and execution of the conversion code and at least allows exception handling to be performed from the state when it entered the code section. Furthermore, the method can be applied to program code optimization where the subject machine and the target machine have the same or at least compatible instruction set and architecture.
[0050]
The present invention relates to a computer program product that retains computer readable instructions for performing the above method, and a computer program for performing the above method on a computer when programmed to perform the above method. Over.
[0051]
The reader's notice is directed to all documents and documents filed with or prior to this specification in connection with the present application and published to the public handbook along with this specification. Is incorporated herein by reference.
[0052]
All features disclosed in this specification (including the appended claims, abstracts, and drawings), and / or every step of a method or process disclosed herein, are at least one of such features and / or steps. Any combination may be used except for combinations in which the parts are mutually exclusive.
[0053]
Each feature disclosed in this specification (including the appended claims, abstract, and drawings) may be replaced with an alternative feature serving the same purpose, an equivalent purpose, or a similar purpose, unless expressly stated otherwise. . Thus, unless expressly stated otherwise, each feature disclosed is one example of a generic series of equivalent or similar features.
[0054]
The invention is not limited to the details of the embodiment (s) described above. The present invention is directed to any new feature, or any new combination of features disclosed herein (including any of the appended claims, abstracts, and drawings), or any of the steps of the method or process disclosed herein. Over a new step, or any new combination.
[Brief description of the drawings]
FIG. 1 is a diagram of a typical subject processor configuration according to the prior art.
FIG. 2 is a diagram of an exemplary emulator that uses binary conversion.
FIG. 3 is a diagram representing the configuration of an emulator using binary conversion that can be used in a preferred embodiment of the present invention.
FIG. 4 is a diagram of a preferred binary conversion type emulator used.
FIG. 5 is a diagram of an exemplary abstract register set.
FIG. 6 is a diagram of an exemplary abstract register set.

Claims (14)

エミュレータ中でサブジェクトレジスタを表す方法であって、エミュレータ装置が、
(a) サブジェクトマシンのサブジェクトレジスタを表すエミュレートされた抽象レジスタ(X)を、ターゲットマシン内の第1の位置(XA)及び第2の位置(XB)にマップするステップであって、前記第1の位置及び前記第2の位置の一方(XA、XB)が前記抽象レジスタの推測バージョンを表し、一方前記第1の位置及び前記第2の位置の他方(XB、XA)が前記抽象レジスタの確定バージョンを表し、前記第1の位置(XA)及び前記第2の位置(XB)それぞれはメモリ位置またはターゲットレジスタである、前記マップするステップと、
(b) 前記第1の位置及び前記第2の位置の一方(XA、XB)が例外処理中に前記エミュレータによる使用のために前記抽象レジスタの確定バージョンを表し、一方前記第1の位置及び前記第2の位置の他方(XB、XA)が前記抽象レジスタの推測バージョンを表すように、前記第1の位置(XA)と前記第2の位置(XB)との間で抽象レジスタ(X)のマッピングを入れ替えるステップと
を実行することを含み、サブジェクトコードの所定セクションがサブジェクトコードの1つまたは複数の基本ブロックを表し、前記第1の位置(XA)と前記第2の位置(XB)との間で抽象レジスタ(X)のマッピングを入れ替えることが前記基本ブロック単位で交互に行われる、前記方法。
A method for representing a subject register in an emulator, wherein the emulator device is
(A) mapping the emulated abstract register (X) representing the subject register of the subject machine to a first location (XA) and a second location (XB) in the target machine, wherein One of the position 1 and the second position (XA, XB) represents a speculative version of the abstract register, while the other of the first position and the second position (XB, XA) is the abstract register the deterministic version and table, each of the first position (XA) and said second position (XB) is a memory location or target register, and said step of maps,
(B) one of the first position and the second position (XA, XB) represents a definitive version of the abstract register for use by the emulator during exception handling, while the first position and the second position An abstract register (X) between the first position (XA) and the second position (XB) so that the other of the second positions (XB, XA) represents a speculative version of the abstract register. look including to perform the steps of replacing the mapping, predetermined sections of the subject code represents one or more basic blocks of subject code, and the first position (XA) and said second position (XB) Wherein the mapping of the abstract register (X) is alternately performed in units of the basic block .
サブジェクトコードの所定セクションについて、前記第1の位置または前記第2の位置の一方(XA、XB)が、前記所定セクションに入ったときの抽象レジスタ(X)の確定値を保持し、前記第1の位置または前記第2の位置の他方(XB、XA)が、前記所定セクション中に使用するための抽象レジスタ(X)の推測現行値を保持する、請求項1に記載の方法。  For a predetermined section of the subject code, one of the first position or the second position (XA, XB) holds a definite value of the abstract register (X) when entering the predetermined section, and the first position 2. The method of claim 1, wherein one of the second position or the other of the second positions (XB, XA) holds an inferred current value of an abstract register (X) for use during the predetermined section. マッピングを入れ替えるステップ(b)が、サブジェクトコードの前記所定セクションの最後に達すると実行される、請求項2に記載の方法。  The method of claim 2, wherein step (b) of swapping mapping is performed when the end of the predetermined section of subject code is reached. マッピングを入れ替えるステップ(b)が、抽象レジスタ(X)の推測バージョンの内容がサブジェクトコードの前記所定セクション中に更新されている場合にのみ実行される、請求項1又は3に記載の方法。  The method according to claim 1 or 3, wherein the step (b) of swapping mapping is performed only if the content of the speculative version of the abstract register (X) has been updated in the predetermined section of the subject code. ステップ(a)が、
(a1) それぞれがサブジェクトマシンのレジスタを表す複数の抽象レジスタ(X、Y)を提供するステップと、
(a2) 複数の抽象レジスタ(X、Y)をそれぞれ、ターゲットマシン内の第1の位置セットの各位置(XA、XB)または第2の位置セットの各位置(XB、YB)にマップするステップと
を含み、
ステップ(b)が、前記第1の位置セットと前記第2の位置セットの各セットの各位置の間で、少なくとも1つの抽象レジスタ(X、Y)についてのマッピングを入れ替えるステップを含む、請求項1〜4のいずれか一項に記載の方法。
Step (a)
(A1) providing a plurality of abstract registers (X, Y) each representing a subject machine register;
(A2) mapping each of the plurality of abstract registers (X, Y) to each position (XA, XB) of the first position set or each position (XB, YB) of the second position set in the target machine Including and
The step (b) comprises replacing the mapping for at least one abstract register (X, Y) between each position of each set of the first position set and the second position set. The method as described in any one of 1-4.
前記エミュレータが動的バイナリ変換において実行される、請求項1〜のいずれか一項に記載の方法。The emulator is executed in a dynamic binary translation method according to any one of claims 1-5. サブジェクトプロセッサに適したサブジェクトコードと、ターゲットプロセッサに適したターゲットコードとの間でプログラムコード変換を行う方法であって、エミュレータ装置が、
(a) それぞれがサブジェクトプロセッサのレジスタを表すエミュレートされた少なくとも1つの抽象レジスタ(X、Y)を提供するステップと、
(b) 前記1つの抽象レジスタ(X又はY)または各抽象レジスタ(X、Y)をそれぞれ、ターゲットプロセッサ内の対応する位置ペア(XA、XB、YA、YB)にマップするステップであって、前記位置ペアの第1の位置及び第2の位置の一方(例えばXA、YA)が、前記抽象レジスタ(X、Y)の推測現行値を保持し、一方前記第1の位置及び前記第2の位置の他方(例えばXB、YB)が、前記抽象レジスタ(X、Y)の確定値を保持し、前記第1の位置(XA)及び前記第2の位置(XB)それぞれはメモリ位置またはターゲットレジスタである、前記マップするステップと、
(c) サブジェクトコードの所定セクションについて、第1の位置及び第2の位置の一方(例えばXA、YA)が、例外処理中に前記エミュレータによる使用のために前記所定のセクションに入ったときの前記抽象レジスタ(X、Y)の確定値を保持し、一方前記第1の位置及び前記第2の位置の他方(例えばXB、YB)が、前記所定のセクション中に前記エミュレータによる更新のために前記抽象レジスタ(X、Y)の推測現行値を保持するように、前記位置ペアの第1のペア(XA、YA)と前記位置ペアの第2のペア(XB、YB)との間で少なくとも1つの抽象レジスタ(X、Y)のマッピングを入れ替えるステップと
を実行することを含み、サブジェクトコードの所定セクションがサブジェクトコードの1つまたは複数の基本ブロックを表し、前記第1の位置(XA)と前記第2の位置(XB)との間で抽象レジスタ(X)のマッピングを入れ替えることが前記基本ブロック単位で交互に行われる、前記方法。
A method for performing program code conversion between a subject code suitable for a subject processor and a target code suitable for a target processor, wherein an emulator device comprises:
(A) providing at least one emulated abstract register (X, Y) each representing a register of a subject processor;
(B) mapping the one abstract register (X or Y) or each abstract register (X, Y) to a corresponding position pair (XA, XB, YA, YB) in the target processor, respectively; One of the first position and the second position of the position pair (eg, XA, YA) holds the estimated current value of the abstract register (X, Y), while the first position and the second position The other of the positions (for example, XB, YB) holds the final value of the abstract register (X, Y) , and the first position (XA) and the second position (XB) are each a memory position or a target register a step is, to the map at,
(C) For a given section of subject code, when one of the first and second locations (eg, XA, YA) enters the given section for use by the emulator during exception handling Holds a definite value of an abstract register (X, Y), while the other of the first location and the second location (eg, XB, YB) is updated for updating by the emulator during the predetermined section. At least 1 between the first pair (XA, YA) of the position pair and the second pair (XB, YB) of the position pair so as to hold an estimated current value of the abstract register (X, Y) one abstract registers (X, Y) viewing including to perform the steps of replacing the mapping, one or more basic predetermined section of the subject code is subject code It represents the lock, the first position that between the (XA) and said second position (XB) replaced the mapping of abstract register (X) are alternately performed in the basic block unit, said method.
マッピングを入れ替えるステップ(c)が、サブジェクトコードの前記所定セクションの終わりに達すると実行される、請求項に記載の方法。The method of claim 7 , wherein step (c) of swapping mapping is performed when the end of the predetermined section of subject code is reached. マッピングを入れ替えるステップ(c)が、サブジェクトコードの前記所定セクション中に更新された前記1つの抽象レジスタまたは各抽象レジスタ(X、Y)についてのみ実行される、請求項又はに記載の方法。9. A method according to claim 7 or 8 , wherein the step (c) of swapping mapping is performed only for the one abstract register or each abstract register (X, Y) updated during the predetermined section of subject code. エミュレータ装置に、請求項1〜のいずれか一項に記載の方法の各ステップを実行させるコンピュータプログラム。The emulator device, a computer program for executing the steps of the method according to any one of claims 1-9. エミュレータ装置であって、
(a) サブジェクトマシンのサブジェクトレジスタを表すエミュレートされた抽象レジスタ(X)を、ターゲットマシン内の第1の位置(XA)及び第2の位置(XB)にマップし、ここで、前記第1の位置及び前記第2の位置の一方(XA、XB)が前記抽象レジスタの推測バージョンを表し、一方前記第1の位置及び前記第2の位置の他方(XB、XA)が前記抽象レジスタの確定バージョンを表し、前記第1の位置(XA)及び前記第2の位置(XB)それぞれはメモリ位置またはターゲットレジスタであり、
(b) 前記第1の位置及び前記第2の位置の一方(XA、XB)が例外処理中に前記エミュレータによる使用のために前記抽象レジスタの確定バージョンを表し、一方前記第1の位置及び前記第2の位置の他方(XB、XA)が前記抽象レジスタの推測バージョンを表すように、前記第1の位置(XA)と前記第2の位置(XB)との間で抽象レジスタ(X)のマッピングを入れ替え、ここで、サブジェクトコードの所定セクションがサブジェクトコードの1つまたは複数の基本ブロックを表し、前記第1の位置(XA)と前記第2の位置(XB)との間で抽象レジスタ(X)のマッピングを入れ替えることが前記基本ブロック単位で交互に行われる、前記エミュレータ装置。
An emulator device,
(A) Map the emulated abstract register (X) representing the subject register of the subject machine to a first location (XA) and a second location (XB) in the target machine, where the first And one of the second positions (XA, XB) represents a speculative version of the abstract register, while the other of the first position and the second position (XB, XA) is the definition of the abstract register. Version, wherein the first location (XA) and the second location (XB) are each a memory location or a target register;
(B) one of the first position and the second position (XA, XB) represents a definitive version of the abstract register for use by the emulator during exception handling, while the first position and the second position An abstract register (X) between the first position (XA) and the second position (XB) so that the other of the second positions (XB, XA) represents a speculative version of the abstract register. Swap the mapping , where a predetermined section of the subject code represents one or more basic blocks of the subject code, and an abstract register between the first location (XA) and the second location (XB) The emulator device , wherein the mapping of X) is alternately performed in units of basic blocks .
サブジェクトコードの所定セクションについて、前記第1の位置または前記第2の位置の一方(XA、XB)が、前記所定セクションに入ったときの抽象レジスタ(X)の確定値を保持し、前記第1の位置または前記第2の位置の他方(XB、XA)が、前記所定セクション中に使用するための抽象レジスタ(X)の推測現行値を保持する、請求項11に記載のエミュレータ装置。For a predetermined section of the subject code, one of the first position or the second position (XA, XB) holds a definite value of the abstract register (X) when entering the predetermined section, and the first position The emulator device according to claim 11 , wherein the other position (XB, XA) of the second position or the second position holds an estimated current value of the abstract register (X) for use during the predetermined section. サブジェクトプロセッサに適したサブジェクトコードと、ターゲットプロセッサに適したターゲットコードとの間でプログラムコード変換を行うエミュレータ装置であって、
それぞれがサブジェクトプロセッサのレジスタを表すエミュレートされた少なくとも1つの抽象レジスタ(X、Y)と、
エミュレータであって、
前記1つの抽象レジスタ(X、Y)または各抽象レジスタ(X、Y)をそれぞれ、ターゲットプロセッサ内の対応する位置ペア(XA、XB、YA、YB)にマップし、ここで、前記位置ペアの第1の位置及び第2の位置の一方(例えばXA、YA)が、前記抽象レジスタ(X、Y)の推測現行値を保持し、一方前記第1の位置及び前記第2の位置の他方(例えばXB、YB)が、前記抽象レジスタ(X、Y)の確定値を保持し、前記第1の位置(XA)及び前記第2の位置(XB)それぞれはメモリ位置またはターゲットレジスタであり、
サブジェクトコードの所定セクションについて、第1の位置及び第2の位置の一方(例えばXA、YA)が例外処理中に前記エミュレータによる使用のために前記所定のセクションに入ったときの抽象レジスタ(X、Y)の確定値を保持し、一方前記第1の位置及び前記第2の位置の他方(例えばXB、YB)が、前記所定のセクション中に前記エミュレータによる更新のために前記抽象レジスタ(X、Y)の推測現行値を保持するように、前記位置ペアの第1のペア(XA、YA)と前記位置ペアの第2のペア(XB、YB)との間で少なくとも1つの抽象レジスタ(X、Y)のマッピングを入れ替える、前記エミュレータと
を備えており、サブジェクトコードの所定セクションがサブジェクトコードの1つまたは複数の基本ブロックを表し、前記第1の位置(XA)と前記第2の位置(XB)との間で抽象レジスタ(X)のマッピングを入れ替えることが前記基本ブロック単位で交互に行われる、前記エミュレータ装置。
An emulator device that performs program code conversion between a subject code suitable for a subject processor and a target code suitable for a target processor,
At least one emulated abstract register (X, Y) each representing a register of the subject processor;
An emulator,
Each said abstract register (X, Y) or each abstract register (X, Y) is mapped to a corresponding position pair (XA, XB, YA, YB) in the target processor, where One of the first position and the second position (eg, XA, YA) holds the estimated current value of the abstract register (X, Y), while the other of the first position and the second position ( For example, XB, YB) holds a definite value of the abstract register (X, Y), and each of the first position (XA) and the second position (XB) is a memory location or a target register,
For a given section of subject code, one of the first and second locations (e.g., XA, YA) when the exception register (X, YA) enters the given section for use by the emulator during exception handling. Y), while the other of the first position and the second position (eg, XB, YB) is stored in the abstract register (X, Y) at least one abstract register (XB) between the first pair (XA, YA) of the position pair and the second pair (XB, YB) of the position pair so as to hold an estimated current value of Y) , Y) for switching the mapping, and the emulator, wherein a predetermined section of the subject code represents one or more basic blocks of the subject code. The emulator apparatus, wherein the mapping of the abstract register (X) between the first position (XA) and the second position (XB) is alternately performed in units of the basic block .
マッピングを入れ替えることが、サブジェクトコードの前記所定セクションの終わりに達すると実行されるか、或いは、サブジェクトコードの前記所定セクション中に更新された前記1つの抽象レジスタまたは各抽象レジスタ(X、Y)についてのみ実行される、請求項13に記載のエミュレータ装置。Swapping the mapping is performed when the end of the predetermined section of subject code is reached, or for the one abstract register or each abstract register (X, Y) updated during the predetermined section of subject code The emulator device according to claim 13 , wherein the emulator device is executed only.
JP2000614118A 1999-04-27 2000-04-26 Method and apparatus for exception handling used in program code conversion Expired - Lifetime JP4709394B2 (en)

Applications Claiming Priority (6)

Application Number Priority Date Filing Date Title
US29975199A 1999-04-27 1999-04-27
GB9909615A GB2349486B (en) 1999-04-27 1999-04-27 Exception handling in program code conversion.
GB9909615.8 1999-04-27
US09/299,751 1999-04-27
US9909615.8 1999-04-27
PCT/GB2000/001439 WO2000065440A2 (en) 1999-04-27 2000-04-26 Exception handling method and apparatus for use in program code conversion

Publications (2)

Publication Number Publication Date
JP2002543490A JP2002543490A (en) 2002-12-17
JP4709394B2 true JP4709394B2 (en) 2011-06-22

Family

ID=26315473

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000614118A Expired - Lifetime JP4709394B2 (en) 1999-04-27 2000-04-26 Method and apparatus for exception handling used in program code conversion

Country Status (4)

Country Link
EP (1) EP1183601A2 (en)
JP (1) JP4709394B2 (en)
AU (1) AU4580300A (en)
WO (1) WO2000065440A2 (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2002042898A2 (en) * 2000-11-20 2002-05-30 Zucotto Wireless, Inc. Interpretation loop for object oriented processor
GB2411990B (en) * 2003-05-02 2005-11-09 Transitive Ltd Improved architecture for generating intermediate representations for program code conversion
GB0315844D0 (en) * 2003-07-04 2003-08-13 Transitive Ltd Method and apparatus for performing adjustable precision exception handling
US7480902B2 (en) * 2004-07-08 2009-01-20 Intel Corporation Unwind information for optimized programs
WO2008068519A1 (en) * 2006-10-02 2008-06-12 Transitive Limited Computer system and method of adapting a computer system to support a register window architecture
JP5115332B2 (en) * 2008-05-22 2013-01-09 富士通株式会社 Emulation program, emulation device, and emulation method
CN102141929B (en) * 2010-10-21 2014-05-07 华为技术有限公司 Application program running method, simulator, host machine and system
KR101642556B1 (en) * 2012-09-21 2016-07-25 인텔 코포레이션 Methods and systems for performing a binary translation

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1998059292A1 (en) * 1997-06-25 1998-12-30 Transmeta Corporation Improved microprocessor

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63156236A (en) * 1986-12-19 1988-06-29 Toshiba Corp Register device
JPS63245529A (en) * 1987-03-31 1988-10-12 Toshiba Corp Register saving and restoring device
JP2707867B2 (en) * 1991-04-25 1998-02-04 富士ゼロックス株式会社 Register file of digital computer and instruction execution method using it.
JP3302706B2 (en) * 1991-05-31 2002-07-15 日本電気株式会社 Storage device
JPH06180653A (en) * 1992-10-02 1994-06-28 Hudson Soft Co Ltd Interruption processing method and device therefor
US5694564A (en) * 1993-01-04 1997-12-02 Motorola, Inc. Data processing system a method for performing register renaming having back-up capability
JPH0756760A (en) * 1993-08-10 1995-03-03 Fujitsu Ltd Recovery device
JP2513142B2 (en) * 1993-09-07 1996-07-03 日本電気株式会社 Program simulator device
US5812823A (en) * 1996-01-02 1998-09-22 International Business Machines Corporation Method and system for performing an emulation context save and restore that is transparent to the operating system
US5925124A (en) * 1997-02-27 1999-07-20 International Business Machines Corporation Dynamic conversion between different instruction codes by recombination of instruction elements
US5872950A (en) * 1997-03-31 1999-02-16 International Business Machines Corporation Method and apparatus for managing register renaming including a wraparound array and an indication of rename entry ages

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO1998059292A1 (en) * 1997-06-25 1998-12-30 Transmeta Corporation Improved microprocessor

Also Published As

Publication number Publication date
EP1183601A2 (en) 2002-03-06
WO2000065440A2 (en) 2000-11-02
JP2002543490A (en) 2002-12-17
WO2000065440A3 (en) 2001-01-25
AU4580300A (en) 2000-11-10

Similar Documents

Publication Publication Date Title
JP3872809B2 (en) Method and apparatus for enhancing scheduling in advanced microprocessors
US6247172B1 (en) Method for a translation system that aggressively optimizes and preserves full synchronous exception state
US7243213B2 (en) Process for translating instructions for an arm-type processor into instructions for a LX-type processor; relative translator device and computer program product
US20050216701A1 (en) Automatic configuration of a microprocessor
US8578351B2 (en) Hybrid mechanism for more efficient emulation and method therefor
US11803387B2 (en) System for executing new instructions and method for executing new instructions
JP3776132B2 (en) Microprocessor improvements
US8290764B2 (en) Virtualization program, simulation apparatus and virtualization method
KR950033859A (en) Dynamic register management device and method in floating point unit
US20240061682A1 (en) Load chunk instruction and store chunk instruction
JP4709394B2 (en) Method and apparatus for exception handling used in program code conversion
US9465595B2 (en) Computing apparatus, computing method, and computing program
JPH0736848A (en) Information processor and processing method
US5375213A (en) Address translation device and method for managing address information using the device
US6684395B2 (en) Multiple image dynamic bind and load procedure for a multi-processor
US7353163B2 (en) Exception handling method and apparatus for use in program code conversion
US7219335B1 (en) Method and apparatus for stack emulation during binary translation
JP2000353092A (en) Information processor and register file switching method for the processor
US20210247991A1 (en) Simulation method and simulation system
JPH0683615A (en) Computer for executing instruction set emulation
JP2001519954A (en) A host microprocessor having a device for temporarily maintaining the state of a target processor
TW200535698A (en) Apparatus and method for managing registersn in a processor to emulate a portion of a stack
JPH06202877A (en) Emulator
JPWO2009057762A1 (en) Multiprocessor and cache synchronization control method and program thereof
GB2349486A (en) Exception handling in program code conversion

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20070206

A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A711

Effective date: 20090731

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20090824

RD12 Notification of acceptance of power of sub attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7432

Effective date: 20090824

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20100527

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20100715

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20100715

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20101126

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110204

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20110204

A911 Transfer to examiner for re-examination before appeal (zenchi)

Free format text: JAPANESE INTERMEDIATE CODE: A911

Effective date: 20110210

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20110301

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A821

Effective date: 20110301

RD14 Notification of resignation of power of sub attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7434

Effective date: 20110301

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110318

R150 Certificate of patent or registration of utility model

Ref document number: 4709394

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

EXPY Cancellation because of completion of term