JP2006285584A - Program code generation device, program code generation method, and computer program - Google Patents
Program code generation device, program code generation method, and computer program Download PDFInfo
- Publication number
- JP2006285584A JP2006285584A JP2005103870A JP2005103870A JP2006285584A JP 2006285584 A JP2006285584 A JP 2006285584A JP 2005103870 A JP2005103870 A JP 2005103870A JP 2005103870 A JP2005103870 A JP 2005103870A JP 2006285584 A JP2006285584 A JP 2006285584A
- Authority
- JP
- Japan
- Prior art keywords
- program code
- design drawing
- information
- code generation
- class
- 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.)
- Pending
Links
Images
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
Description
本発明は、プログラムコード生成装置、プログラムコード生成方法、及びコンピュータプログラムに関し、特に、プログラムコードを生成するために用いて好適なものである。 The present invention relates to a program code generation device, a program code generation method, and a computer program, and is particularly suitable for use in generating a program code.
近年のソフトウェア設計技術として、モデル駆動型アーキテクチャー(Model Driven Architecture)技術(以降、MDA技術と称す)が採用されるようになってきている。一般的にMDA技術とは、オペレータが入力したソフトウェアの設計図面情報から各プラットフォームのプログラムコードを自動的に生成し、且つ、入力したソフトウェアの設計図面情報をMDA専用ツール上で動作させることが可能な技術である。
これらソフトウェアの設計図面情報の代表的な例としては、オブジェクト指向技術のモデル表記言語であるUML(Unified Modeling Language)などが挙げられる。
As a software design technique in recent years, a model driven architecture (Model Drive Architecture) technique (hereinafter referred to as an MDA technique) has been adopted. In general, MDA technology automatically generates program codes for each platform from software design drawing information input by an operator, and allows the input software design drawing information to run on a dedicated MDA tool. Technology.
Typical examples of design drawing information of these software include UML (Unified Modeling Language) which is a model notation language of object-oriented technology.
従来のプログラムコード生成装置により自動生成されるプログラムコードは、ソフトウェアの設計図面情報とほぼ等価であることが前提とされていた。プログラムコード生成装置において以下の(1)〜(3)などの制約があるためである。
(1)全てのプログラムコードを生成するのに必要な設計図面情報を、プログラムコード生成装置に入力できなかった。
(2)設計図面情報から全てのプログラムコードを生成できず、プログラムコードのスケルトンのみを自動生成していた。
(3)自動生成されたプログラムコード上でしかデバッグ作業が出来なかった
It has been assumed that the program code automatically generated by the conventional program code generation device is almost equivalent to the software design drawing information. This is because the program code generation apparatus has the following restrictions (1) to (3).
(1) Design drawing information necessary for generating all program codes could not be input to the program code generating device.
(2) Not all program codes can be generated from the design drawing information, and only the skeleton of the program code is automatically generated.
(3) Debugging was possible only on automatically generated program code
したがって、オペレータは、設計図面情報とプログラムコードとを常に見比べ、プログラムコードを手動で追加する必要がある。このため、設計図面と、自動生成されるプログラムコードとは、視覚的な静的な側面で完全に等価であることが必修条件であった。
このような状況において、オペレータが入力する設計図面情報には、最適化という観点から注目すると冗長的な部分が多々あり、自動生成されるプログラムコードにおいても、その冗長的な部分が忠実にプログラムコードとして生成されることになる。その結果、プログラムコードがコンパイル・リンクされることで出来上がる実行可能形式のサイズは、冗長的な処理が含まれる分大きくなる。更に、実行可能形式の動作時に使用するメモリサイズも大きくなり、且つ実行スピードも遅くなるという問題が存在した。
Therefore, the operator must always compare the design drawing information with the program code and manually add the program code. For this reason, it is a necessary condition that the design drawing and the automatically generated program code are completely equivalent in terms of visual static.
In such a situation, the design drawing information input by the operator has many redundant portions from the viewpoint of optimization, and even in the automatically generated program code, the redundant portions are faithfully programmed. Will be generated. As a result, the size of the executable format that is created by compiling and linking the program code is increased by including redundant processing. Furthermore, there has been a problem that the memory size used in the operation of the executable format becomes large and the execution speed becomes slow.
この問題を解決する技術としては、プログラムコードのコード・コンパイル時に最適化を施すのが通例である。しかしながら、コード・コンパイル時の最適化は、プログラムコードの格納された1ファイルを対象とした最適化であり、プログラムコードの全てのファイルを対象とした最適化については現状では考慮されていない。 As a technique for solving this problem, optimization is usually performed at the time of code compilation of program code. However, optimization at the time of code compilation is optimization for one file in which program code is stored, and optimization for all files of program code is not considered at present.
近年、MDA技術が進歩したことにより、上述した従来のプログラムコード生成装置における制約を除くことができる。その結果、ソフトウェアの設計図面情報から全てのプログラムコードを自動生成することが可能になり、且つ、設計図面情報をMDA専用ツール上でデバッグ動作させることが可能になっている。これにより、オペレータはプログラムコードを参照することなしにソフトウェアの開発作業を進めることが可能になっている。つまり、従来のように設計図面情報とプログラムコードとが、視覚的な静的な側面においては必ずしも等価である必要性がなくなってきている。このような状況の中、最適化されていない設計図面情報の問題に対して、特開平11−237980号公報に掲載の「オブジェクト指向最適化コード生成装置および方法」、特開2004−118865号公報に掲載の「最適化ソフトウェア生成方法」においては、オブジェクト指向機能排除手段を用いて仮想関数の機能を排除、もしくはインスタンスの動的生成の機能を排除することで、必要なメモリ容量を増加させることなく組み込み制御システムに適用可能なコードの最適化を行なうことを可能にしている。 In recent years, with the advancement of MDA technology, it is possible to remove the restrictions in the conventional program code generation apparatus described above. As a result, all program codes can be automatically generated from the software design drawing information, and the design drawing information can be debugged on the MDA dedicated tool. As a result, the operator can proceed with software development work without referring to the program code. That is, it is no longer necessary that the design drawing information and the program code are always equivalent in terms of visual staticity. Under such circumstances, the “object-oriented optimization code generation apparatus and method” disclosed in Japanese Patent Laid-Open No. 11-237980 and Japanese Patent Application Laid-Open No. 2004-118865 address the problem of unoptimized design drawing information. In the "optimized software generation method" described in, the required memory capacity is increased by eliminating the function of virtual functions or eliminating the function of dynamic generation of instances using object-oriented function exclusion means. This makes it possible to optimize code applicable to embedded control systems.
しかしながら、上述のような装置および方法では、オブジェクト指向機能の排除として、仮想関数機能の排除と、インスタンスの動的生成機能の排除だけしか提案されていない。したがって、設計図面を用いてプログラムコードを自動生成するに際してメモリ容量を適切に削減することが困難であるという問題点があった。 However, in the apparatus and method as described above, only the elimination of the virtual function function and the elimination of the instance dynamic generation function have been proposed as the exclusion of the object-oriented function. Therefore, there is a problem that it is difficult to appropriately reduce the memory capacity when the program code is automatically generated using the design drawing.
本発明は、このような問題点に鑑みてなされたもので、プログラムコードを実行するに際し、メモリ使用量を適切に削減することができるようにすることを目的とする。 The present invention has been made in view of such problems, and an object of the present invention is to appropriately reduce the amount of memory used when executing a program code.
本発明のプログラムコード生成装置は、設計図面を用いてプログラムコードを自動生成するプログラムコード生成装置であって、前記設計図面に含まれるメソッドの呼び出し回数を解析する解析手段と、前記解析手段によって解析された呼び出し回数が所定回数以下のメソッドに対してインライン展開処理を行い、前記呼び出し回数が所定回数以下ではないメソッドに対して関数として展開処理を行うことにより、プログラムコードを生成するプログラムコード生成手段とを有することを特徴とする。 The program code generation device of the present invention is a program code generation device that automatically generates a program code using a design drawing, and analyzes the number of method calls included in the design drawing; Code generation means for generating program code by performing inline expansion processing for a method whose number of calls is less than a predetermined number of times and performing expansion processing as a function for a method whose number of calls is not less than a predetermined number of times It is characterized by having.
本発明のプログラムコード生成方法は、設計図面を用いてプログラムコードを自動生成するプログラムコード生成方法であって、前記設計図面に含まれるメソッドの呼び出し回数を解析する解析ステップと、前記解析ステップにおいて解析された呼び出し回数が所定回数以下のメソッドに対してインライン展開処理を行い、前記呼び出し回数が所定回数以下ではないメソッドに対して関数として展開処理を行うことにより、プログラムコードを生成するプログラムコード生成ステップとを有することを特徴とする。 The program code generation method of the present invention is a program code generation method for automatically generating a program code using a design drawing, wherein an analysis step for analyzing the number of times a method is included in the design drawing, and an analysis in the analysis step A program code generation step of generating a program code by performing inline expansion processing on a method whose number of calls is equal to or less than a predetermined number of times and performing expansion processing as a function on a method whose number of calls is not equal to or less than the predetermined number of times It is characterized by having.
本発明のコンピュータプログラムは、設計図面を用いてプログラムコードを自動生成することをコンピュータに実行させるためのコンピュータプログラムであって、前記設計図面に含まれるメソッドの呼び出し回数を解析する解析ステップと、前記解析ステップにおいて解析された呼び出し回数が所定回数以下のメソッドに対してインライン展開処理を行い、前記呼び出し回数が所定回数以下ではないメソッドに対して関数として展開処理を行うことにより、プログラムコードを生成するプログラムコード生成ステップとをコンピュータに実行させることを特徴とする。 The computer program of the present invention is a computer program for causing a computer to automatically generate a program code using a design drawing, wherein the analysis step analyzes the number of times the method is included in the design drawing; A program code is generated by performing inline expansion processing for a method whose number of calls analyzed in the analysis step is a predetermined number or less and performing expansion processing as a function for a method whose number of calls is not less than the predetermined number A program code generation step is executed by a computer.
本発明によれば、プログラムコードを実行する際のメモリ使用量を削減することができる。 According to the present invention, it is possible to reduce the amount of memory used when executing the program code.
(第1の実施形態)
次に、図面を参照しながら、本発明の第1の実施形態について説明する。
図1は、本実施形態のプログラムコード生成装置の構成の一例を示すブロック図である。
図1において、1はCPUである。CPU1は、プログラムコード生成装置を統括制御し、例えば、バス2に接続された装置3、5、7、9にアクセスして制御を行なう。
3は、バス2を介してCPU1からアクセス可能な読み出し専用メモリ(ROM)である。本実施形態では、処理プログラム3a及び処理プログラム3aにより使用されるパラメータ3bがROM3に格納されている。
(First embodiment)
Next, a first embodiment of the present invention will be described with reference to the drawings.
FIG. 1 is a block diagram showing an example of the configuration of the program code generation device of the present embodiment.
In FIG. 1, 1 is a CPU. The CPU 1 performs overall control of the program code generation device, for example, accesses and controls the
A read-only memory (ROM) 3 is accessible from the CPU 1 via the bus 2. In this embodiment, the processing program 3a and the
4は読み書き可能なメモリ(RAM)である。RAM4には、設計図面情報、プラットフォーム情報、最適化可能箇所情報、実行環境制約情報、最適化予定情報、プログラムコード、プロジェクトファイル、ライブラリ、及び実行可能形式をそれぞれ格納するためのデータ格納領域4a〜4iが確保されている。これらデータ格納領域4a〜4iに格納される情報は、それぞれ処理プログラム3aにより作成及び変更される。
5は入力インターフェイスであり、キーボード、ボタン、マウス、ダイアル、タブレット等の入力装置6を介してなされる入力を受け取る。
7は出力インターフェイスであり、例えばCRT(又はLCD)8aや、プリンタ(又はプロッタ)8b等を備える出力装置8に対し、データの表示指示や出力指示を行なう。
9は外部記憶装置インターフェイスであり、HD、FD、CD−ROM、MDなどの外部記憶装置10に対するデータの入出力を行なうものである。
An
本実施形態では、処理プログラム3aやパラメータ3bがROM3にあるものとし、また、処理対象となる各データ格納領域4a〜4iがRAM4にあるものとして説明を行なうが、これら全て又は一部を、外部記憶装置10に配置することも可能であり、更に、必要に応じて、外部記憶装置10からRAM4にロードして使用することも可能である。また、CPU1のキャッシュメモリにこれらを配置することも可能である。
In the present embodiment, the processing program 3a and the
図2は、図1に示した処理プログラム3aの構成要件と、その構成要件と図1に示したデータ格納領域4a〜4iに格納されるデータとの関係と、を示す図である。 FIG. 2 is a diagram showing the configuration requirements of the processing program 3a shown in FIG. 1 and the relationship between the configuration requirements and the data stored in the data storage areas 4a to 4i shown in FIG.
図2において、200は、入力インターフェイス5を介して入力されるデータを扱うGUI入力処理部である。オペレータはこのGUI入力処理部200によりデータの入力や編集ができるようになっている。
In FIG. 2, reference numeral 200 denotes a GUI input processing unit that handles data input via the
201は、実行可能な設計図面を外部記憶装置10内から読み出し、構文解析を行なう実行可能設計図面解析部である。この実行可能設計図面解析部201によって、処理プログラム3aが実行可能設計図面を解釈することを可能にする。なお、設計図面は、プラットフォームに依存せず、オブジェクト指向であるのが好ましい。
202は、外部記憶装置10内から実行ファイルの動作するOSや、プログラミング言語や、利用フレームワークといったプラットフォームデータを読み込み、構文解析を行なうプラットフォーム依存解析部である。このプラットフォーム依存解析部202によって、処理プログラム3aがプラットフォーム情報を解釈することを可能にする。
An executable design
203は、実行可能設計図面解析部201により生成された設計図面情報である。この設計図面情報203は、処理プログラム3aが解釈することが可能な情報である。
204は、プラットフォーム依存解析部202により生成されたプラットフォーム情報である。このプラットフォーム情報は、処理プログラム3aが解釈することが可能な情報である。
205は、全ての設計図面情報203を解析することで、利用されていないクラス、メソッド、イベントや、書き込みアクセスインスタンス、クラスの有無といった最適化が可能な箇所を特定する最適化可能箇所抽出部205である。この最適化可能箇所抽出部205は、実行可能な設計図面内における最適化が可能な箇所を絞り込む。
An optimizable
206は、プラットフォーム情報204から、32bit演算の禁止や、使用メモリ量の制限といった、最適化の際に行なうべき制約を解析する実行環境制約解析部である。この実行環境制約解析部206は、速度やメモリ量といったトレードオフの選択が必要となる情報を抽出する。
207は、最適化可能箇所抽出部205より生成された最適化可能箇所である。この最適化可能箇所207は、最適化が可能な箇所を特定するための情報である。
208は、実行環境制約部206より抽出された実行環境制約である。この実行環境制約208は、実行環境における制約条件の情報である。
208 is an execution environment constraint extracted by the execution
209は、最適化可能箇所207と実行環境制約208とを用いて、プログラムコードやプロジェクトファイルを自動生成する際にどのような最適化が効果的且つ適用可能かを示す情報(最適化予定リスト)を抽出する最適化予定リスト抽出部である。
210は、最適化予定リスト抽出部209より抽出された最適化予定リストである。上述したように、最適化予定リスト210は、プログラムコードやプロジェクトファイルを自動生成する際にどのような最適化が効果的且つ適用可能かを示す情報である。
211は、設計図面情報203と、プラットフォーム情報204と、最適化予定リスト210とを用いて、プログラムコードを自動生成するプログラムコード生成部である。このプログラムコード生成部211によって、設計図面の依存関係や実行対象となるプラットフォームに応じて最適化されたプログラムコードの自動生成が可能になる。
A program
212は、設計図面情報203と、プラットフォーム依存情報204と、最適化予定リスト210とを用いて、プログラムコードやライブラリを管理するプロジェクトファイルを自動生成するプロジェクトファイル生成部である。
213は、プログラムコード生成部211により生成されたプログラムコードである。
214は、プロジェクトファイル生成部212により生成されたプロジェクトファイルである。
215は、プログラムコード213から参照されるライブラリである。
216は、プロジェクトファイル214が管理するプログラムコード213と、プロジェクトファイル214と、ライブラリ215とを用いて、実行可能形式217を生成するコード・コンパイラである。
A project
Reference numeral 213 denotes a program code generated by the program
A
次に、図3のフローチャートを参照しながら、本実施形態のプログラムコード生成装置の処理手順の概要の一例を説明する。本実施の形態におけるプログラムコード生成装置の処理は、ROM3に記憶された処理プログラム3aをRAM4に展開し、CPU1が処理プログラム3aに基づいて処理を実行することによって達成される。
まず、ステップS301にて起動したプログラムコード生成装置は、ステップS302において、外部記憶装置10などに記憶されている実行可能な設計図面を読み込み、実行可能設計図面解析部201により設計図面情報203を生成する。
Next, an example of the outline of the processing procedure of the program code generation device of this embodiment will be described with reference to the flowchart of FIG. The processing of the program code generation device in the present embodiment is achieved by expanding the processing program 3a stored in the
First, the program code generation apparatus activated in step S301 reads an executable design drawing stored in the
そして、ステップS303において、プラットフォーム情報がある場合にはステップS304へ、プラットフォーム情報がない場合にはステップS306へ分岐する。プラットフォーム情報がない場合には、ステップS306において、最適化可能個所抽出部205は、設計図面情報203から図面の依存関係を解析することで最適化可能箇所207を生成する。
In step S303, if there is platform information, the process branches to step S304, and if there is no platform information, the process branches to step S306. If there is no platform information, in step S306, the optimizable
一方、プラットフォーム情報がある場合には、ステップS304において、外部記憶装置10などに記憶されているプラットフォーム情報を読み込み、プラットフォーム依存解析部202によりプラットフォーム情報204を生成する。そして、ステップ305において、実行環境制約解析部206は、プラットフォーム情報204から実行環境制約情報を解析することで実行環境制約208を生成する。その後、上述したように、ステップS306において最適化可能箇所207を生成する。
On the other hand, if there is platform information, the platform information stored in the
最適化可能箇所207が生成されると、ステップS307において、最適化予定リスト生成部209は、最適化可能箇所207と実行環境制約208とを用いて、プログラムコードを生成するときに最適化を施すために必要な情報のリストである最適化予定リスト210を生成する。このとき、実行環境制約208がない場合や、最適化予定リスト210の作成に影響がない場合には、最適化可能箇所207と最適化予定リスト210とは同じ情報であっても構わない。
When the
次に、ステップS308において、設計図面情報203と、プラットフォーム情報204と、最適化予定リスト210とを用いて、プロジェクトファイル生成部212は、プロジェクトファイル214を生成する。
次に、ステップ309において、設計図面情報203と、プラットフォーム情報204と最適化予定リスト210とを用いて、プログラムコード生成部211は、プログラムコード213を生成する。プログラムコード213の生成に必要なプラットフォーム情報204は、プラットフォームに依存した制約情報である。具体的にプラットフォーム情報204は、例えば、タスクやスレッドをどこのドメインやクラスなどにマッピングさせるかを示す情報や、実行スピードとメモリ容量との何れを優先させるのかを示す情報などである。
In step S308, the project
Next, in step 309, the program
最後に、ステップ310において、コード・コンパイラ216は、プロジェクトファイル214を基にして、プログラムコード213とライブラリ215に対して、コンパイルとリンクを実施し、実行可能形式217を生成する。
Finally, in step 310, the
図4は、設計図面情報203の一例を示した図である。図4では、設計図面情報203のうち、一部分のみの情報の一例を示している。
図4において、701は、クラス「A」であり、非公開属性としてint型の「a」、公開関数として戻り値がvoid型の「func_a」、非公開関数として戻り値がint型の「pri_func」という構成を示している。
702は、クラス「B」であり、公開関数として戻り値がvoid型の「func_b」という構成を示している。
なお、図4では、クラス701とクラス702が関連を持つことを示している。
FIG. 4 is a diagram showing an example of the
In FIG. 4,
FIG. 4 shows that the
704は、クラス702のインスタンスがある状態のときの動作定義である。この動作定義704は、「eventB1」というイベントによりメソッド「func_b」を実行し、且つ、メソッド「func_b」の内部動作の指示として「クラス「A」のfunc_aメソッドを実行する」ということを示している。705は、クラス701のメソッドである「func_a」の内部動作の定義である。この内部動作の指示として、属性「a」を用いた計算が定義されている。706は、クラス701のメソッド「pri_func」の内部動作の定義である。
図5は、最適化可能個所207または最適化予定リスト210の一例を示した図である。
図5において、801は、プログラムコードを生成するときに削除する対象のメソッドの一覧(削除対象メソッド)である。802は、プログラムコードを生成するときにインライン展開(設計図面上での関数またはサブルーチン呼び出しに対するコードとして、呼び出される関数またはサブルーチンの中身を直接出力する処理)する対象のメソッドの一覧(インライン対象メソッド)である。803は、設計図面情報203では元々非公開で定義されている属性を、プログラムコードを生成するときに、公開に変更して定義する属性の一覧(公開対象属性)を示している。
FIG. 5 is a diagram showing an example of the
In FIG. 5,
804は、設計図面情報203では元々非公開で定義されているメソッドを、プログラムコードを生成するときに、公開に変更して定義するメソッドの一覧(公開対象メソッド)を示している。なお、ここでは、最適化可能個所抽出部205により抽出された最適可能化個所207と、最適化予定リスト作成部209により作成された最適化予定リスト210とは、同じ情報として扱う。つまり、実行環境制約208が無かった場合を例に挙げて説明する。
図6は、本実施形態における最適化を設計図面情報203に施さないで自動生成されたプログラムコードの一例を示す図である。
図6において、901、902は、クラス701と、内部動作の定義705、706の情報から生成されたプログラムコードの一例である。903は、クラス702と、動作定義704の情報から生成されたプログラムコードの一例である。なお、ここでは、説明を簡潔にするために、説明する上で必要な最低限の情報のみを示している。
FIG. 6 is a diagram showing an example of a program code automatically generated without applying optimization to the
In FIG. 6,
例えば、図4において、属性やメソッド以外の設計図面情報203がクラス701、702に存在していても構わないがここでは表記していない。また、各クラスやメソッドがプログラムコードとして生成される場合に、そのプログラムコードがどこのファイルに展開されるか等の情報についての設計図面情報203も存在している。本実施形態では、これら全部の設計図面情報203を用いてプログラムコードは自動生成されるものとする。
For example, in FIG. 4,
図7は、本実施形態における最適化を設計図面情報203に施して自動生成されたプログラムコードの一例を示す図である。つまり、図7は、図5に示した最適化予定リスト210を加味して自動生成されたプログラムコードの一例を示している。
図7において、1001は、クラス701と、削除対象メソッド801と、インライン対象メソッド802と、公開対象属性803の情報から生成されたプログラムコードの一例である。1002は、クラス702と、動作定義704と、インライン対象メソッド802と、公開対象属性803の情報から生成されたプログラムコードの一例である。
FIG. 7 is a diagram showing an example of a program code automatically generated by applying optimization to the
In FIG. 7, 1001 is an example of a program code generated from information of a
ここで、図4に示した設計図面情報203と、図5に示した最適化予定リスト210と、図7に示したプログラムコードの詳細に関して、CPU1が処理プログラム3aに基づいて実行する図8〜図10の動作処理フローチャートを参照しながら説明する。
Here, regarding the details of the
図8のフローチャートによる処理は、図3に示したステップS307内での処理である。この図8のフローチャートによるが開始するのは、設計図面情報203における1つのメソッドについて注目し最適化が可能かどうかの判断を行なう場合である。つまり、設計図面情報203の全てのメソッドについて、この図8のフローチャートが繰り返し実施されることになる。
The processing according to the flowchart of FIG. 8 is processing within step S307 shown in FIG. The process shown in the flowchart of FIG. 8 starts when it is determined whether optimization is possible by paying attention to one method in the
まず、ステップS1101では、CPU1は、対象メソッドについて設計図面情報203内の全情報を解析して、その対象メソッドが何回呼び出されているかをカウントする。具体的に非公開メソッドの場合についてはそのメソッドが所属するクラス内における設計図面情報203を解析する対象範囲とし、公開メソッドの場合については全クラスの設計図面情報203を解析する対象範囲とし、対象範囲から対象メソッドが呼び出されている回数をカウントする。処理の詳細については、図9のフローチャートを用いて説明する。
First, in step S1101, the CPU 1 analyzes all information in the
次に、ステップS1102では、CPU1は、ステップS1101にて解析した対象メソッドの呼び出し回数が0回であったか否かを判定する。この判定の結果、0回の呼び出し、つまり対象メソッドがどこからも使われていないメソッドであった場合には、ステップS1104へ進む。一方、1回以上の呼び出し、つまり対象メソッドがどこかで使われているメソッドであった場合には、ステップS1103へ進む。 Next, in step S1102, the CPU 1 determines whether the number of calls of the target method analyzed in step S1101 is zero. As a result of this determination, if the number of calls is zero, that is, if the target method is not used anywhere, the process proceeds to step S1104. On the other hand, if it is called once or more, that is, if the target method is used somewhere, the process proceeds to step S1103.
そして、ステップS1104では、CPU1は、対象メソッドが使われていないということを最適化予定リスト210へ記憶する。図5に示した削除対象メソッド801では、使われていないメソッド、つまりプログラムコードの生成から削除対象となるメソッドのリストに登録されることになる。この削除対象メソッド801のリストに登録されたメソッドは、設計図面情報203には存在するが、プログラムコード生成部211によって生成されるプログラムコード213には存在しないことになる。
In step S1104, the CPU 1 stores in the
図4に示した例では、クラス701では、「pri_func」メソッドがこの削除対象メソッドにあたる。よって、図6に示した最適化を施さない場合のプログラムコードでは、プログラムコード901に、「pri_func」メソッドのプログラムコードが生成されているが、図7に示した最適化を施す場合のプログラムコードでは、プログラムコード1001に、「pri_func」メソッドは生成されていない。
In the example illustrated in FIG. 4, in the
ステップS1103では、CPU1は、ステップS1101にて解析した対象メソッドの呼び出し回数が1回であったか否かを判定する。1回の呼び出し、つまり対象メソッドが1箇所だけからしか使われていないメソッドであった場合には、ステップS1106へ進む。一方、2回以上の呼び出し、つまり対象メソッドが複数箇所から使われているメソッドであった場合には、ステップS1105へ進む。なお、ステップS1103では、メソッドの呼び出し回数が1回以下か否かを判断基準としているが、RAM4の残容量に余裕がある場合、2回,3回などを判断基準としてもよい。この場合、RAM4の残容量を参照し、容量が多くなるに従って判断基準とすべき読出し回数を増やす処理が行われることになる。
In step S1103, the CPU 1 determines whether or not the number of calls of the target method analyzed in step S1101 is one. If the method is called once, that is, if the target method is a method that is used only from one place, the process proceeds to step S1106. On the other hand, if it is called twice or more, that is, if the target method is a method used from a plurality of locations, the process proceeds to step S1105. In step S1103, whether or not the number of method calls is one or less is used as a criterion. However, if there is a margin in the remaining capacity of the
そして、ステップS1106では、CPU1は、対象メソッドが1箇所だけからしか使われていないということを最適化予定リスト210へ記憶し、且つ、その対象メソッドを使っている1箇所にその対象メソッドをインライン展開してコード生成する(ソース上での関数またはサブルーチン呼び出しに対するコードとして、呼び出される関数またはサブルーチンの中身を直接出力する)ための処理をする。処理の詳細については、図13のフローチャートにて説明する。
In step S1106, the CPU 1 stores in the
また、ステップS1105では、対象メソッドについては最適化せずにメソッドを関数として展開する、すなわち、メソッドを関数の呼出しに用いられる命令のプログラムコードとして生成する処理を行うこと決定する。なお、本実施形態においては、最適化予定リスト210に対象メソッドを登録しないことでプログラムコードを生成すると決定しているが、最適化予定リスト210に「最適化しないメソッド」のリストとして対象メソッドを記憶することも可能である。
Also, in step S1105, it is determined that the target method is not optimized and the method is expanded as a function, that is, the method is generated as a program code of an instruction used for calling the function. In this embodiment, it is determined that the program code is generated by not registering the target method in the
次に、図9のフローチャートを参照しながら、図8に示したステップS1101(メソッドの呼び出し回数カウント処理)の詳細の一例について説明する。
まず、ステップS1201では、対象メソッドが所属するクラスと関連のあるクラスを設計図面情報203から抽出する。例えば、図4に示したクラス701における「func_a」メソッドが対象メソッドの場合には、関連のあるクラスは所属するクラス701と、クラス702であることを抽出する。また、「pri_func」メソッドが対象メソッドの場合には、この「pri_func」メソッドが非公開メソッドであることから関連のあるクラスは所属するクラス701のみであることを抽出する。
Next, an example of details of step S1101 (method call count processing) shown in FIG. 8 will be described with reference to the flowchart of FIG.
First, in step S1201, a class related to the class to which the target method belongs is extracted from the
次に、ステップS1202では、ステップS1201で抽出した全てのクラスについて、対象メソッドが使われているかどうかの走査が終わったかどうかを判定する。この判定の結果、走査が終わっていない場合にはステップS1203へ進む。一方、走査が終わった場合には、そのままこのフローチャートを抜けて、図8に示したステップS1102に進む。 Next, in step S1202, it is determined whether scanning for whether or not the target method is used has been completed for all the classes extracted in step S1201. If the result of this determination is that scanning has not ended, processing advances to step S1203. On the other hand, when the scanning is finished, the process directly exits the flowchart and proceeds to step S1102 shown in FIG.
一方、走査が終わっておらずステップS1203に進むと、ステップS1201で抽出したクラスに関する設計図面情報203を走査し、対象メソッドが使われているかどうかを判別し、使われている場合には使われている回数分カウントアップしていく。
On the other hand, if scanning has not ended and the process proceeds to step S1203, the
図4に示したクラス701の対象メソッドが「func_a」の場合には、ステップS1201で、関連のあるクラスはクラス701とクラス702との判定されたことから、それらクラス701、702の設計図面情報203を走査することになる。その結果、クラス702の動作定義704において対象メソッドとして、クラス701の「func_a」が使用されていることが確認され、使われている回数が1だけカウントアップされる。
When the target method of the
また、図4に示したクラス701の対象メソッドが「pri_func」の場合には、ステップS1201で、関連のあるクラスはクラス701と判定されたことから、そのクラス701の設計図面情報203を走査することになる。その結果、対象メソッドとして、クラス701の「pri_func」が使用されていないことが確認され、使われている回数が0にセットされる。
If the target method of the
次に、図10のフローチャートを参照しながら、図8に示したステップS1106(メソッドをインライン展開するための処理)の詳細の一例について説明する。図4に示したクラス701では、呼び出し回数が1個所であると確認された対象メソッド(「func_a」)のときに、このフローチャートが開始する。
Next, an example of the details of step S1106 (processing for inline development of a method) shown in FIG. 8 will be described with reference to the flowchart of FIG. In the
まず、ステップS1301では、対象メソッドをインライン展開するための登録を最適化予定リスト210に対して行なう。図5に示した例では、インライン対象メソッド802のリストに「クラスAのfunc_a」がインライン展開の対象メソッドであると登録される。
First, in step S1301, registration for optimizing the target method is performed on the
次に、ステップS1310では、対象メソッドが、所属するクラス以外でも呼び出されているか否かを判定し、所属するクラス以外でも呼び出されている場合にはステップS1302へ進む。図5に示した例では、インライン対象メソッド802である「クラスAのfunc_a」は、図4に示した動作定義704より、クラス702(クラスB)から呼び出されていると判断され、ステップS1302へ進むことになる。もし所属するクラス以外から呼び出されていない場合には、インライン展開される箇所はクラス内であり、対象メソッドが非公開な属性やメソッドを操作していたとしても、その属性やメソッドを操作するスコープには影響しないので、そのまま図10に示すフローチャートを抜けることになる。
Next, in step S1310, it is determined whether or not the target method is called by a class other than the class to which the target method belongs. If the target method is also called by a class other than the class to which the target method belongs, the process proceeds to step S1302. In the example illustrated in FIG. 5, it is determined that “class_func_a”, which is the
ステップS1302では、設計図面情報203を参照して、対象メソッドが非公開属性を操作しているかどうかを確認する。この確認の結果、非公開属性を操作している場合にはステップS1303へ進み、非公開属性を操作していない場合にはステップS1304へ進む。図3に示した例では、クラス701に所属する対象メソッド「func_a」により、クラス701に所属する非公開属性のうち「int型のa」が操作されていると判断されステップS1303へ進むことになる。
In step S1302, it is confirmed with reference to the
ステップS1303では、対象メソッドが操作している非公開属性を、対象メソッドが所属するクラス以外のクラスにインライン展開するので、非公開属性を公開属性に変更するための登録を、最適化予定リスト210に対して行なう。図5に示した公開対象属性803では、非公開属性であった属性「a」を公開属性に変更することを登録している。
In step S1303, since the private attribute operated by the target method is expanded inline to a class other than the class to which the target method belongs, registration for changing the private attribute to the public attribute is performed in the
ステップS1304では、設計図面情報203を参照して、対象メソッドが非公開関数を操作しているかどうかを確認する。この確認の結果、非公開関数を操作している場合にはステップS1305へ進む。図4に示した例では、クラス701に所属する対象メソッドである「func_a」ではクラス701に所属する非公開関数は操作されていないと判断され、そのまま図10のフローチャートを抜けることになる。
In step S1304, with reference to the
ステップS1305では、対象メソッドが操作している非公開関数を、対象メソッドが所属するクラス以外のクラスにインライン展開するために、非公開関数を公開関数に変更するための登録を最適化予定リスト210に対して行なう。図5に示した公開対象メソッド804では、本ステップで対象とするメソッドがないことにより、リストに登録されずに空の状態であることを示している。
In step S1305, in order to inline the private function operated by the target method into a class other than the class to which the target method belongs, registration for changing the private function to the public function is the
図3、図8〜図10のフローチャートの処理によって、設計図面情報203より最適化予定リスト210が生成され、図3のステップS309の処理により設計図面情報203や最適化予定リスト210の情報を基に、最適化されたプログラムコードが生成されることになる。
The
以上のように本実施形態では、設計図面情報203に存在するメソッドにおいて、呼び出しが行なわれないメソッドと、1回しか呼び出されることがないメソッドに関する情報を収集し、呼び出しが行なわれないメソッドに関してはプログラムコードに関数定義を生成しない。一方、1回しか呼び出されることがないメソッドに関しては、メソッドがアクセスする資源に対してメソッドの呼び出し元がアクセスできるように属性を変更し、且つ呼び出し元へメソッドをインライン展開するプログラムコードを生成する。このようにすることで、最終的にコンパイル・リンクされた実行可能形式のファイルが、設計図面情報203にある使用されない関数を含むこともないのでメモリ使用量を削減でき、設計図面情報203上にある関数コールによるオーバーヘッドも少なくなることにより処理を高速化することができる。
As described above, in the present embodiment, among the methods existing in the
なお、前述した本実施形態で示したフローチャートによる処理手順は、一例であり、本発明はこれらの処理手順に限定されることはなく、本発明の結果を満たす限りいかなる手順の組み合わせも可能である。例えば、複数の処理をまとめることも、処理を細分化することも可能であり、また、各処理を個々に切り出してひとつの機能要素として単体として機能することも可能である。さらに、フローチャートに示した処理とフローチャートに示している処理以外の処理とを組み合わせて使用することも可能である。 Note that the processing procedure according to the flowchart shown in the above-described embodiment is an example, and the present invention is not limited to these processing procedures, and any combination of procedures is possible as long as the result of the present invention is satisfied. . For example, a plurality of processes can be combined, or the processes can be subdivided, and each process can be cut out individually and function as a single functional element. Furthermore, it is possible to use a combination of the process shown in the flowchart and a process other than the process shown in the flowchart.
(第2の実施形態)
次に、本発明の第2の実施形態について説明する。本実施形態では、設計図面情報203の読み出しが行なわれないメソッドや、1回しか呼び出されることがないメソッドに関する情報をオペレータに通知するようにしている点が第1の実施形態と異なる。したがって、本実施形態の説明において、第1の実施形態と同一の部分については、図1〜図10に付した符号と同一の符号を付すなどして詳細な説明を省略する。
(Second Embodiment)
Next, a second embodiment of the present invention will be described. This embodiment is different from the first embodiment in that an operator is notified of information regarding a method for which
図11は、最適化予定リスト作成部209により最適化予定リスト210を作成する前に、最適化可能箇所207をオペレータに通知する場合に、出力装置8にGUIで表示される最適化設定ダイアログ1401の一例を示す図である。
FIG. 11 shows an
図14において、1402は、設計図面情報203でどこからも呼び出されていない削除対象の候補のメソッドをリスト形式で表示する削除対象メソッド表示部である。1403は、設計図面情報203で1個所だけから呼び出されているインライン展開対象の候補のメソッドをリスト形式で表示するインライン展開対象メソッド表示部である。
In FIG. 14,
例えば、最適化可能箇所抽出部により、設計図面情報203から最適化可能箇所207を抽出した結果に基づいて、1回も使用されていないメソッドが削除対象メソッド表示部1402に削除対象の候補として表示され、1箇所からだけしか呼び出されていないメソッドがインライン展開対象メソッド表示部1403にインライン展開対象メソッドの候補として表示される。
For example, a method that has not been used once is displayed on the deletion target
オペレータは、削除対象メソッド表示部1402やインライン展開対象メソッド表示部1403の各メソッドに対応したチェックボックスを設定(オン)したり、設定を解除(オフ)したりすることができる。最終的にOKボタン1405を押した時点で設定されているメソッドについては、最適化可能箇所207の情報が、そのまま最適化予定リスト210にも登録され、設定が解除されたメソッドについては、最適化可能箇所207の情報から最適化予定リスト210への登録はなされない。
The operator can set (turn on) check boxes corresponding to the methods in the deletion target
また、最適化可能箇所抽出部は、例えば、オペレータが削除対象メソッド表示部1402やインライン展開対象メソッド表示部1403の設定がオン・オフされる度に、「コードステップ量の削減量」や「予想ROM使用削減量」や「予想実行速度アップ率」などの情報を、表示部1404にリアルタイムに表示することでオペレータに通知する。オペレータはこれらの情報を基に、削除対象メソッド表示部1402やインライン展開対象メソッド表示部1403に表示された候補の各メソッドに対してプログラムコードを生成する際の最適化を実際に行なうかどうかを判断する情報として参考にすることができる。表示部1404に表示するような情報の計算方法は、例えば、ツール独自の計算方法など、どのようなものであってもよく、最適化可能箇所抽出部はその算出された情報をオペレータへ通知するだけである。
In addition, the optimizable location extraction unit, for example, every time the operator turns on / off the setting of the deletion target
以上のように本実施形態では、設計図面情報203の呼び出しが行なわれないメソッドや、呼び出しが1回しか呼び出されることがないメソッドに関する情報をオペレータに通知するようにしたので、前述した第1の実施形態の効果に加え、オペレータは、最適化を行なう候補として表示されたメソッドに関してプログラムコードの生成に関する最適化を行なうのか否かの選択をすることができ、使用メモリ容量や実行スピードのトレードオフに関する検討を行なうことができる。また、設計図面情報上の使用されていないメソッドや呼び出しが1回しか呼び出されることがないメソッドに関する情報をオペレータに通知することで、オペレータの消し忘れのメソッドやソフトウェアの設計自体を見直す機会をオペレータに与えることができる。
As described above, in the present embodiment, the operator is notified of information on a method that does not call the
(本発明の他の実施形態)
上述した実施形態の機能を実現するべく各種のデバイスを動作させるように、該各種デバイスと接続された装置あるいはシステム内のコンピュータに対し、前記実施形態の機能を実現するためのソフトウェアのプログラムコードを供給し、そのシステムあるいは装置のコンピュータ(CPUあるいはMPU)に格納されたプログラムに従って前記各種デバイスを動作させることによって実施したものも、本発明の範疇に含まれる。
(Other embodiments of the present invention)
In order to operate various devices to realize the functions of the above-described embodiments, program codes of software for realizing the functions of the above-described embodiments are provided to an apparatus or a computer in the system connected to the various devices. What is implemented by operating the various devices according to a program supplied and stored in a computer (CPU or MPU) of the system or apparatus is also included in the scope of the present invention.
また、この場合、前記ソフトウェアのプログラムコード自体が上述した実施形態の機能を実現することになり、そのプログラムコード自体、及びそのプログラムコードをコンピュータに供給するための手段、例えば、かかるプログラムコードを格納した記録媒体は本発明を構成する。かかるプログラムコードを記憶する記録媒体としては、例えばフレキシブルディスク、ハードディスク、光ディスク、光磁気ディスク、CD−ROM、磁気テープ、不揮発性のメモリカード、ROM等を用いることができる。 In this case, the program code of the software itself realizes the functions of the above-described embodiments, and the program code itself and means for supplying the program code to the computer, for example, the program code are stored. The recorded medium constitutes the present invention. As a recording medium for storing the program code, for example, a flexible disk, a hard disk, an optical disk, a magneto-optical disk, a CD-ROM, a magnetic tape, a nonvolatile memory card, a ROM, or the like can be used.
また、コンピュータが供給されたプログラムコードを実行することにより、上述の実施形態の機能が実現されるだけでなく、そのプログラムコードがコンピュータにおいて稼働しているOS(オペレーティングシステム)あるいは他のアプリケーションソフト等と共同して上述の実施形態の機能が実現される場合にもかかるプログラムコードは本発明の実施形態に含まれることは言うまでもない。 Further, by executing the program code supplied by the computer, not only the functions of the above-described embodiments are realized, but also the OS (operating system) or other application software in which the program code is running on the computer, etc. It goes without saying that the program code is also included in the embodiment of the present invention even when the functions of the above-described embodiment are realized in cooperation with the embodiment.
さらに、供給されたプログラムコードがコンピュータの機能拡張ボードやコンピュータに接続された機能拡張ユニットに備わるメモリに格納された後、そのプログラムコードの指示に基づいてその機能拡張ボードや機能拡張ユニットに備わるCPU等が実際の処理の一部または全部を行い、その処理によって上述した実施形態の機能が実現される場合にも本発明に含まれることは言うまでもない。 Further, after the supplied program code is stored in the memory provided in the function expansion board of the computer or the function expansion unit connected to the computer, the CPU provided in the function expansion board or function expansion unit based on the instruction of the program code Needless to say, the present invention also includes a case where the functions of the above-described embodiment are realized by performing part or all of the actual processing.
201 実行可能設計図面解析部
202 プラットフォーム依存解析部
203 設計図面情報
204 プラットフォーム情報
205 最適化可能箇所抽出部
206 実行環境制約解析部
207 最適化可能箇所
208 実行環境制約
209 最適化予定リスト作成部
210 最適化予定リスト
211 プログラムコード生成部
212 プロジェクトファイル生成部
213 プログラムコード
214 プロジェクトファイル
215 ライブラリ
216 コード・コンパイラ
217 実行可能形式
701、702 クラス
704 動作定義
705、706 内部動作の定義
801 削除対象メソッド
802 インライン対象メソッド
803 公開対象属性
804 公開対象メソッド
201 Executable Design
Claims (5)
前記設計図面に含まれるメソッドの呼び出し回数を解析する解析手段と、
前記解析手段によって解析された呼び出し回数が所定回数以下のメソッドに対してインライン展開処理を行い、前記呼び出し回数が所定回数以下ではないメソッドに対して関数として展開処理を行うことにより、プログラムコードを生成するプログラムコード生成手段とを有することを特徴とするプログラムコード生成装置。 A program code generation device that automatically generates a program code using a design drawing,
An analysis means for analyzing the number of times the method is included in the design drawing;
A program code is generated by performing inline expansion processing on a method whose number of calls analyzed by the analyzing means is a predetermined number or less and performing expansion processing as a function on a method whose number of calls is not less than the predetermined number And a program code generation means.
前記設計図面に含まれるメソッドの呼び出し回数を解析する解析ステップと、
前記解析ステップにおいて解析された呼び出し回数が所定回数以下のメソッドに対してインライン展開処理を行い、前記呼び出し回数が所定回数以下ではないメソッドに対して関数として展開処理を行うことにより、プログラムコードを生成するプログラムコード生成ステップとを有することを特徴とするプログラムコード生成方法。 A program code generation method for automatically generating a program code using a design drawing,
An analysis step for analyzing the number of times the method is called in the design drawing;
Generate program code by performing inline expansion processing for a method whose number of calls analyzed in the analysis step is a predetermined number or less, and performing expansion processing as a function for a method whose number of calls is not a predetermined number or less A program code generation method comprising: a program code generation step.
前記設計図面に含まれるメソッドの呼び出し回数を解析する解析ステップと、
前記解析ステップにおいて解析された呼び出し回数が所定回数以下のメソッドに対してインライン展開処理を行い、前記呼び出し回数が所定回数以下ではないメソッドに対して関数として展開処理を行うことにより、プログラムコードを生成するプログラムコード生成ステップとをコンピュータに実行させることを特徴とするコンピュータプログラム。 A computer program for causing a computer to automatically generate a program code using a design drawing,
An analysis step for analyzing the number of times the method is called in the design drawing;
Generate program code by performing inline expansion processing for a method whose number of calls analyzed in the analysis step is a predetermined number or less, and performing expansion processing as a function for a method whose number of calls is not a predetermined number or less A computer program for causing a computer to execute a program code generation step.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005103870A JP2006285584A (en) | 2005-03-31 | 2005-03-31 | Program code generation device, program code generation method, and computer program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2005103870A JP2006285584A (en) | 2005-03-31 | 2005-03-31 | Program code generation device, program code generation method, and computer program |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2006285584A true JP2006285584A (en) | 2006-10-19 |
Family
ID=37407457
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2005103870A Pending JP2006285584A (en) | 2005-03-31 | 2005-03-31 | Program code generation device, program code generation method, and computer program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2006285584A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2011055417A1 (en) * | 2009-11-09 | 2011-05-12 | 三菱電機株式会社 | Software library reconfiguration device and method, and navigation device using the same |
-
2005
- 2005-03-31 JP JP2005103870A patent/JP2006285584A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2011055417A1 (en) * | 2009-11-09 | 2011-05-12 | 三菱電機株式会社 | Software library reconfiguration device and method, and navigation device using the same |
JP4964352B2 (en) * | 2009-11-09 | 2012-06-27 | 三菱電機株式会社 | Software library reconstruction apparatus and method, and navigation apparatus using the same |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8201140B2 (en) | System and method for creating and using graphical object instances in a statechart environment | |
US8656352B2 (en) | System and method for synchronized workflow management | |
US9594856B2 (en) | System and method to embed behavior in a CAD-based physical simulation | |
JPH0844547A (en) | Visualization of object-oriented software | |
US20080235660A1 (en) | Depicting Changes to Structures in an Integrated Development Environment | |
EP3244306A1 (en) | A computer-implemented method for allowing modification of a region of original code | |
JP2013518321A (en) | Pattern-based user interface | |
Van Cam Pham et al. | Complete code generation from UML state machine | |
Bandener et al. | Extending DMM behavior specifications for visual execution and debugging | |
CN110554861B (en) | Software development environment with compile and read-evaluate-print-loop operations | |
US9170783B1 (en) | Class creation assistant for textual programming languages | |
JP2008276735A (en) | Program code converter and program code conversion method | |
US9342276B1 (en) | Optimization tracing | |
Combemale et al. | A Solution to the TTC'15 Model Execution Case Using the GEMOC Studio | |
CN101501638B (en) | Plasma processing system component analysis software and methods and systems for creating the same | |
JP2005063136A (en) | Design system, design method, and design program of semiconductor integrated circuit | |
WO2003023612A1 (en) | Computer program having an integrated source code file | |
JP4938991B2 (en) | Program code generating apparatus, program code generating method, and computer program | |
JP2008305337A (en) | Program converter, program conversion method, program, storage medium, debugging device, debugging method and program development system | |
JP2006285584A (en) | Program code generation device, program code generation method, and computer program | |
CN101923466B (en) | Access method of decorator mode order | |
JP2011165051A (en) | Development support device, method and program | |
JP2007226358A (en) | Application generation device, application generation method, and application generation program | |
Randak et al. | Extending ATL for Native UML Profile Support: An Experience Report. | |
Mayerhofer et al. | xMOF: A Semantics Specification Language for Metamodeling. |