JP2015210740A - Compilation method, compilation device, and compilation program - Google Patents

Compilation method, compilation device, and compilation program Download PDF

Info

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
Application number
JP2014093212A
Other languages
Japanese (ja)
Other versions
JP6264179B2 (en
Inventor
石川 貴洋
Takahiro Ishikawa
貴洋 石川
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.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2014093212A priority Critical patent/JP6264179B2/en
Publication of JP2015210740A publication Critical patent/JP2015210740A/en
Application granted granted Critical
Publication of JP6264179B2 publication Critical patent/JP6264179B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

PROBLEM TO BE SOLVED: To shorten a compilation time of a source program.SOLUTION: A compilation device 100 extracts duplicate method candidates from a method group in an intermediate language I code obtained through syntax analysis and meaning analysis on a source program sc. The compilation device 100 generates information 110 on correspondence relation between methods of the extracted duplicate method candidates based upon processing logic specified with respective intermediate language I codes of the extracted duplicate method candidates. The compilation device 100 determines whether the methods of the duplicate method candidates have redundancy in terms of execution based upon the generated correspondence relation information 110, and performs merging processing on duplicate method candidates having the redundancy between methods in terms of execution.

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.

特表2002−517815号公報JP-T-2002-517815 特開平10−171656号公報JP-A-10-171656

しかしながら、従来技術によれば、オブジェクト指向言語でコーディングされたソースプログラムには、オブジェクト指向言語の言語的特徴から大量のメソッドが含まれることが多く、ソースプログラムのコンパイル時間の増加を招くという問題がある。   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.

図1は、実施の形態にかかるコンパイル方法の一実施例を示す説明図である。FIG. 1 is an explanatory diagram of an example of the compiling method according to the embodiment. 図2は、コンパイル装置100のハードウェア構成例を示すブロック図である。FIG. 2 is a block diagram illustrating a hardware configuration example of the compiling device 100. 図3は、ソースプログラムscの具体例を示す説明図である。FIG. 3 is an explanatory diagram showing a specific example of the source program sc. 図4は、中間言語Iコードの具体例を示す説明図である。FIG. 4 is an explanatory diagram showing a specific example of the intermediate language I code. 図5は、コンパイル装置100の機能的構成例を示すブロック図である。FIG. 5 is a block diagram illustrating a functional configuration example of the compiling device 100. 図6は、重複メソッド候補のメソッド間のデータの比較例を示す説明図(その1)である。FIG. 6 is an explanatory diagram (part 1) of a comparative example of data between methods of duplicate method candidates. 図7は、重複メソッド候補のメソッド間のデータの比較例を示す説明図(その2)である。FIG. 7 is an explanatory diagram (part 2) illustrating a comparative example of data between methods of duplicate method candidates. 図8は、重複メソッド候補のメソッド間のデータの比較例を示す説明図(その3)である。FIG. 8 is an explanatory diagram (part 3) of a comparative example of data between methods of duplicate method candidates. 図9は、重複メソッド候補のメソッド間のデータの比較例を示す説明図(その4)である。FIG. 9 is an explanatory diagram (part 4) illustrating a comparative example of data between methods of duplicate method candidates. 図10は、SetColorメソッドのマージ処理を示す説明図である。FIG. 10 is an explanatory diagram showing merge processing of the SetColor method. 図11は、SetColorメソッドをマージしたメソッド本体の中間言語Iコードの一例を示す説明図である。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. 図12は、重複メソッド候補をマージしないソースプログラム例を示す説明図である。FIG. 12 is an explanatory diagram of an example of a source program that does not merge duplicate method candidates. 図13は、コンパイル装置100のコンパイル処理手順の一例を示すフローチャートである。FIG. 13 is a flowchart illustrating an example of a compile processing procedure of the compile device 100. 図14は、重複メソッド候補抽出処理の具体的処理手順の一例を示すフローチャートである。FIG. 14 is a flowchart illustrating an example of a specific processing procedure of the duplicate method candidate extraction processing. 図15は、対応関係情報生成処理の具体的処理手順の一例を示すフローチャートである。FIG. 15 is a flowchart illustrating an example of a specific processing procedure of the correspondence relationship information generation processing. 図16は、マージ処理の具体的処理手順の一例を示すフローチャートである。FIG. 16 is a flowchart illustrating an example of a specific processing procedure of the merge processing.

以下に図面を参照して、本発明にかかるコンパイル方法、コンパイル装置およびコンパイルプログラムの実施の形態を詳細に説明する。   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 device 100 is a computer that compiles a source program sc. The source program sc includes source code coded in an object-oriented language. Examples of object-oriented languages include Java and C ++.

コンパイラのコンパイル処理は、大きく分けると、構文・意味解析区、最適化区およびコード生成区に区分けされる。構文・意味解析区では、ソースプログラム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 device 100 will be described.

(1)コンパイル装置100は、構文・意味解析区において、ソースプログラムscの構文解析および意味解析を行う。ここで、構文解析とは、ソースプログラムscに記述された文(ステートメント)や構造が言語仕様に沿っているか否かをチェックすることである。意味解析は、ソースプログラムscに記述された変数の型や文が意味的に正しいか否かをチェックすることである。   (1) The compiling device 100 performs syntax analysis and semantic analysis of the source program sc in the syntax / semantic analysis section. Here, the syntax analysis is to check whether a sentence or a structure described in the source program sc conforms to the language specification. Semantic analysis is to check whether the variable type and sentence described in the source program sc are semantically correct.

ソースプログラム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 device 100 has a plurality of methods based on at least an inheritance relationship or a name from a plurality of methods in the intermediate language I code obtained by syntax analysis and semantic analysis of the source program sc. Extract merge candidate methods. Here, the plurality of merge candidate methods are a plurality of methods that may have redundancy in terms of execution.

以下の説明では、複数のマージ候補メソッドをまとめて「重複メソッド候補」と表記する場合がある。重複メソッド候補としては、例えば、オーバーライドされたメソッドやオーバーロードされたメソッドがある。   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 device 100 refers to the intermediate language I code of the source program sc, and extracts a plurality of methods having the same name between classes having a parent-child relationship as duplicate method candidates. Thereby, the overridden method can be extracted as a duplicate method candidate.

(3)コンパイル装置100は、構文・意味解析区において、抽出した重複メソッド候補それぞれの中間言語Iコードにより特定される処理ロジックに基づいて、重複メソッド候補のメソッド間の対応関係情報110を生成する。ここで、対応関係情報110は、重複メソッド候補のメソッド間の実行面での冗長性の有無を判断するための情報である。   (3) In the syntax / semantic analysis section, the compiling device 100 generates correspondence information 110 between methods of duplicate method candidates based on the processing logic specified by the intermediate language I code of each extracted duplicate method candidate. . Here, the correspondence relationship information 110 is information for determining whether there is redundancy in terms of execution between methods of duplicate method candidates.

具体的には、例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコードから、重複メソッド候補それぞれに対応する中間言語Iコードを抽出する。つぎに、コンパイル装置100は、抽出した中間言語Iコード中の宣言・文・式それぞれのデータごとに、メソッド間のデータを比較する。   Specifically, for example, the compiling device 100 extracts an intermediate language I code corresponding to each duplicate method candidate from the intermediate language I code of the source program sc. Next, the compiling device 100 compares data between methods for each data of declaration, sentence, and expression in the extracted intermediate language I code.

そして、コンパイル装置100は、データごとの比較結果に基づいて、重複メソッド候補それぞれに対応する中間言語Iコードのうち、メソッド間で意味的に同一である部分と、メソッド間で意味的に異なる部分(各メソッド固有の部分)を識別する情報を対応関係情報110として生成する。   Then, the compiling device 100, based on the comparison result for each data, in the intermediate language I code corresponding to each duplicate method candidate, a portion that is semantically identical between methods and a portion that is semantically different between methods Information for identifying (a part unique to each method) is generated as correspondence information 110.

(4)コンパイル装置100は、構文・意味解析区において、生成した対応関係情報110に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定する。具体的には、例えば、コンパイル装置100は、宣言・文・式それぞれのデータのうち少なくともいずれかのデータが意味的に同一である場合に、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定してもよい。メソッド間で実行面での冗長性を有する重複メソッド候補は、マージ可能な複数のマージ可能メソッドである。   (4) In the syntax / semantic analysis section, the compiling device 100 determines whether or not there is redundancy in terms of execution between methods of duplicate method candidates based on the generated correspondence relationship information 110. Specifically, for example, the compiling apparatus 100 performs redundancy in terms of execution between duplicate method candidate methods when at least one of the data of declarations, statements, and expressions is semantically identical. You may determine with having. Duplicate method candidates having execution redundancy between methods are a plurality of mergeable methods that can be merged.

(5)コンパイル装置100は、構文・意味解析区において、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定した場合に、対応関係情報110に基づいて、重複メソッド候補のマージ処理を行う。すなわち、コンパイル装置100は、重複メソッド候補からマージ可能な複数のマージ可能メソッドを抽出して、複数のマージ可能メソッドのマージ処理を行う。ここで、マージ処理とは、重複メソッド候補である複数のメソッドを、重複メソッド候補のいずれの呼び出し元からも呼び出せる一つのメソッドとしてまとめることである。   (5) When the compiling device 100 determines that there is redundancy in terms of execution between methods of duplicate method candidates in the syntax / semantic analysis section, the merge method of duplicate method candidates based on the correspondence information 110 I do. That is, the compiling device 100 extracts a plurality of mergeable methods that can be merged from the duplicate method candidates, and performs a merge process for the plurality of mergeable methods. Here, the merging process is to combine a plurality of methods that are duplicate method candidates as one method that can be called from any caller of the duplicate method candidates.

例えば、メソッド間で冗長性を有するメソッドとして、メソッド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 device 100 generates an intermediate language I code for processing that is common among methods of duplicate method candidates, and also generates an intermediate language I code for processing unique to each method of the duplicate method candidates. . Then, the compiling device 100 generates the intermediate language I code of the method body in which the duplicate method candidates are merged by merging the generated intermediate language I code.

(6)コンパイル装置100は、構文・意味解析区において、マージしたメソッド本体の中間言語Iコードに基づいて、コンパイラ内のインターフェースである中間言語IIコードを生成する。具体的には、例えば、コンパイル装置100は、中間言語Iコードで表現したメソッド(マージしたメソッド本体、マージしていないメソッド)を中間言語IIコードの形式に変換する。生成された中間言語IIコードは最適化区に入力される。   (6) The compiling device 100 generates intermediate language II code that is an interface in the compiler based on the merged intermediate language I code of the method body in the syntax / semantic analysis section. Specifically, for example, the compiling device 100 converts a method expressed by an intermediate language I code (a merged method body and an unmerged method) into an intermediate language II code format. The generated intermediate language II code is input to the optimization section.

図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 compiling device 100 performs an optimization process of the intermediate language II code of the source program sc in the optimization section. In the optimization process, for example, a method deemed unnecessary from the intermediate language II code is deleted. In the example of FIG. 1, one method deemed unnecessary is deleted from the intermediate language II code. The intermediate language II code subjected to the optimization process is input to the code generation area.

(8)コンパイル装置100は、コード生成区において、最適化処理が行われた中間言語IIコードに基づいて、オブジェクトファイルfを生成する。生成されたオブジェクトファイルfは、例えば、リンカに渡されて、最終的に実行プログラムが生成される。   (8) The compiling device 100 generates the object file f in the code generation section based on the intermediate language II code on which the optimization process has been performed. The generated object file f is transferred to, for example, a linker, and an execution program is finally generated.

このように、実施の形態にかかるコンパイル装置100によれば、構文・意味解析区において、オブジェクト指向言語特有の性質にマッチした効果的な最適化を行ってメソッドの絶対数を削減することができる。これにより、最適化区の入力時点でメソッドの絶対数を削減可能となるため、最適化処理にかかる処理時間が少なくなり、結果的に、ソースプログラムscのコンパイル時間を短縮することができる。また、メソッドの絶対数を削減することにより、オブジェクトファイルfのデータサイズを縮小することができる。   As described above, according to the compiling device 100 according to the embodiment, in the syntax / semantic analysis section, it is possible to reduce the absolute number of methods by performing effective optimization that matches the characteristics specific to the object-oriented language. . Thereby, since the absolute number of methods can be reduced at the time of input of the optimization section, the processing time required for the optimization process is reduced, and as a result, the compilation time of the source program sc can be shortened. Further, the data size of the object file f can be reduced by reducing the absolute number of methods.

(コンパイル装置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 compiling device 100. 2, the compiling device 100 includes a CPU (Central Processing Unit) 201, a memory 202, a disk drive 203, a disk 204, an I / F (Interface) 205, a display 206, a keyboard 207, and a mouse 208. And having. Each component is connected by a bus 200.

ここで、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 compiling device 100. The memory 202 includes, for example, a ROM (Read Only Memory), a RAM (Random Access Memory), and a flash ROM. Specifically, for example, a flash ROM or ROM stores various programs (for example, a compiled program), and a RAM is used as a work area of the CPU 201. The program stored in the memory 202 is loaded on the CPU 201 to cause the CPU 201 to execute the coded process.

ディスクドライブ203は、CPU201の制御に従ってディスク204に対するデータのリード/ライトを制御する。ディスク204は、ディスクドライブ203の制御で書き込まれたデータを記憶する。ディスク204としては、例えば、磁気ディスク、光ディスクなどが挙げられる。   The disk drive 203 controls reading / writing of data with respect to the disk 204 according to the control of the CPU 201. The disk 204 stores data written under the control of the disk drive 203. Examples of the disk 204 include a magnetic disk and an optical disk.

I/F205は、通信回線を通じてネットワーク210に接続され、ネットワーク210を介して他のコンピュータに接続される。そして、I/F205は、ネットワーク210と内部のインターフェースを司り、他のコンピュータからのデータの入出力を制御する。I/F205には、例えば、モデムやLANアダプタなどを採用することができる。   The I / F 205 is connected to the network 210 via a communication line, and is connected to another computer via the network 210. The I / F 205 controls an internal interface with the network 210 and controls input / output of data from other computers. For example, a modem or a LAN adapter may be employed as the I / F 205.

ディスプレイ206は、カーソル、アイコンあるいはツールボックスをはじめ、文書、画像、機能情報などのデータを表示する。ディスプレイ206は、例えば、CRT(Cathode Ray Tube)、TFT(Thin Film Transistor)液晶ディスプレイ、プラズマディスプレイなどを採用することができる。   A display 206 displays data such as a document, an image, and function information as well as a cursor, an icon, or a tool box. As the display 206, for example, a CRT (Cathode Ray Tube), a TFT (Thin Film Transistor) liquid crystal display, a plasma display, or the like can be adopted.

キーボード207は、文字、数字、各種指示などの入力のためのキーを備え、データの入力を行う。キーボード207は、タッチパネル式の入力パッドやテンキーなどであってもよい。マウス208は、カーソルの移動や範囲選択、あるいはウィンドウの移動やサイズの変更などを行う。   The keyboard 207 includes keys for inputting characters, numbers, various instructions, and the like, and inputs data. The keyboard 207 may be a touch panel type input pad or a numeric keypad. The mouse 208 performs cursor movement, range selection, window movement, size change, and the like.

(ソースプログラム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 source program 300 is an example of an object-oriented program coded in an object-oriented language.

ソースプログラム300では、3行目の基底クラスCOLORにおいて、色(カラー)の基本データと処理ロジックを定義している。10行目には、基底クラスCOLORのSetColorメソッドが定義されている。また、22行目の派生クラスREDは、基底クラスCOLORを継承したクラスである。24行目には、REDクラスのメソッドとして、基底クラスCOLORのSetColorメソッドをオーバーライドして定義している。   In the source program 300, color basic data and processing logic are defined in the base class COLOR on the third line. In line 10, the SetColor method of the base class COLOR is defined. The derived class RED on the 22nd line is a class that inherits the base class COLOR. On the 24th line, as a method of the RED class, it is defined by overriding the SetColor method of the base class COLOR.

(中間言語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 codes 410 and 420 schematically show intermediate language I codes obtained by syntax analysis and semantic analysis of the source program 300 (FIG. 3).

具体的には、中間言語Iコード410は、ソースプログラム300内の10行目に定義されたSetColorメソッドを表現する中間言語Iコードである。また、中間言語Iコード420は、ソースプログラム300内の24行目に定義されたSetColorメソッドを表現する中間言語Iコードである。   Specifically, the intermediate language I code 410 is an intermediate language I code that expresses the SetColor method defined on the 10th line in the source program 300. The intermediate language I code 420 is an intermediate language I code that represents the SetColor method defined on the 24th line in the source program 300.

ここで、中間言語Iコード410は、データ411〜414を含む。データ411は、ソースプログラム300に記述された基底クラスCOLORのSetColorメソッドの宣言情報の構文、意味を表現したものである。データ412〜414は、基底クラスCOLORのSetColorメソッドの文情報の構文、意味を表現したものであり、データ415〜417をそれぞれ含む。データ415〜417は、基底クラスCOLORのSetColorメソッドの式情報の構文、意味をそれぞれ表現したものである。   Here, the intermediate language I code 410 includes data 411 to 414. The data 411 represents the syntax and meaning of the declaration information of the SetColor method of the base class COLOR described in the source program 300. Data 412 to 414 represent the syntax and meaning of sentence information of the SetColor method of the base class COLOR, and include data 415 to 417, respectively. Data 415 to 417 represent the syntax and meaning of the expression information of the SetColor method of the base class COLOR, respectively.

また、中間言語Iコード420は、データ421〜424を含む。データ421は、ソースプログラム300に記述された派生クラスREDのSetColorメソッドの宣言情報の構文、意味を表現したものである。データ422〜424は、派生クラスREDのSetColorメソッドの文情報の構文、意味を表現したものであり、データ425〜427をそれぞれ含む。データ425〜427は、派生クラスREDのSetColorメソッドの式情報の構文、意味をそれぞれ表現したものである。   Further, the intermediate language I code 420 includes data 421 to 424. Data 421 represents the syntax and meaning of the declaration information of the SetColor method of the derived class RED described in the source program 300. Data 422 to 424 represent the syntax and meaning of sentence information of the SetColor method of the derived class RED, and include data 425 to 427, respectively. Data 425 to 427 represent the syntax and meaning of the expression information of the SetColor method of the derived class RED.

この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 compiling device 100. 5, the compiling apparatus 100 includes an acquisition unit 501, an analysis unit 502, an extraction unit 503, a generation unit 504, a determination unit 505, a merge processing unit 506, an optimization unit 507, and a code generation unit 508. And an output unit 509. The acquisition unit 501 to the output unit 509 are functions serving as a control unit. Specifically, for example, by causing the CPU 201 to execute a program stored in a storage device such as the memory 202 and the disk 204 illustrated in FIG. Alternatively, the function is realized by the I / F 205. The processing result of each functional unit is stored in a storage device such as the memory 202 and the disk 204, for example.

取得部501は、ソースプログラムscを取得する。ソースプログラムscは、JavaやC++などのオブジェクト指向言語でコーディングされたソースコードを含むものであり、例えば、FortranやC言語などでコーディングされたソースコードが含まれていてもよい。   The acquisition unit 501 acquires the source program sc. The source program sc includes source code coded in an object-oriented language such as Java or C ++. For example, the source program sc may include source code coded in Fortran or C language.

具体的には、例えば、取得部501は、キーボード207やマウス208を用いたユーザの操作入力により、ソースプログラムsc(例えば、ソースプログラム300)を取得する。また、例えば、取得部501は、I/F205により、外部のコンピュータからソースプログラムscを取得することにしてもよい。   Specifically, for example, the acquisition unit 501 acquires the source program sc (for example, the source program 300) by a user operation input using the keyboard 207 or the mouse 208. For example, the acquisition unit 501 may acquire the source program sc from an external computer by the I / F 205.

解析部502は、ソースプログラムscの構文解析および意味解析を行う。具体的には、例えば、まず、解析部502は、ソースプログラムscの字句解析を行う。字句解析とは、ソースプログラムscを構成する文字の並びを、例えば、キーワード、変数、演算子などのトークンの並びに変換することである。   The analysis unit 502 performs syntax analysis and semantic analysis of the source program sc. Specifically, for example, the analysis unit 502 first performs lexical analysis of the source program sc. Lexical analysis is the conversion of a sequence of characters that make up the source program sc, for example, a sequence of tokens such as keywords, variables, and operators.

そして、解析部502は、字句解析により得られるトークンの並びについて、トークン間の関係を解析することにより、ソースプログラムscの構文解析および意味解析を行う。これにより、例えば、図4に示したような、構文・意味解析区内のインターフェースである中間言語Iコードを得ることができる。   Then, the analysis unit 502 performs syntax analysis and semantic analysis of the source program sc by analyzing the relationship between tokens with respect to the token sequence obtained by the lexical analysis. Thereby, for example, an intermediate language I code which is an interface in the syntax / semantic analysis section as shown in FIG. 4 can be obtained.

なお、中間言語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 extraction unit 503 extracts duplicate method candidates from a plurality of methods in the intermediate language I code obtained by syntax analysis and semantic analysis of the source program sc. Here, as described above, the duplicate method candidates are a plurality of merge candidate methods that are candidates for execution redundancy between methods, and are, for example, methods that are overridden or overloaded.

具体的には、例えば、抽出部503は、生成された中間言語Iコードを参照して、親子関係を有するクラス間で同一名のメソッドの組合せを重複メソッド候補として抽出する。これにより、オーバーライドされたメソッドを重複メソッド候補として抽出することができる。   Specifically, for example, the extraction unit 503 refers to the generated intermediate language I code and extracts a combination of methods having the same name between classes having a parent-child relationship as duplicate method candidates. Thereby, the overridden method can be extracted as a duplicate method candidate.

図3に示したソースプログラム300を例に挙げると、基底クラスCOLORと派生クラスREDとが親子関係を有するクラスである。このため、抽出部503は、ソースプログラム300の中間言語Iコード(図4に示した中間言語Iコード410,420を含む中間言語Iコード)を参照して、基底クラスCOLORと派生クラスREDとの間でメソッド名が同一のSetColorメソッドを重複メソッド候補として抽出する。   Taking the source program 300 shown in FIG. 3 as an example, the base class COLOR and the derived class RED are classes having a parent-child relationship. For this reason, the extraction unit 503 refers to the intermediate language I code of the source program 300 (intermediate language I code including the intermediate language I codes 410 and 420 shown in FIG. 4), and determines the base class COLOR and the derived class RED. The SetColor method having the same method name is extracted as a duplicate method candidate.

また、抽出部503は、例えば、生成された中間言語Iコードを参照して、同一クラス内のメソッド、あるいは、いずれのクラスにも属していないメソッドのうち、同一名のメソッドの組合せを重複メソッド候補として抽出することにしてもよい。これにより、オーバーロードされたメソッドを重複メソッド候補として抽出することができる。   In addition, the extraction unit 503 refers to the generated intermediate language I code, for example, duplicates a combination of methods having the same name among methods in the same class or methods not belonging to any class. You may decide to extract as a candidate. As a result, the overloaded method can be extracted as a duplicate method candidate.

また、抽出部503は、例えば、生成された中間言語Iコードを参照して、同一クラス内の演算子、あるいは、いずれのクラスにも属していない演算子のうち、同一名の演算子の組合せを重複メソッド候補として抽出することにしてもよい。これにより、オーバーロードされた演算子(多重定義演算子)を重複メソッド候補として抽出することができる。   Further, the extraction unit 503 refers to the generated intermediate language I code, for example, and combines the operators of the same name among the operators in the same class or the operators not belonging to any class May be extracted as a duplicate method candidate. Thereby, an overloaded operator (overloaded operator) can be extracted as a duplicate method candidate.

なお、オーバーロードされた演算子(多重定義演算子)は、名称(メソッド名)が同一で、かつ、引数の型、数、並び順の少なくともいずれかが異なる演算子である。   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 generation unit 504 generates correspondence information 110 between methods of duplicate method candidates based on the processing logic specified by the intermediate language I code of each of the extracted duplicate method candidates. Specifically, for example, the generation unit 504 extracts an intermediate language I code corresponding to each duplicate method candidate from the intermediate language I code of the source program sc.

つぎに、生成部504は、抽出した中間言語Iコード中の宣言・文・式それぞれのデータごとに、メソッド間のデータを比較する。中間言語Iコードは、ソースプログラムscに記述された順に従って宣言・文・式の構造が形成されている。このため、生成部504は、中間言語Iコードの構造に従って、メソッド間のデータを順次比較する。   Next, the generation unit 504 compares data between methods for each data of declaration, sentence, and expression in the extracted intermediate language I code. The intermediate language I code has a declaration / sentence / expression structure formed in the order described in the source program sc. Therefore, the generation unit 504 sequentially compares data between methods according to the structure of the intermediate language I code.

なお、中間言語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 generation unit 504 generates a portion that is semantically identical between methods and a portion that is semantically different between methods (specific to each method). Information for identifying (part) is generated as correspondence information 110. Note that a comparative example of data between methods and a generation example of the correspondence information 110 will be described later with reference to FIGS.

判定部505は、生成された対応関係情報110に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定する。具体的には、例えば、判定部505は、中間言語Iコード中の宣言・文・式それぞれのデータのうち少なくともいずれかのデータが意味的に同一である場合に、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定してもよい。   Based on the generated correspondence information 110, the determination unit 505 determines whether or not there is redundancy in terms of execution between methods of the duplicate method candidate. Specifically, for example, the determination unit 505 determines whether or not at least one of the declaration, sentence, and expression data in the intermediate language I code is semantically identical between duplicate method candidate methods. It may be determined that there is redundancy in terms of execution.

また、例えば、判定部505は、中間言語Iコード中の宣言・文・式それぞれのデータのうちの所定数X以上のデータが意味的に同一である場合に、重複メソッド候補のメソッド間で実行面での冗長性を有すると判定してもよい。ここで、所定数Xは、例えば、予め任意に設定されてメモリ202やディスク204などの記憶装置に記憶されていてもよい。   Further, for example, the determination unit 505 executes between duplicate method candidate methods when data of a predetermined number X or more among the data of declarations, sentences, and expressions in the intermediate language I code is semantically identical. It may be determined that there is redundancy in terms. Here, the predetermined number X may be arbitrarily set in advance and stored in a storage device such as the memory 202 or the disk 204, for example.

また、所定数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 merge processing unit 506 performs merge processing of duplicate method candidates determined to have redundancy in terms of execution among methods based on the correspondence relationship information 110. Specifically, for example, the merge processing unit 506 scans the duplicate method while scanning the intermediate language I code of each method of duplicate method candidates having redundancy in terms of execution among the methods based on the correspondence relationship information 110. An intermediate language I code of the method body in which candidates are merged is generated.

より具体的には、例えば、マージ処理部506は、対応関係情報110に基づいて、重複メソッド候補のメソッド間で共通する処理の中間言語Iコードを生成する。メソッド間で共通する処理は、例えば、メソッド間で意味的に同一である部分のデータから特定される。   More specifically, for example, the merge processing unit 506 generates an intermediate language I code for processing that is common among duplicate method candidate methods based on the correspondence relationship information 110. A process common among methods is specified from, for example, data of a portion that is semantically identical between methods.

また、マージ処理部506は、対応関係情報110に基づいて、重複メソッド候補の各メソッドで固有の処理の中間言語Iコードを生成する。各メソッドで固有の処理は、例えば、メソッド間で意味的に異なる部分のデータから特定される。そして、マージ処理部506は、生成した中間言語Iコードをマージすることにより、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成する。   Further, the merge processing unit 506 generates an intermediate language I code for processing unique to each method of the duplicate method candidate based on the correspondence relationship information 110. The processing unique to each method is specified, for example, from data of portions that are semantically different between methods. Then, the merge processing unit 506 generates an intermediate language I code of a method body obtained by merging duplicate method candidates by merging the generated intermediate language I code.

なお、重複メソッド候補をマージしたメソッド本体の中間言語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 merge processing unit 506 generates an intermediate language II code of the source program sc that is an interface in the compiler (compile program), based on the intermediate language I code of the method body obtained by merging the duplicate method candidates. Specifically, for example, the merge processing unit 506 converts the method expressed in the intermediate language I code (the merged method body and the unmerged method) into the intermediate language II code format.

これにより、ソースプログラム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 optimization unit 507 performs optimization processing on the intermediate language II code of the generated source program sc. Specifically, for example, the optimization unit 507 deletes a method that is not called from anywhere as an unnecessary method from the intermediate language II code of the source program. As a result, the method that is not used among a plurality of methods in the intermediate language II code can be deleted to reduce the absolute number of methods.

コード生成部508は、最適化処理されたソースプログラムscの中間言語IIコードに基づいて、ソースプログラムscのオブジェクトファイルfを生成する。具体的には、例えば、コード生成部508は、最適化処理された中間言語IIコードを機械語の命令の列に変換することにより、ソースプログラムscのオブジェクトファイルfを生成する。   The code generation unit 508 generates an object file f of the source program sc based on the intermediate language II code of the optimized source program sc. Specifically, for example, the code generation unit 508 generates the object file f of the source program sc by converting the optimized intermediate language II code into a sequence of machine language instructions.

出力部509は、生成されたソースプログラムscのオブジェクトファイルfを出力する。具体的には、例えば、出力部509は、ソースプログラムscのオブジェクトファイルfを、リンカと呼ばれるプログラムに出力する。ここで、リンカとは、オブジェクトファイルfを解析して、必要なライブラリなどを付け加えて実行ファイルを生成するプログラムである。これにより、ソースプログラムscの実行ファイルを得ることができる。   The output unit 509 outputs the generated object file f of the source program sc. Specifically, for example, the output unit 509 outputs the object file f of the source program sc to a program called a linker. Here, the linker is a program that analyzes the object file f, adds a necessary library, etc., and generates an execution file. Thereby, an execution file of the source program sc can be obtained.

なお、上述した説明では、重複メソッド候補としてメソッド名が同一のメソッドの組合せを抽出する場合を例に挙げて説明したが、メソッド名が異なっていてもメソッド間で実行面での冗長性を有する場合がある。しかし、メソッド名が異なる全てのメソッドの組合せについて実行面の冗長性を判断するのは処理時間の増大化を招いてしまう。   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 extraction unit 503 may extract a combination of methods between classes having a parent-child relationship as a duplicate method candidate. .

(メソッド間のデータの比較例)
つぎに、図4に示した中間言語Iコード410,420を例に挙げて、重複メソッド候補のメソッド間のデータの比較例について説明する。
(Example of data comparison between methods)
Next, taking the intermediate language I codes 410 and 420 shown in FIG. 4 as an example, a comparative example of data between methods of duplicate method candidates will be described.

図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 generation unit 504 first selects parameter data 411 from the intermediate language I code 410. Next, the generation unit 504 selects Parameter data 421 of the same type as the data 411 from the intermediate language I code 420.

そして、生成部504は、選択したParameterのデータ411,421同士を比較する。ここでは、データ411,421の間で、引数(仮引数)の型、数、並び順のいずれも異なる。このため、生成部504は、データ411,421が意味的に異なると判断して、メソッド間で意味的に異なる部分を識別する情報を対応関係情報110として生成する。図6の例では、メソッド間で意味的に異なる部分を識別する情報を、チェック記号を付与することで表現している。すなわち、中間言語Iコード中に付与されるチェック記号が対応関係情報110に相当する。   Then, the generation unit 504 compares the selected parameter data 411 and 421 with each other. Here, the types, number, and arrangement order of arguments (provisional arguments) are different between the data 411 and 421. For this reason, the generation unit 504 determines that the data 411 and 421 are semantically different, and generates information that identifies portions that are semantically different between methods as the correspondence information 110. In the example of FIG. 6, information for identifying a portion that is semantically different between methods is expressed by adding a check symbol. That is, the check symbol given in the intermediate language I code corresponds to the correspondence information 110.

図7において、まず、生成部504は、中間言語Iコード410から、Statement(文)のデータ412を選択する。つぎに、生成部504は、中間言語Iコード420から、データ412と同一種のStatementのデータ422を選択する。そして、生成部504は、選択したStatementのデータ412,422にそれぞれ含まれるOperator(式)のデータ415,425同士を比較する。   In FIG. 7, the generation unit 504 first selects Statement data 412 from the intermediate language I code 410. Next, the generation unit 504 selects, from the intermediate language I code 420, Statement data 422 of the same type as the data 412. Then, the generation unit 504 compares the data 415 and 425 of the operator (expression) included in the data 412 and 422 of the selected statement.

ここでは、データ415,425がそれぞれ表す式が同一である。このため、生成部504は、データ412,422が意味的に同一であると判断して、メソッド間で意味的に同一である部分を識別する情報を対応関係情報110として生成する。図7の例では、メソッド間で意味的に同一である部分を識別する情報を、チェック記号を付与しないことで表現している。   Here, the expressions represented by the data 415 and 425 are the same. For this reason, the generation unit 504 determines that the data 412 and 422 are semantically identical, and generates information that identifies a portion that is semantically identical between methods as the correspondence information 110. In the example of FIG. 7, information for identifying a portion that is semantically identical between methods is expressed by not adding a check symbol.

図8において、まず、生成部504は、中間言語Iコード410から、Statementのデータ413を選択する。つぎに、生成部504は、中間言語Iコード420から、データ413と同一種のStatementのデータ423を選択する。そして、生成部504は、選択したStatementのデータ413,423にそれぞれ含まれるOperatorのデータ416,426同士を比較する。   In FIG. 8, the generation unit 504 first selects Statement data 413 from the intermediate language I code 410. Next, the generation unit 504 selects the same type of Statement data 423 as the data 413 from the intermediate language I code 420. Then, the generation unit 504 compares the operator data 416 and 426 included in the selected statement data 413 and 423, respectively.

ここでは、データ416,426がそれぞれ表す式の一部が異なっている。このため、生成部504は、データ413,423が意味的に異なると判断して、メソッド間で意味的に異なる部分を識別する情報を対応関係情報110として生成する。図8の例では、メソッド間で意味的に異なる部分を識別する情報を、チェック記号を付与することで表現している。   Here, some of the expressions represented by the data 416 and 426 are different. For this reason, the generation unit 504 determines that the data 413 and 423 are semantically different, and generates information for identifying a portion that is semantically different between methods as the correspondence information 110. In the example of FIG. 8, information for identifying portions that are semantically different between methods is expressed by adding a check symbol.

図9において、まず、生成部504は、中間言語Iコード410から、Statementのデータ414を選択する。つぎに、生成部504は、中間言語Iコード420から、データ414と同一種のStatementのデータ424を選択する。そして、生成部504は、選択したStatementのデータ414,424にそれぞれ含まれるOperatorのデータ417,427同士を比較する。   In FIG. 9, the generation unit 504 first selects Statement data 414 from the intermediate language I code 410. Next, the generation unit 504 selects, from the intermediate language I code 420, Statement data 424 of the same type as the data 414. Then, the generation unit 504 compares the operator data 417 and 427 included in the selected statement data 414 and 424, respectively.

ここでは、データ417,427がそれぞれ表す式が同一である。このため、生成部504は、データ414,424が意味的に同一であると判断して、メソッド間で意味的に同一である部分を識別する情報を対応関係情報110として生成する。図9の例では、メソッド間で意味的に同一である部分を識別する情報を、チェック記号を付与しないことで表現している。   Here, the expressions represented by the data 417 and 427 are the same. For this reason, the generation unit 504 determines that the data 414 and 424 are semantically identical, and generates information that identifies a portion that is semantically identical between methods as the correspondence information 110. In the example of FIG. 9, information for identifying a portion that is semantically identical between methods is expressed by not adding a check symbol.

(重複メソッド候補のマージ処理例)
つぎに、ソースプログラム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 source program 300 as a duplicate method candidate. First, an image of the merge process of the SetColor method will be described using the source program 300. FIG.

図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 code 1001 on the 10th to 14th lines in the source program 300 is a description related to the SetColor method of the base class COLOR. Further, the code 1002 on the 24th to 29th lines in the source program 300 is a description related to the SetColor method of the derived class RED.

マージ処理部506は、コード1001に対応する中間言語Iコードとコード1002に対応する中間言語Iコードとをマージして、イメージ1010で示すような中間言語Iコードを生成することになる。ここで、コード1001とコード1002とを比較すると、10行目と24行目の引数、および12行目と26行目の式が、それぞれのSetColorメソッドで固有のものとなっている。   The merge processing unit 506 merges the intermediate language I code corresponding to the code 1001 and the intermediate language I code corresponding to the code 1002 to generate an intermediate language I code as shown by the image 1010. Here, when comparing the code 1001 and the code 1002, the arguments on the 10th and 24th lines and the expressions on the 12th and 26th lines are unique to each SetColor method.

このため、マージ処理部506は、イメージ1010内のコード1011〜1015のように、基底クラスCOLORおよび派生クラスREDのSetColorメソッド間で共通する処理の中間言語Iコードと、各SetColorメソッドで固有の処理の中間言語Iコードを生成する。   For this reason, the merge processing unit 506, like codes 1011 to 1015 in the image 1010, processes intermediate language I code common to the SetColor methods of the base class COLOR and the derived class RED, and processes unique to each SetColor method Intermediate language I code is generated.

コード1011は、基底クラスCOLORおよび派生クラスREDのいずれのSetColorメソッドに応じた処理を行うのかを選択するためのものであり、呼び出し元から第1引数として与えられる情報が定義される。コード1012は、SetColorメソッドの引数を表す。   The code 1011 is for selecting which of the base class COLOR and the derived class RED performs processing according to the SetColor method, and information given as a first argument from the caller is defined. Code 1012 represents an argument of the SetColor method.

コード1013,1015は、基底クラスCOLORおよび派生クラスREDのSetColorメソッド間で共通する処理の中間言語Iコードに対応する。一方、コード1014は、基底クラスCOLORおよび派生クラスREDの各SetColorメソッドで固有の処理の中間言語Iコードに対応する。コード1014には、基底クラスCOLORおよび派生クラスREDのいずれのSetColorメソッドであるかを判定する判定文(if)が含まれている。   Codes 1013 and 1015 correspond to an intermediate language I code of processing common between the SetColor method of the base class COLOR and the derived class RED. On the other hand, the code 1014 corresponds to an intermediate language I code of processing unique to each SetColor method of the base class COLOR and the derived class RED. The code 1014 includes a determination statement (if) for determining which SetColor method of the base class COLOR and the derived class RED.

また、ソースプログラム300内の36行目は、基底クラスCOLORのSetColorメソッドを呼び出すための記述である。また、ソースプログラム300内の37行目は、派生クラスREDのSetColorメソッドを呼び出すための記述である。このため、マージ処理部506は、基底クラスCOLORまたは派生クラスREDのSetColorメソッドを呼び出すために、イメージ1020のような中間言語Iコードを合わせて生成する。   The 36th line in the source program 300 is a description for calling the SetColor method of the base class COLOR. The 37th line in the source program 300 is a description for calling the SetColor method of the derived class RED. Therefore, the merge processing unit 506 generates an intermediate language I code such as the image 1020 in order to call the SetColor method of the base class COLOR or the derived class RED.

ここで、イメージ1010に対応する中間言語Iコードについて説明する。   Here, the intermediate language I code corresponding to the image 1010 will be described.

図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 language I code 1100 schematically shows the intermediate language I code of the method body obtained by merging the SetColor method of the base class COLOR and the SetColor method of the derived class RED, as shown in FIG. Corresponds to image 1010.

中間言語Iコード1100において、データ1101は、基底クラスCOLORおよび派生クラスREDのいずれのSetColorメソッドに応じた処理を行うのかを選択するための中間言語Iコードである。データ1101は、図10に示したイメージ1010内のコード1011に対応する。   In the intermediate language I code 1100, the data 1101 is an intermediate language I code for selecting which of the base class COLOR and the derived class RED should be processed according to the SetColor method. Data 1101 corresponds to the code 1011 in the image 1010 shown in FIG.

データ1102は、SetColorメソッドの引数を表す中間言語Iコードである。データ1102は、イメージ1010内のコード1012に対応する。データ1103は、基底クラスCOLORおよび派生クラスREDのSetColorメソッド間で共通する処理の中間言語Iコードである。データ1103は、イメージ1010内のコード1013に対応する。   Data 1102 is an intermediate language I code representing an argument of the SetColor method. Data 1102 corresponds to code 1012 in image 1010. Data 1103 is an intermediate language I code of processing common between the SetColor method of the base class COLOR and the derived class RED. Data 1103 corresponds to the code 1013 in the image 1010.

データ1104は、各SetColorメソッドで固有の処理の中間言語Iコードである。データ1104は、イメージ1010内のコード1014に対応する。データ1105は、SetColorメソッド間で共通する処理の中間言語Iコードである。データ1105は、イメージ1010内のコード1015に対応する。   Data 1104 is an intermediate language I code of processing unique to each SetColor method. Data 1104 corresponds to code 1014 in image 1010. Data 1105 is an intermediate language I code for processing common to the SetColor methods. Data 1105 corresponds to code 1015 in image 1010.

(重複メソッド候補をマージしないソースプログラム例)
つぎに、重複メソッド候補をマージしない場合のソースプログラム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 source program 1200 is an example of an object-oriented program coded in an object-oriented language.

ソースプログラム1200の4行目には、printメソッドが定義されている。また、ソースプログラム1200の9行目には、4行目のprintメソッドと同一名のprintメソッドが定義されている。すなわち、printメソッドがオーバーロードされている。   In the fourth line of the source program 1200, a print method is defined. Also, in the 9th line of the source program 1200, a print method having the same name as the print method in the 4th line is defined. That is, the print method is overloaded.

ソースプログラム1200内の4行目から6行目のコード1201は、4行目のprintメソッドに関する記述である。また、ソースプログラム1200内の9行目から22行目のコード1202は、9行目のprintメソッドに関する記述である。ここで、コード1201とコード1202とを比較すると、メソッド名以外で、メソッド間で意味的に同一である部分は存在しない。   The code 1201 from the 4th line to the 6th line in the source program 1200 describes the print method on the 4th line. Also, the code 1202 from the 9th line to the 22nd line in the source program 1200 is a description relating to the print method in the 9th line. Here, when comparing the code 1201 and the code 1202, there is no portion that is semantically identical between methods other than the method name.

このように、メソッド間で意味的に同一である部分が少なく、メソッド間で実行面での冗長性が低い場合には、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 apparatus 100 does not consider a method such as the print method in the source program 1200 as a merge target.

(コンパイル装置100のコンパイル処理手順)
つぎに、コンパイル装置100のコンパイル処理手順について説明する。
(Compile processing procedure of the compiling device 100)
Next, a compiling process procedure of the compiling apparatus 100 will be described.

図13は、コンパイル装置100のコンパイル処理手順の一例を示すフローチャートである。図13のフローチャートにおいて、まず、コンパイル装置100は、ソースプログラムscを読み込む(ステップS1301)。   FIG. 13 is a flowchart illustrating an example of a compile processing procedure of the compile device 100. In the flowchart of FIG. 13, the compiling device 100 first reads the source program sc (step S1301).

つぎに、コンパイル装置100は、ソースプログラムscの字句解析を行う(ステップS1302)。そして、コンパイル装置100は、字句解析により得られるトークンの並びについて、トークン間の関係を解析することにより、ソースプログラムscの構文解析および意味解析を行う(ステップS1303)。   Next, the compiling device 100 performs lexical analysis of the source program sc (step S1302). Then, the compiling device 100 performs syntax analysis and semantic analysis of the source program sc by analyzing the relationship between tokens in the token sequence obtained by the lexical analysis (step S1303).

つぎに、コンパイル装置100は、ソースプログラムscの構文解析および意味解析により得られる中間言語Iコード中の複数のメソッドから重複メソッド候補を抽出する重複メソッド候補抽出処理を行う(ステップS1304)。重複メソッド候補抽出処理の具体的な処理内容については、図14を用いて後述する。   Next, the compiling device 100 performs a duplicate method candidate extraction process for extracting duplicate method candidates from a plurality of methods in the intermediate language I code obtained by the syntax analysis and semantic analysis of the source program sc (step S1304). The specific processing content of the duplicate method candidate extraction processing will be described later with reference to FIG.

つぎに、コンパイル装置100は、抽出された重複メソッド候補のうち未選択の重複メソッド候補を選択する(ステップS1305)。そして、コンパイル装置100は、重複メソッド候補のメソッド間の対応関係情報110を生成する対応関係情報生成処理を行う(ステップS1306)。対応関係情報生成処理の具体的な処理手順については、図15を用いて後述する。   Next, the compiling device 100 selects an unselected duplicate method candidate from the extracted duplicate method candidates (step S1305). Then, the compiling device 100 performs correspondence information generation processing for generating correspondence information 110 between methods of duplicate method candidates (step S1306). A specific processing procedure of the correspondence relationship information generation processing will be described later with reference to FIG.

つぎに、コンパイル装置100は、生成した重複メソッド候補の対応関係情報に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定する(ステップS1307)。ここで、実行面での冗長性を有さないと判定した場合(ステップS1307:No)、コンパイル装置100は、ステップS1309に移行する。   Next, the compiling device 100 determines whether or not there is redundancy in terms of execution between the methods of the duplicate method candidates based on the generated correspondence information of the duplicate method candidates (step S1307). If it is determined that there is no redundancy in terms of execution (step S1307: No), the compiling device 100 proceeds to step S1309.

一方、実行面での冗長性を有すると判定した場合(ステップ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 device 100 performs a merge process for generating an intermediate language I code of a method body in which duplicate method candidates are merged (step S1308). . A specific processing procedure of the merge processing will be described later with reference to FIG.

つぎに、コンパイル装置100は、抽出された重複メソッド候補のうち未選択の重複メソッド候補があるか否かを判断する(ステップS1309)。ここで、未選択の重複メソッド候補がある場合(ステップS1309:Yes)、コンパイル装置100は、ステップS1305に戻る。   Next, the compiling device 100 determines whether or not there is an unselected duplicate method candidate among the extracted duplicate method candidates (step S1309). If there is an unselected duplicate method candidate (step S1309: YES), the compiling device 100 returns to step S1305.

一方、未選択の重複メソッド候補がない場合は(ステップ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 device 100 determines the intermediate language I code of the method body in which the duplicate method candidates are merged and the intermediate language I code of the method that has not been merged. Based on the above, an intermediate language II code of the source program sc is generated (step S1310).

そして、コンパイル装置100は、生成されたソースプログラムscの中間言語IIコードの最適化処理を行う(ステップS1311)。つぎに、コンパイル装置100は、最適化処理されたソースプログラムscの中間言語IIコードに基づいて、ソースプログラムscのオブジェクトファイルfを生成する(ステップS1312)。   Then, the compiling device 100 performs an optimization process of the intermediate language II code of the generated source program sc (step S1311). Next, the compiling device 100 generates an object file f of the source program sc based on the intermediate language II code of the optimized source program sc (step S1312).

そして、コンパイル装置100は、生成したソースプログラムscのオブジェクトファイルfを出力して(ステップS1313)、本フローチャートによる一連の処理を終了する。   Then, the compiling device 100 outputs the generated object file f of the source program sc (step S1313), and ends the series of processing according to this flowchart.

これにより、コンパイラの構文・意味解析区において、メソッド間で実行面での冗長性を有する複数のメソッドを一つのメソッドにマージすることができ、最適化区の入力時点でメソッドの絶対数を削減することができる。   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 device 100 refers to the intermediate language I code of the source program sc and determines whether or not a method having the same name exists between classes having a parent-child relationship (step S1401). .

ここで、親子関係を有するクラス間で同一名のメソッドが存在する場合(ステップ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 device 100 extracts a combination of methods having the same name between classes having a parent-child relationship as duplicate method candidates. (Step S1402). Then, the compiling device 100 returns to step S1401.

一方、親子関係を有するクラス間で同一名のメソッドが存在しない場合(ステップ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 device 100 refers to the intermediate language I code of the source program sc, and the method or overloaded operation with the same name. It is determined whether or not a child exists (step S1403).

ここで、同一名のメソッドまたは多重定義演算子が存在する場合(ステップS1403:Yes)、コンパイル装置100は、同一名のメソッドまたは多重定義演算子の組合せを重複メソッド候補として抽出する(ステップS1404)。そして、コンパイル装置100は、ステップS1403に戻る。   If a method or overloaded operator with the same name exists (step S1403: Yes), the compiling apparatus 100 extracts a method or overloaded operator combination with the same name as a duplicate method candidate (step S1404). . Then, the compiling device 100 returns to step S1403.

一方、同一名のメソッドまたは多重定義演算子が存在しない場合(ステップS1403:No)、コンパイル装置100は、重複メソッド候補抽出処理を呼び出したステップに戻る。これにより、オーバーロードされたメソッドやオーバーロードされたメソッドを、メソッド間で実行面での冗長性を有する候補となる重複メソッド候補として抽出することができる。   On the other hand, when there is no method or overloaded operator with the same name (step S1403: No), the compiling device 100 returns to the step that called the duplicate method candidate extraction process. Thereby, an overloaded method or an overloaded method can be extracted as a duplicate method candidate that is a candidate having redundancy in terms of execution among methods.

<対応関係情報生成処理手順>
つぎに、図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 device 100 extracts intermediate language I code corresponding to each duplicate method candidate from the intermediate language I code of the source program sc (step S1501).

つぎに、コンパイル装置100は、抽出した中間言語Iコードを参照して、重複メソッド候補のメソッド間で宣言・文・式のデータを順次比較する(ステップS1502)。そして、コンパイル装置100は、比較した比較結果に基づいて、抽出した中間言語Iコードのうち、メソッド間で意味的に異なる部分があるか否かを判断する(ステップS1503)。   Next, the compiling device 100 refers to the extracted intermediate language I code, and sequentially compares the data of the declaration / sentence / expression between the methods of the duplicate method candidate (step S1502). Then, the compiling device 100 determines whether or not there is a part that is semantically different between methods in the extracted intermediate language I code based on the comparison result (step S1503).

ここで、メソッド間で意味的に異なる部分がある場合(ステップS1503:Yes)、コンパイル装置100は、抽出した中間言語Iコードのうちのメソッド間で意味的に異なる部分にマーキングする(ステップS1504)。そして、コンパイル装置100は、対応関係情報生成処理を呼び出したステップに戻る。なお、マーキングは、例えば、図6に示したようなチェック記号に相当する。   Here, when there is a portion that is semantically different between methods (step S1503: Yes), the compiling device 100 marks a portion that is semantically different between methods in the extracted intermediate language I code (step S1504). . Then, the compiling device 100 returns to the step that called the correspondence information generation process. The marking corresponds to, for example, a check symbol as shown in FIG.

一方、メソッド間で意味的に異なる部分がない場合(ステップS1503:No)、コンパイル装置100は、対応関係情報生成処理を呼び出したステップに戻る。これにより、重複メソッド候補それぞれに対応する中間言語Iコードのうち、メソッド間で意味的に同一である部分と、メソッド間で意味的に異なる部分とを識別する対応関係情報110を生成することができる。   On the other hand, if there is no semantically different portion between the methods (step S1503: No), the compiling device 100 returns to the step that called the correspondence relationship information generation process. Thus, the correspondence relationship information 110 for identifying a portion that is semantically identical between methods and a portion that is semantically different between methods in the intermediate language I code corresponding to each of the duplicate method candidates can be generated. it can.

<マージ処理手順>
つぎに、図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 device 100 first selects declaration / sentence / expression data from the intermediate language I code of the duplicate method candidate (step S1601). At this time, if the selected data and the data compared in step S1502 shown in FIG. 15 exist, the compiling device 100 also selects the data.

つぎに、コンパイル装置100は、選択したデータにマーキングがあるか否かを判断する(ステップS1602)。ここで、マーキングがある場合(ステップS1602:Yes)、コンパイル装置100は、選択したデータに基づいて、重複メソッド候補のメソッド固有の処理の中間言語Iコードを生成する(ステップS1603)。   Next, the compiling device 100 determines whether or not the selected data has a marking (step S1602). Here, when there is marking (step S1602: Yes), the compiling device 100 generates an intermediate language I code for the process-specific processing of the duplicate method candidate based on the selected data (step S1603).

そして、コンパイル装置100は、重複メソッド候補の中間言語Iコードから選択されていない未選択のデータがあるか否かを判断する(ステップS1604)。ここで、未選択のデータがある場合(ステップS1604:Yes)、コンパイル装置100は、ステップS1601に戻る。   The compiling device 100 determines whether there is unselected data that is not selected from the intermediate language I code of the duplicate method candidate (step S1604). If there is unselected data (step S1604: YES), the compiling device 100 returns to step S1601.

また、ステップS1602において、マーキングがない場合(ステップS1602:No)、コンパイル装置100は、選択したデータに基づいて、重複メソッド候補のメソッド共通の処理の中間言語Iコードを生成して(ステップS1605)、ステップS1604に移行する。   If there is no marking in step S1602 (step S1602: No), the compiling device 100 generates an intermediate language I code for processing common to duplicate method candidates based on the selected data (step S1605). The process proceeds to step S1604.

また、ステップS1604において、未選択のデータがない場合(ステップS1604:No)、コンパイル装置100は、生成した各処理の中間言語Iコードをマージすることにより、重複メソッド候補をマージしたメソッド本体の中間言語Iコードを生成して(ステップS1606)、マージ処理を呼び出したステップに戻る。   In step S1604, if there is no unselected data (step S1604: No), the compiling device 100 merges the generated intermediate language I codes of the respective processes, so that the intermediate method body into which the duplicate method candidates are merged is merged. A language I code is generated (step S1606), and the process returns to the step that called the merge process.

これにより、メソッド間で実行面での冗長性を有する重複メソッド候補をマージしたメソッド本体の中間言語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, data 1101 shown in FIG. 11). . In step S1606, an intermediate language I code for calling one of the merged methods is also generated.

以上説明したように、実施の形態にかかるコンパイル装置100によれば、ソースプログラムscの構文解析および意味解析により得られる中間言語Iコード中の複数のメソッドから、メソッド間で実行面での冗長性を有する可能性がある重複メソッド候補を抽出することができる。これにより、オブジェクト指向言語の言語的特徴を判断できる構文・意味解析区において、データや処理ロジックについて同一性を有する可能性がある複数のメソッドを重複メソッド候補として抽出することができる。   As described above, according to the compiling apparatus 100 according to the embodiment, the redundancy in terms of execution among methods from a plurality of methods in the intermediate language I code obtained by the syntax analysis and semantic analysis of the source program sc. Can be extracted. As a result, in the syntax / semantic analysis section where the linguistic characteristics of the object-oriented language can be determined, a plurality of methods that may have the same data and processing logic can be extracted as duplicate method candidates.

例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコード中のメソッド群から、親子関係を有するクラス間で同一名のメソッドの組合せを重複メソッド候補として抽出してもよい。これにより、メソッド間で実行面での冗長性を有する可能性があるオーバーライドされたメソッドを重複メソッド候補として抽出することができる。   For example, the compiling apparatus 100 may extract a combination of methods having the same name between classes having a parent-child relationship from the method group in the intermediate language I code of the source program sc as a duplicate method candidate. As a result, overridden methods that may have redundancy in terms of execution among methods can be extracted as duplicate method candidates.

例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコード中のメソッド群から、同一クラス内のメソッド、あるいは、いずれのクラスにも属していないメソッドのうち、同一名のメソッドの組合せを重複メソッド候補として抽出してもよい。これにより、メソッド間で実行面での冗長性を有する可能性があるオーバーロードされたメソッドを重複メソッド候補として抽出することができる。   For example, the compiling device 100 duplicates a combination of methods having the same name among methods in the same class or methods not belonging to any class from the method group in the intermediate language I code of the source program sc. You may extract as a candidate. As a result, overloaded methods that may have execution redundancy between methods can be extracted as duplicate method candidates.

例えば、コンパイル装置100は、ソースプログラムscの中間言語Iコード中のメソッド群から、同一クラス内の演算子、あるいは、いずれのクラスにも属していない演算子のうち、同一名の演算子の組合せを重複メソッド候補として抽出してもよい。これにより、メソッド(演算子)間で実行面での冗長性を有する可能性があるオーバーロードされた多重定義演算子を重複メソッド候補として抽出することができる。   For example, the compiling device 100 selects a combination of operators having the same name among operators in the same class or operators not belonging to any class from the method group in the intermediate language I code of the source program sc. May be extracted as a duplicate method candidate. As a result, overloaded overloaded operators that may have execution redundancy between methods (operators) can be extracted as duplicate method candidates.

また、コンパイル装置100によれば、抽出した重複メソッド候補それぞれの中間言語Iコードにより特定される処理ロジックに基づいて、重複メソッド候補のメソッド間の対応関係情報110を生成することができる。これにより、重複メソッド候補のメソッド間の実行面での冗長性の有無を判断するための対応関係情報110を生成することができる。   Further, the compiling device 100 can generate correspondence information 110 between methods of duplicate method candidates based on the processing logic specified by the intermediate language I code of each extracted duplicate method candidate. Thereby, it is possible to generate the correspondence information 110 for determining whether or not there is redundancy in terms of execution between methods of duplicate method candidates.

例えば、コンパイル装置100は、重複メソッド候補それぞれの中間言語Iコード中の宣言、文、式それぞれのデータごとに、メソッド間のデータを比較する。そして、コンパイル装置100は、比較した比較結果に基づいて、重複メソッド候補それぞれの中間言語Iコードのうち、メソッド間で意味的に同一である部分とメソッド間で意味的に異なる部分とを識別する対応関係情報110を生成してもよい。これにより、重複メソッド候補のメソッド間で意味的に同一である部分とメソッド間で意味的に異なる部分とを識別することが可能となる。   For example, the compiling device 100 compares data between methods for each data of declaration, sentence, and expression in the intermediate language I code of each duplicate method candidate. Then, the compiling device 100 identifies a portion that is semantically identical between the methods and a portion that is semantically different between the methods in the intermediate language I code of each of the duplicate method candidates based on the comparison result. The correspondence information 110 may be generated. This makes it possible to identify a portion that is semantically identical between duplicate method candidate methods and a portion that is semantically different between methods.

また、コンパイル装置100によれば、生成した対応関係情報110に基づいて、重複メソッド候補のメソッド間で実行面での冗長性を有するか否かを判定し、メソッド間で実行面での冗長性を有する重複メソッド候補のマージ処理を行うことができる。これにより、メソッド間で実行面での冗長性を有する複数のメソッドを一つのメソッドにマージすることができ、構文・意味解析区の段階でメソッドの絶対数を削減することができる。   Also, the compiling device 100 determines whether or not there is redundancy in terms of execution between methods of duplicate method candidates based on the generated correspondence relationship information 110, and redundancy in terms of execution between methods. It is possible to perform merge processing of duplicate method candidates having As a result, a plurality of methods having redundancy in terms of execution among methods can be merged into one method, and the absolute number of methods can be reduced at the stage of syntax / semantic analysis.

例えば、コンパイル装置100は、重複メソッド候補それぞれの中間言語Iコード中の宣言・文・式それぞれのデータのうち少なくともいずれかのデータが、メソッド間で意味的に同一である場合にメソッド間で実行面での冗長性を有すると判定してもよい。これにより、メソッド間で意味的に同一である部分が存在する重複メソッド候補をマージ対象とすることができ、効果的なマージ処理を行うことができる。   For example, the compiling device 100 executes between methods when at least one of declaration, sentence, and expression data in the intermediate language I code of each duplicate method candidate is semantically identical between methods. It may be determined that there is redundancy in terms. As a result, duplicate method candidates that have portions that are semantically identical between methods can be merged, and effective merge processing can be performed.

例えば、コンパイル装置100は、重複メソッド候補それぞれの中間言語Iコード中の宣言・文・式それぞれのデータのうちの所定数X以上のデータが意味的に同一である場合に、メソッド間で実行面での冗長性を有すると判定してもよい。これにより、メソッド間で意味的に同一である部分が多く存在する重複メソッド候補をマージ対象とすることができ、より効果的なマージ処理を行うことができる。   For example, the compiling device 100 executes the execution surface between methods when data of a predetermined number X or more among the data of declarations, sentences, and expressions in the intermediate language I code of each of the duplicate method candidates is semantically identical. It may be determined that there is redundancy in. As a result, duplicate method candidates that have many portions that are semantically identical between methods can be merged, and more effective merge processing can be performed.

これらのことから、コンパイル装置100によれば、最適化区の入力時点でメソッドの絶対数を削減することが可能となり、ソースプログラムscのコンパイル時間の短縮化を図るとともに、オブジェクトファイルfのデータサイズを縮小することができる。また、コンパイル装置100によれば、オブジェクト指向言語の言語的特徴からメソッド間で実行面での冗長性を有する可能性がある重複メソッド候補を絞り込むことができるため、マージ対象となる複数のメソッドの判別を効率的かつ効果的に行うことができる。   Thus, according to the compiling apparatus 100, the absolute number of methods can be reduced at the time of input of the optimization section, the compilation time of the source program sc can be shortened, and the data size of the object file f can be reduced. Can be reduced. Further, the compiling device 100 can narrow down duplicate method candidates that may have redundancy in terms of execution among methods from the linguistic characteristics of the object-oriented language, and therefore, a plurality of methods to be merged can be selected. The discrimination can be performed efficiently and effectively.

これにより、ソフトウェア開発の開発スピードを向上させることができる。また、オブジェクトファイル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 appendix 1, wherein a plurality of mergeable methods are extracted from the plurality of merge candidate methods based on the correspondence information.

(付記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 appendix 1 or 2, 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.

(付記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 appendices 1 to 3.

(付記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 appendices 1 to 4, characterized in that:

(付記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 appendix 2, wherein the relation information is generated.

(付記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 appendix 6, wherein a method is extracted as the plurality of mergeable methods.

(付記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 appendix 6, wherein a method is extracted as the plurality of mergeable methods.

(付記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 appendix 2, wherein merge processing of the plurality of mergeable methods is performed by generating an intermediate language code of a method body obtained by merging the plurality of mergeable methods.

(付記10)前記ソースプログラムは、オブジェクト指向言語によってコーディングされたプログラムであることを特徴とする付記1〜9のいずれか一つに記載のコンパイル方法。 (Supplementary note 10) The compiling method according to any one of supplementary notes 1 to 9, wherein the source program is a program coded in an object-oriented language.

(付記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 SYMBOLS 100 Compile apparatus 501 Acquisition part 502 Analysis part 503 Extraction part 504 Generation part 505 Determination part 506 Merge processing part 507 Optimization part 508 Code generation part 509 Output part

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.
前記ソースプログラムは、オブジェクト指向言語によってコーディングされたプログラムであることを特徴とする請求項1〜7のいずれか一つに記載のコンパイル方法。   The compiling method according to claim 1, wherein the source program is a program coded in an object-oriented language. ソースプログラムの構文解析および意味解析により得られる中間言語コード中の複数のメソッドから、少なくとも継承関係または名称のいずれかに基づき複数のマージ候補メソッドを抽出し、前記複数のマージ候補メソッドそれぞれの中間言語コードにより特定される処理ロジックに基づいて、前記複数のマージ候補メソッドからマージ可能な複数のマージ可能メソッドを抽出し、前記複数のマージ可能メソッドのマージ処理を行う制御部、
を有することを特徴とするコンパイル装置。
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.
JP2014093212A 2014-04-28 2014-04-28 Compiling method, compiling device, and compiling program Active JP6264179B2 (en)

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)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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

Patent Citations (4)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
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