WO2012053284A1 - オブジェクトへのアクセスを検出する方法、並びにそのコンピュータ及びコンピュータ・プログラム - Google Patents
オブジェクトへのアクセスを検出する方法、並びにそのコンピュータ及びコンピュータ・プログラム Download PDFInfo
- Publication number
- WO2012053284A1 WO2012053284A1 PCT/JP2011/069484 JP2011069484W WO2012053284A1 WO 2012053284 A1 WO2012053284 A1 WO 2012053284A1 JP 2011069484 W JP2011069484 W JP 2011069484W WO 2012053284 A1 WO2012053284 A1 WO 2012053284A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- pointer
- read
- computer
- exception
- format
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/14—Protection against unauthorised use of memory or access to memory
- G06F12/1416—Protection against unauthorised use of memory or access to memory by checking the object accessibility, e.g. type of access defined by the memory independently of subject rights
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/4493—Object persistence
Definitions
- the present invention relates to a technique for detecting access to an object stored in a memory of a computer, and more particularly to a technique for detecting access to an object having a modified object format.
- the object format is, for example, the current Java TM virtual machine (Virtual Machine) implementation is fixed through program execution.
- the fixed object format is, for example, the layout of headers and data fields, and their sizes.
- reducing the memory footprint, memory bandwidth, cache misses, garbage collection (GC) frequency, and GC overhead will reduce the cost of the computer running the program. It is useful in. Therefore, the fixed object format (hereinafter also referred to as “ordinary object format” or “original object format”) is modified so as to reduce the cost, and can be applied to the program.
- An object format (hereinafter also referred to as “modified object format”) has been developed (see FIGS. 4 to 6 below).
- Patent Literature 1 relates to a method for effectively using a memory area by isolating an object that exists in a memory area and is not accessed for a predetermined period, and particularly relates to a method for isolating an object that exists in a heap memory.
- Patent Document 1 if a user program accesses a semi-inaccessible area, control is transferred to a signal handler, and the accessed virtual memory address can be acquired in the signal handler. And clearing the flag by returning the object with the access flag set at the next GC to the normal heap memory area (paragraph 0114).
- Patent Document 2 relates to a multitask control method and a storage medium capable of multitask processing (paragraph 0001).
- Patent Document 2 describes that when an event such as an interrupt signal occurs and the signal handler detects the occurrence of an interrupt, the signal handler notifies the super signal thread of the occurrence of the interrupt event (paragraph 0064). .
- Non-Patent Document 2 discloses an object compression method.
- Non-Patent Document 3 discloses a method for accessing a permanent object.
- An object of the present invention is to efficiently access an object stored in a computer memory.
- an object of the present invention is to efficiently access an object having a modified object format.
- the present invention provides a method for detecting access to an object, a computer program, and a computer.
- the present invention converts the pointer into a pointer to the read / write protected area by operating a pointer to the object, and uses the fact that an exception occurs in response to an access request to the read / write protected area. It is characterized by performing reverse conversion from the pointer to the original pointer. Since the original pointer is recovered by the inverse transformation, it is possible to detect the object pointed to by the original pointer and to access the object pointed to by the original pointer.
- the inverse transformation refers to an instruction in which an exception has occurred, acquires the operated pointer from the instruction in which the exception has occurred, and obtains the acquired pointer. It includes reverse conversion, and obtaining a pointer to the head of the object pointed to by the original pointer subjected to the reverse conversion. By obtaining a pointer to the head of the object pointed to by the inversely converted original pointer, it is possible to detect the object pointed to by the original pointer and to access the object pointed to by the original pointer. .
- the object pointed to by the inversely converted original pointer (having the referenced header information) Processing suitable for the format (which is also an object) can be performed.
- the process is, for example, decompression of a compressed object to be accessed or delayed allocation of an object to be accessed.
- an exception is generated in response to an access request to the read / write protected area, and the original pointer is recovered. Therefore, the object accessed by the original pointer is efficiently accessed. It is possible. Further, according to the embodiment of the present invention, it is possible to obtain a pointer to the head of the object pointed to by the original pointer that has been inversely transformed, so that the object pointed to by the original pointer can be easily detected. is there. Further, according to the embodiment of the present invention, the header format of the object pointed to by the inversely converted original pointer is referred to, and processing suitable for the format of the object having the referenced header information is performed. Can be easily accessed even if it is modified differently than usual. This makes it possible to adopt a format that uses less memory than the normal object format, which further reduces the cost of the system or increases the processing speed.
- FIG. 1 shows a basic block diagram of computer hardware in an embodiment of the present invention.
- FIG. FIG. 2 shows a functional block diagram of a system having the functions of the computer hardware shown in FIG. 1 and according to an embodiment of the present invention.
- An example of an object and a pointer to the object is shown.
- An example of an object format in which a normal object format is transformed by compression will be described.
- An example of an object format in which a normal object format is modified by specifying a character array using a pointer is shown.
- An example of an object format in which a normal object format is transformed by field rearrangement is shown.
- a method of accessing an object in a conventional object database method is shown.
- a method for accessing a compressed object in a persistent object database method, which is a prior art is shown.
- FIG. 4 illustrates a method for accessing an object when a pointer is converted to point to a read / write protected area according to an embodiment of the present invention.
- Fig. 4 illustrates a method for accessing an object when a pointer is converted to point to a read / write protected area according to an embodiment of the present invention.
- An example of converting a pointer to an object to point to a read / write protected area according to an embodiment of the present invention will be described.
- 10 shows an example of a barrier pointer when the read / write protected area is the same size as the heap area according to an embodiment of the present invention.
- 10 shows an example of a barrier pointer when the read / write protection area is smaller than the heap area according to an embodiment of the present invention.
- FIG. 4 shows an example of a barrier pointer when the read / write protection area is an OS protection area according to an embodiment of the present invention.
- 2 shows a flowchart of a method for detecting access to an object according to an embodiment of the present invention.
- Fig. 5 shows a flowchart of an algorithm for handling a memory access exception using a slot for storing a pointer value to the beginning of an object according to an embodiment of the present invention.
- 6 shows a flowchart of an algorithm for converting a pointer to an object to point to a read / write protected area in object allocation according to an embodiment of the present invention.
- FIG. 6 shows a flowchart of an algorithm for converting a pointer to an object to point to a read / write protected area in garbage collection according to an embodiment of the present invention.
- FIG. FIG. 18 shows a virtual address space in step 1701 (before starting GC) of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows a virtual address space in step 1703 of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows the virtual address space and the contents of element P and set S when processed through steps 1704 and 1705 of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows the virtual address space and the contents of element P and set S when processed through steps 1707, 1709 and 1710 of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows the virtual address space and the contents of element P and set S when processed through steps 1704, 1705, 1707, 1709 and 1710 of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows the virtual address space and the contents of element P and set S when processed through steps 1704, 1705, 1707 and 1708 of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows the virtual address space and the contents of elements P and set S when processed through steps 1708, 1709, 1710, 1704, 1705, 1707 and 1708 of FIG. 17, which is an embodiment of the present invention.
- FIG. 18 shows the virtual address space and the contents of element P and set S when processed through steps 1709, 1710, 1704 and 1706 of FIG. FIG.
- FIG. 6 illustrates an example of an operation of calling a signal handler to recover (reverse) an original pointer from a converted pointer according to an embodiment of the present invention.
- FIG. 2 illustrates an example of a signal handler algorithm according to an embodiment of the present invention. The experimental result about the relationship between the frequency of access to an object and overhead according to the embodiment of the present invention is shown.
- FIG. 1 shows a basic block diagram of computer hardware in an embodiment of the present invention.
- the computer (101) includes a CPU (102) and a main memory (103), which are connected to a bus (104).
- the CPU (102) is preferably based on a 32-bit or 64-bit architecture, for example, Intel Core i (TM) series, Core 2 (TM) series, Atom (TM) series, Xeon (TM).
- the series Pentium (R) series, Celeron (R) series, AMD's Phenom (TM) series, Athlon (TM) series, Turion (TM) series or Empron (TM) may be used.
- a display (106) for example, a liquid crystal display (LCD) can be connected to the bus (104) via a display controller (105).
- LCD liquid crystal display
- the display (106) displays information about a computer connected to a network via a communication line and information about software running on the computer with an appropriate graphic interface for managing the computer. Used for.
- the bus (104) can also be connected via a SATA or IDE controller (107) to a storage device (108) such as a hard disk or silicon disk and a drive (109) such as a CD, DVD or BD drive.
- a keyboard (111) and a mouse (112) can be connected to the bus (104) via a keyboard / mouse controller (110) or a USB bus (not shown).
- the storage device (108) includes an operating system, a Java (registered trademark) processing environment such as J2EE, a Java (registered trademark) application, a Java (registered trademark) virtual machine (VM), and a Java (registered trademark) runtime (JIT). )
- a program for providing a compiler, other programs, and data are stored in the main memory 103 so as to be loadable.
- the drive (109) is used to install a program from a CD-ROM, DVD-ROM or BD to the storage device (108) as necessary.
- the communication interface (114) follows, for example, the Ethernet (registered trademark) protocol.
- the communication interface (114) is connected to the bus (104) via the communication controller (113) and plays a role of physically connecting the computer (101) to the communication line (115).
- a network interface layer is provided for the TCP / IP communication protocol of the communication function of the system.
- the communication line (115) 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.
- FIG. 2 shows a functional block diagram of the computer (201) having the hardware functions of the computer (101) shown in FIG. 1 and according to the embodiment of the present invention.
- the computer (201) includes a conversion unit (211) and an inverse conversion unit (212) in addition to the CPU (102), the main memory (103), and the storage device (108) shown in FIG.
- the computer (201) can further include a processing unit (213) and an execution unit (214).
- the conversion unit (211) operates a pointer to the object to convert the pointer into a pointer that points to the read / write protected area.
- the conversion unit (211) can perform the conversion processes shown in (1) to (3) below, for example.
- (1) A constant offset value is added to the pointer to obtain a pointer (converted pointer) that points to the read / write protected area.
- (2) The pointer to the object is shifted right by n bits (n is an integer), and a fixed offset value is added to obtain a read / write protected area (converted pointer).
- the pointer to the object is shifted to the right by n bits (n is an integer), and the address of the read / write protection area is embedded in the empty left (upper) bit to indicate the read / write protection area (converted) Pointer).
- the conversion unit (211) performs the conversion, for example, in object allocation or garbage collection.
- the reverse conversion unit (212) performs reverse conversion from the converted pointer to the original pointer by using an exception that occurs in response to a request to access the read / write protected area.
- the inverse conversion unit (212) refers to the instruction in which the exception has occurred, acquires the operated pointer from the instruction in which the exception has occurred, and acquires the acquired pointer. Is inversely converted to obtain a pointer to the head of the object pointed to by the inversely converted original pointer.
- the inverse conversion unit (212) includes a register or slot number of a slot (also referred to as a pinning array slot) that stores an instruction address where an exception has occurred and a pointer value to the head of the object.
- the operation pointer is obtained from the instruction address where the exception has occurred, and the obtained pointer is inversely converted, and the object pointed to by the inversely converted original pointer is obtained. Get a pointer to the beginning.
- the inverse transform unit (212) includes: Corresponding to (1) to (3) performed by the conversion unit (211), inverse conversion processing shown in the following (1 ′) to (3 ′) can be performed.
- (1 ′) An original pointer is obtained by subtracting a certain offset value from the pointer converted in (1) above.
- (2 ′) A constant offset value is subtracted from the pointer converted in (2) above, and left-shifted by the same number of n bits as in (2) above to obtain the original pointer.
- (3 ′) The pointer converted in (3) above is shifted left by the same n bits as in (3) to obtain the original pointer.
- the processing unit (213) refers to the header information of the object pointed to by the inversely converted original pointer, and performs processing suitable for the format of the object having the referenced header information.
- a process suitable for the format is, for example, decompression of a compressed object or delayed allocation of a character array.
- the execution unit (214) performs processing suitable for the format, and then accesses the object pointed to by the inversely converted original pointer.
- FIG. 3 shows an example of an object and a pointer to the object.
- An “object” is a specific object of an abstract procedure on a program, and is an object generated from an allocation location of an object described in the program.
- the “object” is allocated in a memory, for example, in a heap area when the program is executed.
- An “object” is generated from a class, for example.
- the “object” may exist in the heap area even when the execution of the program is interrupted or completed, for example.
- the heap area is not an entire heap area used for a program, but a part of the entire heap area and an area to which objects are allocated.
- the heap area is, for example, a heap area targeted for GC.
- Object typically includes a header and at least one field (see FIGS. 4 and 6 below).
- the header is a part that holds information on the object itself, embedded in the object, and includes information on the size and type of the object, for example.
- the field is a part accessible to the user of the object, and has two types of data, for example, a pointer and a non-pointer.
- a pointer is a value that refers to a certain location in a memory area. In many language processing systems, a pointer to an object refers to the start address of the object (see FIG. 3).
- a non-pointer uses a value itself in programming, and includes a numerical value, a character, and / or a truth value.
- Object is allocated on the memory area.
- the GC moves or discards the arranged object depending on the situation.
- the “object format” includes a so-called normal object format and an object format obtained by modifying the normal object format (hereinafter also referred to as “transformed object format”).
- Normal Object Format is, for example, a format found during Java TM, C #, Script (PHP or Perl), Ruby, C, C ++, LISP, Python, or Haskell implementations and is particularly modified. A format that is not. In Java TM, the object format can only be seen during Java TM implementation (ie, in memory). The normal object format depends on the object class.
- Modified object format means normal object format for the purpose of reducing memory footprint, memory bandwidth, cache misses, garbage collection frequency, and GC overhead Is a modified object format. Modifications of the object format are shown in FIGS. 4 to 6 below, but the present invention is not limited to these modifications.
- Object X (311) has a pointer (321) therein.
- the pointer (321) indicates access to the object A (312), and has the head address of the object A (312).
- Object A (312) is also the target object of pointer (321).
- the object A (312) may be either an object having a normal object format or a modified object format.
- Object Y (331) has a pointer (341) therein.
- the pointer (341) indicates access to the object B (332) and has the head address of the object B (332).
- Object B (332) is also the target object of pointer (341).
- Object B (332) has a pointer (342) therein.
- the pointer (342) indicates access to the object C (333) and has the head address of the object C (333).
- Object C (333) is also the target object of pointer (342). In this manner, the pointer is sequentially read, and access to another object is indicated from the read pointer.
- Each of the object B (332) and the object C (333) may be an object having a normal object format or a modified object format.
- FIG. 4 shows an example of an object format in which a normal object format is transformed by compression.
- a character array character array (s)
- ASCII ASCII
- Object compression results in optimization of object access.
- An object format (401) indicates a normal format.
- An object format (402) indicates a format when the object format (401) is deformed by compression.
- the object format (401) includes a header (411) and null value data fields (412, 414, 416 and 418) and an ASCII data field (413, 415, 417 and 419).
- the object format (402) includes a header (421) and ASCII data fields (422-425).
- the null data fields (412, 414, 416 and 418) of the object format (401) are deleted, and the ASCII data fields (413, 415, 417 and 417) are deleted. 419). Since the number of data fields in the modified object format (402) is four and the number of data fields in the object format (401) is eight, the data in the modified object format (402) The field is compressed to half the data field of the object format (401). In the modified object format (402), since the number of data fields is compressed, the cost of the memory can be reduced compared to the object format (401).
- Non-Patent Document 2 There are many known methods for compressing objects (see Non-Patent Document 2).
- FIG. 5 shows an example of an object format in which a normal object format is modified by specifying a character array using a pointer.
- Specifying a character array using a pointer is generated, for example, when a plurality of string objects assigned to a certain part tend not to be accessed and these string objects are concatenated with other string objects.
- the character array that can be connected is designated by using a pointer.
- the assignment of character arrays using the pointer can occur lazily. Lazy allocation results in optimization of object access because it does not allocate the object until it is actually needed.
- the object format (501) indicates a normal format.
- An object format (502) indicates a format when the object format (501) is transformed.
- the character array (512) and the character array (522) are assigned to different positions, the character array (512) and the character array (522) are combined to form a character array. (532) indicates that it is newly generated. The generation of the character array (532) can be delayed.
- each of the character array (542) and the character array (552) has two pointers (562). And 563).
- the modified object format (502) is different in that it has two pointers (562 and 563) instead of the character array (532) of the object format (501). Since the object format (502) has two pointers (562 and 563) instead of the character array (532), the cost of the memory can be reduced.
- FIG. 6 shows an example of an object format in which a normal object format is transformed by field rearrangement.
- Field relocation is, for example, when two or more fields in an object tend to be accessed at the same time in order to reduce data cache misses for the two or more fields. Or it indicates that more fields are co-located.
- An object format (601) indicates a normal format.
- the object format (602) indicates a format when the object format (601) is transformed.
- the object format (601) includes a header (611) and data fields in the order of 1 to 6 (612 to 617).
- the object format (602) includes a header (621) and data fields in the order of 1, 6, 3, 4, 5 and 2 (622 to 627).
- the modified object format (602) is modified so that the data field 6 (623) is positioned adjacent to the data field 1 (622).
- data field 1 (622) and data field 6 (623), which tend to be accessed at the same time, are modified so that they are located next to each other. Costs can be reduced.
- FIG. 7 shows a method of accessing an object in a conventional object database method that is a prior art.
- Access to an object using the persistent object database method has the following characteristics: (1) Monitoring of access to an object is in units of pages; (2) Cases where the method is suitable are in page units. And (3) the field of application of the scheme is mainly in the field of databases and disks, especially in swapping out / or swapping in.
- the computer (201) accesses the object A by following the pointer from the object X (721).
- the computer (201) uses the signal handler to stop the execution of all the threads and remove the protection of the read / write protected page (702).
- the virtual address space (701) after removal of protection is shown in the lower part of FIG.
- the computer (201) uses the signal handler to load the object A (741) from the disk or the remote machine into the memory, and resumes the execution of the program.
- the computer (201) does not only include the object A (741) but also the object B (742) and the object that are in the same read / write protected page (702) as the object A (741). C (743) is also loaded onto the memory. Therefore, there is a demerit that the cost of the memory increases.
- the computer (201) allocates a new read / write protection page (703) and the object A (741). ) Pointer to the read / write protected page (703).
- the computer (201) allocates a new read / write protection page (703), and This indicates that the pointer of C (743) points to the read / write protected page (703).
- FIG. 8 shows a method of accessing a compressed object in the conventional object database method.
- the characteristics of the persistent object database method are as described above.
- the computer (201) traces the pointer from the object X (821) as shown in the upper diagram of FIG.
- the computer (201) uses the signal handler to stop the execution of all threads and remove the protection of the read / write protected page (802) (812).
- the virtual address space (801) after removal of protection is shown in the lower part of FIG.
- the computer (201) uses the signal handler to expand the compressed object A (822) onto the memory, and resumes the execution of the program.
- FIGS. 9A and 9B show an access method to an object when a pointer is converted to point to a read / write protected area according to an embodiment of the present invention.
- access to an object has the following characteristics: (1) Monitoring of access to an object is not a page unit but an individual object unit; (2) Case where the method is suitable Is the case where it is desired to monitor every object scattered in the heap, not when there is locality of access in page units; and (3)
- the application field of the embodiment of the present invention is mainly object access. Profiling, object compression, object delay allocation, and object relocation.
- FIG. 9A there is a virtual address space (901) on the memory of the computer (201). There is a read / write protected area (902) on the virtual address space (901). It is assumed that the pointer of the object X (921) indicates the address (922) of the read / write protected area (902), and the pointer of the compressed object A (923) indicates the address (924) of the read / write protected area (902). The pointer of the object Y (931) indicates the address (932) of the read / write protected area (902).
- the pointer of the object X (921) is converted from the address indicating the compressed object A (923) (that is, the start address of the compressed object A) into the pointer indicating the read / write protected area (902). It is that you are. Further, the pointer of the compressed object A (923) is converted from the address indicating the compressed object B (925) (that is, the start address of the compressed object B) into the pointer indicating the read / write protected area (902). The pointer of the object Y (931) is converted from the address indicating the compressed object C (933) (that is, the start address of the compressed object C) to the pointer indicating the read / write protected area (902).
- barrierize converting a pointer to a target object so as to point to a read / write protected area (code operation) is referred to as “barrierize”.
- the barrier rise is performed in allocation or in the GC. This barrier rise can be performed on all objects in the embodiment of the present invention.
- barrier pointer the pointer converted by the barrier rise is referred to as a “barrier pointer”.
- the name barrier pointer was named by the present inventor. All accesses through the barrier pointer raise an exception.
- FIG. 9B shows the virtual address space (901) after decompressing only the compressed object A (923). As shown in FIG.
- the computer (201) traces the pointer from the object A (943). It is assumed that the point destination indicates the address (924) of the read / write protected area (902). Therefore, an access request to the read / write protection area (902) occurs. Since the point destination indicates the address of the read / write protected area (902), an exception occurs in response to the access request.
- the computer (201) uses the signal handler to reversely convert the original pointer from the pointer of the object A (943). Then, the computer (201) decompresses only the compressed object B (925) to be accessed by using the signal handler. That is, the compressed object C (933) is not expanded. The computer (201) accesses the decompressed object B (925) (not shown) and resumes execution of the program.
- the computer (201) has followed the pointer from the object Y (931). It is assumed that the point destination indicates the address (932) of the read / write protection area (902). Therefore, an access request to the read / write protection area (902) occurs. Since the point destination indicates the address of the read / write protected area (902), an exception occurs in response to the access request.
- the computer (201) uses the signal handler to reversely convert the original pointer from the pointer of the object Y (931). Then, the computer (201) decompresses only the compressed object C (933) to be accessed by using the signal handler. The computer (201) accesses the expanded object C (933) (not shown) and resumes execution of the program.
- FIG. 10 shows an example of converting a pointer to an object to point to a read / write protected area according to an embodiment of the present invention.
- a pointer (1002) included in the object (1001) is a pointer to the object A (1005).
- the pointer (1002) is a pointer before conversion.
- the lower 2 or 3 bits (1004) thereof are zero, and the other bits indicate the address (1003) of the object to be accessed.
- the address (1003) is, for example, the head address of the object A (1005).
- the point that the lower 2 or 3 bits (1004) of the pointer (1002) is zero is used.
- the pointer (1002) is converted into a pointer that points to the read / write protected area by performing the following bit manipulation of the pointer.
- One example of such conversion is, for example, right-shifting the pointer (1002) by n bits (where n is an integer, eg, n is 2 or 3) and read / write protected to the left (upper) bits that are free This is done by setting a pointer to the area.
- the pointer (1012) is a pointer generated by the above conversion.
- the number of upper n bits (1013) is the same as the number of bits shifted to the right.
- the other bits (1014) are the same as the bit (1003).
- the head (1013) of the pointer (1012) indicates the address (1015) of the read / write protected area.
- the read / write protected area is, for example, a memory area generated by a specific language (for example, a read / write protected area outside the heap of Java TM), for example, an OS memory area.
- the read / write protected area can be, for example, an address that causes an exception. For example, when 32-bit Linux (trademark) is installed in the computer, the read / write protected area is 0xC0000000 and above. The read / write protected area cannot be accessed by the user. In addition, the address of the read / write protected area according to the programming language implemented by the computer can be used.
- the use of a read / write protected area in barrier rise eliminates the need to assign pointers to real memory (real memory), and merely reserves and protects virtual memory areas. There is a point. Also, according to an embodiment of the present invention, there is an advantage that it is not necessary to reserve a virtual memory area in the user space.
- the pointer (1012) is inversely converted by performing the following bit manipulation of the pointer.
- the pointer of the object X (1021) points to the start address of the object A. That is, the converted pointer is inversely converted to the original pointer.
- the inverse transformation shifts the pointer (1012) to the left by n bits (n is an integer, for example, n is 2 or 3), and the left-shifted left (lower) bit (1024) is left. This is done by setting zero.
- a pointer (1022) (that is, the same as the pointer 1002) is generated from the pointer (1012), and access to the target object A (1025) can be detected.
- FIGS. 11 to 13 below show examples of various barrier pointers according to the embodiment of the present invention.
- FIGS. 11 to 13 is a memory layout
- the barrier pointer of FIG. 11 is a basic barrier pointer
- FIGS. 12 to 13 are extended barrier pointers.
- those skilled in the art may optionally use the barrier pointers of FIGS. 11-13 and the barrier pointers of other embodiments.
- FIG. 11 shows an example of a barrier pointer in the case where the read / write protected area is the same size as the heap area according to the embodiment of the present invention.
- the virtual address space (1101) there is a Java (trademark) heap area (1111) and a read / write protected area (1112).
- the original pointer is indicated by arrow (1121) and the barrier pointer is indicated by arrow (1122).
- the read / write protected area (1112) is reserved so as to have the same address size as the Java TM heap area (1111). Implementation is simplified by using the same address size.
- a constant offset between the Java TM heap area (1111) and the read / write protected area (1112) is added to the pointer.
- a certain offset is reduced in the unvarialization.
- the offset is constant during Java TM VM initialization and program execution.
- Most OSs have a system call to reserve a read / write protected virtual address area.
- the read / write protected area (1112) does not require real memory allocation.
- Recent OSs do not allocate real memory to virtual pages until the contents of real memory are first accessed by a program.
- the read / write protected area (1112) is used only to generate an exception. Therefore, the contents of the read / write protected area (1112) are never accessed from the outside, and real memory is not required.
- the Java TM heap area (1111) is dynamically expanded, the read / write protected area (1112) must be expanded as well.
- the size of the read / write protected area (1112) is made to match the maximum size of the Java TM heap area (1111). Note that the size of the read / write protected area (1112) may not be smaller than the size of the Java TM heap area (1111).
- the barrier rise can be performed in object allocation (see FIG. 16 below) or in GC (see FIG. 17 below). Barrierization at the time of object allocation is useful for profiling or optimizing an object allocated at a certain allocation site. In order for the barrier pointer to work correctly, it is important that all pointers pointing to the target object are barrierized. Since only one pointer in the register points to the allocated object immediately after allocation, it is sufficient to vary the register in the generated JIT code or in a modified interpreter. In contrast, barrier rise in GC is suitable for profiling or optimizing long live objects. In the embodiment of the present invention, among the barrier rise and unvariate rise methods shown in FIGS. 11 to 13, the barrier rise and unvariate rise methods shown in FIG. 11 are the most basic methods.
- FIG. 12 shows an example of the barrier pointer when the read / write protected area is smaller than the heap area according to the embodiment of the present invention.
- the original pointer is indicated by an arrow (1221) and the barrier pointer is indicated by an arrow (1222).
- the objects used in FIG. 12 are aligned in units of 8 bytes, for example. In a general CPU design, for example, if 8-byte data is read from an address that is not 8-byte aligned, overhead is required.
- the size of the read / write protected area (1112) is set to be equal to or larger than the maximum size of the Java (trademark) heap area (1111).
- the virtual address space (1101) is a limited resource.
- the additional area in the virtual address also increases translation lookaside buffer (TLB) misses. Therefore, it is preferable to make the read / write protected area as small as possible.
- the read / write protected area (1212) is reserved so as to be smaller than the Java (trademark) heap area (1211).
- the read / write protected area (1212) may be one-eighth the size of the Java TM heap area (1211).
- barrier rise the pointer is shifted right by n bits and an offset is added.
- unvarialization a certain offset is reduced, and n bits are shifted to the left.
- Barrier rise is performed in object allocation or GC, as in the example of FIG.
- the Java TM VM can take advantage of the fact that all Java TM objects are aligned on 8-byte boundaries. Since the last 3 bits of each object pointer are zero, a right shift of 3 bits is possible without losing any information. Accordingly, the size of the read / write protected area (1212) can be one-eighth the size of the Java TM heap area (1211), as described above.
- the barrier pointer can be expressed by the following Equation 1.
- Equation 1 can be represented in a simplified form as represented by Equation 2 below.
- FIG. 13 shows an example of a barrier pointer when the read / write protection area is an OS protection area according to an embodiment of the present invention.
- FIG. 13 shows a method of reducing the size of the read / write protected area by a method different from FIG.
- the original pointer is indicated by arrow (1321) and the barrier pointer is indicated by arrow (1322).
- FIG. 13 shows an example of a barrier pointer when the read / write protection area is an OS protection area according to an embodiment of the present invention.
- FIG. 13 shows a method of reducing the size of the read / write protected area by a method different from FIG.
- the Linux (trademark) OS area (1312) occupies a quarter of the virtual address space (1301) according to the specification of the Linux (trademark) OS program, and from OxC0 ... 000 Start. The user cannot access this Linux (trademark) OS area (1312).
- an address indicating the head of the Linux (registered trademark) OS area (1312) is set in two vacant bits after being shifted to the right by the number of n bits of the pointer (11 in the example of FIG. 13). On the other hand, in unvarialization, n bits of the pointer are shifted to the left. Java TM VM does not need to reserve a read / write protected area in the user space.
- the OS typically reserves half or quarter of the virtual address space.
- the OS typically occupies 1 / 16th of a 4 GB virtual address space. This means that the Java TM VM can reserve 256 MB elsewhere to reserve the read / write protected area. Barrier rise is performed in object allocation or GC, as in the example of FIG.
- FIG. 14 shows a flowchart of a method for detecting access to an object according to an embodiment of the present invention.
- the computer (201) starts an algorithm for detecting access to an object.
- the conversion unit (211) performs a code operation on the pointer to the object (target object) to convert the pointer into a pointer that points to the read / write protected area.
- the mode of conversion of the pointer is as described in the description of the conversion unit (211).
- the total value exceeds the read / write protected area it is only necessary to give up the barrier rise, so this object cannot be converted into a format different from the normal format.
- step 1403 when an exception occurs during access to the read / write protected area, the computer (201) detects a memory access exception and activates a signal handler. If an exception has occurred, the process proceeds to step 1404. On the other hand, if no exception has occurred, the system waits for the exception to occur. Note that the computer (201) performs the following steps 1404 to 1410 using the activated signal handler.
- step 1404 the computer (201) uses the signal handler to check whether the data address where the exception has occurred is a data address in the read / write protected area.
- the occurrence of the exception is, for example, the occurrence of a segmentation fault. If the data address where the exception occurred is a data address in the read / write protected area, the process proceeds to step 1405. On the other hand, if the data address where the exception occurred is not a data address in the read / write protected area, the process proceeds to step 1406.
- step 1405 the inverse conversion unit (212) uses the signal handler to change the pointer that has been converted according to the fact that the data address where the exception has occurred is a data address in the read / write protection area. Reverse conversion from to the original pointer.
- the embodiment of the inverse conversion of the pointer is as described in the description of the inverse conversion unit (212). The operation of the inverse conversion unit (212) will be described in more detail below.
- the signal handler needs to obtain a pointer to the beginning of the object that should have been accessed. This is because the computer (201) reads the header of the original object from the pointer to the head of the original object, and decompresses the compressed object when the original object is compressed. This is because it is necessary to decide. To obtain a pointer to the beginning of the original object, the signal handler does the following: Generally, the computer (201) can know the address of the instruction in which an exception has occurred by using the signal hand. When the instruction at the address is read out, for example, the computer (201) is represented in the format represented by the following formula 4. An instruction is obtained (see the detailed description of the invention corresponding to FIG. 18 below).
- the computer (201) can read the register value when an exception occurs using the signal hand, the contents of the "register containing the pointer value" in the above format are read. Can do. Therefore, the JIT compiler or interpreter is modified so that the instruction for accessing the object has the format shown in the following equation 5.
- the computer (201) reads out the instruction represented by Expression 2 using the signal hand, and further reads out “the pointer value to the head of the object”. Since the “pointer value to the beginning of the object” is actually a barrier pointer, the computer (201) performs unvarialization on the “pointer value to the beginning of the object” using the signal hand. As a result, the computer (201) can obtain a pointer value to the head of the original object.
- the computer (201) performs the inverse transformation by reading and unvariating the base_reg_object_head (detailed description of the invention corresponding to FIG. 18). See the description).
- the inverse conversion is performed by shifting the converted pointer to the left by the same n bits as the right shift of the n bits by n 140.
- the inverse conversion refers to, for example, an instruction in which an exception has occurred, acquires a pointer to the head of the object in which the pointer has been converted from the instruction in which the exception has occurred, and reversely converts the acquired pointer. This is done by obtaining a pointer to the beginning of the original object.
- the processing unit (213) confirms whether processing according to the object is necessary with reference to, for example, the header information of the object. For example, a code for identifying compression or delay allocation is written in the header of the object. For example, when “0” is written in a specific field of the header, it means a normal format, and when “1” is written in the field, it means a compressed format, and in the same field. When “2” is written, it means a format in which allocation is delayed. If processing according to the object is necessary, the processing proceeds to step 1409. On the other hand, if the process according to the object is not necessary, the process proceeds to step 1410.
- the processing unit (213) uses the signal handler to refer to the header information of the object pointed to by the inversely converted original pointer, and performs processing suitable for the format of the object.
- the processing suitable for the format of the object includes, for example, logging access to the object, returning the object to the original format, and accessing the field of the object in the new format.
- logging access to an object it is possible to use the method for detecting access to an object, which is an embodiment of the present invention, even in program optimization.
- Returning an object to its original form means, for example, decompressing the compressed object when the object to be accessed is compressed, or delaying assignment of the character array to be accessed.
- step 1410 the execution unit (214) uses the signal handler to access the object pointed to by the original pointer after the inverse transformation. Then, the processing returns to step 1403.
- step 1406 the computer (201) uses the signal handler to determine that the exception is an unauthorized access when the data address where the exception occurred is not a data address in the read / write protected area. And processing according to the unauthorized access. This processing is, for example, acquisition of a memory dump.
- step 1407 the computer (201) ends the algorithm for detecting access to the object.
- FIG. 15 shows a flowchart of an algorithm for handling memory access exceptions using pinning array slots, in accordance with an embodiment of the present invention.
- step 1405 executed by the inverse transform unit (212)
- unvarialization is performed using an expression [register containing the pointer value to the head of the object, offset] (see Expression 5).
- the pointer value to the head of the original object can be obtained.
- this algorithm can be used when there is access to an array object. Note that the algorithm of FIG. 15 differs from the algorithm of FIG.
- Access to the array object can be an instruction sequence represented by the following equations 6-8.
- Register X Pointer value to the beginning of the array object
- the pointer value of Expression 6 is a barrier pointer
- Such a value of the register X is referred to as an internal pointer because it indicates not the beginning of the object but the inside. Therefore, for access to such an array object, the JIT compiler or interpreter is modified so that it is accessed as represented by the following equations 9-12.
- the pointer value to the head of the array object is stored in the pinning array slot (pinning_array_slot).
- the pinning array slot is an area for storing a pointer value to the head of the object.
- a pinning array slot is actually a slot in another register or stack.
- a correspondence table is created from the instruction address of Equation 12 to the corresponding pinning array slot register or slot register or slot number. The signal handler draws the correspondence table using the address of the instruction in which the exception occurred as a key. If there is a corresponding pinning array slot, the pointer value to the head of the array object is read from the corresponding pinning array slot.
- the read pointer value is a barrier pointer
- the pointer value to the head of the original array object can be obtained by performing unvarialization.
- This pinning array slot is already supported by, for example, Java TM VM, for example, as an internal pointer-aware GC, to allow the GC to move the object.
- the internal pointer-aware GC is a GC that can handle a pointer pointing to the inside of an object. Therefore, there is actually no need to modify the JIT compiler or interpreter.
- the above correspondence table needs to be newly prepared in the embodiment of the present invention.
- the correspondence table itself becomes large and does not consume too much memory.
- step 1501 the computer (201) starts an algorithm for handling a memory access exception using a signal handler. After the start of the algorithm, an exception occurs in accessing the read / write protected area, the signal handler is called, and the signal handler is executed.
- step 1502 when an exception occurs during access to the read / write protected area, the computer (201) detects the exception and activates the signal handler. If an exception has occurred, the process proceeds to step 1503. On the other hand, if no exception has occurred, the system waits for the exception to occur. Note that the computer (201) performs the following steps 1503 to 1513 using the activated signal handler.
- step 1503 the computer (201) uses the signal handler to check whether the data address where the exception has occurred is a data address in the read / write protected area.
- the occurrence of the exception is, for example, the occurrence of a segmentation violation (also referred to as a segmentation fault).
- a segmentation violation is a specific error condition that occurs during software execution, and is not allowed to access a location in memory, or in an unauthorized manner (eg, trying to write to a read-only location or operating system Occurs when trying to access a location in memory.
- the process proceeds to step 1504.
- the process proceeds to step 1505.
- step 1504 the computer (201) uses the signal handler to determine whether there is a pinning array slot corresponding to the instruction address at which the exception occurred. Each such access is associated with a stack slot that contains a pointer to the head of the array object. This associated slot is referred to as a pinning array slot, as described above. Each instruction is associated with the pinning array slot. If there is a pinning array slot, the process proceeds to step 1507.
- step 1507 the computer (201) reads the barrier pointer corresponding to the head address of the original object from the pinning array slot using the signal handler.
- step 1510 the computer (201) reversely converts the read barrier pointer using the signal handler to obtain the head address of the original object.
- the inverse transformation is as described above.
- the computer (201) refers to the header information of the object pointed to by the inversely converted original pointer using the signal handler, and performs processing suitable for the format of the object.
- the processing suitable for the format of the object includes, for example, logging access to the object, returning the object to the original format, and accessing the field of the object in the new format. Returning the object to the original form means, for example, when the object is compressed, expanding the compressed object, or allocating the character array in a delayed manner.
- step 1512 the computer (201) uses the signal handler to access the object pointed to by the original pointer after the inverse transformation. Then, the process proceeds to step 1513.
- step 1513 the computer (201) ends the algorithm for handling the memory access exception using the signal handler.
- step 1505 the computer (201) uses the signal handler to determine that the exception is an illegal access if the data address where the exception occurred is not a data address in the read / write protected area. And processing according to the unauthorized access. This processing is, for example, acquisition of a memory dump.
- step 1506 the computer (201) ends the algorithm for detecting access to the object using the signal handler.
- step 1508 the computer (201) uses the signal handler to decode the instruction at the instruction address at which the exception has occurred, and reads the base register number into the memory.
- the computer (201) can use the signal handler to read all register values when an exception occurs.
- step 1509 the computer (201) reads the register value corresponding to the base register number read in step 1508 into the memory using the signal handler.
- the read register value is a barrier pointer corresponding to the head address of the original object.
- the process proceeds to step 1510, and as described above, the read register value (which is a barrier pointer) is inversely converted to obtain the head address of the original object.
- FIG. 16 and FIG. 17 show examples of various barrierizing algorithms according to the embodiment of the present invention.
- the barrier rise is executed in step 1402 of FIG.
- FIG. 16 shows a flowchart of an algorithm for variableizing object allocation according to an embodiment of the present invention.
- Steps 1601 to 1604 in FIG. 16 are one embodiment of the processing performed in step 1402 in FIG.
- the computer (201) starts barrier rise.
- the computer (201) allocates an object to the heap memory. Immediately after the object is allocated, there is only one pointer that points to the allocated object.
- the computer (201) converts the pointer to point to the read / write protected area.
- the computer (201) ends the algorithm in response to the end of the inverse transformation.
- FIG. 17 shows a flowchart of an algorithm for barrierizing in the GC according to an embodiment of the present invention.
- Steps 1701 to 1710 in FIG. 17 are one embodiment of the processing performed in step 1402 in FIG.
- the computer (201) starts barrier rise.
- the computer (201) empties the set S for storing pointers to pointers.
- the computer (201) adds a GC root set such as a register or a stack to the set S.
- the computer (201) checks whether an element is included in the set S. If there is an element in the set S, the process proceeds to step 1705. On the other hand, if the set S contains no element, the process proceeds to step 1706.
- step 1705 the computer (201) extracts one element from the set S in response to the element being included in the set S. This extracted element is named element P. Element P is a pointer to a pointer.
- step 1706 the computer (201) terminates the algorithm in response to the fact that no element is included in the set S.
- step 1707 the computer (201) checks whether or not the object format pointed to by the pointer pointed to by the element P is a modified object format. If the format is modified, the process proceeds to step 1708. On the other hand, if the format is not modified, the process proceeds to step 1709.
- step 1708 the computer (201) reads / write-protects the pointer pointed to by the element P in response to the object format pointed to by the pointer pointed to by the element P being a modified object format. The data is converted to point to the area and stored in the memory pointed to by P.
- Step 1708 is a step of barrierizing in the GC.
- the computer (201) processes the object Q pointed to by the pointer pointed to by the element P by a GC routine.
- the GC routine typically marks object Q as if it were alive.
- step 1710 the computer (201) adds a pointer to the pointer field (eg, 322 in FIG. 3) in the object Q to the set S.
- FIG. 18A shows a virtual address space in step 1701 (before the start of GC) of FIG. 17, which is an embodiment of the present invention.
- a virtual address space (1801) on the memory of the computer (201).
- a read / write protection area (1802) on the memory of the computer (201).
- a thread stack area (1803) No real memory is allocated to the read / write protected area (1802).
- the thread stack area (1803) is a part of the GC root set.
- the pointer (1821) of the object X (1811) points to the start address of the object Y.
- the pointer (1822) of the object X (1811) points to the head address of the compressed object A (1812).
- the pointer (1823) of the object Y (1813) points to the head address of the compressed object A (1812).
- the pointer (1831) in the thread stack area points to the start address of the object X (1811).
- Object A (1812) is in a compressed format. Therefore, it is necessary to convert the pointers (1822 and 1823) to the object A into barrier pointers.
- FIG. 18B shows each object X, Y and A, each pointer value indicating the head of each object X, Y and A, and each barrier pointer value corresponding to each object X, Y and A.
- the pointer of the normal object format is a pointer whose upper 2 bits of each pointer value are other than 11.
- the barrier pointer is a value obtained by shifting the pointer of the normal object format to the right by the number of 2 bits and setting 11 to the free upper 2 bits.
- FIG. 18C shows the four pointers shown in FIG. 18 to FIG. 25, and shows pointer values pointing to the respective pointers (notice that the pointers are not held by the pointers).
- the pointer value indicating each of the pointers is a value given as a premise.
- FIG. 19A shows the virtual address space in step 1703 of FIG. 17, which is an embodiment of the present invention.
- the computer (201) adds a pointer value (000000) indicating a pointer in the stack area indicating the object X to the set S (FIG. 19B). .
- FIG. 20A shows the virtual address space when processed through steps 1704 and 1705 of FIG. 17, which is an embodiment of the present invention.
- step 1705 since the computer (201) takes out the element P from the set S, it takes out from the set S a pointer value (000000) that points to the pointer in the stack area that points to the object X (FIG. 20B).
- FIG. 21A shows a virtual address space when processed through steps 1707, 1709 and 1710 of FIG. 17, which is an embodiment of the present invention.
- the computer (201) adds a pointer to the pointer field in the object X to the set S (FIG. 21B). That is, the computer (201) collects a pointer value (001000) indicating the pointer in the object X indicating the object Y and a pointer value (001100) indicating the pointer in the object X indicating the object A. Add to S. Then, the computer (201) clears the element P. Note that the object X in FIG. 21A corresponds to the object Q in step 1710 in FIG.
- FIG. 22A shows a virtual address space as processed through steps 1704, 1705, 1707, 1709 and 1710 of FIG. 17, which is an embodiment of the present invention.
- the computer (201) retrieves the element P (here, the pointer value (001000) indicating the pointer in the object X indicating the object Y) from the set S, and thus the object X indicating the object Y.
- a pointer value (001000) pointing to the pointer in is taken out from the set S.
- the computer (201) adds a pointer to the pointer field in the object Y to the set S and clears the element P (FIG. 22B).
- the computer (201) adds a pointer value (011100) that points to the object A and points to the pointer in the object Y to the set S, and also adds an element P (pointer in the object X that points to the object Y).
- the pointer value pointing to (001000)) is cleared. Note that the object Y in FIG. 22A corresponds to the object Q in step 1710 in FIG.
- FIG. 23A shows the virtual address space as processed through steps 1704, 1705, 1707 and 1708 of FIG. 17, which is an embodiment of the present invention.
- the computer (201) retrieves an element P (here, a pointer value (001100) pointing to a pointer in the object X pointing to the object A) from the set S, so that the object X pointing to the object A A pointer value (001100) pointing to the pointer in is taken out from the set S.
- the computer (201) rewrites the pointer (100000) in the object X that points to the object A (shifts to the right by 2 bits and adds 11 to the vacant bits). Convert to pointer (111000).
- the computer (201) clears the element P. Note that the object A in FIG. 23A corresponds to the object Q in step 1710 in FIG.
- FIG. 24A shows the virtual address space when processed through steps 1708, 1709, 1710, 1704, 1705, 1707 and 1708 of FIG. 17, which is an embodiment of the present invention.
- the computer (201) retrieves an element P (here, a pointer value (011100) pointing to a pointer in the object Y pointing to the object A) from the set S, so that the object Y pointing to the object A A pointer value (011100) pointing to the pointer in is taken out from the set S.
- the computer (201) rewrites the pointer (100000) in the object Y pointing to the object A (shifts to the right by 2 bits and adds 11 to the vacant bits). Convert to pointer (111000).
- the computer (201) clears the element P. Note that the object A in FIG. 24A corresponds to the object Q in step 1710 in FIG.
- FIG. 25A shows the virtual address space as processed through steps 1709, 1710, 1704 and 1706 of FIG. 17, which is an embodiment of the present invention.
- the computer (201) clears the element P. Then, the process returns to step 1704, and the computer (201) advances the process to step 1706 and terminates since there are no elements in the set S.
- FIG. 25B shows the virtual address space when barrier rise ends.
- FIG. 26 shows an example of an operation of invoking a signal handler to recover (reverse) the original pointer from the converted pointer according to the embodiment of the present invention.
- SIGSEGV indicates a segmentation violation signal.
- a code (2601) is a code for performing the operation indicated by reference numeral 2602. Memory references are represented in the following format: [base_reg_object_head, reg_offset / imm_offset]. The access to the object (CPU memory access instruction) is “ld / st reg, It must be in the format [base_reg_object_head, reg / imm_offset] ”(load / store, load destination register, [register containing pointer value, offset]). The code (2601) performs the following operation (see 2602).
- ⁇ Decode the instruction with 0xab04; Read r12 into memory r3; (r12 is base_reg_object_head) When the most significant 2 bits of r12 are set, If 0xab04 is associated with a pinning array slot, Get the original pointer from the pinning array slot, If not, The original pointer is obtained by shifting left from r12 by a number of 2 bits, and the original pointer is recovered from the barrier pointer as if the object is pointed to by the original pointer.
- FIG. 27 shows an example of a signal handler algorithm according to an embodiment of the present invention. Access via the barrier pointer always causes a hardware memory exception, which is converted into a signal by the OS.
- the algorithm of FIG. 27 shows a signal handler algorithm implemented in Java TM VM. The details of the algorithm will be described below.
- the OS passes to the signal handler the signal content that holds the exception code address, the exception data address, and the signal content of the register at the time of the hardware exception.
- the signal handler first checks whether the exception data address is in the read / write protected area by address comparison (line 2). If the exception data address is in the read / write protected area, the signal handler must recover a pointer to the head of the object being accessed (hereinafter referred to as the “header pointer”). A pointer to the inside of the object (hereinafter referred to as “internal pointer”) is not sufficient. This is because the signal handler must refer to the header of the object to determine whether to perform profiling or recovery (line 11).
- unvariable exception data addresses only generate internal pointers. If the Java TM VM supports a function for obtaining a header pointer from an internal pointer, that function can be used. Since there is generally no such support, it is necessary to limit the format of the object access instructions regardless of whether the object access instructions are code generated by a JIT compiler or interpreted code. This means that the register argument of the memory register must be a header pointer. For example, the format [base_reg, In the memory reference [offset_reg / immediate], base_reg must be a header pointer.
- a variable header header can be obtained by decompressing the object access instruction and loading the contents of base_reg into the memory from the signal contents (lines 6-8). This limitation is usually satisfied in existing Java TM VM and JIT compilers.
- this restriction can be broken when accessing large objects.
- loop derived variable optimization and strength reduction in the JIT compiler can result in an internal pointer to the array.
- the code generated by the JIT compiler is modified to maintain the header pointer in the method's register or in the stack slot.
- Many JIT compilers already support this feature to help GC traverse the root object. Without this support, the GC cannot mark or move the object pointed to by the internal pointer.
- the JIT compiler needs to be modified to associate each instruction that uses an internal pointer with the register number or stack offset that holds the header pointer. This allows the signal handler to obtain the header pointer from the exception code address (lines 3-4). Since most object access instructions do not use internal pointers, the associated data structure does not grow excessively.
- the signal handler After unvarializing the header pointer (line 10), the signal handler performs a recovery operation or profiling depending on the header of the object. Objects that need recovery have special bits set in their headers. For profiling, the signal handler records the access (line 16) and emulates the execution of an exception instruction (line 17). For example, emulating a load means performing a load instead of an exception load instruction and writing the loaded value to a target register in the signal content. The signal handler is not allowed to write the unvaried pointer to the base register and return the exception instruction and re-execute it. Using this approach, the next instruction using the unvaried pointer no longer causes a hardware exception, and thus some of the accesses to be profiled are missed. Unfortunately, this approach can change the semantics of the program. Because some objects are represented by two different pointer values, the pointer-imquality instruction causes the false to be returned even if the two objects refer to the same object. Therefore, signal handlers need to emulate exception instructions.
- FIG. 28 shows the experimental results regarding the relationship between the frequency of access to an object and the overhead according to the embodiment of the present invention.
- the case where there is almost no access to the object pointed to by the pointer is, for example, the case where the object is compressed (see FIG. 4), or the case where the object is delayed (see FIG. 5).
- the conventional persistent object database method it is necessary to perform a run-time check for all accesses of all objects.
- an exception handling overhead is applied only to access to the object pointed to by the pointer. Therefore, according to the embodiment of the present invention, overhead is reduced.
- FIG. 28 shows a graph of the results. From the graph, SPEC (Standard According to the compiler.compiler benchmark of Performance Evaluation Corporation) jvm2008, it can be seen that there is about 3% overhead when the number of bytes is 32 KB or 4 KB, but there is almost no overhead when the number of bytes is 64 MB or 4 MB.
- SPEC Standard According to the compiler.compiler benchmark of Performance Evaluation Corporation
- the object pointed to by the pointer is prepared as a compressed object (402) shown in FIG.
- SPECjbb2005 Java (trademark)
- FIG. Server Benchmark Benchmark program
- a string object (502) is prepared in which the object pointed to by the pointer is assigned in a delayed manner as shown in FIG.
- the string object (502) was used to execute the bloat benchmark program in the DaCapo benchmark on a computer that implements the method according to FIG. As a result, for the string object (502), the “bloat” benchmark was speeded up by 6%.
- the access location of the object can be known using the embodiment of the present invention. This is because, as shown in step 1503 of FIG. 15, the instruction address where the exception has occurred is known and is the access location of the object. Therefore, it is only necessary to recompile the program with the JIT compiler and perform a runtime check for only the access location.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Storage Device Security (AREA)
Abstract
Description
Machine)実装においてプログラム実行を通じて固定されている。当該固定されたオブジェクト・フォーマットは、例えばヘッダ及びデータ・フィールドのレイアウト、並びにそれらのサイズである。ここで、メモリー・フットプリント(メモリ使用量)、メモリ帯域幅、キャッシュ・ミス、ガーベジ・コレクション(GC)頻度、及びGCオーバーヘッドを減少させることが、上記プログラムを実行するコンピュータのコストを減少させる上で有用である。そこで、上記固定されたオブジェクト・フォーマット(以下、「通常のオブジェクト・フォーマット」又は「元のオブジェクト・フォーマット」ともいう)を、上記コストを減少させるように変形し、上記プログラムに適用可能な多くのオブジェクト・フォーマット(以下、「変形されたオブジェクト・フォーマット」ともいう)が開発されている(下記図4~図6を参照)。
コンピュータ(101)は、CPU(102)とメイン・メモリ(103)とを備えており、これらはバス(104)に接続されている。CPU(102)は好ましくは、32ビット又は64ビットのアーキテクチャに基づくものであり、例えば、インテル社のCore i(商標)シリーズ、Core 2(商標)シリーズ、Atom(商標)シリーズ、Xeon(商標)シリーズ、Pentium(登録商標)シリーズ、Celeron(登録商標)シリーズ、AMD社のPhenom(商標)シリーズ、Athlon(商標)シリーズ、Turion(商標)シリーズ又はSempron(商標)が使用されうる。バス(104)には、ディスプレイ・コントローラ(105)を介して、ディスプレイ(106)、例えば液晶ディスプレイ(LCD)が接続されうる。ディスプレイ(106)は、コンピュータの管理のために、通信回線を介してネットワークに接続されたコンピュータについての情報と、そのコンピュータ上で動作中のソフトウェアについての情報を、適当なグラフィック・インタフェースで表示するために使用される。バス(104)にはまた、SATA又はIDEコントローラ(107)を介して、記憶装置(108)、例えばハードディスク又はシリコン・ディスクと、ドライブ(109)、例えばCD、DVD又はBDドライブとが接続されうる。バス(104)にはさらに、キーボード・マウスコントローラ(110)又はUSBバス(図示せず)を介して、キーボード(111)及びマウス(112)が接続されうる。
ドライブ(109)は、必要に応じて、CD-ROM、DVD-ROM又はBDからプログラムを記憶装置(108)にインストールするために使用される。
コンピュータ(201)は、図1に示す例えばCPU(102)、メイン・メモリ(103)及び記憶装置(108)に加えて、変換部(211)、逆変換部(212)を備えている。コンピュータ(201)は、さらに、処理部(213)及び実行部(214)を備えうる。
本発明の1つの実施態様として、変換部(211)は、例えば、下記(1)~(3)に示す変換処理を行いうる。
(1)ポインタに一定のオフセット値を加えて、読み書き保護領域を指すポインタ(変換されたポインタ)を得る。
(2)オブジェクトへのポインタをnビット数分(nは整数である)右シフトし、そして一定のオフセット値を加えて、読み書き保護領域を指す(変換されたポインタ)を得る。
(3)オブジェクトへのポインタをnビット数分(nは整数である)右シフトし、そして空いた左(上位)ビットに読み書き保護領域のアドレスを埋め込んで、読み書き保護領域を指す(変換されたポインタ)を得る。
変換部(211)は、上記変換を、例えば、オブジェクトの割り付けにおいて、又は、ガーベジ・コレクションにおいて行う。
本発明の1つの実施態様として、逆変換部(212)は、上記例外が発生した命令を参照して、当該例外が発生した命令から、上記操作されたポインタを取得し、当該取得されたポインタを逆変換して、当該逆変換された元のポインタが指すオブジェクトの先頭へのポインタを取得する。
本発明の他の実施態様として、逆変換部(212)は、例外が発生した命令アドレスと、オブジェクトの先頭へのポインタ値を格納するスロット(ピンニング・アレイ・スロットともいう)のレジスタ又はスロット番号との対応表を参照して、当該例外が発生した命令アドレスから、前記操作されたポインタを取得し、当該取得されたポインタを逆変換して、当該逆変換された元のポインタが指すオブジェクトの先頭へのポインタを取得する。 本発明の他の実施態様として、逆変換部(212)は、
上記変換部(211)で行われた(1)~(3)に対応して、下記(1’)~(3’)に示す逆変換処理を行いうる。
(1’)上記(1)において変換されたポインタから一定のオフセット値を減じて、元のポインタを得る。
(2’)上記(2)において変換されたポインタから一定のオフセット値を減じ、そして上記(2)と同じnビット数分左シフトして、元のポインタを得る。
(3’)上記(3)において変換されたポインタを上記(3)と同じnビット数分左シフトして、元のポインタを得る。
「オブジェクト」は、プログラム上の抽象化された手続きの対象を具体化したものであり、プログラム中に記述されるオブジェクトの割り付け場所から生成されるオブジェクトである。「オブジェクト」は、プログラムの実行時に、メモリ内、例えばヒープ領域内に割り付けられる。「オブジェクト」は、例えばクラスから生成される。「オブジェクト」は、プログラムの実行が、例えば中断又は完了した場合であっても、ヒープ領域に存在しうる。ヒープ領域は、プログラムに使用されるヒープ領域全体ではなく、当該ヒープ領域全体の一部であって、オブジェクトが割り付けられる領域である。ヒープ領域は、例えば、GCの対象となるヒープ領域である。
圧縮により変形されるとは例えば、ある文字配列(character array(s))又はある部位に割り当てられた文字配列がアクセスされない傾向にあり且つそれら文字配列がアスキー(ASCII)文字列のみを含む場合に、当該文字配列が圧縮されうることをいう。オブジェクトの圧縮は、オブジェクト・アクセスの最適化をもたらす。
オブジェクト・フォーマット(401)は、ヘッダ(411)並びに、ヌル値のデータ・フィールド(412、414、416及び418)及びアスキーのデータ・フィールド(413、415、417及び419)を含む。オブジェクト・フォーマット(402)は、ヘッダ(421)及び、アスキーのデータ・フィールド(422~425)を含む。
ポインタを使用して文字配列を指定するとは例えば、ある部位に割り当てられた複数のストリング・オブジェクトがアクセスされない傾向にあり且つそれらストリング・オブジェクトが他のストリング・オブジェクトと連結されることによって生成される場合に、当該連結されうる文字配列がポインタを使用して文字配列を指定されることをいう。当該ポインタを使用する文字配列の割り当ては、遅延的に(lazily)生じうる。遅延割り当ては、オブジェクトが実際に必要とされるまで当該オブジェクトを割り当てないので、オブジェクト・アクセスの最適化をもたらす。
フィールド再配置とは例えば、オブジェクト中の2つ又はそれ以上のフィールドが同時にアクセスされる傾向にある場合に、当該2つ又はそれ以上のフィールドについてのデータキャッシュミスを減少させるために、当該2つ又はそれ以上のフィールドが同一場所に配置(co-locate)されることを示す。
オブジェクト・フォーマット(601)は、通常のフォーマットを示す。オブジェクト・フォーマット(602)は、オブジェクト・フォーマット(601)が変形された場合のフォーマットを示す。
オブジェクト・フォーマット(601)は、ヘッダ(611)及び、データ・フィールドを1~6(612~617)の順で含む。オブジェクト・フォーマット(602)は、ヘッダ(621)及び、データ・フィールドを1、6、3、4、5及び2(622~627)の順で含む。
データ・フィールド1(612)及びデータ・フィールド6(617)は、同時にアクセスされる傾向にあるとする。
オブジェクト・フォーマット(601)では、同時にアクセスされる傾向にあるデータ・フィールド1(612)及びデータ・フィールド6(617)が離れて存在している。そこで、変形されたオブジェクト・フォーマット(602)では、データ・フィールド1(622)に隣にデータ・フィールド6(623)が位置するように変形されている。変形されたオブジェクト・フォーマット(602)では、同時にアクセスされる傾向にあるデータ・フィールド1(622)及びデータ・フィールド6(623)が隣に位置するように変形されているので、メモリ・アクセスのコストを低減することが可能である。
永続的なオブジェクト・データベース方式によるオブジェクトへのアクセスは下記の特徴を有する:(1)オブジェクトへのアクセスの監視がページ単位である;(2)当該方式が向いているケースはページ単位でアクセスの局所性がある場合である;及び、(3)当該方式の適用分野は、主に、データベース及びディスクへの分野であり、特にスワッピング・アウト/又はスワッピング・インにおいてである。図7に示す永続的なオブジェクトへのアクセス方法は、例えば非特許文献3に示されている。
図7の下図では、ロードされたオブジェクトA(741)から指されているオブジェクトがまだロードされていない場合、コンピュータ(201)は、新たな読み書き保護ページ(703)を割り当てて、オブジェクトA(741)のポインタがその読み書き保護ページ(703)を指すようにすることを示す。同様に、図7の下図では、ロードされたオブジェクトC(743)から指されているオブジェクトがまだロードされていない場合、コンピュータ(201)は、新たな読み書き保護ページ(703)を割り当てて、オブジェクC(743)のポインタがその読み書き保護ページ(703)を指すようにすることを示す。
永続的なオブジェクト・データベース方式の特徴は上記において述べたとおりである。
本発明の実施態様に従う、オブジェクトへのアクセスは下記の特徴を有する:(1)オブジェクトへのアクセスの監視がページ単位でなく、個々のオブジェクト単位である;(2)当該方式が向いているケースはページ単位でアクセスの局所性がある場合でなく、ヒープ中に散らばっているオブジェクト毎に監視したい場合である;及び、(3)本発明の実施態様の適用分野は、主に、オブジェクト・アクセスのプロファイリング、オブジェクトの圧縮、オブジェクトの遅延割り付け、及びオブジェクトの再配置である。
オブジェクト(1001)に含まれるポインタ(1002)は、オブジェクトA(1005)へのポインタである。ポインタ(1002)は、変換前のポインタであり、通常、その下位2又は3ビット(1004)がゼロであり、それ以外のビットがアクセスされるべきオブジェクトのアドレス(1003)を示す。アドレス(1003)は例えば、オブジェクトA(1005)の先頭アドレスである。
本発明の実施態様に従うと、ポインタ(1002)の下位2又は3ビット(1004)がゼロであるという点を使用する。
仮想アドレス・スペース(1101)上に、Java(商標)ヒープ領域(1111)と、読み書き保護領域(1112)がある。元のポインタは矢印(1121)で示されており、バリア・ポインタは矢印(1122)で示されている。
図11の例では、読み書き保護領域(1112)が、Java(商標)ヒープ領域(1111)と同じアドレス・サイズになるように予約される。同じアドレス・サイズにすることによって、実装が簡単になる。バリアライズにおいて、Java(商標)ヒープ領域(1111)と読み書き保護領域(1112)との間の一定のオフセットがポインタに加えられる。一方、アンバリアライズにおいて、一定のオフセットが減じられる。当該オフセットは、Java(商標)VMの初期化の間及びプログラム実行の間を通じて一定である。ほとんどのOSは、読み書き保護された仮想アドレス領域を予約するためのシステム・コールを有している。ここで、読み書き保護領域(1112)は、実メモリの割り当てを要求しないことに留意されたい。最近のOSは、実メモリの内容がプログラムによって最初にアクセスされるまで実メモリを仮想ページに割り当てない。読み書き保護領域(1112)は例外を生じさせるためにのみ使用される。従って、読み書き保護領域(1112)の内容は、外部から決してアクセスされず且つ実メモリも要求されない。図11に示す場合において、もしJava(商標)ヒープ領域(1111)が動的に拡張されるのであれば、読み書き保護領域(1112)も同様に拡張されなければならない。しかし、一般にこの拡張が成功することは保証されない。それ故に、プログラムが実行を開始するときに、読み書き保護領域(1112)のサイズは、Java(商標)ヒープ領域(1111)の最大サイズと一致するようにする。なお、読み書き保護領域(1112)のサイズがJava(商標)ヒープ領域(1111)のサイズよりも小さくないようにしてもよい。
本発明の実施態様において、図11~図13に示すバリアライズ及びアンバリアライズの方式のうち、図11に示すバリアライズ及びアンバリアライズの方式が最も基本的な方式である。
仮想アドレス・スペース(1201)上に、Java(商標)ヒープ領域(1211)と、読み書き保護領域(1212)がある。元のポインタは矢印(1221)で示されており、バリア・ポインタは矢印(1222)で示されている。図12において使用されるオブジェクトは、例えば8バイト単位でアラインされている。一般的なCPUの設計では、例えば8バイトのデータを8バイト・アラインしていないアドレスから読もうとすると、オーバーヘッドがかかる。そこで、オブジェクトの先頭を8バイト・アラインしておけばオブジェクトの中のフィールドも8バイト・アラインされるのでアクセスに余計なオーバーヘッドがかからないからである。
図11の例では、読み書き保護領域(1112)のサイズは、Java(商標)ヒープ領域(1111)の最大サイズと一致又はそれよりも大きくするようにする。しかしながら、仮想アドレス・スペース(1101)は限られたリソースである。仮想アドレスにおける追加領域はまたトランスレーション・ルックアサイド・バッファ(TLB)ミスを増加させる。従って、読み書き保護領域をできるだけ小さくすることがよい。
Barrier_pointer=(Original_pointer - HEAP_BASE) >> 3 + PROTECTED_BASE
Barrier_pointer = Original_pointer >> 3 + CONSTANT;
CONSTANT = PROTECTED_BASE - HEAP_BASE >> 3
Barrier_pointer + Object_size <= PROTECTED_TOP
ここで、PROTECTED_TOPは、読み書き保護領域のトップ・アドレスである。
図13は、図12とは別の方法によって、読み書き保護領域のサイズを減少させる方法を示す。
図13の例では、仮想アドレス・スペース(1301)上に、Java(商標)ヒープ領域(1311)と、Linux(商標) OS領域(1312)がある。Linux(商標) OS領域(1312)は、OSに使用されるアドレス範囲であるので読み書き保護領域である。元のポインタは矢印(1321)で示されており、バリア・ポインタは矢印(1322)で示されている。
図13の例では、Linux(商標) OS領域(1312)がLinux(商標) OSプログラムの仕様に従い、仮想アドレス・スペース(1301)の4分の1を占めており、且つOxC0...000から開始する。このLinux(商標) OS領域(1312)にユーザはアクセスすることができない。バリアライズにおいて、ポインタのnビット数分右シフトされ、空いた2ビットにLinux(商標) OS領域(1312)の先頭を指すアドレスが設定される(図13の例の場合、11である)。一方、アンバリアライズにおいて、ポインタのnビット分が左シフトされる。Java(商標)VMはユーザ・スペース中に読み書き保護領域を予約する必要がない。例えば、32ビットWindows(商標)において、当該OSは典型的に仮想アドレス・スペースの2分の1又は4分の1を予約する。例えば、32ビットAIXにおいて、当該OSは典型的に、4GBの仮想アドレス・スペースの16分の1を占める。このことは、Java(商標)VMが読み書き保護領域を予約するために他の場所において256MBで予約しうることを意味する。バリアライズは、図11の例と同様に、オブジェクトの割り付けにおいて、又はGCにおいて行われる。
ステップ1401では、コンピュータ(201)は、オブジェクトへのアクセスを検出するアルゴリズムを開始する。
load(ロード),ロード先レジスタ,[ポインタ値の入っているレジスタ,オフセット]
load(ロード),ロード先レジスタ,[オブジェクトの先頭へのポインタ値の入っているレジスタ,オフセット]
図14のアルゴリズムでは、逆変換部(212)によって実行されるステップ1405において、[オブジェクトの先頭へのポインタ値の入っているレジスタ,オフセット](式5を参照)という式を使用してアンバリアライズを行い、元のオブジェクトの先頭へのポインタ値が得られることを説明した。しかしながら、このような形式にできないオブジェクト・アクセスがありうる。特に、配列オブジェクトへのアクセスにおいて顕著である。そこで、配列オブジェクトへのアクセスがある場合に、本アルゴリズムを使用しうる。なお、図15のアルゴリズムはステップ1504及び1507を有している点で図14のアルゴリズムと異なり、ステップ1508~1509を経由する場合に図14に対応する処理(すなわち、ピンニング・アレイ・スロットを使用しない態様)が行われる。
配列オブジェクトへのアクセスは、下記式6~8で表される命令列になりうる。
レジスタX=配列オブジェクトの先頭へのポインタ値
レジスタX=レジスタX+インデックス
ロード(load),ロード先レジスタ,[レジスタX,オフセット]
レジスタX=配列オブジェクトの先頭へのポインタ値
pinning_array_slot=レジスタ
レジスタX=レジスタX+インデックス
ロード(load),ロード先レジスタ,[レジスタX,オフセット]
ステップ1501では、コンピュータ(201)は、シグナル・ハンドラを使用して、メモリ・アクセス例外を処理するアルゴリズムを開始する。当該アルゴリズムの開始後に、読み書き保護領域へのアクセスで例外が起きて、シグナル・ハンドラが呼び出され、そして当該シグナル・ハンドラが実行される。
図16のステップ1601~1604は、図14のステップ1402において行われる処理の一つの実施態様である。
ステップ1601では、コンピュータ(201)は、バリアライズを開始する。
ステップ1602では、コンピュータ(201)は、ヒープメモリにオブジェクトを割り付ける。上記オブジェクトが割り付けられた直後において、当該割り付けられたオブジェクトを指すポインタは1つだけである。
ステップ1603では、コンピュータ(201)は、上記オブジェクトが割り付けられた直後において、上記ポインタを読み書き保護領域を指すように変換する。
ステップ1604では、コンピュータ(201)は、上記逆変換の終了に応じて、上記アルゴリズムを終了する。
図17のステップ1701~1710は、図14のステップ1402において行われる処理の一つの実施態様である。
ステップ1701では、コンピュータ(201)は、バリアライズを開始する。
ステップ1702では、コンピュータ(201)は、ポインタへのポインタを保存するための集合Sを空にする。
ステップ1703では、コンピュータ(201)は、レジスタ又はスタックなどのGCのルート集合を上記集合Sに追加する。
ステップ1704では、コンピュータ(201)は、集合Sに要素が入っているかどうかを検査する。集合Sに要素が入っている場合、当該処理はステップ1705に進む。一方、集合Sに要素が入っていない場合、当該処理はステップ1706に進む。
ステップ1705では、コンピュータ(201)は、集合Sに要素が入っていることに応じて、集合Sから要素を1つ取り出す。この取り出した要素を要素Pと名付ける。要素Pはポインタへのポインタである。
ステップ1706では、コンピュータ(201)は、集合Sに要素が入っていないことに応じて、上記アルゴリズムを終了する。
ステップ1707では、コンピュータ(201)は、要素Pが指す先のポインタが指す先のオブジェクト・フォーマットが変形されたオブジェクト・フォーマットであるかどうかを検査する。上記変形されたフォーマットである場合、当該処理はステップ1708に進む。一方、上記変形されたフォーマットでない場合、当該処理はステップ1709に進む。
ステップ1708では、コンピュータ(201)は、要素Pが指す先のポインタが指す先のオブジェクト・フォーマットが、変形されたオブジェクト・フォーマットであることに応じて、要素Pが指す先のポインタを、読み書き保護領域を指すように変換して、Pが指す先のメモリに格納する。ステップ1708は、GCにおいてバリアライズするステップである。
ステップ1709では、コンピュータ(201)は、要素Pが指す先のポインタが指す先のオブジェクトQをGCのルーチンで処理する。当該GCのルーチンは、典型的にはオブジェクトQを生きていると見なして、当該オブジェクトQにマーク付けをする。
ステップ1710では、コンピュータ(201)は、オブジェクトQの中のポインタ・フィールド(例えば、図3の322)へのポインタを集合Sに追加する。
コンピュータ(201)のメモリ上に仮想アドレス・スペース(1801)がある。仮想アドレス・スペース(1801)上に、読み書き保護領域(1802)及びスレッドのスタック領域(1803)がある。読み書き保護領域(1802)には、実メモリが割り付けられていない。スレッドのスタック領域(1803)は、GCのルート集合の一部である。
また、スレッドのスタック領域中のポインタ(1831)は、オブジェクトX(1811)の先頭アドレスを指す。
ステップ1703では、コンピュータ(201)は、GCのルート集合が集合Sに加えられることから、オブジェクトXを指す、スタック領域中のポインタを指すポインタ値(000000)を集合Sに追加する(図19B)。
ステップ1705では、コンピュータ(201)は、集合Sから要素Pを取り出すことから、オブジェクトXを指す、スタック領域中のポインタを指すポインタ値(000000)を集合Sから取り出す(図20B)。
ステップ1710では、コンピュータ(201)は、オブジェクトXの中のポインタ・フィールドへのポインタを集合Sに追加する(図21B)。すなわち、コンピュータ(201)は、オブジェクトYを指す、オブジェクトXの中のポインタを指すポインタ値(001000)、及び、オブジェクトAを指す、オブジェクトXの中のポインタを指すポインタ値(001100)を、集合Sに追加する。そして、コンピュータ(201)は、要素Pをクリアにする。なお、図21AのオブジェクトXは、図17のステップ1710でいうオブジェクトQに対応する。
ステップ1705では、コンピュータ(201)は、集合Sから要素P(ここでは、オブジェクトYを指す、オブジェクトXの中のポインタを指すポインタ値(001000))を取り出すことから、オブジェクトYを指す、オブジェクトXの中のポインタを指すポインタ値(001000)を集合Sから取り出す。そして、ステップ1710では、コンピュータ(201)は、オブジェクトYの中のポインタ・フィールドへのポインタを集合Sに追加し、要素Pをクリアする(図22B)。すなわち、コンピュータ(201)は、オブジェクトAを指す、オブジェクトYの中のポインタを指すポインタ値(011100)を、集合Sに追加し、且つ、要素P(オブジェクトYを指す、オブジェクトXの中のポインタを指すポインタ値(001000))をクリアする。なお、図22AのオブジェクトYは、図17のステップ1710でいうオブジェクトQに対応する。
ステップ1705では、コンピュータ(201)は、集合Sから要素P(ここでは、オブジェクトAを指す、オブジェクトXの中のポインタを指すポインタ値(001100))を取り出すことから、オブジェクトAを指す、オブジェクトXの中のポインタを指すポインタ値(001100)を集合Sから取り出す。そして、ステップ1708では、コンピュータ(201)は、オブジェクトAを指す、オブジェクトXの中のポインタ(100000)を書き換えて(右へ2ビット数分シフトし、空きビットへ11を追加する)、バリア・ポインタ(111000)に変換する。そして、ステップ1710では、コンピュータ(201)は、要素Pをクリアする。なお、図23AのオブジェクトAは、図17のステップ1710でいうオブジェクトQに対応する。
ステップ1705では、コンピュータ(201)は、集合Sから要素P(ここでは、オブジェクトAを指す、オブジェクトYの中のポインタを指すポインタ値(011100))を取り出すことから、オブジェクトAを指す、オブジェクトYの中のポインタを指すポインタ値(011100)を集合Sから取り出す。そして、ステップ1708では、コンピュータ(201)は、オブジェクトAを指す、オブジェクトYの中のポインタ(100000)を書き換えて(右へ2ビット数分シフトし、空きビットへ11を追加する)、バリア・ポインタ(111000)に変換する。そして、ステップ1710では、コンピュータ(201)は、要素Pをクリアする。なお、図24AのオブジェクトAは、図17のステップ1710でいうオブジェクトQに対応する。
ステップ1710では、コンピュータ(201)は、要素Pをクリアにする。そしてステップ1704に戻り、コンピュータ(201)は、集合Sに要素が入っていないので、処理をステップ1706に進めて、終了する。図25Bは、バリアライズが終了した際の仮想アドレス・スペースを示す。
SIGSEGVは、セグメンテーション違反シグナルを示す。
コード(2601)は、符号2602に示されている操作を行うコードである。メモリ参照は、下記のフォーマットで表される:[base_reg_object_head,
reg_offset/imm_offset]。また、オブジェクトへのアクセス(CPUのメモリへのアクセス命令)は、“ld/st reg,
[base_reg_object_head, reg/imm_offset]”(ロード/ストア,ロード先レジスタ,[ポインタ値の入っているレジスタ,オフセット])のフォーマットでなければならない。
コード(2601)は、下記に示す内容の動作を行う(2602を参照)。
・命令を0×ab04でデコードする;
・r12をメモリr3に読み込む;(r12はbase_reg_object_headである)
・r12の最上位の2ビットが設定される場合であって、
0xab04がピンニング・アレイ・スロットに関連付けられている場合、
元のポインタをピンニング・アレイ・スロットから取得し、
関連付けられていない場合、
元のポインタを、r12から2ビット数分だけ左シフトすることによって取得し、 そして、オブジェクトが元のポインタによって指されているようにバリア・ポインタから元のポインタを回復する。
OSは、例外コード・アドレス、例外データ・アドレス、及びハードウェア例外の時間でのレジスタのシグナル内容を保持するシグナル内容をシグナル・ハンドラに渡す。シグナル・ハンドラは、まず、例外データ・アドレスが、アドレス比較によって読み書き保護領域内にあるかどうかをチェックする(行2)。例外データ・アドレスが読み書き保護領域内にある場合、シグナル・ハンドラは、アクセスされるオブジェクトのヘッドへのポインタ(以下、「ヘッダ・ポインタ」という)を回復させなければならない。オブジェクトの内部へのポインタ(以下、「内部ポインタ」という)は十分でない。なぜならば、シグナル・ハンドラはプロファイリング又はリカバリを実行するかどうかを決定するために、オブジェクトのヘッダを参照しなければならないからである(行11)。一般的に、例外データ・アドレスをアンバリアライズすることは内部ポインタを生成するのみである。もしJava(商標)VMが内部ポインタからヘッダ・ポインタを得るための機能をサポートするならば、当該機能が使用されうる。一般的にそのようなサポートがないので、オブジェクト・アクセス命令がJITコンパイラにより生成されたコード又はインタープリタ・コードであるかどうかにかかわらず、オブジェクト・アクセス命令のフォーマットを制限する必要がある。このことは、メモリ・レジスタのレジスタ引数がヘッダ・ポインタでなければならないことを意味する。例えば、形式[base_reg,
offset_reg/immediate]のメモリ参照において、base_regは、ヘッダ・ポインタでなければならない。次に、オブジェクト・アクセス命令を伸長し、且つシグナル内容からbase_regの内容をメモリ内にロードすることによってバリアライズされたヘッダ・ポインタが得られうる(行6~8)。この制限は、既存のJava(商標)VM及びJITコンパイラにおいて通常満足される。
ヘッダ・ポインタのアンバリアライズ後に(行10)、シグナル・ハンドラは、オブジェクトのヘッダに依存して回復操作又はプロファイリングを実行する。回復を必要とするオブジェクトはそれらのヘッダに設定されている特別なビットを有する。プロファイリングのために、シグナル・ハンドラは、アクセスを記録し(行16)及び例外命令の実行をエミュレートする(行17)。例えばロードをエミュレートすることは、例外ロード命令の代わりにロードを実行し、そしてロードされた値をシグナル内容中のターゲット・レジスタに書き込むことを意味する。シグナル・ハンドラは、ベース・レジスタにアンバリアライズされたポインタを書き込むこと、そして例外命令を戻してそれを再実行することを許されていない。このアプローチを使用して、アンバリアライズされたポインタを使用する次の命令がハードウェア例外をもはや生じさせず、従ってプロファイルされるべきアクセスの幾つかをミスされることを生じさせる。悪いことに、このアプローチはプログラムのセマンティクスを変化させうる。なぜならば、幾つかのオブジェクトは、2つの異なるポインタ値によって表され、ポインタ・イクオリティ命令が、2つのオブジェクトが同じオブジェクトを参照している場合でさえもファールスを戻すことを生じさせる。それ故に、シグナル・ハンドラは例外命令をエミュレートすることが必要である。
ポインタが指すオブジェクトにほとんどアクセスがないことを仮定した最適化の場合を考える。ポインタが指すオブジェクトにほとんどアクセスがない場合とは、例えば、当該オブジェクトが圧縮されている場合(図4を参照)、又はオブジェクトが遅延割り付けされる場合(図5を参照)である。従来技術である永続的なオブジェクト・データベース方式では、全てのオブジェクトの全アクセスにおいて実行時チェックをする必要がある。一方、本願発明の実施態様に従うと、ポインタが指すオブジェクトへのアクセスでのみ例外処理のオーバーヘッドがかかる。従って、本願発明の実施態様に従うと、オーバーヘッドが低減される。
実験は、Nバイトのオブジェクトを割り付けるごとに1オブジェクトをアクセス監視の対象とした。なお、監視対象であるオブジェクトに頻繁にアクセスがあるものとする。当該実験は、Linux(商標) p6 4.7GHz×16上でIBM(商標)ppc-32 J9/TR Java(登録商標)6(SR6)を使用して行われた。図28は、その結果のグラフを示す。グラフから、SPEC(Standard
Performance Evaluation Corporation)jvm2008のcompiler.compilerベンチマークに従うと、バイト数が32KB又は4KBにおいてオーバーヘッドが3%程度存在するが、バイト数が64MB又は4MBにおいてはオーバーヘッドがほとんど存在しないことがわかる。
Server Benchmark)ベンチマーク・プログラムを実行した。その結果、割り当て時に圧縮されたオブジェクト(402)を割り当てる手法により、SPECjbb2005のベンチマーク値が6.8%改善された。
Claims (20)
- コンピュータ処理において、オブジェクトへのアクセスを検出する方法であって、当該コンピュータが、
当該オブジェクトへのポインタを操作して、当該ポインタを読み書き保護領域を指すポインタに変換するステップと、
前記読み書き保護領域へのアクセス要求に応じて例外が発生することを利用して、前記変換されたポインタから元のポインタへ逆変換するステップと
を実行することを含む、前記方法。 - 前記逆変換するステップが、
前記例外が発生した命令を参照して、当該例外が発生した命令から、前記操作されたポインタを取得するステップと、
前記取得されたポインタを逆変換して、当該逆変換された元のポインタが指すオブジェクトの先頭へのポインタを取得するステップと
を含む、請求項1に記載の方法。 - 前記コンピュータが、
前記逆変換された元のポインタが指すオブジェクトのヘッダ情報を参照して、当該逆変換された元のポインタが指すオブジェクトのフォーマットに適した処理をするステップ
をさらに実行することを含む、請求項2に記載の方法。 - 前記コンピュータが、
前記フォーマットに適した処理を行った後に、前記逆変換された元のポインタが指すオブジェクトにアクセスするステップ
をさらに実行することを含む、請求項3に記載の方法。 - 前記フォーマットに適した処理が、圧縮オブジェクトの伸長、又は、文字配列の遅延割り当てである、請求項3に記載の方法。
- 前記変換するステップが、ポインタに一定のオフセット値を加えて、前記読み書き保護領域を指すポインタを得るステップを含む、請求項1に記載の方法。
- 前記逆変換するステップが、前記変換されたポインタから一定のオフセット値を減じて、前記元のポインタを得るステップを含む、請求項6に記載の方法。
- 前記変換するステップが、前記オブジェクトへの前記ポインタをnビット数分(nは整数である)右シフトし、そして一定のオフセット値を加えて、前記読み書き保護領域を指すポインタを得るステップを含む、請求項1に記載の方法。
- 前記逆変換するステップが、前記変換されたポインタから一定のオフセット値を減じ、そして前記nビット数分左シフトして、前記元のポインタを得るステップを含む、請求項8に記載の方法。
- 前記読み書き保護領域が、オペレーティング・システムの保護領域である、請求項1に記載の方法。
- 前記変換するステップが、前記オブジェクトへの前記ポインタをnビット数分(nは整数である)右シフトし、そして空いた左ビットに読み書き保護領域のアドレスを埋め込んで、前記読み書き保護領域を指すポインタを得るステップを含む、請求項1に記載の方法。
- 前記逆変換するステップが、前記変換されたポインタを前記nビット数分左シフトして、前記元のポインタを得るステップを含む、請求項11に記載の方法。
- 前記逆変換するステップが、
前記例外が発生した命令アドレスと、オブジェクトの先頭へのポインタ値を格納するスロットのレジスタ又はスロット番号との対応表を参照して、当該例外が発生した命令アドレスから、前記操作されたポインタを取得するステップと、
前記取得されたポインタを逆変換して、当該逆変換された元のポインタが指すオブジェクトの先頭へのポインタを取得するステップを含む、請求項1に記載の方法。 - 前記変換するステップが、オブジェクトの割り付けにおいて、又は、ガーベジ・コレクションにおいて行われる、請求項1に記載の方法。
- 前記例外の発生が、セグメンテーション違反の発生である、請求項1に記載の方法。
- 前記例外の発生によりシグナル・ハンドラが起動し、当該シグナル・ハンドラを使用して、前記逆変換するステップが実行される、請求項1に記載の方法。
- オブジェクトへのアクセスを検出するコンピュータであって、
当該オブジェクトへのポインタを操作して、当該ポインタを読み書き保護領域を指すポインタに変換する変換部と、
前記読み書き保護領域へのアクセス要求に応じて例外が発生することを利用して、前記変換されたポインタから元のポインタへ逆変換する逆変換部と
を備えている、前記コンピュータ。 - 前記変換部が、さらに、前記例外が発生した命令を参照して、当該例外が発生した命令から、前記操作されたポインタを取得し、当該取得されたポインタを逆変換して、当該逆変換された元のポインタが指すオブジェクトの先頭へのポインタを取得し、
前記コンピュータが、
前記逆変換された元のポインタが指すオブジェクトのヘッダ情報を参照して、当該逆変換された元のポインタが指すオブジェクトのフォーマットに適した処理をする処理部をさらに備えている、請求項17に記載のコンピュータ。 - 前記フォーマットに適した処理を行った後に、前記逆変換された元のポインタが指すオブジェクトにアクセスする実行部をさらに備えている、請求項18に記載のコンピュータ。
- コンピュータに、請求項1~16のいずれか一項に記載の方法の各ステップを実行させるコンピュータ・プログラム。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
DE112011103536T DE112011103536T5 (de) | 2010-10-20 | 2011-08-29 | Verfahren zum Erkennen von Zugriffen auf ein Objekt und Computer und Computerprogrammprodukt für selbiges |
GB1307566.8A GB2498484A (en) | 2010-10-20 | 2011-08-29 | Method for detecting access of an object, computer thereof, and computer program |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010-235841 | 2010-10-20 | ||
JP2010235841 | 2010-10-20 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2012053284A1 true WO2012053284A1 (ja) | 2012-04-26 |
Family
ID=45973966
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/JP2011/069484 WO2012053284A1 (ja) | 2010-10-20 | 2011-08-29 | オブジェクトへのアクセスを検出する方法、並びにそのコンピュータ及びコンピュータ・プログラム |
Country Status (4)
Country | Link |
---|---|
US (1) | US20120102284A1 (ja) |
DE (1) | DE112011103536T5 (ja) |
GB (1) | GB2498484A (ja) |
WO (1) | WO2012053284A1 (ja) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2016068981A1 (en) * | 2014-10-31 | 2016-05-06 | Hewlett Packard Enterprise Development Lp | Systems and methods for restricting write access to non-volatile memory |
US9584696B2 (en) * | 2015-03-24 | 2017-02-28 | Semiconductor Components Industries, Llc | Imaging systems with embedded data transmission capabilities |
US10452288B2 (en) | 2017-01-19 | 2019-10-22 | International Business Machines Corporation | Identifying processor attributes based on detecting a guarded storage event |
US10579377B2 (en) | 2017-01-19 | 2020-03-03 | International Business Machines Corporation | Guarded storage event handling during transactional execution |
US10496292B2 (en) | 2017-01-19 | 2019-12-03 | International Business Machines Corporation | Saving/restoring guarded storage controls in a virtualized environment |
US10725685B2 (en) | 2017-01-19 | 2020-07-28 | International Business Machines Corporation | Load logical and shift guarded instruction |
US10496311B2 (en) * | 2017-01-19 | 2019-12-03 | International Business Machines Corporation | Run-time instrumentation of guarded storage event processing |
US10732858B2 (en) | 2017-01-19 | 2020-08-04 | International Business Machines Corporation | Loading and storing controls regulating the operation of a guarded storage facility |
US10353707B2 (en) | 2017-07-12 | 2019-07-16 | International Business Machines Corporation | Efficient pointer load and format |
US11573793B2 (en) * | 2020-03-18 | 2023-02-07 | Oracle International Corporation | Lazy push strategies for vectorized D-Heaps |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5845331A (en) * | 1994-09-28 | 1998-12-01 | Massachusetts Institute Of Technology | Memory system including guarded pointers |
JP2000066904A (ja) | 1998-08-21 | 2000-03-03 | Canon Inc | マルチタスク制御方法及び記憶媒体 |
US7870553B2 (en) * | 2003-08-28 | 2011-01-11 | Mips Technologies, Inc. | Symmetric multiprocessor operating system for execution on non-independent lightweight thread contexts |
US7702663B2 (en) * | 2004-01-05 | 2010-04-20 | International Business Machines Corporation | Breaking read barrier to apply optimizations |
US7313566B1 (en) * | 2004-12-23 | 2007-12-25 | Sun Microsystems, Inc. | Method and apparatus for isolating selected heap objects using a faulting address trap |
US7979394B2 (en) * | 2005-09-20 | 2011-07-12 | Teradata Us, Inc. | Method of managing storage and retrieval of data objects |
JP2010015223A (ja) | 2008-07-01 | 2010-01-21 | Internatl Business Mach Corp <Ibm> | メモリ領域中のオブジェクトを隔離するための方法 |
-
2011
- 2011-08-29 GB GB1307566.8A patent/GB2498484A/en not_active Withdrawn
- 2011-08-29 DE DE112011103536T patent/DE112011103536T5/de not_active Withdrawn
- 2011-08-29 WO PCT/JP2011/069484 patent/WO2012053284A1/ja active Application Filing
- 2011-10-17 US US13/274,981 patent/US20120102284A1/en not_active Abandoned
Non-Patent Citations (3)
Title |
---|
J.B. SARTOR ET AL.: "No bit left behind: the limits of heap data compression", PROCEEDING ISMM '08 PROCEEDINGS OF THE 7TH INTERNATIONAL SYMPOSIUM ON MEMORY MANAGEMENT, 2008, pages 111 - 120, Retrieved from the Internet <URL:http://dl.acm.org/citation.cfm?id=1375634.1375651&coll=DL&dl=ACM&CFID=54243151&CFTOKEN=47381469> [retrieved on 20111118] * |
MIKI WATANABE ET AL.: "Database Engine Design Issues for Java", IPSJ SIG NOTES, vol. 97, no. 64, 14 July 1997 (1997-07-14), pages 125 - 130 * |
SHINJI SUZUKI ET AL.: "The implementation of a persistent programming language P3L", IPSJ SIG NOTES, vol. 92, no. 61, 23 July 1992 (1992-07-23), pages 69 - 77 * |
Also Published As
Publication number | Publication date |
---|---|
DE112011103536T5 (de) | 2013-08-01 |
GB201307566D0 (en) | 2013-06-12 |
US20120102284A1 (en) | 2012-04-26 |
GB2498484A (en) | 2013-07-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2012053284A1 (ja) | オブジェクトへのアクセスを検出する方法、並びにそのコンピュータ及びコンピュータ・プログラム | |
EP3143500B1 (en) | Handling value types | |
JP5147280B2 (ja) | 異機種マルチプロセッサ・システムにおけるガーベッジ・コレクションのためのシステムおよび方法 | |
JP6764485B2 (ja) | ページ・フォールト解決法 | |
US6134601A (en) | Computer resource management system | |
US8024505B2 (en) | System and method for optimistic creation of thread local objects in a virtual machine environment | |
US20140181359A1 (en) | Information processing apparatus and method of collecting memory dump | |
US7506096B1 (en) | Memory segment emulation model for virtual machine | |
JP2008041088A (ja) | 大容量仮想メモリ・ページにおける保護帯域 | |
US20150058381A1 (en) | System and method for dynamically selecting a garbage collection algorithm based on the contents of heap regions | |
JP5031470B2 (ja) | メモリ管理方法、情報処理装置及びメモリ管理プログラム | |
JP2015519646A (ja) | マルチテナント型アプリケーション・ドメイン及びメモリの管理を伴う修正されたjvm | |
EP3278229B1 (en) | Compressed pages having data and compression metadata | |
US8327111B2 (en) | Method, system and computer program product for batched virtual memory remapping for efficient garbage collection of large object areas | |
JP5588072B2 (ja) | メモリ割り当て方法、プログラム、及びシステム | |
US9734620B2 (en) | Apparatus and method for graphics state management | |
JP5255049B2 (ja) | データをキャッシュ・メモリにプリフェッチする方法、コンピュータ・プログラム、及びシステム | |
JP2009282774A (ja) | エミュレーションプログラム、エミュレーション装置およびエミュレーション方法 | |
US8151086B2 (en) | Early detection of an access to de-allocated memory | |
US8479182B2 (en) | Program, apparatus, and method of optimizing a java object | |
AU2018205196B2 (en) | Lock free streaming of executable code data | |
US8732442B2 (en) | Method and system for hardware-based security of object references | |
JP5246014B2 (ja) | 仮想化プログラム、仮想化処理方法及び装置 | |
KR20080067144A (ko) | 효율적인 메모리 사용을 위한 스택 관리 장치 및 방법 | |
JP2022093083A (ja) | 情報処理装置及び制御プログラム |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 11834126 Country of ref document: EP Kind code of ref document: A1 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 1120111035365 Country of ref document: DE Ref document number: 112011103536 Country of ref document: DE |
|
ENP | Entry into the national phase |
Ref document number: 1307566 Country of ref document: GB Kind code of ref document: A Free format text: PCT FILING DATE = 20110829 |
|
WWE | Wipo information: entry into national phase |
Ref document number: 1307566.8 Country of ref document: GB |
|
NENP | Non-entry into the national phase |
Ref country code: JP |
|
ENPC | Correction to former announcement of entry into national phase, pct application did not enter into the national phase |
Ref country code: GB |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 11834126 Country of ref document: EP Kind code of ref document: A1 |