JPH0736709A - Procedure calling system - Google Patents

Procedure calling system

Info

Publication number
JPH0736709A
JPH0736709A JP20035093A JP20035093A JPH0736709A JP H0736709 A JPH0736709 A JP H0736709A JP 20035093 A JP20035093 A JP 20035093A JP 20035093 A JP20035093 A JP 20035093A JP H0736709 A JPH0736709 A JP H0736709A
Authority
JP
Japan
Prior art keywords
code
array
optimized
procedure
argument
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
Application number
JP20035093A
Other languages
Japanese (ja)
Inventor
Yukimasa Yoshida
幸正 吉田
Original Assignee
Nec Corp
日本電気株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nec Corp, 日本電気株式会社 filed Critical Nec Corp
Priority to JP20035093A priority Critical patent/JPH0736709A/en
Publication of JPH0736709A publication Critical patent/JPH0736709A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To provide a procedure calling system capable of calling an optimized code optimized on condition that actual arguments corresponding to the array of dummy arguments are present in consecutive areas only when the actual arguments corresponding to the array of the dummy arguments are present in the consecutive areas. CONSTITUTION:An optimized code generation means 7 generates the optimized code along with the unoptimized code when optimization on the condition that the array specified by the actual arguments corresponding to the dummy arguments is present in the consecutive areas is possible at the time of performing the optimization to a procedure program for which the array is defined as the dummy argument. On the other hand, a calling code generation means 8 generates the code for calling the optimized code when the array of the actual arguments is present in the consecutive areas and generates the code for calling the unoptimized code when the array of the actual arguments is present in non-consecutive areas at the time of generating the code of procedure calling for which the array is defined as the actual arguments.

Description

Detailed Description of the Invention

[0001]

BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to compilation of a programming language capable of designating an array in a non-contiguous area as an actual argument of a procedure calling in a computer programming language processing system, and more particularly to a procedure calling system.

[0002]

2. Description of the Related Art Generally, a compiler performs various optimizations to improve the execution speed of an object program. One of them is that an actual procedure corresponding to a dummy argument for a procedure that takes an array as a dummy argument is performed. There is a method for optimizing a procedure with one requirement that arguments are in continuous areas.

The FORTRAN language subroutine subprogram shown in FIG. 4 is an example thereof. If the actual argument corresponding to the two-dimensional array A, which is a dummy argument, is in a continuous area, it is composed of DO statements 43 and 44. The DO sentence 5 of the FORTRAN program piece of FIG.
As shown by a DO loop composed of two, it is possible to perform single optimization so as to shorten the time required for control of repetition at the time of execution and the time required for calculation of a subscript.

By the way, in a programming language processing system such as FORTRAN90 language that can specify an array in a non-contiguous area as an actual argument of a procedure call, the actual argument may or may not be in a continuous area. Both can be considered, and a compiler that compiles for each program unit cannot obtain information about actual arguments when compiling a procedure to be called. Therefore, when compiling a program as shown in FIG. It is unclear whether the corresponding actual argument has a continuous area. Therefore, the optimization shown in FIG. 5 cannot always be performed.

Therefore, in the past, the official technique number 91 issued by the Institute of Invention and Innovation on April 15, 1991 was used.
The following methods have been proposed as described in the -5661 public technical report.

(1) A method of uniformly suppressing optimization. In other words, if the optimization can be performed assuming that the actual arguments corresponding to the dummy arguments are in continuous areas, then
If the actual argument is not in a continuous area, normal processing cannot be performed, so no optimization is performed to prevent it.

(2) When the actual argument corresponding to the dummy argument is not in the continuous area, it is changed to a continuous area at the time of calling, so that the actual argument corresponding to the dummy argument is not continuous in the continuous area. A method that optimizes the procedure so that it can be handled in the same way as when it is in a specified area, and the procedure can be optimized assuming that the actual argument corresponding to the dummy argument is in a continuous area. This method is further divided into the following two methods.

(2-1) A method in which an actual argument having no continuous area is unconditionally copied to a continuous work area on the call side of the procedure, and the copied continuous area is passed as an actual argument.

(2-2) For a call including an actual argument that does not have a continuous area, copy it to a continuous work area before the call, pass it as an actual argument, and after control returns from the procedure. The object code that is copied again to the original non-contiguous area is generated, and at the time of execution, it is checked whether or not the procedure is optimized, and if it is optimized, the above object code is executed. If not, the area of actual argument is passed to the procedure as it is.

[0010]

However, in the above method (1), since the non-optimized code is called even when the actual argument is in a continuous area and can be optimized, the execution speed of the object code is increased. However, it is a method that is too passive.

On the other hand, in the above method (2), the optimizing code is called when the optimizing is possible, even when the actual argument corresponding to the formal argument is in a continuous area or not, so that It can be said to be a positive method. However, when the actual argument corresponding to the dummy argument is not in the continuous area, the above (2
In the method of -1), a process of always copying the actual argument to the continuous area occurs at the time of execution even if it is not actually optimized, and in the method of (2-2), it is executed when it is not optimized. Although the copy processing amount is smaller than that in (2-1) because there is no copy processing at the time, the copy processing occurs when it is optimized.

As described above, even in the method (2-1), since the copying process always occurs when the optimized code is called, the execution time of the program shortened by the optimization is considered. However, if the execution time required for copying is long, the execution time will increase on the contrary when optimization is performed.

Therefore, the object of the present invention is to assume that the non-optimized code can be called when the actual argument corresponding to the dummy argument is not in the continuous area, and that it can be called when the actual argument is in the continuous area. It is to provide a procedure call method capable of calling an optimized code generated by optimization.

[0014]

In order to achieve the above-mentioned object, the procedure calling method of the present invention is a compiler that interprets a source program to generate an intermediate code and optimizes it to generate an object code. When optimizing for a procedure program that takes an array as a dummy argument, if optimization is possible assuming that the array specified in the actual argument corresponding to the dummy argument is a continuous area,
Optimizing code generation means for generating optimized code together with non-optimized code, and when generating a procedure call code with an array as an actual argument, if the array of actual arguments is in a continuous area, the above-mentioned optimization And a calling code generating means for generating a code for calling the optimized code, and generating a code for calling the non-optimized code if the array of actual arguments is in a non-continuous area.

[0015]

In the procedure calling method of the present invention, when the optimizing code generating means optimizes a procedure program having an array as a dummy argument, the array specified by the actual argument corresponding to the dummy argument is continuous. If optimization is possible assuming that it is a region, the optimized code is generated together with the unoptimized code, while the calling code generation means generates the code for the procedure call using the array as the actual argument. Generates a code that calls the optimized code if the actual argument array is in a continuous area, and generates a code that calls the non-optimized code if the actual argument array is in a non-continuous area To do. Therefore,
When executing the object code, if the actual argument corresponding to the dummy argument is not in the continuous area, the unoptimized code is called, and if it is in the continuous area, it is generated by the optimization based on that. The optimized code is called.

[0016]

Embodiments of the present invention will now be described in detail with reference to the drawings.

Referring to FIG. 1, an example of a compiler 2 to which the present invention is applied includes an intermediate code generating section 3, an optimizing section 4, an object generating section 5, an optimizing code generating section 7, and a calling code generating section 8. It is configured to include. 1 is a source program and 6 is an object program.

The compiler 2 inputs the source program 1 and compiles it to generate an object program 6. At this time, the intermediate code generation unit 3 generates intermediate code from the source program 1, performs optimization conversion on the generated intermediate code by the optimization unit 4, and generates an object based on the converted intermediate code. The part 5 generates the object program 6.

When the optimization unit 4 optimizes and converts an intermediate code, if the program unit is a procedure and its dummy argument includes an array, the optimization code generating means 7 is called.

FIG. 2 shows a processing example of the optimized code generating means 7. First, it is determined whether or not the optimization assuming (assumed) that the actual argument corresponding to the dummy argument in the program unit, which is a procedure using an array as a dummy argument, is in a continuous area is applicable. (22).

For example, in the FORTRAN language subroutine subprogram shown in FIG. 4, if the two-dimensional array A, which is a dummy argument, is in a continuous area, the DO statements 43 and 44 are given.
The dual DO loop consisting of
It is a well-known technique that a DO loop composed of a DO statement 52 of an AN program piece can be unified and optimized as if it is a single loop. Therefore, for the FORTRAN program as shown in FIG. 4, if it is assumed that the array of actual arguments corresponding to the array A that is a dummy argument is in a continuous area, it can be determined that the above optimization can be applied. The result of the determination process 22 is YES, and the process 2
Go to 3.

In process 23, the original intermediate code before optimization is copied to generate a non-optimized code, and the optimized intermediate code is generated and added by performing the above optimization. In this way, the FORTRA of FIG.
The DO loop formed by the DO statement 52 in the FORTRAN program piece in FIG. 5 is generated and added to the DO loop formed by the DO statements 43 and 44 in the N program.

Next, in processing 24, an entrance name indicating that optimization has been performed assuming that the actual argument corresponding to the dummy argument array is an array in a continuous area is added by the processing 23. Insert before intermediate code (optimized code).

In the present embodiment, as the entrance name indicating that the above optimization has been performed, the convention of adding the character "-O" after the original entrance name is adopted. Therefore, in process 24, the original entrance name "SUB" is suffixed with "-O" to create the entrance name "SUB-O" as a secondary entrance, and the FO of FIG.
As shown in the ENTRY statement 51 of the RTRAN program fragment, it is inserted before the intermediate code added by the process 23.

An example showing an image of the intermediate code (or object code) of the entire program including the intermediate code by the optimization added as described above is shown in F of FIG.
Shown as an ORTRAN subroutine subprogram. In FIG. 6, ENTRY statement 609 to CONTINUE
Up to the sentence 612 is an image showing the intermediate code added by the optimized code generation means 7. Other than that, it is an image of the original intermediate code and shows the unoptimized intermediate code. However, the RETURN statement 608 is a newly added code.

On the other hand, if it is judged NO in the judgment processing 22 of FIG. 2, that is, if it is judged that the optimization is not possible even on the assumption that the dummy argument becomes a continuous area, the optimum processing is executed in the processing 25. The generated code is not generated, and the entry name created by the same method as the instruction rule in the process 24 is inserted immediately after the entry name of the original intermediate code (non-optimized code). For example, assuming that the FORTRAN program of FIG. 4 could not be optimized, the original entrance name is "SUB", so it is changed to "SUB, SUB-O".
So that both can be called, as shown in FIG. 9,
The ENTRY statement 49 is inserted between the statements 42 and 43 to generate non-optimized code.

This is because even if the above optimization cannot be applied, and therefore no optimization code exists, in the calling code generating means 8 which will be described later, the array of actual arguments is in a continuous area. Regarding the procedure call statement, the procedure is called uniformly with the name obtained by adding "-O" to the original entry name in accordance with the above naming rules, so in such a case the original entry that is not optimized is used. This is so that the code can be called and executed.

If the program unit is a procedure and its dummy argument includes an array, the optimizing unit 4 calls the optimizing code generating means 7 to perform the above-mentioned processing. If it is a procedure call and the actual argument is an array, the call code generation means 8 is called.

FIG. 3 shows a processing example of the calling code generating means 8.
Shown in. First, it is determined whether or not the array of actual arguments specified in the procedure call is in a continuous area (3
2). If it is in a continuous area, it is premised that the entry name of the procedure call is inserted by the optimizing code generation means 7 in step 33, that is, the actual argument is an array in a continuous area. Change to the optimized entrance name. On the other hand, if it is determined in the determination processing 32 that the array of actual arguments is not in a continuous area, processing 3
3 is skipped and the procedure is called with the original entry name.

FIG. 7 shows an example of a FORTRAN program that calls the subroutine subprogram shown in FIG.
In FIG. 7, in the CALL statement 76, the actual argument is the entire array of the array A, and it is determined by the determination processing 32 that it is in a continuous area. Therefore, since the optimized entry name is called on the assumption that the array of the actual argument is in the continuous area by the process 33, the original call name "SUB"
Is changed to a call name "SUB-O" to which "-O" is added according to the above-mentioned convention.

On the other hand, in the CALL statement 77 of FIG. 7, the actual argument is a partial array of the array A, and it is determined that this is in an area that is not continuous. Therefore, the entry name optimized on the assumption that the array of actual arguments is in a continuous area is not called, and the original call name "SUB" is left as it is.

An example of an image of the object program 6 (or intermediate code) changed and output by the calling code generation means 8 with respect to the FORTRAN program of FIG. 7 is shown in FIG. 8 as a FORTRAN subroutine subprogram. In FIG. 8, the CALL statement 76 of FIG.
C that calls the changed entrance name "SUB-O"
It has been changed to ALL sentence 86.

When the object program 6 generated by the compiler 2 by the above processing is executed, if the array designated as the actual argument is in a continuous area as in the CALL statement 86 of FIG. When the procedure having the code with the entry name "SUB-O" in FIG. 6 that has been optimized is called and executed and the CALL statement 87 is in a non-continuous area, the above optimization is not performed.
The procedure having the code with the entry name "SUB" of is called and executed.

[0034]

According to the procedure calling method of the present invention described above, the following effects can be obtained.

A procedure in which the actual argument corresponding to the dummy argument is in a continuous area can call a code optimized on the premise at the time of execution, and the actual argument corresponding to the dummy argument is not in the continuous area. Can call unoptimized code at runtime. Therefore, as in the conventional method (2), by optimizing the procedure in which the actual argument corresponding to the dummy argument is not in the continuous area, the execution time required for copying is longer than the execution time required for copying. In this case, optimization can eliminate the adverse effect that the execution time is increased.

Since the first entrance name is added as the entrance name of the unoptimized code in addition to the second entrance name, even if the array of actual arguments is in a continuous area, it is optimized by other factors. With respect to the procedure that could not be performed, the target code (non-optimized code) can be correctly called by the first entry name generated by the calling code generation means.

[Brief description of drawings]

FIG. 1 is a block diagram showing an example of a compiler to which the present invention is applied.

FIG. 2 is a flowchart showing a processing example of an optimized code generation means.

FIG. 3 is a flowchart showing a processing example of a calling code generation means.

FIG. 4 is a diagram showing an example of a FORTRAN language subroutine subprogram to be optimized.

5 is a diagram showing an image example of an intermediate code added to the program of FIG. 4 by optimization processing.

FIG. 6 is a diagram showing an image example of an intermediate code or an object program after the program of FIG. 4 has been subjected to optimization processing.

FIG. 7 is a diagram showing an example of a program that calls the program shown in FIG.

8 is a diagram showing an image example of an intermediate code or an object program obtained by subjecting the program of FIG. 7 to processing by a calling code generating means.

FIG. 9 is a diagram showing an image example of an unoptimized intermediate code or object program in which another entrance name is given in addition to the original entrance name.

[Explanation of symbols]

DESCRIPTION OF SYMBOLS 1 ... Source program 2 ... Compiler 3 ... Intermediate code generation part 4 ... Optimization part 5 ... Object generation part 6 ... Object program 7 ... Optimization code generation means 8 ... Call code generation means 41, 601, 73, 83 ... Subroutine statement 42, 602, 71, 74, 81, 84 ... Type declaration statement 43, 44, 52, 603, 604, 610 ... DO statement 45, 53, 605, 611 ... Assignment statement 46, 47, 54, 606, 607, 612 … CONT
INUE sentence 48, 613, 78, 88 ... END sentence 49, 51, 609 ... ENTRY sentence 608 ... RETURN sentence 72, 82 ... INTERFACE sentence 75, 85 ... END INTERFACE sentence 76, 77, 86, 87 ... CALL sentence

Claims (3)

[Claims]
1. A compiler that interprets a source program to generate intermediate code, optimizes it, and generates object code, and handles dummy arguments when optimizing a procedure program that uses an array as a dummy argument If optimization is possible assuming that the array specified in the actual argument is a continuous area, the optimized code generation means that generates optimized code together with the unoptimized code, and the array When generating a procedure call code as an argument, generate a code that calls the optimized code if the actual argument array is in a contiguous area, and generate the optimal code if the actual argument array is in a non-contiguous area. And a call code generating means for generating a code for calling a code that has not been converted.
2. A compiler that interprets a source program to generate intermediate code, optimizes it, and generates object code, and handles dummy arguments when optimizing a procedure program that takes an array as a dummy argument. If optimization is possible on the assumption that the array specified in the actual argument is a continuous area, non-optimized code and optimized code will be generated and specified as the entry name of the optimized code. The first entrance name according to the naming rule of No. 1 is given, and if the optimization is impossible, a non-optimized code is generated. When generating the optimized code generation means for adding both the first entry name and the procedure call code using the array as the actual argument, the actual argument array is stored in a continuous area. Then, a code for calling a procedure with the first entrance name is generated, and a calling code generating means for generating a code for calling the procedure with the second entrance name if the array of actual arguments is in a non-continuous area. A procedure call method characterized in that
3. The entrance name obtained by adding a predetermined symbol to the original entrance name is used as the first entrance name, and the original entrance name itself is used as the second entrance name. The procedure call method described in item 2.
JP20035093A 1993-07-20 1993-07-20 Procedure calling system Pending JPH0736709A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP20035093A JPH0736709A (en) 1993-07-20 1993-07-20 Procedure calling system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP20035093A JPH0736709A (en) 1993-07-20 1993-07-20 Procedure calling system

Publications (1)

Publication Number Publication Date
JPH0736709A true JPH0736709A (en) 1995-02-07

Family

ID=16422842

Family Applications (1)

Application Number Title Priority Date Filing Date
JP20035093A Pending JPH0736709A (en) 1993-07-20 1993-07-20 Procedure calling system

Country Status (1)

Country Link
JP (1) JPH0736709A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010250683A (en) * 2009-04-17 2010-11-04 Nec Corp Compiler, compiling method, and program thereof
JP2011013985A (en) * 2009-07-02 2011-01-20 Internatl Business Mach Corp <Ibm> Program, apparatus and method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63198130A (en) * 1987-02-13 1988-08-16 Nec Corp System for selecting loop optimum instruction train
JPH02116930A (en) * 1988-10-27 1990-05-01 Fujitsu Ltd Array processing system in input/output library

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS63198130A (en) * 1987-02-13 1988-08-16 Nec Corp System for selecting loop optimum instruction train
JPH02116930A (en) * 1988-10-27 1990-05-01 Fujitsu Ltd Array processing system in input/output library

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010250683A (en) * 2009-04-17 2010-11-04 Nec Corp Compiler, compiling method, and program thereof
JP2011013985A (en) * 2009-07-02 2011-01-20 Internatl Business Mach Corp <Ibm> Program, apparatus and method
US8336039B2 (en) 2009-07-02 2012-12-18 International Business Machines Corporation Program, apparatus, and method of optimizing a Java object

Similar Documents

Publication Publication Date Title
US8930922B2 (en) Software-to-hardware compiler with symbol set inference analysis
Click Global code motion/global value numbering
Tate et al. Equality saturation: a new approach to optimization
US8769511B2 (en) Dynamic incremental compiler and method
US5659753A (en) Interface for symbol table construction in a multilanguage optimizing compiler
USRE45199E1 (en) Compiler apparatus
US6128774A (en) Safe to execute verification of software
US6314560B1 (en) Method and apparatus for a translation system that aggressively optimizes and preserves full synchronous exception state
JP2738692B2 (en) Parallel compilation method
Harrison Compiler analysis of the value ranges for variables
US6286135B1 (en) Cost-sensitive SSA-based strength reduction algorithm for a machine with predication support and segmented addresses
Berry Preemption in concurrent systems
US6253371B1 (en) Method for supporting parallelization of source program
JP4057938B2 (en) Compiler, compiling method, and program development tool
Cocke Global common subexpression elimination
Krall Efficient JavaVM just-in-time compilation
Creusillet et al. Interprocedural array region analyses
US7793278B2 (en) Systems and methods for affine-partitioning programs onto multiple processing units
US7784039B2 (en) Compiler, compilation method, and compilation program
US7571427B2 (en) Methods for comparing versions of a program
US6292940B1 (en) Program complete system and its compile method for efficiently compiling a source program including an indirect call for a procedure
EP2281236B1 (en) Just-ahead-of-time compilation
US9645803B2 (en) Methods and systems for forming an adjusted perform range
US7171649B1 (en) Optimizing safe downcasting in an object-oriented programming language
US5511198A (en) Optimizing compiler for shortening execution time of object program