JP2015210740A - Compilation method, compilation device, and compilation program - Google Patents
Compilation method, compilation device, and compilation program Download PDFInfo
- Publication number
- JP2015210740A JP2015210740A JP2014093212A JP2014093212A JP2015210740A JP 2015210740 A JP2015210740 A JP 2015210740A JP 2014093212 A JP2014093212 A JP 2014093212A JP 2014093212 A JP2014093212 A JP 2014093212A JP 2015210740 A JP2015210740 A JP 2015210740A
- Authority
- JP
- Japan
- Prior art keywords
- methods
- intermediate language
- code
- merge candidate
- data
- 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.)
- Granted
Links
Images
Abstract
Description
本発明は、コンパイル方法、コンパイル装置およびコンパイルプログラムに関する。 The present invention relates to a compiling method, a compiling device, and a compiling program.
従来、計算科学の分野、とりわけHPC(High Performance Computing)の世界でのソフトウェア開発は、主にFortranによりコーディングされてきた。しかし、近年は、計算科学の分野でも、C言語は勿論のこと、生産性・再利用性の高さの観点から、C++やJava(登録商標)といったオブジェクト指向言語によりコーディングされたソフトウェアが増えている。 Conventionally, software development in the field of computational science, especially in the world of High Performance Computing (HPC), has been mainly coded by Fortran. However, in recent years, in the field of computational science, not only C language but also software coded in object-oriented languages such as C ++ and Java (registered trademark) has been increasing from the viewpoint of high productivity and reusability. Yes.
先行技術としては、例えば、メソッドへのリファレンスをオブジェクトベースのプログラミングシステムにおいてカプセル化し、そのリファレンスが安全であることを保証するための技術がある。また、インタプリタによってオブジェクト指向プログラムを実行するスクリプト言語処理装置において、複数のオブジェクトに対して同一のメソッドを記述する場合に、グループ化した記述を可能とする技術がある。 Prior art includes, for example, a technique for encapsulating a reference to a method in an object-based programming system and ensuring that the reference is safe. In addition, there is a technique that enables grouped description when the same method is described for a plurality of objects in a script language processing apparatus that executes an object-oriented program by an interpreter.
しかしながら、従来技術によれば、オブジェクト指向言語でコーディングされたソースプログラムには、オブジェクト指向言語の言語的特徴から大量のメソッドが含まれることが多く、ソースプログラムのコンパイル時間の増加を招くという問題がある。 However, according to the prior art, a source program coded in an object-oriented language often includes a large number of methods due to the linguistic features of the object-oriented language, which increases the compilation time of the source program. is there.
一つの側面では、本発明は、ソースプログラムのコンパイル時間の短縮化を図るコンパイル方法、コンパイル装置およびコンパイルプログラムを提供することを目的とする。 In one aspect, an object of the present invention is to provide a compiling method, a compiling device, and a compiling program for shortening the compiling time of a source program.
本発明の一側面によれば、ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、前記複数のマージ可能メソッドのマージ処理を行うコンパイル方法、コンパイル装置およびコンパイルプログラムが提案される。 According to one aspect of the present invention, a plurality of merge candidate methods are extracted from a plurality of methods in an intermediate language code obtained by syntax analysis and semantic analysis of a source program, based on at least an inheritance relationship or a name, Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, a plurality of mergeable methods that can be merged are extracted from the plurality of merge candidate methods, and the plurality of mergeable methods are merged. A compiling method, a compiling device, and a compiling program are proposed.
本発明の一態様によれば、ソースプログラムのコンパイル時間の短縮化を図ることができるという効果を奏する。 According to one aspect of the present invention, there is an effect that it is possible to shorten the compile time of the source program.
以下に図面を参照して、本発明にかかるコンパイル方法、コンパイル装置およびコンパイルプログラムの実施の形態を詳細に説明する。 Exemplary embodiments of a compiling method, a compiling device, and a compiling program according to the present invention will be described below in detail with reference to the drawings.
(コンパイル方法の一実施例)
図1は、実施の形態にかかるコンパイル方法の一実施例を示す説明図である。図1において、コンパイル装置100は、ソースプログラムscをコンパイルするコンピュータである。ソースプログラムscは、オブジェクト指向言語でコーディングされたソースコードを含む。オブジェクト指向言語としては、例えば、Java、C++などがある。
(One example of compiling method)
FIG. 1 is an explanatory diagram of an example of the compiling method according to the embodiment. In FIG. 1, a compiling
コンパイラのコンパイル処理は、大きく分けると、構文・意味解析区、最適化区およびコード生成区に区分けされる。構文・意味解析区では、ソースプログラムscを入力として、ソースプログラムscの構文解析および意味解析が行われ、構文・意味解析区内のインターフェースである中間言語Iコードが生成される。 The compiler compilation process is roughly divided into a syntax / semantic analysis section, an optimization section, and a code generation section. In the syntax / semantic analysis section, the source program sc is input, and the source program sc is subjected to syntax analysis and semantic analysis, and an intermediate language I code that is an interface in the syntax / semantic analysis section is generated.
中間言語Iコードには、ソースプログラムsc内のメソッド(関数)が表現される。メソッドとは、ある処理を実現するための命令のかたまりである。また、構文・意味解析区では、中間言語Iコードを入力として、コンパイラ内のインターフェースである中間言語IIコードが生成される。 Methods (functions) in the source program sc are expressed in the intermediate language I code. A method is a group of instructions for realizing a certain process. Further, in the syntax / semantic analysis section, an intermediate language II code which is an interface in the compiler is generated with the intermediate language I code as an input.
最適化区では、中間言語IIコードを入力として、中間言語IIコードの最適化処理が行われる。最適化処理では、例えば、中間言語IIコードから不要と見なされるメソッドが削除される。不要と見なされるメソッドとしては、例えば、翻訳単位に限定した静的メソッドで使用されていないメソッドが挙げられる。 In the optimization section, the intermediate language II code is input and the intermediate language II code is optimized. In the optimization process, for example, a method deemed unnecessary from the intermediate language II code is deleted. Examples of methods that are considered unnecessary include methods that are not used in static methods limited to translation units.
コード生成区では、中間言語IIコードを入力として、オブジェクトファイルfが生成される。オブジェクトファイルfは、機械語により命令とデータが表現されたオブジェクトコードを含むファイルである。オブジェクトファイルfは、例えば、リンカと呼ばれるプログラムに渡され、最終的に実行プログラムが生成される。 In the code generation area, the object file f is generated with the intermediate language II code as an input. The object file f is a file including an object code in which instructions and data are expressed in machine language. The object file f is transferred to, for example, a program called a linker, and finally an execution program is generated.
ここで、オブジェクト指向言語は、FortranやC言語などに比べて、高い生産性や再利用性を得ることができるプログラミング言語である。一方で、オブジェクト指向言語では、オブジェクト指向言語の言語的特徴であるカプセル化、オーバーライド、オーバーロードの概念から、データ型ごとにデータの操作や処理ロジックをまとめたメソッドが多く作成される。 Here, the object-oriented language is a programming language that can obtain high productivity and reusability as compared to the Fortran or C language. On the other hand, in an object-oriented language, many methods that summarize data operations and processing logic for each data type are created from the concept of encapsulation, override, and overload, which are linguistic features of the object-oriented language.
さらに、オブジェクト指向言語のテンプレート関数では、テンプレート引数の型や値によって、処理ロジックが同じメソッドがコンパイラによって複数作成される。カプセル化とは、データとデータを操作する手続き(メソッド)を一体化して「オブジェクト」として定義し、オブジェクト内の細かい仕様や構造を外部から隠蔽することである。クラス内のメソッドは、カプセル化の概念で記述されたものであるといえる。クラスとは、オブジェクトの雛型を定義したものであり、オブジェクトがどのようなフィールド(変数)/メソッドを持っているかを記述したものである。 Further, in the template function of the object-oriented language, a plurality of methods having the same processing logic are created by the compiler depending on the type and value of the template argument. Encapsulation is to unify data and procedures (methods) for manipulating data, defining them as “objects”, and hiding the detailed specifications and structures in the objects from the outside. It can be said that the methods in a class are described in the concept of encapsulation. A class defines a template of an object and describes what fields (variables) / methods the object has.
また、オーバーライドとは、基底クラス(スーパークラス)から継承された派生クラス(サブクラス)において、基底クラスで定義されたメソッドを再定義することである。また、オーバーロードとは、引数の型、数、並び順などが異なる同一名のメソッドや演算子を多重定義することである。 Overriding means redefining a method defined in the base class in a derived class (subclass) inherited from the base class (super class). Overloading means overloading methods and operators with the same name that have different types, numbers, and order of arguments.
ソースプログラムscに含まれるメソッドが多くなると、ソースプログラムscのコンパイル時間の増加を招くとともに、生成されるオブジェクトファイルfのデータサイズの増加を招いてしまう。すなわち、オブジェクト指向言語では、生産性・再利用性の高さと引き替えに、ソースプログラムscのコンパイル時間の増加や、オブジェクトファイルfのデータサイズの増加が問題となる。 When the number of methods included in the source program sc increases, the compilation time of the source program sc increases and the data size of the generated object file f increases. That is, in the object-oriented language, an increase in the compilation time of the source program sc and an increase in the data size of the object file f are problematic in exchange for high productivity and reusability.
ソースプログラムscのコンパイル時間を短縮し、オブジェクトファイルfのデータサイズを小さくするためには、メソッドの絶対数を減らすことが効果的である。従来のコンパイラでは、最適化区の最適化処理において、不要と見なされるメソッドを削除することが行われている。 In order to shorten the compile time of the source program sc and reduce the data size of the object file f, it is effective to reduce the absolute number of methods. In the conventional compiler, methods that are considered unnecessary are deleted in the optimization processing of the optimization section.
ところが、従来のコンパイラでは、ソースプログラムsc内のメソッドが不要と見なされない限り、全てのメソッドがコンパイル対象としてオブジェクトファイルfに翻訳されてしまう。上述したように、オブジェクト指向言語では大量のメソッドが作成されるため、不要と見なされるメソッドの削除だけではメソッドの絶対数は大して変わらず、コンパイル時間の削減はあまり望めない。 However, in the conventional compiler, unless the methods in the source program sc are not considered unnecessary, all the methods are translated into the object file f as a compilation target. As described above, since a large number of methods are created in an object-oriented language, the absolute number of methods does not change significantly only by deleting unnecessary methods, and the reduction of compile time cannot be expected much.
ここで、データや処理ロジックについて同一性を有する、すなわち、実行面で冗長性を有する複数のメソッドを一つのメソッドにマージすることで、メソッドの絶対数を減らすことができる。例えば、オーバーライドやオーバーロードされるメソッド同士は、実行面で冗長性を有する可能性が高く、マージ対象となるメソッドとなり得る。 Here, it is possible to reduce the absolute number of methods by merging a plurality of methods having the same data and processing logic, that is, redundancy in terms of execution, into one method. For example, methods that are overridden or overloaded are highly likely to have redundancy in terms of execution, and can be methods to be merged.
このため、最適化区の最適化処理において、不要と見なされるメソッドを削除するとともに、オブジェクト指向言語の言語的特徴から実行面で冗長性を有する複数のメソッドを判断して一つのメソッドにマージすることが考えられる。ところが、最適化区では、基本的にFortran、C言語、C++などの言語に依存しない言語無依存な処理が行われる。このため、最適化区では、オブジェクト指向言語固有の情報が乏しく、オブジェクト指向言語特有の最適化処理を行うことは難しい。 For this reason, in the optimization process of the optimization section, methods deemed unnecessary are deleted, and a plurality of methods having redundancy in terms of execution are judged from the linguistic features of the object-oriented language and merged into one method. It is possible. However, in the optimized section, language-independent processing that is basically independent of languages such as Fortran, C language, C ++, and the like is performed. For this reason, the information specific to the object-oriented language is scarce in the optimization section, and it is difficult to perform optimization processing specific to the object-oriented language.
すなわち、最適化区では、オブジェクト指向言語固有の情報が乏しいために、大量のメソッドの中から、どのメソッドがオブジェクト指向言語の言語的特徴を持った実行面で冗長性のあるメソッドであるかを判断することが難しい。従って、最適化区の最適化処理において、複数のメソッドをマージしようとしても、現実的な有限時間内に効果的なメソッド数の削減を行うことはできない。 In other words, because the information specific to the object-oriented language is scarce in the optimization section, it is determined which of the large number of methods is a redundant method in terms of execution with the linguistic features of the object-oriented language. It is difficult to judge. Therefore, even when trying to merge a plurality of methods in the optimization process of the optimization section, it is not possible to effectively reduce the number of methods within a realistic finite time.
また、オブジェクト指向言語では、実行時のコードの冗長性は必ずしもソースプログラムscに表れず、例えば、コンパイラによって実行面で冗長となるコードが生成される場合がある。さらに、カプセル化やオーバーライド、オーバーロードの判定は、ソースプログラムscの字面だけでは判定することができず、構文・意味解析を行わなければ正確に判定することはできない。 In the object-oriented language, code redundancy at the time of execution does not always appear in the source program sc. For example, a compiler may generate code that is redundant in terms of execution. Furthermore, the determination of encapsulation, overriding, and overload cannot be determined only by the face of the source program sc, and cannot be determined accurately unless syntax / semantic analysis is performed.
また、ソースプログラムscのコンパイル時間の多くは最適化区での最適化処理にかかっており、最適化区の入力時点でメソッド数が少なくなっていなければ、コンパイル時間の短縮は見込めない。これらのことから、コンパイル時間の短縮とオブジェクトファイルfのデータサイズの削減のためには、最適化区での最適化処理とともに、オブジェクト指向言語の言語的特徴を判断できる構文・意味解析区でのソースプログラムレベル(よりソースプログラムscに近い)での最適化が必要になっている。 Further, much of the compile time of the source program sc depends on the optimization process in the optimization section. If the number of methods is not reduced at the time of input of the optimization section, the compile time cannot be shortened. From these facts, in order to shorten the compilation time and the data size of the object file f, in the syntax / semantic analysis section that can determine the linguistic features of the object-oriented language as well as optimization processing in the optimization section There is a need for optimization at the source program level (closer to the source program sc).
そこで、本実施の形態では、オブジェクト指向言語の言語的特徴を判断できる構文・意味解析区において、オブジェクト指向言語の言語的特徴から、実行面で冗長性を有する複数のメソッドを判断して一つのメソッドにマージすることで、メソッドの絶対数を減らすコンパイル方法について説明する。以下、コンパイル装置100のコンパイル処理例について説明する。
Therefore, in this embodiment, in the syntax / semantic analysis section that can determine the linguistic characteristics of the object-oriented language, a plurality of methods having redundancy in terms of execution are determined from the linguistic characteristics of the object-oriented language, and one method is determined. Explain how to compile to reduce the absolute number of methods by merging with methods. Hereinafter, a compile processing example of the compile
(1)コンパイル装置100は、構文・意味解析区において、ソースプログラムscの構文解析および意味解析を行う。ここで、構文解析とは、ソースプログラムscに記述された文(ステートメント)や構造が言語仕様に沿っているか否かをチェックすることである。意味解析は、ソースプログラムscに記述された変数の型や文が意味的に正しいか否かをチェックすることである。
(1) The
ソースプログラムscの構文解析および意味解析を行うことにより、構文・意味解析区内のインターフェースである中間言語Iコードを得ることができる。中間言語Iコードには、ソースプログラムsc内のメソッドが表現されている。また、中間言語Iコードには、オブジェクト指向言語の特徴を持ったメソッドについて、オブジェクト指向言語の特徴を表す情報(図1中、(オ))が存在する。 By performing syntax analysis and semantic analysis of the source program sc, an intermediate language I code that is an interface in the syntax and semantic analysis section can be obtained. Methods in the source program sc are expressed in the intermediate language I code. Further, in the intermediate language I code, there is information ((e) in FIG. 1) representing the characteristics of the object-oriented language for the methods having the characteristics of the object-oriented language.
(2)コンパイル装置100は、構文・意味解析区において、ソースプログラムscの構文解析および意味解析により得られる中間言語Iコード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出する。ここで、複数のマージ候補メソッドとは、実行面での冗長性を有する可能性がある複数のメソッドである。
(2) In the syntax / semantic analysis section, the compiling
以下の説明では、複数のマージ候補メソッドをまとめて「重複メソッド候補」と表記する場合がある。重複メソッド候補としては、例えば、オーバーライドされたメソッドやオーバーロードされたメソッドがある。 In the following description, a plurality of merge candidate methods may be collectively referred to as “duplicate method candidates”. Duplicate method candidates include, for example, overridden methods and overloaded methods.
具体的には、例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコードを参照して、親子関係を有するクラス間で同一名の複数のメソッドを重複メソッド候補として抽出する。これにより、オーバーライドされたメソッドを重複メソッド候補として抽出することができる。
Specifically, for example, the compiling
(3)コンパイル装置100は、構文・意味解析区において、抽出した重複メソッド候補それぞれの中間言語Iコードにより特定される処理ロジックに基づいて、重複メソッド候補のメソッド間の対応関係情報110を生成する。ここで、対応関係情報110は、重複メソッド候補のメソッド間の実行面での冗長性の有無を判断するための情報である。
(3) In the syntax / semantic analysis section, the compiling
具体的には、例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコードから、重複メソッド候補それぞれに対応する中間言語Iコードを抽出する。つぎに、コンパイル装置100は、抽出した中間言語Iコード中の宣言・文・式それぞれのデータごとに、メソッド間のデータを比較する。
Specifically, for example, the compiling
そして、コンパイル装置100は、データごとの比較結果に基づいて、重複メソッド候補それぞれに対応する中間言語Iコードのうち、メソッド間で意味的に同一である部分と、メソッド間で意味的に異なる部分(各メソッド固有の部分)を識別する情報を対応関係情報110として生成する。
Then, the compiling
(4)コンパイル装置100は、構文・意味解析区において、生成した対応関係情報110に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定する。具体的には、例えば、コンパイル装置100は、宣言・文・式それぞれのデータのうち少なくともいずれかのデータが意味的に同一である場合に、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定してもよい。メソッド間で実行面での冗長性を有する重複メソッド候補は、マージ可能な複数のマージ可能メソッドである。
(4) In the syntax / semantic analysis section, the compiling
(5)コンパイル装置100は、構文・意味解析区において、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定した場合に、対応関係情報110に基づいて、重複メソッド候補のマージ処理を行う。すなわち、コンパイル装置100は、重複メソッド候補からマージ可能な複数のマージ可能メソッドを抽出して、複数のマージ可能メソッドのマージ処理を行う。ここで、マージ処理とは、重複メソッド候補である複数のメソッドを、重複メソッド候補のいずれの呼び出し元からも呼び出せる一つのメソッドとしてまとめることである。
(5) When the
例えば、メソッド間で冗長性を有するメソッドとして、メソッドA、メソッドBおよびメソッドCの3つのメソッドがあったとする。これら3つのメソッドを、例えば、メソッドABCとして1つにマージすることにより、メソッドの数を1/3にすることができる。なお、共通化できないメソッド固有の部分については、メソッド固有の情報を、マージしたメソッドに引数などで渡すことにより、メソッド固有の処理を切り分けられるようにする。 For example, it is assumed that there are three methods, method A, method B, and method C, as methods having redundancy among methods. By merging these three methods into one as, for example, method ABC, the number of methods can be reduced to 1/3. For method-specific parts that cannot be shared, method-specific processing can be separated by passing method-specific information to the merged method as an argument.
具体的には、例えば、コンパイル装置100は、重複メソッド候補のメソッド間で共通する処理の中間言語Iコードを生成するとともに、重複メソッド候補の各メソッドで固有の処理の中間言語Iコードを生成する。そして、コンパイル装置100は、生成した中間言語Iコードをマージすることにより、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成する。
Specifically, for example, the compiling
(6)コンパイル装置100は、構文・意味解析区において、マージしたメソッド本体の中間言語Iコードに基づいて、コンパイラ内のインターフェースである中間言語IIコードを生成する。具体的には、例えば、コンパイル装置100は、中間言語Iコードで表現したメソッド(マージしたメソッド本体、マージしていないメソッド)を中間言語IIコードの形式に変換する。生成された中間言語IIコードは最適化区に入力される。
(6) The
図1中、最適化区に入力される中間言語IIコード内の点線枠は、マージされたために削除されたメソッドを示している。図1の例では、ソースプログラムscの中間言語Iコードの段階では12個存在していたメソッドが、中間言語IIコードの段階では5個となっており、最適化区への入力時点でメソッドの絶対数が大幅に削減されている。 In FIG. 1, the dotted frame in the intermediate language II code input to the optimization section indicates a method that has been deleted because it has been merged. In the example of FIG. 1, there are 12 methods in the intermediate language I code stage of the source program sc, and there are 5 methods in the intermediate language II code stage. The absolute number has been greatly reduced.
(7)コンパイル装置100は、最適化区において、ソースプログラムscの中間言語IIコードの最適化処理を行う。最適化処理では、例えば、中間言語IIコードから不要と見なされるメソッドが削除される。図1の例では、中間言語IIコードから、不要と見なされた1個のメソッドが削除されている。最適化処理が行われた中間言語IIコードはコード生成区に入力される。
(7) The
(8)コンパイル装置100は、コード生成区において、最適化処理が行われた中間言語IIコードに基づいて、オブジェクトファイルfを生成する。生成されたオブジェクトファイルfは、例えば、リンカに渡されて、最終的に実行プログラムが生成される。
(8) The
このように、実施の形態にかかるコンパイル装置100によれば、構文・意味解析区において、オブジェクト指向言語特有の性質にマッチした効果的な最適化を行ってメソッドの絶対数を削減することができる。これにより、最適化区の入力時点でメソッドの絶対数を削減可能となるため、最適化処理にかかる処理時間が少なくなり、結果的に、ソースプログラムscのコンパイル時間を短縮することができる。また、メソッドの絶対数を削減することにより、オブジェクトファイルfのデータサイズを縮小することができる。
As described above, according to the
(コンパイル装置100のハードウェア構成例)
図2は、コンパイル装置100のハードウェア構成例を示すブロック図である。図2において、コンパイル装置100は、CPU(Central Processing Unit)201と、メモリ202と、ディスクドライブ203と、ディスク204と、I/F(Interface)205と、ディスプレイ206と、キーボード207と、マウス208と、を有する。また、各構成部はバス200によってそれぞれ接続される。
(Example of hardware configuration of compiling device 100)
FIG. 2 is a block diagram illustrating a hardware configuration example of the
ここで、CPU201は、コンパイル装置100の全体の制御を司る。メモリ202は、例えば、ROM(Read Only Memory)、RAM(Random Access Memory)およびフラッシュROMなどを有する。具体的には、例えば、フラッシュROMやROMが各種プログラム(例えば、コンパイルプログラム)を記憶し、RAMがCPU201のワークエリアとして使用される。メモリ202に記憶されるプログラムは、CPU201にロードされることで、コーディングされている処理をCPU201に実行させる。
Here, the CPU 201 governs overall control of the
ディスクドライブ203は、CPU201の制御に従ってディスク204に対するデータのリード/ライトを制御する。ディスク204は、ディスクドライブ203の制御で書き込まれたデータを記憶する。ディスク204としては、例えば、磁気ディスク、光ディスクなどが挙げられる。
The
I/F205は、通信回線を通じてネットワーク210に接続され、ネットワーク210を介して他のコンピュータに接続される。そして、I/F205は、ネットワーク210と内部のインターフェースを司り、他のコンピュータからのデータの入出力を制御する。I/F205には、例えば、モデムやLANアダプタなどを採用することができる。
The I /
ディスプレイ206は、カーソル、アイコンあるいはツールボックスをはじめ、文書、画像、機能情報などのデータを表示する。ディスプレイ206は、例えば、CRT(Cathode Ray Tube)、TFT(Thin Film Transistor)液晶ディスプレイ、プラズマディスプレイなどを採用することができる。
A
キーボード207は、文字、数字、各種指示などの入力のためのキーを備え、データの入力を行う。キーボード207は、タッチパネル式の入力パッドやテンキーなどであってもよい。マウス208は、カーソルの移動や範囲選択、あるいはウィンドウの移動やサイズの変更などを行う。
The
(ソースプログラムscの具体例)
図3は、ソースプログラムscの具体例を示す説明図である。図3において、ソースプログラム300は、オブジェクト指向言語でコーディングされたオブジェクト指向特有のプログラム例である。
(Specific example of source program sc)
FIG. 3 is an explanatory diagram showing a specific example of the source program sc. In FIG. 3, a
ソースプログラム300では、3行目の基底クラスCOLORにおいて、色(カラー)の基本データと処理ロジックを定義している。10行目には、基底クラスCOLORのSetColorメソッドが定義されている。また、22行目の派生クラスREDは、基底クラスCOLORを継承したクラスである。24行目には、REDクラスのメソッドとして、基底クラスCOLORのSetColorメソッドをオーバーライドして定義している。
In the
(中間言語Iコードの具体例)
図4は、中間言語Iコードの具体例を示す説明図である。図4において、中間言語Iコード410,420は、ソースプログラム300(図3)の構文解析および意味解析により得られる中間言語Iコードを模式的に示したものである。
(Specific example of intermediate language I code)
FIG. 4 is an explanatory diagram showing a specific example of the intermediate language I code. In FIG. 4, intermediate language I
具体的には、中間言語Iコード410は、ソースプログラム300内の10行目に定義されたSetColorメソッドを表現する中間言語Iコードである。また、中間言語Iコード420は、ソースプログラム300内の24行目に定義されたSetColorメソッドを表現する中間言語Iコードである。
Specifically, the intermediate
ここで、中間言語Iコード410は、データ411〜414を含む。データ411は、ソースプログラム300に記述された基底クラスCOLORのSetColorメソッドの宣言情報の構文、意味を表現したものである。データ412〜414は、基底クラスCOLORのSetColorメソッドの文情報の構文、意味を表現したものであり、データ415〜417をそれぞれ含む。データ415〜417は、基底クラスCOLORのSetColorメソッドの式情報の構文、意味をそれぞれ表現したものである。
Here, the intermediate
また、中間言語Iコード420は、データ421〜424を含む。データ421は、ソースプログラム300に記述された派生クラスREDのSetColorメソッドの宣言情報の構文、意味を表現したものである。データ422〜424は、派生クラスREDのSetColorメソッドの文情報の構文、意味を表現したものであり、データ425〜427をそれぞれ含む。データ425〜427は、派生クラスREDのSetColorメソッドの式情報の構文、意味をそれぞれ表現したものである。
Further, the intermediate
このSetColorメソッドは、オブジェクト指向言語のオーバーライド(再定義)が使われており、基底クラスCOLORのSetColorメソッドを、派生クラスREDのSetColorメソッドがオーバーライドしている。このため、2つのSetColorメソッドは、メソッド間で実行面での冗長性を有する可能性があるメソッドといえる。 The SetColor method uses an override (redefinition) of an object-oriented language, and the SetColor method of the derived class RED overrides the SetColor method of the base class COLOR. Therefore, the two SetColor methods can be said to be methods that may have redundancy in terms of execution between methods.
(コンパイル装置100の機能的構成例)
図5は、コンパイル装置100の機能的構成例を示すブロック図である。図5において、コンパイル装置100は、取得部501と、解析部502と、抽出部503と、生成部504と、判定部505と、マージ処理部506と、最適化部507と、コード生成部508と、出力部509と、を含む構成である。取得部501〜出力部509は制御部となる機能であり、具体的には、例えば、図2に示したメモリ202、ディスク204などの記憶装置に記憶されたプログラムをCPU201に実行させることにより、または、I/F205により、その機能を実現する。各機能部の処理結果は、例えば、メモリ202、ディスク204などの記憶装置に記憶される。
(Functional configuration example of the compiling device 100)
FIG. 5 is a block diagram illustrating a functional configuration example of the
取得部501は、ソースプログラムscを取得する。ソースプログラムscは、JavaやC++などのオブジェクト指向言語でコーディングされたソースコードを含むものであり、例えば、FortranやC言語などでコーディングされたソースコードが含まれていてもよい。
The
具体的には、例えば、取得部501は、キーボード207やマウス208を用いたユーザの操作入力により、ソースプログラムsc(例えば、ソースプログラム300)を取得する。また、例えば、取得部501は、I/F205により、外部のコンピュータからソースプログラムscを取得することにしてもよい。
Specifically, for example, the
解析部502は、ソースプログラムscの構文解析および意味解析を行う。具体的には、例えば、まず、解析部502は、ソースプログラムscの字句解析を行う。字句解析とは、ソースプログラムscを構成する文字の並びを、例えば、キーワード、変数、演算子などのトークンの並びに変換することである。
The
そして、解析部502は、字句解析により得られるトークンの並びについて、トークン間の関係を解析することにより、ソースプログラムscの構文解析および意味解析を行う。これにより、例えば、図4に示したような、構文・意味解析区内のインターフェースである中間言語Iコードを得ることができる。
Then, the
なお、中間言語Iコードでは、例えば、基底クラスと派生クラスは木構造のように表現されており、クラス間の親子関係を特定できる構造となっている。また、各クラスと各クラスに属するメソッドも木構造のように表現されており、どのクラスにどのメソッドが属しているかを特定できる構造となっている。 In the intermediate language I code, for example, the base class and the derived class are expressed like a tree structure, and the parent-child relationship between classes can be specified. In addition, each class and the methods belonging to each class are also expressed in a tree structure, and it is a structure that can specify which method belongs to which class.
抽出部503は、ソースプログラムscの構文解析および意味解析により得られる中間言語Iコード中の複数のメソッドから重複メソッド候補を抽出する。ここで、重複メソッド候補は、上述したように、メソッド間で実行面での冗長性を有する候補となる複数のマージ候補メソッドであり、例えば、オーバーライドやオーバーロードされたメソッドである。
The
具体的には、例えば、抽出部503は、生成された中間言語Iコードを参照して、親子関係を有するクラス間で同一名のメソッドの組合せを重複メソッド候補として抽出する。これにより、オーバーライドされたメソッドを重複メソッド候補として抽出することができる。
Specifically, for example, the
図3に示したソースプログラム300を例に挙げると、基底クラスCOLORと派生クラスREDとが親子関係を有するクラスである。このため、抽出部503は、ソースプログラム300の中間言語Iコード(図4に示した中間言語Iコード410,420を含む中間言語Iコード)を参照して、基底クラスCOLORと派生クラスREDとの間でメソッド名が同一のSetColorメソッドを重複メソッド候補として抽出する。
Taking the
また、抽出部503は、例えば、生成された中間言語Iコードを参照して、同一クラス内のメソッド、あるいは、いずれのクラスにも属していないメソッドのうち、同一名のメソッドの組合せを重複メソッド候補として抽出することにしてもよい。これにより、オーバーロードされたメソッドを重複メソッド候補として抽出することができる。
In addition, the
また、抽出部503は、例えば、生成された中間言語Iコードを参照して、同一クラス内の演算子、あるいは、いずれのクラスにも属していない演算子のうち、同一名の演算子の組合せを重複メソッド候補として抽出することにしてもよい。これにより、オーバーロードされた演算子(多重定義演算子)を重複メソッド候補として抽出することができる。
Further, the
なお、オーバーロードされた演算子(多重定義演算子)は、名称(メソッド名)が同一で、かつ、引数の型、数、並び順の少なくともいずれかが異なる演算子である。 The overloaded operator (overloaded operator) is an operator having the same name (method name) and different at least one of argument type, number, and arrangement order.
生成部504は、抽出された重複メソッド候補それぞれの中間言語Iコードにより特定される処理ロジックに基づいて、重複メソッド候補のメソッド間の対応関係情報110を生成する。具体的には、例えば、生成部504は、ソースプログラムscの中間言語Iコードから、重複メソッド候補それぞれに対応する中間言語Iコードを抽出する。
The
つぎに、生成部504は、抽出した中間言語Iコード中の宣言・文・式それぞれのデータごとに、メソッド間のデータを比較する。中間言語Iコードは、ソースプログラムscに記述された順に従って宣言・文・式の構造が形成されている。このため、生成部504は、中間言語Iコードの構造に従って、メソッド間のデータを順次比較する。
Next, the
なお、中間言語I中の式のデータは、文のデータに含まれる。このため、式のデータを含む文のデータ同士を比較する際は、文のデータに含まれる式のデータ同士を比較することになり、式のデータが異なると、文のデータも異なることになる。 Note that the expression data in the intermediate language I is included in the sentence data. For this reason, when comparing the sentence data including the expression data, the expression data included in the sentence data is compared. If the expression data is different, the sentence data is also different. .
そして、生成部504は、データごとの比較結果に基づいて、抽出した中間言語Iコードのうち、メソッド間で意味的に同一である部分と、メソッド間で意味的に異なる部分(各メソッド固有の部分)を識別する情報を対応関係情報110として生成する。なお、メソッド間のデータの比較例および対応関係情報110の生成例については、図6〜図9を用いて後述する。
Then, based on the comparison result for each data, the
判定部505は、生成された対応関係情報110に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定する。具体的には、例えば、判定部505は、中間言語Iコード中の宣言・文・式それぞれのデータのうち少なくともいずれかのデータが意味的に同一である場合に、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定してもよい。
Based on the generated correspondence information 110, the
また、例えば、判定部505は、中間言語Iコード中の宣言・文・式それぞれのデータのうちの所定数X以上のデータが意味的に同一である場合に、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定してもよい。ここで、所定数Xは、例えば、予め任意に設定されてメモリ202やディスク204などの記憶装置に記憶されていてもよい。
Further, for example, the
また、所定数Xとして、重複メソッド候補のいずれかのメソッドに対応する中間言語Iコード中の宣言・文・式の全データ数に比率rを乗算した値を設定することにしてもよい。比率rは、1以下の値である。比率rを大きくすればするほど、メソッド間の実行面での冗長性を判定する際の判定基準を厳しくすることができる。 Further, as the predetermined number X, a value obtained by multiplying the total number of data of declarations / sentences / expressions in the intermediate language I code corresponding to any one of the duplicate method candidates by the ratio r may be set. The ratio r is a value of 1 or less. The larger the ratio r, the stricter the criteria for determining redundancy in terms of execution between methods.
マージ処理部506は、対応関係情報110に基づいて、メソッド間で実行面での冗長性を有すると判定された重複メソッド候補のマージ処理を行う。具体的には、例えば、マージ処理部506は、対応関係情報110に基づいて、メソッド間で実行面での冗長性を有する重複メソッド候補の各メソッドの中間言語Iコードを走査しながら、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成する。
The
より具体的には、例えば、マージ処理部506は、対応関係情報110に基づいて、重複メソッド候補のメソッド間で共通する処理の中間言語Iコードを生成する。メソッド間で共通する処理は、例えば、メソッド間で意味的に同一である部分のデータから特定される。
More specifically, for example, the
また、マージ処理部506は、対応関係情報110に基づいて、重複メソッド候補の各メソッドで固有の処理の中間言語Iコードを生成する。各メソッドで固有の処理は、例えば、メソッド間で意味的に異なる部分のデータから特定される。そして、マージ処理部506は、生成した中間言語Iコードをマージすることにより、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成する。
Further, the
なお、重複メソッド候補をマージしたメソッド本体の中間言語Iコードは、呼び出し元が呼び出すメソッドを特定するために、マージ元の各メソッドが属するクラスを特定できるようになっている。重複メソッド候補のマージ処理例については、図10および図11を用いて後述する。 The intermediate language I code of the method body obtained by merging duplicate method candidates can specify the class to which each method of the merge source belongs in order to specify the method to be called by the call source. An example of the merge processing of duplicate method candidates will be described later with reference to FIGS.
また、マージ処理部506は、重複メソッド候補をマージしたメソッド本体の中間言語Iコードに基づいて、コンパイラ(コンパイルプログラム)内のインターフェースであるソースプログラムscの中間言語IIコードを生成する。具体的には、例えば、マージ処理部506は、中間言語Iコードで表現したメソッド(マージしたメソッド本体、マージしていないメソッド)を中間言語IIコードの形式に変換する。
Further, the
これにより、ソースプログラムscの中間言語Iコード中の複数のメソッドのうちのマージされたメソッドの数分だけ絶対数が削減された中間言語IIコードを生成することができる。なお、中間言語IIコードでは、マージされた各メソッドの呼び出し元からマージしたメソッド本体を参照できる構造となっている。 Thus, it is possible to generate an intermediate language II code whose absolute number is reduced by the number of merged methods among a plurality of methods in the intermediate language I code of the source program sc. The intermediate language II code has a structure in which the merged method body can be referred from the caller of each merged method.
最適化部507は、生成されたソースプログラムscの中間言語IIコードの最適化処理を行う。具体的には、例えば、最適化部507は、ソースプログラムの中間言語IIコードから、どこからも呼び出しがないメソッドを不要なメソッドと見なして削除する。これにより、中間言語IIコード中の複数のメソッドのうち使用されないメソッドを削除してメソッドの絶対数を削減することができる。
The
コード生成部508は、最適化処理されたソースプログラムscの中間言語IIコードに基づいて、ソースプログラムscのオブジェクトファイルfを生成する。具体的には、例えば、コード生成部508は、最適化処理された中間言語IIコードを機械語の命令の列に変換することにより、ソースプログラムscのオブジェクトファイルfを生成する。
The
出力部509は、生成されたソースプログラムscのオブジェクトファイルfを出力する。具体的には、例えば、出力部509は、ソースプログラムscのオブジェクトファイルfを、リンカと呼ばれるプログラムに出力する。ここで、リンカとは、オブジェクトファイルfを解析して、必要なライブラリなどを付け加えて実行ファイルを生成するプログラムである。これにより、ソースプログラムscの実行ファイルを得ることができる。
The
なお、上述した説明では、重複メソッド候補としてメソッド名が同一のメソッドの組合せを抽出する場合を例に挙げて説明したが、メソッド名が異なっていてもメソッド間で実行面での冗長性を有する場合がある。しかし、メソッド名が異なる全てのメソッドの組合せについて実行面の冗長性を判断するのは処理時間の増大化を招いてしまう。 In the above description, a case where a combination of methods having the same method name is extracted as a duplicate method candidate has been described as an example. However, even if the method names are different, the methods have redundancy in terms of execution. There is a case. However, judging the redundancy of the execution surface for all the combinations of methods having different method names leads to an increase in processing time.
例えば、クラス間で親子関係があるメソッド同士は、それ以外のメソッド同士に比べて、メソッド間で処理ロジックが共通する部分が多い傾向にある。このため、メソッド名が異なるメソッド間の実行面での冗長性も判断する場合には、抽出部503は、親子関係を有するクラス間のメソッドの組合せを重複メソッド候補として抽出することにしてもよい。
For example, methods that have a parent-child relationship between classes tend to have more parts with common processing logic between methods than other methods. For this reason, when determining redundancy in terms of execution between methods having different method names, the
(メソッド間のデータの比較例)
つぎに、図4に示した中間言語Iコード410,420を例に挙げて、重複メソッド候補のメソッド間のデータの比較例について説明する。
(Example of data comparison between methods)
Next, taking the intermediate language I
図6〜図9は、重複メソッド候補のメソッド間のデータの比較例を示す説明図である。図6において、まず、生成部504は、中間言語Iコード410から、Parameter(宣言)のデータ411を選択する。つぎに、生成部504は、中間言語Iコード420から、データ411と同一種のParameterのデータ421を選択する。
6 to 9 are explanatory diagrams illustrating comparative examples of data between methods of duplicate method candidates. In FIG. 6, the
そして、生成部504は、選択したParameterのデータ411,421同士を比較する。ここでは、データ411,421の間で、引数(仮引数)の型、数、並び順のいずれも異なる。このため、生成部504は、データ411,421が意味的に異なると判断して、メソッド間で意味的に異なる部分を識別する情報を対応関係情報110として生成する。図6の例では、メソッド間で意味的に異なる部分を識別する情報を、チェック記号を付与することで表現している。すなわち、中間言語Iコード中に付与されるチェック記号が対応関係情報110に相当する。
Then, the
図7において、まず、生成部504は、中間言語Iコード410から、Statement(文)のデータ412を選択する。つぎに、生成部504は、中間言語Iコード420から、データ412と同一種のStatementのデータ422を選択する。そして、生成部504は、選択したStatementのデータ412,422にそれぞれ含まれるOperator(式)のデータ415,425同士を比較する。
In FIG. 7, the
ここでは、データ415,425がそれぞれ表す式が同一である。このため、生成部504は、データ412,422が意味的に同一であると判断して、メソッド間で意味的に同一である部分を識別する情報を対応関係情報110として生成する。図7の例では、メソッド間で意味的に同一である部分を識別する情報を、チェック記号を付与しないことで表現している。
Here, the expressions represented by the
図8において、まず、生成部504は、中間言語Iコード410から、Statementのデータ413を選択する。つぎに、生成部504は、中間言語Iコード420から、データ413と同一種のStatementのデータ423を選択する。そして、生成部504は、選択したStatementのデータ413,423にそれぞれ含まれるOperatorのデータ416,426同士を比較する。
In FIG. 8, the
ここでは、データ416,426がそれぞれ表す式の一部が異なっている。このため、生成部504は、データ413,423が意味的に異なると判断して、メソッド間で意味的に異なる部分を識別する情報を対応関係情報110として生成する。図8の例では、メソッド間で意味的に異なる部分を識別する情報を、チェック記号を付与することで表現している。
Here, some of the expressions represented by the
図9において、まず、生成部504は、中間言語Iコード410から、Statementのデータ414を選択する。つぎに、生成部504は、中間言語Iコード420から、データ414と同一種のStatementのデータ424を選択する。そして、生成部504は、選択したStatementのデータ414,424にそれぞれ含まれるOperatorのデータ417,427同士を比較する。
In FIG. 9, the
ここでは、データ417,427がそれぞれ表す式が同一である。このため、生成部504は、データ414,424が意味的に同一であると判断して、メソッド間で意味的に同一である部分を識別する情報を対応関係情報110として生成する。図9の例では、メソッド間で意味的に同一である部分を識別する情報を、チェック記号を付与しないことで表現している。
Here, the expressions represented by the
(重複メソッド候補のマージ処理例)
つぎに、ソースプログラム300内の基底クラスCOLORと派生クラスREDとの間でメソッド名が同一のSetColorメソッドを重複メソッド候補として、重複メソッド候補のマージ処理例について説明する。まず、ソースプログラム300を用いて、SetColorメソッドのマージ処理のイメージについて説明する。
(Duplicate method candidate merge processing example)
Next, an example of merge processing of duplicate method candidates will be described with the SetColor method having the same method name between the base class COLOR and the derived class RED in the
図10は、SetColorメソッドのマージ処理を示す説明図である。図10において、ソースプログラム300内の10行目から14行目のコード1001は、基底クラスCOLORのSetColorメソッドに関する記述である。また、ソースプログラム300内の24行目から29行目のコード1002は、派生クラスREDのSetColorメソッドに関する記述である。
FIG. 10 is an explanatory diagram showing merge processing of the SetColor method. In FIG. 10, a
マージ処理部506は、コード1001に対応する中間言語Iコードとコード1002に対応する中間言語Iコードとをマージして、イメージ1010で示すような中間言語Iコードを生成することになる。ここで、コード1001とコード1002とを比較すると、10行目と24行目の引数、および12行目と26行目の式が、それぞれのSetColorメソッドで固有のものとなっている。
The
このため、マージ処理部506は、イメージ1010内のコード1011〜1015のように、基底クラスCOLORおよび派生クラスREDのSetColorメソッド間で共通する処理の中間言語Iコードと、各SetColorメソッドで固有の処理の中間言語Iコードを生成する。
For this reason, the
コード1011は、基底クラスCOLORおよび派生クラスREDのいずれのSetColorメソッドに応じた処理を行うのかを選択するためのものであり、呼び出し元から第1引数として与えられる情報が定義される。コード1012は、SetColorメソッドの引数を表す。
The
コード1013,1015は、基底クラスCOLORおよび派生クラスREDのSetColorメソッド間で共通する処理の中間言語Iコードに対応する。一方、コード1014は、基底クラスCOLORおよび派生クラスREDの各SetColorメソッドで固有の処理の中間言語Iコードに対応する。コード1014には、基底クラスCOLORおよび派生クラスREDのいずれのSetColorメソッドであるかを判定する判定文(if)が含まれている。
また、ソースプログラム300内の36行目は、基底クラスCOLORのSetColorメソッドを呼び出すための記述である。また、ソースプログラム300内の37行目は、派生クラスREDのSetColorメソッドを呼び出すための記述である。このため、マージ処理部506は、基底クラスCOLORまたは派生クラスREDのSetColorメソッドを呼び出すために、イメージ1020のような中間言語Iコードを合わせて生成する。
The 36th line in the
ここで、イメージ1010に対応する中間言語Iコードについて説明する。
Here, the intermediate language I code corresponding to the
図11は、SetColorメソッドをマージしたメソッド本体の中間言語Iコードの一例を示す説明図である。図11において、中間言語Iコード1100は、基底クラスCOLORのSetColorメソッドと派生クラスREDのSetColorメソッドとをマージしたメソッド本体の中間言語Iコードを模式的に示したものであり、図10に示したイメージ1010に対応する。
FIG. 11 is an explanatory diagram showing an example of the intermediate language I code of the method body obtained by merging the SetColor method. In FIG. 11, the intermediate
中間言語Iコード1100において、データ1101は、基底クラスCOLORおよび派生クラスREDのいずれのSetColorメソッドに応じた処理を行うのかを選択するための中間言語Iコードである。データ1101は、図10に示したイメージ1010内のコード1011に対応する。
In the intermediate
データ1102は、SetColorメソッドの引数を表す中間言語Iコードである。データ1102は、イメージ1010内のコード1012に対応する。データ1103は、基底クラスCOLORおよび派生クラスREDのSetColorメソッド間で共通する処理の中間言語Iコードである。データ1103は、イメージ1010内のコード1013に対応する。
データ1104は、各SetColorメソッドで固有の処理の中間言語Iコードである。データ1104は、イメージ1010内のコード1014に対応する。データ1105は、SetColorメソッド間で共通する処理の中間言語Iコードである。データ1105は、イメージ1010内のコード1015に対応する。
(重複メソッド候補をマージしないソースプログラム例)
つぎに、重複メソッド候補をマージしない場合のソースプログラムscについて説明する。ここでは、オーバーロードされたメソッドを重複メソッド候補として抽出する場合を例に挙げて説明する。
(Example source program that does not merge duplicate method candidates)
Next, the source program sc in the case where duplicate method candidates are not merged will be described. Here, a case where an overloaded method is extracted as a duplicate method candidate will be described as an example.
図12は、重複メソッド候補をマージしないソースプログラム例を示す説明図である。図12において、ソースプログラム1200は、オブジェクト指向言語でコーディングされたオブジェクト指向特有のプログラム例である。
FIG. 12 is an explanatory diagram of an example of a source program that does not merge duplicate method candidates. In FIG. 12, a
ソースプログラム1200の4行目には、printメソッドが定義されている。また、ソースプログラム1200の9行目には、4行目のprintメソッドと同一名のprintメソッドが定義されている。すなわち、printメソッドがオーバーロードされている。
In the fourth line of the
ソースプログラム1200内の4行目から6行目のコード1201は、4行目のprintメソッドに関する記述である。また、ソースプログラム1200内の9行目から22行目のコード1202は、9行目のprintメソッドに関する記述である。ここで、コード1201とコード1202とを比較すると、メソッド名以外で、メソッド間で意味的に同一である部分は存在しない。
The
このように、メソッド間で意味的に同一である部分が少なく、メソッド間で実行面での冗長性が低い場合には、printメソッドをマージしてメソッドの絶対数を削減しても、ソースプログラムscのコンパイル時間の短縮は見込めない。このため、コンパイル装置100は、ソースプログラム1200内のprintメソッドのようなメソッドについてはマージ対象としない。
In this way, when there are few parts that are semantically identical between methods and the execution redundancy between methods is low, even if the print method is merged to reduce the absolute number of methods, the source program The compile time of sc cannot be shortened. For this reason, the compiling
(コンパイル装置100のコンパイル処理手順)
つぎに、コンパイル装置100のコンパイル処理手順について説明する。
(Compile processing procedure of the compiling device 100)
Next, a compiling process procedure of the compiling
図13は、コンパイル装置100のコンパイル処理手順の一例を示すフローチャートである。図13のフローチャートにおいて、まず、コンパイル装置100は、ソースプログラムscを読み込む(ステップS1301)。
FIG. 13 is a flowchart illustrating an example of a compile processing procedure of the compile
つぎに、コンパイル装置100は、ソースプログラムscの字句解析を行う(ステップS1302)。そして、コンパイル装置100は、字句解析により得られるトークンの並びについて、トークン間の関係を解析することにより、ソースプログラムscの構文解析および意味解析を行う(ステップS1303)。
Next, the compiling
つぎに、コンパイル装置100は、ソースプログラムscの構文解析および意味解析により得られる中間言語Iコード中の複数のメソッドから重複メソッド候補を抽出する重複メソッド候補抽出処理を行う(ステップS1304)。重複メソッド候補抽出処理の具体的な処理内容については、図14を用いて後述する。
Next, the compiling
つぎに、コンパイル装置100は、抽出された重複メソッド候補のうち未選択の重複メソッド候補を選択する(ステップS1305)。そして、コンパイル装置100は、重複メソッド候補のメソッド間の対応関係情報110を生成する対応関係情報生成処理を行う(ステップS1306)。対応関係情報生成処理の具体的な処理手順については、図15を用いて後述する。
Next, the compiling
つぎに、コンパイル装置100は、生成した重複メソッド候補の対応関係情報に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定する(ステップS1307)。ここで、実行面での冗長性を有さないと判定した場合(ステップS1307:No)、コンパイル装置100は、ステップS1309に移行する。
Next, the compiling
一方、実行面での冗長性を有すると判定した場合(ステップS1307:Yes)、コンパイル装置100は、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成するマージ処理を行う(ステップS1308)。マージ処理の具体的な処理手順については、図16を用いて後述する。
On the other hand, if it is determined that there is redundancy in terms of execution (step S1307: Yes), the compiling
つぎに、コンパイル装置100は、抽出された重複メソッド候補のうち未選択の重複メソッド候補があるか否かを判断する(ステップS1309)。ここで、未選択の重複メソッド候補がある場合(ステップS1309:Yes)、コンパイル装置100は、ステップS1305に戻る。
Next, the compiling
一方、未選択の重複メソッド候補がない場合は(ステップS1309:No)、コンパイル装置100は、重複メソッド候補をマージしたメソッド本体の中間言語Iコードと、マージしていないメソッドの中間言語Iコードとに基づいて、ソースプログラムscの中間言語IIコードを生成する(ステップS1310)。
On the other hand, if there is no unselected duplicate method candidate (step S1309: No), the compiling
そして、コンパイル装置100は、生成されたソースプログラムscの中間言語IIコードの最適化処理を行う(ステップS1311)。つぎに、コンパイル装置100は、最適化処理されたソースプログラムscの中間言語IIコードに基づいて、ソースプログラムscのオブジェクトファイルfを生成する(ステップS1312)。
Then, the compiling
そして、コンパイル装置100は、生成したソースプログラムscのオブジェクトファイルfを出力して(ステップS1313)、本フローチャートによる一連の処理を終了する。
Then, the compiling
これにより、コンパイラの構文・意味解析区において、メソッド間で実行面での冗長性を有する複数のメソッドを一つのメソッドにマージすることができ、最適化区の入力時点でメソッドの絶対数を削減することができる。 As a result, in the syntax / semantic analysis section of the compiler, multiple methods with redundancy in terms of execution among methods can be merged into one method, and the absolute number of methods is reduced when the optimization section is input. can do.
<重複メソッド候補抽出処理手順>
つぎに、図13に示したステップS1304の重複メソッド候補抽出処理の具体的な処理手順について説明する。
<Duplicate method candidate extraction procedure>
Next, a specific processing procedure of the duplicate method candidate extraction process in step S1304 shown in FIG. 13 will be described.
図14は、重複メソッド候補抽出処理の具体的処理手順の一例を示すフローチャートである。図14のフローチャートにおいて、まず、コンパイル装置100は、ソースプログラムscの中間言語Iコードを参照して、親子関係を有するクラス間で同一名のメソッドが存在するか否かを判断する(ステップS1401)。
FIG. 14 is a flowchart illustrating an example of a specific processing procedure of the duplicate method candidate extraction processing. In the flowchart of FIG. 14, first, the compiling
ここで、親子関係を有するクラス間で同一名のメソッドが存在する場合(ステップS1401:Yes)、コンパイル装置100は、親子関係を有するクラス間で同一名のメソッドの組合せを重複メソッド候補として抽出する(ステップS1402)。そして、コンパイル装置100は、ステップS1401に戻る。
If a method having the same name exists between classes having a parent-child relationship (step S1401: Yes), the compiling
一方、親子関係を有するクラス間で同一名のメソッドが存在しない場合(ステップS1401:No)、コンパイル装置100は、ソースプログラムscの中間言語Iコードを参照して、同一名のメソッドまたは多重定義演算子が存在するか否かを判断する(ステップS1403)。
On the other hand, when a method with the same name does not exist between classes having a parent-child relationship (step S1401: No), the compiling
ここで、同一名のメソッドまたは多重定義演算子が存在する場合(ステップS1403:Yes)、コンパイル装置100は、同一名のメソッドまたは多重定義演算子の組合せを重複メソッド候補として抽出する(ステップS1404)。そして、コンパイル装置100は、ステップS1403に戻る。
If a method or overloaded operator with the same name exists (step S1403: Yes), the compiling
一方、同一名のメソッドまたは多重定義演算子が存在しない場合(ステップS1403:No)、コンパイル装置100は、重複メソッド候補抽出処理を呼び出したステップに戻る。これにより、オーバーロードされたメソッドやオーバーロードされたメソッドを、メソッド間で実行面での冗長性を有する候補となる重複メソッド候補として抽出することができる。
On the other hand, when there is no method or overloaded operator with the same name (step S1403: No), the compiling
<対応関係情報生成処理手順>
つぎに、図13に示したステップS1306の対応関係情報生成処理の具体的な処理手順について説明する。
<Correspondence information generation processing procedure>
Next, a specific processing procedure of the correspondence relationship information generation processing in step S1306 shown in FIG. 13 will be described.
図15は、対応関係情報生成処理の具体的処理手順の一例を示すフローチャートである。図15のフローチャートにおいて、まず、コンパイル装置100は、ソースプログラムscの中間言語Iコードから、重複メソッド候補それぞれに対応する中間言語Iコードを抽出する(ステップS1501)。
FIG. 15 is a flowchart illustrating an example of a specific processing procedure of the correspondence relationship information generation processing. In the flowchart of FIG. 15, first, the compiling
つぎに、コンパイル装置100は、抽出した中間言語Iコードを参照して、重複メソッド候補のメソッド間で宣言・文・式のデータを順次比較する(ステップS1502)。そして、コンパイル装置100は、比較した比較結果に基づいて、抽出した中間言語Iコードのうち、メソッド間で意味的に異なる部分があるか否かを判断する(ステップS1503)。
Next, the compiling
ここで、メソッド間で意味的に異なる部分がある場合(ステップS1503:Yes)、コンパイル装置100は、抽出した中間言語Iコードのうちのメソッド間で意味的に異なる部分にマーキングする(ステップS1504)。そして、コンパイル装置100は、対応関係情報生成処理を呼び出したステップに戻る。なお、マーキングは、例えば、図6に示したようなチェック記号に相当する。
Here, when there is a portion that is semantically different between methods (step S1503: Yes), the compiling
一方、メソッド間で意味的に異なる部分がない場合(ステップS1503:No)、コンパイル装置100は、対応関係情報生成処理を呼び出したステップに戻る。これにより、重複メソッド候補それぞれに対応する中間言語Iコードのうち、メソッド間で意味的に同一である部分と、メソッド間で意味的に異なる部分とを識別する対応関係情報110を生成することができる。
On the other hand, if there is no semantically different portion between the methods (step S1503: No), the compiling
<マージ処理手順>
つぎに、図13に示したステップS1308のマージ処理の具体的な処理手順について説明する。
<Merge processing procedure>
Next, a specific processing procedure of the merge processing in step S1308 shown in FIG. 13 will be described.
図16は、マージ処理の具体的処理手順の一例を示すフローチャートである。図16のフローチャートにおいて、まず、コンパイル装置100は、重複メソッド候補の中間言語Iコードから、宣言・文・式のデータを選択する(ステップS1601)。この際、コンパイル装置100は、選択したデータと図15に示したステップS1502で比較したデータが存在する場合は、そのデータも合わせて選択する。
FIG. 16 is a flowchart illustrating an example of a specific processing procedure of the merge processing. In the flowchart of FIG. 16, the compiling
つぎに、コンパイル装置100は、選択したデータにマーキングがあるか否かを判断する(ステップS1602)。ここで、マーキングがある場合(ステップS1602:Yes)、コンパイル装置100は、選択したデータに基づいて、重複メソッド候補のメソッド固有の処理の中間言語Iコードを生成する(ステップS1603)。
Next, the compiling
そして、コンパイル装置100は、重複メソッド候補の中間言語Iコードから選択されていない未選択のデータがあるか否かを判断する(ステップS1604)。ここで、未選択のデータがある場合(ステップS1604:Yes)、コンパイル装置100は、ステップS1601に戻る。
The compiling
また、ステップS1602において、マーキングがない場合(ステップS1602:No)、コンパイル装置100は、選択したデータに基づいて、重複メソッド候補のメソッド共通の処理の中間言語Iコードを生成して(ステップS1605)、ステップS1604に移行する。
If there is no marking in step S1602 (step S1602: No), the compiling
また、ステップS1604において、未選択のデータがない場合(ステップS1604:No)、コンパイル装置100は、生成した各処理の中間言語Iコードをマージすることにより、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成して(ステップS1606)、マージ処理を呼び出したステップに戻る。
In step S1604, if there is no unselected data (step S1604: No), the compiling
これにより、メソッド間で実行面での冗長性を有する重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成することができる。なお、重複メソッド候補をマージしたメソッド本体の中間言語Iコードには、マージしたいずれのメソッドに応じた処理を行うのかを選択するためのデータ(例えば、図11に示したデータ1101)が含まれる。また、ステップS1606では、マージしたいずれかのメソッドを呼び出すための中間言語Iコードも合わせて生成される。
As a result, it is possible to generate an intermediate language I code of a method body obtained by merging duplicate method candidates having redundancy in terms of execution among methods. Note that the intermediate language I code of the method body into which the duplicate method candidates are merged includes data for selecting which of the merged methods is to be processed (for example,
以上説明したように、実施の形態にかかるコンパイル装置100によれば、ソースプログラムscの構文解析および意味解析により得られる中間言語Iコード中の複数のメソッドから、メソッド間で実行面での冗長性を有する可能性がある重複メソッド候補を抽出することができる。これにより、オブジェクト指向言語の言語的特徴を判断できる構文・意味解析区において、データや処理ロジックについて同一性を有する可能性がある複数のメソッドを重複メソッド候補として抽出することができる。
As described above, according to the
例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコード中のメソッド群から、親子関係を有するクラス間で同一名のメソッドの組合せを重複メソッド候補として抽出してもよい。これにより、メソッド間で実行面での冗長性を有する可能性があるオーバーライドされたメソッドを重複メソッド候補として抽出することができる。
For example, the compiling
例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコード中のメソッド群から、同一クラス内のメソッド、あるいは、いずれのクラスにも属していないメソッドのうち、同一名のメソッドの組合せを重複メソッド候補として抽出してもよい。これにより、メソッド間で実行面での冗長性を有する可能性があるオーバーロードされたメソッドを重複メソッド候補として抽出することができる。
For example, the compiling
例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコード中のメソッド群から、同一クラス内の演算子、あるいは、いずれのクラスにも属していない演算子のうち、同一名の演算子の組合せを重複メソッド候補として抽出してもよい。これにより、メソッド(演算子)間で実行面での冗長性を有する可能性があるオーバーロードされた多重定義演算子を重複メソッド候補として抽出することができる。
For example, the compiling
また、コンパイル装置100によれば、抽出した重複メソッド候補それぞれの中間言語Iコードにより特定される処理ロジックに基づいて、重複メソッド候補のメソッド間の対応関係情報110を生成することができる。これにより、重複メソッド候補のメソッド間の実行面での冗長性の有無を判断するための対応関係情報110を生成することができる。
Further, the compiling
例えば、コンパイル装置100は、重複メソッド候補それぞれの中間言語Iコード中の宣言、文、式それぞれのデータごとに、メソッド間のデータを比較する。そして、コンパイル装置100は、比較した比較結果に基づいて、重複メソッド候補それぞれの中間言語Iコードのうち、メソッド間で意味的に同一である部分とメソッド間で意味的に異なる部分とを識別する対応関係情報110を生成してもよい。これにより、重複メソッド候補のメソッド間で意味的に同一である部分とメソッド間で意味的に異なる部分とを識別することが可能となる。
For example, the compiling
また、コンパイル装置100によれば、生成した対応関係情報110に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定し、メソッド間で実行面での冗長性を有する重複メソッド候補のマージ処理を行うことができる。これにより、メソッド間で実行面での冗長性を有する複数のメソッドを一つのメソッドにマージすることができ、構文・意味解析区の段階でメソッドの絶対数を削減することができる。
Also, the compiling
例えば、コンパイル装置100は、重複メソッド候補それぞれの中間言語Iコード中の宣言・文・式それぞれのデータのうち少なくともいずれかのデータが、メソッド間で意味的に同一である場合にメソッド間で実行面での冗長性を有すると判定してもよい。これにより、メソッド間で意味的に同一である部分が存在する重複メソッド候補をマージ対象とすることができ、効果的なマージ処理を行うことができる。
For example, the compiling
例えば、コンパイル装置100は、重複メソッド候補それぞれの中間言語Iコード中の宣言・文・式それぞれのデータのうちの所定数X以上のデータが意味的に同一である場合に、メソッド間で実行面での冗長性を有すると判定してもよい。これにより、メソッド間で意味的に同一である部分が多く存在する重複メソッド候補をマージ対象とすることができ、より効果的なマージ処理を行うことができる。
For example, the compiling
これらのことから、コンパイル装置100によれば、最適化区の入力時点でメソッドの絶対数を削減することが可能となり、ソースプログラムscのコンパイル時間の短縮化を図るとともに、オブジェクトファイルfのデータサイズを縮小することができる。また、コンパイル装置100によれば、オブジェクト指向言語の言語的特徴からメソッド間で実行面での冗長性を有する可能性がある重複メソッド候補を絞り込むことができるため、マージ対象となる複数のメソッドの判別を効率的かつ効果的に行うことができる。
Thus, according to the
これにより、ソフトウェア開発の開発スピードを向上させることができる。また、オブジェクトファイルfのデータサイズの縮小により、実行時のプログラムのロード時間の短縮化を図るとともに、コンピュータシステムの省資源化(例えば、CPU負荷、メモリ容量、ディスク容量、ネットワーク負荷など)を図ることができる。 Thereby, the development speed of software development can be improved. Further, by reducing the data size of the object file f, the load time of the program at the time of execution is shortened, and resource savings of the computer system (for example, CPU load, memory capacity, disk capacity, network load, etc.) are achieved. be able to.
なお、本実施の形態で説明したコンパイル方法は、予め用意されたプログラムをパーソナル・コンピュータやワークステーション等のコンピュータで実行することにより実現することができる。本コンパイルプログラムは、ハードディスク、フレキシブルディスク、CD−ROM、MO、DVD等のコンピュータで読み取り可能な記録媒体に記録され、コンピュータによって記録媒体から読み出されることによって実行される。また、本コンパイルプログラムは、インターネット等のネットワークを介して配布してもよい。 The compiling method described in the present embodiment can be realized by executing a program prepared in advance on a computer such as a personal computer or a workstation. The compile program is recorded on a computer-readable recording medium such as a hard disk, a flexible disk, a CD-ROM, an MO, and a DVD, and is executed by being read from the recording medium by the computer. Further, the compiled program may be distributed via a network such as the Internet.
上述した実施の形態に関し、さらに以下の付記を開示する。 The following additional notes are disclosed with respect to the embodiment described above.
(付記1)コンピュータが、
ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、
前記複数のマージ可能メソッドのマージ処理を行う、
処理を実行することを特徴とするコンパイル方法。
(Supplementary note 1)
Extracting multiple merge candidate methods based on at least the inheritance relationship or name from multiple methods in the intermediate language code obtained by parsing and semantic analysis of the source program,
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, extract a plurality of mergeable methods that can be merged from the plurality of merge candidate methods,
Performing a merge process of the plurality of mergeable methods,
A compiling method characterized by executing processing.
(付記2)前記コンピュータが、
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドのメソッド間の対応関係情報を生成する処理を実行し、
前記複数のマージ可能メソッドを抽出する処理は、
前記対応関係情報に基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出することを特徴とする付記1に記載のコンパイル方法。
(Appendix 2) The computer
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, execute processing for generating correspondence information between methods of the plurality of merge candidate methods,
The process of extracting the plurality of mergeable methods includes:
The compiling method according to
(付記3)前記複数のマージ候補メソッドを抽出する処理は、
前記中間言語コード中の複数のメソッドから、親子関係を有するクラス間で同一名のメソッドの組合せを前記複数のマージ候補メソッドとして抽出することを特徴とする付記1または2に記載のコンパイル方法。
(Supplementary Note 3) The process of extracting the plurality of merge candidate methods is as follows:
3. The compiling method according to
(付記4)前記複数のマージ候補メソッドを抽出する処理は、
前記中間言語コード中の複数のメソッドから、同一クラス内のメソッド、あるいは、いずれのクラスにも属していないメソッドのうち、同一名のメソッドの組合せを前記複数のマージ候補メソッドとして抽出することを特徴とする付記1〜3のいずれか一つに記載のコンパイル方法。
(Supplementary Note 4) The process of extracting the plurality of merge candidate methods is as follows:
A combination of methods having the same name among methods in the same class or methods not belonging to any class is extracted as a plurality of merge candidate methods from a plurality of methods in the intermediate language code. The compiling method according to any one of
(付記5)前記複数のマージ候補メソッドを抽出する処理は、
前記中間言語コード中の複数のメソッドから、同一クラス内の演算子、あるいは、いずれのクラスにも属していない演算子のうち、同一名の演算子の組合せを前記複数のマージ候補メソッドとして抽出することを特徴とする付記1〜4のいずれか一つに記載のコンパイル方法。
(Supplementary Note 5) The process of extracting the plurality of merge candidate methods is as follows:
From a plurality of methods in the intermediate language code, a combination of operators having the same name among operators in the same class or operators not belonging to any class is extracted as the plurality of merge candidate methods. The compiling method according to any one of
(付記6)前記コンピュータが、
前記複数のマージ候補メソッドそれぞれの中間言語コード中の宣言、文、式それぞれのデータごとに、前記複数のマージ候補メソッドのメソッド間のデータを比較する処理を実行し、
前記生成する処理は、
前記データごとの比較結果に基づいて、前記複数のマージ候補メソッドそれぞれの中間言語コードのうち、前記メソッド間で意味的に同一である部分と前記メソッド間で意味的に異なる部分とを識別する対応関係情報を生成することを特徴とする付記2に記載のコンパイル方法。
(Appendix 6) The computer
For each data of declaration, sentence, and expression in the intermediate language code of each of the plurality of merge candidate methods, execute processing for comparing data between the methods of the plurality of merge candidate methods,
The process to generate is
Corresponding to identifying a portion that is semantically identical between the methods and a portion that is semantically different between the methods, among the intermediate language codes of each of the plurality of merge candidate methods based on the comparison result for each data The compiling method according to
(付記7)前記複数のマージ可能メソッドを抽出する処理は、
前記対応関係情報を参照して、前記複数のマージ候補メソッドそれぞれの中間言語コード中の宣言、文、式それぞれのデータのうちの少なくともいずれかのデータが意味的に同一である前記複数のマージ候補メソッドを、前記複数のマージ可能メソッドとして抽出することを特徴とする付記6に記載のコンパイル方法。
(Supplementary Note 7) The process of extracting the plurality of mergeable methods is as follows:
With reference to the correspondence information, the plurality of merge candidates in which at least one of data of declaration, sentence, and expression in the intermediate language code of each of the plurality of merge candidate methods is semantically identical The compiling method according to
(付記8)前記複数のマージ可能メソッドを抽出する処理は、
前記対応関係情報を参照して、前記複数のマージ候補メソッドそれぞれの中間言語コード中の宣言、文、式それぞれのデータのうちの所定数以上のデータが意味的に同一である前記複数のマージ候補メソッドを、前記複数のマージ可能メソッドとして抽出することを特徴とする付記6に記載のコンパイル方法。
(Supplementary Note 8) The process of extracting the plurality of mergeable methods is as follows:
With reference to the correspondence information, the plurality of merge candidates in which a predetermined number or more of the data of declarations, sentences, and expressions in the intermediate language code of each of the plurality of merge candidate methods is semantically identical The compiling method according to
(付記9)前記マージ処理を行う処理は、
前記対応関係情報に基づいて、前記複数のマージ可能メソッドのメソッド間で共通する処理の中間言語コードと、前記複数のマージ可能メソッドの各メソッドで固有の処理の中間言語コードとをマージして、前記複数のマージ可能メソッドをマージしたメソッド本体の中間言語コードを生成することにより、前記複数のマージ可能メソッドのマージ処理を行うことを特徴とする付記2に記載のコンパイル方法。
(Supplementary Note 9) The process of performing the merge process is as follows:
Based on the correspondence information, the intermediate language code of processing common among the methods of the plurality of mergeable methods and the intermediate language code of processing unique to each method of the plurality of mergeable methods are merged, The compiling method according to
(付記10)前記ソースプログラムは、オブジェクト指向言語によってコーディングされたプログラムであることを特徴とする付記1〜9のいずれか一つに記載のコンパイル方法。
(Supplementary note 10) The compiling method according to any one of
(付記11)ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、前記複数のマージ可能メソッドのマージ処理を行う制御部、
を有することを特徴とするコンパイル装置。
(Supplementary Note 11) A plurality of merge candidate methods are extracted from a plurality of methods in an intermediate language code obtained by syntax analysis and semantic analysis of a source program based on at least an inheritance relationship or a name, and the plurality of merge candidate methods A control unit that extracts a plurality of mergeable methods that can be merged from the plurality of merge candidate methods based on the processing logic specified by each intermediate language code, and performs a merge process of the plurality of mergeable methods;
A compiling device characterized by comprising:
(付記12)コンピュータに、
ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、
前記複数のマージ可能メソッドのマージ処理を行う、
処理を実行させることを特徴とするコンパイルプログラム。
(Supplementary note 12)
Extracting multiple merge candidate methods based on at least the inheritance relationship or name from multiple methods in the intermediate language code obtained by parsing and semantic analysis of the source program,
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, extract a plurality of mergeable methods that can be merged from the plurality of merge candidate methods,
Performing a merge process of the plurality of mergeable methods,
A compiled program characterized by causing processing to be executed.
(付記13)コンピュータに、
ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、
前記複数のマージ可能メソッドのマージ処理を行う、
処理を実行させるコンパイルプログラムを記録したことを特徴とする前記コンピュータに読み取り可能な記録媒体。
(Supplementary note 13)
Extracting multiple merge candidate methods based on at least the inheritance relationship or name from multiple methods in the intermediate language code obtained by parsing and semantic analysis of the source program,
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, extract a plurality of mergeable methods that can be merged from the plurality of merge candidate methods,
Performing a merge process of the plurality of mergeable methods,
A computer-readable recording medium in which a compilation program for executing processing is recorded.
100 コンパイル装置
501 取得部
502 解析部
503 抽出部
504 生成部
505 判定部
506 マージ処理部
507 最適化部
508 コード生成部
509 出力部
DESCRIPTION OF
Claims (10)
ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、
前記複数のマージ可能メソッドのマージ処理を行う、
処理を実行することを特徴とするコンパイル方法。 Computer
Extracting multiple merge candidate methods based on at least the inheritance relationship or name from multiple methods in the intermediate language code obtained by parsing and semantic analysis of the source program,
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, extract a plurality of mergeable methods that can be merged from the plurality of merge candidate methods,
Performing a merge process of the plurality of mergeable methods,
A compiling method characterized by executing processing.
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドのメソッド間の対応関係情報を生成する処理を実行し、
前記複数のマージ可能メソッドを抽出する処理は、
前記対応関係情報に基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出することを特徴とする請求項1に記載のコンパイル方法。 The computer is
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, execute processing for generating correspondence information between methods of the plurality of merge candidate methods,
The process of extracting the plurality of mergeable methods includes:
The compiling method according to claim 1, wherein a plurality of mergeable methods are extracted from the plurality of merge candidate methods based on the correspondence information.
前記中間言語コード中の複数のメソッドから、親子関係を有するクラス間で同一名のメソッドの組合せを前記複数のマージ候補メソッドとして抽出することを特徴とする請求項1または2に記載のコンパイル方法。 The process of extracting the plurality of merge candidate methods is as follows:
3. The compiling method according to claim 1, wherein a combination of methods having the same name between classes having a parent-child relationship is extracted as the plurality of merge candidate methods from a plurality of methods in the intermediate language code.
前記中間言語コード中の複数のメソッドから、同一クラス内のメソッド、あるいは、いずれのクラスにも属していないメソッドのうち、同一名のメソッドの組合せを前記複数のマージ候補メソッドとして抽出することを特徴とする請求項1〜3のいずれか一つに記載のコンパイル方法。 The process of extracting the plurality of merge candidate methods is as follows:
A combination of methods having the same name among methods in the same class or methods not belonging to any class is extracted as a plurality of merge candidate methods from a plurality of methods in the intermediate language code. The compiling method according to any one of claims 1 to 3.
前記中間言語コード中の複数のメソッドから、同一クラス内の演算子、あるいは、いずれのクラスにも属していない演算子のうち、同一名の演算子の組合せを前記複数のマージ候補メソッドとして抽出することを特徴とする請求項1〜4のいずれか一つに記載のコンパイル方法。 The process of extracting the plurality of merge candidate methods is as follows:
From a plurality of methods in the intermediate language code, a combination of operators having the same name among operators in the same class or operators not belonging to any class is extracted as the plurality of merge candidate methods. The compiling method according to any one of claims 1 to 4.
前記複数のマージ候補メソッドそれぞれの中間言語コード中の宣言、文、式それぞれのデータごとに、前記複数のマージ候補メソッドのメソッド間のデータを比較する処理を実行し、
前記生成する処理は、
前記データごとの比較結果に基づいて、前記複数のマージ候補メソッドそれぞれの中間言語コードのうち、前記メソッド間で意味的に同一である部分と前記メソッド間で意味的に異なる部分とを識別する対応関係情報を生成することを特徴とする請求項2に記載のコンパイル方法。 The computer is
For each data of declaration, sentence, and expression in the intermediate language code of each of the plurality of merge candidate methods, execute processing for comparing data between the methods of the plurality of merge candidate methods,
The process to generate is
Corresponding to identifying a portion that is semantically identical between the methods and a portion that is semantically different between the methods, among the intermediate language codes of each of the plurality of merge candidate methods based on the comparison result for each data The compiling method according to claim 2, wherein the relation information is generated.
前記対応関係情報を参照して、前記複数のマージ候補メソッドそれぞれの中間言語コード中の宣言、文、式それぞれのデータのうちの少なくともいずれかのデータが意味的に同一である前記複数のマージ候補メソッドを、前記複数のマージ可能メソッドとして抽出することを特徴とする請求項6に記載のコンパイル方法。 The process of extracting the plurality of mergeable methods includes:
With reference to the correspondence information, the plurality of merge candidates in which at least one of data of declaration, sentence, and expression in the intermediate language code of each of the plurality of merge candidate methods is semantically identical The compiling method according to claim 6, wherein a method is extracted as the plurality of mergeable methods.
を有することを特徴とするコンパイル装置。 A plurality of merge candidate methods are extracted from a plurality of methods in the intermediate language code obtained by the syntax analysis and semantic analysis of the source program based on at least the inheritance relationship or the name, and the intermediate languages of the plurality of merge candidate methods are extracted. Based on the processing logic specified by the code, a control unit that extracts a plurality of mergeable methods that can be merged from the plurality of merge candidate methods, and performs a merge process of the plurality of mergeable methods;
A compiling device characterized by comprising:
ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、
前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、
前記複数のマージ可能メソッドのマージ処理を行う、
処理を実行させることを特徴とするコンパイルプログラム。 On the computer,
Extracting multiple merge candidate methods based on at least the inheritance relationship or name from multiple methods in the intermediate language code obtained by parsing and semantic analysis of the source program,
Based on the processing logic specified by the intermediate language code of each of the plurality of merge candidate methods, extract a plurality of mergeable methods that can be merged from the plurality of merge candidate methods,
Performing a merge process of the plurality of mergeable methods,
A compiled program characterized by causing processing to be executed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2014093212A JP6264179B2 (en) | 2014-04-28 | 2014-04-28 | Compiling method, compiling device, and compiling program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2014093212A JP6264179B2 (en) | 2014-04-28 | 2014-04-28 | Compiling method, compiling device, and compiling program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2015210740A true JP2015210740A (en) | 2015-11-24 |
JP6264179B2 JP6264179B2 (en) | 2018-01-24 |
Family
ID=54612851
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2014093212A Active JP6264179B2 (en) | 2014-04-28 | 2014-04-28 | Compiling method, compiling device, and compiling program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6264179B2 (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105468428A (en) * | 2015-12-04 | 2016-04-06 | 上海斐讯数据通信技术有限公司 | Android source code compiling method and system |
WO2018116449A1 (en) * | 2016-12-22 | 2018-06-28 | 三菱電機株式会社 | Program development assistance device and management method for program component |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH09146766A (en) * | 1995-11-17 | 1997-06-06 | Hitachi Ltd | Method for changing class structure |
US6041180A (en) * | 1997-04-28 | 2000-03-21 | International Business Machines Corporation | System and method for optimizing template object files |
JP2011203960A (en) * | 2010-03-25 | 2011-10-13 | Fujitsu Ltd | Method and device for compiling template |
JP2013210920A (en) * | 2012-03-30 | 2013-10-10 | Nec Corp | Compilation device, compilation method, and compiler |
-
2014
- 2014-04-28 JP JP2014093212A patent/JP6264179B2/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH09146766A (en) * | 1995-11-17 | 1997-06-06 | Hitachi Ltd | Method for changing class structure |
US6041180A (en) * | 1997-04-28 | 2000-03-21 | International Business Machines Corporation | System and method for optimizing template object files |
JP2011203960A (en) * | 2010-03-25 | 2011-10-13 | Fujitsu Ltd | Method and device for compiling template |
JP2013210920A (en) * | 2012-03-30 | 2013-10-10 | Nec Corp | Compilation device, compilation method, and compiler |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105468428A (en) * | 2015-12-04 | 2016-04-06 | 上海斐讯数据通信技术有限公司 | Android source code compiling method and system |
CN105468428B (en) * | 2015-12-04 | 2018-07-06 | 上海斐讯数据通信技术有限公司 | A kind of Android compilation of source code method and system |
WO2018116449A1 (en) * | 2016-12-22 | 2018-06-28 | 三菱電機株式会社 | Program development assistance device and management method for program component |
KR20190070999A (en) * | 2016-12-22 | 2019-06-21 | 미쓰비시덴키 가부시키가이샤 | How to manage program development support device and program parts |
KR102021327B1 (en) | 2016-12-22 | 2019-09-16 | 미쓰비시덴키 가부시키가이샤 | Program Development Supporting Device and Program Parts Management Method |
Also Published As
Publication number | Publication date |
---|---|
JP6264179B2 (en) | 2018-01-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7865870B2 (en) | Automatic content completion of valid values for method argument variables | |
US11036937B2 (en) | Contraction aware parsing system for domain-specific languages | |
US20180136914A1 (en) | Programming Language with Extensions using a Strict Meta-Model | |
WO2021017735A1 (en) | Smart contract formal verification method, electronic apparatus and storage medium | |
CN110149800B (en) | Apparatus for processing abstract syntax tree associated with source code of source program | |
US11531529B2 (en) | Method and electronic device for deploying operator in deep learning framework | |
US9081586B2 (en) | Systems and methods for customizing optimization/transformation/ processing strategies | |
US9164744B2 (en) | Method and system for program building | |
JPH08202545A (en) | Object-oriented system and method for generation of target language code | |
CN109313547B (en) | Query optimizer for CPU utilization and code reformulation | |
US20160321055A1 (en) | Mapping between local and remote for seamless build and design time experience | |
CN111736840A (en) | Compiling method and running method of applet, storage medium and electronic equipment | |
CN111316232A (en) | Providing optimization using annotations of programs | |
US11487522B1 (en) | Training and/or using neural network model to generate target source code from lower-level representation | |
JP5176478B2 (en) | Data flow analysis device, data flow analysis method, and data flow analysis program | |
CN106484389B (en) | Action stream segment management | |
US20190042207A1 (en) | Configuration model parsing for constraint-based systems | |
JP6264179B2 (en) | Compiling method, compiling device, and compiling program | |
US9274755B2 (en) | Infrastructure for generating code using annotation and template generators | |
JP6651974B2 (en) | Information processing apparatus, compiling method and compiler program | |
Edmunds et al. | Tool support for Event-B code generation | |
KR20190123146A (en) | Application converting apparatus and method for improving security | |
WO2016189721A1 (en) | Source code evaluation device, source code evaluation method, and source code evaluation program | |
US20150347182A1 (en) | Computer product, execution-flow-creation aiding apparatus, and execution-flow-creation aiding method | |
CN110727428A (en) | Method and device for converting service logic layer codes and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20170206 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20171117 |
|
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: 20171121 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20171204 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6264179 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |