WO2020008855A1 - コンパイル装置およびコンパイル方法 - Google Patents

コンパイル装置およびコンパイル方法 Download PDF

Info

Publication number
WO2020008855A1
WO2020008855A1 PCT/JP2019/023996 JP2019023996W WO2020008855A1 WO 2020008855 A1 WO2020008855 A1 WO 2020008855A1 JP 2019023996 W JP2019023996 W JP 2019023996W WO 2020008855 A1 WO2020008855 A1 WO 2020008855A1
Authority
WO
WIPO (PCT)
Prior art keywords
variable
program
shared variable
shared
address
Prior art date
Application number
PCT/JP2019/023996
Other languages
English (en)
French (fr)
Inventor
航 荒井
Original Assignee
オムロン株式会社
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 オムロン株式会社 filed Critical オムロン株式会社
Priority to US17/251,182 priority Critical patent/US11226814B2/en
Priority to EP19830528.6A priority patent/EP3819756A4/en
Priority to CN201980039733.7A priority patent/CN112334873A/zh
Publication of WO2020008855A1 publication Critical patent/WO2020008855A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/54Link editing before load time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3885Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units
    • G06F9/3893Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units controlled in tandem, e.g. multiplier-accumulator
    • G06F9/3895Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units controlled in tandem, e.g. multiplier-accumulator for complex operations, e.g. multidimensional or interleaved address generators, macros
    • G06F9/3897Concurrent instruction execution, e.g. pipeline or look ahead using a plurality of independent parallel functional units controlled in tandem, e.g. multiplier-accumulator for complex operations, e.g. multidimensional or interleaved address generators, macros with adaptable data path
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Definitions

  • the present invention relates to a compiling device and a compiling method for preventing unintended overwriting of data shared between user programs.
  • Patent Document 1 the following control device is known (see Patent Document 1). That is, when there are a plurality of user programs, data exchange between them is performed via the data storage unit. When exchanging data between programs, a variable name is given to the data, and each user program writes and reads data from the data storage unit using the variable name as a key.
  • none of the above techniques are techniques for preventing unintended overwriting of data due to collision of variable names when a plurality of programs exist.
  • One object of one embodiment of the present invention is to prevent unintended overwriting of data when variable names collide and there are a plurality of programs that define shared variables.
  • a shared variable that can be referred to by both the first user program and the second user program is defined.
  • An identifier acquiring unit for acquiring an identifier of the first user program; a variable name of the shared variable in the source code of the first user program; and a shared variable name for generating a shared variable name including the identifier.
  • a shared variable that can be referred to by both the first user program and the second user program is defined. Acquiring an identifier of the first user program, generating a shared variable name including the variable name of the shared variable in the source code of the first user program and the identifier, and Converting to a machine language, determining an address of the shared variable, associating the shared variable name with the address of the shared variable, and embedding in the first user program converted to a machine language.
  • a compiling device includes a determining unit that determines whether a variable referred to in a source code of a second user program is a shared variable, A conversion unit that converts the second user program into a machine language; and an address determination unit.
  • the address determination unit transmits an instruction for accessing the variable to an API (application program interface). If the variable is a shared variable without using a machine language instruction that accesses the address of the variable without using the program, the conversion unit converts the instruction that accesses the variable into a program that knows the address of the shared variable. The variable is replaced with a machine language instruction for accessing the variable via an API provided by the management unit.
  • a determining step of determining whether a variable referred to in a source code of a second user program is a shared variable A conversion step of converting the second user program into a machine language.
  • an instruction for accessing the variable is transmitted without using an API (application @ program @ interface).
  • the instruction for accessing the variable is replaced by an API provided by a program management unit that knows the address of the shared variable. Is replaced by a machine language instruction that accesses
  • FIG. 4 is a diagram illustrating details of a shared variable symbol table.
  • FIG. 4 is a diagram illustrating an example of a flowchart of a process in which a compiling device according to an embodiment compiles and links a program.
  • FIG. 4 is a diagram illustrating an example of a flowchart of a process in which a compiling device according to an embodiment compiles and links a program.
  • FIG. 1 is a block diagram schematically illustrating an example of a configuration of a first information processing device 1 including a compiling device 12 according to the present embodiment.
  • the compiling device 12 according to the present embodiment is a device for preventing, when there are a plurality of user programs defining a shared variable, variable names from colliding and unintentionally overwriting data.
  • the compiling device 12 generates a shared variable name including a variable name of the shared variable included in the source code of the first user program and an identifier.
  • the identifier is an identifier that allows a plurality of user programs to be distinguished from each other.
  • the compiling device 12 associates the shared variable name with the address of the shared variable and embeds it in the first user program converted into the machine language. Even if the same variable name is unintentionally given to a plurality of shared variables in the source code of the plurality of user programs, the second user program accessing the shared variable is assigned the same Shared variables can be distinguished.
  • the first information processing device 1 includes a storage device 11 and a compiling device 12.
  • the storage device 11 stores a source 11a of a first user program (hereinafter, referred to as a program A) and a source 11b of a second user program (hereinafter, referred to as a program B).
  • the compiling device 12 includes a compiler 121 and a linker 122.
  • the compiler 121 includes an identifier acquisition unit 121a, a shared variable name generation unit 121b, a conversion unit 121c, and a determination unit 121d.
  • the linker 122 includes an address determination unit 122a.
  • the source 11a of the program A defines a shared variable therein. That is, an instruction for generating a shared variable and writing a value to the shared variable is described in the source 11a of the program A.
  • the source 11b of the program B references the shared variable therein. That is, an instruction to read the shared variable is described in the source 11b of the program B.
  • the storage device 11 is, for example, a non-volatile memory or a hard disk, but is not limited to this.
  • the provision of the storage device 11 can reliably prevent data loss.
  • the compiling device 12 compiles and links the source 11a of the program A in the storage device 11 (for example, a text file in which the program code is described by the user). When the source 11a of the program A is compiled and linked, it becomes an executable program. In this specification, compile and link processing may be collectively referred to as "compile".
  • a shared variable that can be referred to by both the program A and the program B is defined.
  • the identifier acquisition unit 121a acquires the identifier of the program A.
  • the determining unit 121d determines whether a variable described in the source code of the program A is a shared variable or a non-shared variable. For example, in a source code, a predetermined declaration may define whether a variable is a shared variable or a non-shared variable.
  • the shared variable name generation unit 121b generates a shared variable name including the variable name of the shared variable in the source code of the program A and the identifier.
  • the conversion unit 121c converts the source code of the program A into a machine language.
  • the compiler 121 generates a plurality of object codes from the source code of the program A.
  • the object code includes a machine language code and relocation information.
  • the shared variable name generation unit 121b replaces the variable name of the shared variable with the generated shared variable name.
  • an access instruction to a shared variable is described by a symbolic reference (a reference using a shared variable name).
  • the linker 122 is also called a linkage editor.
  • the linker 122 combines a plurality of object codes converted by the compiler 121.
  • the address determining unit 122a determines an address of the shared variable.
  • the address determination unit 122a replaces an access (write / reference) instruction to the shared variable using a symbolic reference in the object code with an access instruction to the shared variable using the address. That is, the address determining unit 122a replaces the instruction for accessing the shared variable in the program A converted into the machine language with the instruction for accessing the address of the shared variable.
  • the address determination unit 122a associates the shared variable name with the address of the shared variable and embeds it in the program A converted into a machine language. For example, the shared variable name and the address are embedded in the program A as a symbol table.
  • the program A in machine language (converted into an executable form) is stored in the storage device 11.
  • the first information processing device 1 transmits the machine language program A to the second information processing device 2.
  • FIG. 2 is a block diagram schematically illustrating an example of the configuration of the second information processing device 2 according to the present embodiment.
  • the second information processing device 2 may be a control device that controls operations of various devices such as a PLC (programmable logic controller).
  • the second information processing device 2 includes a program management unit 21, an auxiliary storage device 22, and a memory 23.
  • the program management unit 21 includes a program A management unit 21a and a program B management unit 21b.
  • the program A management unit 21a executes a program A in a machine language.
  • the program B management unit 21b executes the machine language program B.
  • the auxiliary storage device 22 stores the program A and the program B received from the first information processing device 1.
  • the memory 23 temporarily stores the program A and the program B.
  • the auxiliary storage device 22 is, for example, a nonvolatile memory or a hard disk, but is not limited to this.
  • the memory 23 temporarily stores the program A and the program B.
  • the memory 23 is, for example, a volatile memory, but is not limited to this.
  • the memory 23 includes a data storage unit 23a and a shared variable symbol table 23b.
  • the data storage unit 23a stores data of shared variables that can be referred to by both the program A and the program B.
  • a shared variable here refers to a variable that can be referenced from a plurality of user programs.
  • the shared variable symbol table 23b stores storage locations (addresses) of the shared variables stored in the data storage unit 23a.
  • FIG. 3 is a diagram illustrating details of the shared variable symbol table 23b.
  • the program A management unit 21a loads the program A from the auxiliary storage device 22 and stores the program A in the memory 23.
  • the program A stored in the auxiliary storage device 22 is a program converted (compiled and linked) into a machine language.
  • the program A converted into the machine language includes a symbol table indicating the correspondence between the shared variable name and the address of the shared variable.
  • the non-shared variable is a variable that is used only in the program A and can be referred to only by the program A.
  • the address of the non-shared variable is defined.
  • the information on the variable name of the non-shared variable may not be left. However, even after being compiled, the program A includes the information on the shared variable name and the information on the address of the shared variable.
  • the program A management unit 21a acquires information on the shared variable name and information on the corresponding address.
  • the program A management unit 21a records the shared variable name and the address of the shared variable in the shared variable symbol table 23b in association with each other. Further, the program A management unit 21a writes the data of the shared variable to the address of the data storage unit 23a.
  • the identifier of the user program is a character string or a numerical value unique to the user program.
  • the identifiers of the plurality of user programs are set so as not to overlap each other. For example, the program name of the user program, the path of the directory where the user program is located, a character string arbitrarily set by the user, a universally unique identifier (UUID), or a domain name may be used as the identifier of the user program.
  • UUID universally unique identifier
  • the identifier of the program A is “Press”.
  • the variable name “status” is a variable name of a shared variable defined in the source code of the program A.
  • the shared variable name generation unit 121b generates a shared variable name “Press.status” of the shared variable by combining the identifier “Press” with the original variable name “status”.
  • the shared variable name “Press.status” is a variable name used as a key when referring to the shared variable from another program B.
  • “.” Is added between the identifier and the variable name, but any character or character string may be used instead. Also, there may be no characters between the identifier and the variable name.
  • the order of the identifier and the variable name is also arbitrary.
  • “Cutter.status” illustrated in FIG. 3 is a shared variable name of a shared variable defined in the program B.
  • the identifier of the program B is “Cutter”.
  • the variable name of the shared variable defined in the program B is “status”.
  • the shared variable name generation unit 121b generates a shared variable name including an identifier and a variable name according to a predetermined rule. Thereby, even if a plurality of shared variables having the same variable name “status” are defined in a plurality of user programs, it is possible to avoid a collision of the shared variable names.
  • the shared variable names include, for example, Press.status and Cutter.status, and the addresses corresponding to these shared variable names are 0X00000000 and 0X00000001, respectively, but this is not a limitation of the present embodiment.
  • the program B refers to (reads) the shared variable defined (generated) by the program A.
  • the compiling device 12 of the first information processing device 1 compiles and links the source 11b of the program B.
  • the determination unit 121d determines whether a variable described in the source code of the program B is a shared variable or a non-shared variable. Further, the determination unit 121d determines that the shared variable described in the source code of the program B is a shared variable generated (defined) in the program B or generated (defined) in another program. Determine whether it is a shared variable. For example, in the source code, by making a predetermined declaration, it is defined whether the variable is a shared variable generated by the own program, a shared variable generated by another program, or a non-shared variable. May be. Further, for example, when the variable name of the variable includes a predetermined identifier (identifier of another program), the determination unit 121d may determine that the variable is a shared variable generated in another program. Good.
  • the conversion unit 121c converts the source code of the program B into a machine language. If the variable is a shared variable generated by its own program, the method of compiling and linking is as described for program A.
  • variable is a shared variable generated by another program (for example, program A)
  • the conversion unit 121c converts an instruction for accessing (referencing) the shared variable in the source code of the program B into an API (application @ program @ interface). Is replaced with a machine language instruction that accesses the shared variable via the.
  • This API is provided by the program management unit 21 that knows the address of the shared variable.
  • the program management unit 21 can acquire the address of the shared variable from the shared variable symbol table 23b using the shared variable name as a key.
  • the program management unit 21 uses the first API that returns the value (data) of the shared variable using the shared variable name as a key, or the shared API using the shared variable name as a key.
  • a second API for returning the address of a variable and a third API for returning the value of a variable (shared variable) using the address as a key are provided.
  • the conversion unit 121c may replace an instruction for accessing (referencing) the shared variable in the source code of the program B with a machine language instruction for referring to the shared variable via the first API.
  • the conversion unit 121c converts a command for accessing (referencing) a shared variable in the source code of the program B into a machine language command for acquiring an address via a second API and a machine language command for referencing a shared variable via a third API. It may be replaced with an instruction.
  • the linker 122 combines a plurality of object codes converted by the compiler 121.
  • the address is not determined for shared variables created by other programs. If the variable is a non-shared variable (if not a shared variable), the address determination unit 122a uses an API to issue an instruction to access the variable (using a symbolic reference) in the program B converted to the machine language. Instead, it is replaced with a machine language instruction that accesses the address of the variable.
  • the program B in machine language (converted into an executable form) is stored in the storage device 11.
  • the first information processing device 1 transmits a machine language program B to the second information processing device 2.
  • the program A and the program B may be compiled and linked in different information processing devices.
  • the program A is executed first, and the shared variable names and addresses of the shared variables defined in the program A are recorded in the shared variable symbol table 23b.
  • the program B management unit 21b loads the program A from the auxiliary storage device 22 and causes the memory 23 to store the program A.
  • the program B stored in the auxiliary storage device 22 is a program converted (compiled and linked) into a machine language.
  • the program B converted into the machine language includes an instruction for calling an API (first API, second API, or third API) that refers to the shared variable using the shared variable name as a key.
  • the address of the non-shared variable is defined.
  • the information on the variable name of the non-shared variable may not be left. However, even after being compiled, the program B includes information on the shared variable name of the shared variable.
  • the program B passes the shared variable name “Press.status” of the shared variable as a key to the program B management unit 21b via an API function.
  • the program B management unit 21b acquires an address corresponding to the shared variable name from the shared variable symbol table 23b.
  • the program B management unit 21b acquires the data of the shared variable from the data storage unit 23a using the address as a key.
  • the program B management unit 21b returns the data of the shared variable to the program B. In this manner, the program B management unit 21b can know the address of the shared variable with reference to the shared variable symbol table 23b.
  • variable names specified in the source file have been converted to addresses and do not remain.
  • the shared variable name in the compiled and linked program B remains as a key by using the API that refers to the shared variable.
  • the program A and the program B may be configured in different programming languages. According to the above aspect, the variables can be shared between the program A and the program B which are configured in different programming languages. For example, the program A and the program B may be configured in the same programming language.
  • the program A or the program B includes a program using a ladder language, a C language, or the like, but is not limited to the present embodiment.
  • the ladder language is a programming language suitable for the case where the second information processing device 2 controls the operation of a machine tool, a production device, or the like.
  • the source is a text file.
  • the source may be a text file or a binary file representing a ladder diagram.
  • the compiling device 12 when there are a plurality of programs that define a shared variable, it is possible to prevent unintended overwriting of data due to collision of variable names.
  • the compiling device 12 may replace the instruction for accessing the shared variable with the machine language instruction for accessing the shared variable via the API in the program A in which the shared variable is defined, in addition to the program B.
  • the program A management unit 21a that executes the program A determines the address to be assigned to the shared variable.
  • the program A management unit 21a associates the determined address with the shared variable name and records it in the shared variable symbol table 23b.
  • configuration example 1 of identifier (Configuration example 1 of identifier)
  • configuration example 1 of the identifier may be an argument specified by the user at the time of compiling. Then, the identifier acquiring unit 121a uses this argument as the identifier.
  • the identifier is not limited to the argument.
  • the identifier may include a path where the program A is to be located.
  • the user defines the path of the directory in which the program A is to be placed in the program A.
  • the program A itself may acquire the path of the program A.
  • the first information processing device 1 and the second information processing device 2 may be the same information processing device without being separated.
  • the identifier is not limited to the argument and the path.
  • the identifier may include the file name of the program A.
  • the file name may be defined in the program A, or the program A itself may acquire the file name of the program A.
  • the identifier acquiring unit 121a acquires the identifier of the program A. Specifically, the identifier acquiring unit 121a acquires the identifier from the setting file. The setting file defining the identifier of the program A is stored in a predetermined directory.
  • the source of the identifier is not limited to the setting file.
  • the identifier acquiring unit 121a may acquire the identifier from the source code of the program A.
  • the source code a shared variable that can be referred to by both the program A and the program B is defined.
  • the shared variable name generation unit 121b generates a shared variable name including the variable name of the shared variable in the source code of the program A and the identifier.
  • the shared variable names include, for example, Press.status, Cutter.status, and the like.
  • the conversion unit 121c converts the programs A and B into a machine language. Specifically, the conversion unit 121c replaces an instruction for accessing the shared variable in the source code of the program A with a machine language instruction for accessing the address of the shared variable.
  • the conversion unit 121c replaces the instruction for accessing the shared variable with a machine language instruction for accessing the shared variable via an API provided by a program management unit that knows the address of the shared variable.
  • FIG. 4 is a flowchart of a process in which the compiling device 12 according to the present embodiment compiles and links the program A.
  • the identifier acquiring unit 121a acquires an identifier of the program A (first user program).
  • the shared variable name generation unit 121b generates a shared variable name including the variable name of the shared variable in the source code of the program A and the identifier.
  • the conversion unit 121c converts the program A into a machine language.
  • the address determining unit 122a determines an address of the shared variable.
  • the address determination unit 122a associates the shared variable name with the address of the shared variable and embeds the program in the program A converted into machine language.
  • FIG. 5 is a flowchart of a process in which the compiling device 12 according to the present embodiment compiles and links the program B.
  • the determination unit 121d determines whether the variable referenced in the source code of the program B is a shared variable.
  • the conversion unit 121c converts the program B into a machine language.
  • an instruction for accessing the variable is sent to a machine language for accessing the variable via an API provided by a program management unit that knows the address of the shared variable. Replace with an instruction (S8).
  • the address determining unit 122a replaces the instruction for accessing the variable with a machine language instruction for accessing the address of the variable without using an API ( S7).
  • the compiling and linking steps are collectively referred to as a conversion step.
  • the compiling device 12 can access the shared variable. Can compile and link program B.
  • the conversion unit 121c replaces an instruction (access / write) to the shared variable in the source 11b of the program B with an instruction using the API.
  • the address of the shared variable is not determined.
  • the address of the non-shared variable is determined by the address determining unit 122a, and the variable name of the non-shared variable in the machine language program B is replaced with the address.
  • Control blocks of the compiling device 12 and the program management unit 21 (in particular, the identifier acquisition unit 121a, the shared variable name generation unit 121b, the conversion unit 121c, the determination unit 121d, the address determination unit 122a, the program A management unit 21a, and the program B management unit 21b ) May be realized by a logic circuit (hardware) formed in an integrated circuit (IC chip) or the like, or may be realized by software.
  • the compiling device 12 and the program management unit 21 include a computer that executes instructions of a program that is software for realizing each function.
  • This computer includes, for example, one or more processors and a computer-readable recording medium storing the above-described program. Then, in the computer, the object of the present invention is achieved when the processor reads the program from the recording medium and executes the program.
  • the processor for example, a CPU (Central Processing Unit) can be used.
  • the recording medium include a “temporary tangible medium” such as a ROM (Read Only Memory), a tape, a disk, a card, a semiconductor memory, and a programmable logic circuit. Further, a RAM (Random Access Memory) for expanding the program may be further provided.
  • the program may be supplied to the computer via an arbitrary transmission medium (a communication network, a broadcast wave, or the like) capable of transmitting the program.
  • a transmission medium a communication network, a broadcast wave, or the like
  • one embodiment of the present invention can also be realized in the form of a data signal embedded in a carrier wave, in which the program is embodied by electronic transmission.
  • a shared variable that can be referred to by both the first user program and the second user program is defined.
  • An identifier acquiring unit for acquiring an identifier, a variable name of the shared variable in the source code of the first user program, and a shared variable name generating unit for generating a shared variable name including the identifier; and the first user program To a machine language, and an address determining unit for determining the address of the shared variable, the address determining unit associates the shared variable name and the address of the shared variable, the machine It is embedded in the first user program converted into words.
  • the address determination unit may replace an instruction for accessing the shared variable in the first user program converted into a machine language with an instruction for accessing the address of the shared variable.
  • the conversion unit can replace the instruction for accessing the shared variable with the machine language instruction for accessing the address of the shared variable.
  • high-speed access can be achieved by accessing the shared variable using an address.
  • the identifier acquisition unit acquires the identifier from a setting file.
  • the identifier acquiring section can acquire the identifier from a setting file.
  • the identifier acquisition unit acquires the identifier from the source code of the first user program.
  • the identifier acquisition unit can acquire the identifier from the source code of the first user program.
  • the identifier acquisition unit uses an argument specified by a user at the time of compiling as the identifier.
  • the identifier acquisition unit can use the argument as the identifier.
  • the identifier includes a path where the first user program is to be located.
  • the identifier can include a path where the first user program is to be located.
  • the identifier includes a file name of the first user program.
  • the identifier may include a file name of the first user program.
  • a shared variable that can be referred to by both the first user program and the second user program is defined, and Acquiring an identifier, generating a shared variable name including the variable name of the shared variable in the source code of the first user program and the identifier, converting the first user program into a machine language, And embedding the shared variable name and the address of the shared variable in the first user program converted into a machine language in association with each other.
  • a compiling device includes a determining unit that determines whether a variable referred to in a source code of a second user program is a shared variable, and that converts the second user program into a machine language. And an address determining unit, wherein when the variable is not a shared variable, the address determining unit sends an instruction for accessing the variable to an address of the variable without using an API (application @ program @ interface). If the variable is a shared variable, the conversion unit converts the instruction to access the variable through an API provided by a program management unit that knows the address of the shared variable. It is characterized in that the variable is replaced with a machine language instruction for accessing the variable.
  • the second user program can be compiled and linked so that the second user program can access a shared variable defined by another first user program.
  • a determining step of determining whether a variable referred to in a source code of a second user program is a shared variable, and converting the second user program into a machine language A converting step of, if the variable is not a shared variable, a machine language instruction for accessing an address of the variable without using an API (application program interface).
  • an API application program interface
  • first information processing device 2 second information processing device 11 storage device 12 compiling device 21 program management unit 21a program A management unit 21b program B management unit 121 compiler 121a identifier acquisition unit 121b shared variable name generation unit 121c conversion unit 121d determination unit 122 Linker 122a Address determination unit

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)
  • Programmable Controllers (AREA)

Abstract

共有変数を定義するプログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きすることを防止する。コンパイル装置(12)は、第1ユーザプログラムの識別子を取得する識別子取得部(121a)と、共有変数の変数名と、前記識別子とを含む共有変数名を生成する共有変数名生成部(121b)と、前記第1ユーザプログラムを機械語に変換する変換部(121c)と、前記共有変数のアドレスを決定するアドレス決定部(122a)と、を備え、アドレス決定部(122a)は、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込む。

Description

コンパイル装置およびコンパイル方法
  本発明は、ユーザプログラム間で共有するデータの意図せずに上書きすることを防止するためのコンパイル装置およびコンパイル方法に関する。
  従来では、以下のようなコントロール制御装置が知られている(特許文献1を参照)。すなわち、ユーザプログラムが複数あるとき、それらの間のデータのやり取りはデータ記憶部を介して行う。プログラム間でデータのやり取りを行うにあたっては、データに変数名を与え、その変数名をキーにして各ユーザプログラムがデータ記憶部からデータの書き込みや読み取りを行う。
  また、従来では、異なるアプリケーションフレームワーク間のデータサービスのためのプラットフレームが知られている(特許文献2を参照)。
  また、従来では、仕様記述もしくは言語記述を処理する言語処理システムにおける入力/出力仕様記述中もしくは入力ソースプログラム/出力オブジェクトプログラム中の名標を管理する言語管理システムの名標管理方式が知られている(特許文献3を参照)。
日本国公開特許公報「特開2000-132208号公報」 日本国公開特許公報「特開2006-244488号公報」 日本国公開特許公報「特開平4-260134号公報」
  しかしながら、上記の何れの技術も、プログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きしてしまうことを防止する技術ではない。
  本発明の一態様は、共有変数を定義するプログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きすることを防止することを目的とする。
  上記の課題を解決するために、本発明の一態様に係るコンパイル装置は、第1ユーザプログラムのソースコードにおいて、前記第1ユーザプログラムおよび第2ユーザプログラムの両方から参照可能な共有変数が定義されており、前記第1ユーザプログラムの識別子を取得する識別子取得部と、前記第1ユーザプログラムの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成する共有変数名生成部と、前記第1ユーザプログラムを機械語に変換する変換部と、前記共有変数のアドレスを決定するアドレス決定部と、を備え、前記アドレス決定部は、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込む。
  上記の課題を解決するために、本発明の一態様に係るコンパイル方法では、第1ユーザプログラムのソースコードにおいて、前記第1ユーザプログラムおよび第2ユーザプログラムの両方から参照可能な共有変数が定義されており、前記第1ユーザプログラムの識別子を取得し、前記第1ユーザプログラムの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成し、前記第1ユーザプログラムを機械語に変換し、前記共有変数のアドレスを決定し、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込むことを特徴とする。
  上記の課題を解決するために、本発明の一態様に係るコンパイル装置は、第2ユーザプログラムのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する判定部と、前記第2ユーザプログラムを機械語に変換する変換部と、アドレス決定部とを備え、前記変数が共有変数ではない場合、前記アドレス決定部は、前記変数にアクセスする命令を、API(application program interface)を利用せずに前記変数のアドレスにアクセスする機械語命令に置き換え、前記変数が共有変数である場合、前記変換部は、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換えることを特徴とする。
  上記の課題を解決するために、本発明の一態様に係るコンパイル方法では、第2ユーザプログラムのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する判定工程と、前記第2ユーザプログラムを機械語に変換する変換工程とを含み、前記変換工程では、前記変数が共有変数ではない場合、前記変数にアクセスする命令を、API(application program interface)を利用せずに前記変数のアドレスにアクセスする機械語命令に置き換え、前記変数が共有変数である場合、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換えることを特徴とする。
  本発明の一態様によれば、共有変数を定義するプログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きすることを防止することができる。
一実施形態に係るコンパイル装置を備えた第1情報処理装置の構成の一例を模式的に示すブロック図である。 一実施形態に係る第2情報処理装置の構成の一例を模式的に示すブロック図である。 共有変数シンボルテーブルの詳細を例示する図である。 一実施形態に係るコンパイル装置がプログラムのコンパイルおよびリンクを実行する工程のフロチャートの一例を示す図である。 一実施形態に係るコンパイル装置がプログラムのコンパイルおよびリンクを実行する工程のフロチャートの一例を示す図である。
  §1 適用例
 図1を用いて、本実施形態に係るコンパイル装置の適用場面の一例について説明する。図1は、本実施形態に係るコンパイル装置12を備えた第1情報処理装置1の構成の一例を模式的に示すブロック図である。本実施形態に係るコンパイル装置12は、共有変数を定義するユーザプログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きすることを防止するための装置である。
  コンパイル装置12は、第1ユーザプログラムのソースコードに含まれる共有変数の変数名と、識別子とを含む共有変数名を生成する。識別子は複数のユーザプログラムを互いに区別可能にする識別子である。コンパイル装置12は、共有変数名と共有変数のアドレスとを対応付けて、機械語に変換された第1ユーザプログラムに埋め込む。複数のユーザプログラムのソースコードにおいて、複数の共有変数に対して同じ変数名が意図せず付与されていたとしても、共有変数にアクセスする第2ユーザプログラムは、識別子を含む共有変数名でそれぞれの共有変数を区別することができる。
  §2 構成例
 (第1情報処理装置の構成)
 図1に示すように、第1情報処理装置1は、記憶装置11と、コンパイル装置12とを備える。記憶装置11は、第1ユーザプログラム(以下プログラムAと称する)のソース11aと、第2ユーザプログラム(以下プログラムBと称する)のソース11bとを記憶している。コンパイル装置12は、コンパイラ121と、リンカ122とを備える。コンパイラ121は、識別子取得部121aと、共有変数名生成部121bと、変換部121cと、判定部121dとを備える。リンカ122は、アドレス決定部122aを備える。
  プログラムAのソース11aは、その中で共有変数を定義している。即ちプログラムAのソース11aには、共有変数を生成し該共有変数に値を書き込む命令が記述されている。プログラムBのソース11bは、その中で前記共有変数を参照する。即ちプログラムBのソース11bには、前記共有変数を読み出す命令が記述されている。
  また、記憶装置11は、例えば、不揮発性のメモリ、またはハードディスク等であるが、これに限らない。記憶装置11を備えることにより、データ消失を確実に防止することができる。
  コンパイル装置12は、記憶装置11のプログラムAのソース11a(例えば、ユーザによってプログラムコードが記述されたテキストファイル)をコンパイルし、リンクする。プログラムAのソース11aがコンパイルされかつリンクされると実行形式のプログラムになる。なお、本明細書では、コンパイルおよびリンクの処理を合わせて、「コンパイルする」と表現することがある。
  具体的には、プログラムAのソースコードにおいて、前記プログラムAおよび前記プログラムBの両方から参照可能な共有変数が定義されている。識別子取得部121aは、前記プログラムAの識別子を取得する。判定部121dは、前記プログラムAの前記ソースコードに記述されている変数が、共有変数か非共有変数かを判定する。例えば、ソースコードにおいて、所定の宣言をすることにより、変数が共有変数であるか非共有変数であるかが定義されていてもよい。共有変数名生成部121bは、前記プログラムAの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成する。変換部121cは、前記プログラムAの前記ソースコードを機械語に変換する。例えば、コンパイラ121は、プログラムAのソースコードから複数のオブジェクトコードを生成する。オブジェクトコードは機械語コードおよびリロケーション情報等を含む。共有変数名生成部121bは、共有変数の変数名を生成した共有変数名に置き換える。オブジェクトコードにおいて、共有変数へのアクセス命令は、シンボリックな参照(共有変数名を用いた参照)によって記述されている。
  リンカ122は、リンケージエディタとも呼ばれる。リンカ122は、コンパイラ121により変換された複数のオブジェクトコードを結合する。アドレス決定部122aは、前記共有変数のアドレスを決定する。アドレス決定部122aは、オブジェクトコードにおけるシンボリックな参照を用いた共有変数へのアクセス(書き込み/参照)命令を、前記アドレスを用いた共有変数へのアクセス命令に置き換える。即ち、アドレス決定部122aは、機械語に変換されたプログラムAにおける、共有変数へアクセスする命令を、共有変数のアドレスにアクセスする命令に置き換える。また、アドレス決定部122aは、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換されたプログラムAに埋め込む。例えば、共有変数名とアドレスとは、シンボルテーブルとしてプログラムAに埋め込まれる。
  機械語の(実行形式に変換された)プログラムAは記憶装置11に記憶される。第1情報処理装置1は機械語のプログラムAを第2情報処理装置2に送信する。
  (第2情報処理装置の構成)
 図2は、本実施形態に係る第2情報処理装置2の構成の一例を模式的に示すブロック図である。第2情報処理装置2は、例えばPLC(プログラマブルロジックコントローラ)等の各種の機器の動作を制御する制御装置であってもよい。第2情報処理装置2は、プログラム管理部21と、補助記憶装置22と、メモリ23とを備える。
  プログラム管理部21は、プログラムA管理部21aと、プログラムB管理部21bとを含む。プログラムA管理部21aは、機械語のプログラムAを実行する。プログラムB管理部21bは、機械語のプログラムBを実行する。
  補助記憶装置22は、第1情報処理装置1から受け取ったプログラムAおよびプログラムBを格納する。メモリ23は、プログラムAおよびプログラムBを一時的に記憶する。補助記憶装置22は、例えば、不揮発性のメモリ、またはハードディスク等であるが、これに限らない。
  メモリ23は、プログラムAおよびプログラムBを一時的に記憶する。メモリ23は、例えば揮発性のメモリ等であるが、これに限らない。メモリ23は、データ記憶部23aと、共有変数シンボルテーブル23bとを備える。データ記憶部23aは、プログラムAおよびプログラムBの両方から参照可能な共有変数のデータを記憶している。
  ここでいう共有変数とは、複数のユーザプログラムから参照可能な変数のことを指す。共有変数シンボルテーブル23bは、データ記憶部23aに記憶されている前記共有変数の記憶場所(アドレス)を記憶している。
  (プログラムAの実行)
 図3は、共有変数シンボルテーブル23bの詳細を例示する図である。プログラムA管理部21aは、ユーザからプログラムAを実行する指示を受けると、補助記憶装置22からプログラムAをロードし、メモリ23にプログラムAを記憶させる。補助記憶装置22に格納されたプログラムAは、機械語に変換された(コンパイルおよびリンクされた)プログラムである。機械語に変換されたプログラムAは、共有変数名と該共有変数のアドレスとの対応関係を示すシンボルテーブルを含む。非共有変数は、プログラムAの中だけで使用され、プログラムAのみが参照可能な変数である。コンパイルされたプログラムAにおいて、非共有変数のアドレスが規定されている。コンパイルされたプログラムAにおいて、非共有変数の変数名の情報は残っていなくてもよい。ただし、プログラムAは、コンパイルされた後でも、共有変数の共有変数名の情報とアドレスの情報とを含む。
  プログラムA管理部21aは、共有変数名の情報、および対応するアドレスの情報を取得する。プログラムA管理部21aは、前記共有変数名と、前記共有変数の前記アドレスとを対応付けて、共有変数シンボルテーブル23bに記録する。また、プログラムA管理部21aは、データ記憶部23aの前記アドレスに、前記共有変数のデータを書き込む。
  (識別子)
 ユーザプログラムの識別子は、該ユーザプログラムに固有の文字列または数値である。複数のユーザプログラムの識別子は、互いに重複しないように設定される。例えば、ユーザプログラムのプログラム名、ユーザプログラムの配置先ディレクトリのパス、ユーザが任意に設定する文字列、UUID(universally unique identifier)、またはドメイン名を、該ユーザプログラムの識別子としてもよい。
  図3の例示では、プログラムAの識別子が「Press」である。変数名「status」は、プログラムAのソースコードで定義された共有変数の変数名である。共有変数名生成部121bは、識別子「Press」と元々の変数名「status」を組み合わせることで、該共有変数の共有変数名「Press.status」を生成する。共有変数名「Press.status」は、他のプログラムBから該共有変数を参照するときにキーとして使用される変数名である。ここでは、識別子と変数名との間に「.」を加えているが、代わりに任意の文字または文字列を用いてもよい。また、識別子と変数名との間の文字はなくてもよい。識別子と変数名との順番も任意である。例えば、図3に例示する「Cutter.status」は、プログラムBで定義される共有変数の、共有変数名である。プログラムBの識別子が「Cutter」である。プログラムBで定義されている共有変数の変数名は「status」である。共有変数名生成部121bは、所定の規則に沿って識別子と変数名とを含む共有変数名を生成する。これにより、複数のユーザプログラムにおいて、変数名「status」が同じ複数の共有変数が定義されていても、共有変数名の衝突を回避することができる。共有変数名はたとえばPress.status、Cutter.statusを挙げ、これらの共有変数名に対応するアドレスはそれぞれ0X00000000、0X00000001を挙げたが、これは本実施形態を限定するものではない。
  (プログラムBのコンパイルおよびリンク)
 プログラムBはプログラムAが定義した(生成した)共有変数を参照(読み出し)する。第1情報処理装置1のコンパイル装置12は、プログラムBのソース11bのコンパイルおよびリンクを行う。
  具体的には、プログラムBのソースコードにおいて、他のプログラムAで定義された共有変数を参照する命令が記述されている。なお、ユーザは、参照する共有変数の共有変数名「Press.status」を知っているものとする。例えば、ユーザは、プログラムBを作る際に、共有変数の変数名として共有変数名「Press.status」を使用してソースコードを記述する。
  判定部121dは、前記プログラムBの前記ソースコードに記述されている変数が、共有変数か非共有変数かを判定する。また、判定部121dは、前記プログラムBの前記ソースコードに記述されている共有変数が、プログラムBの中で生成(定義)された共有変数か、他のプログラムの中で生成(定義)された共有変数かを判定する。例えば、ソースコードにおいて、所定の宣言をすることにより、変数が自プログラムで生成された共有変数であるか、他のプログラムで生成された共有変数であるか、非共有変数であるかが定義されていてもよい。また、例えば、判定部121dは、変数の変数名に所定の識別子(他のプログラムの識別子)が含まれる場合、該変数を他のプログラムの中で生成された共有変数であると判定してもよい。
  変換部121cは、前記プログラムBの前記ソースコードを機械語に変換する。変数が自プログラムで生成された共有変数である場合、コンパイルおよびリンクの方法はプログラムAに関して説明した通りである。
  変数が他のプログラム(例えばプログラムA)で生成された共有変数である場合について説明する。変数が他のプログラム(例えばプログラムA)で生成された共有変数である場合、変換部121cは、前記プログラムBの前記ソースコードにおける共有変数にアクセス(参照)する命令を、API(application program interface)を介して前記共有変数にアクセスする機械語命令に置き換える。このAPIは、共有変数のアドレスを知っているプログラム管理部21が提供するAPIである。プログラム管理部21は、共有変数名をキーにして、共有変数シンボルテーブル23bから共有変数のアドレスを取得することができる。
  例えば、プログラム管理部21(プログラムA管理部21aおよびプログラムB管理部21b)は、共有変数名をキーにして共有変数の値(データ)を返す第1API、または、共有変数名をキーにして共有変数のアドレス返す第2APIおよびアドレスをキーにして変数(共有変数)の値を返す第3APIを提供する。変換部121cは、前記プログラムBの前記ソースコードにおける共有変数にアクセス(参照)する命令を、第1APIを介して共有変数を参照する機械語命令に置き換えてもよい。変換部121cは、前記プログラムBの前記ソースコードにおける共有変数にアクセス(参照)する命令を、第2APIを介してアドレスを取得する機械語命令と、第3APIを介して共有変数を参照する機械語命令とに置き換えてもよい。
  リンカ122は、コンパイラ121により変換された複数のオブジェクトコードを結合する。他のプログラムで生成された共有変数に対しては、アドレスは決定されない。変数が非共有変数である場合(共有変数ではない場合)、アドレス決定部122aは、機械語に変換されたプログラムBにおける(シンボリックな参照を用いた)前記変数にアクセスする命令を、APIを利用せずに前記変数のアドレスにアクセスする機械語命令に置き換える。
  機械語の(実行形式に変換された)プログラムBは記憶装置11に記憶される。第1情報処理装置1は機械語のプログラムBを第2情報処理装置2に送信する。なお、プログラムAとプログラムBとは、互いに異なる情報処理装置においてコンパイルおよびリンクされてもよい。
  (プログラムBの実行)
 第2情報処理装置2において、プログラムAは先に実行され、プログラムAで定義された共有変数の共有変数名およびアドレスは、共有変数シンボルテーブル23bに記録されている。プログラムB管理部21bは、ユーザからプログラムBを実行する指示を受けると、補助記憶装置22からプログラムAをロードし、メモリ23にプログラムAを記憶させる。補助記憶装置22に格納されたプログラムBは、機械語に変換された(コンパイルおよびリンクされた)プログラムである。機械語に変換されたプログラムBは、共有変数名をキーとして共有変数を参照するAPI(第1API、第2APIまたは第3API)を呼び出す命令を含む。コンパイルされたプログラムBにおいて、非共有変数のアドレスが規定されている。コンパイルされたプログラムBにおいて、非共有変数の変数名の情報は残っていなくてもよい。ただし、プログラムBは、コンパイルされた後でも、共有変数の共有変数名の情報を含む。
  プログラムBは、キーとして共有変数の共有変数名「Press.status」をAPI関数を介してプログラムB管理部21bに渡す。プログラムB管理部21bは、共有変数シンボルテーブル23bから該共有変数名に対応するアドレスを取得する。プログラムB管理部21bは、アドレスをキーにしてデータ記憶部23aから共有変数のデータを取得する。プログラムB管理部21bは、共有変数のデータをプログラムBに返す。このように、プログラムB管理部21bは、共有変数シンボルテーブル23bを参照して、共有変数のアドレスを知ることができる。
  通常、コンパイラ型のユーザプログラムは、機械語に変換されている。そのため、ソースファイルで規定した変数名は、アドレスに変換されており、残っていない。上記の態様によれば、共有変数を参照するAPIを用いることで、コンパイルおよびリンクされたプログラムBの中の共有変数名はキーとして残る。
  前記プログラムAと、前記プログラムBとは、互いに異なるプログラミング言語で構成されたものであってもよい。上記の態様によれば、互いに異なるプログラミング言語で構成されたプログラムAとプログラムBとの間で、変数を共有することができる。例えば、プログラムAと、プログラムBとは、同じプログラミング言語で構成されたものであってもよい。
  ここで、プログラムAまたはプログラムBとして、ラダー言語またはC言語等を用いたプログラムが挙げられるが、これは本実施形態を限定するものではない。ラダー言語は、第2情報処理装置2が工作機械または生産装置等の動作制御を行う場合に適したプログラミング言語である。例えば、C言語の場合、ソースはテキストファイルである。例えば、ラダー言語の場合、ソースはラダー図を表現するテキストファイルまたはバイナリファイルであり得る。
  本実施形態に係るコンパイル装置12によれば、共有変数を定義するプログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きすることを防止することができる。
  なお、コンパイル装置12は、プログラムBだけでなく、共有変数を定義したプログラムAにおいても、共有変数にアクセスする命令を、APIを介して共有変数にアクセスする機械語命令に置き換えてもよい。この場合、プログラムAを実行するプログラムA管理部21aは、共有変数シンボルテーブル23bに前記共有変数名が記録されていない場合、前記共有変数に割り当てる前記アドレスを決定する。プログラムA管理部21aは、決定した前記アドレスと前記共有変数名とを対応付けて共有変数シンボルテーブル23bに記録する。
  (識別子の構成例1)
 以下、本実施形態1に係る識別子の構成例1について説明する。識別子の構成例1として、例えばコンパイル実行時にユーザによって指定された引数であってもよい。そして、識別子取得部121aは、この引数を前記識別子として用いる。
  (識別子の構成例2)
 以下、本実施形態1に係る識別子の他の構成例について説明する。識別子は、前記引数に限定されない。例えば、識別子は、前記プログラムAが配置される予定のパスを含んでいてもよい。ユーザは、プログラムAを作成する際に、プログラムAを配置する予定であるディレクトリのパスをプログラムA内で規定しておく。または、プログラムA自身が、プログラムAのパスを取得してもよい。第1情報処理装置1と第2情報処理装置2とは、分かれておらず同じ情報処理装置であってもよい。
  (識別子の構成例3)
 以下、本実施形態1に係る識別子の更に他の構成例について説明する。識別子は、前記引数および前記パスに限定されない。例えば、識別子は、前記プログラムAのファイル名を含んでいてもよい。パスと同様に、ファイル名はプログラムA内で規定されていてもよいし、プログラムA自身がプログラムAのファイル名を取得してもよい。
  (識別子の取得例1)
 以下、本実施形態1に係る識別子の取得例について説明する。上述したように、識別子取得部121aは、プログラムAの識別子を取得する。具体的には、識別子取得部121aは、設定ファイルから、前記識別子を取得する。プログラムAの識別子を規定する設定ファイルは、所定のディレクトリに格納されている。
  (識別子の取得例2)
 以下、本実施形態1に係る識別子の他の取得例について説明する。識別子の取得先は、前記設定ファイルに限定されない。例えば、識別子取得部121aは、前記プログラムAの前記ソースコードから前記識別子を取得してもよい。この場合、前記ソースコードにおいて、前記プログラムAおよび前記プログラムBの両方から参照可能な共有変数が定義されている。
  (共有変数名生成部の構成)
 上述したように、共有変数名生成部121bは、前記プログラムAの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成する。例示として、共有変数名はたとえばPress.status、Cutter.status等が挙げられる。
  (変換部の構成)
 上述したように、変換部121cは、前記プログラムA、Bを機械語に変換する。具体的には、変換部121cは、前記プログラムAの前記ソースコードにおける前記共有変数にアクセスする命令を、前記共有変数の前記アドレスにアクセスする機械語命令に置き換える。
  変換部121cは、前記共有変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記共有変数にアクセスする機械語命令に置き換える。
  (コンパイル方法)
 図4は、本実施形態に係るコンパイル装置12がプログラムAのコンパイルおよびリンクを実行する工程のフロチャートである。ステップS1において、識別子取得部121aは、プログラムA(第1ユーザプログラム)の識別子を取得する。続いて、ステップS2において、共有変数名生成部121bは、プログラムAの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成する。続いて、ステップS3において、変換部121cは、プログラムAを機械語に変換する。続いて、ステップS4において、アドレス決定部122aは、前記共有変数のアドレスを決定する。最後に、ステップS5において、アドレス決定部122aは、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換されたプログラムAに埋め込む。
  図5は、本実施形態に係るコンパイル装置12がプログラムBのコンパイルおよびリンクを実行する工程のフロチャートである。ステップS6において、判定部121dは、プログラムBのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する。変換部121cは、プログラムBを機械語に変換する。このとき、変数が共有変数である場合(S6でYes)、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換える(S8)。変数が共有変数ではない場合(S6でNo)、リンクの段階でアドレス決定部122aは、前記変数にアクセスする命令を、APIを利用せずに前記変数のアドレスにアクセスする機械語命令に置き換える(S7)。ここでは、コンパイルおよびリンクの工程を、合わせて変換工程と称する。
  上記の態様によれば、他のプログラムAが生成した共有変数のアドレスをプログラムBおよび第1情報処理装置1が知らなくても、プログラムBが該共有変数にアクセス可能なように、コンパイル装置12は、プログラムBをコンパイルおよびリンクすることができる。
  このように、変換部121cが、プログラムBのソース11bにおける共有変数へのアクセス(書き込み/参照)命令を、APIを利用した命令に置き換える。機械語に変換されたプログラムBにおいて、共有変数のアドレスは決定されない。
  なお、非共有変数は、アドレス決定部122aによってアドレスが決定され、機械語のプログラムBの中の非共有変数の変数名はアドレスに置き換えられる。
  〔ソフトウェアによる実現例〕
 コンパイル装置12およびプログラム管理部21の制御ブロック(特に識別子取得部121a、共有変数名生成部121b、変換部121c、判定部121d、アドレス決定部122a、プログラムA管理部21a、およびプログラムB管理部21b)は、集積回路(ICチップ)等に形成された論理回路(ハードウェア)によって実現してもよいし、ソフトウェアによって実現してもよい。
  後者の場合、コンパイル装置12およびプログラム管理部21は、各機能を実現するソフトウェアであるプログラムの命令を実行するコンピュータを備えている。このコンピュータは、例えば1つ以上のプロセッサを備えていると共に、上記プログラムを記憶したコンピュータ読み取り可能な記録媒体を備えている。そして、上記コンピュータにおいて、上記プロセッサが上記プログラムを上記記録媒体から読み取って実行することにより、本発明の目的が達成される。上記プロセッサとしては、例えばCPU(Central Processing Unit)を用いることができる。上記記録媒体としては、「一時的でない有形の媒体」、例えば、ROM(Read Only Memory)等の他、テープ、ディスク、カード、半導体メモリ、プログラマブルな論理回路などを用いることができる。また、上記プログラムを展開するRAM(Random Access Memory)などをさらに備えていてもよい。また、上記プログラムは、該プログラムを伝送可能な任意の伝送媒体(通信ネットワークや放送波等)を介して上記コンピュータに供給されてもよい。なお、本発明の一態様は、上記プログラムが電子的な伝送によって具現化された、搬送波に埋め込まれたデータ信号の形態でも実現され得る。
 〔まとめ〕
  本発明の一態様に係るコンパイル装置は、第1ユーザプログラムのソースコードにおいて、前記第1ユーザプログラムおよび第2ユーザプログラムの両方から参照可能な共有変数が定義されており、前記第1ユーザプログラムの識別子を取得する識別子取得部と、前記第1ユーザプログラムの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成する共有変数名生成部と、前記第1ユーザプログラムを機械語に変換する変換部と、前記共有変数のアドレスを決定するアドレス決定部と、を備え、前記アドレス決定部は、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込む。
  上記の態様によれば、共有変数を定義するプログラムが複数存在する場合、変数名が衝突し意図せずにデータを上書きすることを防止することができる。
  本発明の一態様では、前記アドレス決定部は、機械語に変換された前記第1ユーザプログラムにおける前記共有変数にアクセスする命令を、前記共有変数の前記アドレスにアクセスする命令に置き換えてもよい。
  上記の態様によれば、前記変換部は、前記共有変数にアクセスする命令を前記共有変数の前記アドレスにアクセスする機械語命令に置き換えることができる。共有変数を定義したプログラムにおいては、アドレスを利用して共有変数にアクセスすることで、高速にアクセスすることができる。
  本発明の一態様では、前記識別子取得部は、設定ファイルから、前記識別子を取得することを特徴とする。
  上記の態様によれば、前記識別子取得部は、設定ファイルから、前記識別子を取得することができる。
  本発明の一態様では、前記識別子取得部は、前記第1ユーザプログラムの前記ソースコードから前記識別子を取得することを特徴とする。
  上記の態様によれば、前記識別子取得部は、前記第1ユーザプログラムの前記ソースコードから前記識別子を取得することができる。
  本発明の一態様では、前記識別子取得部は、コンパイル実行時にユーザによって指定された引数を前記識別子として用いることを特徴とする。
  上記の態様によれば、前記識別子取得部は、前記引数を前記識別子として用いることができる。
  本発明の一態様では、前記識別子は、前記第1ユーザプログラムが配置される予定のパスを含むことを特徴とする。
  上記の態様によれば、前記識別子は、前記第1ユーザプログラムが配置される予定のパスを含むことができる。
  本発明の一態様では、前記識別子は、前記第1ユーザプログラムのファイル名を含むことを特徴とする。
  上記の態様によれば、前記識別子は、前記第1ユーザプログラムのファイル名を含むことができる。
  本発明の一態様に係るコンパイル方法では、第1ユーザプログラムのソースコードにおいて、前記第1ユーザプログラムおよび第2ユーザプログラムの両方から参照可能な共有変数が定義されており、前記第1ユーザプログラムの識別子を取得し、前記第1ユーザプログラムの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成し、前記第1ユーザプログラムを機械語に変換し、前記共有変数のアドレスを決定し、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込むことを特徴とする。
  本発明の一態様に係るコンパイル装置は、第2ユーザプログラムのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する判定部と、前記第2ユーザプログラムを機械語に変換する変換部と、アドレス決定部とを備え、前記変数が共有変数ではない場合、前記アドレス決定部は、前記変数にアクセスする命令を、API(application program interface)を利用せずに前記変数のアドレスにアクセスする機械語命令に置き換え、前記変数が共有変数である場合、前記変換部は、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換えることを特徴とする。
  上記の態様によれば、他の第1ユーザプログラムが定義した共有変数に第2ユーザプログラムがアクセス可能なように、第2ユーザプログラムをコンパイルおよびリンクすることができる。
  本発明の一態様に係るコンパイル方法では、第2ユーザプログラムのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する判定工程と、前記第2ユーザプログラムを機械語に変換する変換工程とを含み、前記変換工程では、前記変数が共有変数ではない場合、前記変数にアクセスする命令を、API(application program interface)を利用せずに前記変数のアドレスにアクセスする機械語命令に置き換え、前記変数が共有変数である場合、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換えることを特徴とする。
  本発明は上述した各実施形態に限定されるものではなく、請求項に示した範囲で種々の変更が可能であり、異なる実施形態にそれぞれ開示された技術的手段を適宜組み合わせて得られる実施形態についても本発明の技術的範囲に含まれる。
 1 第1情報処理装置
2 第2情報処理装置
11 記憶装置
12 コンパイル装置
21 プログラム管理部
21a プログラムA管理部
21b プログラムB管理部
121 コンパイラ
121a 識別子取得部
121b 共有変数名生成部
121c 変換部
121d 判定部
122 リンカ
122a アドレス決定部

Claims (10)

  1.  第1ユーザプログラムのソースコードにおいて、前記第1ユーザプログラムおよび第2ユーザプログラムの両方から参照可能な共有変数が定義されており、
     前記第1ユーザプログラムの識別子を取得する識別子取得部と、
     前記第1ユーザプログラムの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成する共有変数名生成部と、
     前記第1ユーザプログラムを機械語に変換する変換部と、
     前記共有変数のアドレスを決定するアドレス決定部と、を備え、
     前記アドレス決定部は、前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込むことを特徴とするコンパイル装置。
  2.  前記アドレス決定部は、機械語に変換された前記第1ユーザプログラムにおける前記共有変数にアクセスする命令を、前記共有変数の前記アドレスにアクセスする命令に置き換えることを特徴とする請求項1に記載のコンパイル装置。
  3.  前記識別子取得部は、設定ファイルから、前記識別子を取得することを特徴とする請求項1または2に記載のコンパイル装置。
  4.  前記識別子取得部は、前記第1ユーザプログラムの前記ソースコードから前記識別子を取得することを特徴とする請求項1または2に記載のコンパイル装置。
  5.  前記識別子取得部は、コンパイル実行時にユーザによって指定された引数を前記識別子として用いることを特徴とする請求項1または2に記載のコンパイル装置。
  6.  前記識別子は、前記第1ユーザプログラムが配置される予定のパスを含むことを特徴とする請求項1から5のいずれか一項に記載のコンパイル装置。
  7.  前記識別子は、前記第1ユーザプログラムのファイル名を含むことを特徴とする請求項1から5のいずれか一項に記載のコンパイル装置。
  8.  第1ユーザプログラムのソースコードにおいて、前記第1ユーザプログラムおよび第2ユーザプログラムの両方から参照可能な共有変数が定義されており、
     前記第1ユーザプログラムの識別子を取得し、
     前記第1ユーザプログラムの前記ソースコードにおける前記共有変数の変数名と、前記識別子とを含む共有変数名を生成し、
     前記第1ユーザプログラムを機械語に変換し、
     前記共有変数のアドレスを決定し、
     前記共有変数名と前記共有変数の前記アドレスとを対応付けて、機械語に変換された前記第1ユーザプログラムに埋め込むことを特徴とするコンパイル方法。
  9.  第2ユーザプログラムのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する判定部と、
     前記第2ユーザプログラムを機械語に変換する変換部と、
     アドレス決定部とを備え、
     前記変数が共有変数ではない場合、前記アドレス決定部は、前記変数にアクセスする命令を、API(application program interface)を利用せずに前記変数のアドレスにアクセスする機械語命令に置き換え、
     前記変数が共有変数である場合、前記変換部は、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換えることを特徴とするコンパイル装置。
  10.  第2ユーザプログラムのソースコードにおいて参照されている変数が、共有変数であるか否かを判定する判定工程と、
     前記第2ユーザプログラムを機械語に変換する変換工程とを含み、
     前記変換工程では、
      前記変数が共有変数ではない場合、前記変数にアクセスする命令を、API(application program interface)を利用せずに前記変数のアドレスにアクセスする機械語命令に置き換え、
      前記変数が共有変数である場合、前記変数にアクセスする命令を、前記共有変数のアドレスを知っているプログラム管理部が提供するAPIを介して前記変数にアクセスする機械語命令に置き換えることを特徴とするコンパイル方法。
PCT/JP2019/023996 2018-07-03 2019-06-18 コンパイル装置およびコンパイル方法 WO2020008855A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US17/251,182 US11226814B2 (en) 2018-07-03 2019-06-18 Compiler device and compiling method
EP19830528.6A EP3819756A4 (en) 2018-07-03 2019-06-18 COMPILERS AND COMPILATION METHODS
CN201980039733.7A CN112334873A (zh) 2018-07-03 2019-06-18 编译装置以及编译方法

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2018126935A JP6950635B2 (ja) 2018-07-03 2018-07-03 コンパイル装置およびコンパイル方法
JP2018-126935 2018-07-03

Publications (1)

Publication Number Publication Date
WO2020008855A1 true WO2020008855A1 (ja) 2020-01-09

Family

ID=69059557

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2019/023996 WO2020008855A1 (ja) 2018-07-03 2019-06-18 コンパイル装置およびコンパイル方法

Country Status (5)

Country Link
US (1) US11226814B2 (ja)
EP (1) EP3819756A4 (ja)
JP (1) JP6950635B2 (ja)
CN (1) CN112334873A (ja)
WO (1) WO2020008855A1 (ja)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04260134A (ja) 1991-02-15 1992-09-16 Nec Corp 言語処理システムの名標管理方式
JPH11272475A (ja) * 1998-03-20 1999-10-08 Nec Corp 非リエントラントプログラムの自動リエントラント化方法及びシステム
JP2000132208A (ja) 1998-10-28 2000-05-12 Omron Corp コントロール制御装置
JP2001109632A (ja) * 1999-10-13 2001-04-20 Nec Ic Microcomput Syst Ltd プログラム翻訳システム及びプログラム翻訳方法
JP2001282864A (ja) * 2000-03-29 2001-10-12 Matsushita Electric Ind Co Ltd 機能ブロック修正方法
JP2006099639A (ja) * 2004-09-30 2006-04-13 Denso Wave Inc プログラム作成装置,制御装置及びコンピュータプログラム
JP2006244488A (ja) 2005-02-28 2006-09-14 Microsoft Corp 異なるアプリケーションフレームワーク間のデータサービスのためのプラットフォーム
WO2018198439A1 (ja) * 2017-04-27 2018-11-01 株式会社日立産機システム 産業用コントローラ及び産業用コントローラにおけるデータ共有方法

Family Cites Families (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6067413A (en) * 1996-06-13 2000-05-23 Instantations, Inc. Data representation for mixed-language program development
US6351848B1 (en) * 1998-05-29 2002-02-26 Sun Microsystems, Inc. Unitary data structure systems, methods, and computer program products, for global conflict determination
JP3901530B2 (ja) * 2001-01-31 2007-04-04 株式会社東芝 ソフトウェア・ハードウェア言語モデル変換装置及びプログラム
CN100388200C (zh) * 2003-01-06 2008-05-14 松下电器产业株式会社 编译方法、编译单元,目标程序执行方法及单元
JP4500040B2 (ja) * 2003-01-06 2010-07-14 パナソニック株式会社 コンパイラプログラム、コンパイラプログラムを記録したコンピュータ読み取り可能な記録媒体、コンパイル方法及びコンパイル装置
US7712080B2 (en) * 2003-05-21 2010-05-04 The Regents Of The University Of California Systems and methods for parallel distributed programming
US7380086B2 (en) * 2003-12-12 2008-05-27 International Business Machines Corporation Scalable runtime system for global address space languages on shared and distributed memory machines
JP2005228047A (ja) * 2004-02-13 2005-08-25 Toshiba Corp 言語処理装置及び言語処理プログラム
US7366956B2 (en) * 2004-06-16 2008-04-29 Hewlett-Packard Development Company, L.P. Detecting data races in multithreaded computer programs
US7757237B2 (en) * 2004-06-16 2010-07-13 Hewlett-Packard Development Company, L.P. Synchronization of threads in a multithreaded computer program
US7555748B2 (en) * 2004-08-30 2009-06-30 International Business Machines Corporation Method and apparatus for improving data cache performance using inter-procedural strength reduction of global objects
CN1790268A (zh) * 2004-12-14 2006-06-21 艾克斯麦提克方案私人有限公司 通过散列技术的编译时间链接
US8161464B2 (en) * 2006-04-11 2012-04-17 International Business Machines Corporation Compiling source code
US7725881B2 (en) * 2006-06-09 2010-05-25 Microsoft Corporation Automatically extracting coupling metrics from compiled code
US20080005728A1 (en) * 2006-06-30 2008-01-03 Robert Paul Morris Methods, systems, and computer program products for enabling cross language access to an addressable entity in an execution environment
US20080005727A1 (en) * 2006-06-30 2008-01-03 Robert Paul Morris Methods, systems, and computer program products for enabling cross language access to an addressable entity
CN101782860B (zh) * 2009-01-21 2013-10-09 华为技术有限公司 一种程序链接方法及装置
US8549468B2 (en) * 2010-02-08 2013-10-01 National Tsing Hua University Method, system and computer readable storage device for generating software transaction-level modeling (TLM) model
US20120233410A1 (en) * 2011-03-13 2012-09-13 National Tsing Hua University Shared-Variable-Based (SVB) Synchronization Approach for Multi-Core Simulation
KR101219535B1 (ko) * 2011-04-28 2013-01-10 슈어소프트테크주식회사 코드 컨버팅 장치, 방법 및 컴퓨터 판독 가능한 기록 매체
US8898648B2 (en) * 2012-11-30 2014-11-25 International Business Machines Corporation Methodology for fast detection of false sharing in threaded scientific codes
US10261889B2 (en) * 2014-06-25 2019-04-16 Microsoft Technology Licensing, Llc Techniques for edit-and-continue and enhanced optimized debugging on optimized code
US9940267B2 (en) * 2016-05-17 2018-04-10 Nxp Usa, Inc. Compiler global memory access optimization in code regions using most appropriate base pointer registers
CN106407111B (zh) * 2016-09-07 2019-05-17 努比亚技术有限公司 终端测试装置、终端测试设备及变量维护方法
JP2019144762A (ja) * 2018-02-19 2019-08-29 株式会社東芝 プログラマブルコントローラ

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04260134A (ja) 1991-02-15 1992-09-16 Nec Corp 言語処理システムの名標管理方式
JPH11272475A (ja) * 1998-03-20 1999-10-08 Nec Corp 非リエントラントプログラムの自動リエントラント化方法及びシステム
JP2000132208A (ja) 1998-10-28 2000-05-12 Omron Corp コントロール制御装置
JP2001109632A (ja) * 1999-10-13 2001-04-20 Nec Ic Microcomput Syst Ltd プログラム翻訳システム及びプログラム翻訳方法
JP2001282864A (ja) * 2000-03-29 2001-10-12 Matsushita Electric Ind Co Ltd 機能ブロック修正方法
JP2006099639A (ja) * 2004-09-30 2006-04-13 Denso Wave Inc プログラム作成装置,制御装置及びコンピュータプログラム
JP2006244488A (ja) 2005-02-28 2006-09-14 Microsoft Corp 異なるアプリケーションフレームワーク間のデータサービスのためのプラットフォーム
WO2018198439A1 (ja) * 2017-04-27 2018-11-01 株式会社日立産機システム 産業用コントローラ及び産業用コントローラにおけるデータ共有方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3819756A4

Also Published As

Publication number Publication date
JP2020008942A (ja) 2020-01-16
CN112334873A (zh) 2021-02-05
EP3819756A1 (en) 2021-05-12
JP6950635B2 (ja) 2021-10-13
EP3819756A4 (en) 2022-03-23
US11226814B2 (en) 2022-01-18
US20210216309A1 (en) 2021-07-15

Similar Documents

Publication Publication Date Title
JP4638484B2 (ja) データ処理装置におけるデータ整合性
US8881123B2 (en) Enabling symbol resolution of private symbols in legacy programs and optimizing access to the private symbols
CN112685030A (zh) 一种生成业务代码的方法、装置、存储介质及电子设备
CN101208690A (zh) 计算环境中翻译表达式
WO2020008855A1 (ja) コンパイル装置およびコンパイル方法
WO2020008867A1 (ja) 制御装置および制御方法
CN115658140A (zh) 一种sdk的打包方法、装置、终端以及存储介质
JP2008165342A (ja) ソースコード生成方法及び装置並びにプログラム
US20160283291A1 (en) Facilitating communication between software components that use middleware
JP5141095B2 (ja) プラントコントローラシステム
JP6455096B2 (ja) コントロールシステム、その支援装置、プログラマブルコントロール装置
CN106547519B (zh) 信息处理方法及系统
JP2014228990A (ja) 制御プログラム作成装置および制御プログラム作成方法
CN109947407B (zh) 一种数据获取方法及装置
JP2007213392A (ja) Sqlトレース取得システム及び方法
JP2016062311A (ja) 更新装置及び情報処理方法
JP2019179383A (ja) Api処理方法、端末、api処理プログラム
EP3301527A2 (en) Method to extend mes functionalities in a message routing system
JP2013190837A (ja) エンジニアリングツール
KR101992419B1 (ko) 자바 응용을 관제하는 자바 응용 관제 장치 및 방법
KR100583154B1 (ko) 반도체 장비서버의 프로그램 소스 및 헤더 파일 정의방법
CN110249590B (zh) 控制系统及路径信息生成方法
CN112988225A (zh) 注解配置方法、装置、设备及存储介质
JP2022018696A (ja) 制御プログラム生成装置
CN117369784A (zh) 一种服务接口的处理系统及方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19830528

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2019830528

Country of ref document: EP

Effective date: 20210203