WO2010125960A1 - マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム - Google Patents

マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム Download PDF

Info

Publication number
WO2010125960A1
WO2010125960A1 PCT/JP2010/057122 JP2010057122W WO2010125960A1 WO 2010125960 A1 WO2010125960 A1 WO 2010125960A1 JP 2010057122 W JP2010057122 W JP 2010057122W WO 2010125960 A1 WO2010125960 A1 WO 2010125960A1
Authority
WO
WIPO (PCT)
Prior art keywords
variable
statement
program code
path
conditional
Prior art date
Application number
PCT/JP2010/057122
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 CN201080005431.7A priority Critical patent/CN102292709B/zh
Priority to JP2011511377A priority patent/JP5204300B2/ja
Priority to KR1020117027092A priority patent/KR20120058455A/ko
Publication of WO2010125960A1 publication Critical patent/WO2010125960A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/45Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
    • G06F8/458Synchronisation, e.g. post-wait, barriers, locks

Definitions

  • the present invention relates to a method for converting a program code of a program operating on a multi-thread into a program code with less lock collision, and a computer program and a computer system thereof.
  • a shift to a so-called multi-core in which a plurality of CPU cores are enclosed in one central processing unit (hereinafter referred to as a CPU: Central Processing Unit) has been advanced.
  • the multi-core is recognized as two CPUs internally although it is one CPU externally. With the multi-core, it is possible to increase the processing capability of the entire CPU chip and improve the system performance in an environment where mainly parallel processing is performed. Multi-core dramatically increases the number of hardware threads that a processor can execute simultaneously. For example, SUN (TM) Niagara2 (TM) can execute 64 threads on one CPU.
  • the lock collision is a state in which when a lock is acquired to enter a critical section that requires exclusive execution in one thread, the next step is not executed until the lock is released in another thread.
  • a thread where the next step is not executed typically goes into a spin loop or sleep state.
  • lock collision There are various causes for the occurrence of lock collision. For example, consider the case of a program in which processing for retrieving data from a queue is frequently executed by a plurality of threads. Also, consider a case where a sentence about the process to be taken out is described in a synchronous block for describing a process that requires exclusive execution in the program code of the program. At the time of execution, the program always acquires a lock every time the process to be taken out is called. Therefore, lock collisions frequently occur. Therefore, the above-mentioned lock collision that frequently occurs may cause a system performance problem.
  • a program code having a structure similar to that of the program code is as follows.
  • the poll () method corresponding to the above-described extraction process that is a method of the above class is corrected in SUN JDK 1.5.0_14.
  • the following non-patent document 1 adds a marked bit to a program code, and uses the marked marked bit and a compareAndSwap (CAS) instruction so that the program code has a high concurrency. Indicate that the code can be transformed.
  • CAS compareAndSwap
  • the present invention provides a method for converting a program code of a program operating on a multi-thread into a program code with few lock collisions.
  • the method causes a computer system to perform the following steps.
  • the step is Reading the program code into a memory and searching the first conditional statement for branching from the read program code to a path in the synchronous block and having no side effect on the synchronous block, If there is no, the value being processed by the statement in the synchronization block cannot be referred to by a statement outside the synchronization block, the searching step, Duplicating a path without side effects branched by the searched first conditional statement outside the synchronization block;
  • the first conditional statement includes a first conditional expression.
  • the first conditional expression is defined so as to select a path based on reading of the first variable, a constant, or a combination thereof.
  • the first variable is not a variable that is valid only in a routine that calls a subroutine including the first conditional statement.
  • the second conditional statement selects a path according to the result of the first conditional expression, based on a variable for storing the result of the first conditional expression.
  • a second conditional expression is included.
  • the step of searching includes the step of further searching for an update sentence from the read program code, the update sentence being in the synchronization block and the first variable.
  • Update The adding step includes a variable for storing the result of the first conditional expression immediately after the searched update sentence to an end sentence of the synchronous block, and the first assigned to the variable.
  • the step of searching includes the step of further searching for an update sentence from at least one of the read program code and other program code, wherein the update sentence includes the synchronization code.
  • the adding step is assigned to a variable for storing the result of the first conditional expression and the same variable immediately after the searched update sentence until the end sentence of the other synchronization block.
  • the adding step includes a step in which the second conditional statement includes the synchronization block before the statement in which the variable for storing the result of the first conditional expression is referred to for the first time.
  • the method further includes the step of further adding a statement for initializing a variable for storing the result of the first conditional expression by using a value for executing a path including the result or by using the result of the first conditional expression.
  • the side effect is a process that makes it difficult to cancel the execution result.
  • the side effects include processing for executing synchronization between threads, processing for assigning a value to an instance variable, processing for assigning a value to a class variable, processing for executing input / output, and native code.
  • This is a process for calling or a process for assigning a value to a number indicating the position of an array element.
  • the result of the two or more first conditional expressions is obtained by a combination of the two or more first conditional expressions. It is done.
  • the number of paths selected by the first conditional expression is three or more, there are three or more variables for storing the result of the first conditional expression. Corresponds to each path with no side effects.
  • the variable for storing the result of the first conditional expression is a data type variable in which atomicity is guaranteed.
  • the step of searching includes the step of further searching for another synchronization block synchronized with the synchronization block from at least one of the program code and the other program code.
  • the duplicating step is executed.
  • the searching step is included in at least one of the program code and other program code, and the first variable is referenced from a statement outside the synchronization block. Including further searching for sentences, In response to the end of the search, the duplicating step is executed.
  • the step of searching is executed synchronously with a statement in the synchronization block from a statement that describes the implementation of the thread and that is included in at least one of the program code and other program code.
  • the method further causes the computer system to execute a step of determining a path including a sentence that activates the thread as a path having a side effect in response to a search for a sentence to be executed in synchronization.
  • the step of searching further includes the step of requesting the user to determine whether or not the path including the statement that activates the thread is a path having no side effect.
  • the step of searching includes the step of further searching from outside the synchronization block for a sentence that is included in at least one of the program code and other program code and that refers to the used variable;
  • the method further causes the computer system to execute a step of determining a path including the used variable as a path having a side effect in response to a search for a sentence referring to the used variable.
  • the searching step further includes the step of prompting the user to determine whether the path containing the used variable is a path without side effects.
  • the adding step includes a step of further adding a statement declaring a variable for storing the result of the first conditional expression to the read program code,
  • a shared variable is included in at least one of the program code and the other program code and accessed from a statement outside the synchronous block, the declaration suppresses optimization related to the memory access order.
  • the shared variable is included in the path without the side effects, and can be accessed from a plurality of threads.
  • the declaration includes a specification that guarantees atomicity.
  • the step of searching further comprises allowing the user to determine whether there are other synchronization blocks that are synchronized with the synchronization block.
  • the method then causes the computer system to execute the copying step after the allowing step.
  • the step of searching further includes the step of allowing the user to determine whether there is a sentence referring to the first variable. The method then causes the computer system to execute the copying step after the allowing step.
  • the result of the first conditional expression is substituted.
  • a statement for assigning the result of the first conditional expression is added immediately before the end statement of the synchronous block.
  • the present invention also provides a method for converting a program code of a program operating on a multi-thread into a program code with less lock collisions.
  • the method causes a computer system to perform the following steps.
  • the step is Reading the program code into a memory and searching the first conditional statement for branching from the read program code to a path that is in a synchronous block and has no side effect on the synchronous block, If there is no, the value being processed by the statement in the synchronization block cannot be referred to by a statement outside the synchronization block, the searching step, Duplicating a path without side effects branched by the searched first conditional statement outside the synchronization block;
  • the first conditional statement includes a first conditional expression, and when the first conditional expression branches to a path without side effects based on reading of an instance variable or class variable, a constant, or a combination thereof, The result is defined to be true, while when branching to a path with side effects, the result is defined to be false.
  • the second conditional statement includes a second conditional expression, and the second conditional expression is based on a boolean variable for storing a result of the first conditional expression. It is defined to select a path according to the result of the expression.
  • the present invention further provides a computer program that causes a computer to execute each step of the method described in any one of the above methods.
  • the present invention also provides a computer system for converting a program code of a program operating on a multi-thread into a program code with few lock collisions.
  • the computer system A search unit that reads the program code into a memory, and searches for a first conditional statement that branches from the read program code to a path that is in a synchronous block and has no side effect on the synchronous block; The fact that there is no side effect is that the value being processed by the statement in the synchronization block cannot be referred to by a statement outside the synchronization block, A duplicating unit that duplicates a path without a side effect branched by the searched first conditional statement outside the synchronous block; An adder that adds a second conditional statement in the program code in response to the duplication, wherein the second conditional statement is a conditional statement that branches to the duplicated path without side effects, Includes additional parts and.
  • the search unit further searches for an update sentence from the read program code, the update sentence is in the synchronization block, and updates the first variable
  • the additional unit stores a variable for storing the result of the first conditional expression between immediately after the searched update sentence and the end sentence of the synchronous block, and the first assigned to the variable. Add a statement that includes the result of the conditional expression.
  • the retrieval unit further retrieves an update sentence from at least one of the read program code and other program code, and the update sentence is synchronized with the synchronization block. And the first variable is updated between the immediately following the searched update statement and the end statement of the other synchronization block.
  • a statement is further added that includes a variable for storing the result of and the result of the first conditional expression that is assigned to the same variable.
  • the second conditional statement includes the synchronization block before the statement in which the variable for storing the result of the first conditional expression is referred to for the first time.
  • a statement for initializing a variable for storing the result of the first conditional expression is further added using a value for executing the pass or using the result of the first conditional expression.
  • the search unit further searches for another synchronization block synchronized with the synchronization block from at least one of the program code and another program code.
  • the search unit includes a sentence that is included in at least one of the program code and another program code and that refers to the first variable from a sentence outside the synchronization block. Search for more.
  • the computer system further includes a determination unit that determines a path including a sentence that activates the thread as a path having a side effect in response to a search for a sentence executed in synchronization.
  • the search unit when a statement for starting a thread is included in the synchronous block, the search unit further includes a determination unit that allows the user to determine whether a path including a sentence that activates the thread is a path having no side effect.
  • the retrieval unit further retrieves a sentence that is included in at least one of the program code and the other program code and refers to the used variable from outside the synchronization block.
  • the computer system further includes a determination unit that determines a path including the used variable as a path having a side effect when a sentence that refers to the used variable is searched.
  • the search unit further includes a determination unit that allows the user to determine whether the path including the used variable is a path having no side effect.
  • the adding unit further adds a statement declaring a variable for storing the result of the first conditional expression to the read program code,
  • a shared variable is included in at least one of the program code and the other program code and accessed from a statement outside the synchronous block, the declaration suppresses optimization related to the memory access order.
  • the shared variable is included in the path without the side effects, and can be accessed from a plurality of threads.
  • the declaration includes a specification that guarantees atomicity.
  • the search unit further includes a determination unit that allows the user to determine whether there is another synchronization block that is synchronized with the synchronization block.
  • the search unit further includes a determination unit that allows the user to determine whether there is a sentence that refers to the first variable.
  • the second path that can be executed even if the lock is not acquired is automatically found from the first paths in the synchronization block. Then, a conditional statement for executing the second pass without acquiring the detected second pass and lock is added outside the first pass in the program code.
  • FIG. 2 shows an example of program code before conversion shown in FIG. 1 in the embodiment of the present invention.
  • the example of the process step which acquires the information required for conversion among the process steps performed in the conversion program shown in FIG. 1 in the embodiment of the present invention is shown.
  • the example of the process step which performs conversion among the process steps performed in the conversion program shown in FIG. 1 in the embodiment of the present invention is shown.
  • the details of the processing of step 317 described in FIG. 4 in the embodiment of the present invention will be described.
  • FIG. 6 shows input data CL used for specifically explaining the operation of each step shown in FIGS. 3 to 5 in the embodiment of the present invention.
  • FIG. 6 shows input data (converted program code) after the processing of the steps shown in FIGS. 3 to 5 is executed.
  • FIG. 6 shows input data CL used for specifically explaining the operation of each step shown in FIGS. 3 to 5 in the embodiment of the present invention.
  • FIG. 9 shows input data (converted program code) after the processing of each step shown in FIGS. 3 to 5 is executed.
  • FIG. 2 is a block diagram of computer hardware included in the system of FIG. 1 according to an embodiment of the present invention.
  • program code of a program operating on a multi-thread means that a plurality of processing units called threads are generated, and a CPU time is allocated to each of the generated threads.
  • a source code of a program that can perform a plurality of processes. The source code is described using, for example, Java (trademark) language or C ++ language.
  • lock means that when processing is executed by one thread, the processing itself and processing related to the processing are not executed by another thread. For example, when the process to be locked is started in the first thread, the process or the process related to the process is not executed in the second thread. The process in the second thread or a process related to the process can be waited until the process in the first thread is finished, and can be executed after the end.
  • lock collision means that the process executed in one thread is a lock target, and therefore the process itself executed in another thread and the process related to the process are: A state in which execution is waited until the processing executed in the first thread is completed. Further, “there is little lock collision” means that the frequency of occurrence of the lock collision is low and the execution waiting time due to the lock collision is short.
  • Program code converted using an embodiment of the present invention has fewer lock collisions than program code before conversion.
  • the “synchronous block” is a sentence on the program code in which the process to be locked is described.
  • the sentence on the program code is composed of a start sentence of the synchronization block, an end sentence of the synchronization block, and a sentence surrounded by the start sentence and the end sentence.
  • the synchronized block start sentence is, for example, a sentence that describes a synchronized declaration or a sentence that describes a method name modified with a synchronized qualifier.
  • the end sentence of the synchronization block is “ ⁇ ” indicating the end position of the start sentence when the program code is written in, for example, Java (trademark) language.
  • a statement describing the implementation of the subroutine may be included in the synchronous block.
  • a subroutine call is hierarchical, such as a statement that describes the implementation of a subroutine, including a call to another subroutine, a statement that describes the implementation of all subroutines is included in the synchronization block. Further, it may be included.
  • the subroutine is, for example, a method.
  • another synchronization block synchronized with a synchronization block means, for example, a synchronization block in which a variable accessed by a process to be locked is common or a specified lock object is common It is.
  • the lock object is a variable designated in the synchronized declaration of the Java (trademark) language. For example, when the lock object lock is specified in the synchronized declaration that declares the first synchronized block and the lock object lock is specified in the synchronized declaration that declares the second synchronized block, the second synchronized block It is another synchronization block that synchronizes with the synchronization block.
  • the second synchronization block is synchronized with the first synchronization block. This is a synchronous block.
  • the “side effect on the synchronization block” is the process A in which the result of the process in the synchronization block (process A) can be referred to by the process in the statement outside the synchronization block (process B).
  • a side effect on the synchronous block is also a process in which the processing result cannot be easily canceled.
  • Side effects on a synchronous block include, for example, processing in another synchronous block described in the synchronous block, processing to assign a value to an instance variable, processing to assign a value to a class variable, processing to execute input / output, and native code Is a process of calling a process included in the process or a process of assigning a value to a number indicating the position of an array element, but is not limited thereto.
  • the side effect is determined, for example, when the user registers a sentence regarding the processing in a list and the computer system refers to the sentence registered in the list.
  • the input / output is, for example, input / output to a screen, a file, or a network, but is not limited thereto.
  • the native code is a program written in machine language.
  • the native code is, for example, a compiled program.
  • the process included in the native code is called by, for example, Java Native Interface (JNI).
  • “there is no side effect on the synchronization block” means that the value being processed by the statement in the synchronization block cannot be referred to by the statement outside the synchronization block. If there is no side effect, execute a process that causes a side effect, such as a process in another synchronized block described in the synchronized block, a process that assigns a value to an instance variable, a process that assigns a value to a class variable, and input / output There is no process, a process for calling a process included in the native code, or a process for assigning a value to a number indicating the position of an array element.
  • the “path” is a series of sentences on the program code corresponding to the processing executed when the program is executed.
  • the sentence may be zero.
  • the “path without side effects on the synchronization block” is a series of sentences corresponding to processing without side effects on the synchronization block at the time of execution of the program.
  • the “conditional sentence” is a sentence described on a program code for realizing a branch of processing in a program.
  • the conditional statement includes a conditional expression.
  • the conditional statement may include a symbol indicating the range of the selected path.
  • the symbols are, for example, “ ⁇ ” and “ ⁇ ”.
  • the conditional statement selects a path to be executed according to the result of the conditional expression.
  • the conditional statement is, for example, an if statement or a switch statement.
  • the “conditional expression” is an expression used for selecting a path.
  • the conditional expression includes at least one of a variable, a constant, and an operator.
  • the conditional statement is, for example, a switch statement or a select-case statement, an expression that compares a case value related to both statements and a variable storing the value is used as a conditional expression.
  • conditional expressions are not necessarily one for one conditional statement.
  • the combination means that the conditional expressions are logically operated, for example.
  • the “first variable” is one variable for causing the first conditional expression to select a path.
  • the “first variable” is, for example, at most one variable. If the program code is written in, for example, the Java language, the first variable is one instance variable or one class variable.
  • the “result of the first conditional expression” is a value represented by the first conditional expression or a combination of a plurality of first conditional expressions.
  • the conditional statement is, for example, an if statement
  • the result of the first conditional expression is expressed, for example, as true or false.
  • the true or false may be expressed by a value according to the specification of the conditional expression of the language describing the program code, or may be expressed by a value determined by the user. For example, the value representing true may be true and the value representing false may be false, or the value representing true may be 0 and the value representing false may be -1.
  • the variable for storing the result of the first conditional expression is, for example, a boolean type.
  • the variable for storing the result of the first conditional expression is, for example, a numerical type that supports a negative value. If the if statement includes a plurality of first conditional expressions because the if statement includes, for example, an elseif clause, the result of the first conditional expression is obtained by combining values represented by the plurality of first conditional expressions. May be.
  • the above combination means, for example, a logical operation between values representing the conditional expressions.
  • the result of the first conditional expression is, for example, a value (hereinafter, indicated value) indicating that the variable specified in the switch statement is a value specified in the case clause or It is represented by a value corresponding to the indicated value.
  • the value indicated above may be, for example, a value specified by the case clause.
  • the corresponding value is, for example, a value determined by the user. The user uses, for example, serial numbers for the corresponding values.
  • the variable for storing the result of the first conditional expression has, for example, the same data type as the designated variable.
  • the result of the first conditional expression may be obtained by combining a plurality of the above-described values or a plurality of the corresponding values.
  • the above combination means, for example, grouping according to the value shown above or the range of the corresponding value.
  • a variable of a data type with guaranteed atomicity is a variable of a data type in which reading of a variable into a memory is executed by one operation, and the execution is a program code.
  • the language is, for example, a Java (trademark) language and the program code is executed on an OS of 32 bits or more, for example, a boolean type, a byte type, a short type, an int type or a float type has an atomicity. Guaranteed data type.
  • the “other program code” is a program code linked from the program code before being converted.
  • being linked is, for example, being called or sharing a variable, but is not limited thereto.
  • the other program code is a program code that can be analyzed by the embodiment of the present invention.
  • the other program code is, for example, source code or byte code.
  • “suppressing the optimization related to the memory access order” means that when the program code before conversion is compiled, the compiler does not optimize the memory access order. It is.
  • the designation to suppress the optimization is to qualify the variable with the modifier volatile.
  • FIG. 1 is a functional block diagram showing functions included in a system for converting program codes in an embodiment of the present invention.
  • the computer system (101) includes a memory (102), a search unit (103), a duplication unit (104), an addition unit (105), a determination unit (106), and a determination unit (107).
  • the storage unit (108) may be included in the computer system (101) or may be included in another system.
  • the computer system (101) reads the program code (109) before conversion from the storage unit (108) into the memory (102).
  • the computer system (101) may read other program code (110) from the storage unit (108) into the memory.
  • the search unit (103) searches the program code (109) read to the memory and optionally another program code (110). By the search, the search unit (103) causes the first conditional statement in the synchronization block, the update statement, another synchronization block synchronized with the synchronization block, a statement referring to the first variable from the statement outside the synchronization block, A statement that describes the implementation of another thread that is executed in synchronization with the statement in the synchronization block that starts the thread, or a statement that refers to a variable used to determine the execution order of the threads is retrieved.
  • the search unit (103) includes a determination unit (107).
  • the determination unit (107) allows the user to input the information when the information for performing the search is insufficient.
  • the determination unit (107) also allows the user to input the search conditions in order to further narrow down the search conditions.
  • the determination unit (106) receives the search result from the search unit (103). The determination unit (106) determines a path without a side effect in the program code (109) from the search result.
  • the duplicating unit (104) duplicates the determined path without side effects outside the synchronized block of the program code (109).
  • the addition unit (105) adds the second conditional statement that branches to the copied path without side effects to the program code (109) read out to the memory.
  • the adding unit (105) also includes a statement that includes a variable for storing the result of the first conditional expression and the result of the first conditional expression assigned to the variable, a statement that initializes the variable, or A statement declaring the variable is added to the program code (109) read into the memory.
  • FIG. 2 shows an example of the program code before conversion shown in FIG. 1 in the embodiment of the present invention.
  • the program code (200) is a program code before being converted.
  • terms used in the specification will be described using the program code (200) as an example.
  • the sentence corresponding to “class” is a sentence satisfying the format “class class name ⁇ class implementation ⁇ ”. Therefore, the sentences corresponding to “class” in the program code (200) before conversion are class W (201A) and class X (201B).
  • the statement corresponding to “method” is a statement satisfying the format “return value method name (argument type argument name) ⁇ method implementation ⁇ ”. Therefore, the statements corresponding to “method” in the program code (200) before conversion are the method enqueue (W w) (202A) and the method dequeue () (202B). Further, when another method call is included in the statement described in the method, the statement describing the implementation of the other method is also handled as the statement described in the synchronous method.
  • the statement corresponding to “synchronized block” is, for example, a statement in which a synchronized block is declared or a method in which a synchronized modifier is specified. Therefore, the sentences corresponding to the “synchronization block” in the program code (200) before conversion are the first synchronization block (203A), the second synchronization block (203B), and the third synchronization block (203C). It is.
  • the “synchronized block lock object” is, for example, a variable specified in the declaration of the synchronized block or in an argument of a method in which the synchronized modifier is specified. Therefore, the lock object of the first synchronization block (203A) is w (204A). The lock object of the second synchronization block (203B) is lock (204B). The lock object of the third synchronization block (203C) is lock (204C). Further, when a method call is included in a sentence described in the synchronous block, a sentence describing the implementation of the method is also handled as a sentence described in the synchronous block.
  • the sentence corresponding to the “condition sentence” is, for example, a sentence in which an “IF” sentence, a “SWITCH” sentence, or a “ternary operator” is described. Therefore, the sentences corresponding to the “conditional sentence” in the program code (200) before conversion are the first conditional sentence (205A), the second conditional sentence (205B), and the third conditional sentence (205C). And the fourth conditional statement (205D).
  • the sentence corresponding to “path” is a sentence that may be processed when the program code (200) is executed.
  • the path until the method enqueue (W w) (202A) is executed and ended is the path (207A)
  • the path until the method dequeue () (202B) is executed and ended is the path (207B). It is.
  • the path from the execution of the conditional statement to the end is from the statement at which each branch process starts to the statement at which each branch process ends.
  • the path until the first conditional statement (205A) is executed and ended is the path (209A) executed when the conditional expression (206A) is satisfied and the conditional expression (206A) are not satisfied. This is the path to be executed (209B).
  • the third conditional statement (205C) is the next statement after the processing (208C and 208D) exiting from the method dequeue () (202B), and the processing of each branch ends. Therefore, the path until the third conditional statement (205C) is executed and ended is the path (209C) executed when the conditional expression (206C) is satisfied and the conditional expression (206C) are not satisfied. This is the path to be executed (209D).
  • the first variable is a variable used to determine a branch. Therefore, the first variable in the first conditional statement (205A) is w.val (210A). The first variable in the second conditional statement (205B) is head (210B). The first variable in the third conditional statement (205C) is head (210C). The first variable in the fourth conditional statement (205D) is w.next (210D).
  • the “update sentence” is a sentence in the synchronization block including the first variable, and is a sentence for updating the first variable.
  • the update statement for updating w.val (210A) is not included in the first synchronization block (203A) including w.val (210A).
  • the update sentence for updating the head (210B) is the update sentence (211B).
  • the update sentence for updating the head (210C) is the update sentence (211C).
  • the update sentence for updating w.next (210D) is the update sentence (211D).
  • 3 to 5 show examples of processing steps executed in the conversion program shown in FIG. 1 in the embodiment of the present invention.
  • program code before conversion is written in Java (trademark) language will be described as an example.
  • the computer system (101) uses the program code (hereinafter CL) before conversion as input data.
  • the computer system may further use another program code (hereinafter, another CL) linked from the CL as input data.
  • the input data is data that can be referred to from the conversion program.
  • FIG. 3 shows an example of processing steps for acquiring information necessary for conversion among the processing steps executed in the conversion program shown in FIG. 1 in the embodiment of the present invention.
  • Step 301 is the start of the conversion process.
  • the computer system reads the input data into, for example, a memory.
  • the processing proceeds to step 302.
  • step 302 the computer system prepares a variable i, a set variable M, a set variable S, and a set variable C for storing the information for conversion.
  • the variable i is a variable in which a value for identifying a variable declared in step 315 below (hereinafter referred to as a second variable) is stored.
  • the variable i is used, for example, as a serial number assigned to the second variable. Note that the variable i need not be prepared. If the variable i is not prepared, the computer system assigns a variable name that can uniquely identify the second variable every time the second variable is declared.
  • the variable name that can be uniquely identified may be determined by the user, for example, or may be determined randomly so as not to overlap. Aggregate variables are groups for collectively handling data having different meanings.
  • the aggregate variable is represented by, for example, an array or a structure.
  • the collective variable M is a collective variable in which information about a method that can be processed when the CL is executed is stored for each method.
  • the information about the method may be information that can identify a statement describing the implementation of the corresponding method from the program code.
  • the information about the method is, for example, a sentence start position describing the method implementation, a sentence end position describing the method implementation, or a sentence describing the method implementation, but is not limited thereto.
  • the set variable S is a set variable in which information about a synchronization block that can be processed when each of the above methods is executed is set for each synchronization block.
  • the information about the synchronous block includes the lock object of the synchronous block (hereinafter referred to as S first information), the start / end position on the program code of the synchronous block (hereinafter referred to as S second information), and the synchronization block. (Hereinafter, the third information of S).
  • the set variable C is a set variable in which information about execution paths satisfying a predetermined condition included in each of the synchronization blocks is set for each execution path.
  • the information on the execution path includes the lock object of the synchronous block corresponding to the execution path (hereinafter referred to as C first information), and the start / end position on the program code of the synchronous block corresponding to the execution path.
  • C second information information (hereinafter referred to as C second information) and information (hereinafter referred to as C third information) that can specify the execution path from the program code.
  • the third information C is, for example, a sentence that describes the start position of the execution path, the end position of the execution path, or the execution path, but is not limited thereto.
  • the computer system sets initial values for the variable i, the aggregate variable S, and the aggregate variable C.
  • the initial value is, for example, a value indicating that nothing is entered.
  • the computer system sets, for example, 0 or 1 as the initial value of the variable i.
  • the computer system sets, for example, the initial values of the numeric type variables as the initial values of the set variables S and C. 0 is set, and NULL is set as the initial value of the character variable.
  • the computer system also sets information on the method in the set variable M in the preparation of the set variable M.
  • the computer system searches for a method included in the CL, and sets information about the searched method in the set variable M. In the search, a target method may be designated in advance by the user, or all methods included in the CL may be searched. A method that can be reached by executing a method included in the CL may be retrieved from, for example, another CL. Further, instead of the search, the user may set information on the method in the set variable M. In response to the completion of the preparation, the process proceeds to step 303.
  • Step 303 represents the start of iteration for the set variable M.
  • the computer system retrieves one piece of information (hereinafter, m) about the method from the set variable M.
  • m one piece of information
  • step 304 the computer system sets data in the set variable S.
  • the computer system searches for a synchronization block that can be reached when the method corresponding to the extracted m is executed. If the method itself is a synchronous block, the method itself is also a synchronous block to be searched.
  • the CL is a program code written in Java (trademark), for example, the computer system searches the CL for “synchronized”, for example.
  • the method corresponding to m is modified with “synchronized”, the “synchronized” to be modified is also “synchronized” to be searched.
  • the computer system For each of the retrieved synchronization blocks, the computer system obtains a lock object (first information of S), a start / end position (second information of S) on the program code, and a statement (S 3rd information) is acquired from the retrieved synchronization block, and the acquired first to third information of S is set as a set of information in the set variable S for each synchronization block.
  • first information of S first information of S
  • second information of S start / end position
  • S 3rd information a statement
  • the process proceeds to step 305.
  • Step 305 represents the end of the iteration for the set variable M. If all m have been extracted, the process proceeds to step 306. If there is m that has not been extracted, the processing returns to step 303.
  • Step 306 indicates the start of iteration for the set variable S.
  • the computer system extracts one set of information (hereinafter referred to as “s”) about the synchronization block from the set variable S.
  • s one set of information
  • the process proceeds to step 307.
  • the computer system includes a path in which a side effect does not occur in a sentence (hereinafter, third information of s) in the synchronous block set in the set variable S corresponding to the extracted s. Determine whether or not. This determination is executed for all paths (hereinafter referred to as execution paths) that are paths included in the sentence (third information of s) in the synchronous block and that are executed for each path. In this determination, the computer system determines, for example, whether or not the cause causing the side effect described in the following side effect list is included in the execution path. For example, the side effect list is created in advance by the user. The user registers a cause causing the side effect, for example, a method or a variable, in the side effect list in advance.
  • a cause causing the side effect for example, a method or a variable
  • the method is, for example, a method related to I / O or a JNI method.
  • the variable is, for example, an instance variable or a class variable.
  • the computer system determines that the execution path is a path where a side effect occurs. It is determined that the path does not occur.
  • the registration may be automatically executed by a computer system.
  • the computer system may acquire a cause causing a side effect from at least one of the CL or the other CL, and register the cause causing the acquired side effect in a side effect list. Further, the computer system can execute the determination by examining the type of variable included in the execution path.
  • the computer system may perform the determination by, for example, examining where in the CL the declaration of the variable is described or in which range the scope of the variable is set on the CL. If there is a path where no side effect occurs in the execution path, the process proceeds to step 308. If all the execution paths are paths that cause side effects, the process proceeds to step 310.
  • step 308 the computer system determines whether or not the execution path that does not cause the side effect and the conditional statement for executing the execution path satisfy the following requirements.
  • the requirement is that the execution path includes at most one reading of an instance variable or a class variable, and the conditional statement evaluates the reading and the constant. If even one conditional statement that satisfies the requirement exists, the process proceeds to step 309. If there is no conditional statement that satisfies the requirement, the process proceeds to step 310.
  • step 309 the computer system, for each path executed by the conditional statement satisfying the above requirement, the lock object (the first information of C) that is the first information of S, the second information of the S A set of information (C 3rd information) that can specify from the program code the execution path executed by the conditional statement that satisfies the above requirements and the start / end position (C 2nd information) on the program code Set to variable C as a set of information.
  • the process proceeds to step 310.
  • Step 310 represents the end of the iteration for the set variable S. If all s have been extracted, the process proceeds to step 311. If there is s that has not been extracted, the processing returns to step 306.
  • FIG. 4 shows an example of processing steps for performing conversion among the processing steps executed in the conversion program shown in FIG. 1 in the embodiment of the present invention.
  • Step 311 indicates the start of iteration for the set variable C.
  • the computer system extracts one set of information (hereinafter referred to as “c”) about the execution path from the set variable C. Note that the computer system sequentially extracts the information from the information about the execution path that is executed earlier by the program code. In response to the end of the extraction, the process proceeds to step 312.
  • step 312 the computer system determines whether or not the lock object (hereinafter, the first information of c) set in the set variable C corresponding to the extracted c is used only in the CL. To do. In this determination, for example, when CL is written in Java (trademark) language, the private qualifier is used in the definition of the lock object (first information of c), or the above-mentioned another CL is locked. It is checked that the description using the object (first information of c) is not included. The check includes the use of the private qualifier in the definition of the lock object (first information of c) or the use of the lock object (first information of c) in the other CL. If not, the computer system determines that the lock object (first information of c) is used only in the CL.
  • the lock object hereinafter, the first information of c
  • the above check is executed because the other CL is not provided as input data or the description of the source code is unknown because the other CL is provided as binary data. There are cases where it is not possible.
  • the computer system may determine that the lock object (first information of c) is not used only in the CL, for example. In addition, the computer system may display a message for causing the monitor to make the above determination and allow the user to make the above determination. If it is used only within the CL, the process proceeds to step 314. If it is also used outside the CL, the process proceeds to step 313.
  • step 313 the computer system determines that all variables included in the conditional statement for executing the path corresponding to the third information of the set variable C corresponding to c (hereinafter, the third information of c) are in CL. Determine whether it is defined only in. In this determination, it is checked that the definition of the referenced variable is not included in the other CL. If the other CL does not include the definition of the referenced variable, the computer system determines that the referenced variable is defined only in the CL.
  • the above check cannot be executed because the other CL is not given as input data or the description of the source code is unknown because the other CL is provided as binary data. There is a case. If the check cannot be performed, the computer system may determine that the referenced variable is not defined only in the CL, for example.
  • the computer system may display a message for causing the monitor to make the above determination and allow the user to make the above determination. If the referenced variable is defined only in CL, the process proceeds to step 314. If the referenced variable is not defined only in CL, the process proceeds to step 318.
  • step 314 the computer system adds a statement declaring a variable (hereinafter, a second variable) in the CL.
  • the location to be added differs depending on the specification of the programming language describing the CL.
  • the declaration of the second variable is a declaration of the second variable of a data type that is guaranteed to be atomic and can be designated as static and deterring optimization.
  • “atomicity is guaranteed” means that the language specification guarantees that reading of variables into the memory is executed in one operation.
  • the Java (trademark) language for example, the boolean type, byte type, short type, int type or float type is a data type having a size of 32 bits or less.
  • the Java (trademark) is used on a CPU of 32 bits or more.
  • a program written in a language When a program written in a language is executed, it is a data type that is guaranteed to be read by a single operation of reading a variable into a memory.
  • To be static means to have only one entity in the CL.
  • Inhibiting optimization means, for example, preventing the compiler from optimizing the program code with respect to the memory access order.
  • the Java (trademark) language it is possible to specify that the optimization of a variable is suppressed with the modifier volatile. By introducing a volatile declaration, the visibility of memory orders and changes outside the synchronized block is guaranteed.
  • the variable name of the second variable may be any name as long as it does not overlap with other variables.
  • the name may be identified, for example, by including a variable i. If CL is a program code written in a language in which the array can be used as the second variable, the name may be an array with the variable i as a subscript. In the declaration of the second variable, it is declared that the second variable is a static variable. When the shared variable included in the path corresponding to the third information of c is accessed from other than a statement in the synchronous block in which information is set in S, the declaration of the second variable It is further declared that the second variable is a variable to be optimized. Here, the shared variable is a variable that may be accessed from a plurality of threads. When the programming language that describes CL is the Java (trademark) language, the shared variables are instance variables and class variables.
  • the above access is obtained, for example, by examining a CL or another CL.
  • the above examination cannot be performed because the other CL is not given as input data or the description of the source code is unknown because the other CL is provided as binary data.
  • the computer system may allow the shared variable to be accessed from outside the synchronization block.
  • the computer system may display a message for allowing the user to determine whether or not the shared variable is accessed from outside the synchronization block on the monitor, and allow the user to make the above determination.
  • the process proceeds to step 315.
  • step 315 the computer system creates a sentence from the conditional sentence that causes the execution path corresponding to the third information of c to be executed.
  • the value assigned to the variable b indicates which path is selected from paths that have no side effects.
  • b when b is 1, a path for executing “c1 ++;” is selected, and when b is 2, a sentence for selecting a path for executing “c2 ++;” is created.
  • the computer system deletes the declaration of the static variable from the declaration of the second variable. For example, in the case of the Java (trademark) language, the deletion is to delete the modifier static. In response to the end of the deletion, the process proceeds to step 316.
  • step 316 the computer system duplicates the path corresponding to the third information of c just before the start position of the synchronization block on the CL indicated by the second information of c.
  • the computer system starts processing from the added execution path when the value of the second variable is an established value, whereas the computer system starts the synchronization when the value of the second variable is an established value.
  • the process proceeds to step 317.
  • step 317 the computer system executes the process for the synchronization block related to the execution path corresponding to the third information of c.
  • This process will be described in detail with reference to FIG.
  • a new sentence can be added to CL.
  • the sentence added to the CL in steps 314 and 316 can be deleted.
  • the process proceeds to step 318.
  • Step 318 represents the end of the iteration for the set variable C. If all c have been extracted, the process proceeds to step 319. If there is c that has not been taken out, the processing returns to step 311.
  • step 319 for the second variable, the computer system declares the second variable, the statement added to CL in steps 314 and 316 corresponding to the second variable, or the second variable.
  • a statement that sets an initial value in the second variable is added to a statement that is executed at the earliest time in the statement of the synchronous block corresponding to the variable.
  • the sentence for setting the initial value is the sentence generated in step 315.
  • the initial value may be the failure value. Note that the addition of the above sentence is executed for all the defined second variables. In response to the end of the addition, the process proceeds to step 320.
  • Step 320 is the end of the conversion process.
  • FIG. 5 shows details of the processing of step 317 described in FIG. 4 in the embodiment of the present invention.
  • Step 321 indicates the start of the processing of Step 317.
  • step 322 the computer system extracts one piece of information (s) about the method from the set variable S. In response to the end of the extraction, the process proceeds to step 323.
  • step 323 the computer system determines whether the lock object that is the first information of c is the same as the lock object that is the first information of s. If so, the process proceeds to step 324. If not, the process proceeds to step 329.
  • step 324 the computer system determines whether or not the synchronization block represented by the third information of s includes a sentence for updating the variable included in the sentence created in step 315. If the sentence to be updated is included, the process proceeds to step 325. If the sentence to be updated is not included, the process proceeds to step 329.
  • the computer system includes a statement that activates a thread that acquires a lock using the lock object that is the first information of c in the synchronization block represented by the third information of s.
  • a sentence (hereinafter referred to as a first sentence) that causes the lock object to be used in the synchronization block may be found.
  • the first sentence is, for example, a method using the lock object as an argument.
  • the computer system examines the other CL and obtains an execution path executed by the first statement.
  • the computer system can find the statement that activates the thread by examining the determined execution path.
  • step 326 If the statement that activates the thread is not found by the above examination, the process proceeds to step 326. If found, the process proceeds to step 328.
  • the above examination cannot be performed because the other CL is not given as input data or the description of the source code is unknown because the other CL is provided as binary data. There is a case.
  • the computer system may determine that the statement that activates the thread is included in the execution path corresponding to the third information of c. Further, the computer system may display a message for inputting whether or not the sentence for starting the thread is included in the monitor, and allow the user to make the determination.
  • step 326 the computer system determines whether a variable defined in the synchronization block corresponding to the third information of s is referenced outside the synchronization block and used for execution ordering between threads. To do. The rough determination is executed by the computer system examining the program code. If the variable is not found by the above examination, the processing proceeds to step 327. If found, the process proceeds to step 328.
  • the above examination is executed because the other CL is not given as input data or the description of the source code is unknown because the other CL is provided as binary data. There are cases where it is impossible.
  • the computer system may determine that the variable is included in an execution path corresponding to the third information of c. Further, the computer system may display a message for inputting whether or not the variable is included in the monitor, for example, and allow the user to make the determination.
  • step 327 the computer system adds the sentence created in step 315 to CL.
  • the second variable is a variable designated to suppress the optimization of the variable
  • the addition is performed for the synchronization block corresponding to s.
  • the position on the CL to be added is immediately before the sentence for leaving the synchronization block corresponding to s.
  • the second variable is a variable that is not designated to suppress optimization of the variable
  • the position on the added CL is after the statement to be updated found in step 324, and This is before the process of exiting the synchronization block corresponding to s.
  • the process proceeds to step 329.
  • step 328 the computer system deletes the sentence added to CL in steps 314 and 316.
  • the repetition for step 322 ends and the process proceeds to step 330.
  • Step 329 represents the end of the iteration for the set variable S. If all s have been retrieved, the computer system increments the variable i. In response to the end of the increment, the process proceeds to step 330. If there is s that has not been extracted, the processing returns to step 322.
  • Step 330 indicates the end of the process of step 317.
  • FIGS. 6 to 8 and 9 to 11 Specific examples of the operation of each step in FIGS. 3 to 5 are shown in FIGS. 6 to 8 and 9 to 11 below.
  • FIG. 6 shows input data CL used for specifically explaining the operation of each step shown in FIGS. 3 to 5 in the embodiment of the present invention. Note that the examples shown in FIGS. 6 to 8 show cases in which the user is inquired in Step 325 and Step 326.
  • the computer program starts the conversion program with the input data (401) as the input CL.
  • the computer system sets the following values for the variables.
  • Aggregate variable M ⁇ void enqueue (W w) public W dequeue () ⁇
  • Variable i 1
  • the process proceeds to step 306.
  • the computer system executes Steps 307 to 309 for each of s1 to s3 included in the set variable S.
  • the path including the S03th line has a side effect of synchronization.
  • the path including the S04 line and the T05 line has a side effect of assignment to an instance variable. Therefore, the path including the S03 line, the S04 line, and the T05 line does not satisfy the condition of Step 307. Therefore, the path including the S03 line, the S04 line, and the T05 line is not stored in the collective variable C in step 309.
  • a local variable passed from an argument of a method called w is referenced. Therefore, the S02 line does not satisfy the condition of step 308. Therefore, the S02 line is not stored in the collective variable C in step 309.
  • the process proceeds to Step 311.
  • step 311 to step 318 the computer system executes steps 312 to 317 for c included in the set variable C.
  • step 312 and step 313 the determination on c is performed.
  • “lock” included in c is a variable declared private, and is a variable that is not referenced from outside the CL. Therefore, since c satisfies the conditions of Step 312 and Step 313, the processing proceeds to Step 314.
  • step 314 the computer system adds a statement declaring a variable to CL.
  • the shared variable head is accessed only within s1. Therefore, the computer system adds the instance variable declaration “private static boolean b1” to the CL.
  • step 316 the computer system generates the T02 line, the T07 line, and the T08 line before the T01 line. Also, the computer system replaces the conditional statement included in c with “(b1)”. Since the then clause in the T02 line is a branch to a path having a side effect, the computer system connects the then clause to the code to the synchronization block.
  • FIG. 7 shows the method dequeue () after the processing of step 316 described in FIG. 4 is executed in the embodiment of the present invention.
  • a sentence (412) is added to the CL method dequeue ().
  • step 316 in response to the execution of the addition, the process proceeds to step 317.
  • step 317 the computer system repeats steps 322 to 329.
  • step 322 the computer system executes steps 323 to 328 for each of s1 to s3 included in the set variable S.
  • S1 to s3 that satisfy the condition of step 322 are: ⁇ lock, (S03, S07), (S04, S05, S06)> (s2) and ⁇ lock, (T01, T09), (T02, T03, T04, T05, T06, T07, T08)> (s3) is there.
  • step 323 the computer system checks whether there is at least one assignment to the variable referenced on the right side of the assignment statement of b0 in the path related to s2 or s3 that satisfies the condition of step 322.
  • s2 or s3 a process for substituting for head is searched. As a result of the search, s2 or s3 satisfies the condition of step 323.
  • step 324 the computer system creates a new thread for the synchronization block represented by s2 or s3, and the created thread acquires the same lock object as the synchronization block represented by s2 or s3.
  • the process S (0) of the synchronization block represented by s2 includes a process for calling the method bar (lock) with LO as an argument.
  • the program code of the program that implements the method bar (lock) is unknown. Therefore, the computer system allows the user to determine whether or not the acquisition is attempted.
  • the computer system displays on the monitor “Does foo.bar (lock) activate the thread and call the synchronized block or the synchronized method regarding the lock?” And makes an inquiry to the user. If the user answers “N”, the process proceeds to step 326, and if the user answers “Y”, the process proceeds to step 328.
  • step 326 the computer system does not use variables defined within the synchronization block represented by s2 or s3 to be referenced outside the synchronization block and to determine the execution order between at least two threads.
  • the shared variable lock on line S06 may be accessed from other threads by escaping from foo.bar (lock). Therefore, the computer system displays, for example, “Can lock be used to determine the execution order with other threads?” On the monitor and inquires the user. If the user answers “N”, the process proceeds to step 327, and if the user answers “Y”, the process proceeds to step 328, and the process repeats.
  • step 319 In response to the end of the repetition of steps 322 to 329, the processing proceeds to step 319.
  • FIG. 8 shows input data (hereinafter, converted program code (421)) after the processing of the steps shown in FIGS. 3 to 5 is executed for FIG. 6 in the embodiment of the present invention.
  • a sentence (422) is added to the converted program code (421) by the processing of the steps of FIGS.
  • b1 is false when head is null. Therefore, when the converted program code (421) is executed and the dequeue () method is called when the head is null, the process returns null without entering the synchronization block. Therefore, the problem of lock collision is solved.
  • FIG. 9 shows input data CL used to specifically explain the operation of each step shown in FIGS. 3 to 5 in the embodiment of the present invention.
  • the example shown in FIGS. 9 to 11 is an example in which another CL (not shown) exists in addition to the above-described CL, and the user is not inquired in Steps 325 and 326.
  • the computer program starts the conversion program with the input data (501) as the input CL.
  • the computer system sets the following values for the variables.
  • the process proceeds to step 303.
  • the process proceeds to step 306.
  • Steps 306 to 310 the computer system executes Steps 307 to 309 for each of s1 to s3 included in the set variable S.
  • the path including the S03th line has a side effect of synchronization.
  • the path including the S04 line and the T05 line has a side effect of assignment to an instance variable. Therefore, the path including the S03 line, the S04 line, and the T05 line does not satisfy the condition of Step 307.
  • the path including the S03 line, the S04 line, and the T05 line is not stored in the collective variable C in step 309.
  • a local variable passed from an argument of a method called w is referenced. Therefore, the S02 line does not satisfy the condition of step 308. Therefore, the S02 line is not stored in the collective variable C in step 309.
  • the process proceeds to Step 311.
  • step 311 to step 318 the computer system executes steps 312 to 317 for c included in the set variable C.
  • step 312 and step 313 the determination on c is performed.
  • “lock” included in c is a variable declared private, and is a variable that is not referenced from outside the CL. Therefore, since c satisfies the conditions of Step 312 and Step 313, the processing proceeds to Step 314.
  • step 314 the computer system adds a statement declaring a variable to CL.
  • the shared variable head is accessed only within s1. Therefore, the computer system adds the instance variable declaration “private static boolean b1” to the CL.
  • step 316 the computer system generates the T02 line, the T07 line, and the T08 line before the T01 line. Also, the computer system replaces the conditional statement included in c with “(b1)”. Since the then clause in the T02 line is a branch to a path having a side effect, the computer system connects the then clause to the code to the synchronization block.
  • FIG. 10 shows the method dequeue () after the process of step 316 described in FIG. 4 is executed in the embodiment of the present invention.
  • a statement (512) is added to the CL method dequeue ().
  • step 316 in response to the execution of the addition, the process proceeds to step 317.
  • step 317 the computer system repeats steps 322 to 329.
  • step 322 the computer system executes steps 323 to 328 for each of s1 to s3 included in the set variable S.
  • S1 to s3 that satisfy the condition of step 322 are: ⁇ lock, (S03, S07), (S04, S05, S06)> (s2) and ⁇ lock, (T01, T09), (T02, T03, T04, T05, T06, T07, T08)> (s3) is there.
  • step 323 the computer system checks whether there is at least one assignment to the variable referenced on the right side of the assignment statement of b0 in the path related to s2 or s3 that satisfies the condition of step 322.
  • s2 or s3 a process for substituting for head is searched. As a result of the search, s2 or s3 satisfies the condition of step 323.
  • step 324 the computer system creates a new thread for the synchronization block represented by s2 or s3, and the generated thread acquires the same lock object as the synchronization block represented by s2 or s3. Check if you are not trying to win.
  • the synchronous block represented by s2 or s3 does not include a statement for generating a new thread. Therefore, the computer system determines in the check that it is not trying to acquire the same lock object as the synchronization block represented by s2 or s3. In response to not trying to acquire, the process proceeds to step 326.
  • step 326 the computer system does not use variables defined within the synchronization block represented by s2 or s3 to be referenced outside the synchronization block and to determine the execution order between at least two threads.
  • the shared variable lock since the shared variable lock is declared private, it is not accessed from outside the CL. Further, the shared variable lock is accessed only in the synchronization block in the CL. Therefore, the computer system determines in the check that the shared variable lock is not used to determine the execution order. If not, the process proceeds to step 327.
  • the locations to be added are, for example, before s2 line for s2, and before T06 line and before T08 line for s3.
  • step 319 In response to the end of the repetition of steps 322 to 329, the processing proceeds to step 319.
  • FIG. 11 shows the input data (hereinafter referred to as the converted program code (521)) after the processing of each step shown in FIGS. 3 to 5 is executed for FIG. 9 in the embodiment of the present invention.
  • a sentence (522) is added to the converted program code (521) by the processing of the steps of FIGS.
  • b1 is false when head is null. Therefore, when the converted program code (401) is executed and the dequeue () method is called when the head is null, the process returns null without entering the synchronous block. Therefore, the problem of lock collision is solved.
  • FIG. 12 shows a program before the processing of each step shown in FIGS. 3 to 5 is executed when there are three or more paths selected by the first conditional expression in the embodiment of the present invention.
  • three paths (602 to 604) are selected according to the two first conditional expressions.
  • c1 and c2 are local variables
  • the path (603) and the path (604) are paths without side effects.
  • the path (602) is a path with a side effect because it includes a statement for updating the two variables x and y corresponding to the first variable.
  • the program code (611) shows the result of the processing of each step shown in FIGS. 3 to 5 being executed on the program code (601).
  • the program code (611) includes a declaration statement (612) for declaring the second variable, a second conditional statement (613), and a statement created in step 315 (in the synchronous block of the program code (601)). 614) has been added.
  • a variable that can take a value indicating which path is selected from the paths (603 and 604) having no side effect is prepared as the second variable. Therefore, a declaration statement (612) for declaring a variable b that can take 2 as a value for selecting the path (603) and 1 as a value indicating the path (604) is added to the program code (611). Yes.
  • a second conditional statement (613) is added to the program code (611) as a conditional statement for executing a path (603 and 604) having no side effect according to the second variable.
  • the statement (614) created in step 315 which is a statement for obtaining the value of the variable b, is added immediately after the update statement for updating the first variables x and y. ing.
  • the lock collision problem in java.lang.ref.ReferenceQueue can be solved by executing the steps of FIGS.
  • FIG. 13 is a block diagram of computer hardware included in the system of FIG. 1 in the embodiment of the present invention.
  • a computer system (701) according to an embodiment of the present invention includes a CPU (702) and a main memory (703), which are connected to a bus (704).
  • the CPU (702) is preferably based on a 32-bit or 64-bit architecture, such as Intel's Xeon (TM) series, Core (TM) series, Atom (TM) series, Pentium (TM) series, The Celeron (TM) series, AMD's Phenom (TM) series, Athlon (TM) series, Turion (TM) series, or Empron (TM) can be used.
  • Intel's Xeon (TM) series such as Intel's Xeon (TM) series, Core (TM) series, Atom (TM) series, Pentium (TM) series, The Celeron (TM) series, AMD's Phenom (TM) series, Athlon (TM) series, Turion (TM)
  • a display (706) such as an LCD monitor is connected to the bus (704) via a display controller (705).
  • the display (706) appropriately displays information about a computer system connected to a network via a communication line and information about software running on the computer system for management of the computer system. Used for display with a graphic interface.
  • a hard disk or silicon disk (708) and a CD-ROM, DVD drive or Blu-ray drive (709) are also connected to the bus (704) via an IDE or SATA controller (707).
  • the hard disk (708) stores an operating system, a program that provides a Java (trademark) processing environment such as J2EE, and other programs and data so that they can be loaded into the main memory (703).
  • the CD-ROM, DVD or Blu-ray drive (709) is used for additionally introducing a program from a CD-ROM, DVD-ROM or Blu-ray disc to a hard disk as necessary. Further, a keyboard (711) and a mouse (712) are connected to the bus (704) via a keyboard / mouse controller (710).
  • the communication interface (714) follows, for example, the Ethernet (trademark) protocol.
  • the communication interface (714) is connected to the bus (704) via the communication controller (713), and plays a role of physically connecting the computer system and the communication line (715), and the operating system of the computer system.
  • a network interface layer is provided for the TCP / IP communication protocol of the communication function.
  • the communication line may be a wired LAN environment or a wireless LAN environment based on a wireless LAN connection standard such as IEEE802.11a / b / g / n.

Landscapes

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

Abstract

ロック衝突による性能低下の問題が発生しそうな箇所を自動的に特定し、該箇所を自動的に修正する方法が必要とされている。 本発明は、マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換する方法を提供する。該方法は、上記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索するステップと、上記同期ブロック外に、上記検索された第1の条件文によって分岐される副作用のないパスを複製するステップと、上記複製に応じて、上記プログラム・コード内に第2の条件文を追加するステップであって、上記第2の条件文は上記複製された副作用のないパスへ分岐させる条件文である、上記追加するステップとを含む。

Description

マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム
 本発明は、マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システムに関する。
 近年、プロセッサ・アーキテクチャにおいて、1つの中央演算処理装置(以下、CPU:Central Processing Unit)の内部に複数のCPUコアを封入したいわゆるマルチコアへのシフトが進んでいる。マルチコアは、外部的には1つのCPUでありながら、内部的には2つのCPUとして認識させられる。マルチコアにより、主に並列処理を行わせる環境下において、CPUチップ全体での処理能力を上げ、システムの性能向上を果たすことが可能である。マルチコアは、プロセッサが同時に実行可能なハードウェアスレッドの数を飛躍的に増加させる。例えば、SUN(商標)のNiagara2(商標)は、1CPU上で64個のスレッドを実行することが可能である。
 複数のスレッドを同時に実行することが可能なプロセッサ上で従来のプログラムが実行される場合、ロック衝突によるプロセッサの性能低下が問題になる。ここで、ロック衝突とは、あるスレッドにおいて、排他実行が必要なクリティカル・セクションに入るためにロックが獲得された場合、他のスレッドにおいて、上記ロックが解放されるまで次のステップが実行されない状態をいう。次のステップが実行されないスレッドは、典型的には、スピン・ループ(spin loop)又はスリープ(sleep)状態になる。
 ロック衝突が発生する原因はさまざまである。例えば、キューからデータを取り出す処理が、複数のスレッドで頻繁に実行されるプログラムの場合を考える。また、上記プログラムのプログラム・コードにおいて、排他実行が必要な処理を記載するための同期ブロック中に、上記取り出す処理についての文が記載されている場合を考える。上記プログラムは、実行時において、上記取り出す処理が呼び出される毎に常にロックを獲得する。よって、ロック衝突が頻繁に発生する。従って、頻繁に発生する上記ロック衝突によって、システムの性能上の問題が引き起こされうる。
 32個のハードウェアスレッドを実行しうるコンピュータ・システムにおいて、上記プログラム・コードと似た構造のプログラム・コードのプログラムが、
システムの性能上のボトルネックになることが、SUN(商標) BUG DataBaseに報告されている(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6525425)。該報告では、上記似た構造のプログラム・コードを有するSUN JDK 1.5.0_13 のjava.lang.ref.RereferenceQueue クラスで上記問題が確認されている。
 上記クラスのメソッドである上記取り出す処理に対応するpoll()メソッドは、SUN JDK1.5.0_14において修正されている。該修正では、poll()メソッドの実装において、ロックを獲得する処理についての文の前に、キューが空かどうかを判断し空と判断した場合にメソッドを抜ける処理についての文が挿入されている。
 下記非特許文献1は、プログラム・コードにmarked bitを付加し、該付加されたmarked bitとcompareAndSwap(CAS)命令とを利用することで、プログラム・コードが同時並行性(concurrency)の高いプログラム・コードに変形可能であることを記載する。下記非特許文献1では、上記marked bitの付加は手動で行われている。
Martin Vechev, Eran Yahav, Deriving Linearizable Fine-Grained Concurrent Objects, PLDI’08, ACM 978-1-59593-860-2/08/06, 2008年6月7日~13日
 ロック衝突による性能低下の問題が発生するたびに、その原因を特定し、人手でプログラム・コードを修正する作業が必要である。しかし、該作業は、現存するプログラム・コードの量から考えると、多量のワークロードを必要とするために不可能に近い。従って、上記問題が発生しそうな箇所を自動的に特定し、該箇所を自動的に修正する方法が必要とされている。
 本発明は、マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換する方法を提供する。該方法は、コンピュータ・システムに下記ステップを実行させる。該ステップは、
 上記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索するステップであって、上記副作用がないとは上記同期ブロック内の文による処理中の値が上記同期ブロック外の文によって参照できないことである、上記検索するステップと、
 上記同期ブロック外に、上記検索された第1の条件文によって分岐される副作用のないパスを複製するステップと、
 上記複製に応じて、上記プログラム・コード内に第2の条件文を追加するステップであって、上記第2の条件文は上記複製された副作用のないパスへ分岐させる条件文である、上記追加するステップと
 を含む。上記方法によって、副作用のないパスへ分岐させた場合、同期ブロック内の第1の条件文が実行されない。よって、ロック衝突が少なくなる。上記方法は、特に、条件文が1つで、分岐が2つの場合に有効である。
 本発明の1つの実施態様では、上記第1の条件文が、第1の条件式を含む。該第1の条件式は、第1の変数の読み出し、定数又はそれらの組み合わせに基づいてパスを選択させるように定義されている。ただし、前記第1の変数は、前記第1の条件文を含むサブルーチンを呼び出すルーチンの中だけが有効範囲である変数ではない。
 本発明の1つの実施態様では、上記第2の条件文が、上記第1の条件式の結果を格納するための変数に基づいて、上記第1の条件式の結果に応じてパスを選択させる第2の条件式を含む。
 本発明の1つの実施態様では、上記検索するステップが、上記読み出したプログラム・コードから、更新文をさらに検索するステップを含み、上記更新文は、上記同期ブロック内にあり且つ上記第1の変数を更新させ、
 上記追加するステップが、上記検索された更新文の直後から上記同期ブロックの終了文までの間に、上記第1の条件式の結果を格納するための変数と、該変数に代入される上記第1の条件式の結果とを含む文をさらに追加するステップを含む。
 本発明の1つの実施態様では、上記検索するステップが、上記読み出したプログラム・コード及び他のプログラム・コードの少なくとも1つから、更新文をさらに検索するステップを含み、上記更新文は、上記同期ブロックと同期する他の同期ブロック内にあり且つ上記第1の変数を更新させ、
 上記追加するステップが、上記検索された更新文の直後から上記他の同期ブロックの終了文までの間に、上記第1の条件式の結果を格納するための変数と、該同じ変数に代入される上記第1の条件式の結果とを含む文をさらに追加するステップを含む。
 本発明の1つの実施態様では、上記追加するステップが、上記第1の条件式の結果を格納するための変数が初めて参照される文より前に、上記第2の条件文が上記同期ブロックを含むパスを実行させる値を用いて又は上記第1の条件式の結果を用いて上記第1の条件式の結果を格納するための変数を初期化する文をさらに追加するステップを含む。
 本発明の1つの実施態様では、上記副作用が、実行結果の取り消しが容易でない処理である。
 本発明の1つの実施態様では、上記副作用が、スレッド間の同期を実行する処理、インスタンス変数に値を代入する処理、クラス変数に値を代入する処理、入出力を実行する処理、ネイティブコードを呼び出す処理又は配列要素の位置を示す番号に値を代入する処理である。
 本発明の1つの実施態様では、上記第1の条件式の数が2以上である場合、該2以上の第1の条件式の結果が、上記2以上の第1の条件式の組み合わせで求められる。
 本発明の1つの実施態様では、上記第1の条件式によって選択されるパスの数が3通り以上である場合、上記第1の条件式の結果を格納するための変数が、上記3通り以上のパスのうち副作用のないパスそれぞれに対応する。
 本発明の1つの実施態様では、上記第1の条件式の結果を格納するための変数が、原子性が保証されたデータ型の変数である。
 本発明の1つの実施態様では、上記検索するステップが、上記プログラム・コード及び他のプログラム・コードの少なくとも1つから、上記同期ブロックと同期する他の同期ブロックをさらに検索するステップを含み、
 上記検索の終了に応じて、上記複製するステップを実行する。
 本発明の1つの実施態様では、上記検索するステップが、上記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ上記同期ブロック外の文から上記第1の変数を参照する文をさらに検索するステップを含み、
 上記検索の終了に応じて、上記複製するステップを実行する。
 本発明の1つの実施態様では、上記同期ブロック内にスレッドを起動させる文が含まれる場合、
 上記検索するステップが、上記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ上記スレッドの実装を記載する文から、上記同期ブロック内の文と同期をとって実行される文をさらに検索するステップを含み、
 上記方法は、コンピュータ・システムに、上記同期をとって実行される文が検索されることに応じて、上記スレッドを起動させる文を含むパスを副作用のあるパスと判定するステップをさらに実行させる。
 本発明の1つの実施態様では、上記同期ブロック内にスレッドを起動させる文が含まれる場合、
 上記検索するステップが、上記スレッドを起動させる文を含むパスが副作用のないパスかどうかをユーザに判断することを求めるステップをさらに含む。
 本発明の1つの実施態様では、上記同期ブロックが実行されるスレッドの実行順序を決定するために使用される変数が上記同期ブロック内に定義されている場合、
 上記検索するステップが、上記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ上記使用される変数を参照する文を上記同期ブロック外からさらに検索するステップを含み、
 上記方法は、コンピュータ・システムに、上記使用される変数を参照する文が検索されることに応じて、上記使用される変数を含むパスを副作用のあるパスと判定するステップをさらに実行させる。
 本発明の1つの実施態様では、上記同期ブロックが実行されるスレッドの実行順序を決定するために使用される変数が上記同期ブロック内に定義されている場合、
 上記検索するステップが、上記使用される変数を含むパスが副作用のないパスかどうかをユーザに判断することを求めるステップをさらに含む。
 本発明の1つの実施態様では、上記追加するステップが、上記読み出したプログラム・コードに、上記第1の条件式の結果を格納するための変数を宣言する文をさらに追加するステップを含み、
 共有変数が上記プログラム・コード及び上記他のプログラム・コードの少なくとも1つに含まれており且つ上記同期ブロック外の文からアクセスされる場合に、上記宣言がメモリのアクセス順序に関する最適化を抑止することの指定及び原子性を保証することの指定を含み、上記共有変数は上記副作用のないパスに含まれており、且つ複数のスレッドからアクセスされることができ、
 上記アクセスされない場合に、上記宣言が原子性を保証することの指定を含む。
 本発明の1つの実施態様では、上記検索するステップが、上記同期ブロックと同期する他の同期ブロックがあるかどうかをユーザに判断させることを許すステップをさらに含む。そして、上記方法は、コンピュータ・システムに、上記許すステップの後に、上記複製するステップを実行させる。
 本発明の1つの実施態様では、上記検索するステップが、上記第1の変数を参照する文があるかどうかをユーザに判断させることを許すステップをさらに含む。そして、上記方法は、コンピュータ・システムに、上記許すステップの後に、上記複製するステップを実行させる。
 本発明の1つの実施態様では、上記第2の条件式に含まれる変数がメモリのアクセス順序に関する最適化を抑止することを指定された変数の場合、上記第1の条件式の結果を代入する文をさらに追加するステップにおいて、上記同期ブロックの終了文の直前に、上記第1の条件式の結果を代入する文を追加する。
 本発明はまた、マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換する方法を提供する。該方法は、コンピュータ・システムに下記ステップを実行させる。該ステップは、
 上記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索するステップであって、上記副作用がないとは上記同期ブロック内の文による処理中の値が上記同期ブロック外の文によって参照できないことである、上記検索するステップと、
 上記同期ブロック外に、上記検索された第1の条件文によって分岐される副作用のないパスを複製するステップと、
 上記複製に応じて、上記プログラム・コード内に第2の条件文を追加するステップであって、上記第2の条件文は上記複製された副作用のないパスへ分岐させる条件文である、上記追加するステップと
 を含み、
 前記第1の条件文が第1の条件式を含み、該第1の条件式は、インスタンス変数若しくはクラス変数の読み出し、定数又はそれらの組み合わせに基づいて、副作用のないパスに分岐させる場合にその結果がtrueとなるように定義されており、一方副作用のあるパスに分岐させる場合にその結果がfalseとなるように定義されており、
 上記第2の条件文が、第2の条件式を含み、該第2の条件式は、上記第1の条件式の結果を格納するためのboolean型の変数に基づいて、上記第1の条件式の結果に応じてパスを選択させるように定義されている。
 本発明はさらに、コンピュータに、上記方法のいずれか1つに記載の方法の各ステップを実行させるコンピュータ・プログラムを提供する。
 本発明はまた、マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するコンピュータ・システムを提供する。該コンピュータ・システムは、
 上記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索する検索部であって、上記副作用がないとは上記同期ブロック内の文による処理中の値が上記同期ブロック外の文によって参照できないことである、上記検索部と、
 上記同期ブロック外に、上記検索された第1の条件文によって分岐される副作用のないパスを複製する複製部と、
 上記複製に応じて、上記プログラム・コード内に第2の条件文を追加する追加部であって、上記第2の条件文は上記複製された副作用のないパスへ分岐させる条件文である、上記追加部と
 を含む。
 本発明の1つの実施態様では、上記検索部が、上記読み出したプログラム・コードから、更新文をさらに検索し、上記更新文は上記同期ブロック内にあり、且つ上記第1の変数を更新させ、
 上記追加部が、上記検索された更新文の直後から上記同期ブロックの終了文までの間に、上記第1の条件式の結果を格納するための変数と、該変数に代入される上記第1の条件式の結果とを含む文をさらに追加する。
 本発明の1つの実施態様では、上記検索部が、上記読み出したプログラム・コード及び他のプログラム・コードの少なくとも1つから、更新文をさらに検索し、上記更新文は上記同期ブロックと同期する他の同期ブロック内にあり、且つ上記第1の変数を更新させ、 上記追加部が、上記検索された更新文の直後から上記他の同期ブロックの終了文までの間に、上記第1の条件式の結果を格納するための変数と、該同じ変数に代入される上記第1の条件式の結果とを含む文をさらに追加する。
 本発明の1つの実施態様では、上記追加部が、上記第1の条件式の結果を格納するための変数が初めて参照される文より前に、上記第2の条件文が上記同期ブロックを含むパスを実行させる値を用いて又は上記第1の条件式の結果を用いて上記第1の条件式の結果を格納するための変数を初期化する文をさらに追加する。
 本発明の1つの実施態様では、上記検索部が、上記プログラム・コード及び他のプログラム・コードの少なくとも1つから、上記同期ブロックと同期する他の同期ブロックをさらに検索する。
 本発明の1つの実施態様では、上記検索部が、上記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ上記同期ブロック外の文から上記第1の変数を参照する文をさらに検索する。
 本発明の1つの実施態様では、上記同期ブロック内にスレッドを起動させる文が含まれる場合、
 上記検索部が、上記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ上記スレッドの実装を記載する文から、上記同期ブロック内の文と同期をとって実行される文をさらに検索する。
 上記コンピュータ・システムは、上記同期をとって実行される文が検索されることに応じて、上記スレッドを起動させる文を含むパスを副作用のあるパスと判定する判定部をさらに含む。
 本発明の1つの実施態様では、上記同期ブロック内にスレッドを起動させる文が含まれる場合、
 上記検索部が、上記スレッドを起動させる文を含むパスが副作用のないパスかどうかをユーザに判断させることを許す判断部をさらに含む。
 本発明の1つの実施態様では、上記同期ブロックが実行されるスレッドの実行順序を決定するために使用される変数が上記同期ブロック内に定義されている場合、
 上記検索部が、上記プログラム・コード及び上記他のプログラム・コードの少なくとも1つに含まれており且つ上記使用される変数を参照する文を上記同期ブロック外からさらに検索する。
 上記コンピュータ・システムは、上記使用される変数を参照する文が検索されることに応じて、上記使用される変数を含むパスを副作用のあるパスと判定する判定部をさらに含む。
 本発明の1つの実施態様では、上記同期ブロックが実行されるスレッドの実行順序を決定するために使用される変数が上記同期ブロック内に定義されている場合、
 上記検索部が、上記使用される変数を含むパスが副作用のないパスかどうかをユーザに判断させることを許す判断部をさらに含む。
 本発明の1つの実施態様では、上記追加部が、上記読み出したプログラム・コードに、上記第1の条件式の結果を格納するための変数を宣言する文をさらに追加し、
 共有変数が上記プログラム・コード及び上記他のプログラム・コードの少なくとも1つに含まれており且つ上記同期ブロック外の文からアクセスされる場合に、上記宣言がメモリのアクセス順序に関する最適化を抑止することの指定及び原子性を保証することの指定を含み、上記共有変数は上記副作用のないパスに含まれており、且つ複数のスレッドからアクセスされることができ、
 上記アクセスされない場合に、上記宣言が原子性を保証することの指定を含む。
 本発明の1つの実施態様では、上記検索部が、上記同期ブロックと同期する他の同期ブロックがあるかどうかをユーザに判断させることを許す判断部をさらに含む。
 本発明の1つの実施態様では、上記検索部が、上記第1の変数を参照する文があるかどうかをユーザに判断させることを許す判断部をさらに含む。
 本発明の実施態様によれば、同期ブロック中の第1のパスの中から、ロックが獲得されていなくても実行が可能な第2のパスが自動的に見つけ出される。そして、該見つけ出された第2のパス及びロックを獲得せずに第2のパスを実行させるための条件文が、プログラム・コード中の上記第1のパスの外に追加される。上記追加によって、プログラム・コード実行時のロック衝突時間が減少し、マルチスレッド上のCPU効率の低下を防止することが可能である。
本発明の実施態様における、プログラム・コードを変換するためのシステムが有する機能を示す機能ブロック図を示す。 本発明の実施態様における、図1に示す変換される前のプログラム・コードの例を示す。 本発明の実施態様における、図1に示す変換プログラムにおいて実行される処理ステップのうち、変換に必要な情報を取得する処理ステップの例を示す。 本発明の実施態様における、図1に示す変換プログラムにおいて実行される処理ステップのうち、変換を行う処理ステップの例を示す。 本発明の実施態様における、図4に記載のステップ317の処理の詳細を示す。 本発明の実施態様における、図3~図5に記載の各ステップの動作を具体的に説明するために使用する入力データCLを示す。 本発明の実施態様における、図4に記載のステップ316の処理が実行された後のメソッドdequeue()を示す。 本発明の実施態様における、図6について、図3~図5に記載のステップの処理が実行された後の入力データ(変換後のプログラム・コード)を示す。 本発明の実施態様における、図3~図5に記載の各ステップの動作を具体的に説明するために使用する入力データCLを示す。 本発明の実施態様における、図4に記載のステップ316の処理が実行された後のメソッドdequeue()を示す。 本発明の実施態様における、図9について、図3~図5に記載の各ステップの処理が実行された後の入力データ(変換後のプログラム・コード)を示す。 本発明の実施態様における、第1の条件式によって選択されるパスが3通り以上である場合の、図3~図5に記載の各ステップの処理が実行される前のプログラム・コードの一部及び実行された後のプログラム・コードの一部を示す。 本発明の実施態様における、図1のシステムが有するコンピュータ・ハードウェアのブロック図を示す。
 本発明の実施態様において、「マルチスレッド上で動作するプログラムのプログラム・コード」とは、スレッドと呼ばれる処理単位を複数生成し、該生成されたスレッド毎にCPUタイムを割り当てることによって、並行して複数の処理を行なうことができるプログラムのソースコードをいう。該ソースコードは、例えばJava(商標)言語又はC++言語を使用して記述される。
 本発明の実施態様において、「ロック」とは、1つのスレッドで処理が実行されるときに、他のスレッドで上記処理自身及び上記処理と関係する処理が実行されないようにすることである。例えば、第1のスレッドにおいて上記ロックの対象の処理が開始された場合、第2のスレッドにおいて上記処理又は上記処理に関係する処理は実行されない。上記第2のスレッドにおける上記処理又は上記処理に関係する処理は、上記第1のスレッドにおける処理が終了するまで待機させられ、上記終了後に実行されうる。
 本発明の実施態様において、「ロック衝突」とは、1つのスレッドで実行される処理がロックの対象であるために、他のスレッドで実行される上記処理自身及び上記処理と関係する処理が、上記第1のスレッドで実行される処理が終了するまで実行待ちになる状態をいう。また、「ロック衝突が少ない」とは、ロック衝突の発生する頻度が少ないこと及びロック衝突による上記実行待ちの時間が短いことを表す。本発明の実施態様を用いて変換されたプログラム・コードは、変換される前のプログラム・コードに比べ、ロック衝突が少なくなる。
 本発明の実施態様において、「同期ブロック」とは、上記ロックの対象である処理が記載されているプログラム・コード上の文である。該プログラム・コード上の文は、同期ブロックの開始文、同期ブロックの終了文及び上記開始文と終了文に囲まれた文で構成される。
 同期ブロックの開始文は、上記プログラム・コードが例えばJava(商標)言語で記載されている場合、例えば、synchronized宣言を記載する文又はsynchronized修飾子で修飾されたメソッド名を記載する文である。
 同様に、同期ブロックの終了文は、上記プログラム・コードが例えばJava(商標)言語で記載されている場合、上記開始文の終了位置を表す「}」である。
 サブルーチンの呼び出しが上記開始文と終了文に囲まれた文(すなわち同期ブロック内)内に含まれている場合、該サブルーチンの実装を記載する文は上記同期ブロック内に含まれていてもよい。上記サブルーチンの実装を記載する文の中に別のサブルーチンの呼び出しが含まれるというように、サブルーチンの呼び出しが階層状になっている場合、全てのサブルーチンの実装を記載する文が、上記同期ブロックにさらに含まれていてもよい。ここで、サブルーチンとは例えば、メソッドである。
 本発明の実施態様において、「同期ブロックと同期する他の同期ブロック」とは、例えば、ロックの対象である処理によってアクセスされる変数が共通である又は指定されたロックオブジェクトが共通である同期ブロックである。ここで、ロックオブジェクトとは、Java(商標)言語のsynchronized宣言において指定する変数である。例えば、第1の同期ブロックを宣言するsynchronized宣言においてロックオブジェクトlockが指定され且つ第2の同期ブロックを宣言するsynchronized宣言においてロックオブジェクトlockが指定された場合、第2の同期ブロックは、第1の同期ブロックと同期する他の同期ブロックである。また、第1の同期ブロックがメソッドであり且つ第2の同期ブロックを宣言するsynchronized宣言において上記メソッドを指すthisが指定された場合、第2の同期ブロックは、第1の同期ブロックと同期する他の同期ブロックである。
 本発明の実施態様において、「同期ブロックに対する副作用」とは、同期ブロック内の文による処理(処理A)の結果が同期ブロック外の文による処理(処理B)によって参照されうる処理Aである。同期ブロックに対する副作用はまた、処理結果の取り消しが容易でない処理である。同期ブロックに対する副作用は、例えば、同期ブロック内に記載された別の同期ブロック内の処理、インスタンス変数に値を代入する処理、クラス変数に値を代入する処理、入出力を実行する処理、ネイティブコードに含まれる処理を呼び出す処理、又は配列要素の位置を示す番号に値を代入する処理であるが、これらに限定されない。 上記副作用は、例えばユーザが上記処理についての文をリストに登録し、コンピュータ・システムが該リストに登録された文を参照することにより判断される。
 なお、上記入出力とは、例えば、画面、ファイル又はネットワークへの入出力であるが、これらに限定されない。また、上記ネイティブコードは、マシン語で記載されたプログラムである。ネイティブコードは、例えば、コンパイル済みのプログラムである。ネイティブコードに含まれる処理は、例えば、Java Native Interface(JNI)によって呼び出される。
 本発明の実施態様において、「同期ブロックに対する副作用がない」とは、同期ブロック内の文による処理中の値が上記同期ブロック外の文によって参照できないことである。副作用がないとは、副作用を起こす処理、例えば同期ブロック内に記載された別の同期ブロック内の処理、インスタンス変数に値を代入する処理、クラス変数に値を代入する処理、入出力を実行する処理、ネイティブコードに含まれる処理を呼び出す処理、又は配列要素の位置を示す番号に値を代入する処理のいずれもないことである。
 本発明の実施態様において、「パス」とは、プログラムの実行時において実行される処理に対応する、プログラム・コード上の一連の文である。該文は0であってもよい。
 本発明の実施態様において、「同期ブロックに対する副作用のないパス」とは、プログラムの実行時において上記同期ブロックに対する副作用のない処理に対応する、上記一連の文である。
 本発明の実施態様において、「条件文」とは、プログラムにおいて処理の分岐を実現させるためのプログラム・コード上に記載された文である。条件文は、条件式を含む。条件文は、選択されるパスの範囲を示す記号を含んでいてもよい。プログラム・コードが、例えばJava(商標)で記載されている場合、上記記号は例えば「{」及び「}」である。条件文は、条件式の結果に応じて、実行されるパスを選択する。プログラム・コードが、例えばJava言語で記載されている場合、条件文は例えばif文又はswitch文である。
 本発明の実施態様において、「条件式」とは、パスを選択するために使用される式である。条件式は、変数、定数及び演算子の少なくとも1を含む。条件文が、例えば、if文の文「if(x==0){y=1;}」である場合、条件式は、「(x==0)」である。また、条件文が、例えば、switch文又はselect case文の場合、両文に関連するcaseの値と該値が格納される変数とを比較する式を条件式とする。条件文が、例えばswitch文の文「switch(x){case 1:y=1;break;}」である場合、条件式は、「(x==1)」である。
 条件式の数は、1つの条件文に対して1つとは限らない。
 (1)条件文が、例えば、if文の文
  「if(x==0){y=0;}else if(x==1){y=1;}else{y=2;}」
 である場合、「(x==0)」、「(x==1)」及び「その他」の少なくとも1が条件式でありうる。また、複数の条件式、例えば「(x==0)」、「(x==1)」及び「その他」から選択される2つ以上を組み合わせて、新たな条件式としてもよい。ここで、組み合わせとは、上記条件式同士を例えば論理演算することである。
 (2)条件文が、例えば、switch文の文
  「switch(x){
   case 1: y=1; break;
   case 2: y=2; break;
   default: y=3; break;
  }」
 である場合、「(x==1)」、「(x==2)」及び「その他」の少なくとも1が条件式でありうる。また、複数の条件式、例えば「(x==1)」、「(x==2)」及び「その他」から選択される2つ以上を組み合わせて、新たな条件式としてもよい。
 本発明の実施態様において、「第1の変数」とは、第1の条件式にパスを選択させるための1つの変数である。「第1の変数」とは、例えば高々1つの変数である。プログラム・コードが、例えばJava言語で記載されている場合、第1の変数は、1つのインスタンス変数又は1つのクラス変数である。
 本発明の実施態様において、「第1の条件式の結果」とは、第1の条件式によって又は複数の第1の条件式の組み合わせによって表わされる値である。
(1)条件文が例えばif文の場合、第1の条件式の結果は例えば真又は偽で表される。上記真又は偽は、プログラム・コードを記載する言語の上記条件式の仕様に合わせた値で表現されてもよいし、又はユーザが決定した値で表現されてもよい。例えば、真を表す値をtrueとし偽を表す値をfalseとしてもよいし、又は真を表す値を0とし偽を表す値を-1としてもよい。上記真又は偽を表す値がtrue又はfalseの場合、第1の条件式の結果を格納するための変数は、例えばboolean型である。上記真又は偽を表す値が0又は-1の場合、第1の条件式の結果を格納するための変数は、例えば負の値をサポートする数値型である。また、if文が例えばelseif句を含むために上記if文に第1の条件式が複数ある場合、第1の条件式の結果は、複数の第1の条件式によって表わされる値を組み合わせて求められてよい。上記組み合わせるとは、条件式を表す値同士を例えば論理演算することである。
(2)条件文が例えばswitch文の場合、第1の条件式の結果は例えば、switch文において指定された変数がcase句で指定された値であることを示す値(以下、示す値)又は該示す値に対応する値で表される。上記示す値は、例えば、上記case句で指定された値であってもよい。上記対応する値は、例えばユーザが決定した値である。ユーザは、上記対応する値に、例えば連番を用いる。上記示す値を第1の条件式の結果とする場合、第1の条件式の結果を格納するための変数は、例えば上記指定された変数と同じデータ型である。また、第1の条件式の結果は、複数の上記示す値又は複数の上記対応する値を組み合わせて求められてもよい。上記組み合わせるとは、例えば、上記示す値又は上記対応する値のとる範囲に応じて、グループ分けすることである。
 本発明の実施態様において、「原子性が保証されたデータ型の変数」とは、メモリへの変数の読み込みが1回の操作で実行されるデータ型の変数であり、該実行がプログラム・コードを記載する言語の仕様によって保証されているデータ型の変数である。
 上記言語が、例えばJava(商標)言語であり且つ上記プログラム・コードが32ビット以上のOS上で実行される場合、例えばboolean型、byte型、short型、int型又はfloat型が、原子性が保証されたデータ型である。
 本発明の実施態様において、「他のプログラム・コード」とは、変換される前のプログラム・コードからリンクされるプログラム・コードである。ここで、リンクされるとは、例えば呼び出されること又は変数を共有することであるが、これらに限定されない。また、他のプログラム・コードは、本発明の実施態様によって解析可能なプログラム・コードである。他のプログラム・コードとは、例えば、ソースコード又はバイトコードである。
 本発明の実施態様において、「メモリのアクセス順序に関する最適化を抑止すること」とは、変換される前のプログラム・コードがコンパイルされるときに、コンパイラによるメモリのアクセス順序に関する最適化をさせないことである。最適化を抑止することの指定は、例えば、変換される前のプログラム・コードがJava(商標)で記載された言語の場合、修飾子volatileで変数を修飾することである。
 以下、図面に従って、本発明の実施態様を説明する。本実施態様は、本発明の好適な態様を説明するためのものであり、本発明の範囲をここで示すものに限定する意図はないことを理解されたい。また、以下の図を通して、特に断らない限り、同一の符号は、同一の対象を指す。
 図1は、本発明の実施態様における、プログラム・コードを変換するためのシステムが有する機能を示す機能ブロック図を示す。
 コンピュータ・システム(101)は、メモリ(102)、検索部(103)、複製部(104)、追加部(105)、判定部(106)及び判断部(107)を含む。また、記憶部(108)は、コンピュータ・システム(101)に含まれていても、又は別のシステムに含まれていてもよい。
 コンピュータ・システム(101)は、記憶部(108)から、変換される前のプログラム・コード(109)をメモリ内(102)に読み出す。ここで、コンピュータ・システムは(101)は、記憶部(108)から、他のプログラム・コード(110)をさらにメモリ内に読み出してもよい。
 検索部(103)は、上記メモリに読み出されたプログラム・コード(109)及び任意的に他のプログラム・コード(110)を検索する。該検索により、検索部(103)は、同期ブロック内にある第1の条件文、更新文、同期ブロックと同期する他の同期ブロック、同期ブロック外の文から第1の変数を参照する文、スレッドを起動させる同期ブロック内の文と同期をとって実行される他のスレッドの実装を記載する文、又は、スレッドの実行順序を決定するために使用される変数を参照する文を検索する。
 検索部(103)は、判断部(107)を含む。
 判断部(107)は、上記検索をするための情報が不十分の場合、ユーザに該情報を入力させることを許す。判断部(107)はまた、上記検索の条件をさらに絞り込むために、ユーザに該条件を入力させることを許す。
 判定部(106)は、検索部(103)から検索結果を受け取る。判定部(106)は、上記検索結果から、プログラム・コード(109)中の副作用のないパスを判定する。
 複製部(104)は、上記判定された副作用のないパスを、プログラム・コード(109)の同期ブロック外に複製する。
 追加部(105)は、上記複製された副作用のないパスへ分岐させる第2の条件文を、上記メモリに読み出されたプログラム・コード(109)に追加する。追加部(105)はまた、第1の条件式の結果を格納するための変数と該変数に代入される上記第1の条件式の結果とを含む文、該変数を初期化する文、又は該変数を宣言する文を、上記メモリに読み出されたプログラム・コード(109)に追加する。
 図2は、本発明の実施態様における、図1に示す変換される前のプログラム・コードの例を示す。
 プログラム・コード(200)は、変換される前のプログラム・コードである。以下では、該プログラム・コード(200)を例として、明細書に記載の各用語を説明する。
 「クラス」に対応する文は、フォーマット「class クラス名 {クラスの実装}」を満たす文である。よって、変換される前のプログラム・コード(200)において「クラス」に対応する文は、クラスW(201A)及びクラスX(201B)である。
 「メソッド」に対応する文は、フォーマット「戻り値 メソッド名 (引数型 引数名){メソッドの実装}」を満たす文である。よって、変換される前のプログラム・コード(200)において「メソッド」に対応する文は、メソッドenqueue(W w)(202A)及びメソッドdequeue()(202B)である。また、メソッド内に記載された文に別のメソッド呼び出しが含まれる場合、該別のメソッドの実装を記載する文も、上記同期メソッド内に記載された文として扱う。
 「同期ブロック」に対応する文は、例えば、synchronizedブロックの宣言がされた文又はsynchronized修飾子が指定されたメソッドである。よって、変換される前のプログラム・コード(200)において「同期ブロック」に対応する文は、第1の同期ブロック(203A)、第2の同期ブロック(203B)及び第3の同期ブロック(203C)である。
 「同期ブロックのロックオブジェクト」は、例えば、上記synchronizedブロックの宣言で又は上記synchronized修飾子が指定されたメソッドの引数で指定される変数である。よって、第1の同期ブロック(203A)のロックオブジェクトは、w(204A)である。第2の同期ブロック(203B)のロックオブジェクトは、lock(204B)である。第3の同期ブロック(203C)のロックオブジェクトは、lock(204C)である。
 また、同期ブロック内に記載された文にメソッド呼び出しが含まれる場合、該メソッドの実装を記載する文も、上記同期ブロック内に記載された文として扱う。
 「条件文」に対応する文は、例えば「IF」文、「SWITCH」文、又は「3項演算子」が記載された文である。よって、変換される前のプログラム・コード(200)において「条件文」に対応する文は、第1の条件文(205A)、第2の条件文(205B)、第3の条件文(205C)及び第4の条件文(205D)である。
 「条件式」は、条件分岐文に含まれ実行パスを選択するために使用される式である。よって、第1の条件文(205A)の条件式は、w.val==null(206A)である。第2の条件文(205B)の条件式は、head==null(206B)である。第3の条件文(205C)の条件式は、head!=null(206C)である。第4の条件文(205D)の条件式は、w.next==w(206D)である。
 「パス」に対応する文は、プログラム・コード(200)が実行された場合に、処理される可能性のある文である。例えば、メソッドenqueue(W w)(202A)が実行され終了するまでのパスは、パス(207A)であり、及びメソッドdequeue()(202B)が実行され終了するまでのパスは、パス(207B)である。
 また、条件文が実行され終了するまでのパスは、それぞれの分岐の処理が開始する文から、それぞれの分岐の処理が終了する文までである。
 (1)第1の条件文(205A)は、メソッドenqueue(W w) (202A)から抜ける処理(208A及び208B)の次の文においてそれぞれの分岐の処理が終了する。よって、第1の条件文(205A)が実行され終了するまでのパスは、条件式(206A)が成立した場合に実行されるパス(209A)及び条件式(206A)が成立しなかった場合に実行されるパス(209B)である。
 (2)第2の条件文(205B)は、「if(head==null){w.next=w;}else{w.next=head;}」と同じ意味である。よって、w又はheadをw.nextに代入する処理の次の文においてそれぞれの分岐の処理が終了する。従って、第2の条件文(205B)が実行され終了するまでのパスは、条件式(206B)が成立した場合に実行されるパスである「w.next=W;」、及び条件式(206B)が成立しなかった場合に実行されるパスである「w.next=head;」である。
 (3)第3の条件文(205C)は、メソッドdequeue()(202B)から抜ける処理(208C及び208D)の次の文でそれぞれの分岐の処理が終了する。よって、第3の条件文(205C)が実行され終了するまでのパスは、条件式(206C)が成立した場合に実行されるパス(209C)及び条件式(206C)が成立しなかった場合に実行されるパス(209D)である。
 (4)第4の条件文(205D)は、「if(w.next==w){head=null;}else{head=w.next;}」と同じ意味である。よって、headにnull又はw.nextを代入する処理の次の文でそれぞれの分岐の処理が終了する。従って、第4の条件文(205D)が実行され終了するまでのパスは、条件式(206D)が成立した場合に実行されるパスである「head=null;」及び条件式(206D)が成立しなかった場合に実行されるパスである「head=w.next;」である。
 「第1の変数」は、分岐の判断に使用される変数である。よって、第1の条件文(205A)における第1の変数は、w.val(210A)である。第2の条件文(205B)における第1の変数は、head(210B)である。第3の条件文(205C)における第1の変数は、head(210C)である。第4の条件文(205D)における第1の変数は、w.next(210D)である。
 「更新文」は、上記第1の変数を含む同期ブロック内の文であって、上記第1の変数を更新させる文である。w.val(210A)を更新させる更新文は、w.val(210A)を含む第1の同期ブロック(203A)には含まれていない。head(210B)を更新させる更新文は、更新文(211B)である。head(210C)を更新させる更新文は、更新文(211C)である。w.next(210D)を更新させる更新文は、更新文(211D)である。
 図3~図5は、本発明の実施態様における、図1に示す変換プログラムにおいて実行される処理ステップの例を示す。
 以下では、変換される前のプログラム・コードがJava(商標)言語で記載されたプログラム・コードの場合を例として説明する。
 コンピュータ・システム(101)は、変換される前のプログラム・コード(以下、CL)を入力データとする。コンピュータ・システムは、該CLに加えて、上記CLからリンクされる別のプログラム・コード(以下、別のCL)をさらに入力データとしてもよい。ここで、入力データとは、上記変換プログラムから参照可能なデータである。
 図3は、本発明の実施態様における、図1に示す変換プログラムにおいて実行される処理ステップのうち、変換に必要な情報を取得する処理ステップの例を示す。
 ステップ301は、上記変換する処理の開始である。ステップ301では、コンピュータ・システムは、上記入力データを、例えばメモリに読み込む。該読み込みが終了することに応じて、該処理はステップ302に進む。
 ステップ302では、コンピュータ・システムは、上記変換のための情報を格納するための変数i、集合変数M、集合変数S及び集合変数Cを用意する。
 変数iは、下記ステップ315で宣言される変数(以下、第2の変数)を識別するための値が格納される変数である。変数iは、例えば、上記第2の変数に振られる連番に使用される。なお、変数iは用意されなくてもよい。変数iが用意されない場合、コンピュータ・システムは、第2の変数が宣言される毎に、第2の変数に一意に識別できるような変数名を付ける。上記一意に識別できるような変数名は、例えばユーザによって決定されてもよいし、重複しないようにランダムで決定されてもよい。
 集合変数は、異なる意味を持つデータをまとめて扱うためのグループである。集合変数は、例えば、配列又は構造体で表される。
 集合変数Mは、上記CLが実行されたときに処理が到達しうるメソッドについての情報が、上記メソッド毎に格納される集合変数である。上記メソッドについての情報は、対応するメソッドの実装を記載する文を、プログラム・コードから特定できる情報であればよい。上記メソッドについての情報は、例えばメソッドの実装を記載する文の開始位置、メソッドの実装を記載する文の終了位置、又はメソッドの実装を記載する文であるがこれらに限られない。
 集合変数Sは、上記メソッドそれぞれが実行されたときに処理が到達しうる同期ブロックについての情報が、上記同期ブロック毎に設定される集合変数である。上記同期ブロックについての情報とは、同期ブロックのロックオブジェクト(以下、Sの第1の情報)、同期ブロックのプログラム・コード上の開始終了位置(以下、Sの第2の情報)及び同期ブロック内の文(以下、Sの第3の情報)である。
 集合変数Cは、上記同期ブロックそれぞれに含まれる所定の条件を満たす実行パスについての情報が、上記実行パス毎に設定される集合変数である。上記実行パスについての情報とは、上記実行パスに対応する上記同期ブロックのロックオブジェクト(以下、Cの第1の情報)、上記実行パスに対応する上記同期ブロックのプログラム・コード上の開始終了位置(以下、Cの第2の情報)及び上記実行パスをプログラム・コードから特定できる情報(以下、Cの第3の情報)である。上記Cの第3の情報は、例えば実行パスの開始位置、実行パスの終了位置、又は実行パスを記載する文であるがこれらに限られない。
 コンピュータ・システムは、変数i、集合変数S及び集合変数Cの上記用意において、該変数i、該集合変数S及び該集合変数Cに初期値を設定する。上記初期値は、例えば、何も入っていないことを表す値である。コンピュータ・システムは、変数iの初期値として、例えば0又は1を設定する。また、集合変数S及びCが、例えば、数値型変数と文字型変数とを含む構造体の場合、コンピュータ・システムは、集合変数S及びCの初期値として、例えば、数値型変数の初期値には0を、文字型変数の初期値にはNULLを設定する。
 コンピュータ・システムはまた、集合変数Mの上記用意において、該集合変数Mに上記メソッドについての情報を設定する。コンピュータ・システムは、CLに含まれるメソッドを検索し、検索されたメソッドについての情報を集合変数Mに設定する。上記検索では、対象とするメソッドが予めユーザに指定されてもよいし、CLに含まれる全てのメソッドが検索されてもよい。CLに含まれるメソッドが実行されることによって到達しうるメソッドが、例えば上記別のCLから検索されてもよい。また、上記検索の代わりに、ユーザが、集合変数Mに上記メソッドについての情報を設定してもよい。
 上記用意が終了することに応じて、該処理はステップ303に進む。
 ステップ303は、集合変数Mについての繰り返しの開始を表す。
 ステップ303では、コンピュータ・システムは、集合変数Mからメソッドについての情報(以下、m)を1件取り出す。該取り出しが終了することに応じて、該処理はステップ304に進む。
 ステップ304では、コンピュータ・システムは、集合変数Sにデータを設定する。
 コンピュータ・システムは、上記取り出されたmに対応するメソッドが実行されたときに処理が到達しうる同期ブロックを検索する。なお、上記メソッド自身が同期ブロックの場合、上記メソッド自身も検索される同期ブロックとなる。CLが、例えばJava(商標)で記載されたプログラム・コードの場合、コンピュータ・システムは、例えば「synchronized」を上記CLから検索する。なお、mに対応するメソッドが「synchronized」で修飾されている場合、上記修飾する「synchronized」もまた、検索される「synchronized」である。
 コンピュータ・システムは、上記検索された同期ブロックそれぞれについての、ロックオブジェクト(Sの第1の情報)、プログラム・コード上の開始終了位置(Sの第2の情報)及び同期ブロック内の文(Sの第3の情報)を該検索された同期ブロックから取得し、該取得したSの第1~第3の情報を、同期ブロックごとに、集合変数Sに1組の情報として設定する。なお、検索された同期ブロックのうち、既に検索され情報が設定されている同期ブロックについては、上記設定は不要である。上記設定が終了することに応じて、該処理はステップ305に進む。
 ステップ305は、集合変数Mについての繰り返しの終了を表す。
 全てのmが取り出し済みの場合、該処理はステップ306に進む。取り出していないmがある場合、該処理はステップ303に戻る。
 ステップ306は、集合変数Sについての繰り返しの開始を示す。
 ステップ306では、コンピュータ・システムは、集合変数Sから同期ブロックについての上記1組の情報(以下、s)を1件取り出す。該取り出しが終了することに応じて、該処理はステップ307に進む。
 ステップ307では、コンピュータ・システムは、上記取り出されたsに対応する集合変数Sに設定されている同期ブロック内の文(以下、sの第3の情報)に、副作用が発生しないパスが含まれるかどうかを判定する。該判定は、同期ブロック内の文(sの第3の情報)に含まれるパスであって、実行される経路それぞれについてのパス(以下、実行パス)全てに実行される。該判定では、コンピュータ・システムは、例えば、下記副作用リストに記載された副作用を起こす原因が、上記実行パスに含まれているかどうかを判定する。
 副作用リストは、例えば、ユーザが予め作成しておく。ユーザは、副作用を起こす原因、例えばメソッド又は変数を、副作用リスト予めに登録しておく。メソッドは、例えばI/Oに関するメソッド又はJNIのメソッドである。変数は、例えばインスタンス変数又はクラス変数である。コンピュータ・システムは、上記判定において、上記実行パスに、例えば上記メソッド又は変数への書き込みが見つかった場合、上記実行パスを副作用が発生するパスと判定し、見つからなかった場合、上記実行パスを副作用の発生しないパスと判定する。なお、上記登録は、コンピュータ・システムによって、自動的に実行されてもよい。コンピュータ・システムは、例えばステップ302において、上記CL又は上記別のCLの少なくとも1つから、副作用を起こす原因を取得し、該取得した副作用を起こす原因を副作用リストに登録しうる。
 また、コンピュータ・システムは、実行パスに含まれる変数の種類を調べることによって、上記判定を実行しうる。コンピュータ・システムは、例えば、上記変数の宣言が上記CLのどこに記載されているか又は上記変数のスコープがCL上のどの範囲に設定されているかを調べることによって、上記判定を実行しうる。
 上記実行パスに副作用が発生しないパスがある場合、該処理はステップ308に進む。上記実行パスが全て副作用の発生するパスの場合、該処理はステップ310に進む。
 ステップ308では、コンピュータ・システムは、上記副作用が発生しない実行パスと該実行パスを実行させるための条件文とが、以下の要件を満たすかどうかを判定する。上記要件とは、上記実行パスが、インスタンス変数又はクラス変数の高々1つの読み出しを含み、上記条件文が、該読み出しと定数とを評価することである。
 要件を満たす条件文が1つでも存在する場合、該処理はステップ309に進む。要件を満たす条件文が存在しない場合、該処理はステップ310に進む。
 ステップ309では、コンピュータ・システムは、上記要件を満たす条件文によって実行されるパスそれぞれについて、上記Sの第1の情報であるロックオブジェクト(Cの第1の情報)、上記Sの第2の情報であるプログラム・コード上の開始終了位置(Cの第2の情報)及び上記要件を満たす条件文によって実行される実行パスをプログラム・コードから特定できる情報(Cの第3の情報)を、集合変数Cに1組の情報として設定する。
 上記設定の終了に応じて、該処理はステップ310に進む。
 ステップ310は、集合変数Sについての繰り返しの終了を表す。
 全てのsが取り出し済みの場合、該処理はステップ311に進む。取り出していないsがある場合、該処理はステップ306に戻る。
 図4は、本発明の実施態様における、図1に示す変換プログラムにおいて実行される処理ステップのうち、変換を行う処理ステップの例を示す。
 ステップ311は、集合変数Cについての繰り返しの開始を示す。
 ステップ311では、コンピュータ・システムは、集合変数Cから実行パスについての上記1組の情報(以下、c)を1件取り出す。なお、コンピュータ・システムは、プログラム・コードで早く実行される実行パスについての情報から順に上記取り出しを行う。該取り出しが終了することに応じて、該処理はステップ312に進む。
 ステップ312では、コンピュータ・システムは、上記取り出されたcに対応する集合変数Cに設定されているロックオブジェクト(以下、cの第1の情報)が、CL内のみで使用されているかどうかを判定する。該判定では、例えばCLがJava(商標)言語で記載されている場合、ロックオブジェクト(cの第1の情報)の定義にprivate修飾子が使用されていること又は、上記別のCLに上記ロックオブジェクト(cの第1の情報)を使用する記載が含まれていないことがチェックされる。該チェックにより、ロックオブジェクト(cの第1の情報)の定義にprivate修飾子が使用されているか又は、上記別のCLに上記ロックオブジェクト(cの第1の情報)を使用する記載が含まれていない場合、コンピュータ・システムは、ロックオブジェクト(cの第1の情報)が、CL内のみで使用されていると判定する。ここで、例えば、上記別のCLが入力データとして与えられていない、又は、上記別のCLがバイナリデータとして提供されているためにソースコードの記載が不明であるという理由により、上記チェックが実行できない場合がある。上記チェックが実行できない場合、コンピュータ・システムは、例えば、ロックオブジェクト(cの第1の情報)が、CL内のみで使用されていないと判定してもよい。また、コンピュータ・システムは、例えば、モニタに上記判定をさせるためのメッセージを表示して、ユーザに上記判定をさせてもよい。CL内でのみ使用されている場合、該処理はステップ314に進む。CL外でも使用されている場合、該処理はステップ313に進む。
 ステップ313では、コンピュータ・システムは、上記cに対応する集合変数Cの第3の情報(以下、cの第3の情報)に対応するパスを実行させる条件文に含まれる全ての変数がCL内でのみ定義されているかどうかを判定する。該判定では、上記別のCLに上記参照される変数の定義が含まれていないことがチェックされる。該チェックにより、上記別のCLに上記参照される変数の定義が含まれていない場合、コンピュータ・システムは、参照される変数がCL内でのみ定義されていると判定する。ここで、例えば、上記別のCLが入力データとして与えられていない又は、上記別のCLがバイナリデータとして提供されているためにソースコードの記載が不明であるという理由により、上記チェックが実行できない場合がある。上記チェックが実行できない場合、コンピュータ・システムは、例えば、上記参照される変数がCL内でのみ定義されていないと判定してもよい。また、コンピュータ・システムは、例えば、モニタに上記判定をさせるためのメッセージを表示して、ユーザに上記判定をさせてもよい。上記参照される変数がCL内でのみ定義されている場合、該処理はステップ314に進む。上記参照される変数がCL内でのみ定義されていない場合、該処理はステップ318に進む。
 ステップ314では、コンピュータ・システムは、CL内に、変数(以下、第2の変数)を宣言する文を追加する。上記追加する場所は、CLを記述するプログラム言語の仕様によって異なる。なお、第2の変数の宣言は、原子性が保証されているデータ型であって、スタティックであること及び最適化を抑止することが指定可能なデータ型の第2の変数の宣言である。ここで、原子性が保証されているとは、メモリへの変数の読み込みが1回の操作で実行されることが言語仕様によって保証されていることである。Java(商標)言語であれば、例えばboolean型、byte型、short型、int型又はfloat型は、サイズが32ビット以下のデータ型であり、例えば32ビット以上のCPU上で上記Java(商標)言語で記載されたプログラムが実行される場合、メモリへの変数の読み込みが1回の操作で実行されることが保証されているデータ型である。スタティックであるとは、CL内で実体を1つしか持たないことである。例えば、Java(商標)言語の場合、変数がスタティックであることは、修飾子staticで指定可能である。また、最適化を抑止するとは、例えば、コンパイラにおいてプログラム・コードがメモリのアクセス順序に関する最適化されることを抑止することである。例えば、Java(商標)言語の場合、変数の最適化を抑止することは、修飾子volatileで指定可能である。volatile宣言を導入することにより、メモリ・オーダと同期ブロック外への変更との可視性が保証される。
 第2の変数の変数名は、他の変数と重複しない名前であればどのような名前であってもよい。該名前は、例えば、変数iを含ませることで識別されてもよい。CLが、第2の変数として配列が使用可能な言語で記載されたプログラム・コードであれば、上記名前は、変数iを添え字とする配列であってもよい。
 上記第2の変数の宣言では、第2の変数がスタティック変数であることを宣言させる。また、上記cの第3の情報に対応するパスに含まれる共有変数が、Sに情報が設定されている同期ブロック内の文以外からアクセスされる場合、上記第2の変数の宣言では、上記第2の変数が最適化が抑止される対象の変数であることをさらに宣言させる。ここで、共有変数とは、複数のスレッドからアクセスされる可能性のある変数である。CLを記述するプログラム言語がJava(商標)言語の場合、上記共有変数は、インスタンス変数及びクラス変数である。なお、上記アクセスされることは、例えばCL又は上記別のCLが精査されることで求められる。ここで、例えば、上記別のCLが入力データとして与えられていない又は、上記別のCLがバイナリデータとして提供されているためにソースコードの記載が不明であるという理由により、上記精査が実行できない場合がある。上記精査が実行できない場合、コンピュータ・システムは、共有変数が同期ブロックの外側からアクセスされるとしてもよい。また、コンピュータ・システムは、例えば、モニタに共有変数が同期ブロックの外側からアクセスされるかどうかをユーザに判断させるメッセージを表示して、ユーザに上記判断をさせてもよい。
 上記追加が終了することに応じて、該処理はステップ315に進む。
 ステップ315では、コンピュータ・システムは、上記cの第3の情報に対応する実行パスを実行させる条件文から文を作成する。上記作成される文は、上記実行パスが実行されるための条件が成立した場合と、条件が成立しなかった場合とでそれぞれ違う値を上記第2の変数に代入する文である。
 例えば、上記第2の変数がboolean型の変数b1であり、上記条件文の条件式が(x!=null)の場合、上記作成される文は「b1=(x!=null);」とすることができる。別の例では、上記第2の変数がint型の変数i1であり、上記条件文の条件式が(y==0)の場合、上記作成される文は、例えば「if(y==0){i1=0;}else{i1=1;};」とすることができる。
 また、上記条件文が、例えば、3通り以上のパスに分岐させる条件文「
if(x==0){if(y==0){x++;y--;}else{c2++;}}else{c1++;}(c1及びc2はともにローカル変数)」の場合、上記作成される文は、例えば、「b=(x!==0)?1:(y!=0)?2:0;」とすることができる。ここで、変数bに代入される値は、副作用を持たないパスの中からどれを選ぶかを示す。上記例では、bが1の場合「c1++;」が実行されるパスが選択され、bが2の場合「c2++;」が実行されるパスが選択される文が作成される。
 次にコンピュータ・システムは、上記条件式にインスタンス変数が含まれる場合、上記第2の変数の宣言から、上記スタティック変数であることの宣言を削除する。例えばJava(商標)言語の場合、上記削除は、修飾子staticを削除することである。
 上記削除が終了することに応じて、該処理はステップ316に進む。
 ステップ316では、コンピュータ・システムは、上記cの第3の情報に対応するパスを、上記cの第2の情報で示されるCL上の同期ブロックの開始位置の直前に複製する。次に、コンピュータ・システムは、上記第2の変数の値が成立値の場合に上記追加された実行パスからの処理を開始させ、一方上記第2の変数の値が不成立値の場合に上記同期ブロックからの処理を開始させる条件文をCL上に追加する。なお、上記条件文の終端は、値が成立値の場合及び値が不成立値の場合ともに、上記cの第2の情報で示されるCL上の同期ブロックの終了位置の直後になるようにする。
 上記条件文の追加が終了することに応じて、該処理はステップ317に進む。
 ステップ317では、コンピュータ・システムは、上記cの第3の情報に対応する実行パスと関係する同期ブロックについての処理を実行する。該処理については、下記図5で詳しく述べる。なお、上記同期ブロックについての処理では、CLに新たな文が追加されうる。また、上記同期ブロックについての処理では、ステップ314及び316でCLに追加された文が削除されうる。上記同期ブロックについての処理が終了することに応じて、該処理はステップ318に進む。
 ステップ318は、集合変数Cについての繰り返しの終了を表す。
 全てのcが取り出し済みの場合、該処理はステップ319に進む。取り出していないcがある場合、該処理はステップ311に戻る。
 ステップ319では、コンピュータ・システムは、第2の変数について、上記第2の変数を宣言する文と、上記第2の変数に対応する上記ステップ314及び316でCLに追加された文又は上記第2の変数に対応する同期ブロックの文であって最も早く実行される文との間に、上記第2の変数に初期値を設定する文を追加する。上記初期値を設定する文は、ステップ315で生成された文である。ここで、上記初期値は、上記不成立値であってもよい。なお、上記文の追加は、定義された全ての第2の変数について実行される。
 上記追加が終了することに応じて、該処理はステップ320に進む。
 ステップ320は、上記変換する処理の終了である。
 図5は、本発明の実施態様における、図4に記載のステップ317の処理の詳細を示す。
 ステップ321は、ステップ317の処理の開始を示す。
 ステップ322では、コンピュータ・システムは、集合変数Sからメソッドについての情報(s)を1件取り出す。該取り出しが終了することに応じて、該処理はステップ323に進む。
 ステップ323では、コンピュータ・システムは、上記cの第1の情報であるロックオブジェクトと、上記sの第1の情報であるロックオブジェクトが同じかどうかを判定する。同じである場合、該処理はステップ324に進む。同じでない場合、該処理はステップ329に進む。
 ステップ324では、コンピュータ・システムは、上記sの第3の情報で表される同期ブロックに、ステップ315で作成された文に含まれる変数を更新させる文が含まれるかどうかを判定する。上記更新させる文が含まれる場合、該処理はステップ325に進む。上記更新させる文が含まれない場合、該処理はステップ329に進む。
 ステップ325では、コンピュータ・システムは、上記sの第3の情報で表される同期ブロックに、上記cの第1の情報であるロックオブジェクトを使用してロックを取得するスレッドを起動する文が含まれるかどうかを判定する。概判定は、コンピュータ・システムが、上記同期ブロックを精査することで実行される。なお、上記精査において、上記ロックオブジェクトを、上記同期ブロック内で使用させる文(以下、第1の文)が見つかる場合がある。上記第1の文は、例えば、上記ロックオブジェクトを引数とするメソッドである。上記第1の文が見つかった場合、コンピュータ・システムは、例えば、上記別のCLを精査して、上記第1の文によって実行される実行パスを求める。コンピュータ・システムは、上記求められた実行パスを精査することで、上記スレッドを起動する文を見つけうる。
 上記精査により、上記スレッドを起動する文が見つからなかった場合、該処理はステップ326に進む。見つかった場合、該処理はステップ328に進む。
 ここで、例えば、上記別のCLが入力データとして与えられていない又は、上記別のCLがバイナリデータとして提供されているためにソースコードの記載が不明であるという理由により、上記精査が実行できない場合がある。上記精査が実行できない場合、コンピュータ・システムは、上記スレッドを起動する文が、上記cの第3の情報に対応する実行パスに含まれると判定してもよい。また、コンピュータ・システムは、例えば、モニタに上記スレッドを起動する文が含まれるかどうかを入力させるメッセージを表示して、ユーザに上記判定をさせてもよい。
 ステップ326では、コンピュータ・システムは、上記sの第3の情報に対応する同期ブロック内で定義されている変数が、上記同期ブロック外で参照され且つスレッド間の実行順序付けに使用されているかを判定する。概判定は、コンピュータ・システムが、上記プログラム・コードを精査することで実行される。上記精査により、上記変数が見つからなかった場合、該処理はステップ327に進む。見つかった場合、該処理はステップ328に進む。
 ここで、例えば、上記別のCLが入力データとして与えられていない、又は、上記別のCLがバイナリデータとして提供されているためにソースコードの記載が不明であるという理由により、上記精査が実行できない場合がある。上記精査が実行できない場合、コンピュータ・システムは、上記変数が、上記cの第3の情報に対応する実行パスに含まれると判定してもよい。また、コンピュータ・システムは、例えば、モニタに上記変数が含まれるかどうかを入力させるメッセージを表示して、ユーザに上記判定をさせてもよい。
 ステップ327では、コンピュータ・システムは、ステップ315において作成した文を、CLに追加する。ここで、第2の変数が、変数の最適化を抑止することが指定されている変数である場合、上記追加は、sに対応する同期ブロックについて実行される。また、上記追加されるCL上の位置は、上記sに対応する同期ブロックから抜けるための文の直前である。
 第2の変数が、変数の最適化を抑止することが指定されていない変数である場合、上記追加されるCL上の位置は、上記ステップ324で見つかった上記更新させる文の後であって、上記sに対応する同期ブロックを抜ける処理の前である。
 上記追加が終了することに応じて、該処理はステップ329に進む。
 ステップ328では、コンピュータ・システムは、ステップ314及び316において、CLに追加された文を削除する。
 上記削除が終了することに応じて、ステップ322についての繰り返しは終了し、該処理はステップ330に進む。
 ステップ329は、集合変数Sについての繰り返しの終了を表す。
 全てのsが取り出し済みの場合、コンピュータ・システムは、変数iをインクリメントする。該インクリメントが終了することに応じて、該処理はステップ330に進む。取り出していないsがある場合、該処理はステップ322に戻る。
 ステップ330は、ステップ317の処理の終了を示す。
 図3~図5の各ステップの動作の具体的な例を下記図6~図8及び図9~図11に示す。
 図6は、本発明の実施態様における、図3~図5に記載の各ステップの動作を具体的に説明するために使用する入力データCLを示す。
 なお、図6~図8で示される例は、ステップ325及びステップ326において、ユーザに問い合わせを行う場合を示す。
 コンピュータ・プログラムは、入力データ(401)を入力CLとして、変換プログラムを起動する。
 ステップ302では、コンピュータ・システムは、変数に以下の値を設定する。
 集合変数M = {void enqueue(W w) public W dequeue()}
 変数i = 1
 集合変数S= {φ}
 集合変数C = {φ}
 上記設定が終了することに応じて、該処理はステップ303に進む。
 ステップ303~ステップ305の繰り返しでは、コンピュータ・システムは、m=“boolean enqueue(W w)”及びm=“public W dequeue()”それぞれについて、ステップ304を実行する。該実行により、集合変数Sには、
 S = {
  <w、(S01,S08)、(S02,S03,S04,S05,S06,S07)>(以下、s1),
  <lock、(S03,S07)、(S04,S05,S06)> (以下、s2),
  <lock、(T01,T09)、(T02,T03,T04,T05,T06,T07,T08)>(以下、s3)
 }
 が保存される。
 上記保存が終了することに応じて、該処理はステップ306に進む。
 ステップ306~ステップ310の繰り返しでは、コンピュータ・システムは、上記集合変数Sに含まれるs1~s3それぞれについて、ステップ307~ステップ309を実行する。該実行の結果、集合変数Cには、
 C = {
  <lock、(T01,T09)、(T02,T07,T08)>(以下、c)
 }
 が保存される。
 ここで、S03行目を含むパスには、同期という副作用がある。また、S04行目及びT05行目を含むパスには、インスタンス変数への代入という副作用が存在する。よって、S03行目、S04行目及びT05行目を含むパスは、ステップ307の条件を満たさない。従って、S03行目、S04行目及びT05行目を含むパスは、ステップ309において、集合変数Cに保存されることはない。また、例えば、S02行目では、wというメソッドの引数から渡されるローカル変数が参照されている。よって、S02行目は、ステップ308の条件を満たさない。従って、S02行目は、ステップ309において、集合変数Cに保存されることはない。 次に、該処理はステップ311に進む。
 ステップ311~ステップ318の繰り返しでは、コンピュータ・システムは、上記集合変数Cに含まれるcについて、ステップ312~317を実行する。
 ステップ312及びステップ313では、上記cについての判定が実行される。ここで、cに含まれる“lock”は、privateで宣言された変数であり、CL外からは参照されない変数である。よって、cはステップ312及びステップ313の条件を満たすので、該処理はステップ314に進む。
 ステップ314では、コンピュータ・システムは、変数を宣言する文をCLに追加する。ここで、共有変数headは、s1内でのみアクセスされる。よって、コンピュータ・システムは、インスタンス変数の宣言“private static boolean b1”をCLに追加する。
 ステップ315では、コンピュータ・システムは、T02行目の条件文(head != null)を用いて、“b1 = (head != null)”という文を生成する。また、headはインスタンス変数であるので、コンピュータ・システムは、ステップ314で追加された宣言“private static boolean b1”から、“static”を取り除く。
 ステップ316では、コンピュータ・システムは、T02行目、T07行目及びT08行目をT01行目の前に生成する。また、コンピュータ・システムは、cに含まれる条件文を“(b1)”で置き換える。コンピュータ・システムは、T02行目のthen節が副作用を持つパスへの分岐であるので、上記then節を同期ブロックへのコードに繋がるようにする。
 図7は、本発明の実施態様における、図4に記載のステップ316の処理が実行された後のメソッドdequeue()を示す。
 ステップ316の処理によって、CLのメソッドdequeue()には、文(412)が追加されている。
 上記ステップ316において、上記追加が実行されることに応じて、該処理はステップ317に進む。
 ステップ317では、コンピュータ・システムは、ステップ322~ステップ329の繰り返しを実行する。
 ステップ322~ステップ329の繰り返しでは、コンピュータ・システムは、上記集合変数Sに含まれるs1~s3それぞれについて、ステップ323~ステップ328を実行する。
 ステップ322の条件を満たすs1~s3は、
 <lock、(S03,S07)、(S04,S05,S06)>(s2)及び
 <lock、(T01,T09)、(T02,T03,T04,T05,T06,T07,T08)>(s3)である。
 ステップ323では、コンピュータ・システムは、上記ステップ322の条件を満たすs2又はs3に関するパスに、b0の代入文の右辺で参照される変数への代入が1つでもあるかを調べる。s2又はs3においては、headへの代入をする処理が検索される。上記検索の結果、s2又はs3は、ステップ323の条件を満たす。
 ステップ324では、コンピュータ・システムは、上記s2又はs3で表される同期ブロックについて、新たなスレッドが生成されて、生成されたスレッドが、上記s2又はs3で表される同期ブロックと同じロックオブジェクトを獲得しようとしていないかどうかをチェックする。該チェックにより、s2で表される同期ブロックのS06行目に、LOを引数としてメソッドbar(lock)を呼び出す処理が含まれていることが発見される。
 ここで、入力がCLのみの場合、上記メソッドbar(lock)を実装するプログラムのプログラム・コードは不明である。よって、コンピュータ・システムは、ユーザに上記獲得しようとしていないかどうかを判定させる。コンピュータ・システムは、例えばモニタに「foo.bar(lock)は、スレッドを起動してlockに関してsynchronized block又はsynchronized methodを呼んでいますか?」と表示し、ユーザに対して問い合わせを行う。ユーザが「N」と答えた場合、該処理はステップ326に進み、ユーザが「Y」と答えた場合、該処理はステップ328に進む。
 ステップ326では、コンピュータ・システムは、s2又はs3で表される同期ブロック内で定義された変数が、同期ブロック外で参照され且つ少なくとも2のスレッド間の実行順序を決定するために用いられていないかをチェックする。ここで、S06行目の共有変数lockは、foo.bar(lock)からエスケープして他のスレッドからアクセスされる可能性がある。よって、コンピュータ・システムは、例えばモニタに「lockは他のスレッドと実行順序を決定するために用いられますか?」と表示し、ユーザに対して問い合わせを行う。ユーザが「N」と答えた場合、該処理はステップ327に進み、ユーザが「Yと答えた場合、該処理はステップ328に進み、上記繰り返しを抜ける。
 ステップ327では、コンピュータ・システムは、ステップ315において生成された文“b1 = (head != null)”を追加する位置を決定する。なお、b1はvolatile宣言がされていないため、コンピュータ・システムは、上記生成された文をheadを更新させる文より後ろに追加する。該追加する場所は、例えば、s2については、S06行目の後に、s3については、T06行目の前とT08行目の前である。
 上記ステップ322~ステップ329の繰り返しが終了することに応じて、該処理はステップ319に進む。
 ステップ319では、コンピュータ・システムは、ステップ314において追加された宣言に“b1 = (head != null);”を追加する。
 上記追加されることに応じて、該処理は終了する。
 図8は、本発明の実施態様における、図6について、図3~図5に記載のステップの処理が実行された後の入力データ(以下、変換後のプログラム・コード(421))を示す。
 図3~図5のステップの処理によって、変換後のプログラム・コード(421)には、文(422)が追加されている。
 変換後のプログラム・コード(421)は、headがnullの場合、b1はfalseとなる。よって、変換後のプログラム・コード(421)が実行され、headがnullのときにdequeue()メソッドが呼び出されると、該処理は同期ブロックに突入することなくnullを返す。従って、ロック衝突の問題が解決されている。
 図9は、本発明の実施態様における、図3~図5に記載の各ステップの動作を具体的に説明するために使用する入力データCLを示す。
 なお、図9~図11で示される例は、上記CLの他に別のCL(図示せず)が存在し、ステップ325及びステップ326において、ユーザに問い合わせを行わない場合の例である。
 コンピュータ・プログラムは、入力データ(501)を入力CLとして、変換プログラムを起動する。
 ステップ302では、コンピュータ・システムは、変数に以下の値を設定する。
 集合変数M = {boolean enqueue(W w) public W dequeue()}
 変数i = 1
 集合変数S= {φ}
 集合変数C = {φ}
 上記設定が終了することに応じて、該処理はステップ303に進む。
 ステップ303~ステップ305の繰り返しでは、コンピュータ・システムは、m=“boolean enqueue(W w)”及びm=“public W dequeue()”それぞれについて、ステップ304を実行する。該実行により、集合変数Sには、
 S = {
  <w、(S01,S08)、(S02,S03,S04,S05,S06,S07)>(以下、s1),
  <lock、(S03,S07)、(S04,S05,S06)> (以下、s2),
  <lock、(T01,T09)、(T02,T03,T04,T05,T06,T07,T08)>(以下、s3)
 }
 が保存される。
 上記設定が終了することに応じて、該処理はステップ306に進む。
 ステップ306~ステップ310の繰り返しでは、コンピュータ・システムは、上記集合変数Sに含まれるs1~s3それぞれについて、ステップ307~ステップ309を実行する。該実行の結果、集合変数Cには、
 C = {
  <lock, (T01, T09), (T02, T07, T08)>(以下、c)
 }
 が保存される。
 ここで、S03行目を含むパスには、同期という副作用がある。また、S04行目及びT05行目を含むパスには、インスタンス変数への代入という副作用が存在する。よって、S03行目、S04行目及びT05行目を含むパスは、ステップ307の条件を満たさない。従って、S03行目、S04行目及びT05行目を含むパスは、ステップ309において、集合変数Cに保存されることはない。また、例えば、S02行目では、wというメソッドの引数から渡されるローカル変数が参照されている。よって、S02行目は、ステップ308の条件を満たさない。従って、S02行目は、ステップ309において、集合変数Cに保存されることはない。 次に、該処理はステップ311に進む。
 ステップ311~ステップ318の繰り返しでは、コンピュータ・システムは、上記集合変数Cに含まれるcについて、ステップ312~317を実行する。
 ステップ312及びステップ313では、上記cについての判定が実行される。ここで、cに含まれる“lock”は、privateで宣言された変数であり、CL外からは参照されない変数である。よって、cはステップ312及びステップ313の条件を満たすので、該処理はステップ314に進む。
 ステップ314では、コンピュータ・システムは、変数を宣言する文をCLに追加する。ここで、共有変数headは、s1内でのみアクセスされる。よって、コンピュータ・システムは、インスタンス変数の宣言“private static boolean b1”をCLに追加する。
 ステップ315では、コンピュータ・システムは、T02行目の条件文(head != null)を用いて、“b1 = (head != null)”という文を生成する。また、headはインスタンス変数であるので、コンピュータ・システムは、ステップ314で追加された宣言“private static boolean b1”から、“static”を取り除く。
 ステップ316では、コンピュータ・システムは、T02行目、T07行目及びT08行目をT01行目の前に生成する。また、コンピュータ・システムは、cに含まれる条件文を“(b1)”で置き換える。コンピュータ・システムは、T02行目のthen節が副作用を持つパスへの分岐であるので、上記then節を同期ブロックへのコードに繋がるようにする。
 図10は、本発明の実施態様における、図4に記載のステップ316の処理が実行された後のメソッドdequeue()を示す。
 ステップ316の処理によって、CLのメソッドdequeue()には、文(512)が追加されている。
 上記ステップ316において、上記追加が実行されることに応じて、該処理はステップ317に進む。
 ステップ317では、コンピュータ・システムは、ステップ322~ステップ329の繰り返しを実行する。
 ステップ322~ステップ329の繰り返しでは、コンピュータ・システムは、上記集合変数Sに含まれるs1~s3それぞれについて、ステップ323~ステップ328を実行する。
 ステップ322の条件を満たすs1~s3は、
 <lock、(S03,S07)、(S04,S05,S06)>(s2)及び
 <lock、(T01,T09)、(T02,T03,T04,T05,T06,T07,T08)>(s3)である。
 ステップ323では、コンピュータ・システムは、上記ステップ322の条件を満たすs2又はs3に関するパスに、b0の代入文の右辺で参照される変数への代入が1つでもあるかを調べる。s2又はs3において、headへの代入をする処理が検索される。上記検索の結果、s2又はs3は、ステップ323の条件を満たす。
 ステップ324では、コンピュータ・システムは、上記s2又はs3で表される同期ブロックについて、新たなスレッドが生成され、該生成されたスレッドが、上記s2又はs3で表される同期ブロックと同じロックオブジェクトを獲得しようとしていないかどうかをチェックする。上記s2又はs3で表される同期ブロックには、新たなスレッドを生成する文は含まれない。よって、コンピュータ・システムは、該チェックにおいて、上記s2又はs3で表される同期ブロックと同じロックオブジェクトを獲得しようとしていないと判断する。該獲得しようとしていないことに応じて、該処理はステップ326に進む。
 ステップ326では、コンピュータ・システムは、s2又はs3で表される同期ブロック内で定義された変数が、同期ブロック外で参照され且つ少なくとも2のスレッド間の実行順序を決定するために用いられていないかをチェックする。ここで、共有変数lockは、private宣言されているためにCL外からはアクセスされない。また、共有変数lockは、CL内では、同期ブロック内でのみアクセスされる。よって、コンピュータ・システムは、該チェックにおいて、共有変数lockは実行順序を決定するために用いられていないと判断する。該用いられていないことに応じて、該処理はステップ327に進む。
 ステップ327では、コンピュータ・システムは、ステップ315において生成された文“b1 = (head != null)”を追加する位置を決定する。なお、b1はvolatile宣言がされていないため、コンピュータ・システムは、上記生成された文をheadを更新させる文より後ろに追加する。該追加する場所は、例えば、s2については、S06行目の前に、s3については、T06行目の前とT08行目の前である。
 上記ステップ322~ステップ329の繰り返しが終了することに応じて、該処理はステップ319に進む。
 ステップ319では、コンピュータ・システムは、ステップ314において追加された宣言に“b1 = (head != null);”を追加する。
 上記追加されることに応じて、該処理は終了する。
 図11は、本発明の実施態様における、図9について、図3~図5に記載の各ステップの処理が実行された後の入力データ(以下、変換後のプログラム・コード(521))を示す。
 図3~図5のステップの処理によって、変換後のプログラム・コード(521)には、文(522)が追加されている。
 変換後のプログラム・コード(521)は、headがnullの場合、b1はfalseとなる。よって、変換後のプログラム・コード(401)が実行され、headがnullのときにdequeue()メソッドが呼び出されると、該処理は同期ブロックに突入することなくnullを返す。従って、ロック衝突の問題が解決されている。
 図12は、本発明の実施態様における、第1の条件式によって選択されるパスが3通り以上である場合の、図3~図5に記載の各ステップの処理が実行される前のプログラム・コードの一部及び実行された後のプログラム・コードの一部を示す。
 プログラム・コード(601)の同期ブロックは、2つの第1の条件式「(x==0)」及び「(y==0)」を含む。また、上記2つの第1の条件式により、3通りのパス(602~604)が選択される。ここで、c1及びc2がローカル変数の場合、パス(603)及びパス(604)は、副作用のないパスである。なお、パス(602)は、第1の変数に対応するx及びyの2つの変数を更新させる文を含むため、副作用のあるパスである。
 プログラム・コード(611)は、プログラム・コード(601)に対して、図3~図5に記載の各ステップの処理が実行された結果を示す。
 プログラム・コード(611)には、プログラム・コード(601)の同期ブロックに、第2の変数を宣言する宣言文(612)、第2の条件文(613)及びステップ315で作成される文(614)が追加されている。
 上記各ステップの処理において、第2の変数には、副作用のないパス(603及び604)の中からどのパスを選ぶかを示す値をとることができる変数が用意される。よって、プログラム・コード(611)には、パス(603)を選ぶ値として2を、パス(604)を示す値として1を取ることができる変数bを宣言する宣言文(612)が追加されている。さらに、プログラム・コード(611)には、上記第2の変数に応じて副作用のないパス(603及び604)を実行させる条件文として、第2の条件文(613)が追加されている。
 プログラム・コード(611)にはまた、第1の変数であるx及びyを更新させる更新文の直後に、変数bの値を求める文であるステップ315で作成される文(614)が追加されている。
 本発明の実施態様によれば、図3~図5の各ステップを実行することによって、java.lang.ref.ReferenceQueueにおけるロック衝突の問題が解決可能である。
 図13は、本発明の実施態様における、図1のシステムが有するコンピュータ・ハードウェアのブロック図を示す。
 本発明の実施形態に係るコンピュータ・システム(701)は、CPU(702)とメイン・メモリ(703)と含み、これらはバス(704)に接続されている。CPU(702)は好ましくは、32ビット又は64ビットのアーキテクチャに基づくものであり、例えば、インテル社のXeon(商標)シリーズ、Core(商標)シリーズ、Atom(商標)シリーズ、Pentium(商標)シリーズ、Celeron(商標)シリーズ、AMD社のPhenom(商標)シリーズ、Athlon(商標)シリーズ、Turion(商標)シリーズ又はSempron(商標)などを使用することができる。バス(704)には、ディスプレイ・コントローラ(705)を介して、LCDモニタなどのディスプレイ(706)が接続されている。ディスプレイ(706)は、コンピュータ・システムの管理のために、通信回線を介してネットワークに接続されたコンピュータ・システムについての情報と、そのコンピュータ・システム上で動作中のソフトウェアについての情報を、適当なグラフィック・インターフェースで表示するために使用される。バス(704)にはまた、IDE又はSATAコントローラ(707)を介して、ハードディスク又はシリコン・ディスク(708)と、CD-ROM、DVDドライブ又はBlu-rayドライブ(709)が接続されている。
 ハードディスク(708)には、オペレーティング・システム、J2EEなどのJava(商標)処理環境を提供するプログラム、その他のプログラム及びデータが、メイン・メモリ(703)にロード可能なように記憶されている。
 CD-ROM、DVD又はBlu-rayドライブ(709)は、必要に応じて、CD-ROM、DVD-ROM又はBlu-rayディスクからプログラムをハードディスクに追加導入するために使用される。バス(704)には更に、キーボード・マウスコントローラ(710)を介して、キーボード(711)及びマウス(712)が接続されている。
 通信インタフェース(714)は、例えばイーサネット(商標)・プロトコルに従う。通信インタフェース(714)は、通信コントローラ(713)を介してバス(704)に接続され、コンピュータ・システム及び通信回線(715)を物理的に接続する役割を担い、コンピュータ・システムのオペレーティング・システムの通信機能のTCP/IP通信プロトコルに対して、ネットワーク・インターフェース層を提供する。なお、通信回線は、有線LAN環境、或いは例えばIEEE802.11a/b/g/nなどの無線LAN接続規格に基づく無線LAN環境であってもよい。

Claims (21)

  1.  マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換する方法であって、
     前記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索するステップであって、前記副作用がないとは前記同期ブロック内の文による処理中の値が前記同期ブロック外の文によって参照できないことである、前記検索するステップと、
     前記同期ブロック外に、前記検索された第1の条件文によって分岐される副作用のないパスを複製するステップと、
     前記複製に応じて、前記プログラム・コード内に第2の条件文を追加するステップであって、前記第2の条件文は前記複製された副作用のないパスへ分岐させる条件文である、前記追加するステップと
     を含む、前記方法。
  2.  前記第1の条件文が第1の条件式を含み、該第1の条件式は、第1の変数の読み出し、定数又はそれらの組み合わせに基づいてパスを選択させるように定義されており、前記第1の変数は、前記第1の条件文を含むサブルーチンを呼び出すルーチンの中だけが有効範囲である変数ではない、請求項1に記載の方法。
  3.  前記第2の条件文が、前記第1の条件式の結果を格納するための変数に基づいて、前記第1の条件式の結果に応じてパスを選択させる第2の条件式を含む、請求項2に記載の方法。
  4.  前記検索するステップが、前記読み出したプログラム・コードから、更新文をさらに検索するステップを含み、前記更新文は、前記同期ブロック内にあり且つ前記第1の変数を更新させ、
     前記追加するステップが、前記検索された更新文の直後から前記同期ブロックの終了文までの間に、前記第1の条件式の結果を格納するための変数と、該変数に代入される前記第1の条件式の結果とを含む文をさらに追加するステップを含む、
     請求項3に記載の方法。
  5.  前記検索するステップが、前記読み出したプログラム・コード及び他のプログラム・コードの少なくとも1つから、更新文をさらに検索するステップを含み、前記更新文は、前記同期ブロックと同期する他の同期ブロック内にあり且つ前記第1の変数を更新させ、
     前記追加するステップが、前記検索された更新文の直後から前記他の同期ブロックの終了文までの間に、前記第1の条件式の結果を格納するための変数と、該同じ変数に代入される前記第1の条件式の結果とを含む文をさらに追加するステップを含む、
     請求項3に記載の方法。
  6.  前記追加するステップが、前記第1の条件式の結果を格納するための変数が初めて参照される文より前に、前記第2の条件文が前記同期ブロックを含むパスを実行させる値を用いて又は前記第1の条件式の結果を用いて前記第1の条件式の結果を格納するための変数を初期化する文をさらに追加するステップを含む、請求項3に記載の方法。
  7.  前記第1の条件式の数が2以上である場合、該2以上の第1の条件式の結果が、前記2以上の第1の条件式の組み合わせで求められる、請求項2に記載の方法。
  8.  前記第1の条件式によって選択されるパスの数が3通り以上である場合、
      前記第1の条件式の結果を格納するための変数が、前記3通り以上のパスのうち副作用のないパスそれぞれに対応する、請求項3に記載の方法。
  9.  前記第1の条件式の結果を格納するための変数が、原子性が保証されたデータ型の変数である、請求項3に記載の方法。
  10.  前記検索するステップが、前記プログラム・コード及び他のプログラム・コードの少なくとも1つから、前記同期ブロックと同期する他の同期ブロックをさらに検索するステップを含み、
     前記検索の終了に応じて、前記複製するステップを実行する、請求項1に記載の方法。
  11.  前記検索するステップが、前記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ前記同期ブロック外の文から前記第1の変数を参照する文をさらに検索するステップを含み、
     前記検索の終了に応じて、前記複製するステップを実行する、請求項2に記載の方法。
  12.  前記同期ブロック内にスレッドを起動させる文が含まれる場合、
     前記検索するステップが、前記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ前記スレッドの実装を記載する文から、前記同期ブロック内の文と同期をとって実行される文をさらに検索するステップを含み、
     前記同期をとって実行される文が検索されることに応じて、前記スレッドを起動させる文を含むパスを副作用のあるパスと判定するステップ
     をさらに含む、請求項1に記載の方法。
  13.  前記同期ブロック内にスレッドを起動させる文が含まれる場合、
     前記検索するステップが、前記スレッドを起動させる文を含むパスが副作用のないパスかどうかをユーザに判断することを求めるステップをさらに含む、
     請求項1記載の方法。
  14.  前記同期ブロックが実行されるスレッドの実行順序を決定するために使用される変数が前記同期ブロック内に定義されている場合、
     前記検索するステップが、前記プログラム・コード及び他のプログラム・コードの少なくとも1つに含まれており且つ前記使用される変数を参照する文を前記同期ブロック外からさらに検索するステップを含み、
     前記使用される変数を参照する文が検索されることに応じて、前記使用される変数を含むパスを副作用のあるパスと判定するステップをさらに含む、
     請求項1に記載の方法。
  15.  前記同期ブロックが実行されるスレッドの実行順序を決定するために使用される変数が前記同期ブロック内に定義されている場合、
     前記検索するステップが、前記使用される変数を含むパスが副作用のないパスかどうかをユーザに判断することを求めるステップをさらに含む、
     請求項1に記載の方法。
  16.  前記追加するステップが、前記読み出したプログラム・コードに、前記第1の条件式の結果を格納するための変数を宣言する文をさらに追加するステップを含み、
     共有変数が前記プログラム・コード及び前記他のプログラム・コードの少なくとも1つに含まれており且つ前記同期ブロック外の文からアクセスされる場合に、前記宣言がメモリのアクセス順序に関する最適化を抑止することの指定及び原子性を保証することの指定を含み、前記共有変数は前記副作用のないパスに含まれており、且つ複数のスレッドからアクセスされることができ、
     上記アクセスされない場合に、前記宣言が原子性を保証することの指定を含む、
     請求項3に記載の方法。
  17.  前記検索するステップが、前記同期ブロックと同期する他の同期ブロックがあるかどうかをユーザに判断させることを許すステップをさらに含み、
     該許すステップの後に、前記複製するステップを実行する、請求項1に記載の方法。
  18.  前記検索するステップが、前記第1の変数を参照する文があるかどうかをユーザに判断させることを許すステップをさらに含み、
     該許すステップの後に、前記複製するステップを実行する、請求項2に記載の方法。
  19.  マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するコンピュータ・システムであって、
     前記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索する検索部であって、前記副作用がないとは前記同期ブロック内の文による処理中の値が前記同期ブロック外の文によって参照できないことである、前記検索部と、
     前記同期ブロック外に、前記検索された第1の条件文によって分岐される副作用のないパスを複製する複製部と、
     前記複製に応じて、前記プログラム・コード内に第2の条件文を追加する追加部であって、前記第2の条件文は前記複製された副作用のないパスへ分岐させる条件文である、前記追加部と
     を含む、前記コンピュータ・システム。
  20.  マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換する方法であって、
     前記プログラム・コードをメモリ内に読み出し、該読み出したプログラム・コードから、同期ブロック内にあり且つ該同期ブロックに対する副作用がないパスへ分岐させる第1の条件文を検索するステップであって、前記副作用がないとは前記同期ブロック内の文による処理中の値が前記同期ブロック外の文によって参照できないことである、前記検索するステップと、
     前記同期ブロック外に、前記検索された第1の条件文によって分岐される副作用のないパスを複製するステップと、
     前記複製に応じて、前記プログラム・コード内に第2の条件文を追加するステップであって、前記第2の条件文は前記複製された副作用のないパスへ分岐させる条件文である、前記追加するステップと
     を含み、
     前記第1の条件文が第1の条件式を含み、該第1の条件式は、インスタンス変数若しくはクラス変数の読み出し、定数又はそれらの組み合わせに基づいて、副作用のないパスに分岐させる場合にその結果がtrueとなるように定義されており、一方副作用のあるパスに分岐させる場合にその結果がfalseとなるように定義されており、
     前記第2の条件文が第2の条件式を含み、該第2の条件式は、前記第1の条件式の結果を格納するためのboolean型の変数に基づいて、前記第1の条件式の結果に応じてパスを選択させるように定義されている、前記方法。
  21.  コンピュータ・システムに、請求項1~18のいずれか1項に記載の方法の各ステップを実行させるコンピュータ・プログラム。
PCT/JP2010/057122 2009-04-28 2010-04-22 マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム WO2010125960A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
CN201080005431.7A CN102292709B (zh) 2009-04-28 2010-04-22 用于变换在多线程上工作的程序的程序代码的方法和系统
JP2011511377A JP5204300B2 (ja) 2009-04-28 2010-04-22 マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム
KR1020117027092A KR20120058455A (ko) 2009-04-28 2010-04-22 멀티 스레드 상에서 동작하는 프로그램의 프로그램 코드를 록 충돌이 적은 프로그램 코드로 변환하기 위한 방법, 및 그 컴퓨터 프로그램 및 컴퓨터 시스템

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2009109937 2009-04-28
JP2009-109937 2009-04-28

Publications (1)

Publication Number Publication Date
WO2010125960A1 true WO2010125960A1 (ja) 2010-11-04

Family

ID=42993248

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2010/057122 WO2010125960A1 (ja) 2009-04-28 2010-04-22 マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム

Country Status (5)

Country Link
US (1) US8972959B2 (ja)
JP (1) JP5204300B2 (ja)
KR (1) KR20120058455A (ja)
CN (1) CN102292709B (ja)
WO (1) WO2010125960A1 (ja)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8239843B2 (en) * 2008-03-11 2012-08-07 Oracle America, Inc. Value predictable variable scoping for speculative automatic parallelization with transactional memory
US8612407B1 (en) 2012-07-18 2013-12-17 International Business Machines Corporation Source control inheritance locking
EP2731008B1 (en) * 2012-11-12 2020-03-18 Fujitsu Limited Resource contention in multiple cores
JP6004110B2 (ja) * 2013-07-19 2016-10-05 日産自動車株式会社 ソフトウェア検査装置、ソフトウェア検査方法、ソフトウェア検査プログラム
CN105431817B (zh) * 2013-08-01 2019-01-04 石田伸一 源程序比较装置以及存储装置
US9250877B2 (en) * 2013-09-20 2016-02-02 Cray Inc. Assisting parallelization of a computer program
CA2831134A1 (en) * 2013-10-24 2015-04-24 Ibm Canada Limited - Ibm Canada Limitee Identification of code synchronization points
GB201405754D0 (en) * 2014-03-31 2014-05-14 Irdeto Bv Protecting an item of software comprising conditional code
JP6366033B2 (ja) * 2014-05-09 2018-08-01 インターナショナル・ビジネス・マシーンズ・コーポレーションInternational Business Machines Corporation プログラム中のif文の最適化方法
US9582312B1 (en) 2015-02-04 2017-02-28 Amazon Technologies, Inc. Execution context trace for asynchronous tasks
JP6969460B2 (ja) * 2018-03-15 2021-11-24 オムロン株式会社 プログラム開発支援システム、プログラム開発支援方法及びプログラム開発支援プログラム

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0475136A (ja) * 1990-07-17 1992-03-10 Sanyo Electric Co Ltd プログラム開発装置
JPH0566972A (ja) * 1991-09-06 1993-03-19 Nippon Telegr & Teleph Corp <Ntt> ロツク区間の自動解析方法と平均命令実行時間の計算方法
JPH11288367A (ja) * 1998-04-02 1999-10-19 Hitachi Ltd プログラム自動生成システムと方法
JP2000276343A (ja) * 1999-03-24 2000-10-06 Mitsubishi Electric Corp プログラム変更装置
JP2009032233A (ja) * 2007-06-28 2009-02-12 Sharp Corp 排他制御不具合候補抽出装置、排他制御不具合候補抽出方法、および排他制御不具合候補抽出プログラム

Family Cites Families (44)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5093916A (en) * 1988-05-20 1992-03-03 International Business Machines Corporation System for inserting constructs into compiled code, defining scoping of common blocks and dynamically binding common blocks to tasks
CA2109799A1 (en) * 1991-05-24 1992-12-10 Daniel Mark Nosenchuck Optimizing compiler for computers
US5450554A (en) * 1991-11-11 1995-09-12 Matsushita Electric Industrial Co., Ltd. Apparatus for detecting possibility of parallel processing and method thereof and a program translation apparatus utilized therein
JP2634144B2 (ja) * 1994-07-06 1997-07-23 インターナショナル・ビジネス・マシーンズ・コーポレイション プログラムの並列化実行方法及び並列化実行コンパイラ
US5875337A (en) * 1995-09-14 1999-02-23 Nec Corporation Modifier for a program executing parallel processes that reduces wait time for access to a shared resource
JP3006505B2 (ja) * 1995-09-14 2000-02-07 日本電気株式会社 並列プロセスを含むプログラムの修正装置、修正方法、および修正プログラムを記憶する記憶媒体
JP3305949B2 (ja) * 1996-02-08 2002-07-24 富士通株式会社 プログラム解析装置
JPH10328959A (ja) 1997-05-28 1998-12-15 Koike Sanso Kogyo Co Ltd 永電磁吸着装置
US5999739A (en) * 1997-05-29 1999-12-07 Hewlett-Packard Company Method and apparatus for elimination of redundant branch instructions from a program
JP4075136B2 (ja) 1998-06-01 2008-04-16 株式会社Sumco 単結晶育成装置
US6851109B1 (en) * 1999-05-06 2005-02-01 International Business Machines Corporation Process and system for dynamically compiling a partially interpreted method
US6530079B1 (en) * 1999-06-02 2003-03-04 International Business Machines Corporation Method for optimizing locks in computer programs
JP3756352B2 (ja) * 1999-06-29 2006-03-15 富士通株式会社 コンパイラ装置およびコンパイラを記録したコンピュータ読み取り可能な記録媒体
US6438747B1 (en) * 1999-08-20 2002-08-20 Hewlett-Packard Company Programmatic iteration scheduling for parallel processors
US6374403B1 (en) * 1999-08-20 2002-04-16 Hewlett-Packard Company Programmatic method for reducing cost of control in parallel processes
JP2001103836A (ja) 1999-10-08 2001-04-17 Misawa Homes Co Ltd 植物育成用マットおよび人工地盤の緑化方法
US6496975B1 (en) * 1999-10-15 2002-12-17 International Business Machines Corporation Method, system, and program for performing conditional program operations
US6748589B1 (en) * 1999-10-20 2004-06-08 Transmeta Corporation Method for increasing the speed of speculative execution
US6564354B1 (en) * 2000-06-01 2003-05-13 Hewlett Packard Development Company, L.P. Method for translating conditional expressions from a non-verilog hardware description language to verilog hardware description language while preserving structure suitable for logic synthesis
US6553362B2 (en) * 2000-07-14 2003-04-22 Hewlett-Packard Development Company, L.P. Case-reduced verification condition generation system and method using weakest precondition operator expressed using strongest postcondition operators
US7343594B1 (en) * 2000-08-07 2008-03-11 Altera Corporation Software-to-hardware compiler with symbol set inference analysis
JP3664478B2 (ja) * 2001-03-29 2005-06-29 インターナショナル・ビジネス・マシーンズ・コーポレーション コンパイラ、変換プログラム、例外処理プログラム及びこれらを用いたコンピュータ装置
US6988266B2 (en) * 2001-05-08 2006-01-17 Sun Microsystems, Inc. Method of transforming variable loops into constant loops
KR20030042319A (ko) * 2001-11-22 2003-05-28 한국전자통신연구원 병렬 프로그램 수행중 경합 탐지를 위한 병렬 루프 변형방법
JP3790707B2 (ja) * 2002-01-17 2006-06-28 インターナショナル・ビジネス・マシーンズ・コーポレーション プログラム変換方法、これを用いたコンピュータ装置及びプログラム
CA2453776A1 (en) * 2003-12-19 2005-06-19 Ibm Canada Limited-Ibm Canada Limitee Compiler optimization
CA2453714A1 (en) * 2003-12-19 2005-06-19 Ibm Canada Limited - Ibm Canada Limitee Method, system and product for indentifying and executing locked read regions and locked write regions in programming languages that offer synchronization without explicit means to distinguish between such regions
US7644402B1 (en) * 2004-03-17 2010-01-05 Sun Microsystems, Inc. Method for sharing runtime representation of software components across component loaders
JP4129981B2 (ja) * 2004-04-02 2008-08-06 インターナショナル・ビジネス・マシーンズ・コーポレーション コンパイラ、コンパイラプログラム、記録媒体、制御方法、及び中央処理装置
US7784039B2 (en) * 2004-09-22 2010-08-24 Panasonic Corporation Compiler, compilation method, and compilation program
JP2006185232A (ja) * 2004-12-28 2006-07-13 Hitachi Ltd 複数のプログラムの実行方法、プログラム変換方法及びこれを用いたコンパイラプログラム
US7797690B2 (en) * 2005-03-15 2010-09-14 International Business Machines Corporation System, method and program product to optimize code during run time
US8473934B2 (en) * 2005-07-15 2013-06-25 Imec Method for mapping applications on a multiprocessor platform/system
EP1783604A3 (en) * 2005-11-07 2007-10-03 Slawomir Adam Janczewski Object-oriented, parallel language, method of programming and multi-processor computer
US8266609B2 (en) * 2005-12-07 2012-09-11 Microsoft Corporation Efficient placement of software transactional memory operations around procedure calls
US8146066B2 (en) * 2006-06-20 2012-03-27 Google Inc. Systems and methods for caching compute kernels for an application running on a parallel-processing computer system
JP2008059279A (ja) * 2006-08-31 2008-03-13 Internatl Business Mach Corp <Ibm> 文字列出力処理を最適化する技術
US8141054B2 (en) * 2007-08-08 2012-03-20 International Business Machines Corporation Dynamic detection of atomic-set-serializability violations
JP2010039536A (ja) * 2008-07-31 2010-02-18 Panasonic Corp プログラム変換装置、プログラム変換方法およびプログラム変換プログラム
US9672019B2 (en) * 2008-11-24 2017-06-06 Intel Corporation Systems, apparatuses, and methods for a hardware and software system to automatically decompose a program to multiple parallel threads
US8418154B2 (en) * 2009-02-10 2013-04-09 International Business Machines Corporation Fast vector masking algorithm for conditional data selection in SIMD architectures
JP2011013985A (ja) * 2009-07-02 2011-01-20 Internatl Business Mach Corp <Ibm> プログラム、装置、および方法
US8561046B2 (en) * 2009-09-14 2013-10-15 Oracle America, Inc. Pipelined parallelization with localized self-helper threading
JP5479942B2 (ja) * 2010-02-22 2014-04-23 インターナショナル・ビジネス・マシーンズ・コーポレーション 並列化方法、システム、及びプログラム

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0475136A (ja) * 1990-07-17 1992-03-10 Sanyo Electric Co Ltd プログラム開発装置
JPH0566972A (ja) * 1991-09-06 1993-03-19 Nippon Telegr & Teleph Corp <Ntt> ロツク区間の自動解析方法と平均命令実行時間の計算方法
JPH11288367A (ja) * 1998-04-02 1999-10-19 Hitachi Ltd プログラム自動生成システムと方法
JP2000276343A (ja) * 1999-03-24 2000-10-06 Mitsubishi Electric Corp プログラム変更装置
JP2009032233A (ja) * 2007-06-28 2009-02-12 Sharp Corp 排他制御不具合候補抽出装置、排他制御不具合候補抽出方法、および排他制御不具合候補抽出プログラム

Also Published As

Publication number Publication date
JP5204300B2 (ja) 2013-06-05
JPWO2010125960A1 (ja) 2012-10-25
US20100275190A1 (en) 2010-10-28
US8972959B2 (en) 2015-03-03
KR20120058455A (ko) 2012-06-07
CN102292709A (zh) 2011-12-21
CN102292709B (zh) 2014-05-21

Similar Documents

Publication Publication Date Title
JP5204300B2 (ja) マルチスレッド上で動作するプログラムのプログラム・コードをロック衝突が少ないプログラム・コードに変換するための方法、並びにそのコンピュータ・プログラム及びコンピュータ・システム
US8281012B2 (en) Managing parallel data processing jobs in grid environments
US7721286B2 (en) Preemptive multi-tasking with cooperative groups of tasks
US6052707A (en) Preemptive multi-tasking with cooperative groups of tasks
US9928059B1 (en) Automated deployment of a multi-version application in a network-based computing environment
US8112745B2 (en) Apparatus and method for capabilities verification and restriction of managed applications in an execution environment
JP2005235228A5 (ja)
TWI269225B (en) Method and system for performing global processor resource assignment in an assembler
US9542173B2 (en) Dependency handling for software extensions
JPH1040107A (ja) セキュリテ・インタープリタにおけるプライベート変数機能呼出しの走行時間最適化のためのシステム及び方法
US10360079B2 (en) Architecture and services supporting reconfigurable synchronization in a multiprocessing system
US8572584B2 (en) Converting program code of a multi-threaded program into program code causing less lock contentions
JP3664478B2 (ja) コンパイラ、変換プログラム、例外処理プログラム及びこれらを用いたコンピュータ装置
US20030074656A1 (en) Program execution apparatus and method, computer program for performing the program execution method, image forming system, and address solution method
US7770152B1 (en) Method and apparatus for coordinating state and execution context of interpreted languages
US9727381B2 (en) Image forming apparatus and resource management method
US20150178074A1 (en) Method, a system, and a non-transitory computer-readable medium for supporting application development
US7111288B2 (en) Method and system for minimizing the cycle time when compiling a program in a processing system
US20210303339A1 (en) Data backup method, electronic device and computer program product
US20070083860A1 (en) SKU determination mechanism and API
JP4925514B2 (ja) 内外イベントドリブン方式によるプログラム実行制御方法、プログラム、実行制御装置および記録媒体
US7055144B2 (en) Method and system for optimizing the use of processors when compiling a program
US7958330B2 (en) Compiler program, compiler program recording medium, compile method, and program processing system
JP2003076558A (ja) プログラム実行制御方法及びプログラム実行制御プログラム
JP3293821B2 (ja) 動的リンクシステム

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 201080005431.7

Country of ref document: CN

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

Ref document number: 10769659

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2011511377

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 20117027092

Country of ref document: KR

Kind code of ref document: A

122 Ep: pct application non-entry in european phase

Ref document number: 10769659

Country of ref document: EP

Kind code of ref document: A1