WO2002077802A1 - Function executing method, function executing device, computer program and recording medium - Google Patents

Function executing method, function executing device, computer program and recording medium Download PDF

Info

Publication number
WO2002077802A1
WO2002077802A1 PCT/JP2002/002888 JP0202888W WO02077802A1 WO 2002077802 A1 WO2002077802 A1 WO 2002077802A1 JP 0202888 W JP0202888 W JP 0202888W WO 02077802 A1 WO02077802 A1 WO 02077802A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
called
call
recording area
area
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.)
Ceased
Application number
PCT/JP2002/002888
Other languages
English (en)
French (fr)
Inventor
Akishige Yamamoto
Taiichi Yuasa
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.)
Kansai Technology Licensing Organization Co Ltd
Original Assignee
Kansai Technology Licensing Organization Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kansai Technology Licensing Organization Co Ltd filed Critical Kansai Technology Licensing Organization Co Ltd
Priority to EP02705496A priority Critical patent/EP1383044A1/en
Priority to JP2002575788A priority patent/JP3785596B2/ja
Publication of WO2002077802A1 publication Critical patent/WO2002077802A1/ja
Priority to US10/628,133 priority patent/US7130972B2/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms

Definitions

  • a function recording area based on a format of a called function called from a calling function including a process of calling another function is stacked in a stack area in a memory, and the stacking of the function recording area is performed using the stacked function recording area.
  • the present invention relates to a function execution method, a function execution device, a computer program, and a recording medium for executing a function described in an object-oriented language such as a Java language in a JVM (Java Virtual Machine).
  • a function execution method for executing a program including a plurality of functions composed of a plurality of instructions described in an object-oriented language such as the Java language has been used for various purposes.
  • a language is typically compiled into JVM bytecode and then executed in an area in the JVM's memory.
  • FIG. 1 is a conceptual diagram showing a function recording area for recording functions necessary for executing a program.
  • FIG. 1 (a), (b) and (c) show As described above, the functions necessary for the processing of the program call the called function to be executed from the executing call function, and store the function record area of the executing call function secured in the stack area of the memory (file ), A new function recording area based on the format of the called function is secured in a stacked form, the called function is executed using the secured function recording area, and after the execution of the called function is completed. , Discard the stacked function storage area that is no longer needed.
  • the function recording area that records the function that is being executed at the top is called the top frame.
  • function F is being executed, and the function recording area of function F is It becomes a top frame.
  • FIG. 1 (b) when function G is the calling function and another called function H is called, as shown in FIG. 1 (c), the function H is The function recording area for execution is stacked in the stack area to become the top frame.After the execution of function H is completed, the execution result of function H is passed to function G, and the function recording area is discarded and called. The state shown in Fig. 1 (b) is obtained.
  • stacking a large number of function recording areas in the stack area causes a situation in which the stack area overflows, and in some cases, hinders program execution. There is.
  • the present invention has been made in view of such circumstances, and when it is determined that a call by a call function is a tail call, the call function is recorded without stacking a new function recording area.
  • the function recording area as a function recording area for recording the called function, it is possible to reduce the possibility that the function recording area overflows the stack area and hinder the program execution.
  • Function execution method for reducing the processing load required for the above and improving the overall execution speed, a function execution device to which the method is applied, a computer program for realizing the device, and a recording medium on which the computer program is recorded The main purpose is to provide
  • Another object of the present invention is to provide a method for executing a function that does not require a special instruction to be added to a compiler that converts the function into an executable function such as.
  • Another object is to provide a function execution method and the like capable of optimizing a recording area. Disclosure of the invention
  • a function recording area based on a format of a called function called from a calling function including a process of calling another function is stacked in a stack area in a memory, and the stacked function recording is performed.
  • the function execution method of calling the called function using the area executing the called function, and discarding the stacked function recording area, analyzing the calling function executed in the function recording area, When it is determined from the analysis that the call function satisfies a predetermined condition, the function recording area for executing the call function is used as an area for calling the called function.
  • the function recording area of the call function is reused as the recording area of the called function, and the function stored in the stack area is used.
  • a function recording area based on a format of a called function called by executing a calling function including a process of calling another function in a stack area in the memory.
  • the called function is called by using the stacked function recording area, and the called
  • the function execution method for discarding the accumulated function recording area after executing the output function the execution form of the first call function executed in the function recording area is analyzed, and the first call function is determined by the analysis. If it is determined that the above condition is satisfied, a second call function different from the first including a process of using a function recording area for executing the call function as an area for calling the called function is used as the first call function. Execute as an alternative function of.
  • the second call function which is a newly prepared function including the process of reusing the used function record area as the record area of the called function, is called a substitute function of the first call function.
  • the second call function which is a newly prepared function including the process of reusing the used function record area as the record area of the called function, is called a substitute function of the first call function.
  • the above-described processing is described in a language such as Java language.
  • Source code This is performed when executing the first call function of the executable form such as byte code obtained by the filter, so no special consideration is required when creating the source code, and the source code is converted. There is no need to add special instructions to the compiler.
  • the predetermined condition is that an execution result of the called function is an execution result of the called function.
  • the function recording area of the call function is re-recorded as the record area of the called function.
  • a function execution method is the method according to any one of the first invention to the third invention, wherein the function recording area is changed based on a format of the called function when the called function and the called function are different. I do.
  • the function recording area reserved for the called function is changed based on the format of the called function, whereby the called function is changed.
  • the function can be executed without any problem in the function recording area where the called function is reused, and when the calling function and the called function are the same function, the function can be reused without changing the format of the function recording area Therefore, it is possible to eliminate the processing required for changing the format and to improve the overall processing speed.
  • the function execution device has a function recording area based on the format of the called function called from the calling function including the processing for calling another function in the stack area in the memory, and stacks the function recording area.
  • the called function is called using the function recording area, and after executing the called function, the function execution unit that destroys the stacked function recording area analyzes the called function executed in the function recording area.
  • the call by the call function is If it is determined that a predetermined condition such as a tail call whose execution result is the execution result of the calling function is satisfied, the function recording area of the calling function is reused as the recording area of the called function, and By reducing the number of function recording areas stacked in the stack area, it is possible to reduce the possibility that the function recording area overflows the stack area and hinders the execution of the program. The processing load required for stacking and discarding can be reduced, and the overall execution speed can be improved.
  • a function execution device provides a function recording area based on a format of a called function called by executing a calling function including a process of calling another function in a stack area in the memory.
  • Means for analyzing the execution form of the first call function, and a function recording area for executing the call function when the first call function satisfies a predetermined condition by the analysis Means for executing, as an alternative function of the first call function, a second call function different from the first including a process for using the call function as a call area.
  • the function execution device when it is determined that the call by the first call function satisfies a predetermined condition, such as a tail call whose execution result of the called function is the execution result of the call function, the second call function, which is a newly prepared function including the process of reusing the used function recording area as the recording area of the called function, is assumed to be a substitute function of the first call function. And reduce the number of function recording areas that are stacked in the stack area, thus reducing the possibility that the function recording area will overflow the stack area and interfere with program execution. And again The processing load required for stacking and discarding function recording areas can be reduced, and the overall execution speed can be improved.
  • a predetermined condition such as a tail call whose execution result of the called function is the execution result of the call function
  • processing can be performed using source code written in a language such as the Java language. This is performed when executing the first call function of the executable form such as byte code obtained by compiling the source code.Therefore, no special consideration is required when creating the source code. There is no need to add special instructions to the converting compiler.
  • a computer program causes a computer to stack, in a stack area in a memory, a function recording area based on a format of a called function called from a calling function including a process of calling another function.
  • the computer program that causes the called function to be called using the function recording area that has been set, and after the called function has been executed, the accumulated function recording area is discarded, the computer calls the function executed in the function recording area.
  • the function recording area for executing the call function when the computer determines that the call function satisfies a predetermined condition by analyzing the function and the computer is defined as an area for calling the called function. And a procedure for using the information.
  • the execution function is executed by a JVM using a processing device such as a mobile phone or a personal computer, so that the JVM operates as a function execution device.
  • a processing device such as a mobile phone or a personal computer
  • the function recording area of the called function is reused as the recording area of the called function, and the number of function recording areas stacked in the stack area is reduced, so that the function recording area is stacked. It is possible to improve the overall execution speed by reducing the possibility of overflowing the area and hindering program execution, and reducing the processing load required for stacking and destroying the function recording area. is there.
  • a computer program provides a function recording area based on a form of a called function called by executing a calling function including a process of calling another function in a stack area in a memory in a computer.
  • the computer records the function.
  • a second call function different from the first call function including a process for using the function recording area as an area for calling the called function is called the first call function. And a procedure to be executed as an alternative function.
  • the computer program is executed by a JVM using a processing device such as a mobile phone and a personal computer, so that the JVM operates as a function execution device. If it is determined that the call satisfies a predetermined condition such as a tail call in which the execution result of the called function is the execution result of the called function, the used function recording area is re-recorded as the recording area of the called function. Executes the second call function, which is a newly prepared function including the processing to be used, as a substitute function of the first call function, and records the function that is stacked in the stack area.
  • a predetermined condition such as a tail call in which the execution result of the called function is the execution result of the called function
  • the above-described processing can be performed by compiling source code written in a language such as Java language or the like.
  • the first of the executable Since it is performed when the calling function is executed, no special consideration is required when creating the source code, and no special instructions need to be added to the compiler that converts the source code.
  • the computer program according to a ninth invention is based on the seventh invention or the eighth invention, wherein the predetermined condition is that an execution result of the called function is an execution result of the calling function.
  • the call by the call function is a tail call, that is, the execution result of the call function is the execution result of the call function, and after the execution of the call function is completed, the function recording area of the call function is completed. Then, if the function record area of the called function is also a discarded call, a problem may occur with the function record area of the called function as the function record area of the called function. It can be reused without the need.
  • a computer program according to a tenth aspect of the present invention is the computer program according to any one of the seventh to ninth aspects, wherein the function recording area is changed based on a format of the called function when the called function and the called function are different.
  • the function recording area reserved for the calling function is changed based on the format of the called function.
  • the function can be executed without any problem in the function recording area where the called function is reused.
  • the computer-readable recording medium is a computer-readable storage medium that calls another function in a stack area in memory. Function storage area based on the format of the called function called from the calling function that includes the function, the called function is called using the stacked function recording area, and after the called function is executed, stacking is performed. On a computer-readable recording medium on which a computer program for discarding the function recording area is recorded, wherein the computer causes the computer to analyze the call function executed in the function recording area. And a step of, when it is determined by analysis that the calling function satisfies a predetermined condition, using the function recording area for executing the calling function as an area for calling the called function. Program is recorded.
  • the recorded computer program is executed by a JVM using a processing device such as a mobile phone or a personal computer, so that the JVM functions as a function execution device.
  • a processing device such as a mobile phone or a personal computer
  • the JVM functions as a function execution device.
  • the function recording area of the called function is reused as the recording area of the called function, and the function recording area is stacked on the stack area.
  • the computer-readable recording medium is a computer-readable recording medium that is called by executing a call function including a process of calling another function in a stack area in a memory.
  • a computer program that stacks the function recording area based on the function format, calls the called function using the stacked function recording area, and discards the stacked function recording area after executing the called function.
  • a computer program including a procedure for executing the function as an alternative to the first calling function.
  • the recorded computer program is executed by a JVM using a processing device such as a mobile phone or a personal computer, so that the JVM functions as a function execution device. If the call by the first call function satisfies a predetermined condition, such as a tail call where the execution result of the called function is the execution result of the call function, it is determined that Executing the second call function, which is a newly prepared function including the process of reusing the used function recording area as the callee function recording area, as an alternative function to the first call function This reduces the number of function recording areas that can be stacked in the stack area, and reduces the possibility that the function recording area overflows the stack area and hinders program execution.
  • a predetermined condition such as a tail call where the execution result of the called function is the execution result of the call function
  • FIG. 1 is a conceptual diagram showing a function recording area for recording functions necessary for executing a program
  • FIG. 2 is a block diagram showing a function execution device of the present invention
  • FIG. 3 is a diagram showing a function execution method of the present invention.
  • FIG. 4 is a conceptual diagram
  • FIG. 4 is a flowchart showing analysis processing in the function execution method of the present invention
  • FIG. 5 is a flowchart showing execution processing in the function execution method of the present invention
  • FIG. FIG. 7 is a flowchart showing execution processing in the function execution method of the present invention.
  • FIG. 7 is a graph showing the processing speed of the function execution method of the present invention and the conventional function execution method.
  • FIG. 2 is a block diagram showing a function execution device according to the present invention.
  • reference numeral 10 denotes a function execution device of the present invention using a processing device such as a mobile phone or a personal computer.
  • Function execution device 10 is a computer program PG for the function execution device of the present invention and information such as data.
  • Storage means 12 to read information such as computer programs PG and data from recording media REC such as CD-ROM and memory card on which data is recorded.
  • Computer programs PG and data read by auxiliary storage means 12.
  • recording means 13 for recording information such as a hard disk, and memory means 14 for temporarily recording various information.
  • the function execution device 10 includes a communication means 15 such as a modem, a TA (Terminal Adapter), and an antenna, and is connected to a communication network NW such as the Internet by the communication means 15.
  • Information such as the computer program PG of the present invention and data recorded on the recording medium 21 provided in the recording device 20 such as a web server computer connected to the communication network NW may be executed. Les ,. Next, processing contents of the function execution method of the present invention will be described.
  • the function execution method of the present invention is obtained by compiling source code written in a language such as Java into an execution format such as a byte code of a JVM using a general-purpose compiler.
  • the present invention is applied to a method of executing a program including a plurality of functions composed of a plurality of instructions.
  • the stack area in the memory means 14 includes the number of arguments for the function to be executed and the local variable area.
  • a function execution method is based on stacking function recording areas based on the format such as the size of a function, and calling and executing functions in the stacked function recording areas.
  • FIG. 3 is an explanatory view conceptually showing the function execution method of the present invention.
  • Fig. 3 (a) shows the state in which the executable function F is executed in the function recording area secured in the stack function area.
  • the execution result of the function H is related.
  • the tail call results in the execution of the number G, as shown in Fig. 3 (c)
  • the function record in which the function G is recorded without a new function recording area for the function H is accumulated.
  • the area is a function recording area for calling function H.
  • a new function recording area is first secured, and the functions to be called are called functions such as invo Kestatic ;, invokevirtual ⁇ invokesecia1, and invokeinterface.
  • the calling function includes an instruction to be called, the execution format of the calling function is analyzed (S101), and the analysis indicates that the execution result of the called function is the execution result of the calling function. If it is determined that the function is the last call function that satisfies the condition (S102: Y), it is further determined whether the call function and the called function are the same (S103). ).
  • step S103 if the called function and the called function are different, When it is determined (S103: N), a recursive alternative function (second call function) in which the call function (first call function) is replaced with an instruction that prepares an instruction to call the called function in advance is prepared. ) (S104). When it is determined that the called function and the called function are the same (S103: Y), an instruction to call the called function (first calling function) that is the same as the calling function is prepared in advance. Replace with the self-recursive alternative function (second calling function) that has been replaced with the alternative instruction being used (S105).
  • Step S 1 0 2 when it is judged not to be the last call function (S 1 0 2: N) , Step S 1 0 3 ⁇ S 1 0 5 is processing performed such Rere 0
  • step S104 As the recursive alternative function shown in step S104 and the self-recursive alternative function shown in step S105 used as an alternative function of the calling function, a function including the following new instructions is prepared. Keep it.
  • FIGS. 5 and 6 are flowcharts showing execution processing in the function execution method of the present invention.
  • the called function is called from the recursive alternative function (second calling function) that is being executed as the calling function (first calling function) by processing using an alternative instruction such as tailinvokestatic included in the alternative function.
  • the function recording area where the recursive substitution function was executed is changed based on the format of the called function without adding a new function recording area.
  • Update (S205) use the function recording area with the changed format as the area to call the called function (S206), call the called function (S207), and call
  • the called function is executed (S208), and after executing the called function, the function recording area used for executing the called function is discarded (S209).
  • step S201 If it is determined in step S201 that the function is a self-recursive alternative function (S201: 2), a function recording area based on the format of the self-recursive alternative function (second calling function) is accumulated (S2 1 0), call the self-recursive alternative function using the accumulated function recording area (S 2 1 1), and execute the self-recursive alternative function in the function recording area accumulated in step 210 (S 2 1 2).
  • the self-recursive alternative function included in the self-recursive alternative function is used to execute the self-recursive alternative function (second call function) executed as the call function (first call function).
  • second call function the function recording area where the self-recursive alternative function was executed is used as the area to call the called function without stacking up a new function recording area (S 21). 3), call the called function (S2 14), execute the called function (S2 15), and after executing the called function, discard the function recording area used for executing the called function Yes (S2 16).
  • step S201 If it is determined in step S201 that the function is not a substitute function (S201: 3), the function recording area based on the form of the calling function is accumulated (S2177), and the accumulated function recording area is used. The calling function is called (S218), and the calling function is executed in the function recording area accumulated in step 217 (S219).
  • the horizontal axis shows the call depth of the tail calling function
  • the vertical axis shows the processing time in units of microseconds (us).
  • Each time a call function is called the function record area is accumulated.
  • the relationship between the call depth and the processing time by the conventional execution method is shown.
  • the seal mark reuses the function record area when the call function is the tail call.
  • the processing time of the function execution method of the present invention is shorter than that of the conventional function execution method, and the tendency is particularly remarkable in the self-tail calling function.
  • JIT Just In Time Compiler
  • the byte code of the JVM is converted into a machine language by the JIT technology.
  • the speed of the execution process can be improved.
  • the calling function is tail-call or self-tail-call.
  • the alternative function is used.However, the present invention is not limited to this.Tail recursion is determined each time the function is executed, and tail recursion is performed when it is determined that tail recursion is performed. You may do it. Industrial applicability
  • a mobile phone and a personal computer execute a program described in a language such as Java language and including a plurality of functions.
  • a processing device such as the above
  • the process of calling another function in the stack area in memory is called by the call function, and the execution result of the called function is the execution result of the called function.
  • the function recording area of the called function is reused as the recording area of the called function, and the function recording area of the function recording area stacked in the stack area is reused. Reducing the number reduces the possibility that the function recording area overflows the stack area and hinders the execution of the program.
  • the calling function and the called function are different, By changing the function recording area reserved for the function based on the format of the called function, it is possible to execute the function in the function recording area that reuses the called function without any problem.
  • the called function and the called function are the same function, they are reused without changing the format of the function recording area, thus eliminating the processing required to change the format and improving the overall processing speed. It has excellent effects, such as being able to cause

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Executing Machine-Instructions (AREA)

Description

明 細 書
関数実行方法、 関数実行装置、 コンピュータプログラム、 及び記録 媒体 技術分野
本発明は、 メモリ 中のスタ ック領域に、 他の関数を呼び出す処理 を含む呼出関数から呼び出される被呼出関数の形式に基づく 関数記 録領域を積み上げ、 積み上げた関数記録領域を利用して被呼出関数 を呼び出し、 呼び出された被呼出関数の実行後、 当該関数記録領域 を破棄する関数実行方法、 その方法を適用した関数実行装置、 その 装置を実現するためのコンピュータプログラム、 及びそのコンビュ ータプログラムを記録した記録媒体に関し、 特に J V M (Java Virtual Machine)にて J a v a言語等のオブジェク ト指向の言語にて 記述された関数を実行する関数実行方法、 関数実行装置、 コンビュ ータプログラム、 及び記録媒体に関する。
背景技術
J a V a言語等のオブジェク ト指向の言語にて記述された複数の 命令からなる関数を複数含むプログラムを実行する関数実行方法が 近年様々な用途で利用されており、 またこのよ うな J a v a言語は 一般的に J V Mのバイ トコー ドにコンパイルされてから J V Mのメ モリ 中の領域にて実行される。
第 1図はプログラムの実行に必要な関数を記録する関数記録領域 を示す概念図である。
プログラムは、 一般に関数 (メ ソッ ド) の呼び出しが入れ子状態 になって実行される。 即ち第 1図 ( a ) , ( b ) , ( c ) に示すよ うにプログラムの処理に必要な関数は、 実行中の呼出関数から実行 すべき被呼出関数を呼び出して、 メ モ リ 中のスタ ツク領域に確保さ れた実行中の呼出関数の関数記録領域 (フ レーム) に、 被呼出関数 の形式に基づく新たな関数記録領域を積み上げる形で確保し、 確保 された関数記録領域を利用して呼び出された被呼出関数を実行し、 被呼出関数の実行完了後、 積み上げられている不要になった関数記 録領域を破棄する。
最上位に積み上げられた実行中の関数を記録している関数記録領 域は、 ト ップフ レームと呼ばれ、 第 1 図 ( a ) では関数 Fが実行中 であり、 関数 Fの関数記録領域が ト ップフ レームとなる。
この関数 Fを呼出関数と して、 被呼出関数である関数 Gが呼び出 されると、 第 1図 ( b ) に示すよ うに、 関数 Gを実行するための関 数記録領域がスタ ック領域に積み上げられて ト ップフ レームとな り、 関数 Gの実行完了後、 関数 Gの実行結果を関数 Fに渡し、 当該 関数記録領域は破棄されて、 呼び出し前の第 1図 ( a ) の状態とな る。
なお第 1図 ( b ) において、 関数 Gを呼出関数と して、 更に他の 被呼出関数である関数 Hが呼び出されたときは、 第 1図 ( c ) に示 すよ うに、 関数 Hを実行するための関数記録領域がスタ ック領域に 積み上げられて トップフ レームとなり、 関数 Hの実行完了後、 関数 Hの実行結果を関数 Gに渡し、 当該関数記録領域は破棄されて、 呼 び出し前の第 1 図 ( b ) の状態となる。
このとき呼出関数である関数 Gによ り呼び出された被呼出関数で ある関数 Hの実行結果を関数 Gの実行結果と して関数 Fに渡す場 合、 関数 Hの呼び出しを末尾呼び出しと呼び、 末尾呼び出しでは関 数 Hの実行完了後、 関数 H及び関数 Gの関数記録領域は連続して破 棄されることになる。
しかしながらスタ ック領域に数多く の関数記録領域を積み上げて いく ことによ り、 スタ ック領域をオーバーフローするという状況を 引き起こ し、 場合によってはプログラムの実行に支障を来すことが ある という問題がある。
また関数記録領域の積み上げ及び破棄に要する処理負荷が、 全体 の実行速度の低下を招く という問題がある。
本発明は斯かる事情に鑑みてなされたものであり、 呼出関数によ る呼び出しが末尾呼び出しであると判断した場合に、 新たな関数記 録領域を積み上げることなく 、 呼出関数が記録されている関数記録 領域を、 被呼出関数を記録する関数記録領域と して利用すること で、 関数記録領域がスタック領域をオーバーフローしてプログラム の実行に支障を来す可能性を低減し、 また積み上げ及び破棄に要す る処理負荷を低減し、 全体の実行速度を向上させる関数実行方法、 その方法を適用した関数実行装置、 その装置を実現するためのコン ピュータプログラム、 及びそのコンピュータプログラムを記録した 記録媒体の提供を主たる目的とする。
さ らに J V Mのバイ トコ一ド等の実行形式の呼出関数を実行する 際に、 上述した関数記録領域を再利用する処理を、 実行すべき呼出 関数を予め準備している代替関数に代替し、 代替された代替関数を 実行することによ り実現するので、 J a v a言語等の言語によるソ —スコ一ドの作成時には特別な配慮を行う必要が無く、 またソース コー ドをバイ トコ一ド等の実行形式の関数に変換するコンパイラに 特別な命令を追加する必要が無い関数実行方法等の提供を他の目的 とする。
また呼出関数及び被呼出関数が同じ場合には、 確保されている関 数記録領域をそのまま利用し、 呼出関数及び被呼出関数が異なる場 合には、 確保されている関数記録領域を被呼出関数の形式に基づい て変更することにより、 全体の処理負荷の軽減及び関数記録領域の 適正化を行う ことが可能な関数実行方法等の提供を他の目的とす る。 発明の開示
第 1発明の関数実行方法は、 メモリ 中のスタ ック領域に、 他の関 数を呼び出す処理を含む呼出関数から呼び出される被呼出関数の形 式に基づく 関数記録領域を積み上げ、 積み上げた関数記録領域を利 用して被呼出関数を呼び出し、 呼び出された被呼出関数の実行後、 積み上げた関数記録領域を破棄する関数実行方法において、 関数記 録領域で実行される呼出関数を解析し、 該解析によ り呼出関数が所 定の条件を満足すると判断した場合に、 呼出関数を実行する前記関 数記録領域を、 被呼出関数を呼び出す領域と して利用する。
第 1発明の関数実行方法では、 呼出関数が所定の条件を満足した 場合に、 呼出関数の関数記録領域を被呼出関数の記録領域と して再 利用して、 スタ ック領域に積み上げられる関数記録領域の数を低减 することで、 関数記録領域がスタ ック領域をオーバーフ ローしてプ 口グラムの実行に支障を来す可能性を低減し、 また関数記録領域の 積み上げ及び破棄に要する処理負荷を低減して、 全体の実行速度を 向上させることが可能である。
第 2発明の関数実行方法は、 メモ リ 中のスタ ック領域に、 他の関 数を呼び出す処理を含む呼出関数を実行することによ り呼び出され る被呼出関数の形式に基づく 関数記録領域を積み上げ、 積み上げた 関数記録領域を利用して被呼出関数を呼び出し、 呼び出された被呼 出関数の実行後、 積み上げた関数記録領域を破棄する関数実行方法 において、 関数記録領域で実行される第 1の呼出関数の実行形式を 解析し、 該解析によ り第 1の呼出関数が所定の条件を満足すると判 断した場合に、 呼出関数を実行する関数記録領域を、 被呼出関数を 呼び出す領域と して利用させる処理を含む第 1 と異なる第 2の呼出 関数を第 1の呼出関数の代替関数と して実行する。
第 2発明の関数実行方法では、 第 1 の呼出関数による呼び出し が、 被呼出関数の実行結果を呼出関数の実行結果とする末尾呼び出 しである等の所定の条件を満足すると判断した場合に、 利用した関 数記録領域を被呼出関数の記録領域と して再利用する処理を含む新 たに用意された関数である第 2の呼出関数を、 .第 1 の呼出関数の代 替関数と して実行し、 これによ りスタ ック領域に積み上げられる関 数記録領域の数を低減して、 関数記録領域がスタック領域をオーバ —フローしてプログラムの実行に支障を来す可能性を低減し、 また 関数記録領域の積み上げ及び破棄に要する処理負荷を低減して、 全 体の実行速度を向上させることが可能であり、 しかも上述した処理 は J a v a言語等の言語によ り記述されたソースコー ドをコンパィ ルして得られたバイ トコー ド等の実行形式の第 1の呼出関数を実行 する際に行われるので、 ソースコー ドの作成時には特別な配慮を行 う必要が無く、 またソースコードを変換するコンパイ ラに特別な命 令を追加する必要がない。
第 3発明の関数実行方法は、 第 1発明又は第 2発明において、 前 記所定の条件は、 被呼出関数の実行結果が呼出関数の実行結果とな ることである。
第 3発明の関数実行方法では、 呼出関数が所定の条件を満足した 場合に、 呼出関数の関数記録領域を被呼出関数の記録領域と して再 利用して、 スタ ツク領域に積み上げられる関数記録領域の数を低減 することで、 関数記録領域がスタ ック領域をオーバーフローしてプ 口グラムの実行に支障を来す可能性を低減し、 また関数記録領域の 積み上げ及び破棄に要する処理負荷を低減して、 全体の実行速度を 向上させることが可能である。
第 4発明の関数実行方法は、 第 1発明乃至第 3発明のいずれかに おいて、 前記呼出関数及び被呼出関数が異なるときに、 被呼出関数 の形式に基づいて、 前記関数記録領域を変更する。
第 4発明の関数実行方法では、 呼出関数及び被呼出関数が異なる ときに、 呼出関数のために確保されている関数記録領域を被呼出関 数の形式に基づいて変更することによ り、 被呼出関数を再利用した 関数記録領域にて問題なく実行することが可能であり、 また呼出関 数及び被呼出関数が同じ関数であるときには、 関数記録領域の形式 を変更することなく、 そのまま再利用するので形式の変更に要する 処理を無く し、 全体と しての処理速度を向上させることが可能であ る。
第 5発明の関数実行装置は、 メモ リ 中のスタ ック領域に、 他の関 数を呼び出す処理を含む呼出関数から呼び出された被呼出関数の形 式に基づく関数記録領域を積み上げ、 積み上げた関数記録領域を利 用して被呼出関数を呼び出し、 呼び出された被呼出関数の実行後、 積み上げた関数記録領域を破棄する関数実行装置において、 関数記 録領域で実行される呼出関数を解析する手段と、 該解析によ り呼出 関数が所定の条件を満足すると判断した場合に、 呼出関数を実行す る前記関数記録領域を、 被呼出関数を呼び出す領域と して利用する 手段とを備える。
第 5発明の関数実行装置では、 呼出関数による呼び出しが、 被呼 出関数の実行結果を呼出関数の実行結果とする末尾呼び出しである 等の所定の条件を満足すると判断した場合に、 呼出関数の関数記録 領域を被呼出関数の記録領域と して再利用し、 スタ ツク領域に積み 上げられる関数記録領域の数を低减することで、 関数記録領域がス タック領域をオーバーフローしてプログラムの実行に支障を来す可 能性を低減し、 また関数記録領域の積み上げ及び破棄に要する処理 負荷を低減して、 全体の実行速度を向上させることが可能である。 第 6発明の関数実行装置は、 メモ リ 中のスタ ック領域に、 他の関 数を呼び出す処理を含む呼出関数を実行することによ り呼び出され る被呼出関数の形式に基づく 関数記録領域を積み上げ、 積み上げた 関数記録領域を利用して被呼出関数を呼び出し、 呼び出された被呼 出関数の実行後、 積み上げた関数記録領域を破棄する関数実行装置 において、 関数記録領域で実行される第 1 の呼出関数の実行形式を 解析する手段と、 該解析によ り第 1 の呼出関数が所定の条件を満足 する と判断した場合に、 呼出関数を実行する関数記録領域を、 被呼 出関数を呼び出す領域と して利用させる処理を含む第 1 と異なる第 2の呼出関数を第 1の呼出関数の代替関数と して実行する手段とを 備える。
第 6発明の関数実行装置では、 第 1 の呼出関数による呼び出し が、 被呼出関数の実行結果を呼出関数の実行結果とする末尾呼び出 しである等の所定の条件を満足すると判断した場合に、 利用した関 数記録領域を被呼出関数の記録領域と して再利用する処理を含む新 たに用意された関数である第 2の呼出関数を、 第 1 の呼出関数の代 替関数と して実行し、 これによ り スタ ック領域に積み上げられる関 数記録領域の数を低減して、 関数記録領域がスタック領域をオーバ —フロー してプロダラムの実行に支障を来す可能性を低減し、 また 関数記録領域の積み上げ及び破棄に要する処理負荷を低減して、 全 体の実行速度を向上させることが可能であり、 しかも上述した処理 は J a V a言語等の言語によ り記述されたソースコー ドをコンパイ ルして得られたバイ トコー ド等の実行形式の第 1の呼出関数を実行 する際に行われるので、 ソースコー ドの作成時には特別な配慮を行 う必要が無く、 またソースコー ドを変換するコンパイラに特別な命 令を追加する必要がない。
第 7発明のコ ンピュータプログラムは、 コンピュータに、 メモリ 中のスタ ック領域に、 他の関数を呼び出す処理を含む呼出関数から 呼び出される被呼出関数の形式に基づく 関数記録領域を積み上げさ せ、 積み上げた関数記録領域を利用して被呼出関数を呼び出させ、 呼び出された被呼出関数の実行後、 積み上げた関数記録領域を破棄 させるコ ンピュータプログラムにおいて、 コンピュータに、 関数記 録領域で実行される呼出関数を解析させる手順と、 コ ンピュータ に、 解析によ り呼出関数が所定の条件を満足すると判断した場合 に、 呼出関数を実行する前記関数記録領域を、 被呼出関数を呼び出 す領域と して利用させる手順とを含む。
第 7発明のコ ンピュータプログラムでは、 携帯電話及びパーソナ ルコンピュータ等の処理装置を用いた J V Mにて実行することで、 J V Mが関数実行装置と して動作することによ り、 呼出関数が所定 の条件を満足した場合に、 呼出関数の関数記録領域を被呼出関数の 記録領域と して再利用し、 スタ ック領域に積み上げられる関数記録 領域の数を低減することで、 関数記録領域がスタック領域をオーバ 一フロー してプログラムの実行に支障を来す可能性を低減し、 また 関数記録領域の積み上げ及び破棄に要する処理負荷を低減して、 全 体の実行速度を向上させることが可能である。 第 8発明のコンピュータプログラムは、 コンピュータに、 メモリ 中のスタ ック領域に、 他の関数を呼び出す処理を含む呼出関数を実 行することによ り呼び出される被呼出関数の形式に基づく関数記録 領域を積み上げさせ、 積み上げた関数記録領域を利用 して被呼出関 数を呼び出させ、 呼び出された被呼出関数の実行後、 積み上げた関 数記録領域を破棄させるコンピュータプログラムにおいて、 コンビ ユータに、 関数記録領域で実行される第 1 の呼出関数の実行形式を 解析させる手順と、 コンピュータに、 解析によ り第 1 の呼出関数が 所定の条件を満足する と判断した場合に、 呼出関数を実行する前記 関数記録領域を、 被呼出関数を呼び出す領域と して利用させる処理 を含む第 1 と異なる第 2の呼出関数を、 第 1の呼出関数の代替関数 と して実行させる手順とを含む。
第 8発明のコンピュータプログラムでは、 携帯電話及びパーソナ ルコンピュータ等の処理装置を用いた J V Mにて実行することで、 J V Mが関数実行装置と して動作することによ り、 第 1の呼出関数 による呼び出しが、 被呼出関数の実行結果を呼出関数の実行結果と する末尾呼び出しである等の所定の条件を満足すると判断した場合 に、 利用 した関数記録領域を被呼出関数の記録領域と して再利用す る処理を含む新たに用意された関数である第 2の呼出関数を、 第 1 の呼出関数の代替関数と して実行し、 これによ りスタ ック領域に積 み上げられる関数記録領域の数を低減して、 関数記録領域がスタ ッ ク領域をオーバーフローしてプログラムの実行に支障を来す可能性 を低減し、 また関数記録領域の積み上げ及び破棄に要する処理負荷 を低減して、 全体の実行速度を向上させることが可能であり、 しか も上述した処理は J a v a言語等の言語によ り記述されたソースコ ー ドをコンパイルして得られたバイ トコ一 ド等の実行形式の第 1 の 呼出関数を実行する際に行われるので、 ソース コー ドの作成時には 特別な配慮を行う必要が無く 、 またソースコー ドを変換するコンパ イラに特別な命令を追加する必要がない。
第 9発明のコ ンピュータプログラムは、 第 7発明又は第 8発明に おいて、 前記所定の条件は、 被呼出関数の実行結果が呼出関数の実 行結果となるこ とである。
第 9発明のコ ンピュータプログラムでは、 呼出関数による呼び出 しが末尾呼び出し、 即ち被呼出関数の実行結果が呼出関数の実行結 果となり、 被呼出関数の実行完了後、 被呼出関数の関数記録領域に 続いて、 呼出関数の関数記録領域も破棄される呼び出しであること を条件とするこ とによ り、 呼出関数の関数記録領域を被呼出関数の 関数記録領域と して問題を発生することなく再利用することが可能 である。
第 1 0発明のコンピュータプログラムは、 第 7発明乃至第 9発明 のいずれかにおいて、 前記呼出関数及び被呼出関数が異なる とき に、 被呼出関数の形式に基づいて、 前記関数記録領域を変更する。 第 1 0発明のコンピュータプログラムでは、 呼出関数及び被呼出 関数が異なる関数であるときに、 呼出関数のために確保されている 関数記録領域を被呼出関数の形式に基づいて変更することによ り、 被呼出関数を再利用した関数記録領域にて問題なく実行することが 可能であり、 また呼出関数及び被呼出関数が同じ関数である ときに は、 関数記録領域の形式を変更することなく 、 そのまま再利用する ので形式の変更に要する処理を無く し、 全体と しての処理速度を向 上させることが可能である。
第 1 1発明のコンピュータでの読み取りが可能な記録媒体は、 コ ンピュータに、 メモ リ 中のスタ ック領域に、 他の関数を呼び出す処 理を含む呼出関数から呼び出される被呼出関数の形式に基づく 関数 記録領域を積み上げさせ、 積み上げた関数記録領域を利用して被呼 出関数を呼び出させ、 呼び出された被呼出関数の実行後、 積み上げ た関数記録領域を破棄させるコンピュータプログラムを記録してあ る、 コンピュータでの読み取りが可能な記録媒体において、 コンビ ユ ータに、 関数記録領域で実行される呼出関数を解析させる手順 と、 コンピュータに、 解析によ り呼出関数が所定の条件を満足する と判断した場合に、 呼出関数を実行する前記関数記録領域を、 被呼 出関数を呼び出す領域と して利用させる手順と、 を含むコンビユ ー タプログラムを記録してある。
第 1 1発明のコンピュータでの読み取りが可能な記録媒体では、 記録されているコンピュータプログラムを携帯電話及びパーソナル コンピュータ等の処理装置を用いた J V Mにて実行することで、 J V Mが関数実行装置と して動作することによ り 、 呼出関数が所定の 条件を満足した場合に、 呼出関数の関数記録領域を被呼出関数の記 録領域と して再利用し、 スタック領域に積み上げられる関数記録領 域の数を低減することで、 関数記録領域がスタ ック領域をオーバー フ ローしてプログラムの実行に支障を来す可能性を低減し、 また関 数記録領域の積み上げ及び破棄に要する処理負荷を低減して、 全体 の実行速度を向上させることが可能である。
第 1 2発明のコンピュータでの読み取りが可能な記録媒体は、 コ ンピュータに、 メモ リ 中のスタック領域に、 他の関数を呼び出す処 理を含む呼出関数を実行することによ り呼び出される被呼出関数の 形式に基づく関数記録領域を積み上げさせ、 積み上げた関数記録領 域を利用 して被呼出関数を呼び出させ、 呼び出された被呼出関数の 実行後、 積み上げた関数記録領域を破棄させるコンピュータプログ ラムを記録してある、 コンピュータでの読み取りが可能な記録媒体 において、 コンピュータに、 関数記録領域で実行される第 1 の呼出 関数の実行形式を解析させる手順と、 コンピュータに、 解析によ り 第 1の呼出関数が所定の条件を満足すると判断した場合に、 呼出関 数を実行する前記関数記録領域を、 被呼出関数を呼び出す領域と し て利用させる処理を含む第 1 と異なる第 2の呼出関数を、 第 1の呼 出関数の代替関数と して実行させる手順とを含むコンピュータプロ グラムを記録してある。
第 1 2発明のコンピュータでの読み取りが可能な記録媒体では、 記録されているコンピュータプログラムを携帯電話及びパーソナル コンピュータ等の処理装置を用いた J V Mにて実行することで、 J V Mが関数実行装置と して動作するこ とによ り 、 第 1 の呼出関数に よる呼び出しが、 被呼出関数の実行結果を呼出関数の実行結果とす る末尾呼び出しである等の所定の条件を満足すると判断した場合 に、 利用した関数記録領域を被呼出関数の記録領域と して再利用す る処理を含む新たに用意された関数である第 2の呼出関数を、 第 1 の呼出関数の代替関数と して実行し、 これによ りスタック領域に積 み上げられる関数記録領域の数を低減して、 関数記録領域がスタツ ク領域をオーバーフローしてプロダラムの実行に支障を来す可能性 を低減し、 また関数記録領域の積み上げ及び破棄に要する処理負荷 を低減して、 全体の実行速度を向上させることが可能であり、 しか も上述した処理は J a v a言語等の言語によ り記述されたソースコ 一ドをコンパイルして得られたバイ トコー ド等の実行形式の第 1の 呼出関数を実行する際に行われるので、 ソースコー ドの作成時には 特別な配慮を行う必要が無く 、 またソースコー ドを変換するコンパ ィラに特別な命令を追加する必要がない。 図面の簡単な説明
第 1図はプログラムの実行に必要な関数を記録する関数記録領域 を示す概念図、 第 2図は本発明の関数実行装置を示すプロ ック図、 第 3図は本発明の関数実行方法を概念的に示す説明図、 第 4図は本 発明の関数実行方法における解析処理を示すフローチャー ト、 第 5 図は本発明の関数実行方法における実行処理を示すフローチヤ一 ト、 第 6図は本発明の関数実行方法における実行処理を示すフロー チャー ト、 第 7図は本発明の関数実行方法及び従来の関数実行方法 の処理速度を示すグラフである。 発明を実施するための最良の形態
以下、 本発明をその実施の形態を示す図面に基づいて詳述する。 第 2図は本発明の関数実行装置を示すブロ ック図である。
図中 1 0は携帯電話及びパーソナルコンピュータ等の処理装置を 用いた本発明の関数実行装置であり、 関数実行装置 1 0は、 本発明 の関数実行装置用のコンピュータプログラム P G及びデータ等の情 報を記録した C D— R O M及びメモ リ カー ド等の記録媒体 R E Cか らコンピュータプログラム P G及びデータ等の情報を読み取る補助 記憶手段 1 2、 補助記憶手段 1 2によ り読み取られたコンピュータ プログラム P G及びデータ等の情報を記録するハー ドディスク等の 記録手段 1 3、 並びに各種情報を一時的に記録するメモリ手段 1 4 を備えている。
そして記録手段 1 3からコンピュータプログラム P G及びデータ 等の情報を読み取り、 メモリ手段 1 4に記録して C P U 1 1 によ り 実行することで、 処理装置 (コンピュータ) は本発明の関数実行装 置 1 0 と して動作する。
また関数実行装置 1 0は、 モデム、 T A (Terminal Adapter)、 及び アンテナ等の通信手段 1 5を備えており、 通信手段 1 5によ りイン ターネッ ト等の通信ネッ トワーク N Wに接続して、 通信ネッ トヮー ク N Wに接続するウェブサーバコンピュータ等の記録装置 2 0が備 える記録媒体 2 1 に記録された本発明のコンピュータプログラム P G及びデータ等の情報を取り込み、 実行するよ うにしてもよレ、。 次に本発明の関数実行方法の処理内容を説明する。
本発明の関数実行方法は、 J a v a言語等の言語にて記述された ソースコー ドを、 汎用性のコンパイラを用いて J V Mのバイ ト コ一 ド等の実行形式にコンパイルすることによ り得られた複数の命令か らなる関数を複数含むプログラムを実行する方法に適用されるもの であり 、 メモ リ手段 1 4中のスタツク領域に、 実行すべき関数につ いての引数の個数及びローカル変数領域の大きさ等の形式に基づく 関数記録領域を積み上げ、 積み上げた関数記録領域に、 関数を呼び 出して実行する関数実行方法を基本とする。
第 3図は本発明の関数実行方法を概念的に示す説明図である。 第 3図 ( a ) はスタ ック関数領域に確保された関数記録領域にて 実行形式の関数 Fが実行されている状態を示す。
そして関数記録領域にて実行される関数 Fを呼出関数と し、 関数 Fに呼び出される被呼出関数である実行形式の関数 Gを呼び出す場 合、 第 3図 ( b ) に示すよ うに関数 Fの関数記録領域に、 関数 Gを 呼び出すための関数記録領域を新たに積み上げ、 積み上げた関数記 録領域を利用して関数 Gを呼び出し実行する。
さ らに関数 Gを呼出関数と し、 関数 Gに呼び出される被呼出関数 である実行形式の関数 Hを呼び出す場合で、 関数 Hの実行結果が関 数 Gの実行結果となる末尾呼出である ときに、 第 3図 ( c ) に示す よ うに関数 Hのための関数記録領域を新たに積み上げることなく、 関数 Gが霄己録されている関数記録領域を、 関数 Hを呼び出すための 関数記録領域とする。
そして関数 Hの実行結果は関数 Fに渡され、 関数 Hを実行した関 数記録領域は破棄される。
次に本発明の関数実行方法における解析処理を第 4図に示すフ口 一チャー トを用いて説明する。
J V M等のバイ トコー ドによる関数を実行するにあたり、 先ず新 たに関数記録領域を確保し、 そして呼び出すべき関数が、 i n v o K e s t a t i c;、 i n v o k e v i r t u a l ^ i n v o k e s e c i a 1 、 及び i n v o k e i n t e r f a c e等の被'呼出関 数を呼び出す命令を含む呼出関数である場合に、 当該呼出関数の実 行形式を解析し ( S 1 0 1 ) 、 解析によ り、 呼出関数が、 被呼出関 数の実行結果が呼出関数の実行結果となるという条件を満足する末 尾呼出関数であると判断したときに ( S 1 0 2 : Y) 、 更に呼出関 数及び被呼出関数が同じであるか否かを判別する ( S 1 0 3 ) 。
なおステップ S 1 0 2において末尾呼出関数である と判断する基 準の J a v a言語における具体例と しては、 被呼出関数を呼び出す 命令の直後に任意個のプログラムカ ウンタ以外を変化させない n o p及び g o t o等の命令を挟んで復帰命令があり、 被呼出関数の戻 り愜の型と、 i r e t u r n、 1 r e t u r n、 f r e t u r n、 d r e t u r n、 a r e t u r n 及び r e t u r n等の復帰命令 の型とがー致し、 被呼出関数を呼び出す命令から復帰命令の間に例 外ハンドラが設定されていない等の基準がある。
ステップ S 1 0 3において、 呼出関数及び被呼出関数が異なると 判別したとき ( S 1 0 3 : N) 、 当該呼出関数 (第 1 の呼出関数) を、 被呼出関数を呼び出す命令を予め用意している代替命令に置換 した再帰代替関数 (第 2の呼出関数) に置換する ( S 1 0 4 ) 。 呼出関数及び被呼出関数が同じであると判別したとき ( S 1 0 3 : Y) 当該呼出関数 (第 1 の呼出関数) を、 呼出関数と同じであ る被呼出関数を呼び出す命令を予め用意している代替命令に置換し た自己再帰代替関数 (第 2の呼出関数) に置換する ( S 1 0 5 ) 。
なお置換すべき命令が複数個含まれる場合、 該当する全ての命令 を置換した関数に置換される。
ステップ S 1 0 2において、 末尾呼出関数でないと判断したとき ( S 1 0 2 : N) 、 ステップ S 1 0 3〜 S 1 0 5の処理は行われな レヽ 0
なお呼出関数の代替関数と して用いられるステップ S 1 0 4に示 す再帰代替関数及びステップ S 1 0 5に示す自己再帰代替関数と し て、 以下に示す新たな命令を含む関数を用意しておく。
即ち、
i n v o k e s t a t i c、
i n v o k e v i r t u a l N
i n v o k e s p e c i a l 、
及ひ i n v o k e i n t e r l a c e
等の呼出命令を含む呼出関数の再帰代替関数と して、
t a l 1 i n v o k e s t a t i c、
t a l 1 i n v o k e v ι r t u a 1 N
t a i 1 i n v o k e s p e c i a l N
及び t a i 1 i n v o k e i n t e r f a c e
等の代替命令を用意し、 用意した代替命令を含む再帰代替関数を '用いる。
また自己再帰代替関数と して、
s e 丄 f t a 1 1 i n v o k e s t a t i c
s e l f t a l l i n v o k e v i r t u a l ^
及び s e l f t a i 1 i n v o k e i n t e r f a c e 等の代替命令を用意し、 用意した代替命令を含む自己再帰代替関 数を用いる。
これらの命令を含む関数は、 解析処理では置換されるだけであ り、 実際に実行されるのは、 置換された関数を実行する実行処理に おいてであるので、 以下の実行処理の説明にてその機能を説明す る。
図 5及び図 6は本発明の関数実行方法における実行処理を示すフ ローチャー トである。
実行形式の解析処理によ り必要に応じて置換がなされた関数を実 行する場合、 先ず実行すべき呼出関数が、 代替関数である再帰代替 関数或いは自己再帰代替関数、 又は代替関数で無いかを判別し ( S 2 0 1 ) 、 再帰代替関数であると判断した場合 ( S 2 0 1 : 1 ) 、 再帰代替関数 (第 2の呼出関数) の形式に基づく関数記録領域を積 み上げ ( S 2 0 2 ) 、 積み上げた関数記録領域を利用して再帰代替 関数を呼び出し ( S 2 0 3 ) 、 ステップ S 2 0 2にて積み上げた関 数記録領域にて再帰代替関数を実行する ( S 2 0 4 )
そして代替関数に含まれる t a i l i n v o k e s t a t i c等 の代替命令による処理によ り、 呼出関数 (第 1 の呼出関数) と して 実行している再帰代替関数 (第 2の呼出関数) から被呼出関数を呼 び出す場合に、 新たに関数記録領域を積み上げることなく、 再帰代 替関数を実行した関数記録領域を、 被呼出関数の形式に基づいて変 更し ( S 2 0 5 ) 、 形式を変更した関数記録領域を、 被呼出関数を 呼び出す領域と して利用して ( S 2 0 6 ) 、 被呼出関数を呼び出し ( S 2 0 7 ) 、 呼び出した被呼出関数を実行し ( S 2 0 8 ) 、 被呼 出関数の実行後、 被呼出関数の実行に利用した関数記録領域を破棄 する ( S 2 0 9 ) 。
ステップ S 2 0 1 において、 自己再帰代替関数であると判断した 場合 ( S 2 0 1 : 2 ) 、 自己再帰代替関数 (第 2の呼出関数) の形 式に基づく関数記録領域を積み上げ ( S 2 1 0 ) 、 積み上げた関数 記録領域を利用して自己再帰代替関数を呼び出し ( S 2 1 1 ) 、 ス テツプ 2 1 0にて積み上げた関数記録領域にて自己再帰代替関数を 実行する ( S 2 1 2 ) 。
そして自己再帰代替関数に含まれる s e 1 f t a i 1 i n v o k e s t a t i c等の代替命令による処理によ り、 呼出関数 (第 1 の 呼出関数) と して実行している自己再帰代替関数 (第 2の呼出関 数) から被呼出関数を呼び出す場合に、 新たに関数記録領域を積み 上げるこ となく 、 自己再帰代替関数を実行した関数記録領域を、 被 呼出関数を呼び出す領域と して利用 して ( S 2 1 3 ) 、 被呼出関数 を呼び出し ( S 2 1 4 ) 、 呼び出した被呼出関数を実行し ( S 2 1 5 ) 、 被呼出関数の実行後、 被呼出関数の実行に利用した関数記録 領域を破棄する ( S 2 1 6 ) 。
ステップ S 2 0 1 において、 代替関数でないと判断した場合 ( S 2 0 1 : 3 ) 、 呼出関数の形式に基づく関数記録領域を積み上げ ( S 2 1 7 ) 、 積み上げた関数記録領域を利用して呼出関数を呼び 出し ( S 2 1 8 ) 、 ステップ 2 1 7にて積み上げられた関数記録領 域にて呼出関数を実行する ( S 2 1 9 ) 。
そして呼出関数から被呼出関数を呼び出す場合に、 被呼出関数の 形式に基づく新たな関数記録領域を積み上げ ( S 2 2 0 ) 、 積み上 げた関数記録領域を利用して被呼出関数を呼び出し ( S 2 2 1 ) 、 ステップ S 2 2 0にて積み上げた関数記録領域にて被呼出関数を実 行し ( S 2 2 2 ) 、 被呼出関数の実行後、 被呼出関数の実行に利用 した関数記録領域を破棄し ( S 2 2 3 ) 、 更に呼出関数における被 呼出関数実行後の処理を実行して、 呼出関数の実行に利用した関数 記録領域を破棄する ( S 2 2 4 ) 。
次に本発明の関数実行方法及び従来の関数実行方法の処理速度を 比較した結果を第 7図に示すグラフを用いて説明する。
第 7図では横軸に末尾呼出関数の呼び出し深さをと り、 縦軸にマ イク 口秒 ( u s ) を単位とする処理時間をとつて、 その関係を示し たものであり、 X印は呼出関数を呼び出す都度、 関数記録領域を積 み上げる従来の閧数実行方法による呼び出し深さと処理時間との関 係を示し、 口印は呼出関数が末尾呼出の場合に関数記録領域を再利 用する本発明の関数実行方法による呼び出し深さと処理時間との関 係を示し、 〇印は呼出関数と被呼出関数とが同じである自己末尾呼 出関数を扱う場合の呼び出し深さと処理時間との関係を示してい る。
第 7図に示すように従来の関数実行方法と比較して、 本発明の関 数実行方法は処理時間が短く 、 特に自己末尾呼出関数ではその傾向 が顕著である。
また本発明の実施の形態と しては、 J I T (Just In Time Compiler) と呼ばれる J V Mの実装技術を用いてもよく、 J I T技術によ り、 J V Mのバイ トコ一ドを機械語に変換して、 C P U 1 1 にて実行す ることで、 実行処理の速度を向上させることが可能である。
そして前記実施の形態では、 呼出関数が末尾呼出又は自己末尾呼 出である場合に、 代替関数を用いる形態を示したが、 本発明はこれ に限らず、 関数実行時に都度再帰判定を行い、 末尾再帰である と判 断した場合に、 末尾再帰処理を行う よ うにしてもよい。 産業上の利用可能性
以上詳述した如く本発明に係る命令実行方法、 命令実行装置、 コ ンピュータプログラム、 及び記録媒体では、 J a v a言語等の言語 にて記述され複数の関数を含むプログラムを、 携帯電話及びパーソ ナルコンピュータ等の処理装置を用いた J V Mにて実行する場合 で、 メモリ 中のスタック領域に、 他の関数を呼び出す処理を呼出関 数による呼び出しが、 被呼出関数の実行結果を呼出関数の実行結果 とする末尾呼び出しである等の所定の条件を満足すると判断したと きに、 呼出関数の関数記録領域を被呼出関数の記録領域と して再利 用し、 スタ ック領域に積み上げられる関数記録領域の数を低減する ことで、 関数記録領域がスタ ック領域をオーバーフローしてプログ ラムの実行に支障を来す可能性を低減し、 また関数記録領域の積み 上げ及び破棄に要する処理負荷を低減して、 全体の実行速度を向上 させることが可能である等、 優れた効果を奏する。
また J V Mのバイ トコード等の実行形式の呼出関数を実行する際 に、 上述した関数記録領域を再利用する処理を、 実行すべき呼出関 数を予め準備している代替関数に代替し、 代替された代替関数を実 行することによ り実現するので、 J a v a言語等の言語によるソー スコー ドの作成時には特別な配慮を行う必要が無く、 またソースコ ー ドをバイ トコー ド等の実行形式の関数に変換するコンパイラに特 別な命令を追加する必要が無い等、 優れた効果を奏する。
さ らに本発明では呼出関数及び被呼出関数が異なるときに、 呼出 関数のために確保されている関数記録領域を被呼出関数の形式に基 づいて変更することによ り、 被呼出関数を再利用した関数記録領域 にて問題なく実行することが可能であり、 また呼出関数及び被呼出 関数が同じ関数である ときには、 関数記録領域の形式を変更するこ となく、 そのまま再利用するので形式の変更に要する処理を無く し、 全体と しての処理速度を向上させることが可能である等、 優れ た効果を奏する。

Claims

請 求 の 範 囲
1 . メモ リ 中のスタ ック領域に、 他の関数を呼び出す処理を含む 呼出関数から呼び出される被呼出関数の形式に基づく 関数記録領域 を積み上げ、 積み上げた関数記録領域を利用して被呼出関数を呼び 出し、 呼び出された被呼出関数の実行後、 積み上げた関数記録領域 を破棄する関数実行方法において、
関数記録領域で実行される呼出関数を解析し、
該解析によ り呼出関数が所定の条件を満足すると判断した場合 に、 呼出関数を実行する前記関数記録領域を、 被呼出関数を呼び出 す領域と して利用する
ことを特徴とする関数実行方法。
2 . メモリ 中のスタ ック領域に、 他の関数を呼び出す処理を含む 呼出関数を実行することによ り呼び出される被呼出関数の形式に基 づく 関数記録領域を積み上げ、 積み上げた関数記録領域を利用して 被呼出関数を呼び出し、 呼び出された被呼出関数の実行後、 積み上 げた関数記録領域を破棄する関数実行方法において、
関数記録領域で実行される第 1の呼出関数の実行形式を解析し、 該解析により第 1の呼出関数が所定の条件を満足すると判断した 場合に、 呼出関数を実行する関数記録領域を、 被呼出関数を呼び出 す領域と して利用させる処理を含む第 1 と異なる第 2の呼出関数を 第 1の呼出関数の代替関数と して実行する
ことを特徴とする関数実行方法。
3 . 前記所定の条件は、 被呼出関数の実行結果が呼出関数の実行 結果となることであることを特徴とする請求項 1又は請求項 2に記 載の関数実行方法。
4 . 前記呼出関数及び被呼出関数が異なるときに、 被呼出関数の 形式に基づいて、 前記関数記録領域を変更することを特徴とする請 求項 1乃至請求項 3のいずれかに記載の関数実行方法。
5 . メ モ リ 中のスタ ック領域に、 他の関数を呼び出す処理を含む 呼出関数から呼び出された被呼出関数の形式に基づく 関数記録領域 を積み上げ、 積み上げた関数記録領域を利用して被呼出関数を呼び 出し、 呼び出された被呼出関数の実行後、 積み上げた関数記録領域 を破棄する関数実行装置において、
該解析によ り呼出関数が所定の条件を満足すると判断した場合 に、 呼出関数を実行する前記関数記録領域を、 被呼出関数を呼び出 す領域と して利用する手段と
を備えることを特徴とする関数実行装置。
6 . メ モ リ 中のスタ ック領域に、 他の関数を呼び出す処理を含む 呼出関数を実行することによ り呼び出される被呼出関数の形式に基 づく 関数記録領域を積み上げ、 積み上げた関数記録領域を利用して 被呼出関数を呼び出し、 呼び出された被呼出関数の実行後、 積み上 げた関数記録領域を破棄する関数実行装置において、
関数記録領域で実行される第 1の呼出関数の実行形式を解析する 手段と、
該解析によ り第 1の呼出関数が所定の条件を満足すると判断した 場合に、 呼出関数を実行する関数記録領域を、 被呼出関数を呼び出 す領域と して利用させる処理を含む第 1 と異なる第 2の呼出関数を 第 1の呼出関数の代替関数と して実行する手段と
を備えることを特徴とする関数実行装置。
7 . コンピュータに、 メモリ 中のスタック領域に、 他の関数を呼 び出す処理を含む呼出関数から呼び出される被呼出関数の形式に基 づく 関数記録領域を積み上げさせ、 積み上げた関数記録領域を利用 して被呼出関数を呼び出させ、 呼び出された被呼出関数の実行後、 積み上げた関数記録領域を破棄させるコンピュータプロダラムにお いて、
コ ンピュータに、 関数記録領域で実行される呼出関数を解析させ る手順と、
コンピュータに、 解析によ り呼出関数が所定の条件を満足すると 判断した場合に、 呼出関数を実行する前記関数記録領域を、 被呼出 関数を呼び出す領域と して利用させる手順と
を含むことを特徴とするコ ンピュータプログラム。
8 . コ ンピュータに、 メモ リ 中のスタ ック領域に、 他の関数を呼 び出す処理を含む呼出関数を実行することによ り呼び出される被呼 出関数の形式に基づく 関数記録領域を積み上げさせ、 積み上げた関 数記録領域を利用して被呼出関数を呼び出させ、 呼び出された被呼 出関数の実行後、 積み上げた関数記録領域を破棄させるコンビユ ー タプロダラムにおいて、
コンピュータに、 関数記録領域で実行される第 1の呼出関数の実 行形式を解析させる手順と、
コンピュータに、 解析によ り第 1の呼出関数が所定の条件を満足 すると判断した場合に、 呼出関数を実行する前記関数記録領域を、 被呼出関数を呼び出す領域と して利用させる処理を含む第 1 と異な る第 2の呼出関数を、 第 1の呼出関数の代替関数と して実行させる 手順と
を含むことを特徴とするコンピュータプログラム。
9 . 前記所定の条件は、 被呼出関数の実行結果が呼出関数の実行 結果となることであることを特徴とする請求項 7又は請求項 8に記 載のコンピュータプログラム。
1 0 . 前記呼出関数及び被呼出関数が異なるときに、 被呼出関数 の形式に基づいて、 前記関数記録領域を変更することを特徴とする 請求項 7乃至請求項 9のいずれかに記載のコンピュータプロダラ ム。
1 1 . コンピュータに、 メモ リ中のスタ ック領域に、 他の関数を 呼び出す処理を含む呼出関数から呼び出される被呼出関数の形式に 基づく 関数記録領域を積み上げさせ、 積み上げた関数記録領域を利 用して被呼出関数を呼び出させ、 呼び出された被呼出関数の実行 後、 積み上げた関数記録領域を破棄させるコンピュータプログラム を記録してある、 コンピュータでの読み取りが可能な記録媒体にお いて、
コ ンピュータに、 関数記録領域で実行される呼出関数を解析させ る手順と、
コ ンピュータに、 解析によ り呼出関数が所定の条件を満足すると 判断した場合に、 呼出関数を実行する前記関数記録領域を、 被呼出 関数を呼び出す領域と して利用させる手順と、
を含むコンピュータプログラムを記録してあることを特徴とする コンピュータでの読み取りが可能な記録媒体。
1 2 . コンピュータに、 メモ リ 中のスタ ック領域に、 他の関数を 呼び出す処理を含む呼出関数を実行することによ り呼び出される被 呼出関数の形式に基づく 関数記録領域を積み上げさせ、 積み上げた 関数記録領域を利用して被呼出関数を呼び出させ、 呼び出された被 呼出関数の実行後、 積み上げた関数記録領域を破棄させるコ ンビュ ータプログラムを記録してある、 コ ンピュータでの読み取り が可能 な記録媒体において、
コンピュータに、 関数記録領域で実行される第 1の呼出関数の実 行形式を解析させる手順と、
コンピュータに、 解析によ り第 1 の呼出関数が所定の条件を満足 すると判断した場合に、 呼出関数を実行する前記関数記録領域を、 被呼出関数を呼び出す領域と して利用させる処理を含む第 1 と異な る第 2の呼出関数を、 第 1の呼出関数の代替関数と して実行させる 手順と
を含むコンピュータプログラムを記録してあることを特徴とする コンピュータでの読み取りが可能な記録媒体。
PCT/JP2002/002888 2001-03-26 2002-03-25 Function executing method, function executing device, computer program and recording medium Ceased WO2002077802A1 (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP02705496A EP1383044A1 (en) 2001-03-26 2002-03-25 Function executing method, function executing device, computer program and recording medium
JP2002575788A JP3785596B2 (ja) 2001-03-26 2002-03-25 関数実行方法、関数実行装置、コンピュータプログラム、及び記録媒体
US10/628,133 US7130972B2 (en) 2001-03-26 2003-07-25 Function execution method, function execution apparatus, computer program and recorded medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2001088850 2001-03-26
JP2001-88850 2001-03-26

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US10/628,133 Continuation US7130972B2 (en) 2001-03-26 2003-07-25 Function execution method, function execution apparatus, computer program and recorded medium

Publications (1)

Publication Number Publication Date
WO2002077802A1 true WO2002077802A1 (en) 2002-10-03

Family

ID=18943875

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2002/002888 Ceased WO2002077802A1 (en) 2001-03-26 2002-03-25 Function executing method, function executing device, computer program and recording medium

Country Status (4)

Country Link
US (1) US7130972B2 (ja)
EP (1) EP1383044A1 (ja)
JP (1) JP3785596B2 (ja)
WO (1) WO2002077802A1 (ja)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7610474B2 (en) * 2005-12-01 2009-10-27 Sun Microsystems, Inc. Mechanism for hardware tracking of return address after tail call elimination of return-type instruction
US7836290B2 (en) * 2005-11-09 2010-11-16 Oracle America, Inc. Return address stack recovery in a speculative execution computing apparatus
US8250551B2 (en) * 2008-01-17 2012-08-21 International Business Machines Corporation Refining tail call optimizations at link-time
US7661092B1 (en) * 2008-12-30 2010-02-09 International Business Machines Corporation Intelligent reuse of local variables during bytecode compilation
KR101283469B1 (ko) 2009-08-31 2013-07-12 한국전자통신연구원 프로세서 명령어의 메모리 액세스 방법 및 장치
CN103294517B (zh) 2012-02-22 2018-05-11 国际商业机器公司 堆栈溢出保护装置、堆栈保护方法、相关编译器和计算装置
US10114573B1 (en) * 2017-04-26 2018-10-30 International Business Machines Corporation Dynamic reduction of stack-overflow errors in a recursive data-serialization algorithm
FR3070775B1 (fr) * 2017-09-04 2019-08-23 Vsora Allocation dynamique utilisant plusieurs piles

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS608944A (ja) * 1983-06-28 1985-01-17 Fujitsu Ltd 関数型マシンの終端再帰呼出し制御方式

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4530049A (en) * 1982-02-11 1985-07-16 At&T Bell Laboratories Stack cache with fixed size stack frames
US5522072A (en) * 1990-09-04 1996-05-28 At&T Corp. Arrangement for efficiently transferring program execution between subprograms
US5335332A (en) * 1991-12-24 1994-08-02 International Business Machines Corporation Method and system for stack memory alignment utilizing recursion
US5590332A (en) * 1995-01-13 1996-12-31 Baker; Henry G. Garbage collection, tail recursion and first-class continuations in stack-oriented languages
US6101326A (en) * 1997-05-29 2000-08-08 Hewlett-Packard Company Method and apparatus for frame elimination for simple procedures with tail calls

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS608944A (ja) * 1983-06-28 1985-01-17 Fujitsu Ltd 関数型マシンの終端再帰呼出し制御方式

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
ISHIZAKI ET AL.: "Java just-in-time compiler ni okeru saitekika to sono hyoka", THE INSTITUTE OF ELECTRONICS, INFORMATION AND COMMUNICATION ENGINEERS GIJUTSU KENKYU HOKOKU (CPSY99-64), vol. 99, no. 252, 5 August 1999 (1999-08-05), pages 17 - 24, XP002951530 *
KOMIYA YUASA: "Museigen no jumyo o matsu tan'itsu yobidashi keizoku", TRANSACTIONS OF INFORMATION PROCESSING SOCIETY OF JAPAN, vol. 37, no. 1, 15 January 1996 (1996-01-15), pages 92 - 100, XP002951528 *
MAEDA SOWA: "Asai sokubaku ni yoru doteki scope hensu ga sonzai suru tokino matsubi saiki yobidashi", TRANSACTIONS OF INFORMATION PROCESSING SOCIETY OF JAPAN, vol. 41, no. SIG4 (PRO07), 15 June 2000 (2000-06-15), pages 1 - 10, XP002951527 *
MATSUOKA: "Open JIT- jiko han'ei keisan ni motoduita doteki ni henki kano no java JIT compiler", COMPUTER TODAY, vol. 15, no. 6, 1 November 1998 (1998-11-01), pages 4 - 11, XP002951531 *
WATANABE ITO: "Call/cc o mochiita kurikaeshi teki scheme program to CPS henkan", INFORMATION PROCESSING SOCIETY OF JAPAN (94-SYM-75), vol. 94, no. 79, 16 September 1994 (1994-09-16), pages 7 - 14, XP002951529 *

Also Published As

Publication number Publication date
EP1383044A1 (en) 2004-01-21
JP3785596B2 (ja) 2006-06-14
US7130972B2 (en) 2006-10-31
US20040088686A1 (en) 2004-05-06
JPWO2002077802A1 (ja) 2004-08-19

Similar Documents

Publication Publication Date Title
KR100573043B1 (ko) 컴파일링된활성화레코드를동적최적화해제하는방법및장치
CN111736884B (zh) 组件化方法和系统
JPH11237991A5 (ja)
US7406684B2 (en) Compiler, dynamic compiler, and replay compiler
EP0933706B1 (en) Language processing system and language processing method enabling reduction of memory region and overhead in profile information collection of computer
WO2002077802A1 (en) Function executing method, function executing device, computer program and recording medium
CN110334024B (zh) 一种基于树状结构的测试用例管理方法、装置及终端
CN112328298A (zh) 移动端的代码库裁剪方法及装置
CN115292201B (zh) 函数调用栈解析和回溯方法与装置
CN114024865B (zh) 基于Linux进程函数的网络审计方法、装置、系统
JP4769946B2 (ja) メモリ管理方法、メモリ管理装置、及びメモリ管理プログラムが記録されている記録媒体
US9389843B2 (en) Efficient interpreter profiling to obtain accurate call-path information
CN1781127B (zh) 便携式数据载体中的存储器管理方法
JP2007226784A (ja) インラインされたメソッドの呼出方法およびそれを用いたジャバ仮想マシン
JP3790707B2 (ja) プログラム変換方法、これを用いたコンピュータ装置及びプログラム
JP4864287B2 (ja) 識別方法、記録媒体及びコンピュータシステム
US20050060707A1 (en) Method for iterating through elements of a collection
CN109040645B (zh) 音视频文件转录方法、装置及存储介质、服务器
JP3049814B2 (ja) マイクロコンピュータの言語処理装置
CN118069244A (zh) 一种安全插件的配置方法及装置、数据采集系统
CN118626111A (zh) 一种前端项目部署优化方法及系统
CN116501710A (zh) 一种无入侵日志压缩方法、系统、设备及存储介质
JP3807860B2 (ja) コンパイル方法および装置、並びにメソッド活動度計算方法および装置
KR20210078396A (ko) 컴퓨터 내 행위 이벤트 축약 방법
CN112948000B (zh) 栈空间统计方法、装置及介质

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): JP US

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): AT BE CH CY DE DK ES FI FR GB GR IE IT LU MC NL PT SE TR

DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
121 Ep: the epo has been informed by wipo that ep was designated in this application
WWE Wipo information: entry into national phase

Ref document number: 10628133

Country of ref document: US

WWE Wipo information: entry into national phase

Ref document number: 2002705496

Country of ref document: EP

WWP Wipo information: published in national office

Ref document number: 2002705496

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2002575788

Country of ref document: JP

WWW Wipo information: withdrawn in national office

Ref document number: 2002705496

Country of ref document: EP