JP6326838B2 - Program processing apparatus, program processing method, and program processing program - Google Patents

Program processing apparatus, program processing method, and program processing program Download PDF

Info

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
Application number
JP2014019881A
Other languages
Japanese (ja)
Other versions
JP2015148856A (en
Inventor
一久 石坂
一久 石坂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP2014019881A priority Critical patent/JP6326838B2/en
Publication of JP2015148856A publication Critical patent/JP2015148856A/en
Application granted granted Critical
Publication of JP6326838B2 publication Critical patent/JP6326838B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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 multiplication result 6. Optimize to

通常、コンパイラはソースコードを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.

特開2000−10791号公報(第4−6ページ、図1、10)JP 2000-10791 A (page 4-6, FIGS. 1 and 10)

特許文献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の実施形態におけるプログラム処理装置の構成の一例を示すブロック図である。It is a block diagram which shows an example of a structure of the program processing apparatus in the 1st Embodiment of this invention. 本発明の第1の実施形態におけるプログラム処理装置が具体的な装置である場合のハードウェア構成の一例を示すブロック図である。It is a block diagram which shows an example of a hardware configuration in case the program processing apparatus in the 1st Embodiment of this invention is a specific apparatus. 本発明の第1の実施形態におけるプログラム処理装置のユーザープログラム処理手段の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the user program processing means of the program processing apparatus in the 1st Embodiment of this invention. 本発明の第1の実施形態におけるプログラム処理装置の処理手順の具体例を説明するための図である。It is a figure for demonstrating the specific example of the process sequence of the program processing apparatus in the 1st Embodiment of this invention. 本発明の第2の実施形態におけるプログラム処理装置の構成の一例を示すブロック図である。It is a block diagram which shows an example of a structure of the program processing apparatus in the 2nd Embodiment of this invention. 本発明の第2の実施形態におけるプログラム処理装置のユーザープログラム処理手段の動作を示すフローチャートである。It is a flowchart which shows operation | movement of the user program processing means of the program processing apparatus in the 2nd Embodiment of this invention. 本発明の第2の実施形態におけるプログラム処理装置の処理手順の具体例を説明するための図である。It is a figure for demonstrating the specific example of the process sequence of the program processing apparatus in the 2nd Embodiment of this invention. 本発明の第3の実施形態におけるプログラム処理装置の構成の一例を示すブロック図である。It is a block diagram which shows an example of a structure of the program processing apparatus in the 3rd Embodiment of this invention. 本発明の第3の実施形態におけるプログラム処理装置の動作を示す図である。It is a figure which shows operation | movement of the program processing apparatus in the 3rd Embodiment of this invention. 本発明の第3の実施形態におけるプログラム処理装置の処理手順の具体例を説明するための図である。It is a figure for demonstrating the specific example of the process sequence of the program processing apparatus in the 3rd Embodiment of this invention. 本発明の第3の実施形態におけるプログラム処理装置の処理手順の別の具体例におけるユーザープログラムとライブラリプログラムを説明するための図である。It is a figure for demonstrating the user program and library program in another specific example of the process sequence of the program processing apparatus in the 3rd Embodiment of this invention. 本発明の第3の実施形態におけるプログラム処理装置の処理手順の別の具体例における最適化されないプログラムと最適化されたプログラムを説明するための図である。It is a figure for demonstrating the non-optimized program and the optimized program in another specific example of the process sequence of the program processing apparatus in the 3rd Embodiment of this invention. 本発明の第4の実施形態におけるプログラム処理装置の構成の一例を示すブロック図である。It is a block diagram which shows an example of a structure of the program processing apparatus in the 4th Embodiment of this invention. 本発明の第5の実施形態におけるプログラム処理装置の構成の一例を示すブロック図である。It is a block diagram which shows an example of a structure of the program processing apparatus in the 5th Embodiment of this invention. 手続き間最適化の具体例を説明するための図である。It is a figure for demonstrating the specific example of interprocedural optimization. 手続き間最適化の問題点を説明するための図である。It is a figure for demonstrating the problem of interprocedural optimization.

以下、本発明の実施形態について図面を参照して詳細に説明する。尚、すべての図面において、同等の構成要素には同じ符号を付し、適宜説明を省略する。
(第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 program processing apparatus 100 in the present embodiment.

本実施形態におけるプログラム処理装置100は、ライブラリ200を利用する。   The program processing apparatus 100 in this embodiment uses a library 200.

ライブラリ200は、手続きコード220と、プラグイン210とを含む。   The library 200 includes a procedure code 220 and a plug-in 210.

ライブラリ200は、ヘッダーファイル230を更に含んでもよい。手続きコード220は、ライブラリ200が提供する手続き(関数等。以下、「ライブラリ手続き」という。)のコードである。ライブラリ手続きのコードは、例えば、オブジェクトコードまたはソースコードである。   The library 200 may further include a header file 230. The procedure code 220 is a code of a procedure (function or the like; hereinafter referred to as “library procedure”) provided by the library 200. The code of the library procedure is, for example, object code or source code.

ヘッダーファイル230は、ライブラリ手続きや外部変数の型宣言等を含むファイルである。   The header file 230 is a file including a library procedure and a type declaration of an external variable.

プラグイン210は、特定のインターフェース仕様にしたがった記述された、プログラム処理装置100から起動可能なプログラムである。プラグイン210は、例えば、単独で実行可能なプログラムや、プログラムに動的リンクされて呼び出されるダイナミックリンクライブラリである。プラグイン210は、特定の形態をもつものには限定されず、プログラム処理装置100から起動可能な、ライブラリ手続きを呼び出すユーザープログラムのコードに対する処理を行う任意のプログラムである。   The plug-in 210 is a program that can be started from the program processing apparatus 100 and is written according to a specific interface specification. The plug-in 210 is, for example, a program that can be executed alone or a dynamic link library that is called after being dynamically linked to the program. The plug-in 210 is not limited to one having a specific form, and is an arbitrary program that performs processing on a user program code that can be activated from the program processing apparatus 100 and calls a library procedure.

プログラム処理装置100は、ライブラリ手続きを呼び出す、ソースコード、またはソースコードが変換された中間コード(以下では、簡単のためにソースコードおよび中間コードを「ソースコード」と総称する)を指定して、プラグイン210を起動する。プラグイン210は、プログラム処理装置100から渡されたソースコードに対して所定の処理を行う。プラグイン210が実行する所定の処理は、ソースコードに対する、変換、最適化、検証等の処理を含むが、それらには限定されない任意の処理である。プラグイン210は、処理の結果をプログラム処理装置100に返してもよい。   The program processing apparatus 100 designates a source code that calls a library procedure, or an intermediate code converted from the source code (hereinafter, the source code and the intermediate code are collectively referred to as “source code” for the sake of simplicity) The plug-in 210 is activated. The plug-in 210 performs predetermined processing on the source code passed from the program processing apparatus 100. The predetermined processing executed by the plug-in 210 includes arbitrary processing including, but not limited to, conversion, optimization, verification, and the like for the source code. The plug-in 210 may return the processing result to the program processing apparatus 100.

プラグイン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 program processing apparatus 100 according to the present embodiment is, for example, a compiler, a compiler component, or a single tool, that is, a program that performs a predetermined conversion process. Alternatively, the program processing apparatus 100 may be an apparatus such as a computer that performs conversion processing including compilation. In the present embodiment, the function realized by the program processing apparatus 100 is characterized, and it is not an essential problem whether the program processing apparatus 100 is an intangible program or a tangible apparatus.

プログラム処理装置100は、特定の種類のツールに限定されない。プログラム処理装置100は、ユーザープログラム処理手段120と、プラグイン起動手段110とを含む。   The program processing apparatus 100 is not limited to a specific type of tool. The program processing apparatus 100 includes user program processing means 120 and plug-in activation means 110.

ユーザープログラム処理手段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 program processing unit 120 instructs the plug-in activation unit 110 to activate the plug-in 210 corresponding to the library procedure based on the name of the loaded plug-in 210 with respect to the loaded source code.

プラグイン起動手段110は、指定されたプラグイン210にユーザープログラムのソースコードを渡し、プラグイン210を起動する。   The plug-in activation unit 110 passes the source code of the user program to the designated plug-in 210 and activates the plug-in 210.

図2は、本実施形態におけるプログラム処理装置100が具体的な装置である場合のハードウェア構成の一例を示すブロック図である。   FIG. 2 is a block diagram illustrating an example of a hardware configuration when the program processing apparatus 100 according to the present embodiment is a specific apparatus.

プログラム処理装置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 storage device 12, a CPU (Central Processing Unit) 13, a keyboard 14, a monitor 15, and an I / O (Input / Output) 18, which are connected via an internal bus 16. Yes. The storage device 12 stores an operation program for the CPU 13 such as the plug-in activation unit 110. The CPU 13 controls the entire program processing device 11, executes an operation program stored in the storage device 12, and executes programs such as the plug-in activation means 110 and transmits / receives data via the I / O 18. The internal configuration of the program processing apparatus 11 is an example. The program processing apparatus 11 includes only the CPU 13, the storage device 12, and the I / O 18, and may operate using a keyboard 14 and a monitor 15 that are provided outside.

次に、本実施形態における動作について説明する。   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 program processing apparatus 100 in the present embodiment.

ユーザープログラム処理手段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 program processing apparatus 100 in the present embodiment.

図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 program processing apparatus 100 in this embodiment. FIG. 4C shows the source code (“library_source.c”: “library program C”), which is the procedure code 220 of the library 200 in this embodiment, and FIG. An error message that is an execution result of the plug-in 210 is shown.

まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。   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 library 200 is an executable program that reads the user program A, checks the normality of the argument of the library procedure call code in the user program A, and outputs an error message if there is an abnormality.

「div」は、ライブラリ200が提供する手続きコード220に含まれる手続き名である。ライブラリ手続き「div」は、整数である第1引数を、整数である第2引数で除算する関数である。「arg-verification」は、ライブラリ200が提供するプラグイン210のファイル名である。プラグイン「arg-verification」は、ライブラリ200のライブラリ手続きを呼び出すコードの引数の正常性を確認する。   “Div” is a procedure name included in the procedure code 220 provided by the library 200. The library procedure “div” is a function that divides a first argument that is an integer by a second argument that is an integer. “Arg-verification” is the file name of the plug-in 210 provided by the library 200. The plug-in “arg-verification” confirms the normality of the argument of the code that calls the library procedure of the library 200.

なお、上述のライブラリ手続きとプラグインの機能との対応関係は一例であり、これに限定されない。特定のライブラリに対して、そのライブラリ手続きを呼び出すコードに対する付加処理を行うプラグインが特定されればよい。例えば、ライブラリ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 library 200, one plug-in “arg-verification” performs individual processing that is not limited to checking the normality of an argument according to each library procedure. May be executed.

ユーザープログラム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 program processing apparatus 100, and acquires the argument of the “-plugin” option in the command line, thereby determining the name of the plug-in 210. Obtain (step S11). The user program processing unit 120 stores that the plug-in “arg-verification” is a plug-in of the library 200.

ユーザープログラム処理手段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 activation unit 110 passes the source code of the user program A to the designated plug-in “arg-verification” and activates the plug-in “arg-verification”.

プラグイン「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 program processing apparatus 100 according to the present embodiment passes the source code of the user program including the library procedure call code of the library 200 to the plug-in 210 specified by the command line when the program processing apparatus 100 is activated. Then, the plug-in 210 is activated. That is, the plug-in 210 can process the library procedure call code in the user program by using information on the processing contents of the library procedure. Therefore, the program processing apparatus 100 according to the present embodiment has an effect that the library can provide an additional process depending on the processing content of each procedure in the library for the library procedure call code in the user program. .

なお、本実施形態では、プラグインの名称がプログラム処理装置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 program processing apparatus 100 has been described. However, the name of the plug-in in this embodiment does not necessarily have to be specified in the command line. The name of the plug-in in this embodiment may be specified in an information source (a file, a file under a specific folder, an environment variable, etc.) other than the command line. When the name of the plug-in is described in an information source different from the command line, the program processing apparatus 100 may acquire the name of the plug-in from another information source.
(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 library 204.

ライブラリ204は、手続きコード220と、手続きリスト234と、プラグイン210とを含む。   The library 204 includes a procedure code 220, a procedure list 234, and a plug-in 210.

手続きリスト234は、ライブラリ手続きのリストである。手続きリスト234は、ライブラリ手続きに関する付加処理を行うプラグイン210を特定する情報を更に含む。特定のライブラリ手続きに対して特定のプラグインが対応する場合には、手続きリスト234は、特定のライブラリ手続きに対して特定のプラグインを対応付ける情報を更に含んでもよい。手続きリスト234は、例えば、ライブラリのヘッダーファイルである。しかしながら、手続きリスト234はライブラリのヘッダーファイルに限定されない。手続きリスト234は、ライブラリ手続き、及びライブラリ手続きに対するプラグイン、を特定する情報を保持する任意の情報源(ファイル、特定フォルダ配下のファイル、コマンドラインオプション、環境変数等)であってよい。なお、手続きリスト234の内容は、複数の情報源(ファイル、特定フォルダ配下のファイル、コマンドラインオプション、環境変数等)に分散されて保持されてもよい。   The procedure list 234 is a list of library procedures. The procedure list 234 further includes information for specifying the plug-in 210 that performs the additional processing related to the library procedure. When a specific plug-in corresponds to a specific library procedure, the procedure list 234 may further include information associating the specific plug-in with a specific library procedure. The procedure list 234 is, for example, a library header file. However, the procedure list 234 is not limited to the library header file. The procedure list 234 may be an arbitrary information source (file, file under a specific folder, command line option, environment variable, etc.) that holds information for specifying a library procedure and a plug-in for the library procedure. The contents of the procedure list 234 may be distributed and held in a plurality of information sources (files, files under a specific folder, command line options, environment variables, etc.).

プログラム処理装置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 procedure list 234 and the source code of the user program, and searches for a code including a library procedure call in the user program. The user program processing unit 124 activates the plug-in 210 corresponding to the library procedure based on the information of the plug-in 210 in the read procedure list 234 for the unprocessed code including the library procedure call. Instructs the plug-in activation means 110.

その他の構成要素については、第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 program processing unit 124 reads the procedure list 234 of the library 204 (step S21).

ユーザープログラム処理手段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 program processing unit 124 ends the process.

ユーザープログラム中のライブラリ手続き呼び出しを含む未処理のコードを発見すると(ステップ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 read procedure list 234. The plug-in activation means 110 is instructed to activate the plug-in 210 corresponding to (step S24).

次に、本実施形態における処理手順の具体例について説明する。   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 procedure list 234 of the library 204 in this embodiment. The source code of the header file (“library_header.h”: “header file B”) is shown in FIG. 7C. The source code (“library_source.c”: below) is the procedure code 220 of the library 204 in this embodiment. , “Library program C”), FIG. 7D shows an error message that is an execution result of the plug-in 210 in this embodiment.

まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。   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 library 204 is an executable program that reads the user program A, checks the normality of the argument of the library procedure call code in the user program A, and outputs an error message if there is an abnormality.

ライブラリ204が提供するヘッダーファイルB中には、手続きリスト234として、以下が記述されている。   In the header file B provided by the library 204, the following is described as the procedure list 234.

#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 procedure code 220 provided by the library 204. The library procedure “div” is a function that divides a first argument that is an integer by a second argument that is an integer. “Div-verification” is the file name of the plug-in 210 provided by the library 204. The above description indicates that the plug-in “div-verification” corresponds to the library procedure “div”. The plug-in “div-verification” confirms the normality of the argument of the corresponding library procedure “div”.

なお、上述のライブラリ手続きとプラグインとの対応付けは一例であり、これに限定されない。特定のライブラリ手続きに対して、その手続きの処理を行うプラグインが特定されればよい。例えば、ヘッダーファイル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 procedure list 234 of the library 204 by processing the include directives in the user program A (step S21). When the user program processing means 124 reads the header file B of the library 204, the user program processing means 124 finds the “#pragma plugin” directive in the header file B, and the plug-in “div-verification” corresponds to the library procedure “div”. Remember.

ユーザープログラム処理手段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 program processing unit 124 uses the plug-in “div-verification corresponding to the library procedure“ div ”. "Is started to the plug-in starting means 110 (step S24). When one plug-in is associated with all the library procedures declared in the header file B, one plug-in may execute individual processing corresponding to each library procedure. Good.

プラグイン起動手段110は、指定されたプラグイン「div-verification」にユーザープログラムAのソースコードを渡し、プラグイン「div-verification」を起動する。   The plug-in activation unit 110 passes the source code of the user program A to the designated plug-in “div-verification”, and activates the plug-in “div-verification”.

プラグイン「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 library 204 exists in the user program, the program processing apparatus 104 according to the present embodiment stores the user program in the plug-in 210 associated with the library procedure in the procedure list 234. And the plug-in 210 is activated. That is, the plug-in 210 can process the source code of the user program by using information regarding the processing contents of the library procedure. Therefore, the program processing apparatus 104 according to the present embodiment has an effect that the library can provide an additional process depending on the processing content of each procedure in the library for the library procedure call code in the user program. .

なお、本実施形態では、手続きリストがライブラリの提供するヘッダーファイル中に記述されている場合について説明した。しかしながら、本実施形態における手続きリストは、必ずしもヘッダーファイル中に記述されている必要はない。本実施形態における手続きリストは、ヘッダーファイルとは別の情報源(ファイル、特定フォルダ配下のファイル、コマンドラインオプション、環境変数等)に記述されてもよい。手続きリストがヘッダーファイルとは別の情報源に記述されている場合には、プログラム処理装置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 program conversion apparatus 105 in the present embodiment.

本実施形態におけるプログラム変換装置105は、ライブラリ205を利用する。   The program conversion apparatus 105 in this embodiment uses a library 205.

ライブラリ205は、オブジェクトコード225と、ヘッダーファイル235と、プラグイン215とを含む。   The library 205 includes an object code 225, a header file 235, and a plug-in 215.

ヘッダーファイル235は、プラグイン215の起動を指示する指示文255を含む。   The header file 235 includes an instruction sentence 255 that instructs activation of the plug-in 215.

プラグイン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 optimization unit 245 optimizes the library procedure call code in the source code by using the passed source code information and information on the processing contents of the library.

指示文255は、ライブラリプログラム中に記述された、コンパイラへ指示を与える文である。ヘッダーファイル235中の指示文255は、コンパイラに対して、ライブラリ205が提供するプラグイン215を起動することを指示する。   The instruction sentence 255 is a sentence for giving an instruction to the compiler described in the library program. The directive 255 in the header file 235 instructs the compiler to start the plug-in 215 provided by the library 205.

本実施形態におけるプログラム変換装置105は、例えば、コンパイラ、コンパイラのコンポーネント、または単独のツール、すなわち所定の変換処理を行うプログラムである。あるいは、プログラム変換装置105は、コンパイルを含む変換処理を行うコンピュータ等の装置であってもよい。本実施形態においては、プログラム変換装置105が実現する機能に特徴があるのであって、無形のプログラムであるか、有形の装置であるかは本質的問題ではない。   The program conversion apparatus 105 in this embodiment is, for example, a compiler, a component of a compiler, or a single tool, that is, a program that performs a predetermined conversion process. Alternatively, the program conversion apparatus 105 may be an apparatus such as a computer that performs conversion processing including compilation. In the present embodiment, the function realized by the program conversion apparatus 105 is characterized, and it is not an essential problem whether it is an intangible program or a tangible apparatus.

プログラム変換装置105は、指示文処理手段125と、プラグイン起動手段115とを含む。プログラム変換装置105は、その他のコンパイラの一般的な構成要素を更に含んでもよい。   The program conversion apparatus 105 includes an instruction sentence processing unit 125 and a plug-in activation unit 115. The program conversion apparatus 105 may further include general components of other compilers.

指示文処理手段125は、ソースコード(例えば、ヘッダーファイル235)中の指示文(例えば、指示文255)を読み込み、指示文で指定される処理を行う。指示文は、例えば、C言語のインクルード指示文である。指示文処理手段125は、一般的なコンパイラが有する指示文を処理する機能を有してもよい。指示文処理手段125は、プラグイン215の起動を指示する指示文255を読み込み、指示文255で指定されたプラグイン215を起動するように、プラグイン起動手段115に指示する。指示文処理手段125は、その他の指示文を処理する機能を有してもよい。   The instruction sentence processing unit 125 reads an instruction sentence (for example, the instruction sentence 255) in the source code (for example, the header file 235), and performs processing specified by the instruction sentence. The directive is, for example, a C language include directive. The instruction sentence processing unit 125 may have a function of processing an instruction sentence included in a general compiler. The instruction sentence processing unit 125 reads the instruction sentence 255 instructing activation of the plug-in 215 and instructs the plug-in activation unit 115 to activate the plug-in 215 specified by the instruction sentence 255. The instruction sentence processing unit 125 may have a function of processing other instruction sentences.

プラグイン起動手段115は、指定されたプラグイン215にソースコードを渡し、プラグイン215を起動する。プラグイン起動手段115は、プラグイン215から返却される最適化された、ソースコードまたは中間コードを受け取る。プラグイン起動手段115は、ソースコードに加えて、コンパイラが解析した情報(例えば、変数の依存関係に関する情報)をプラグイン215に渡してもよい。   The plug-in activation unit 115 passes the source code to the designated plug-in 215 and activates the plug-in 215. The plug-in activation unit 115 receives the optimized source code or intermediate code returned from the plug-in 215. In addition to the source code, the plug-in activation unit 115 may pass information analyzed by the compiler (for example, information related to variable dependency) to the plug-in 215.

なお、コンパイラは、一般にソースコードをオブジェクトコードに変換するプログラムを指すが、ソースコードを別のソースコードに変換するプログラムをコンパイラと呼ぶこともある。ソースコードを別のソースコードに変換するプログラムは、ソースツーソースコンパイラまたはプリプロセッサと呼ばれることがある。プログラム変換装置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 program conversion apparatus 105 may be a source-to-source compiler.

次に、本実施形態における動作について説明する。   Next, the operation in this embodiment will be described.

図9は、本実施形態におけるプログラム変換装置105の動作を説明するための図である。   FIG. 9 is a diagram for explaining the operation of the program conversion apparatus 105 in the present embodiment.

本実施形態におけるユーザープログラム305のソースコードは、ライブラリ205を利用するために、ライブラリ205が提供するヘッダーファイル235をインクルードする。「インクルードする」とは、例えば、プログラム中のインクルード指示文によって、ライブラリ205のヘッダーファイル235があたかもユーザープログラム305のソースコード中に含まれるかのように、プログラム変換装置105により取り扱われることである。   In order to use the library 205, the source code of the user program 305 in this embodiment includes the header file 235 provided by the library 205. “Include” means that, for example, the header file 235 of the library 205 is handled by the program conversion apparatus 105 as if included in the source code of the user program 305 by an include directive in the program. .

プログラム変換装置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 program conversion apparatus 105 first processes the include instruction sentence in the user program 305. The instruction processing unit 125 reads the header file 235 of the library 205. Next, the instruction sentence processing unit 125 processes the instruction sentence 255 in the read header file 235. As described above, in the header file 235, the instruction statement 255 for instructing activation of the plug-in 215 is described. The instruction sentence processing unit 125 instructs the plug-in activation unit 115 to activate the plug-in 215 specified by the instruction sentence 255 as processing for the instruction sentence 255.

プラグイン起動手段115は、コンパイラ(プログラム変換装置105)のプラグイン仕様にしたがって、プラグイン215を起動する。   The plug-in activation unit 115 activates the plug-in 215 in accordance with the plug-in specification of the compiler (program conversion device 105).

プログラム変換装置105は、プラグイン215から返却されたソースコード(または中間コード)を用いて、コンパイラとしての処理を継続する。プログラム変換装置105は、オブジェクトコード405を生成し、生成したオブジェクトコード405と、ライブラリ205が提供するオブジェクトコード225とをリンクし、実行プログラム605を生成する。   The program conversion apparatus 105 continues processing as a compiler using the source code (or intermediate code) returned from the plug-in 215. The program conversion apparatus 105 generates an object code 405, links the generated object code 405 and the object code 225 provided by the library 205, and generates an execution program 605.

次に、本実施形態における処理手順の具体例について説明する。   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 program conversion apparatus 105 in the present embodiment.

図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 user program 305 in this embodiment, and FIG. 10B shows the header file 235 of the library 205 in this embodiment. The source code (“library_header.h”: “header file F”) is shown in FIG. 10C, and the source code of the library 205 (“library_source.c”: “library program G”) in this embodiment is shown in FIG. FIG. 10D shows a source code (not shown; hereinafter referred to as “program H”) of a program in which the user program E in the present embodiment is optimized.

まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。   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 library 205 is an executable program that reads the user program E and outputs an optimized program H.

ライブラリ205が提供するヘッダーファイルF中には、プラグイン215の実行を指示する指示文255として、以下が記述されている。   In the header file F provided by the library 205, the following is described as an instruction statement 255 for instructing execution of the plug-in 215.

#pragma plugin mulexpanshion
「mulexpansion」は、ライブラリ205が提供するプラグイン215のファイル名である。
#pragma plugin mulexpanshion
“Mulexpansion” is the file name of the plug-in 215 provided by the library 205.

以上が、以下の処理手順における前提である。次に、処理手順について説明する。   The above is the premise in the following processing procedure. Next, the processing procedure will be described.

指示文処理手段125は、ユーザープログラムEを読み込み、ユーザープログラムE中のインクルード指示文を処理することにより、ライブラリ205のヘッダーファイルFを読み込む。   The instruction sentence processing unit 125 reads the header file F of the library 205 by reading the user program E and processing the include instruction sentence in the user program E.

指示文処理手段125は、ライブラリ205のヘッダーファイルFを読み込むと、ヘッダーファイルF中の「#pragma plugin」指示文を見つける。指示文処理手段125は、「#pragma plugin」指示文を見つけると、プラグイン起動手段115にプラグイン215(mulexpansion)を起動するように指示する。   When reading the header file F of the library 205, the directive processing means 125 finds the “#pragma plugin” directive in the header file F. When the instruction text processing unit 125 finds the “#pragma plugin” directive, it instructs the plug-in activation unit 115 to activate the plug-in 215 (mulexpansion).

プラグイン起動手段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 program conversion apparatus 105 continues the compilation process using “tmp.c” output by the plug-in mulexpansion.

なお、プログラム変換装置105は、プラグイン215を連続的に起動する場合には、後続のプラグイン215の起動では、先行するプラグイン215の出力ファイル(プログラムH)を更に渡してもよい。   When the plug-in 215 is continuously activated, the program conversion apparatus 105 may further pass the output file (program H) of the preceding plug-in 215 when the subsequent plug-in 215 is activated.

プラグイン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 program conversion apparatus 105 generates the object code 405 for generating the execution program 605 that speeds up the execution of the program as compared with the case where the optimization is not performed by reducing the calculation amount.

一方、ライブラリの提供するプラグインを用いることなくコンパイラが最適化を行う場合には、ライブラリはオブジェクトコードで提供されるため、コンパイラがライブラリ関数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 program processing apparatus 105 in the present embodiment.

図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 program conversion apparatus 105 in the present embodiment.

図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 library 205 in this embodiment (hereinafter referred to as “library program K”). ).

まず、本実施形態における処理手順の具体例を説明するにあたっての前提について説明する。   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 library 205 provides a matrix operation function. The library 205 is a C ++ class library and provides a matrix class Mat.

図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 library 205 in the present embodiment. In the library program K, three operators “+”, “−”, and “=” of the matrix class are defined. Note that the program examples of the user program J and library program K schematically show the processing contents.

ユーザープログラム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 program conversion apparatus 105 converts the user program J, the plug-in 215 is provided by the developer of the library program K, so that the plug-in 215 can use information on the processing contents of the library function. Therefore, the plug-in 215 can convert the calculation “A = B + C−D” into one iteration process, as shown in FIG. Further, in the optimized program M, a temporary matrix is not necessary for execution of the calculation for the expression “A = B + C−D”. The optimized program M can reduce the calculation time and the amount of memory used compared to the non-optimized program L.

以上説明したように、本実施形態におけるプログラム変換装置105は、ライブラリが提供するヘッダーファイル中で、ライブラリが提供するプラグインの起動が指示されると、プラグインを起動する。つまり、プログラム変換装置105は、ライブラリを利用するユーザープログラムを変更することなく、プラグインを起動することができる。プラグインにはユーザープログラムのソースコード(またはソースコードに対応する中間コード)が渡されるため、プラグインはソースコードを解析してユーザープログラムに関する情報を得ることができる。プラグインはライブラリ提供者によって作成されるため、ライブラリ提供者はライブラリの処理内容に関する情報を利用して、プラグインを作成することができる。つまり、プラグインは、ユーザープログラムおよびライブラリの情報を利用して手続き間最適化を行うことが可能である。したがって、本実施形態におけるプログラム変換装置105では、ライブラリとユーザープログラムとの間で手続き間最適化を行うことが可能であるという効果がある。   As described above, the program conversion apparatus 105 according to the present embodiment activates a plug-in when an instruction to activate the plug-in provided by the library is given in the header file provided by the library. That is, the program conversion apparatus 105 can activate the plug-in without changing the user program that uses the library. Since the source code of the user program (or intermediate code corresponding to the source code) is passed to the plug-in, the plug-in can analyze the source code to obtain information on the user program. Since the plug-in is created by the library provider, the library provider can create a plug-in using information on the processing contents of the library. That is, the plug-in can perform interprocedural optimization by using the user program and library information. Therefore, the program conversion apparatus 105 according to the present embodiment has an effect that interprocedural optimization can be performed between the library and the user program.

なお、本実施形態では、プラグインを起動する指示文がライブラリの提供するヘッダーファイル中に記述されている場合について説明した。しかしながら、本実施形態における指示文は、必ずしもヘッダーファイル中に記述されている必要はない。本実施形態における指示文は、ユーザープログラム中に記述されてもよい。指示文がユーザープログラム中に記述されている場合には、ユーザープログラムの開発者がユーザープログラムを書き換える必要があるが、プラグインを起動するかどうかをユーザープログラムの開発者が制御することができるという効果がある。   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 program conversion apparatus 105 in this embodiment is independent of the plug-in interface specifications determined by a specific compiler and the contents of optimization executed by the plug-in. It is.
(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 program conversion apparatus 106 in the present embodiment.

本実施形態におけるライブラリ206は、ヘッダーファイル236と、プラグイン216と、オブジェクトコード226とを含む。   The library 206 in the present embodiment includes a header file 236, a plug-in 216, and an object code 226.

ヘッダーファイル236は、プラグイン216の起動を指示する指示文を含まない。   The header file 236 does not include an instruction sentence for instructing activation of the plug-in 216.

本実施形態におけるプログラム変換装置106は、コンパイラである。コンパイラ106は、プラグイン起動手段116と、オプション処理手段126とを含む。   The program conversion apparatus 106 in this embodiment is a compiler. The compiler 106 includes a plug-in activation unit 116 and an option processing unit 126.

オプション処理手段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 compiler 106 is started. The option processing unit 126 then instructs the plug-in activation unit 116 to execute the plug-in according to the option that indicates the execution condition of the plug-in 216 included in the execution condition.

その他の構成要素については、第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 compiler 106, the user program developer specifies an option to activate the plug-in 216 provided by the library 206.

オプション処理手段126は、指定されたオプションにしたがって、ライブラリ206の提供するプラグイン216を起動する。オプションの指定方法は、ライブラリ206に付属の文書等によって説明されることが望ましい。   The option processing unit 126 activates the plug-in 216 provided by the library 206 according to the specified option. The option designation method is preferably explained by a document attached to the library 206.

プラグイン起動手段116の動作は、第3の実施形態におけるプラグイン起動手段115動作と同じである。   The operation of the plug-in activation unit 116 is the same as the operation of the plug-in activation unit 115 in the third embodiment.

なお、ユーザープログラムの開発者が直接コンパイラ106を起動するのではなく、ユーザープログラムの開発者は開発ツール等を介して間接的にコンパイラ106を起動してもよい。   Note that the user program developer does not directly activate the compiler 106, but the user program developer may indirectly activate the compiler 106 via a development tool or the like.

本実施形態におけるプログラム変換装置106では、第3の実施形態におけるプログラム変換装置105と同様に、ユーザープログラムとライブラリとの間で手続き間最適化が可能である。   In the program conversion apparatus 106 according to the present embodiment, interprocedural optimization can be performed between the user program and the library, similarly to the program conversion apparatus 105 according to the third embodiment.

本実施形態におけるプログラム変換装置106では、第3の実施形態におけるプログラム変換装置105の効果に加えて、手続き間最適化を行うかどうかを、ユーザープログラムの開発者が指定可能であるという効果がある。本効果により、例えば、ユーザープログラムの開発者は、ユーザープログラムのデバッグ時には、手続き間最適化を行わないという使い方が可能である。   In addition to the effect of the program conversion apparatus 105 in the third embodiment, the program conversion apparatus 106 in the present embodiment has an effect that the user program developer can specify whether or not to perform interprocedural optimization. . With this effect, for example, a developer of a user program can use the program so that interprocedural optimization is not performed when debugging the user program.

なお、本実施形態では、ユーザープログラムの開発者がコンパイラの起動時にプラグインの実行条件を指定する場合について説明した。しかしながら、本実施形態におけるプラグインの実行条件は、必ずしもユーザープログラムの開発者により指定される必要はない。本実施形態におけるプラグインの実行条件は、ライブラリのインストール時等に、ライブラリの提供するプラグインが特定のディレクトリに格納されることにより設定されてもよい。つまり、本実施形態におけるコンパイラ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 compiler 106 according to the present embodiment may automatically start a plug-in stored in a specific directory. Therefore, in the program conversion apparatus 106 according to this embodiment that automatically activates a plug-in stored in a specific directory, the developer of the user program needs to specify an execution condition for interprocedural optimization as an option at the time of compilation. There is an effect that there is no.
(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 program conversion apparatus 107 in the present embodiment.

本実施形態におけるプログラム変換装置107は、指示文処理手段127と、プラグイン起動手段117と、コンパイラ起動手段137とを含む。ただし、プログラム変換装置107は、コンパイラとしての機能を含まない。   The program conversion apparatus 107 in the present embodiment includes a directive processing unit 127, a plug-in activation unit 117, and a compiler activation unit 137. However, the program conversion apparatus 107 does not include a function as a compiler.

指示文処理手段127、プラグイン起動手段117の機能は、それぞれ、第3の実施形態における指示文処理手段125、プラグイン起動手段115の機能と同じである。だだし、プラグイン起動手段117は、最適化後のユーザープログラムを、コンパイラ起動手段137に渡す機能を更に有する。   The functions of the instruction sentence processing unit 127 and the plug-in activation unit 117 are the same as the functions of the instruction sentence processing unit 125 and the plug-in activation unit 115 in the third embodiment, respectively. However, the plug-in activation unit 117 further has a function of passing the optimized user program to the compiler activation unit 137.

コンパイラ起動手段137は、最適化後のユーザープログラムを指定して、コンパイラ707を起動する機能を備える。   The compiler starting unit 137 has a function of starting the compiler 707 by designating an optimized user program.

コンパイラ707は、与えられたソースコードをオブジェクトコードに変換する、一般的なコンパイラである。   The compiler 707 is a general compiler that converts a given source code into an object code.

その他の構成要素については、第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 program conversion apparatus 107 instead of the compiler 707.

プログラム変換装置107は、第2の実施の形態におけるプログラム変換装置105と同様に、ヘッダーファイル237中の指示文257にしたがって、ライブラリ207の提供するプラグイン217を起動する。プラグイン217の実行後、プログラム変換装置107は、プラグイン217によって最適化されたユーザープログラムのソースコード(またはコンパイラが読み込み可能な中間コード)を指定してコンパイラ707を起動する。   The program conversion apparatus 107 activates the plug-in 217 provided by the library 207 in accordance with the directive statement 257 in the header file 237, similarly to the program conversion apparatus 105 in the second embodiment. After executing the plug-in 217, the program conversion apparatus 107 activates the compiler 707 by specifying the source code of the user program optimized by the plug-in 217 (or intermediate code that can be read by the compiler).

コンパイラ707は、指定されたソースコードを読み込み、オブジェクトコードに変換する。コンパイラ707は、プラグイン217を起動するための指示文257を処理する指示文処理機能やプラグイン起動機能を有しなくてもよい。   The compiler 707 reads the designated source code and converts it into object code. The compiler 707 does not need to have an instruction sentence processing function or a plug-in activation function for processing the instruction sentence 257 for activating the plug-in 217.

プログラム変換装置107のその他の動作は、第3の実施形態におけるプログラム変換装置105の動作と同じである。   Other operations of the program conversion apparatus 107 are the same as the operations of the program conversion apparatus 105 in the third embodiment.

なお、プログラム変換装置107は、コンパイラ707が受け取り可能なオプションを含むオプションを受け取り、コンパイラ起動時に、コンパイラ707が受け取り可能なオプションをコンパイラ707に渡してもよい。   Note that the program conversion apparatus 107 may receive options including options that can be received by the compiler 707, and pass the options that can be received by the compiler 707 to the compiler 707 when the compiler is activated.

本実施形態におけるプログラム変換装置107では、第3の実施形態におけるプログラム変換装置105と同様に、ライブラリとユーザープログラムとの間で手続き間最適化が可能である。   In the program conversion apparatus 107 according to the present embodiment, interprocedural optimization can be performed between the library and the user program, similarly to the program conversion apparatus 105 according to the third embodiment.

本実施形態におけるプログラム変換装置107では、第3の実施形態におけるプログラム変換装置105の効果に加えて、コンパイラが、プラグイン起動機能、またはプラグインの実行を指示するための指示文を処理する指示文処理機能を有しない場合にも利用可能であるという効果がある。   In the program conversion apparatus 107 according to the present embodiment, in addition to the effects of the program conversion apparatus 105 according to the third embodiment, an instruction for the compiler to process a plug-in activation function or a directive for instructing execution of the plug-in There is an effect that it can be used even when the sentence processing function is not provided.

なお、プログラム変換装置107が、コンパイラが受け取り可能なオプションを含むオプションを受け取り、コンパイラ起動時に、コンパイラが受け取り可能なオプションをコンパイラに渡す場合には、ユーザープログラムの開発者は、コンパイラのオプションと同様なオプションを指定して、プログラム変換装置107を利用することが可能である。   When the program conversion apparatus 107 receives an option including an option that can be received by the compiler, and passes the option that can be received by the compiler to the compiler when the compiler is started, the developer of the user program is similar to the option of the compiler. It is possible to use the program conversion apparatus 107 by specifying various options.

また、本実施形態におけるプログラム変換装置107は、第4の実施形態におけるプログラム変換装置106のように、オプションによってプラグイン起動手段117に対するプラグイン217の起動指示を受けとってもよい。   Further, the program conversion apparatus 107 in the present embodiment may receive an activation instruction for the plug-in 217 to the plug-in activation means 117 as an option, like the program conversion apparatus 106 in the fourth embodiment.

尚、図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 6, further comprising compiler starting means for passing the second code to the compiling process when starting the compiling process for the second code.
(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のコードを取得し、前記特定した前記プラグインの実行を指示するユーザープログラム処理手段と、
前記第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のコードを処理すべき、前記プラグインを特定する
ことを特徴とする請求項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.
前記ユーザープログラム処理手段は、前記リストに基づいて、前記第1のコードにおいて、前記呼び出し命令を含む第1の部分コードを検索し、前記リストに基づいて前記第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のコードを渡す
ことを特徴とする請求項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のコードは、ソースコード又は前記ソースコードが変換された中間コードである
ことを特徴とする請求項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.
前記プラグインは、前記呼び出し命令部分の最適化を行った結果である第2のコードを生成する
ことを特徴とする請求項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.
JP2014019881A 2014-02-05 2014-02-05 Program processing apparatus, program processing method, and program processing program Active JP6326838B2 (en)

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)

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

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

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