The present invention relates to systems and methods for maintaining the correctness of pointers. More specifically, the invention relates to systems and methods for maintaining the correctness of pointers from a managed heap to off-heap memory.
When a class redefinition occurs at runtime, a memory address of native memory for the class and its methods may change. When using a Java programming language, objects will not reference native data structures such as a J9Class and J9Method. In some cases, it is possible to maintain bidirectional pointers between the native memory and the Java heap. However, Direct MethodHandles are an exception, as Direct MethodHandles need to store the memory address of the J9Method it represents. Further, there may be multiple Direct MethodHandles referencing the same method. This makes a bidirectional pointer a suboptimal solution, as the native structure would have to maintain the accuracy of a set of pointers to the on-heap data structures, which includes updating on every garbage collection. A complete heap scan for objects that are known to have off-heap pointers is thus generally required. Such a scan of the entire heap for these objects is slow and requires significant computational resources.
An embodiment of the present invention elates to a method, and associated computer system and computer program product, for maintaining correctness of pointers from a managed heap to off-heap memory. One or more processors of a computer system store in a cache a first heap object in a managed heap that holds at least one off-heap pointer pointing to a first off-heap data structure, and create a weak reference node linked to the first heap object such that the first heap object not kept alive by the weak reference node during garbage collection.
Although certain embodiments are shown and described in detail, it should be understood that various changes and modifications may be made without departing from the scope of the appended claims. The scope of the present disclosure will in no way be limited to the number of constituting components, the materials thereof, the shapes thereof, the relative arrangement thereof, etc., and are disclosed simply as an example of embodiments of the present disclosure. A more complete understanding of the present embodiments and advantages thereof may be acquired by referring to the following description taken in conjunction with the accompanying drawings, in which like reference numbers indicate like features.
As a preface to the detailed description, it should be noted that, as used in this specification and the appended claims, the singular forms “a”, “an” and “the” include plural referents, unless the context clearly dictates otherwise.
The runtime system 120 is shown having a stack 130 with a frame 132 within the stack 130. The stack 130 may be a software stack that provides a basis to place the stack frame 132 on the stack. The stack frame 132 may be an object, method, frames and/or other data structures located on the stack 130. The stack may further provide a basis to remove the stack frame 132. The objects, data structures or frame 132 may further reference objects or data structures in other areas of the runtime system 120, such as a heap memory location 140. Thus, the frames 132 of the stack 130 may include pointers (not shown) to objects in the heap memory location 140.
The heap memory location 140 is further located in the runtime system 120, containing one or more objects 142. The stack frames 132 may contain references to the one or more objects 142. The one or more objects 142 may be many objects located in the heap memory location 140, some or all of which may be referenced by the frames 132 on the stack 130. The heap memory location 140 may be a location whereby memory is allocated during the runtime, rather than prior. The heap memory location 140 may be a global memory pool, dynamic memory allocation resource, or the like. The heap may be a managed heap, in one embodiment.
The runtime system 120 further includes a native memory location 150. The native memory location 150 is shown including a first data structure 152 and a second data structure 154. The native memory location 150 may be a memory location that provides memory tot the runtime system 120 by the operating system, for example. The native memory location 150 may be used for heap storage and other purposes. The one or more objects 142 stored in the heap memory location 140 may contain pointers or references to data structures in the native memory location 150, such as the first data structure 152 and the second data structure 154. Likewise, the data structures of the native memory locations 150 may point to or reference objects of the heap memory location 140 such as the one or more objects 142.
The runtime system 120 is shown further including a garbage collector 160. The garbage collector 160 may be an automatic memory management system. The garbage collector 160 may be configured to reclaim memory occupied by objects, data structures or the like that are no longer in use by the program. For example, if a structure being pointed to by a data object has been deleted off the stack 130, the data object is no longer in use by the program and the garbage collector 160 may remove this data object from the heap memory location, for example 140. Thus, the garbage collector 160 may be configured to reclaim this memory from the heap memory location 140, for example. The garbage collector 160 may not be configured to collect memory from the native memory location 150.
The first off-heap data structure 154 and the second off-heap data structure 155 may be related data structures. As shown by way of exemplification, the second data structure 152 (the J9Class data structure) contains a pointer to the first data structure 154 (the J9Method data structure). Further, the Direct Method Handle first heap object 144 includes or otherwise maintains a pointer to the first off-heap data structure 154 (the J9Method data structure). Additionally, the second off-heap data structure 152 (the J9Class data structure) may maintain a pointer to the java.lang.Class second heap object 142. Similarly, the second heap object 142 (java.lang.Class) may maintain a pointer to the second off heap data structure 152 (the J9Class data structure). A bi-directional pointer may exist between the second heap object 142 (java.lang.Class) and the second off heap data structure 152 (the J9Class data structure).
In order to maintain the correctness of the pointer from the first heap object 144 to the first off-heap data structure 154 when a redefinition occurs that changes the memory address of the first off-heap data structure 154, the runtime system 120 may be configured to store the first heap object 144 that holds the unmanaged pointer to the first off-heap data structure 154 in a cache. In the embodiment shown, the cache where the first heap object 144 is stored may be in field of the second data object 142. The first heap object 144 may be placed in the cache at the time the first heap object 144 is constructed, at the time the second heap object 142 is constructed, or when the off-heap pointer of the first heap object 144 is written. The cache may only contain elements of a specific type in order to ensure that it is known which fields are off-heap pointers within the cache. To support multiple object types, multiple caches may be added.
The cache or caches created by the runtime system 120 in accordance with the above may create a live reference to the heap object. To allow the object to be properly collected by a garbage collector, the runtime system 120 may create a linked list of weak reference nodes 145, 146 in the heap memory location 140. The garbage collector 160 is configured to not treat the weak Reference's object reference as live, thereby allowing proper garbage collection by the garbage collector 160. Thus, the garbage collector 160 may be configured to collect garbage within sub-section 148 of the heap memory location 140.
When an event occurs that will invalidate the off-heap pointer between the first heap object 144 and the first off-heap data structure 154, the runtime system 120 may be configured to perform one or more of several steps. First, the runtime system 120 may determine a new address of the first off-heap data structure. Thus, the runtime system 120 may understand the old and new address of the first off-heap data structure 154. The runtime system 120 may be configured to traverse the cache of objects that have pointers to off-heap data structures, such as the cache of the second heap object 142 The runtime system 120 may be configured to check whether any of the objects in the cache requires updating by comparing against the old off-heap memory address of the first off-heap data structure 154. The runtime system 120 may be configured to update the off-heap memory pointers as necessary, such as the off heap pointer from the first heap object 144 to the first off-heap data structure 154.
The runtime system 120 may further be configured to remove the weak reference node linked to the first heap object. The removing may be configured to occur during the creating another weak reference node linked to a heap object such as the first heap object or another heap object stored in the cache or another cache. Alternatively or additionally, the removal of weak reference nodes linked to the first heap object may occur during the updating of the off-heap pointer held by the first heap object 144. The removal of the weak reference nodes created by the runtime system may occur at these times, but the removal may only occur for unneeded reference nodes. Still further, the garbage collector 160 may be configured to add the nodes for collected heap objects to a separate Collected List (not shown). During either of the above processes where removal is initiated, the nodes in the Collected List may be removed from the cache's linked list. The Collected List may be a subset of the cache's linked list.
The memory device 594 may include input data 596. The input data 596 includes any inputs required by the computer code 597. The output device 593 displays output from the computer code 597. Either or both memory devices 594 and 595 may be used as a computer usable storage medium (or program storage device) having a computer readable program embodied therein and/or having other data stored therein, wherein the computer readable program comprises the computer code 597. Generally, a computer program product (or, alternatively, an article of manufacture) of the computer system 500 may comprise said computer usable storage medium (or said program storage device).
Memory devices 594, 595 include any known computer readable storage medium, including those described in detail below, In one embodiment, cache memory elements of memory devices 594, 595 may provide temporary storage of at least some program code (e.g., computer code 597) in order to reduce the number of times code must be retrieved from bulk storage while instructions of the computer code 597 are executed. Moreover, similar to processor 591, memory devices 594, 595 may reside at a single physical location, including one or more types of data storage, or be distributed across a plurality of physical systems in various forms. Further, memory devices 594, 595 can include data distributed across, for example, a local area network (LAN) or a wide area network (WAN). Further, memory devices 594, 595 may include an operating system (not shown) and may include other systems not shown in
In some embodiments, the computer system 500 may further be coupled to an Input/output (I/O) interface and a computer data storage unit. An I/O interface may include any system for exchanging information to or from an input device 592 or output device 593. The input device 592 may be, inter alia, a keyboard, a mouse, etc. The output device 593 may be, inter alia, a printer, a plotter, a display device (such as a computer screen), a magnetic tape, a removable hard disk, a floppy disk, etc. The memory devices 594 and 595 may be, inter alia, a hard disk, a floppy disk, a magnetic tape, an optical storage such as a compact disc (CD) or a digital video disc (DVD), a dynamic random access memory (DRAM), a read-only memory (ROM), etc. The bus may provide a communication link between each of the components in computer 500, and may include any type of transmission link, including electrical, optical, wireless, etc.
An I/O interface may allow computer system 500 to store information (e.g., data or program instructions such as program code 597) on and retrieve the information from computer data storage unit (not shown). Computer data storage unit includes a known computer-readable storage medium, which is described below. In one embodiment, computer data storage unit may be a non-volatile data storage device, such as a magnetic disk drive (i.e., hard disk drive) or an optical disc drive (e.g., a CD-ROM drive which receives a CD-ROM disk). In other embodiments, the data storage unit may include a knowledge base or data repository 125 as shown in
As will be appreciated by one skilled in the art, in a first embodiment, the present invention may be a method; in a second embodiment, the present invention may be a system; and in a third embodiment, the present invention may be a computer program product. Any of the components of the embodiments of the present invention can be deployed, managed, serviced, etc. by a service provider that offers to deploy or integrate computing infrastructure with respect to systems and methods for maintaining correctness of pointers from a managed heap to off-heap memory. Thus, an embodiment of the present invention discloses a process for supporting computer infrastructure, where the process includes providing at least one support service for at least one of integrating, hosting, maintaining and deploying computer-readable code (e.g., program code 597) in a computer system (e.g., computer 500) including one or more processor(s) 591, wherein the processor(s) carry out instructions contained in the computer code 597 causing the computer system to provide a system for maintaining correctness of pointers from a managed heap to off-heap memory. Another embodiment discloses a process for supporting computer infrastructure, where the process includes integrating computer-readable program code into a computer system including a processor.
The step of integrating includes storing the program code in a computer-readable storage device of the computer system through use of the processor. The program code, upon being executed by the processor, implements a method for maintaining correctness of pointers from a managed heap to off-heap memory. Thus, the present invention discloses a process for supporting, deploying and/or integrating computer infrastructure, integrating, hosting, maintaining, and deploying computer-readable code into the computer system 500, wherein the code in combination with the computer system 500 is capable of performing a method for maintaining correctness of pointers from a managed heap to off-heap memory.
A computer program product of the present invention comprises one or more computer readable hardware storage devices having computer readable program code stored therein, said program code containing instructions executable by one or more processors of a computer system to implement the methods of the present invention.
A computer system of the present invention comprises one or more processors, one or more memories, and one or more computer readable hardware storage devices, said one or more hardware storage devices containing program code executable by the one or more processors via the one or more memories to implement the methods of the present invention.
The present invention may be a system, a method, and/or a computer program product at any possible technical detail level of integration. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.
The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, configuration data for integrated circuitry, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++, or the like, and procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the :Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the Figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
It is to be understood that although this disclosure includes a detailed description on cloud computing, implementation of the teachings recited herein are not limited to a cloud computing environment. Rather, embodiments of the present invention are capable of being implemented in conjunction with any other type of computing environment now known or later developed.
Cloud computing is a model of service delivery for enabling convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, network bandwidth, servers, processing, memory, storage, applications, virtual machines, and services) that can be rapidly provisioned and released with minimal management effort or interaction with a provider of the service. This cloud model may include at least five characteristics, at least three service models, and at least four deployment models.
Characteristics are as follows:
On-demand self-service: a cloud consumer can unilaterally provision computing capabilities, such as server time and network storage, as needed automatically without requiring human interaction with the service's provider.
Broad network access: capabilities are available over a network and accessed through standard mechanisms that promote use by heterogeneous thin or thick client platforms (e.g., mobile phones, laptops, and PDAs).
Resource pooling: the provider's computing resources are pooled to serve multiple consumers using a multi-tenant model, with different physical and virtual resources dynamically assigned and reassigned according to demand. There is a sense of location independence in that the consumer generally has no control or knowledge over the exact location of the provided resources but may be able to specify location at a higher level of abstraction (e.g., country, state, or datacenter).
Rapid elasticity: capabilities can be rapidly and elastically provisioned, in some cases automatically, to quickly scale out and rapidly released to quickly scale in. To the consumer, the capabilities available for provisioning often appear to be unlimited and can be purchased in any quantity at any time.
Measured service: cloud systems automatically control and optimize resource use by leveraging a metering capability at some level of abstraction appropriate to the type of service (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency for both the provider and consumer of the utilized service.
Service Models are as follows:
Software as a Service (SaaS): the capability provided to the consumer is to use the provider's applications running on a cloud infrastructure. The applications are accessible from various client devices through a thin client interface such as a web browser (e.g., web-based e-mail). The consumer does not manage or control the underlying cloud infrastructure including network, servers, operating systems, storage, or even individual application capabilities, with the possible exception of limited user-specific application configuration settings.
Platform as a Service (PaaS): the capability provided to the consumer is to deploy onto the cloud infrastructure consumer-created or acquired applications created using programming languages and tools supported by the provider. The consumer does not manage or control the underlying cloud infrastructure including networks, servers, operating systems, or storage, but has control over the deployed applications and possibly application hosting environment configurations.
Infrastructure as a Service (IaaS): the capability provided to the consumer is to provision processing, storage, networks, and other fundamental computing resources where the consumer is able to deploy and run arbitrary software, which can include operating systems and applications. The consumer does not manage or control the underlying cloud infrastructure but has control over operating systems, storage, deployed applications, and possibly limited control of select networking components (e.g., host firewalls).
Deployment Models are as follows:
Private cloud: the cloud infrastructure is operated solely for an organization. It may be managed by the organization or a third party and may exist on-premises or off-premises.
Community cloud: the cloud infrastructure is shared by several organizations and supports a specific community that has shared concerns (e.g., mission, security requirements, policy, and compliance considerations). It may be managed by the organizations or a third party and may exist on-premises or off-premises.
Public cloud: the cloud infrastructure is made available to the general public or a large industry group and is owned by an organization selling cloud services.
Hybrid cloud: the cloud infrastructure is a composition of two or more clouds (private, community, or public) that remain unique entities but are bound together by standardized or proprietary technology that enables data and application portability (e.g., cloud bursting for load-balancing between clouds).
A cloud computing environment is service oriented with a focus on statelessness, low coupling, modularity, and semantic interoperability. At the heart of cloud computing is an infrastructure that includes a network of interconnected nodes.
Referring now to
Referring now to
Hardware and software layer 60 includes hardware and software components. Examples of hardware components include: mainframes 61; RISC (Reduced Instruction Set Computer) architecture based servers 62; servers 63; blade servers 64; storage devices 65; and networks and networking components 66. In some embodiments, software components include network application server software 67 and database software 68.
Virtualization layer 70 provides an abstraction layer from which the following examples of virtual entities may be provided: virtual servers 71; virtual storage 72; virtual networks 73, including virtual private networks; virtual applications and operating systems 74; and virtual clients 75.
in one example, management layer 80 may provide the functions described below. Resource provisioning 81 provides dynamic procurement of computing resources and other resources that are utilized to perform tasks within the cloud computing environment. Metering and Pricing 82 provide cost tracking as resources are utilized within the cloud computing environment, and billing or invoicing for consumption of these resources. In one example, these resources may include application software licenses. Security provides identity verification for cloud consumers and tasks, as well as protection for data and other resources. User portal 83 provides access to the cloud computing environment for consumers and system administrators. Service level management 84 provides cloud computing resource allocation and management such that required service levels are met. Service Level Agreement (SLA) planning and fulfillment 85 provide pre-arrangement for, and procurement of, cloud computing resources for which a future requirement is anticipated in accordance with an SLA.
Workloads layer 90 provides examples of functionality for which the cloud computing environment may be utilized. Examples of workloads and functions which may be provided from this layer include: mapping and navigation 91; software development and lifecycle management 92; virtual classroom education delivery 93; data analytics processing 94; transaction processing 95; and processing of maintaining correctness of pointers from a managed heap to off-heap memory 96.
While embodiments of the present invention have been described herein for purposes of illustration, many modifications and changes will become apparent to those skilled in the art. Accordingly, the appended claims are intended to encompass all such modifications and changes as fall within the true spirit and scope of this invention.
The descriptions of the various embodiments of the present invention have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.