JP6326838B2 - Program processing apparatus, program processing method, and program processing program - Google Patents
Program processing apparatus, program processing method, and program processing program Download PDFInfo
- Publication number
- JP6326838B2 JP6326838B2 JP2014019881A JP2014019881A JP6326838B2 JP 6326838 B2 JP6326838 B2 JP 6326838B2 JP 2014019881 A JP2014019881 A JP 2014019881A JP 2014019881 A JP2014019881 A JP 2014019881A JP 6326838 B2 JP6326838 B2 JP 6326838B2
- Authority
- JP
- Japan
- Prior art keywords
- plug
- program
- library
- code
- processing
- 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.)
- Active
Links
Images
Description
本発明は、プログラムの、ソースコードまたは中間コードに対する処理を行うことが可能な、プログラム処理装置、プログラム処理方法、及びプログラム処理プログラムに関する。 The present invention relates to a program processing apparatus, a program processing method, and a program processing program capable of performing processing on a source code or intermediate code of a program.
プログラムをより効率的に実行できるように、プログラムを別のプログラムや、中間コード、実行ファイル等に変換することは、プログラム最適化(以下、単に「最適化」ともいう。)と呼ばれる。例えば、プログラマが、プログラムを書き換えることによって、最適化を行うことがある。 Converting a program into another program, intermediate code, executable file or the like so that the program can be executed more efficiently is called program optimization (hereinafter, also simply referred to as “optimization”). For example, a programmer may perform optimization by rewriting a program.
一方、プログラムのソースコードを計算機で実行可能なオブジェクトコードに変換するコンパイラは、プログラムを、より効率的に実行できるオブジェクトコードに変換する最適化機能を備えていることが多い。また、ソースコードを読み込み、最適化されたソースコードを出力する変換ツールも存在する。このようなコンパイラや変換ツールによる最適化は、プログラマによる最適化を不要にすることにより、プログラムの開発効率を向上させるために重要である。以下の説明では、コンパイラや変換ツール等による最適化等、プログラムに対して所定の処理を行うツールまたは装置を総称して、「プログラム処理ツール」または「プログラム処理装置」と呼ぶ。 On the other hand, compilers that convert program source code into object code that can be executed by a computer often have an optimization function that converts the program into object code that can be executed more efficiently. There are also conversion tools that read source code and output optimized source code. Such optimization using a compiler or conversion tool is important for improving the efficiency of program development by eliminating the need for optimization by a programmer. In the following description, tools or devices that perform predetermined processing on a program, such as optimization by a compiler or a conversion tool, are collectively referred to as “program processing tools” or “program processing devices”.
最適化の中には、プログラム中の複数の手続き(関数等)にまたがる最適化がある。複数の手続きにまたがる最適化は、「手続き間最適化」と呼ばれる。例えば、ある関数から呼び出される別の関数内で行われる処理に関する情報を用いて、呼び出し元の関数の最適化を行うといった最適化がある。 Among the optimizations, there is optimization across a plurality of procedures (functions etc.) in the program. Optimization across multiple procedures is called “interprocedural optimization”. For example, there is an optimization in which a caller function is optimized using information on processing performed in another function called from a certain function.
手続き間最適化について、定数伝搬を行う最適化の例を用いて説明する。なお、「定数伝搬」とは、コンパイル時等、プログラム起動前の準備段階に、定数と判断される変数を定数に置き換える最適化である。図15(a)のプログラムTは、2つの引数の乗算結果を返す関数mulと、mulを呼び出す関数mainとを含む。関数mulの呼び出し時にmulに渡される引数が定数であるため、これを伝搬することで関数mulが実行される前に、関数の戻り値が6であることが分かる。したがって、図15(b)に示すように、プログラム処理ツールは、関数main中の関数mulの呼び出しを、乗算結果である6に置き換えることにより、実行時に関数mulを呼び出して乗算を行うことを不要にする最適化を行う。
Interprocedural optimization will be described using an example of optimization that performs constant propagation. Note that “constant propagation” is an optimization in which a variable determined to be a constant is replaced with a constant in a preparation stage before starting the program, such as during compilation. The program T in FIG. 15A includes a function mul that returns a multiplication result of two arguments, and a function main that calls mul. Since the argument passed to mul when the function mul is called is a constant, it is understood that the return value of the function is 6 before the function mul is executed by propagating the argument. Accordingly, as shown in FIG. 15B, the program processing tool does not need to call and multiply the function mul at the time of execution by replacing the call of the function mul in the function main with the
通常、コンパイラはソースコードを1つのファイル毎にコンパイルする。1つのファイル中に、手続き間最適化の対象である関数の、呼び出す側及び呼び出される側の両方の関数定義が存在する場合には、コンパイラは、関数定義を解析して得られる情報を用いて、呼び出す側の関数の最適化を行うことができる。しかしながら、手続き間最適化の対象である関数の、呼び出す側及び呼び出される側の関数定義の各々が別々のファイルに記述されている場合には、コンパイラは、呼び出す側の関数の最適化を行う際に、呼び出される側の関数定義等の関数の情報(例えば、関数の処理内容に関する情報)を用いることができない。そのため、コンパイラは、十分な最適化を行うことができないという問題がある。 Normally, a compiler compiles source code for each file. When there is a function definition for both the calling side and the called side of the function that is the target of interprocedural optimization in one file, the compiler uses the information obtained by analyzing the function definition. , The calling function can be optimized. However, if each of the calling and called function definitions of the function that is the target of interprocedural optimization is described in a separate file, the compiler must optimize the calling function. In addition, information on a function such as a function definition on the called side (for example, information on processing contents of the function) cannot be used. Therefore, there is a problem that the compiler cannot perform sufficient optimization.
例えば、図16の例では、関数mulが別のファイル“source1.c”、“source2.c”に記述されている。したがって、コンパイラは、ユーザープログラムVのコンパイル時には、ライブラリプログラムWに記述された「関数mulが引数に対する乗算結果を返す処理である」という情報を利用することができない。そのため、コンパイラは、複数の関数にまたがる定数伝搬を行うことができない。 For example, in the example of FIG. 16, the function mul is described in separate files “source1.c” and “source2.c”. Therefore, when compiling the user program V, the compiler cannot use information described in the library program W that “the function mul is a process for returning a multiplication result for an argument”. For this reason, the compiler cannot perform constant propagation across a plurality of functions.
このような問題を解決するため、コンパイラの中には、生成するオブジェクトコード中にソースコードを解析して得られた情報の一部を埋め込む機能を備えるものがある。また、リンカの中には、オブジェクトコードをリンクする際に、オブジェクトコードに埋め込まれた情報を利用して最適化を行うものがある。 In order to solve such a problem, some compilers have a function of embedding a part of information obtained by analyzing the source code in the generated object code. Some linkers perform optimization using information embedded in the object code when the object code is linked.
オブジェクトコード中に埋め込まれた、ソースコードの解析情報を利用して手続き間最適化を行う技術の一例が、特許文献1に開示されている。 An example of a technique for performing interprocedural optimization using analysis information of a source code embedded in an object code is disclosed in Patent Document 1.
特許文献1のシステムは、以下のように動作する。 The system of Patent Document 1 operates as follows.
特許文献1のコンパイラは、ソースファイルからグローバルレジスタ情報を含むオブジェクトファイルを生成する。「グローバルレジスタ情報」とは、ソースファイル内で定義または参照されるグローバルシンボルを、グローバルレジスタに関連付ける情報である。「グローバルシンボル」とは、あるモジュール(例えば、1つのソースファイル)内で定義され、別のモジュールから参照されるシンボル(変数等)である。「グローバルレジスタ」とは、任意の手続き(関数等)からアクセス可能なレジスタである。 The compiler of Patent Document 1 generates an object file including global register information from a source file. “Global register information” is information for associating a global symbol defined or referenced in a source file with a global register. A “global symbol” is a symbol (such as a variable) that is defined in a certain module (for example, one source file) and is referenced from another module. The “global register” is a register accessible from an arbitrary procedure (function or the like).
特許文献1のリンカは、コンパイラが生成した複数のオブジェクトファイルに含まれるグローバルレジスタ情報を利用して、レジスタ割り付けを行った上で、オブジェクトファイルをリンクし、実行可能ファイルを生成する。「レジスタ割り付け」とは、プログラム内の多数の変数をCPUの少数のレジスタに多重化する最適化である。 The linker of Patent Document 1 uses global register information included in a plurality of object files generated by the compiler to perform register allocation, and then links the object files to generate an executable file. “Register allocation” is an optimization in which a large number of variables in a program are multiplexed into a small number of registers in the CPU.
以上の動作の結果、特許文献1のシステムでは、オブジェクトファイルに埋め込まれたソースコードの解析情報を利用することによって、複数の関数にまたがる手続き間最適化が行われる。 As a result of the above operation, the system of Patent Document 1 performs interprocedural optimization across a plurality of functions by using the analysis information of the source code embedded in the object file.
オブジェクトコード中に情報が埋め込まれるとオブジェクトコードのサイズが増大する等理由から、埋め込まれた情報はソースコードを解析して得られる情報よりも情報が少ないものに制限されることがある。そのため、オブジェクトコード中に解析情報が埋め込まれる場合には、十分な最適化が困難であるという問題がある。また、オブジェクトコード中に解析情報が埋め込まれない場合には、オブジェクトコードを最適化することができないという問題もある。 If information is embedded in the object code, the size of the object code increases, and the embedded information may be limited to information with less information than information obtained by analyzing the source code. Therefore, when analysis information is embedded in the object code, there is a problem that sufficient optimization is difficult. There is also a problem that the object code cannot be optimized when the analysis information is not embedded in the object code.
ところで、プログラムはライブラリを利用して開発されることが多い。「ライブラリ」とは、特定の処理を行うプログラムのソースコードがあらかじめコンパイルされたオブジェクトコードである。また、ライブラリは、ライブラリが備える特定の処理(以下、「ライブラリ手続き」という。)に対応したヘッダーファイルを備えることもある。ライブラリを利用するユーザープログラム(ライブラリ手続きを呼び出す、ライブラリに含まれないプログラム)は、ライブラリのオブジェクトコードとリンクされることによって、ライブラリ手続きを利用することができる。なお、ある手続きがライブラリ手続きであるか否かの情報は、ライブラリのヘッダーファイル等の、ライブラリ手続きのリスト情報(以下、「手続きリスト」という。)から得ることができる場合がある。 By the way, programs are often developed using libraries. A “library” is object code in which source code of a program that performs a specific process is compiled in advance. Further, the library may include a header file corresponding to a specific process (hereinafter referred to as “library procedure”) included in the library. A user program that uses a library (a program that calls a library procedure and is not included in the library) can use the library procedure by linking with the object code of the library. Note that information on whether or not a procedure is a library procedure may be obtained from library procedure list information (hereinafter referred to as “procedure list”) such as a library header file.
ライブラリはオブジェクトコードとして提供されるため、ユーザープログラムのコンパイル時には、コンパイラはライブラリのソースコードを利用することができない。このため、ユーザープログラムの関数とライブラリの関数との間では、前述のように十分な最適化を実行することができないという問題がある。オブジェクトコード中に埋め込まれた解析情報を最適化に用いるためには、ライブラリのコンパイル時に解析情報が埋め込まれる必要がある。ところが、一般にライブラリはユーザープログラムの開発者とは異なる開発者によって開発される。さらに、ユーザープログラムのリンクに使われるコンパイラやリンカはライブラリのコンパイル時には不明であることや、異なるユーザープログラムに対しては異なるコンパイラやリンカが利用されることが多い。そのため、ライブラリの開発者が、個別のコンパイラや個別のリンカに対応した解析情報をライブラリのオブジェクトコードに埋め込むことは困難であるという問題がある。また前述のようにオブジェクトコード中に埋め込まれた解析情報では十分な最適化をすることができないという問題もある。 Since the library is provided as object code, the compiler cannot use the source code of the library when compiling the user program. Therefore, there is a problem that sufficient optimization cannot be performed between the function of the user program and the function of the library as described above. In order to use the analysis information embedded in the object code for optimization, the analysis information needs to be embedded when compiling the library. However, in general, the library is developed by a developer different from the developer of the user program. Furthermore, the compiler and linker used for linking user programs are often unknown when compiling the library, and different compilers and linkers are often used for different user programs. Therefore, there is a problem that it is difficult for a library developer to embed analysis information corresponding to an individual compiler or an individual linker in an object code of the library. Further, as described above, there is also a problem that sufficient optimization cannot be performed with the analysis information embedded in the object code.
また、コンパイラの中には、プラグイン機能を備えるものがある。「プラグイン機能」とは、あるプログラムが、一定の仕様を満たした別のプログラム(プラグイン)を起動する機能である。プラグインを用いることによって、プログラムに元々実装された機能を拡張することが可能である。プラグイン機能をサポートするコンパイラにはGNUのgcc等がある。コンパイラのプラグインを利用することにより、コンパイラ自身を変更することなく、コンパイラに新たな機能を導入することができる。 Some compilers have a plug-in function. The “plug-in function” is a function in which a certain program starts another program (plug-in) that satisfies a certain specification. By using plug-ins, it is possible to extend the functions originally implemented in the program. A compiler that supports the plug-in function includes GNU gcc. By using a compiler plug-in, new functions can be introduced into the compiler without changing the compiler itself.
特許文献1のコンパイラは、ソースコードを解析して、レジスタ割り付けのための情報を埋め込んだオブジェクトコードを生成する。レジスタ割り付けのための情報は、ソースコードに一般的に内在するコンパクトな情報である。 The compiler of Patent Document 1 analyzes source code and generates object code in which information for register allocation is embedded. Information for register allocation is compact information that is generally inherent in the source code.
ところが、ユーザープログラム中でライブラリ関数を呼び出す場合の手続き間最適化等では、例えば、呼び出されるライブラリ関数の処理内容に基づいて、ライブラリ手続き(関数等)を呼び出すコードの部分(以下、「ライブラリ手続き呼び出しコード」という。)を最適化されたコードに置き換えることがある。ライブラリ手続き呼び出しコードを最適化されたコードに置き換える操作は、ライブラリ手続きの個別の処理内容に依存するので、最適化のための情報をコンパクトに表現することは困難である。つまり、ライブラリとユーザープログラムとの間での手続き間最適化等の、ユーザープログラムにおけるライブラリ手続き呼び出しコードに対する付加処理のための情報を、オブジェクトコードに埋め込むことは困難である。 However, in interprocedural optimization when calling a library function in a user program, for example, a part of code that calls a library procedure (function, etc.) based on the processing contents of the called library function (hereinafter referred to as “library procedure call”). "Code") may be replaced with optimized code. Since the operation of replacing the library procedure call code with the optimized code depends on the individual processing contents of the library procedure, it is difficult to express information for optimization in a compact manner. That is, it is difficult to embed in the object code information for additional processing to the library procedure call code in the user program, such as interprocedural optimization between the library and the user program.
従って、特許文献1の技術には、ライブラリとユーザープログラムとの間での高度な手続き間最適化等の付加処理を提供すること、つまり、ユーザープログラムにおけるライブラリ手続き呼び出しコードに対して、ライブラリがライブラリの個々の手続きの処理内容に依存する付加処理を提供することが困難であるという問題がある。
(発明の目的)
本発明の目的は、ユーザープログラムにおけるライブラリ手続き呼び出しコードに対して、ライブラリがライブラリの個々の手続きの処理内容に依存する付加処理を提供することが可能な、プログラム処理装置、プログラム処理方法、及びプログラム処理プログラムを提供することにある。
Therefore, the technology of Patent Document 1 provides additional processing such as advanced interprocedural optimization between the library and the user program, that is, the library is the library procedure call code in the user program. There is a problem that it is difficult to provide additional processing depending on the processing contents of individual procedures.
(Object of invention)
An object of the present invention is to provide a program processing apparatus, a program processing method, and a program capable of providing an additional process in which a library depends on the processing content of each procedure of the library to a library procedure call code in a user program. To provide a processing program.
本発明のプログラム処理装置は、ライブラリと共に提供される、ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、呼び出し命令を含むユーザープログラムの第1のコードを取得し、特定したプラグインの実行を指示するユーザープログラム処理手段と、第1のコードを処理対象に指定して、実行を指示されたプラグインを起動するプラグイン起動手段とを備えることを特徴とする。 The program processing apparatus of the present invention specifies a plug-in that is an executable program that performs processing on a code including a call instruction of a procedure included in a library, provided with the library, and first code of a user program including the call instruction And a user program processing means for instructing execution of the specified plug-in, and a plug-in starting means for starting the plug-in instructed to execute by designating the first code as a processing target. Features.
本発明のプログラム処理方法は、ライブラリと共に提供される、ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、呼び出し命令を含むユーザープログラムの第1のコードを取得し、特定したプラグインの実行を指示し、第1のコードを処理対象に指定して、実行を指示されたプラグインを起動することを特徴とする。 The program processing method of the present invention specifies a plug-in that is an executable program that performs processing on a code including a call instruction of a procedure included in a library, provided with the library, and first code of a user program including the call instruction Is obtained, the execution of the specified plug-in is instructed, the first code is designated as a processing target, and the instructed execution is started.
本発明のプログラム処理プログラムは、プログラム処理装置が備えるコンピュータを、ライブラリと共に提供される、ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、呼び出し命令を含むユーザープログラムの第1のコードを取得し、特定したプラグインの実行を指示するユーザープログラム処理手段と、第1のコードを処理対象に指定して、実行を指示されたプラグインを起動するプラグイン起動手段として機能させることを特徴とする。 The program processing program of the present invention specifies a plug-in, which is an executable program that performs processing on a code including a procedure call instruction of a library provided in a library provided by a computer included in the program processing apparatus. User program processing means for acquiring a first code of a user program including the user program and instructing execution of the specified plug-in, and a plug for starting the plug-in instructed to execute by designating the first code as a processing target It functions as an in-starting means.
本発明によれば、ユーザープログラムにおけるライブラリ手続き呼び出しコードに対して、ライブラリがライブラリの個々の手続きの処理内容に依存する付加処理を提供することが可能であるという効果がある。 According to the present invention, there is an effect that it is possible for the library to provide an additional process depending on the processing contents of each procedure of the library to the library procedure call code in the user program.
以下、本発明の実施形態について図面を参照して詳細に説明する。尚、すべての図面において、同等の構成要素には同じ符号を付し、適宜説明を省略する。
(第1の実施形態)
本実施形態における構成について説明する。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings. In all the drawings, equivalent components are denoted by the same reference numerals, and description thereof will be omitted as appropriate.
(First embodiment)
A configuration in the present embodiment will be described.
図1は、本実施形態におけるプログラム処理装置100の構成の一例を示すブロック図である。
FIG. 1 is a block diagram showing an example of the configuration of the
本実施形態におけるプログラム処理装置100は、ライブラリ200を利用する。
The
ライブラリ200は、手続きコード220と、プラグイン210とを含む。
The
ライブラリ200は、ヘッダーファイル230を更に含んでもよい。手続きコード220は、ライブラリ200が提供する手続き(関数等。以下、「ライブラリ手続き」という。)のコードである。ライブラリ手続きのコードは、例えば、オブジェクトコードまたはソースコードである。
The
ヘッダーファイル230は、ライブラリ手続きや外部変数の型宣言等を含むファイルである。
The
プラグイン210は、特定のインターフェース仕様にしたがった記述された、プログラム処理装置100から起動可能なプログラムである。プラグイン210は、例えば、単独で実行可能なプログラムや、プログラムに動的リンクされて呼び出されるダイナミックリンクライブラリである。プラグイン210は、特定の形態をもつものには限定されず、プログラム処理装置100から起動可能な、ライブラリ手続きを呼び出すユーザープログラムのコードに対する処理を行う任意のプログラムである。
The plug-in 210 is a program that can be started from the
プログラム処理装置100は、ライブラリ手続きを呼び出す、ソースコード、またはソースコードが変換された中間コード(以下では、簡単のためにソースコードおよび中間コードを「ソースコード」と総称する)を指定して、プラグイン210を起動する。プラグイン210は、プログラム処理装置100から渡されたソースコードに対して所定の処理を行う。プラグイン210が実行する所定の処理は、ソースコードに対する、変換、最適化、検証等の処理を含むが、それらには限定されない任意の処理である。プラグイン210は、処理の結果をプログラム処理装置100に返してもよい。
The
プラグイン210は、手続き呼び出しコード処理手段240を含む。手続き呼び出しコード処理手段240は、渡されたソースコードの情報、およびライブラリの処理内容に関する情報を利用して、ソースコード中のライブラリ手続き呼び出しを含むコードに対する処理を行う。手続き呼び出しコード処理手段240が実行する処理は、ソースコード中のライブラリ手続き呼び出しコードに対する、変換、最適化、検証等の処理を含むが、それらには限定されない任意の処理である。 The plug-in 210 includes procedure call code processing means 240. The procedure call code processing means 240 processes the code including the library procedure call in the source code by using the passed source code information and information on the processing contents of the library. The processing executed by the procedure call code processing means 240 includes arbitrary processing including, but not limited to, conversion, optimization, verification and the like for the library procedure call code in the source code.
本実施形態におけるプログラム処理装置100は、例えば、コンパイラ、コンパイラのコンポーネント、または単独のツール、すなわち所定の変換処理を行うプログラムである。あるいは、プログラム処理装置100は、コンパイルを含む変換処理を行うコンピュータ等の装置であってもよい。本実施形態においては、プログラム処理装置100が実現する機能に特徴があるのであって、無形のプログラムであるか、有形の装置であるかは本質的問題ではない。
The
プログラム処理装置100は、特定の種類のツールに限定されない。プログラム処理装置100は、ユーザープログラム処理手段120と、プラグイン起動手段110とを含む。
The
ユーザープログラム処理手段120は、プラグイン210を識別するための名称、およびユーザープログラムのソースコードを読み込む。ユーザープログラムとは、ライブラリ手続きを呼び出すプログラムである。ユーザープログラム処理手段120は、読み込んだソースコードに対して、読み込んだプラグイン210の名称に基づいて、ライブラリ手続きに対応するプラグイン210を起動するように、プラグイン起動手段110に指示する。
The user program processing means 120 reads the name for identifying the plug-in 210 and the source code of the user program. A user program is a program that calls a library procedure. The user
プラグイン起動手段110は、指定されたプラグイン210にユーザープログラムのソースコードを渡し、プラグイン210を起動する。
The plug-in
図2は、本実施形態におけるプログラム処理装置100が具体的な装置である場合のハードウェア構成の一例を示すブロック図である。
FIG. 2 is a block diagram illustrating an example of a hardware configuration when the
プログラム処理装置11は、記憶装置12と、CPU(Central Processing Unit)13と、キーボード14と、モニタ15と、I/O(Input/Output)18とを備え、これらが内部バス16で接続されている。記憶装置12は、プラグイン起動手段110等のCPU13の動作プログラムを格納する。CPU13は、プログラム処理装置11全体を制御し、記憶装置12に格納された動作プログラムを実行し、I/O18を介してプラグイン起動手段110等のプログラムの実行やデータの送受信を行なう。なお、上記のプログラム処理装置11の内部構成は一例である。プログラム処理装置11は、CPU13、記憶装置12、及びI/O18のみを備え、外部に備えられた、キーボード14、及びモニタ15を用いて動作してもよい。
The program processing device 11 includes a
次に、本実施形態における動作について説明する。 Next, the operation in this embodiment will be described.
図3は、本実施形態におけるプログラム処理装置100のユーザープログラム処理手段120の動作を説明するためのフローチャートである。
FIG. 3 is a flowchart for explaining the operation of the user program processing means 120 of the
ユーザープログラム処理手段120は、ライブラリ200のプラグイン210の名称を読み込む(ステップS11)。 The user program processing means 120 reads the name of the plug-in 210 of the library 200 (step S11).
ユーザープログラム処理手段120は、ユーザープログラムのソースコードを読み込む(ステップS12)。なお、ステップS11とステップS12の実行順序は、一例であり、これに限定されない。例えば、ステップS12の処理の開始後に、ステップS11の処理が開始されてもよいし、ステップS11の処理とステップS12の処理とが並行して実行されてもよい。 The user program processing means 120 reads the source code of the user program (step S12). In addition, the execution order of step S11 and step S12 is an example, and is not limited to this. For example, after the process of step S12 is started, the process of step S11 may be started, or the process of step S11 and the process of step S12 may be executed in parallel.
ユーザープログラム処理手段120は、読み込んだソースコードに対して、名称を読み込んだプラグイン210を起動するように、プラグイン起動手段110に指示する(ステップS14)。 The user program processing means 120 instructs the plug-in activation means 110 to activate the plug-in 210 whose name has been read for the read source code (step S14).
次に、本実施形態における処理手順の具体例について説明する。 Next, a specific example of the processing procedure in the present embodiment will be described.
図4は、本実施形態におけるプログラム処理装置100の処理手順の具体例を説明するための図である。
FIG. 4 is a diagram for explaining a specific example of the processing procedure of the
図4(a)に本実施例におけるユーザープログラムのソースコード(”source.c”:以下、「ユーザープログラムA」)を、図4(b)に本実施例におけるプログラム処理装置100を起動するコマンドラインを、図4(c)に本実施例におけるライブラリ200の手続きコード220であるソースコード(“library_source.c”:以下、「ライブラリプログラムC」)を、図4(d)に本実施例におけるプラグイン210の実行結果であるエラーメッセージを示す。
FIG. 4A shows a source code (“source.c”: “user program A”) of the user program in this embodiment, and FIG. 4B shows a command for starting the
まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。 First, the premise for explaining a specific example of the processing procedure in the present embodiment will be described.
ライブラリ200の提供するプラグイン210は、ユーザープログラムAを読み込み、ユーザープログラムA中のライブラリ手続き呼び出しコードの引数の正常性を確認し、異常があればエラーメッセージを出力する実行可能プログラムである。
The plug-in 210 provided by the
「div」は、ライブラリ200が提供する手続きコード220に含まれる手続き名である。ライブラリ手続き「div」は、整数である第1引数を、整数である第2引数で除算する関数である。「arg-verification」は、ライブラリ200が提供するプラグイン210のファイル名である。プラグイン「arg-verification」は、ライブラリ200のライブラリ手続きを呼び出すコードの引数の正常性を確認する。
“Div” is a procedure name included in the
なお、上述のライブラリ手続きとプラグインの機能との対応関係は一例であり、これに限定されない。特定のライブラリに対して、そのライブラリ手続きを呼び出すコードに対する付加処理を行うプラグインが特定されればよい。例えば、ライブラリ200により提供される任意のライブラリ手続きを呼び出すコードに対して、1つのプラグイン「arg-verification」が、各ライブラリ手続きに応じて、引数の正常性確認に限られない個別の処理を実行してもよい。
The correspondence relationship between the above-described library procedure and the plug-in function is an example, and the present invention is not limited to this. For a specific library, a plug-in that performs an additional process for a code that calls the library procedure may be specified. For example, for a code that calls an arbitrary library procedure provided by the
ユーザープログラムAの3行目において、ライブラリ手続き「div(2,0)」が呼び出される。 In the third line of the user program A, the library procedure “div (2,0)” is called.
以上が、以下の処理手順における前提である。次に、処理手順について説明する。 The above is the premise in the following processing procedure. Next, the processing procedure will be described.
ユーザープログラム処理手段120は、プログラム処理装置100の起動時のコマンドライン(図4(b))を読み込み、コマンドライン中の“-plugin”オプションの引数を取得することにより、プラグイン210の名称を取得する(ステップS11)。ユーザープログラム処理手段120は、プラグイン「arg-verification」が、ライブラリ200のプラグインであることを記憶する。
The user program processing means 120 reads the command line (FIG. 4B) at the time of starting the
ユーザープログラム処理手段120は、ユーザープログラムのソースコードを読み込む(ステップS12)。 The user program processing means 120 reads the source code of the user program (step S12).
ユーザープログラム処理手段120は、ライブラリ200のプラグイン210「arg-verification」を起動するように、プラグイン起動手段110に指示する(ステップS14)。 The user program processing means 120 instructs the plug-in activation means 110 to activate the plug-in 210 “arg-verification” of the library 200 (step S14).
プラグイン起動手段110は、指定されたプラグイン「arg-verification」にユーザープログラムAのソースコードを渡し、プラグイン「arg-verification」を起動する。
The plug-in
プラグイン「arg-verification」は、渡されたユーザープログラムAを読み込み、ユーザープログラムA中のライブラリ手続き呼び出しコード「div(2,0)」の引数の正常性を確認し、異常があればエラーメッセージを出力する。具体的には、整数である第1引数を、整数である第2引数で除算することができないので、プラグイン「arg-verification」は、異常があると判定し、エラーメッセージ「Error: Illegal arguments: div(2,0)」を出力する。 The plug-in “arg-verification” reads the passed user program A, checks the normality of the argument of the library procedure call code “div (2,0)” in the user program A, and if there is an error, an error message Is output. Specifically, since the first argument that is an integer cannot be divided by the second argument that is an integer, the plug-in “arg-verification” determines that there is an abnormality, and the error message “Error: Illegal arguments” : div (2,0) "is output.
以上説明したように、本実施形態におけるプログラム処理装置100は、プログラム処理装置100起動時のコマンドラインにより指定されたプラグイン210に、ライブラリ200のライブラリ手続き呼び出しコードを含むユーザープログラムのソースコードを渡し、プラグイン210を起動する。つまり、プラグイン210は、ライブラリ手続きの処理内容に関する情報を利用して、ユーザープログラム中のライブラリ手続き呼び出しコードを処理することができる。したがって、本実施形態におけるプログラム処理装置100では、ユーザープログラムにおけるライブラリ手続き呼び出しコードに対して、ライブラリがライブラリの個々の手続きの処理内容に依存する付加処理を提供することが可能であるという効果がある。
As described above, the
なお、本実施形態では、プラグインの名称がプログラム処理装置100を起動するコマンドラインオプションとして指定される場合について説明した。しかしながら、本実施形態におけるプラグインの名称は、必ずしもコマンドライン中に指定される必要はない。本実施形態におけるプラグインの名称は、コマンドラインとは別の情報源(ファイル、特定フォルダ配下のファイル、環境変数等)に指定されてもよい。プラグインの名称がコマンドラインとは別の情報源に記述されている場合には、プログラム処理装置100は別の情報源からプラグインの名称を取得してもよい。
(第2の実施形態)
本実施形態における構成について説明する。
In the present embodiment, the case where the name of the plug-in is designated as a command line option for starting the
(Second Embodiment)
A configuration in the present embodiment will be described.
図5は、本実施形態におけるプログラム処理装置104の構成の一例を示すブロック図である。 FIG. 5 is a block diagram showing an example of the configuration of the program processing apparatus 104 in the present embodiment.
本実施形態におけるプログラム処理装置104は、ライブラリ204を利用する。
The program processing apparatus 104 in this embodiment uses a
ライブラリ204は、手続きコード220と、手続きリスト234と、プラグイン210とを含む。
The
手続きリスト234は、ライブラリ手続きのリストである。手続きリスト234は、ライブラリ手続きに関する付加処理を行うプラグイン210を特定する情報を更に含む。特定のライブラリ手続きに対して特定のプラグインが対応する場合には、手続きリスト234は、特定のライブラリ手続きに対して特定のプラグインを対応付ける情報を更に含んでもよい。手続きリスト234は、例えば、ライブラリのヘッダーファイルである。しかしながら、手続きリスト234はライブラリのヘッダーファイルに限定されない。手続きリスト234は、ライブラリ手続き、及びライブラリ手続きに対するプラグイン、を特定する情報を保持する任意の情報源(ファイル、特定フォルダ配下のファイル、コマンドラインオプション、環境変数等)であってよい。なお、手続きリスト234の内容は、複数の情報源(ファイル、特定フォルダ配下のファイル、コマンドラインオプション、環境変数等)に分散されて保持されてもよい。
The
プログラム処理装置104は、ライブラリ手続きを呼び出す、ソースコードを指定して、プラグイン210を起動する。プラグイン210は、プログラム処理装置104から渡されたソースコードに対して所定の処理を行う。 The program processing device 104 activates the plug-in 210 by specifying a source code for calling a library procedure. The plug-in 210 performs predetermined processing on the source code passed from the program processing device 104.
プログラム処理装置104は、ユーザープログラム処理手段124と、プラグイン起動手段110とを含む。 The program processing device 104 includes user program processing means 124 and plug-in activation means 110.
ユーザープログラム処理手段124は、手続きリスト234、およびユーザープログラムのソースコードを読み込み、ユーザープログラム中のライブラリ手続き呼び出しを含むコードを検索する。ユーザープログラム処理手段124は、ライブラリ手続き呼び出しを含む未処理のコードに対して、読み込んだ手続きリスト234中のプラグイン210の情報に基づいて、ライブラリ手続きに対応するプラグイン210を起動するように、プラグイン起動手段110に指示する。
The user program processing means 124 reads the
その他の構成要素については、第1の実施形態と同じである。 Other components are the same as those in the first embodiment.
次に、本実施形態における動作について説明する。 Next, the operation in this embodiment will be described.
図6は、本実施形態におけるプログラム処理装置104のユーザープログラム処理手段124の動作を説明するためのフローチャートである。 FIG. 6 is a flowchart for explaining the operation of the user program processing means 124 of the program processing apparatus 104 in the present embodiment.
ユーザープログラム処理手段124は、ライブラリ204の手続きリスト234を読み込む(ステップS21)。
The user
ユーザープログラム処理手段124は、ユーザープログラムのソースコードを読み込み、ユーザープログラム中のライブラリ手続き呼び出しを含む未処理のコードを検索する(ステップS22)。なお、ステップS21とステップS22の実行順序は、一例であり、これに限定されない。ステップS22において、あるライブラリ手続きの呼び出しを含むコードを検索する前に、そのライブラリ手続きを含む手続きリストが読み込まれればよい。例えば、ステップS22の処理の開始後に、ステップS21の処理が開始されてもよいし、ステップS21の処理とステップS22の処理とが並行して実行されてもよい。 The user program processing means 124 reads the source code of the user program and searches for unprocessed code including library procedure calls in the user program (step S22). In addition, the execution order of step S21 and step S22 is an example, and is not limited to this. In step S22, a procedure list including the library procedure may be read before searching for a code including a call to a library procedure. For example, after the process of step S22 is started, the process of step S21 may be started, or the process of step S21 and the process of step S22 may be executed in parallel.
ユーザープログラム処理手段124は、ユーザープログラム中のライブラリ手続き呼び出しを含む未処理のコードの有無を判定する(ステップS23)。 The user program processing means 124 determines whether or not there is an unprocessed code including a library procedure call in the user program (step S23).
ユーザープログラム中のライブラリ手続き呼び出しを含む未処理のコードが存在しないと(ステップS23:No)、ユーザープログラム処理手段124は、処理を終了する。
If there is no unprocessed code including a library procedure call in the user program (step S23: No), the user
ユーザープログラム中のライブラリ手続き呼び出しを含む未処理のコードを発見すると(ステップS23:Yes)、ユーザープログラム処理手段124は、読み込んだ手続きリスト234中で指定された、ライブラリ手続き呼び出しを含む未処理のコードに対応するプラグイン210を起動するように、プラグイン起動手段110に指示する(ステップS24)。
When the unprocessed code including the library procedure call in the user program is found (step S23: Yes), the user program processing means 124 specifies the unprocessed code including the library procedure call specified in the
次に、本実施形態における処理手順の具体例について説明する。 Next, a specific example of the processing procedure in the present embodiment will be described.
図7は、本実施形態におけるプログラム処理装置104の処理手順の具体例を説明するための図である。 FIG. 7 is a diagram for explaining a specific example of the processing procedure of the program processing apparatus 104 in the present embodiment.
図7(a)に本実施例におけるユーザープログラムのソースコード(”source.c”:以下、「ユーザープログラムA」)を、図7(b)に本実施例におけるライブラリ204の手続きリスト234であるヘッダーファイルのソースコード(“library_header.h”:以下、「ヘッダーファイルB」)を、図7(c)に本実施例におけるライブラリ204の手続きコード220であるソースコード(“library_source.c”:以下、「ライブラリプログラムC」)を、図7(d)に本実施例におけるプラグイン210の実行結果であるエラーメッセージを示す。
FIG. 7A shows the source code (“source.c”: “user program A”) of the user program in this embodiment, and FIG. 7B shows the
まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。 First, the premise for explaining a specific example of the processing procedure in the present embodiment will be described.
ユーザープログラムA中には、手続きリストであるヘッダーファイルBのインクルードを指示する指示文として、以下が記述されている。 In the user program A, the following is described as an instruction for instructing inclusion of the header file B which is a procedure list.
#include <library_header.h>
ライブラリ204の提供するプラグイン210は、ユーザープログラムAを読み込み、ユーザープログラムA中のライブラリ手続き呼び出しコードの引数の正常性を確認し、異常があればエラーメッセージを出力する実行可能プログラムである。
#include <library_header.h>
The plug-in 210 provided by the
ライブラリ204が提供するヘッダーファイルB中には、手続きリスト234として、以下が記述されている。
In the header file B provided by the
#pragma plugin div-verification div
「div」は、ライブラリ204が提供する手続きコード220に含まれる手続き名である。ライブラリ手続き「div」は、整数である第1引数を、整数である第2引数で除算する関数である。「div-verification」は、ライブラリ204が提供するプラグイン210のファイル名である。上記の記述は、プラグイン「div-verification」が、ライブラリ手続き「div」に対応することを示す。プラグイン「div-verification」は、対応するライブラリ手続き「div」の引数の正常性を確認する。
#pragma plugin div-verification div
“Div” is a procedure name included in the
なお、上述のライブラリ手続きとプラグインとの対応付けは一例であり、これに限定されない。特定のライブラリ手続きに対して、その手続きの処理を行うプラグインが特定されればよい。例えば、ヘッダーファイルB中で関数宣言されたすべてのライブラリ手続きに対して、1つのプラグインが対応付けられ、1つのプラグインが各ライブラリ手続きに応じた個別の処理を実行してもよい。 Note that the above-described association between the library procedure and the plug-in is an example, and the present invention is not limited to this. For a specific library procedure, a plug-in that performs the processing of the procedure may be specified. For example, one plug-in may be associated with all library procedures declared in the header file B, and one plug-in may execute individual processing corresponding to each library procedure.
ユーザープログラムAの3行目において、ライブラリ手続き「div(2,0)」が呼び出される。 In the third line of the user program A, the library procedure “div (2,0)” is called.
以上が、以下の処理手順における前提である。次に、処理手順について説明する。 The above is the premise in the following processing procedure. Next, the processing procedure will be described.
ユーザープログラム処理手段124は、ユーザープログラムAを読み込み、ユーザープログラムA中のインクルード指示文を処理することにより、ライブラリ204の手続きリスト234であるヘッダーファイルBを読み込む(ステップS21)。ユーザープログラム処理手段124は、ライブラリ204のヘッダーファイルBを読み込むと、ヘッダーファイルB中の「#pragma plugin」指示文を見つけ、プラグイン「div-verification」が、ライブラリ手続き「div」に対応することを記憶する。
The user program processing means 124 reads the user program A and reads the header file B which is the
ユーザープログラム処理手段124は、ユーザープログラムのソースコードを読み込み、ユーザープログラム中のライブラリ手続き「div」の呼び出しを含む未処理のコードを検索する(ステップS22)。 The user program processing means 124 reads the source code of the user program and searches for an unprocessed code including a call to the library procedure “div” in the user program (step S22).
ユーザープログラム中にライブラリ手続き「div」の呼び出しを含む未処理のコードが発見されるので(ステップS23:Yes)、ユーザープログラム処理手段124は、ライブラリ手続き「div」に対応するプラグイン「div-verification」を起動するように、プラグイン起動手段110に指示する(ステップS24)。なお、ヘッダーファイルB中で関数宣言されたすべてのライブラリ手続きに対して、1つのプラグインが対応付けられる場合には、1つのプラグインが各ライブラリ手続きに応じた個別の処理を実行してもよい。
Since unprocessed code including a call to the library procedure “div” is found in the user program (step S23: Yes), the user
プラグイン起動手段110は、指定されたプラグイン「div-verification」にユーザープログラムAのソースコードを渡し、プラグイン「div-verification」を起動する。
The plug-in
プラグイン「div-verification」は、渡されたユーザープログラムAを読み込み、ユーザープログラムA中のライブラリ手続き呼び出しコード「div(2,0)」の引数の正常性を確認し、異常があればエラーメッセージを出力する。具体的には、整数である第1引数を、整数である第2引数で除算することができないので、プラグイン「div-verification」は、異常があると判定し、エラーメッセージ「Error: Illegal arguments: div(2,0)」を出力する。 The plug-in “div-verification” reads the passed user program A, checks the normality of the argument of the library procedure call code “div (2,0)” in the user program A, and if there is an error, an error message Is output. Specifically, since the first argument that is an integer cannot be divided by the second argument that is an integer, the plug-in “div-verification” determines that there is an abnormality, and the error message “Error: Illegal arguments” : div (2,0) "is output.
以上説明したように、本実施形態におけるプログラム処理装置104は、ユーザープログラム中に、ライブラリ204のライブラリ手続き呼び出しコードが存在すると、手続きリスト234中でライブラリ手続きに対応付けられたプラグイン210にユーザープログラムのソースコードを渡し、プラグイン210を起動する。つまり、プラグイン210は、ライブラリ手続きの処理内容に関する情報を利用して、ユーザープログラムのソースコードを処理することができる。したがって、本実施形態におけるプログラム処理装置104では、ユーザープログラムにおけるライブラリ手続き呼び出しコードに対して、ライブラリがライブラリの個々の手続きの処理内容に依存する付加処理を提供することが可能であるという効果がある。
As described above, when the library procedure call code of the
なお、本実施形態では、手続きリストがライブラリの提供するヘッダーファイル中に記述されている場合について説明した。しかしながら、本実施形態における手続きリストは、必ずしもヘッダーファイル中に記述されている必要はない。本実施形態における手続きリストは、ヘッダーファイルとは別の情報源(ファイル、特定フォルダ配下のファイル、コマンドラインオプション、環境変数等)に記述されてもよい。手続きリストがヘッダーファイルとは別の情報源に記述されている場合には、プログラム処理装置104は別の情報源から手続きリストを読み込んでもよい。
(第3の実施形態)
本発明による「処理」の例として、ソースコードからオブジェクトコードへの「変換」であるコンパイルを行うプログラム変換装置の例を第3の実施形態として示す。
In the present embodiment, the case where the procedure list is described in the header file provided by the library has been described. However, the procedure list in this embodiment does not necessarily have to be described in the header file. The procedure list in this embodiment may be described in an information source (a file, a file under a specific folder, a command line option, an environment variable, etc.) different from the header file. When the procedure list is described in an information source different from the header file, the program processing apparatus 104 may read the procedure list from another information source.
(Third embodiment)
As an example of “processing” according to the present invention, an example of a program conversion apparatus that performs compilation, which is “conversion” from source code to object code, will be described as a third embodiment.
図8は、本実施形態におけるプログラム変換装置105の構成の一例を示すブロック図である。
FIG. 8 is a block diagram showing an example of the configuration of the
本実施形態におけるプログラム変換装置105は、ライブラリ205を利用する。
The
ライブラリ205は、オブジェクトコード225と、ヘッダーファイル235と、プラグイン215とを含む。
The
ヘッダーファイル235は、プラグイン215の起動を指示する指示文255を含む。
The
プラグイン215は、コンパイラが定めるインターフェース仕様にしたがった記述された、コンパイラから起動可能なプログラムである。プラグイン215は、例えば、単独で実行可能なプログラムや、プログラムに動的リンクされて呼び出されるダイナミックリンクライブラリである。プラグイン215は、特定の形態をもつものには限定されず、コンパイラから起動可能な任意のプログラムである。 The plug-in 215 is a program that can be started from the compiler, which is described according to the interface specification defined by the compiler. The plug-in 215 is, for example, a program that can be executed alone or a dynamic link library that is called by being dynamically linked to the program. The plug-in 215 is not limited to one having a specific form, and is an arbitrary program that can be started from a compiler.
コンパイラは、ソースコード、またはソースコードを指定して、プラグイン215を起動する。プラグイン215は、コンパイラから渡されたソースコードに対して最適化を行い、最適化の結果をコンパイラに返す。 The compiler activates the plug-in 215 by specifying the source code or the source code. The plug-in 215 optimizes the source code passed from the compiler and returns the optimization result to the compiler.
プラグイン215は、最適化手段245を含む。最適化手段245は、渡されたソースコードの情報およびライブラリの処理内容に関する情報を利用して、ソースコード中のライブラリ手続き呼び出しコードの最適化を行う。
Plug-in 215 includes optimization means 245. The
指示文255は、ライブラリプログラム中に記述された、コンパイラへ指示を与える文である。ヘッダーファイル235中の指示文255は、コンパイラに対して、ライブラリ205が提供するプラグイン215を起動することを指示する。
The
本実施形態におけるプログラム変換装置105は、例えば、コンパイラ、コンパイラのコンポーネント、または単独のツール、すなわち所定の変換処理を行うプログラムである。あるいは、プログラム変換装置105は、コンパイルを含む変換処理を行うコンピュータ等の装置であってもよい。本実施形態においては、プログラム変換装置105が実現する機能に特徴があるのであって、無形のプログラムであるか、有形の装置であるかは本質的問題ではない。
The
プログラム変換装置105は、指示文処理手段125と、プラグイン起動手段115とを含む。プログラム変換装置105は、その他のコンパイラの一般的な構成要素を更に含んでもよい。
The
指示文処理手段125は、ソースコード(例えば、ヘッダーファイル235)中の指示文(例えば、指示文255)を読み込み、指示文で指定される処理を行う。指示文は、例えば、C言語のインクルード指示文である。指示文処理手段125は、一般的なコンパイラが有する指示文を処理する機能を有してもよい。指示文処理手段125は、プラグイン215の起動を指示する指示文255を読み込み、指示文255で指定されたプラグイン215を起動するように、プラグイン起動手段115に指示する。指示文処理手段125は、その他の指示文を処理する機能を有してもよい。
The instruction
プラグイン起動手段115は、指定されたプラグイン215にソースコードを渡し、プラグイン215を起動する。プラグイン起動手段115は、プラグイン215から返却される最適化された、ソースコードまたは中間コードを受け取る。プラグイン起動手段115は、ソースコードに加えて、コンパイラが解析した情報(例えば、変数の依存関係に関する情報)をプラグイン215に渡してもよい。
The plug-in
なお、コンパイラは、一般にソースコードをオブジェクトコードに変換するプログラムを指すが、ソースコードを別のソースコードに変換するプログラムをコンパイラと呼ぶこともある。ソースコードを別のソースコードに変換するプログラムは、ソースツーソースコンパイラまたはプリプロセッサと呼ばれることがある。プログラム変換装置105は、ソースツーソースコンパイラであってもよい。
A compiler generally refers to a program that converts source code into object code, but a program that converts source code into another source code may also be referred to as a compiler. A program that converts source code into another source code is sometimes called a source-to-source compiler or preprocessor. The
次に、本実施形態における動作について説明する。 Next, the operation in this embodiment will be described.
図9は、本実施形態におけるプログラム変換装置105の動作を説明するための図である。
FIG. 9 is a diagram for explaining the operation of the
本実施形態におけるユーザープログラム305のソースコードは、ライブラリ205を利用するために、ライブラリ205が提供するヘッダーファイル235をインクルードする。「インクルードする」とは、例えば、プログラム中のインクルード指示文によって、ライブラリ205のヘッダーファイル235があたかもユーザープログラム305のソースコード中に含まれるかのように、プログラム変換装置105により取り扱われることである。
In order to use the
プログラム変換装置105の指示文処理手段125は、まず、ユーザープログラム305中のインクルード指示文を処理する。指示文処理手段125は、ライブラリ205のヘッダーファイル235を読み込む。次に、指示文処理手段125は、読み込んだヘッダーファイル235中の指示文255を処理する。前述のように、ヘッダーファイル235中には、プラグイン215の起動を指示する指示文255が記述されている。指示文処理手段125は、指示文255に対する処理として、プラグイン起動手段115に、指示文255で指定されたプラグイン215を起動するように指示する。
The instruction sentence processing means 125 of the
プラグイン起動手段115は、コンパイラ(プログラム変換装置105)のプラグイン仕様にしたがって、プラグイン215を起動する。
The plug-in
プログラム変換装置105は、プラグイン215から返却されたソースコード(または中間コード)を用いて、コンパイラとしての処理を継続する。プログラム変換装置105は、オブジェクトコード405を生成し、生成したオブジェクトコード405と、ライブラリ205が提供するオブジェクトコード225とをリンクし、実行プログラム605を生成する。
The
次に、本実施形態における処理手順の具体例について説明する。 Next, a specific example of the processing procedure in the present embodiment will be described.
図10は、本実施形態におけるプログラム変換装置105の処理手順の具体例を説明するための図である。
FIG. 10 is a diagram for explaining a specific example of the processing procedure of the
図10(a)に本実施例におけるユーザープログラム305のソースコード(”source.c”:以下、「ユーザープログラムE」)を、図10(b)に本実施例におけるライブラリ205のヘッダーファイル235のソースコード(“library_header.h”:以下、「ヘッダーファイルF」)を、図10(c)に本実施例におけるライブラリ205のソースコード(“library_source.c”:以下、「ライブラリプログラムG」)を、図10(d)に本実施例におけるユーザープログラムEが最適化されたプログラムのソースコード(図示しない。以下、「プログラムH」)を示す。
FIG. 10A shows the source code (“source.c”: “user program E”) of the
まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。 First, the premise for explaining a specific example of the processing procedure in the present embodiment will be described.
ユーザープログラムE中には、ヘッダーファイルFのインクルードを指示する指示文として、以下が記述されている。 In the user program E, the following is described as an instruction for instructing inclusion of the header file F.
#include <library_header.h>
ライブラリ205の提供するプラグイン215は、ユーザープログラムEを読み込み最適化後のプログラムHを出力する実行可能プログラムである。
#include <library_header.h>
The plug-in 215 provided by the
ライブラリ205が提供するヘッダーファイルF中には、プラグイン215の実行を指示する指示文255として、以下が記述されている。
In the header file F provided by the
#pragma plugin mulexpanshion
「mulexpansion」は、ライブラリ205が提供するプラグイン215のファイル名である。
#pragma plugin mulexpanshion
“Mulexpansion” is the file name of the plug-in 215 provided by the
以上が、以下の処理手順における前提である。次に、処理手順について説明する。 The above is the premise in the following processing procedure. Next, the processing procedure will be described.
指示文処理手段125は、ユーザープログラムEを読み込み、ユーザープログラムE中のインクルード指示文を処理することにより、ライブラリ205のヘッダーファイルFを読み込む。
The instruction
指示文処理手段125は、ライブラリ205のヘッダーファイルFを読み込むと、ヘッダーファイルF中の「#pragma plugin」指示文を見つける。指示文処理手段125は、「#pragma plugin」指示文を見つけると、プラグイン起動手段115にプラグイン215(mulexpansion)を起動するように指示する。
When reading the header file F of the
プラグイン起動手段115は、実行パス中に「mulexpansion」という実行ファイルがあるか否かを検索し、見つかった場合には、プラグインmulexpansionを以下のような引数で起動する。 The plug-in activation means 115 searches for an execution file “mulexpansion” in the execution path, and if found, activates the plug-in mulexpansion with the following argument.
mulexpansion “source.c” “tmp.c”
ここで、第1引数はソースファイル(ユーザープログラムE)の名前、第2引数はプラグイン215が最適化の結果(プログラムH)を格納するファイル名である。
mulexpansion “source.c” “tmp.c”
Here, the first argument is the name of the source file (user program E), and the second argument is the file name in which the plug-in 215 stores the optimization result (program H).
プラグインmulexpansionは、渡されたソースコード(ユーザープログラムE)を解析して、「mul(2,3)」という形でライブラリ関数mulが呼び出されていることを認識する。プラグインmulexpansionは、ライブラリ関数mulは渡された引数の乗算を行う関数であることを利用して定数伝搬を行い、最適化後のプログラムH(”tmp.c”)を出力する(”tmp.c”中の本実施例に無関係な部分は省略されている)。プラグインmulexpansionは、ライブラリ開発者によって作成される。そのため、プラグインmulexpansionは、ライブラリ関数mulが引数の乗算を行う関数であることを利用した最適化が可能であることは明らかである。プラグイン215による最適化の実施方法の詳細は本発明とは直接関係しないので説明を省略する。 The plug-in mulexpansion analyzes the passed source code (user program E) and recognizes that the library function mul is called in the form of “mul (2,3)”. The plug-in mulexpansion performs constant propagation using the library function mul that is a function that multiplies the passed arguments, and outputs the optimized program H (“tmp.c”) (“tmp. The portion of c ″ that is not relevant to the present embodiment is omitted). Plug-in mulexpansion is created by library developers. Therefore, it is clear that the plug-in mulexpansion can be optimized using the fact that the library function mul is a function that performs argument multiplication. The details of the method of performing the optimization by the plug-in 215 are not directly related to the present invention, and thus description thereof is omitted.
プログラム変換装置105は、プラグインmulexpansionが出力した”tmp.c”を用いてコンパイル処理を継続する。
The
なお、プログラム変換装置105は、プラグイン215を連続的に起動する場合には、後続のプラグイン215の起動では、先行するプラグイン215の出力ファイル(プログラムH)を更に渡してもよい。
When the plug-in 215 is continuously activated, the
プラグインmulexpansionが実行された結果、「x = mul(2,3)」というユーザープログラムE中にあるライブラリ手続き呼び出しコードは、代入文「x = 6」に置き換えられる。すなわち、ユーザープログラムEの実行時には、ライブラリ関数mulによる乗算処理は行われず代入処理のみが行われる。そのため、プログラム変換装置105は、演算量を削減することで、最適化が行われなかった場合に比べてプログラムの実行を高速化する実行プログラム605を生成するためのオブジェクトコード405を生成する。
As a result of execution of the plug-in mulexpansion, the library procedure call code in the user program E “x = mul (2,3)” is replaced with the assignment statement “x = 6”. That is, when executing the user program E, only the substitution process is performed without performing the multiplication process by the library function mul. Therefore, the
一方、ライブラリの提供するプラグインを用いることなくコンパイラが最適化を行う場合には、ライブラリはオブジェクトコードで提供されるため、コンパイラがライブラリ関数mulの処理内容に関する情報を得ることは困難である。ライブラリ関数の処理内容に関する情報を用いることができない場合には、ライブラリ手続き呼び出しコード「x = mul(2,3)」を代入文「x = 6」に置き換えることは不可能である。したがって、コンパイラは、ライブラリ関数mulを呼び出すコードを生成する。そのため、実行プログラムの実行時には、ライブラリ関数mulによる乗算が実行される。 On the other hand, when the compiler performs optimization without using the plug-in provided by the library, since the library is provided by object code, it is difficult for the compiler to obtain information on the processing contents of the library function mul. When the information regarding the processing contents of the library function cannot be used, it is impossible to replace the library procedure call code “x = mul (2,3)” with the assignment statement “x = 6”. Therefore, the compiler generates code that calls the library function mul. Therefore, multiplication by the library function mul is executed when the execution program is executed.
次に、本実施形態における処理手順の別の具体例について説明する。 Next, another specific example of the processing procedure in the present embodiment will be described.
図11は、本実施形態におけるプログラム処理装置105の処理手順の別の具体例におけるユーザープログラムとライブラリプログラムを説明するための図である。
FIG. 11 is a diagram for explaining a user program and a library program in another specific example of the processing procedure of the
図12は、本実施形態におけるプログラム変換装置105の処理手順の別の具体例における最適化されないプログラムと最適化されたプログラムを説明するための図である。
FIG. 12 is a diagram for explaining an unoptimized program and an optimized program in another specific example of the processing procedure of the
図11(a)に本実施例におけるユーザープログラム305のソースコード(以下、「ユーザープログラムJ」)を、図11(b)に本実施例におけるライブラリ205のソースコード(以下、「ライブラリプログラムK」)を示す。
FIG. 11A shows the source code of the user program 305 (hereinafter referred to as “user program J”) in this embodiment, and FIG. 11B shows the source code of the
まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。 First, the premise for explaining a specific example of the processing procedure in the present embodiment will be described.
以上が、以下の処理手順における前提である。次に、処理手順について説明する。 The above is the premise in the following processing procedure. Next, the processing procedure will be described.
次に、本実施形態における処理手順の別の具体例について説明する。本実施例はライブラリ205が行列演算機能を提供する場合の例である。ライブラリ205は、C++のクラスライブラリであり、行列クラスMatを提供する。
Next, another specific example of the processing procedure in the present embodiment will be described. This embodiment is an example when the
図11(a)に、本実施例における305のソースコード(以下、「ユーザープログラムJ」)を示す。ユーザープログラムJでは、行列クラス型Matの4つのデータA、B、C、Dに対して、「A=B+C−D」という演算を行う。図11(b)に、本実施例におけるライブラリ205のソースコード(以下、「ライブラリプログラムK」)を示す。ライブラリプログラムKでは、行列クラスの3つの演算子“+”、“−”、“=”が定義される。なお、ユーザープログラムJおよびライブラリプログラムKのプログラム例は処理内容を模式的に表したものである。
FIG. 11A shows source code 305 (hereinafter, “user program J”) in the present embodiment. In the user program J, an operation “A = B + C−D” is performed on the four data A, B, C, and D of the matrix class type Mat. FIG. 11B shows a source code (hereinafter, “library program K”) of the
ユーザープログラムJを通常のコンパイル方法でコンパイルする場合、コンパイラの最適化部はライブラリ関数(すなわち行列クラスの演算子)の処理内容に関する情報を有しないため、コンパイラは手続き間最適化を実行せずにライブラリ関数を呼び出すオブジェクトコードを生成する。図12(a)に、ユーザープログラムJが手続き間最適化されない場合の、ライブラリ関数の呼び出し側のオブジェクトコードに対応するソースコードを模式的に示す。図12(a)に示すように、3つの各演算子“+”、“−”、“=”に対応する3つのライブラリ関数が順次、呼び出される。各演算子“+”、“−”、“=”に対応する処理内容は、図11(b)に示すように、それぞれ、行列の各要素に対する加算、減算、代入を繰り返し実行するものである。したがって、「A=B+C−D」という式に対しては、演算子毎に1回、合計3回の繰り返し処理が行われる。また、最適化されないプログラムLでは、「A=B+C−D」という式に対して、3つの一時行列(tmp1、tmp2、tmp)を用いた演算が行われる。 When compiling the user program J by the normal compilation method, the compiler optimization section does not have information on the processing contents of the library function (that is, the operator of the matrix class), so the compiler does not perform interprocedural optimization. Generate object code that calls library functions. FIG. 12A schematically shows source code corresponding to the object code on the call side of the library function when the user program J is not optimized between procedures. As shown in FIG. 12A, three library functions corresponding to the three operators “+”, “−”, and “=” are sequentially called. The processing contents corresponding to the operators “+”, “−”, and “=” repeatedly execute addition, subtraction, and substitution for each element of the matrix, as shown in FIG. 11B. . Therefore, the expression “A = B + C−D” is subjected to a repetition process three times, once for each operator. In the non-optimized program L, an operation using three temporary matrices (tmp1, tmp2, tmp) is performed on the expression “A = B + C−D”.
一方、プログラム変換装置105がユーザープログラムJを変換する場合は、プラグイン215はライブラリプログラムKの開発者により提供されるので、プラグイン215はライブラリ関数の処理内容に関する情報を利用可能である。そのため、プラグイン215は、図12(b)に示すように、「A=B+C−D」という演算を1回の繰り返し処理に変換することができる。また、最適化後のプログラムMでは、「A=B+C−D」という式に対して、演算の実行に一時行列が不要である。最適化後のプログラムMでは、最適化されないプログラムLに比べ、演算時間および利用メモリ量を削減することができる。
On the other hand, when the
以上説明したように、本実施形態におけるプログラム変換装置105は、ライブラリが提供するヘッダーファイル中で、ライブラリが提供するプラグインの起動が指示されると、プラグインを起動する。つまり、プログラム変換装置105は、ライブラリを利用するユーザープログラムを変更することなく、プラグインを起動することができる。プラグインにはユーザープログラムのソースコード(またはソースコードに対応する中間コード)が渡されるため、プラグインはソースコードを解析してユーザープログラムに関する情報を得ることができる。プラグインはライブラリ提供者によって作成されるため、ライブラリ提供者はライブラリの処理内容に関する情報を利用して、プラグインを作成することができる。つまり、プラグインは、ユーザープログラムおよびライブラリの情報を利用して手続き間最適化を行うことが可能である。したがって、本実施形態におけるプログラム変換装置105では、ライブラリとユーザープログラムとの間で手続き間最適化を行うことが可能であるという効果がある。
As described above, the
なお、本実施形態では、プラグインを起動する指示文がライブラリの提供するヘッダーファイル中に記述されている場合について説明した。しかしながら、本実施形態における指示文は、必ずしもヘッダーファイル中に記述されている必要はない。本実施形態における指示文は、ユーザープログラム中に記述されてもよい。指示文がユーザープログラム中に記述されている場合には、ユーザープログラムの開発者がユーザープログラムを書き換える必要があるが、プラグインを起動するかどうかをユーザープログラムの開発者が制御することができるという効果がある。 In the present embodiment, the description has been given of the case where the directive for starting the plug-in is described in the header file provided by the library. However, the directive in this embodiment does not necessarily need to be described in the header file. The directive in this embodiment may be described in the user program. If the directive is described in the user program, the user program developer must rewrite the user program, but the user program developer can control whether the plug-in is activated. effective.
本実施形態の説明から明らかなように、本実施形態におけるプログラム変換装置105の効果は、特定のコンパイラの定めるプラグインのインターフェース仕様や、プラグインにより実行される最適化の内容とは独立したものである。
(第4の実施形態)
本実施形態における構成について説明する。
As is clear from the description of the present embodiment, the effect of the
(Fourth embodiment)
A configuration in the present embodiment will be described.
図13は、本実施形態におけるプログラム変換装置106の構成の一例を示すブロック図である。
FIG. 13 is a block diagram showing an example of the configuration of the
本実施形態におけるライブラリ206は、ヘッダーファイル236と、プラグイン216と、オブジェクトコード226とを含む。
The
ヘッダーファイル236は、プラグイン216の起動を指示する指示文を含まない。
The
本実施形態におけるプログラム変換装置106は、コンパイラである。コンパイラ106は、プラグイン起動手段116と、オプション処理手段126とを含む。
The
オプション処理手段126は、まず、コンパイラ106が起動されるときに指定された実行条件(コマンドラインオプション、環境変数等。以下、「オプション」という。)を解析する。オプション処理手段126は、続いて、実行条件に含まれる、プラグイン216の実行条件を指示するオプションにしたがい、プラグイン起動手段116に、プラグインの実行を指示する。
The option processing means 126 first analyzes an execution condition (command line option, environment variable, etc., hereinafter referred to as “option”) specified when the
その他の構成要素については、第3の実施形態と同じである。 Other components are the same as those in the third embodiment.
次に、本実施形態における動作について説明する。 Next, the operation in this embodiment will be described.
ユーザープログラムの開発者がコンパイラ106を起動するときに、ユーザープログラムの開発者はライブラリ206が提供するプラグイン216を起動するように、オプションを指定する。
When the user program developer activates the
オプション処理手段126は、指定されたオプションにしたがって、ライブラリ206の提供するプラグイン216を起動する。オプションの指定方法は、ライブラリ206に付属の文書等によって説明されることが望ましい。
The
プラグイン起動手段116の動作は、第3の実施形態におけるプラグイン起動手段115動作と同じである。
The operation of the plug-in
なお、ユーザープログラムの開発者が直接コンパイラ106を起動するのではなく、ユーザープログラムの開発者は開発ツール等を介して間接的にコンパイラ106を起動してもよい。
Note that the user program developer does not directly activate the
本実施形態におけるプログラム変換装置106では、第3の実施形態におけるプログラム変換装置105と同様に、ユーザープログラムとライブラリとの間で手続き間最適化が可能である。
In the
本実施形態におけるプログラム変換装置106では、第3の実施形態におけるプログラム変換装置105の効果に加えて、手続き間最適化を行うかどうかを、ユーザープログラムの開発者が指定可能であるという効果がある。本効果により、例えば、ユーザープログラムの開発者は、ユーザープログラムのデバッグ時には、手続き間最適化を行わないという使い方が可能である。
In addition to the effect of the
なお、本実施形態では、ユーザープログラムの開発者がコンパイラの起動時にプラグインの実行条件を指定する場合について説明した。しかしながら、本実施形態におけるプラグインの実行条件は、必ずしもユーザープログラムの開発者により指定される必要はない。本実施形態におけるプラグインの実行条件は、ライブラリのインストール時等に、ライブラリの提供するプラグインが特定のディレクトリに格納されることにより設定されてもよい。つまり、本実施形態におけるコンパイラ106は、特定のディレクトリに保存されたプラグインを自動的に起動してもよい。したがって、特定のディレクトリに保存されたプラグインを自動的に起動する本実施形態におけるプログラム変換装置106では、ユーザープログラムの開発者は、コンパイル時にオプションとして、手続き間最適化の実行条件を指定する必要がないという効果がある。
(第5の実施形態)
本実施形態における構成について説明する。
In the present embodiment, the case where the developer of the user program specifies the plug-in execution condition when starting the compiler has been described. However, the plug-in execution conditions in this embodiment are not necessarily specified by the user program developer. The plug-in execution conditions in the present embodiment may be set by storing a plug-in provided by the library in a specific directory when the library is installed. That is, the
(Fifth embodiment)
A configuration in the present embodiment will be described.
図14は、本実施形態におけるプログラム変換装置107の構成の一例を示すブロック図である。
FIG. 14 is a block diagram showing an example of the configuration of the
本実施形態におけるプログラム変換装置107は、指示文処理手段127と、プラグイン起動手段117と、コンパイラ起動手段137とを含む。ただし、プログラム変換装置107は、コンパイラとしての機能を含まない。
The
指示文処理手段127、プラグイン起動手段117の機能は、それぞれ、第3の実施形態における指示文処理手段125、プラグイン起動手段115の機能と同じである。だだし、プラグイン起動手段117は、最適化後のユーザープログラムを、コンパイラ起動手段137に渡す機能を更に有する。
The functions of the instruction
コンパイラ起動手段137は、最適化後のユーザープログラムを指定して、コンパイラ707を起動する機能を備える。
The
コンパイラ707は、与えられたソースコードをオブジェクトコードに変換する、一般的なコンパイラである。
The
その他の構成要素については、第3の実施形態と同じである。 Other components are the same as those in the third embodiment.
次に、本実施形態における動作について説明する。 Next, the operation in this embodiment will be described.
本実施形態では、ユーザープログラムの開発者は、コンパイラ707ではなく、プログラム変換装置107を起動する。
In this embodiment, the user program developer activates the
プログラム変換装置107は、第2の実施の形態におけるプログラム変換装置105と同様に、ヘッダーファイル237中の指示文257にしたがって、ライブラリ207の提供するプラグイン217を起動する。プラグイン217の実行後、プログラム変換装置107は、プラグイン217によって最適化されたユーザープログラムのソースコード(またはコンパイラが読み込み可能な中間コード)を指定してコンパイラ707を起動する。
The
コンパイラ707は、指定されたソースコードを読み込み、オブジェクトコードに変換する。コンパイラ707は、プラグイン217を起動するための指示文257を処理する指示文処理機能やプラグイン起動機能を有しなくてもよい。
The
プログラム変換装置107のその他の動作は、第3の実施形態におけるプログラム変換装置105の動作と同じである。
Other operations of the
なお、プログラム変換装置107は、コンパイラ707が受け取り可能なオプションを含むオプションを受け取り、コンパイラ起動時に、コンパイラ707が受け取り可能なオプションをコンパイラ707に渡してもよい。
Note that the
本実施形態におけるプログラム変換装置107では、第3の実施形態におけるプログラム変換装置105と同様に、ライブラリとユーザープログラムとの間で手続き間最適化が可能である。
In the
本実施形態におけるプログラム変換装置107では、第3の実施形態におけるプログラム変換装置105の効果に加えて、コンパイラが、プラグイン起動機能、またはプラグインの実行を指示するための指示文を処理する指示文処理機能を有しない場合にも利用可能であるという効果がある。
In the
なお、プログラム変換装置107が、コンパイラが受け取り可能なオプションを含むオプションを受け取り、コンパイラ起動時に、コンパイラが受け取り可能なオプションをコンパイラに渡す場合には、ユーザープログラムの開発者は、コンパイラのオプションと同様なオプションを指定して、プログラム変換装置107を利用することが可能である。
When the
また、本実施形態におけるプログラム変換装置107は、第4の実施形態におけるプログラム変換装置106のように、オプションによってプラグイン起動手段117に対するプラグイン217の起動指示を受けとってもよい。
Further, the
尚、図3、6のプログラム処理装置の各処理は、ソフトウェアによって実行されてもよい。すなわち、各処理を行うためのコンピュータプログラムが、プログラム処理装置が備えるCPU(図2:13)によって読み込まれ、実行されてもよい。プログラムを用いて各処理を行っても、上述の実施形態の処理と同内容の処理を行うことができる。そして、上記のプログラムは、ROM(Read Only Memory)、RAM(Random Access Memory)、フラッシュメモリ等の半導体記憶装置、光ディスク、磁気ディスク、光磁気ディスク等、非一時的な媒体に格納されてもよい。 3 and 6 may be executed by software. That is, a computer program for performing each process may be read and executed by a CPU (FIG. 2:13) provided in the program processing apparatus. Even if each process is performed using a program, the same process as the process of the above-described embodiment can be performed. The above program may be stored in a non-transitory medium such as a ROM (Read Only Memory), a RAM (Random Access Memory), a semiconductor memory device such as a flash memory, an optical disk, a magnetic disk, or a magneto-optical disk. .
あるいは、各処理は、個別の回路等の構成要素によって実行されてもよい。 Alternatively, each process may be executed by a component such as an individual circuit.
尚、本願発明は、上述の実施形態に限定されるものではなく、本願発明の要旨を逸脱しない範囲で種々変更、変形して実施することができる。 In addition, this invention is not limited to the above-mentioned embodiment, It can implement in various changes and deformation | transformation in the range which does not deviate from the summary of this invention.
上記の実施形態の一部または全部は、以下の付記のようにも記載されうるが、以下には限られない。
(付記1)
ライブラリと共に提供される、前記ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、前記呼び出し命令を含むユーザープログラムの第1のコードを取得し、前記特定した前記プラグインの実行を指示するユーザープログラム処理手段と、
前記第1のコードを処理対象に指定して、前記実行を指示された前記プラグインを起動するプラグイン起動手段と、
を備えることを特徴とするプログラム処理装置。
(付記2)
前記ユーザープログラム処理手段は、前記ライブラリと共に提供される、前記手続きに前記プラグインを対応付ける情報を含む前記手続きのリストに基づいて、前記第1のコードを処理すべき、前記プラグインを特定する
ことを特徴とする付記1に記載のプログラム処理装置。
(付記3)
前記ユーザープログラム処理手段は、前記リストに基づいて、前記第1のコードにおいて、前記呼び出し命令を含む第1の部分コードを検索し、前記リストに基づいて前記第1の部分コードを処理すべき、前記プラグインを特定し、前記特定した前記プラグインの実行を指示する
ことを特徴とする付記2に記載のプログラム処理装置。
(付記4)
前記プラグイン起動手段は、前記プラグインを起動する際に、前記プラグインに前記ライブラリに含まれるライブラリプログラムとリンクすることが可能な前記第1のコードを渡す
ことを特徴とする付記1乃至3のいずれか1項に記載のプログラム処理装置。
(付記5)
前記第1のコードは、ソースコード又は前記ソースコードが変換された中間コードである
ことを特徴とする付記1乃至4のいずれか1項に記載のプログラム処理装置。
(付記6)
前記プラグインは、前記呼び出し命令部分の最適化を行った結果である第2のコードを生成する
ことを特徴とする付記1乃至5のいずれか1項に記載のプログラム処理装置。
(付記7)
前記リストは、前記ライブラリが有するヘッダーファイルであり、前記プラグインの実行を指示する指示文を含み、
前記ユーザープログラム処理手段は、前記指示文に従って、前記プラグインの実行を前記プラグイン起動手段に指示する
ことを特徴とする付記1乃至6のいずれか1項に記載のプログラム処理装置。
(付記8)
前記リストは、コマンドラインオプション、環境変数、又はファイルとして前記ユーザープログラム処理手段に与えられる
ことを特徴とする付記1乃至6のいずれか1項に記載のプログラム処理装置。
(付記9)
前記第2のコードに対するコンパイル処理を起動する際に、前記コンパイル処理に前記第2のコードを渡すコンパイラ起動手段を更に備える
ことを特徴とする付記6に記載のプログラム処理装置。
(付記10)
前記プラグインは、単独で実行可能なプログラムである
ことを特徴とする付記1乃至9のいずれか1項に記載のプログラム処理装置。
(付記11)
ライブラリと共に提供される、前記ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、
前記呼び出し命令を含むユーザープログラムの第1のコードを取得し、
前記特定した前記プラグインの実行を指示し、
前記第1のコードを処理対象に指定して、前記実行を指示された前記プラグインを起動する
ことを特徴とするプログラム処理方法。
(付記12)
プログラム処理装置が備えるコンピュータを、
ライブラリと共に提供される、前記ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、前記呼び出し命令を含むユーザープログラムの第1のコードを取得し、前記特定した前記プラグインの実行を指示するユーザープログラム処理手段と、
前記第1のコードを処理対象に指定して、前記実行を指示された前記プラグインを起動するプラグイン起動手段、
として機能させるためのプログラム処理プログラム。
A part or all of the above-described embodiment can be described as in the following supplementary notes, but is not limited thereto.
(Appendix 1)
A plug-in that is an executable program that performs processing on a code including a procedure call instruction included in the library, provided with the library, is identified, a first code of a user program including the call instruction is obtained, and the specification User program processing means for instructing execution of the plug-in,
Plug-in activation means for activating the plug-in instructed to execute by designating the first code as a processing target;
A program processing apparatus comprising:
(Appendix 2)
The user program processing means identifies the plug-in that is to process the first code based on the list of procedures provided with the library and including information associating the plug-in with the procedure. The program processing device according to appendix 1, wherein:
(Appendix 3)
The user program processing means searches the first code based on the list for a first partial code including the calling instruction, and processes the first partial code based on the list; The program processing apparatus according to appendix 2, characterized by specifying the plug-in and instructing execution of the specified plug-in.
(Appendix 4)
The plug-in activation means passes the first code that can be linked to a library program included in the library to the plug-in when the plug-in is activated. The program processing device according to any one of the above.
(Appendix 5)
The program processing apparatus according to any one of appendices 1 to 4, wherein the first code is a source code or an intermediate code obtained by converting the source code.
(Appendix 6)
The program processing apparatus according to any one of appendices 1 to 5, wherein the plug-in generates a second code that is a result of optimization of the call instruction portion.
(Appendix 7)
The list is a header file that the library has, and includes a directive that instructs execution of the plug-in,
7. The program processing apparatus according to claim 1, wherein the user program processing means instructs the plug-in activation means to execute the plug-in according to the instruction text.
(Appendix 8)
The program processing apparatus according to any one of appendices 1 to 6, wherein the list is given to the user program processing means as a command line option, an environment variable, or a file.
(Appendix 9)
The program processing apparatus according to
(Appendix 10)
The program processing apparatus according to any one of appendices 1 to 9, wherein the plug-in is a program that can be executed independently.
(Appendix 11)
Identify a plug-in that is an executable program that is provided with the library and performs processing for code including a procedure call instruction of the library,
Obtaining a first code of a user program including the calling instruction;
Instructing execution of the identified plug-in,
A program processing method comprising: designating the first code as a processing target and activating the plug-in instructed to execute.
(Appendix 12)
A computer provided in the program processing device,
A plug-in that is an executable program that performs processing on a code including a procedure call instruction included in the library, provided with the library, is identified, a first code of a user program including the call instruction is obtained, and the specification User program processing means for instructing execution of the plug-in,
A plug-in activation unit that activates the plug-in instructed to execute by designating the first code as a processing target;
Program processing program to function as.
本発明におけるプログラム処理装置は、例えば、ライブラリ開発者が、ライブラリの処理内容とユーザープログラムの処理内容を用いた手続き間最適化を行うプラグインを開発するために利用可能である。 The program processing apparatus according to the present invention can be used, for example, by a library developer to develop a plug-in that performs interprocedural optimization using the processing contents of a library and the processing contents of a user program.
また、本発明におけるプログラム処理装置は、例えば、行列計算または画像処理等に関する、手続き間最適化が可能なライブラリを提供するために利用可能である。 Further, the program processing apparatus according to the present invention can be used to provide a library capable of interprocedural optimization related to, for example, matrix calculation or image processing.
Claims (10)
前記第1のコードを処理対象に指定して、前記実行を指示された前記プラグインを起動するプラグイン起動手段と、
を備えることを特徴とするプログラム処理装置。 A plug-in that is an executable program that performs processing on a code including a procedure call instruction included in the library, provided with the library, is identified, a first code of a user program including the call instruction is obtained, and the specification User program processing means for instructing execution of the plug-in,
Plug-in activation means for activating the plug-in instructed to execute by designating the first code as a processing target;
A program processing apparatus comprising:
ことを特徴とする請求項1に記載のプログラム処理装置。 The user program processing means identifies the plug-in that is to process the first code based on the list of procedures provided with the library and including information associating the plug-in with the procedure. The program processing apparatus according to claim 1.
ことを特徴とする請求項2に記載のプログラム処理装置。 The user program processing means searches the first code based on the list for a first partial code including the calling instruction, and processes the first partial code based on the list; The program processing apparatus according to claim 2, wherein the plug-in is specified, and execution of the specified plug-in is instructed.
ことを特徴とする請求項1乃至3のいずれか1項に記載のプログラム処理装置。 The plug-in activation means, when activating the plug-in, passes the first code that can be linked to a library program included in the library to the plug-in. 4. The program processing device according to any one of items 3.
ことを特徴とする請求項1乃至4のいずれか1項に記載のプログラム処理装置。 5. The program processing apparatus according to claim 1, wherein the first code is source code or intermediate code obtained by converting the source code. 6.
ことを特徴とする請求項1乃至5のいずれか1項に記載のプログラム処理装置。 The program processing apparatus according to claim 1, wherein the plug-in generates a second code that is a result of optimization of the call instruction part.
前記ユーザープログラム処理手段は、前記指示文に従って、前記プラグインの実行を前記プラグイン起動手段に指示する
ことを特徴とする請求項2又は3に記載のプログラム処理装置。 The list is a header file that the library has, and includes a directive that instructs execution of the plug-in,
4. The program processing apparatus according to claim 2, wherein the user program processing means instructs the plug-in activation means to execute the plug-in according to the instruction text.
ことを特徴とする請求項2、3、又は7に記載のプログラム処理装置。 8. The program processing apparatus according to claim 2, wherein the list is given to the user program processing means as a command line option, an environment variable, or a file.
前記呼び出し命令を含むユーザープログラムの第1のコードを取得し、
前記特定した前記プラグインの実行を指示し、
前記第1のコードを処理対象に指定して、前記実行を指示された前記プラグインを起動する
ことを特徴とするプログラム処理方法。 Identify a plug-in that is an executable program that is provided with the library and performs processing for code including a procedure call instruction of the library,
Obtaining a first code of a user program including the calling instruction;
Instructing execution of the identified plug-in,
A program processing method comprising: designating the first code as a processing target and activating the plug-in instructed to execute.
ライブラリと共に提供される、前記ライブラリが有する手続きの呼び出し命令を含むコードに対する処理を行う実行可能プログラムであるプラグインを特定し、前記呼び出し命令を含むユーザープログラムの第1のコードを取得し、前記特定した前記プラグインの実行を指示するユーザープログラム処理手段と、
前記第1のコードを処理対象に指定して、前記実行を指示された前記プラグインを起動するプラグイン起動手段、
として機能させるためのプログラム処理プログラム。 A computer provided in the program processing device,
A plug-in that is an executable program that performs processing on a code including a procedure call instruction included in the library, provided with the library, is identified, a first code of a user program including the call instruction is obtained, and the specification User program processing means for instructing execution of the plug-in,
A plug-in activation unit that activates the plug-in instructed to execute by designating the first code as a processing target;
Program processing program to function as.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2014019881A JP6326838B2 (en) | 2014-02-05 | 2014-02-05 | Program processing apparatus, program processing method, and program processing program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2014019881A JP6326838B2 (en) | 2014-02-05 | 2014-02-05 | Program processing apparatus, program processing method, and program processing program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2015148856A JP2015148856A (en) | 2015-08-20 |
JP6326838B2 true JP6326838B2 (en) | 2018-05-23 |
Family
ID=53892189
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2014019881A Active JP6326838B2 (en) | 2014-02-05 | 2014-02-05 | Program processing apparatus, program processing method, and program processing program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6326838B2 (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106569869B (en) * | 2016-11-14 | 2019-04-19 | 平安科技(深圳)有限公司 | Plug-in unit packaging method and device |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2010072852A (en) * | 2008-09-17 | 2010-04-02 | Nec Corp | Structure analyzing device, structure analyzing method, and structure analyzing program |
JP5556480B2 (en) * | 2010-07-29 | 2014-07-23 | 富士通株式会社 | Context Violation Detection Support Method, Context Violation Detection Support Device, and Context Violation Detection Support Program |
-
2014
- 2014-02-05 JP JP2014019881A patent/JP6326838B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2015148856A (en) | 2015-08-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7725883B1 (en) | Program interpreter | |
US8726255B2 (en) | Recompiling with generic to specific replacement | |
US7657878B2 (en) | Compiler, method of compiling and program development tool | |
US9552193B2 (en) | Automated compiler specialization for global optimization | |
EP3244306B1 (en) | A computer-implemented method for allowing modification of a region of original code | |
US10269087B2 (en) | Language translation using preprocessor macros | |
US7823144B2 (en) | Computer program code comparison using lexemes | |
US20180101370A1 (en) | Selective generation of multiple versions of machine code for source code functions for execution on different processor versions and/or architectures | |
US7917899B2 (en) | Program development apparatus, method for developing a program, and a computer program product for executing an application for a program development apparatus | |
JP2010079894A (en) | Reducing trace overhead by modifying trace operation | |
US20180203676A1 (en) | Removing library objects from a static library | |
US8930925B2 (en) | Method for enabling compilation of a Cobol source program utilizing a two-stage compilation process, the Cobol source program including a mix of Cobol, C++ or JAVA statements, and optional OpenMP directives | |
Ilyushin et al. | On source-to-source compilers | |
JP2008276735A (en) | Program code converter and program code conversion method | |
Birken | Building code generators for DSLs using a partial evaluator for the Xtend language | |
Sathyanathan et al. | Incremental whole program optimization and compilation | |
JP6326838B2 (en) | Program processing apparatus, program processing method, and program processing program | |
CN110674474B (en) | Operation control method and device for application program | |
JP2008305337A (en) | Program converter, program conversion method, program, storage medium, debugging device, debugging method and program development system | |
Chang et al. | Analysis of low-level code using cooperating decompilers | |
JP2007226589A (en) | Program conversion system | |
Paltoglou et al. | Automated refactoring of client-side JavaScript code to ES6 modules | |
Acosta et al. | Paralldroid: Performance analysis of gpu executions | |
JP2009258796A (en) | Program development device and program development method | |
Reis et al. | SSA-based MATLAB-to-C Compilation and Optimization |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20170116 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20171025 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20171114 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20171206 |
|
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: 20180320 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20180402 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6326838 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |