Preventing garbage object accumulation with minimal runtime
A compiler tool analyzes data type definitions to prevent reference cycles, ensuring timely deallocation and avoiding memory leaks in programming languages without implicit deallocation support, using a facade approach to maintain acyclic data structures.
Patent Information
- Application Number
- JP2023548181
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-12-22
- Filing Date
- 2021-12-21
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-12-21
AI Technical Summary
Existing programming languages that do not support implicit deallocation at runtime can lead to the accumulation of garbage objects, causing memory leaks and potential program failures due to unintended reference cycles, which are difficult to resolve with traditional garbage collection methods.
A compiler or data type checking tool that analyzes data type definitions in programming language source code to detect potential reference cycles and generates alerts or modifications to prevent them, allowing for timely deallocation using a facade approach that maintains acyclic data structures even when implicit deallocation is not supported by the runtime.
This approach ensures timely deallocation of objects without the need for complex garbage collection, simplifying runtime operations and reducing the risk of memory leaks and program failures, while maintaining compatibility with languages that lack implicit deallocation support.
Smart Images

Figure 0007542175000016 
Figure 0007542175000005 
Figure 0007542175000011
Abstract
Description
[Technical field]
[0001] The present disclosure relates to computer programming language compilers and, more particularly, to computer-implemented techniques for preventing the accumulation of garbage objects with minimal runtime. [Background technology]
[0002] Computers are very powerful tools for performing a variety of tasks. A computer program is a generic mechanism for accomplishing custom processing tasks using a computer system. A generic program is a set of programmed instructions (source code) that are compiled into an executable format. The executable format is then executed by a computer system to accomplish the task. For example, a set of C programming language instructions may be compiled into a set of x86 processor-executable instructions. The set of processor-executable instructions may then be executed by an x86 compatible processor to accomplish the processing task.
[0003] A compiler is typically used as a translator between a set of instructions programmed by a human computer programmer and an executable form. In essence, a compiler shields the programmer from knowing, or even caring about, the details of the underlying executable form. Typically, all program instructions created by the programmer are translated by the compiler. For example, a compiler may check data types, build symbol tables, allocate registers, and schedule instructions without the programmer's knowledge of the underlying compiler implementation. In this way, a compiler provides the programmer with tools to reason and express processing tasks at a higher level using a high-level programming language that relieves the programmer of the cognitive burden of worrying about low-level execution details. The general organization and operation of compilers is well known in the art. See, for example, Aho, A., Sethi, R., and Ullman, J., "Compilers: Principles, Techniques, and Tools," Second Edition, 2007.
[0004] One of the purposes of some compilers is cross-compilation. A cross-compiler may be defined as a compiler that generates two or more outputs from one input. For example, a cross-compiler may accept source code written in both human and computer readable source programming languages as input and generate one or more executable forms of source code as output. Consider, for example, a cross-compiler for the C programming language. From C source code, such a cross-compiler may generate an x86 executable file (e.g., for execution on a computer configured with the MICROSOFT WINDOWS® operating system), an ARM executable file (e.g., for execution on a mobile computing device configured with the ANDROID® operating system), and a WASM executable file (e.g., for execution on a virtual stack machine supported by a web browser application).
[0005] There are also source-to-source compilers. A source-to-source compiler may be defined as a compiler that accepts as input source code written in both a human- and computer-readable source programming language, and outputs both human- and computer-readable source code in one or more target programming languages. For example, the HAXE compiler can transform source code written in the HAXE programming language into several structurally similar programming language targets. More information on HAXE is available on the Internet at the haxe.org Internet domain.
[0006] Many widely used programming languages today support runtime implicit object deallocation. Deallocation may be defined as a runtime operation that frees computer memory space occupied by unneeded objects so that the space can be reused. Deallocation occurs in a timely manner at runtime if the space will eventually be freed, for example, immediately after the object is no longer needed or when the running program determines that the space is needed for other purposes. Objects that are not deallocated in a timely manner are sometimes called memory "leaks."
[0007] Some programming languages require explicit programmatic deallocation, while others support implicit runtime deallocation. In explicit deallocation, a computer program is explicitly programmed by the programmer to allocate and deallocate memory space for runtime objects using programming language operations such as "new", "malloc", "free", and "delete". Implicit runtime deallocation relieves the programmer from the responsibility of explicitly programming programs that allocate and deallocate memory space for runtime objects. Instead, the programming language runtime takes care of deallocating runtime objects in a timely manner.
[0008] To support runtime implicit object deallocation, a programming language runtime may provide runtime memory management services, such as a garbage collector that periodically identifies objects in memory that can be safely deallocated, or a cycle collector that identifies groups of objects in memory that cross-reference each other but are not referenced by other parts of the running program. The memory space occupied by the objects can then be freed for other uses.
[0009] There are also smart references. Smart references combine memory address bits with other bits that control how the memory area is deallocated. An example of one kind of smart reference is a reference-counted reference, which keeps a count of the number of program elements that require the referenced object. When the count reaches zero, the object can be safely deallocated. Smart references can be used in some programming languages that do not provide runtime support for implicit deallocation. The modern C++ programming language is one example.
[0010] Currently, most computer programmers are accustomed to programming in programming languages that support runtime implicit deallocation. Unfortunately, there are still many programming languages in widespread use that do not support runtime implicit deallocation. Examples of such programming languages include C, C++, Objective-C, and RUST. A cross-compiler or source-to-source compiler designed to support all widely used programming languages cannot assume that all targets provide runtime implicit deallocation.
[0011] The techniques disclosed herein address this and other problems.
[0012] The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Thus, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.
[0013] These techniques are illustrated by way of example, and not by way of limitation, in the accompanying drawings, in which like reference numbers indicate similar elements and in which: [Brief description of the drawings]
[0014] [Figure 1] Here is a first example of a circular data structure: [Diagram 2] We present a first example that uses the facade approach to provide an apparently cyclic view of an actually acyclic data structure. [Diagram 3] Here is a second example of a circular data structure: [Figure 4] We present a second example that uses the facade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 5A]We present an example of using the façade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 5B] We present an example of using the façade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 5C] We present an example of using the façade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 5D] We present an example of using the façade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 5E] We present an example of using the façade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 5F] We present an example of using the façade approach to provide an apparently cyclic view of an actually acyclic data structure. [Figure 6A] 1 shows an example of a data type definition graph. [Figure 6B] 1 shows an example of a data type definition graph. [Figure 6C] 1 shows an example of a data type definition graph. [Figure 7A] 13 is a flowchart of a data type checking process. [Figure 7B] 13 is a flowchart of a data type checking process. [Figure 7C] 13 is a flowchart of a data type checking process. [Figure 7D] 13 is a flowchart of a data type checking process. [Figure 7E] 13 is a flowchart of a data type checking process. [Figure 7F] 13 is a flowchart of a data type checking process. [Figure 7G] 13 is a flowchart of a data type checking process. [Figure 7H] 13 is a flowchart of a data type checking process. [Figure 8]FIG. 1 is a block diagram of an exemplary basic computing device that may be used in implementations of the present technology. [Figure 9] FIG. 9 is a block diagram of an exemplary basic software system that may be employed to control the operation of the basic computing device of FIG. 8. Summary of the Invention
[0015] The "Overview" section of the detailed description below provides a useful overview of techniques for preventing the accumulation of garbage objects with minimal runtime.
[0016] In some embodiments, a compiler or data type checking tool checks data type definitions in the programming language source code and informs the programmer of any definitions that may allow reference cycles at run time. In some embodiments, the compiler or data type checking tool takes into account how the computer program uses the type definitions.
[0017] In some embodiments, the compiler or data type checking tool considers which property definitions of the data type definitions of the programming language source code are read-only. In some embodiments, the compiler or data type checking tool uses explicit hints in the programming language source code to determine whether a property definition is read-only, including keywords or annotations such as "const", "final", or "read-only", or lacks explicit hints with the opposite meaning such as "mutable" or "writeable". In some embodiments, the compiler or data type checking tool inspects the property definition to infer read-onlyness. For example, a property definition may be inferred to be read-only when any programming language source code that could have set the property is not set after an initial value has been so assigned. In some embodiments, the compiler or data type checking tool inserts additional instructions into the programming language source code or executable program to detect or enforce the required read-onlyness. For example, the additional instructions may cause assignment of a value to the property after initialization of the property to fail.
[0018] In some embodiments, the compiler or data type checking tool considers which property definitions in the programming language source code are initialized early, before any references to the contained object. The concept of early is used to prevent an object from creating a reference cycle to itself during the initialization of the property. Early initialization may be inferred based on an inspection of the programming language source that initializes the property. Early initialization may also be based on explicit hints. Explicit hints may result in other checks of the programming language source code that may perform the initialization, such as checking the constructor definition of the data type to check the temporal relationship between the use of the "this" reference as a value and the assignment of the property. The compiler or data type checking tool may insert additional instructions into the programming language source code or executable program to detect or enforce the required read-only nature. For example, the additional instructions may cause an attempt to initialize a property to fail after the "this" reference to the object that contains the property has been used as a value.
[0019] In some embodiments, a compiler or data type checking tool considers whether a data type definition is closed (e.g., whether all its subtypes are known to the compiler or data type checking tool). Closedness may be based on explicit hints in the programming language source code, such as the presence of keywords or annotations such as "final," "closed," or "sealed," or the absence of hints with the opposite meaning, such as "open." Closedness may be inferred based on context. For example, closedness may be inferred for a data type definition if access to the data type definition is restricted to some modules of the programming language source code by an information hiding mechanism, and no definitions exist in the programming language source code for subtypes in those modules. Closedness may also be used to allow substitution of case-based reasoning to reason about general super data types.
[0020] In some embodiments, a compiler or data type checking tool considers whether a data type definition is concrete (e.g., considers whether there can be values of that data type that are not values of its subdata types). A concrete data type may be contrasted with an abstract data type that is insufficient to describe a value but from which a concrete subdata type may be derived. Concreteness may be based on explicit hints, such as the presence of a keyword or annotation like "concrete", or the absence of a keyword or annotation like "abstract". Concreteness may be inferred based on the context, such as by a user of the data type in programming language source code to construct an object, or by the absence of any missing parts that would prevent the construction of a fully functional object. Because all values created at runtime must be of at least one concrete data type, a compiler or data type checking tool may infer that concrete types are sufficient to detect reference cycles.
[0021] In some embodiments, a compiler or data type checking tool checks for potential reference cycles by constructing a graph of potential type containment relationships. Some nodes of the graph may correspond to data types defined in the programming language source code. Some nodes of the graph may correspond to worst-case assumptions about generic type parameters. The worst-case assumptions may consider generic type parameter bounds or data type definition bounds. One type of data type definition bound is referred to herein as a "may-not-reference" bound. Some edges of the graph may correspond to ways in which one data type defined in the programming language source code may reference another data type defined in the programming language source code. The graph elements (e.g., nodes and edges, etc.) may be associated with metadata derived from properties and the earlyness, read-onlyness, or closedness of the data type definitions. In some embodiments, cycles in the graph with certain kinds of edges correspond to possible reference cycles enabled by a set of one or more data type definitions in the programming language source code.
[0022] An alert generated by a compiler or data type checking tool may include a human-readable description of the possible reference cycle. For example, the description may state something like "A value of type Thing may reference itself using its property otherThing. 'aThing.otherThing=aThing;' would result in a reference cycle." Such a description may be derived from metadata associated with nodes or edges of a potential type containment graph. The description may include suggestions on how to fix the issue (e.g., how to avoid the potential reference cycle, etc.). In some embodiments, an external tool, such as an integrated development environment, uses the alert, or a modified form of the alert (e.g., a more machine-readable form of the alert), to automatically modify programming language source code based on the suggestions selected by a programmer user.
[0023] In some embodiments, the compiler or data type checking tool ignores potential reference cycles that are deemed safe by a human reviewer. Identifying reference cycles that are deemed safe may be based on hints, annotations, or other metadata associated with data type definitions in the programming language source code. Identifying reference cycles that are deemed safe may alternatively or similarly be based on determining that the associated properties are assigned only within "unsafe" fragments of the programming language source code that the compiler or data type checking tool excludes from data type checking, so that data type definitions that should allow for reference cycles can be approved.
[0024] In some embodiments, the distributed object system keeps reference counts of objects that are needed by other computers or processes on the same computer, eliminating the need to rely on acyclic collectivity checks to detect reference cycles between some types of objects. In this context, objects can reference objects that exist in other processes, and when a process in the distributed system no longer needs an object, the distributed system may send a message to the process in the system that is considered to own the object. Separate reference counts may be maintained for the same object by multiple processes in the system to handle cases where one of the processes dies or fails, or where one of the processes misbehaves. For example, sometimes when there were fewer than two references, with the intention of making the object unavailable to other processes, by asserting that two references are no longer needed. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0025] In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present technology. It will be apparent, however, that these technologies may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present technology.
[0026] Glossary The following definitions are provided by way of example, and not by way of limitation, to aid in the understanding of the present disclosure.
[0027] Client: A "client" may be defined as a portion of a computer system that delegates tasks to a library.
[0028] Compiler: A "compiler" consumes input suitable for both human and machine consumption and produces one or more outputs, each of which is a transformation by the compiler of the input. For example, the input may be source code written in a source programming language. The output may be an executable form of the input source code. The output may also be a source code form of the input source code in a target programming language that is different from the source programming language.
[0029] Cross-Compiler: A "cross-compiler" is a compiler that produces two or more outputs from one input.
[0030] Deallocation: The term "deallocation" refers to a runtime operation in the context of a running computer program that frees memory space occupied by unneeded objects for reuse.
[0031] Garbage Objects: A "garbage object" is an object that can be safely deallocated, but has not yet been deallocated.
[0032] Graph: A "graph" is a mathematical structure used to model pairwise relationships between entities. A graph in this context typically consists of vertices (also called nodes or points) connected by edges (also called links or lines). Computer programs can represent graphs in a variety of different ways, including through node objects that reference edge objects that reference node objects. Other possible ways include an adjacency matrix, an occurrence matrix, or an adjacency list.
[0033] Library: A "library" may be defined as a representation of an algorithm or algorithms in an automatable form. An example of an automatable form may be programming language code or a compiled version thereof (e.g., bytecode, binary executable code, etc.). Typically, when a library is executed as a process or processes, it does not "own" the process(es) it runs as part of. Instead, the library runs with or as part of a larger system that delegates certain types of algorithmic tasks to the library. For example, a microservice on a computer network may be considered a library. Often, microservices exist for other network nodes to offload certain algorithmic tasks.
[0034] Object: An "object" may be defined as a run-time entity that may respond to messages in a computer program. Typically, an entity occupies a region of computer memory. An object may respond to messages and organize the bits of the occupied memory region according to a data type definition. One example of an object is a run-time instance of a class definition in an object-oriented programming language.
[0035] Reference: A "reference" is a run-time value that allows a computer program to access an object stored at a location in computer memory. Using a reference to retrieve the object stored at that location is sometimes called dereferencing. A "pointer" is an example of a reference.
[0036] Runtime: The "runtime" of a programming language includes the computational mechanisms that support the execution of computer programs written in that language. For example, the runtime of a programming language may include a virtual machine that understands the bytecode instructions into which computer programs in that language are compiled. The JAVA Virtual Machine (JVM) is just one example of such a runtime. A runtime may also provide implicit deallocation services, such as garbage collection or cycle collection. However, not all runtimes provide implicit deallocation services. Additionally, as used herein, the term "runtime" refers to the time when a computer program is executed.
[0037] Target: A "target" can be defined as the mechanism used by a client to connect to compiler output. A programming language can be targeted. A programmer writes code that connects to a library that is loaded into the same memory space. A virtual machine (VM) can be targeted. A programmer writes code that compiles to the kind of bytecode that the virtual machine runs, and can rely on the VM using a link through an interface. Another program can be a client. Thus, a mechanism between programs is a target. Code can use inter-process communication (IPC), remote procedure calls (RPC), or RESTful network protocols to send messages to something running outside the client program's process (e.g., a network service or microservice) and know when a message containing a response is coming.
[0038] Summary Unresolved reference cycles in a computer program can lead to the accumulation at runtime of garbage objects. Such accumulation can result in fatal program failure. As an example, consider the PYTHON programming language. Older versions of the PYTHON runtime use reference counting to track allocated memory. In particular, PYTHON runtime objects have a reference count that indicates the number of objects that reference it. When the reference count reaches zero, the object is freed from memory. Reference counting works effectively in most PYTHON programs and prevents the accumulation of garbage objects. However, reference counting can fail when there is a "reference" cycle. Reference cycles occur when objects reference each other.
[0039] Consider the following simple PYTHON program, which creates a list object, stores a reference to the list in an element of the list itself, and then deletes the list object. 00: l = [] 01: l.append(l) 02: del l
[0040] The statement on line 00 creates a list and increments the list's reference count to 1. The statement on line 01 adds a reference to the list to itself, creating a reference cycle and incrementing the list's reference count to 2. The statement on line 02 removes the reference to the list by variable 'l' and decrements the list's reference count from 2 to 1. Because of the reference cycle, the list is left with a reference count of 1 due to the internally held self-reference created by the statement on line 01. Therefore, the list is not implicitly deallocated by its reference count alone, which is undesirable because the list is not usable after the statement on line 02 and needs to be deallocated.
[0041] Intentionally creating reference cycles in a computer program is generally not considered good programming practice, but sometimes reference cycles can be difficult to avoid and the programmer may not even realize that they have been created. For long-running programs such as server programs, this can become a problem, potentially fatal, if the server program runs out of memory because it cannot deallocate an object that is no longer reference counted.
[0042] To address this shortcoming of reference counting, some versions of the PYTHON runtime use a garbage collector that finds reference cycles in running PYTHON programs at runtime. Reference counting is still used to deallocate other objects. Nevertheless, problems can still exist with an object's "finalizer". A "finalizer" is a set of one or more actions that must be taken when an object is deallocated. Finalizers are often used to free system resources, such as file descriptors on operating systems, whose numbers can be limited. An example of a PYTHON finalizer is an object's "__del__" method (e.g., an instance of a class that provides an implementation of a special PYTHON "__del__" method).
[0043] With reference counting, when an object's reference count goes to zero, the finalizer is called before the object is deallocated. However, with garbage collection, it becomes more difficult for the programmer to reason about the runtime's finalizer behavior, especially when there are reference cycles. For example, if two objects in a reference cycle both have finalizers, which finalizer should be called first? After calling one of the finalizers, the object cannot be freed because the other finalizer may still need to access it. Faced with this situation, some versions of the PYTHON runtime do not deallocate objects with finalizers that create reference cycles. Instead, the objects are added to a global list of uncollectible garbage objects. PYTHON programs can be programmed to access the global list and explicitly free reference cycles in a way that is useful for the particular application at hand. Of course, this assumes that the programmer is aware that reference cycles can be created in the first place. Even then, the programmer must be careful to deallocate objects in the global list.
[0044] As is evident from the PYTHON example above, adding support for implicit deallocation to a runtime can introduce complex issues. Adding garbage collection, as in the PYTHON case, could be helped by the fact that the PYTHON runtime runs within a C or C++ runtime. However, adding support to a C or C++ runtime that may embed other runtimes is not straightforward. For example, the various runtimes need to recognize each other's references as references and consistently agree on which runtime is responsible for doing deallocation.
[0045] In general, from a programmer's perspective, there are at least two kinds of reference cycles: (1) intended reference cycles, and (2) unintended reference cycles. Recursive data types such as Trees can be a source of unintended reference cycles. For example, several lists of lists can avoid reference cycles if their usage is carefully programmed. However, as seen in the PYTHON example above, many programming languages can unintentionally create reference cycles at runtime that cannot be resolved by simple reference counting.
[0046] The techniques disclosed herein address these and other problems.
[0047] Computer-implemented techniques are provided for preventing the accumulation of garbage objects with minimal runtime. The techniques include checking whether source code written in a source programming language that does not require a programmer to explicitly program when deallocation occurs can be executed within a runtime that has little or no support for implicit deallocation. At the same time, the techniques ensure that objects are deallocated in a timely manner with minimal runtime.
[0048] The technique includes generating a compile-time alert (e.g., an error or warning message) to a source programming language source code programmer or stopping compilation of the source code upon detecting a source code data type definition with a possible reference cycle. The technique is flexible enough to allow a programmer to define data types in source code that appear cyclic but are actually non-cyclic. The technique is also flexible enough to allow a programmer to define data types in source code that are recursive but not self-referential. With the technique, a programmer is provided with an implicit deallocation experience while generating program fragments that interoperate with minimal runtimes that do not provide any implicit deallocation or that only minimally support it (e.g., provide only reference counting).
[0049] Other and further aspects of the present technology will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, which illustrate, by way of example, the principles of the technology.
[0050] Apparent cycles without real cycles As shown, a programmer may program source code in a source programming language for the purpose of allowing reference cycles. For example, a programmer may program source code to define a recursive data type. A recursive data type is a data type that references its own data type definition.
[0051] For example, consider the following data type definitions in a possible source programming language: 00: Closed type List <e>; 01: closed concrete type Cons <f>extends List <f>{ 02: initial: F; 03: rest: List <f>; 04:} 05: closed concrete type Empty <g>extends List <g>{}
[0052] According to the above data type definition, the initial property is defined as a generic data type, and the remaining properties are Cons <f>The parent type of the type is List <f>It is defined as a type. <f>The initial properties and / or remaining properties of the object are Cons <f>You can refer to the object itself. Therefore, Cons <f>The data type is a recursive data type.
[0053] In the above data type definition, the closed keyword specifies that all of the subtypes of the data type are known to the compiler, as opposed to extensible data types, where additional subtypes of the data type can be specified after the fact. In some implementations, closed data types are the default, so if a closed data type is desired, it is not necessary to specify the closed keyword.
[0054] As another example, consider the following data type definition for a binary tree in a possible source programming language: 00: Closed type Tree ; 01: closed concrete type BinaryTree <f>extends Tree <f>{ 02: element: F; 03: left: Tree <f>; 04: right: Tree <f>; 05:} 06: closed concrete type Empty <g>extends Tree <g>{}
[0055] The above data type definition defines the generic data type BinaryTree <f>as a set of values. According to the above type definition, BinaryTree <f>The left and / or right properties of an object are <f>It can contain values of type BinaryTree. <f>The data type is also a recursive data type.
[0056] As mentioned previously, instances of recursive data types may develop into reference cycles at runtime. Figure 1 shows an example of a cyclic collection of objects at runtime. For example, the collection of objects may represent a tree or graph data structure. The ellipses represent the runtime objects in computer memory, and the directed edges represent references from one object to another. For example, object 1 references object 2 by reference symbol d. In the example collection, there are multiple reference cycles, as indicated by the directed edges in different directions. For example, if the collection of data objects represents a tree data structure, reference symbol u from object 6 to object 7 may represent that object 7 is the first child node in object 6's tree, where reference symbol v may represent that object 7 is the last child node in object 6's tree, reference symbol t may represent that object 7 is the parent node in object 6's tree, and so on.
[0057] Facade Approach The present technology includes a facade approach, whereby instead of representing relationships between objects at runtime through a taxonomy of mutually referencing nodes and edges, the facade approach can be used to represent relationships between objects at runtime. With the facade approach, a collection of objects may appear to a running program as cyclic (i.e., circular in appearance), but its runtime implementation is actually acyclic. Because its runtime implementation is actually acyclic, no implicit runtime deallocation support, such as an automatic garbage collector or an automatic cycle collector, is needed. Instead, a simple reference counting mechanism can be used to deallocate objects in a timely manner.
[0058] A source-to-source compiler that translates source code in a source programming language into source code in a target programming language that does not support implicit object deallocation at runtime can generate the target source code to use the façade approach. By doing so, the target programming language runtime does not need to support implicit runtime deallocation and can deallocate objects in a timely manner. In conjunction with the façade approach, the source programming language can provide an implicit deallocation programming experience to the programmer, where the programmer does not need to care about programming source code in the source programming language to explicitly allocate and deallocate objects. This experience is provided even if one or more of the target languages of the source-to-source compiler do not support implicit runtime deallocation. It also allows the programmer to define recursive data types in the source programming language. No reference cycles are created at runtime because they appear to be circular but are not actually circular.
[0059] In the façade approach, a larger taxonomy is used. In particular, the larger taxonomy includes the following objects: "data" objects that are instances of the defined data types, "relationship" objects that collect relationships between data objects; A "graph" object that pairs data objects and relationship objects; and A "facade" object that presents the appearance of circulation and references both data objects and graph objects.
[0060] According to the façade approach, a program accesses and modifies a collection of data objects programmed in a source programming language at runtime, enabling cycles of reference. For example, the collection of data objects may represent a data structure based on a recursive data type defined in the source programming language. For example, the data structure may be a list, tree, or graph data structure where the objects of the data structure are instances of the recursive data type.
[0061] The facade approach provides a run-time mechanism by which collections of data objects, via facade objects, can maintain acyclicity. Through the facade objects, apparently cyclic collections of data objects remain actually acyclic despite appearing to be cyclic to the program. Because acyclicity is maintained, no run-time garbage collection or reference cycle detection is required to deallocate collections of data objects in a timely manner.
[0062] In the taxonomy of the façade approach, a given façade object corresponds to at most one graph object and at most one data object. However, multiple façade objects may correspond to the same data object. A given graph object may correspond to one or more relationship objects, and a given relationship object can correspond to one or more data objects. Thus, a given graph object can correspond to one or more data objects via one or more relationship objects to which the given graph object corresponds.
[0063] FIG. 2 illustrates the application of the facade approach to the example circular collection of objects shown in FIG. 1. As can be seen in FIG. 2, the circular collection of objects is represented at runtime as a non-circular collection of objects. In this example, data objects 1, 4, and 6 have only facade objects, and data objects 2, 3, 5, and 7 have no facade objects. Different sets of facade objects are possible, including a set with only one facade object and a set that includes multiple facade objects for the same underlying data object. Furthermore, different sets of facade objects may be created for a collection of data objects at different points in the course of a running program, depending on the program's access and modification patterns to the collection of data objects.
[0064] At runtime, references to the data objects of a collection are made through the facade objects of the data objects. For example, referring to Figure 2, when a program uses facade object 6 to request data object 1 at the other end of reference f, instead of providing data object 1 or a reference to data object 1, facade object 1 is provided to the program. For example, facade object 1 may be provided by an abstraction of a computed property of facade object 6.
[0065] To determine at runtime which data object is on the other end of a reference, a facade object may use a graph object. A graph object may include a map object. A map object pairs data object relationships with objects. For example, the map object in FIG. 2 may map data object 6 and data object 1 to relationship object X. In particular, when a program uses facade object 6 for data object 6 to reference the data object on the other end of reference f, facade object 6 uses the graph object and the map object to determine which of the relationship objects referenced by the graph object collects the relationship between data object 6 and data object 1 via reference f. Facade object 6 may then create facade object 1. In doing so, facade object 1 is created or configured to reference data object 1, which facade object 6 obtains via relationship object X. Facade object 1 is created or configured to reference the graph object. This is shown in FIG. 2. Facade object 1 is then returned to the calling program by facade object 6 in place of data object 1, preserving the apparent circularity but actual acyclicity of the collection of data objects.
[0066] A map object may be constructed in a variety of ways. For example, a map object may comprise a two-dimensional array where each element of the array corresponds to a pair of data objects and indicates a relationship object that groups all relationships between the pair of data objects. For example, if M is a two-dimensional array, M[x][y] may refer to a relationship object that groups all relationships between data object x and data object y. As an alternative to a two-dimensional array, M[x][y] may refer to a relationship object that groups all relationships from data object x to data object y (or from data object y to data object x). Alternatively, a map object may comprise a one-dimensional array where each array element corresponds to a data object and a relationship object that groups all relationships from that data object to other data objects. For example, M[x] may refer to a relationship object that groups all relationships from data object x to other data objects.
[0067] As a data object is added to the collection at runtime, it may be connected to the graph object. For example, Figure 3 shows the circular collection of data objects of Figure 1, but with the addition of data object 8, which has references w and x of data object 4. The references w and x create a reference cycle in the circular collection of objects of Figure 3. Figure 4 shows a representation of the apparently circular, but in fact acyclic collection, of the collection of objects with the addition of data object 8. In particular, the map object of the graph object may be updated to map data object 8 and data object 4 to relationship object Y. Relationship object Y collects the w and x relationships between data object 8 and data object 4.
[0068] In the façade approach, a data object can have relationships with other data objects through a graph object. This has implications on how data objects can be added to an existing data structure. For example, consider the following source code in any possible source programming language: 00: let root = BinaryTree("root", Empty, Empty); 01: let left = BinaryTree("left", Empty, Empty); 02: root.left = left;
[0069] Line 00 is the BinaryTree explained above. <f>Create a "root" data object as an instance of a recursive data type. Figure 5A shows an acyclic runtime representation of the "root" data object created in line 00 above with the facade approach. The variable "root" is a facade object that references the "root" data object and the "root" graph object, instead of directly referencing the "root" data object. At this point in the execution, the "left" object instance in line 01 has not been created. Therefore, the "root" relationship object does not group the relationships between the "root" data object and the "left" object.
[0070] Line 01 is the BinaryTree explained above. <f>Create the "left" data object as an instance of the recursive data type. Figure 5B shows an acyclic runtime representation of the "left" data object created in line 01 above with the facade approach. Instead of directly referencing the "left" data object, the variable "left" is a facade object that references the "left" data object and the "left" graph object, which may be a different graph object than the "root" graph object referenced by the "root" facade object of the "root" data object as shown in Figure 5A. At this point of execution, there is still no relationship between the "root" data object and the "left" data object. Therefore, the "left" relationship object that references the "left" data object also does not group the relationships between the "root" object and the "left" object. The "left relationship object" may be a different relationship object than the "root" relationship object that references the "root" data object as shown in Figure 5A.
[0071] Line 02 sets the left property of the "root" object to reference the "left" data object. Without the facade approach, the left property of the "root" data object may directly reference the "left" data object at runtime. However, with the facade approach, such direct references are prevented when source code in a source programming language is compiled into source code in a target programming language that does not support implicit runtime deallocation. Specifically, the target language source code is compiled to implement the facade approach at runtime, such that direct references are prevented when the target language source code is compiled into an executable and executed.
[0072] FIG. 5C illustrates the acyclic runtime representation of the "root" and "left" data objects after the "root" data object's left property has been assigned to reference the "left" data object according to the facade approach. The root and left facade objects now share the same graph object. Specifically, the "left" graph object referenced by the "left" facade object (FIG. 5B) is imported into the "root" graph object referenced by the "root" facade object (FIG. 5A). The "left" facade object is then updated to reference the "root" graph object and no longer references the "left" graph object. The "root" relationship object referenced by the "root" graph object is updated to reference the "left" data object, and the "left" relationship object in the left graph is disconnected from the "left" data object. The "left" graph object in the left graph may now be deallocated when its reference count is zero. When the "left" graph object is deallocated, the "left" map object and the "left" relationship object of the "left" graph object may be deallocated. This is because after the "left" graph objects are deallocated, their reference counts need to be zero. The "root" map object of the "root" graph object is updated to specify that the "root" data object has a relationship with the "data objects" on the left, and that the relationships are grouped by the "root" relationship object.
[0073] The acyclic representation of FIG. 5C represents the notion that at run time, the left property of the "root" data object directly references the "left" data object, as shown in FIG. 5D.
[0074] In addition to the source code above, consider now the following source code in any possible source programming language: 03: left.right = root; 04: let extra = root;
[0075] Without the façade approach, the additional source code in line 03 above would create a reference cycle between the "root" and "left" data objects at runtime. However, with the façade approach, the reference cycle can be avoided. This is illustrated in FIG. 5E, which shows the acyclic runtime representation of the "root" and "left" data objects with the façade approach after the right property of the "left" data object has been assigned to reference the "root" data object via the façade object, as in line 03 above. The "root" and "left" data objects still share a "root" relationship object that groups both (1) the relationship between the "root" and "left" data objects via the left property of the "root" data object, and (2) the relationship between the "root" and "left" data objects created via the right property of the "left" data object. The variable named "extra" is a façade object that references the "root" graph object and the "root" data object.
[0076] In addition to the source code above, consider now the following source code in any possible source programming language: 05: let super = BinaryTree("root", Empty, Empty); 06: super.left = root;
[0077] Line 05 is the BinaryTree explained above. <f>Create a "super" data object as an instance of the recursive data type. Line 06 sets the left property of the "super" data object to reference the "root" data object created in line 00 above. In the facade approach, line 06 results in the "root" graph object being imported into the "super" graph object at runtime for target languages that do not support runtime implicit deallocation. This import is shown in FIG. 5F. FIG. 5F shows an acyclic representation of the "super", "root", and "left" data objects after import in accordance with the facade approach. The "root" and "left" facade objects have been updated to reference the "super" graph object. The "super" graph object and the "super" map object are updated to map the relationship between the "root" and "left" data objects via the "root" data object's left property (line 02 above) to the "root" relationship object. The "super" graph object and the "super" map object are also updated to map the relationship between the "super" object and the "root" data object via the left property of the "super" data object to the "super" relationship object (line 06 above). Note that acyclicity is maintained even without the facade approach, even though line 03 has been programmed to create a reference cycle.
[0078] Note that the "extra" facade object assigned to reference the "root" data object in line 04 above may still reference the "root" graph object after the graph import caused by line 06 above. However, due to the graph import, the "root" graph object no longer references the "root" relationship object. In other words, the "extra" facade object has been "abandoned" by the graph import caused by line 06 above. This abandonment is illustrated in FIG. 5F. As can be seen, the "root" map object is not connected to the "root" relationship object. Thus, after line 06 above, a source programming language source code programmer may need to be careful not to attempt to use the "extra" facade object to dereference a relationship that the "root" data object has with another object. For example, consider the following additional source code: 07: A = root.left; 08: B = extra.left;
[0079] At runtime, after the import shown in Figure 5F, the assignment in line 02 above will result in variable A becoming a facade object that references the "left" data object. However, the statement in line 08 will generate a runtime error or fault because the "extra" facade object has been discarded by the import of the graph shown in Figure 5F. Careful programming in the source programming language can avoid facade objects being discarded by the import of the graph. For example, the creation of the extra variable in line 04 can be omitted and the already created "root" facade object can be used instead.
[0080] Different facade objects that reference the same underlying data object and the same underlying graph object cannot be properly compared for equality based on comparing the memory addresses of the facade objects because the facade objects are stored at different memory addresses. However, a facade object is semantically the same as another facade object if both facade objects reference the same underlying data object and the same underlying graph object. The facade approach allows the equality operator of the target programming language (e.g., C or C++) to be overridden so that when two facade objects are compared for equality, the operator indicates that the two facade objects are equal if the facade objects reference the same underlying data object and the same underlying graph object, and indicates that they are unequal if the facade objects reference different data objects or different graph objects.
[0081] Checking for possible cycles in data type definitions As already mentioned, if a collection of data objects does not contain any reference cycles at runtime, then reference counting is sufficient for timely deallocation of data objects -- more sophisticated deallocation mechanisms such as garbage collection or cycle detection are not required.
[0082] How data objects are created and changed at run time is determined by the definitions of data types in the source code of the source programming language. The source programming language may impose sufficient restrictions on the data type definitions in the source to prevent reference cycles from occurring at run time.
[0083] For example, consider the following data type definition for a "Cons" list in a possible source programming language: Cons <f>A data type is a recursive data type that is either empty or has a head element and a tail that is another list containing the remaining elements. 00: Closed type List <e>; 01: closed concrete type Cons <f>extends List <f>{ 02: head: F; 03: tail: List <f>; 04:} 05: closed concrete type Empty <g>extends List <g>{}
[0084] The above data type definition is susceptible to runtime reference cycles. For example, the following example shows a Cons <f>By creating a data object, one can create an "ouroboros" list. 06: let list = Cons(0, Empty); 07: list.tail = list;
[0085] In accordance with some of the present techniques, data type definitions in source programming language source code that are susceptible to runtime reference cycles are detected at source code compilation time. The compiler can then alert the programmer or halt compilation of the source code. The alert can be, for example, a warning or error message presented in a user interface, output to a file, or the like. Alternatively, the detection and alerting can be done by a compiler, a dedicated type checking tool, or other source code control tools that detect potential reference cycles in the source code and generate an alert.
[0086] In general, detecting potential reference cycles in data type definitions involves the source programming language compiler creating a data type definition graph with a node for each data type involved, and then adding an edge for each property to the node representing that data type. <f>For generic data types such as types, the compiler contextualizes the data type parameters. Contextualization is achieved by creating a graph for each concrete data type definition, rather than the abstract data type definition. The concrete data type definition can be used to instantiate data objects of that data type at runtime, while the abstract data type definition exists only to support the concrete data types derived from it. With a graph for each concrete data type definition, the compiler can convert the data type parameters into the context of those defined in the concrete data type definition, allowing the source programming language source code programmer to define and safely use nested data structures, for example, a list of lists. Additionally, the compiler creates a "limit node" for each data type parameter that represents the worst case for the data type to which the data type parameter may bind.
[0087] FIG. 6A shows the concrete and generic data types Cons <f>An example data type definition graph for. The solid edges in the graph represent edges that may be involved in reference cycles at runtime. The graph shows two ways that reference cycles can arise at runtime.
[0088] In the first method, the edge 602 is <f>A data object of type List via its tail property <f>The edge 604 represents a list of <f>A data object of type Cons <f>This indicates that the data object can be of any type.
[0089] In the second approach, if a generic data type F is instantiated with a very generic data type like Top (which represents a hypothetical super data type that contains all data objects), then Cons <f>A data object of type can point, via its head property, to a data object of type F, where F is a type of Cons <f>It could be some unknown data type with its own property reference to a data object of type 2. The second way is represented by edges 606, 608, and 610 in Figure 6A.
[0090] The first data type reference cycle can be resolved by allowing the inclusion of two extra pieces of information in the data type definition: this information can be entered manually by a programmer of the source code in the source programming language, this information can be inferred based on static analysis of the source code, or this information can be automatically added to the source code because it is required by an automatic or semi-automatic tool, e.g., an automatic or semi-automatic data type checking tool.
[0091] A property of a data object is not sufficient for a reference cycle if, at run-time, it can only point to data objects that are older than the data object that contains the property. Thus, if the initial value of a property is older than the data object that contains the property, and the compiler can determine that the property cannot be changed from its initial value (e.g., it is read-only), then the property is not sufficient for a reference cycle.
[0092] According to the present technique, two meta-properties may be defined implicitly (eg, by default) or explicitly (eg, by a programmer) for a property of a data object in the data type definition of the data object. · Read Only - A "read only" property is a property of a data object that cannot be changed from its initially assigned value. · Early - An "early" property is a property of a data object that, instead of being used simply as a means to initialize the property of a data object, is initially assigned a value that is determined before any reference to the data object that contains the property is used as a value. This latter restriction is used to avoid an exceptional case in constructors.
[0093] Using these two metaproperties, we can modify the above example data type definition with the following read-only initial hints, as in the following example: 00: Closed type List <e>; 01: closed concrete type Cons <f>extends List <f>{ 02: head: F; 03: readonly early tail: List <f>; 04:} 05: closed concrete type Empty <g>extends List <g>{}
[0094] There are various ways that a compiler can determine at compile time whether a property of a data type definition is read-only. No special method is required. One way is based on keyword hints explicitly programmed by the programmer in the property definition. Keyword hints can be "const", "final", "readonly", etc. Another way can be based on the absence of keyword hints with the opposite meaning, for example the absence of "mutable" or "writeable" keyword hints in the property definition. Yet another way is for the compiler to perform static analysis of the source code to determine whether any of the source code that could have set the property to a value after it was assigned an initial value actually did so. If not, the compiler can infer that the property is read-only. Static analysis can be triggered by explicit keyword hints in the property definition (e.g. "read-only").
[0095] A compiler can also force a property to be read-only by inserting additional instructions at compile time that prevent a value from being assigned to the property at run time after the property has been initialized. Additionally or alternatively, the additional instructions may log (e.g., in a run time diagnostic log or a run time profiler log) any attempt at run time to assign a value to the property after the property has been initialized.
[0096] Similarly, there are various ways that a compiler can determine if a property is initial at compile time. No special method is required. One way is based on the presence or absence of keyword hints in the property definition. Another way is for the compiler to statically analyze the source code to determine if the property is initialized before any reference is made to the containing data object as its value. Static analysis can be triggered by an explicit keyword hint (e.g., "initial") in the property definition.
[0097] A compiler can also force a property to be initial by inserting additional instructions at compile time to prevent the property from being initialized at run time after a reference to a data object that contains the property is used as a value. Additionally or alternatively, the additional instructions may log (e.g., in a run time diagnostic log or a run time profiler log) any attempt to initialize the property at run time after a reference to a data object that contains the property is used as a value.
[0098] There are also various ways in which a compiler can determine if a data type is closed at compile time. A closed data type is a data type for which any and all subdata types are known to the compiler at compile time. A compiler can determine if a data type is closed based on explicit keyword hints in the data type definition, such as "final," "closed," or "sealed," or based on explicit keyword hints in the data type definition with the opposite meaning, such as "open." Closedness can be inferred by the compiler as part of static analysis of the source code based on context. For example, if access to a data type definition is restricted to a few modules or packages by an information hiding mechanism, and there are no definitions of subdata types of the data type in those modules or packages, the compiler can infer that the data type is closed.
[0099] There are also various ways in which a compiler can determine whether a data type is concrete at compile time. A concrete data type is a data type that may exist as a data object of that type that is not an instance of a subdata type of that data type. A concrete data type is in contrast to an abstract data type, which is insufficient to define a data object but from which concrete subdata types may be derived. A compiler can determine that a data type is concrete based on the presence of an explicit keyword hint in the data type definition, such as "concrete", or based on the presence of an explicit keyword hint in the data type definition with the opposite meaning, such as "abstract". A compiler may infer the concreteness of a data type by static analysis of the source code, such as using the data type in the source code to construct a data object of the data type, or by the absence of a definition element in the data type definition of the data type in the source code that prevents the construction of a data object of the data type. Since all data objects must be concrete data types, it is sufficient to type check only concrete data types for the possibility of creating reference cycles.
[0100] FIG. 6B is an example of a data type definition graph for the above data type definition using read-only and initial hints. As can be seen, edges 602 and 604 are now broken to reflect that the corresponding references cannot participate in creating a runtime reference cycle. Additionally, edge 602 of the tail property now has a strict less-than relationship ("<"), less-than relationship ("<="). Semantically, when the edges of a cycle in the data type definition graph have a less-than relationship ("<="), there is a known ordering where some of the data type definitions represented by the edges are insufficient for a runtime reference cycle. One type of known ordering is a read-only initial relationship. For example, because of the read-only and early restrictions on the tail property, the potential reference cycle of edges 602 and 604 in FIG. 6A is no longer a potential reference cycle as represented in FIG. 6B. It is recognized that there is no contradiction in asserting that a data type is less-than or equal to its own value.
[0101] However, there is still a potential reference cycle represented by edges 606, 608, and 610 in Figure 6B. In particular, even if the tail property has an initial hint of read-only, Cons <f>If the head property of a data object can reference a data object of unknown type F, and then that data object is Cons <f>Being able to point back at a data object creates a reference cycle, even if the head property is read-only early on. For this reason, the head property is always a Cons <f>This is because it could be initialized to a data object of unknown type F that references a data object.
[0102] To prevent reference cycles of the type represented by edges 606, 608, and 610 in Figure 6B, it is desirable to allow a data object of a particular data type to reference another data object of the same particular data type, as long as the reference is not to itself. For example, a list of lists that does not reference itself should be allowed. Additionally, data objects containing primitive data types should also be allowed. For example, a list of strings or numbers should be allowed.
[0103] To address issues such as a property of a data object being a generic data type that can be of any data type, additional restrictions expressed in the source programming language source code may be used. For example, consider the following data type definition for the "Cons" list: 00: Closed type List <E ┤ Cons <e>>; 01: closed concrete type Cons<F ┤ Cons <f>> extends List <f>{ 02: head: F; 03: readonly early tail: List <f>; 04:} 05: closed concrete type Empty<G ┤ Cons <g>> extends List <g>{}
[0104] In the above example, the notation A ┤ B means that a data object of type A must not directly reference a data object of type B at runtime, or any data object that directly references a data object of type B. <number>is valid. Depending on the font ligature used in the source code editor, the notation may be written as a dash bar and the symbol may appear in the source programming language source as ('┤') or ('-|'). Other text-based notations may be used to express the restriction "A must not point to B," and the invention is not limited to the dash bar notation.
[0105] According to this technology, as a result of the above data type definition, Cons <f>The data type definitions are generic, recursive, and importantly free of reference cycles.
[0106] FIG. 6C is an example data type definition graph for the above data type definition using read-only and initial hints and additional information. As can be seen, the data type definition is <f>Start with a reference from Cons <f>Cons <f>There is no potential reference cycle with a '<' edge going back to . The difference between the data type definition graph in Figure 6B and the data type definition graph in Figure 6C is that the F data object is written as 'Top ┤ (Cons <f>)". This restriction means that the types <f>Or Cons <f>However, there is no "may-be" connection to Empty <f>This will be possible.
[0107] Example of the data type checking process 7A, 7B, 7C, 7D, 7E, 7F, 7G, and 7H include flow charts of examples of data type checking processes. The data type checking process may be performed by a compiler of source code of a source programming language, where the source code includes a concrete data type definition. The compiler may perform the data type checking process to determine whether a concrete data type definition allows for a reference cycle at runtime. Upon detecting a concrete data type definition that allows for a reference cycle at runtime, the compiler may stop the compilation process or output an alert. The alert may be output to a user interface (e.g., graphical or command line), to a file, to a database, or to another data container suitable for the alert. The alert may be an error or warning message indicating that there was a problem with the concrete type definition identified by the type checking process. For example, the message may identify the concrete data type definition that allows for a reference cycle at runtime. For example, the identification may include the name of the source code file and the line number in the source code file, or a set or span of line numbers in the source code file where the concrete data type definition is defined, along with a description of the error or warning. For example, the description might read "The concrete type Cons defined on line 52 of mysource.src <f>allows for reference cycles."
[0108] The compiler performing the type checking process may be a source-to-source compiler that compiles source code in a source programming language into one or more target programming languages, the one or more target programming languages including at least one target programming language with minimal run-time support for deallocation (e.g., a non-implicit deallocation service). For example, the target programming language may be any of C, C++, OBJECTIVE-C, or RUST. Alternatively, the compiler of the source code may process the source code for quality control purposes without further translating the intermediate representation of the source code into a target programming language. As yet another alternative, the compiler may be a source-to-source compiler that compiles source code in a source programming language into one or more target programming languages, all of which support implicit deallocation. In this case, type checking may be performed for quality control purposes, such as reducing or eliminating the need for run-time garbage collection or cycle detection.
[0109] 7A, the data type checking process begins with an empty list of unconstructed nodes for a data type checking graph of a concrete data type C defined in the source code (712). The empty list may be any suitable list data structure initialized in a computer storage medium. As an example, the description of the data type checking process uses the following data type definitions expressed in a possible source programming language: 00: Closed type List <E ┤ Cons <e>>; 01: closed concrete type Cons<F ┤ Cons <f>> extends List <f>{ 02: head: F; 03: readonly early tail: List <f>; 04:} 05: closed concrete type Empty<G ┤ Cons <g>> extends List <g>{}
[0110] In the embodiment, C is a concrete data type Cons <f>It is.
[0111] In operation 714, elements representing nodes of concrete data type C of the graph are added to the unconstructed node list. <f>An element representing a node of may be added to the unconstructed node list.
[0112] At operation 716, it is determined whether the unconstructed node list is empty (i.e., does not contain any elements). If the unconstructed node list is not empty, operations 718, 720, 722, and 724 are performed for the current node on the unconstructed node list.
[0113] At operation 718, a current node N on the to-be-constructed node list is identified. For example, the current node N may be a node corresponding to an element that was recently added to the to-be-constructed node list. In an embodiment, the current node N is a node of concrete data type Cons <f>, may be a node added to
[0114] In operation 720, the element representing the current node N is removed from the unconstructed node list. <f>The element representing the current node N of may be removed from the unconstructed node list.
[0115] Operation 722 is performed for each direct subdata type S defined in the source code that extends the data type represented by the current node N. The subdata types may directly extend the data type represented by the current node N in the sense of subclasses or child classes, as is typically possible in object-oriented programming languages that support trait-based inheritance. The source programming language may support such trait-based inheritance. Traits provide a mechanism for fine-grained code reuse. A trait may be defined as a set of methods that are independent of a class hierarchy and can be flexibly used to construct other traits or classes by a series of composition operations.
[0116] Operation 722 is illustrated in more detail with respect to FIG. 7B. In an embodiment, the current node N is <f>When the data type is Cons <f>There is no direct subtype defined to extend the concrete data type Cons <f>This may not be done for any direct subdatatype S of
[0117] Operation 724 is performed for each property P of the data type represented by the current node N. The properties [AS12] of the data type may correspond to member variable definitions in the source code of the definition of the data type represented by the current node N. The member variables may be static variables or instance variables of the data type. Operation 724 is shown in more detail with respect to FIG. 7C. In an embodiment, operation 724 includes a Cons <f>This can be done for each of the head and tail properties defined for the data type.
[0118] After operations 718, 720, 722, and 724 have been performed for the current node N, the process returns to operation 716 to consider any remaining elements on the not yet constructed node list corresponding to other nodes. If no elements remain on the not yet constructed node list at operation 716, then at operation 726 the elements of all nodes removed at operation 720 are added back to the not yet constructed node list for further processing as described below with respect to FIG.
[0119] As previously discussed, act 722 of Figure 7A is performed for each subdata type S of the source code that directly extends the data type represented by the current node N. Figure 7B is a flow chart of act 722.
[0120] In operation 728, if the current direct sub-data type S is a generic type, the current direct sub-data type S is converted using the type parameters of the data type represented by the current node N. For example, <x>Super <Bar <x>> extends "Super <Bar <baz>Given a supertype, such as "Baz", the transformation may involve finding appropriate bindings for each of Sub's type parameters. In this example, X is bound to Baz, and Sub <baz>Super <Bar <baz>> to expand the converted sub data type, Sub <baz>This will be the case. <x>Super <Bar <x>> is known to reflect that when X is replaced by Baz, and will no longer bind to X, X will be prevented from binding to Baz.
[0121] At operation 730 it is determined whether an element representing a node of the current direct sub-data type S is on the not yet constructed node list. If not, at operation 732 an element is created for the node representing the current direct sub-data type S, and at operation 734 the element is added to the not yet constructed node list. In either case, an edge is added (736) to the data type definition graph of the concrete data type C, the edge being from the current node N to a node of the current direct sub-data type S. The edge is qualified with the "may be" requirement in that a data object that is an instance of the data type represented by the current node N may also be an instance of the current direct sub-data type S.
[0122] As previously mentioned, operation 724 of Figure 7A is performed for each property P of the data type represented by the current node N defined in the source code. Figure 7C is a flow chart of operation 724. In an embodiment, the current node N is a node in the Cons <f>If so, then operation 724 is performed for each of the head and tail properties.
[0123] In operation 738, the data type of the current property P is converted using the type parameters of the data type represented by the current node N. In this example, the current property P is <f>The data type of the current property P is a generic type F when it is the head property of a data type. <f>The data type of the current property P is List when it is a tail property of a data type. <f>It is.
[0124] At operation 740, it is determined whether an element representing a node of the current direct subdata type S is on the unconstructed node list. If not, at operation 742, an element is created for the node representing the data type of the current property P. At operation 744, the element is added to the unconstructed node list. In this example, the current property P is Cons <f>When a data type's head property is created, the elements of the graph's nodes that represent the generic data type F are added to the unconstructed node list. <f>When it is a tail property of a data type, List <f>The elements of the graph nodes that represent the data type are added to the unbuilt nodes list.
[0125] In operation 746, the current property P may be defined as read-only and initial. In an embodiment, the current property P is Cons <f>When it is the head property of a data type, Cons <f>It may be determined that the current property P is not read-only or initial because there is no such keyword hint in the property definition of the data type's data type definition. On the other hand, if the current property P is Cons <f>When the current property P is a tail property of a data type, Cons <f>Read-only early may be determined by the presence of such keyword hints in the property definition for the tail property of the data type.
[0126] In operation 748, if the current property P is read-only and initial, an edge is added to the data type definition graph of the concrete data type C, the edge being from the current node N to the node representing the data type of the current property P. The edge is qualified with a "<=" requirement. In an embodiment, if the current property P is Cons <f>When a data type is a tail property, edges with "<=" requirements are ignored because tail properties are read-only and initial. <f>From a node that represents a data type to a List <f>It will be added to the node that represents the data type.
[0127] In operation 750, if the current property P is not read-only and not initial, an edge is added to the data type definition graph of the concrete data type C, the edge being from the current node N to the node representing the data type of the current property P. In this case, the edge is qualified with a "<" requirement. In an embodiment, if the current property P is Cons <f>When it is the head property of a data type, the edge with the "<" requirement is not a Cons <f>From the node representing the data type, an F data type will be added to the node representing the F data type.
[0128] In the embodiment, Cons <f>After operation 724 is performed on the head and tail properties of the data type, the process returns to operation 716 to determine if the unconstructed node list is empty. <f>Elements of the data type have been added to the unconstructed node list so that the list is not empty. These nodes are removed from the list in operation 720. Operation 722 returns the List <f>Direct subtype Empty that extends a data type <f>Since it has List <f>The operation 722 is not performed on generic data type F because there are no direct subdata types that extend generic data type F. The operation 722 is not performed on generic data type F or List because these data types have no defined properties. <f>No action 724 is performed on the data type List <f>As a result of performing operation 722 on a data type, Empty <f>A node of data type is added to the graph (action 734), and edges with "possible" requirements are added to the List <f>Empty from the data type node <f>The Empty <f>Only elements in the unconstructed node list that are nodes that represent data types are removed in operation 720 and the Empty <f>Because the data type does not have any direct subdata types that extend it or any defined properties, operations 722 and 724 are not performed on the node.
[0129] 7D, the data type checking process for concrete data type C continues with the list of unconstructed nodes resulting from operation 726 of FIG. 7A after all elements of the nodes constructed according to the sub-processes of FIG. 7A, FIG. 7B, and FIG. 7C have been added back to the unconstructed node list. In an embodiment, at this point in the process, the Empty <f>、List <f>, F, and Cons <f>The elements of these nodes are added back to the unconstructed node list.
[0130] At operation 752, it is determined whether the unconstructed node list is empty (i.e., does not contain any elements). If the unconstructed node list is not empty, operations 754, 756, and 758 are performed on the current node on the unconstructed node list to construct a node.
[0131] A current node N on the unconstructed node list is identified in operation 754. For example, the current node N may be the node corresponding to the element most recently added to the unconstructed node list.
[0132] In operation 756, the element representing the current node N is removed from the unconstructed node list.
[0133] Operations 760, 762, 764, 766, and 768 may be performed for each super data type that the data type represented by the current node N directly extends, as defined in the source code. The data type represented by the current node N may directly extend the super data type in the sense of a superclass or parent class, as is typically possible in object-oriented programming languages that support trait-based inheritance. The source programming language may support such trait-based inheritance.
[0134] For purposes of operations 760, 762, 764, 766, and 768, if the data type represented by the current node N does not directly extend a super data type defined in the source code, then that data type is considered to directly extend a hypothetical "top" super data type that represents a hypothetical super data type of all other data types. Thus, at least operation 768 is performed for each current node N that is considered to directly extend a top super data type, and operations 746 and 766 are each performed once for the top super data type.
[0135] In operation 760, if the current direct super type T is a generic type, the current direct super data type T is converted using the type parameters of the data type represented by the current node N.
[0136] At operation 762 it is determined whether an element representing a node of the current direct subdata type T is on the not yet constructed node list. If not, at operation 764 an element is created for the node representing the current direct superdata type T, and at operation 766 the element is added to the not yet constructed node list. In either case, at operation 768 an edge is added to the data type definition graph of the concrete data type C, the edge being from a node of the current direct superdata type T to the current node N. The edge is qualified with the "may be" requirement in that a data object that is an instance of the current direct superdata type T could also be an instance of the data type represented by the current node N.
[0137] After operations 754, 756, and 758 have been performed for the current node N, the process returns to operation 752 to consider any remaining elements on the unconstructed node list corresponding to other nodes. If there are no elements remaining on the unconstructed node list at operation 752, the subprocess illustrated by the flowchart of Figure 7D ends.
[0138] In the embodiment, Cons <f>List, the super data type of the data type <f>The nodes of are of concrete data type Cons <f>In operation 768, there is a "possible" requirement, List <f>Cons <f>Edges are added to the graph up to the nodes of the data type. <f>The data type is Empty. <f>However, edges with "possible" requirements are also supertypes of List <f>When considering direct subdata types that extend a data type, in operation 736 of FIG. 7B, List <f>From the node Empty <f>The edge has already been added to the node representing the generic data type F in operation 768. Therefore, in operation 768, the edge does not need to be added again. Also, in operation 768, edges with "possible" requirements are added from the top super data type of all nodes to the node representing the generic data type F. Similarly, in operation 768, edges with "possible" requirements are added from the top super data type node to the node representing the generic data type F in operation 768. <f>Added to nodes that represent generic data types.
[0139] Referring now to FIG. 7E, the data type checking process for concrete data type C continues with the nodes and edges of the data type definition graph for concrete data type C as they exist after the execution of the sub-processes illustrated by the flowcharts of FIGS. 7A, 7B, 7C, and 7D has been performed on concrete data type C.
[0140] At this point in constructing the graph for concrete data type C, the graph consists of data type nodes but no limit nodes. The data type nodes of the graph are created based on the direct subdatatypes of concrete data type C, the data types of the properties of concrete data type C, and the superdatatypes of their direct subdatatypes, their property datatypes, and the concrete data type C, as described above with respect to Figures 7A, 7B, 7C, and 7D.
[0141] Limit nodes may be added by a compiler to the data type definition graph of a concrete data type C to group unrestricted data type nodes. An unrestricted data type node in this context is a node that represents either (a) an unclosed data type, in the sense that not all subdata types are known to the compiler at compile time, or (b) a generic data type.
[0142] Operation 770 may be performed for each node in the graph that is a data type node. Operation 772 determines whether the data type represented by the current data type node N is unrestricted. If "NO", operations 774, 776, 778, and 780 are not performed for the current data type node N. If "YES", operations 774, 776, 778, and 780 are performed for the current data type node N. In an embodiment, the following are selected: Top, Empty <f>、List <f>, F, and Cons <f>A data type node is a data type node in the graph. <f>、List <f>, F, and Cons <f>The data type nodes are not restricted since they are generic data types.
[0143] In operation 774, the "YES" set of data types that are converted super data types of the data type represented by the current data type node N is determined.
[0144] In operation 776, a "NO" set that may not refer to a restriction on the data type represented by the current data type node N is determined.
[0145] In operation 778, if a limit node LN has not been added to the graph of the concrete data type C for the combination of the current YES set and the current NO set, a limit node LN is created for the combination and added to the graph.
[0146] In operation 780, an edge with a "possible" requirement is added to the graph from the node N representing the current data type to the limit node LN for the current combination of YES and NO.
[0147] Referring now to FIG. 7F, the data type checking process for concrete data type C continues with the nodes and edges of the data type definition graph for concrete data type C as they exist after the execution of the sub-processes illustrated by the flowcharts of FIGS. 7A, 7B, 7C, 7D, and 7E has been performed on concrete data type C.
[0148] Operation 782 is performed for each limit node in the graph. And for each limit node in the graph, operation 784 is performed for each of the data type nodes in the graph.
[0149] In operation 786, it is determined whether the data type of the current node N is a sub-data type of each data type in the YES set for the current limit node LN (operation 774 of FIG. 7E). If so, the process proceeds to operation 788. If not, the sub-process of FIG. 7F ends.
[0150] In operation 788, it is determined whether any data type in the NO set of the current limit node LN (operation 776 in FIG. 7E) is a sub-data type of the data type of the current node N. If so, the subprocess of FIG. 7F ends. If not, in operation 790, an edge is created in the graph from the current limit node LN to the current data type node N that has a less than "<" requirement.
[0151] Referring now to FIG. 7G, the data type checking process for concrete data type C continues with the nodes and edges of the data type definition graph for concrete data type C as they exist after the execution of the sub-processes illustrated by the flowcharts of FIGS. 7A, 7B, 7C, 7D, 7E, and 7F has been performed on concrete data type C.
[0152] In operation 792, the set CHAIN is initialized to be an empty set of edges.
[0153] In operation 794, the set VISITED is initialized to be an empty set of nodes.
[0154] In operation 796, a sub-process is invoked starting with concrete data type C for which a data type definition graph has been generated according to the sub-processes of Figures 7A, 7B, 7C, 7D, 7E, and 7F. The sub-process looks for inconsistencies in the graph, which is described in more detail below with reference to Figure 7H.
[0155] In operation 798, any problems detected during the type checking process are reported. For example, for each potential reference cycle identified in the source code written in the source programming language, output can be provided to a computer user interface, such as a command line interface or a graphical user interface, or to a file or database that provides a human-readable description of the potential reference cycle. The output can be, for example, text such as "A value of type 'Thing' may reference itself using its property 'otherThing'. 'aThing.otherThing=aThing;' would give rise to a reference cycle." The output can be derived from metadata associated with nodes or edges of a data type definition graph of the concrete data type C in which the potential reference cycle was detected. The output can also suggest ways to correct the problem, such as avoiding the potential reference cycle. The output can be input to an integrated development environment (IDE) program to modify the source code automatically or based on suggestions selected or approved by a human programmer.
[0156]
[0046] Referring now to Figure 7H, there is shown a flow chart of the sub-process search for contradictions invoked in sub-process operation 796 of Figure 7G. The sub-process is invoked with a current node N. Also, the sub-process may be recursive or may be implemented in a non-recursive but equivalent manner. In the first invocation of the sub-process search for contradictions, the current node N is a node of the graph representing the concrete data type C for which the data type definition graph was generated.
[0157] At operation 800, it is determined whether the current node N is in the VISITED set. If the current node N is in the VISITED set, the sub-process search for contradictions proceeds to operation 802.
[0158] At operation 802, it is determined whether the CHAIN set contains an edge with a "<" requirement. If so, the subprocess proceeds to operation 804.
[0159] In operation 804, a potential reference cycle problem is reported for the concrete data type C. For example, the set of edges in the CHAIN set may be used to report the problem and derive a human-readable explanation of the problem.
[0160] If, at operation 802, there is no edge in the CHAIN set with a "<" requirement, then, at operation 806, the current node N is removed from the VISITED set and the current invocation of the sub-process search for contradictions returns / ends.
[0161] If, at operation 800, the current node N is not in the VISITED set, then, at operation 808, the current node N is added to the VISITED set.
[0162] Operation 810 is performed for each edge of the graph from the current node N.
[0163] At operation 812, if the CHAIN set is empty or the current edge E has a "<" or "<=" requirement, then at operation 814 the current edge E is added to the CHAIN set and the search for contradictions sub-process is recursively called (816), providing the target node of the graph of the current edge E as an input node to the recursive call, and when the recursive call returns / ends, the current edge E is removed (818) from the end of the CHAIN set before proceeding to operation 806. At operation 812, if CHAIN is not empty or the current edge E does not have a "<" or "<=" requirement, then the sub-process proceeds to operation 806.
[0164] advantage Provably acyclic objects have a number of advantages. For one, reference counting is sufficient to deallocate objects in a timely manner at runtime. For another, certain runtime meta-operations are simplified and made more reliable. These runtime meta-operations are: Comparing two objects at run time to see if they are structurally equal (i.e., determining that two objects are the same type of object whose corresponding properties are themselves structurally equivalent); and Obtaining a fingerprint of an object at run time, regardless of how its parts are arranged in memory; and Serializing the object for transmission to another computing process or computer; Converting the object into a diagnostic form that can be presented to a human programmer debugging the problem.
[0165] Reference-cycle-free data type definitions also have advantages in distributed computing systems. For example, distributed garbage collection can require substantial inter-process communication (e.g., data network) messaging back and forth between distributed computing processes when many property values are on different computing nodes of the system than the objects that contain those property values. On the other hand, if all data types are acyclic, distributed garbage collection can be replaced by distributed reference counting, with reference count updates batched into a smaller number of small messages that can be acted upon by nodes in the system and experienced less latency by the computing processes at the nodes.
[0166] Basic Computing Device The present technology may be implemented by at least one computing device. In the case of two or more computing devices, the present technology may be implemented in whole or in part using a combination of computing devices coupled together using a network such as a packet data network. The computing device used in the implementation of the present technology may be hardwired to perform some or all of the present technology, or may include digital electronic devices such as at least one application specific integrated circuit (ASIC) or field programmable gate array (FPGA) that are permanently programmed to perform some or all of the present technology, or may include at least one general-purpose hardware processor that is programmed to perform some or all of the present technology according to program instructions in firmware, memory, other storage, or a combination thereof. The computing device used in the implementation of the present technology may also combine custom hardwired logic, ASIC, or FPGA with custom programming to achieve some or all of the present technology. The computing device used in the implementation of the present technology may be a server computing device, a workstation computing device, a personal computing device, a portable computing device, a handheld computing device, a mobile computing device, or any other computing device that incorporates hardwired logic or program logic to implement some or all of the present technology.
[0167] Figure 8 is a block diagram of an exemplary basic computing device that may be used in embodiments of the present technology. In the example of Figure 8, computing device 800 and instructions for implementing some or all of the present technology in hardware, software, or a combination of hardware and software are represented generally as boxes and circles at the same level of detail commonly used by those of ordinary skill in the art to which this disclosure pertains in communicating computer architecture and computing device embodiments.
[0168] Computing device 800 includes an input / output (I / O) subsystem 802, which may include a bus or other communication mechanism for communicating information or instructions between components of computing device 800 over electronic signal paths. I / O subsystem 802 may include an I / O controller, a memory controller, and at least one I / O port. The electronic signal paths are represented in the drawings generally, for example, as lines, one-way arrows, or two-way arrows.
[0169] At least one hardware processor 804 is coupled to the I / O subsystem 802 for processing information and instructions. The hardware processor 804 may include, for example, a general purpose microprocessor or microcontroller, or an embedded system or a special purpose microprocessor such as a graphics processing unit (GPU) or a digital signal processor or an ARM processor. The processor 804 may include an integrated arithmetic logic unit (ALU) or may be coupled to a separate ALU.
[0170] Computing device 800 includes one or more units of memory 806, such as a main memory, coupled to I / O subsystem 802 for electronically and digitally storing data and instructions executed by processor 804. Memory 806 may include volatile memory, such as various forms of random access memory (RAM) or other dynamic storage. Memory 806 may also be used to store temporary variables or other intermediate information during execution of instructions executed by processor 804. Such instructions, when stored in a non-transitory storage medium accessible to processor 804, may render computing device 800 into a special-purpose machine that is customized to perform operations specified in the instructions.
[0171] The computing device 800 further includes a non-volatile memory, such as a read only memory (ROM) 808 or other static storage coupled to the I / O subsystem 802 for storing information and instructions for the processor 804. The ROM 808 may include various forms of programmable ROM (PROM), such as erasable programmable ROM (EPROM) or electrically erasable programmable ROM (EEPROM). A unit of persistent storage 810 may include various forms of non-volatile RAM (NVRAM), such as flash memory, or solid state storage, magnetic disks, or optical disks, such as CD-ROM or DVD-ROM, and may be coupled to the I / O subsystem 802 for storing information and instructions. The storage 810 is an example of a non-transitory computer-readable medium that may be used to store instructions and data that, when executed by the processor 804, cause a computer-implemented method to perform some or all of the present technology.
[0172] The instructions in the memory 806, ROM 808, or storage 810 may include one or more sets of instructions organized as a module, method, object, function, routine, or call. The instructions may be organized as one or more computer programs, operating system services, or application programs, including mobile apps. The instructions may include an operating system or system software; one or more libraries supporting multimedia, programming, or other functionality; data protocol instructions or stacks for implementing TCP / IP, HTTP, or other communications protocols; file processing instructions for interpreting and rendering files coded using HTML, XML, JPEG, MPEG, or PNG; user interface instructions for rendering or interpreting commands in a graphical user interface (GUI), command line interface, or text user interface; application software, such as an office suite, Internet access applications, design and manufacturing applications, graphics applications, audio applications, software engineering applications, educational applications, games, or other applications. The instructions may implement a web server, a web application server, or a web client. The instructions may be organized as a presentation layer, an application layer, and a data storage layer, such as a relational database system using Structured Query Language (SQL) or NoSQL, an object store, a graph database, a flat file system, or other data storage.
[0173] The computing device 800 may be coupled to at least one output device 812 via the I / O subsystem 802. The output device 812 may be a digital computer display. Examples of displays that may be used include a touch screen display or a light emitting diode (LED) display or a liquid crystal display (LCD), or an electronic paper display. The computing device 800 may include other types of output devices 812 instead of or in addition to a display device. Examples of other output devices 812 include a printer, a ticket printer, a plotter, a projector, a sound or video card, a speaker, a buzzer or piezoelectric device or other audible device, a lamp or LED or LCD indicator, a tactile device, an actuator or servo.
[0174] Input devices 814 may be coupled to the I / O subsystem 802 for communicating signals, data, command selections, or gestures to the processor 804. Examples of input devices 814 include touch screens, microphones, still and video digital cameras, alphanumeric and other keys, keypads, keyboards, graphic tablets, image scanners, joysticks, clocks, switches, buttons, dials, slides, or various types of sensors such as force sensors, motion sensors, thermal sensors, accelerometers, gyroscopes, inertial measurement unit (IMU) sensors, or various types of transceivers such as wireless, radio frequency (RF) transceivers or infrared (IR) transceivers such as cellular or Wi-Fi, and global positioning system (GPS) transceivers.
[0175] Another type of input device is a control device 816, which may instead of or in addition to input functions perform cursor control or other automated control functions such as navigation in a graphical interface on a display screen. The control device 816 may be a touchpad, mouse, trackball, or cursor direction keys for communicating directional information and command selections to the processor 804 and controlling cursor movement on the display 812. The input device may have at least two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), that allow the device to specify a position in a plane. Another type of input device is a wired, wireless, or optical control device, such as a joystick, wand, console, steering wheel, pedals, gear shift mechanism, or other type of control device. The input device 814 may include a combination of multiple different input devices, such as a video camera and a depth sensor.
[0176] Computing device 800 may comprise an Internet of Things (IoT) device or other computing equipment in which one or more of output device 812, input device 814, and control device 816 are omitted. Input device 814 may comprise one or more cameras, motion detectors, thermometers, microphones, earthquake detectors, other sensors or detectors, measurement devices or encoders, and output device 812 may comprise a dedicated display, such as a single-line LED display or a single-line LCD display, one or more indicators, display panels, meters, valves, solenoids, actuators, or servos.
[0177] When computing device 800 is a mobile or portable computing device, input device 814 may comprise a Global Positioning System (GPS) receiver coupled to a GPS module capable of triangulating multiple GPS satellites and determining and generating geolocation information or location data, such as latitude and longitude values for the geophysical location of computing device 800. Output device 812 may include hardware, software, firmware, and interfaces for generating position report packets, notifications, pulse or heartbeat signals, or other repetitive data transmissions specifying the location of computing device 800, alone or in combination with other application-specific data directed to host 824 or server 830.
[0178] Computing device 800 may implement some or all of the present technology using customized hardwired logic, at least one ASIC or FPGA, firmware, or program instructions or logic that, when loaded and used or executed in conjunction with computing device 800, activate or program computing device 800 to operate as a special-purpose machine.
[0179] The techniques performed by computing device 800 may be performed in response to processor 804 executing at least one sequence of at least one instructions contained in main memory 806. Such instructions may be read into main memory 806 from another storage medium, such as storage 810. Execution of the sequences of instructions contained in main memory 806 causes processor 804 to perform some or all of the techniques. Hardwired circuitry may be used in place of or in combination with software instructions.
[0180] The term "storage medium" as used herein refers to any non-transitory computer-readable medium that stores data or instructions that cause a machine to operate in a specific manner. Such storage media may include non-volatile media or volatile media. Non-volatile media include, for example, optical or magnetic disks, such as storage 810. Volatile media include dynamic memory, such as memory 806. Common forms of storage media include, for example, hard disks, solid-state drives, flash drives, magnetic data storage media, any optical or physical data storage media, memory chips, and the like.
[0181] Storage media are distinct from but may be used in combination with transmission media. Transmission media involves transferring information between storage media. For example, transmission media include coaxial cables, copper wire, and fiber optics, including the wires that comprise a bus in I / O subsystem 802. Transmission media can also take the form of acoustic or light waves, such as those generated during radio wave and infrared data communications.
[0182] Various forms of media may be involved in carrying at least one sequence of at least one instructions to processor 804 for execution. For example, the instructions may initially be stored on a magnetic disk or solid state drive of a remote computer. The remote computer can load the instructions into a dynamic memory and send the instructions over a communications link, such as a fiber optic or coaxial cable or a telephone line using a modem. A modem or router local to computing device 800 can receive the data over the communications link and convert the data so that it can be read by computing device 800. For example, a receiver, such as a radio frequency antenna or infrared detector, can receive the data carried in a radio or optical signal and appropriate circuitry can provide the data to I / O subsystem 802, such as placing the data on a bus. I / O subsystem 802 carries the data to memory 806, and processor 804 retrieves and executes the instructions from memory 806. The instructions received by memory 806 may optionally be stored in storage 810 either before or after execution by processor 804.
[0183] The computing device 800 also includes a communications interface 818 coupled to the bus 802. The communications interface 818 provides a two-way data communication coupling to a network link 820 that is directly or indirectly connected to at least one communications network, such as a network 822 or a public or private cloud on the Internet. For example, the communications interface 818 can be an Ethernet networking interface, an Integrated Services Digital Network (ISDN) card, a cable modem, a satellite modem, or a modem that provides a data communication connection to a corresponding communications line type (e.g., an Ethernet cable or any type of metal cable, or a fiber optic line or a telephone line), or the like. The network 822 broadly represents a local area network (LAN), a wide area network (WAN), a campus network, an internetwork, or any combination thereof. The communications interface 818 can comprise a LAN card that provides a data communication connection to a compatible LAN, or a cellular radiotelephone interface that is wired to transmit or receive cellular data according to a cellular radiotelephone wireless networking standard, or a satellite wireless interface that is wired to transmit or receive digital data according to a satellite wireless networking standard. In any such implementation, communication interface 618 sends and receives electrical, electromagnetic or optical signals via signal paths that carry digital data streams representing various types of information.
[0184] Network link 820 typically provides electrical, electromagnetic or optical data communication directly or through at least one network to other data devices, for example using satellite, cellular, Wi-Fi®, or BLUETOOTH® technology. For example, network link 820 may provide a connection through network 822 to a host computer 824.
[0185] Further, network link 820 may provide connectivity through network 822 or to other computing devices through internetworking devices and / or computers operated by an Internet Service Provider (ISP) 826. ISP 826 provides data communication services through a worldwide packet data communications network represented as Internet 828. A server computer 830 may be connected to Internet 828. Server 830 broadly represents any computer with or without a hypervisor, data center, virtual machine or virtual computing instance, or a computer running a containerized program system such as DOCKER or KUBERNETES. Server 830 may represent a digital electronic service, which may be implemented using two or more computers or instances, and which may be accessed and used by transmitting web service requests, uniform resource locator (URL) strings with parameters of HTTP payloads, API calls, app service calls, or other service calls.
[0186] The computing device 800 and the server 830 may form elements of a distributed computing system that includes other computers, processing clusters, server farms, or other organizations of computers that cooperate to perform tasks or execute applications or services. The server 830 may include one or more sets of instructions organized as modules, methods, objects, functions, routines, or calls. The instructions may be organized as one or more computer programs, operating system services, or application programs, including mobile apps. The instructions may include operating systems and / or system software; one or more libraries supporting multimedia, programming, or other functionality; data protocol instructions or stacks for implementing TCP / IP, HTTP, or other communications protocols; file format processing instructions for interpreting or rendering files coded using HTML, XML, JPEG, MPEG, or PNG; user interface instructions for rendering or interpreting commands in a graphical user interface (GUI), command line interface, or text user interface; application software, such as an office suite, Internet access applications, design and manufacturing applications, graphics applications, audio applications, software engineering applications, educational applications, games, or other applications. Servers 830 may include web application servers hosting a presentation tier, an application tier, and a data storage tier, such as a relational database system using Structured Query Language (SQL) or NoSQL, an object store, a graph database, a flat file system, or other data storage.
[0187] Computing device 800 can send messages and receive data and instructions, including program code, through the network(s), network link 820 and communication interface 818. In the Internet example, a server 830 might transmit a requested code for an application program through the Internet 828, ISP 826, local network 822 and communication interface 818. The received code may be executed by processor 804 as it is received, or may be stored in storage 810, or other non-volatile storage for later execution.
[0188] Basic Software Systems Figure 9 is a block diagram of an exemplary basic software system 900 that may be employed to control the operation of the computing device 800 of Figure 8. The software system 900 and its components, including their connections, relationships, and functionality, are intended to be exemplary only and are not intended to limit the implementation of the present technology. Other software systems suitable for implementing the present technology may have different components, including components with different connections, relationships, and functionality.
[0189] The software system 900 is provided to direct the operation of the computer system 800. The software system 900 includes a kernel or operating system (OS) 910, which may be stored in the system memory (RAM) 806 and in persistent storage (e.g., a hard disk or flash memory) 810.
[0190] The OS 910 manages low-level aspects of computer operation, including managing the execution of processes represented as 902-1, 902-2, 902-3...902-N, memory allocation, file input / output (I / O), and device I / O. One or more application programs may be "loaded" (e.g., transferred from persistent storage 810 to memory 806) for execution as one or more processes by the system 900. Applications or other software intended for use on the computing device 800 may also be stored as a downloadable set of computer-executable instructions, for example, for downloading and installation from an Internet location (e.g., a web server, app store, or other online service).
[0191] The execution of application program instructions may embody a process (e.g., 902-2) in the form of an instance of a computer program that is running and consists of program code and its current activity. Depending on the operating system (OS), a process (e.g., 902-3) may consist of multiple threads of execution that execute instructions simultaneously. In this context, a computer program is a passive collection of instructions, while a process (e.g., 902-1) may be the actual execution of those instructions. Several processes (e.g., 902-1 and 902-2) may be associated with the same program. For example, opening several instances of the same program often means that there are two or more processes running, or a program that initially launches as a single process may subsequently spawn (e.g., fork) additional processes.
[0192] The OS 910 may implement multitasking to allow processes 902-1, 902-2, 902-3...902-N to share the processor 804. Although each of the processors 804 or processor cores executes a single task at a time, the computing device 800 may be programmed to implement multitasking to allow each processor to switch between tasks that are running without having to wait for each task to finish. Switching may occur when a task performs an I / O operation, when the task indicates that it is available to switch, or upon a hardware interrupt. Time sharing may be implemented to allow fast response of interactive user applications by providing rapid context switching to give the appearance of multiple processes occurring simultaneously. For security and reliability, the OS 910 may prevent direct communication between independent processes and provide a tightly mediated and controlled inter-process communication facility.
[0193] In some examples, processes 902-1, 902-2, 902-3...902-N, and the application programs they implement, may be executed within an application container 940. An application container is generally an operating mode of OS 910 that allows the existence of multiple isolated user space instances to run on OS 910. Application container 940 is an example of such an instance. The instances themselves may alternatively be referred to as zones, virtual private servers, partitions, virtual environments, virtual kernels, or jails. Application containers provide a mechanism by which finite hardware computing resources, such as CPU time and storage media space, can be allocated among the instances.
[0194] The software system 900 includes a graphical user interface (GUI) 915 for receiving user commands and data in a graphical (e.g., "point-and-click" or "touch gesture") manner. These inputs may then be processed by the system 900 according to instructions from the operating system 910 or processes 902-1, 902-2, 902-3...902-N. The GUI 915 is then also responsible for displaying the results of operations from the OS 910 and processes 902-1, 902-2, 902-3...902-N, 902-N, after which the user may provide additional input or terminate the session (e.g., log off).
[0195] The OS 910 may execute directly on the bare hardware 920 (e.g., processor 804) of the computing device 800. Alternatively, a hypervisor or virtual machine monitor (VMM) 930 may be inserted between the bare hardware 920 and the OS 910. In this configuration, the VMM 930 acts as a software "cushion" or virtualization layer between the OS 910 and the bare hardware 920 of the computing device 800.
[0196] VMM 930 instantiates and runs one or more virtual machine instances ("guest machines"). Each guest machine comprises a "guest" operating system, such as OS 910, and one or more applications, such as application 902, designed to run on the guest operating system. VMM 930 presents the guest operating systems to a virtual operating platform and manages the execution of the guest operating systems.
[0197] In some examples, the VMM 930 may enable guest operating systems to run as if they were running directly on the bare hardware 920 of the computing device 800. In these examples, the same version of a guest operating system that is configured to run directly on the bare hardware 920 may also run on the VMM 930 without modification or reconfiguration. In other words, the VMM 930 may, in some examples, provide complete hardware and CPU virtualization to the guest operating systems.
[0198] In other examples, the guest operating systems may be specially designed or configured to run on the VMM 930. In these examples, the guest operating systems "know" that they are running on a virtual machine monitor. In other words, the VMM 930 may, in some examples, provide paravirtualization to the guest operating systems.
[0199] Cloud Computing The technology may be implemented in a "cloud computing" environment. The term "cloud computing" is generally used herein to describe a computing model that enables on-demand access to a shared pool of computing resources, such as computer networks, servers, software applications, and services, enabling rapid provisioning and release of resources with minimal administrative effort or interaction with service providers.
[0200] Cloud computing environments (sometimes referred to as cloud environments or clouds) can be implemented in a variety of different ways to best suit different requirements. For example, in a public cloud environment, the underlying computing infrastructure is owned by an organization that makes its cloud services available to other organizations or to the general public. In contrast, a private cloud environment is generally intended for use only by or within a single organization. A community cloud is intended to be shared by several organizations within a community, while a hybrid cloud includes two or more types of clouds (e.g., private, community, public) bound together by data and application portability.
[0201] Generally, the cloud computing model allows some of the responsibilities that may have previously been provided by an organization's own information technology department to instead be provided as service tiers within a cloud environment for use by consumers (either within the organization or outside the organization, depending on the public / private nature of the cloud). Depending on the particular implementation, the exact definition of the components or functions provided by or within each cloud service tier may vary, but common examples include Software as a Service (SaaS), where a consumer uses software applications running on a cloud infrastructure, while the SaaS provider manages or controls the underlying cloud infrastructure and applications. In Platform as a Service (PaaS), a consumer can develop, deploy, and otherwise control its own applications using software programming languages and development tools supported by the PaaS provider, while the PaaS provider manages or controls other aspects of the cloud environment (e.g., everything below the runtime execution environment). In Infrastructure as a Service (IaaS), consumers can deploy and launch any software applications and / or provisioning processing, storage, network, and other underlying computing resources, while the IaaS provider manages or controls the underlying physical cloud infrastructure (e.g., everything below the operating system layer). In Database as a Service (DBaaS), consumers use database servers or database management systems running on the cloud infrastructure, while the DbaaS provider manages or controls the underlying cloud infrastructure, applications, and servers, including one or more database servers.
[0202] Other Aspects of the Disclosure Unless the context clearly dictates otherwise, the term "or" is used in the foregoing specification and the appended claims in its inclusive (and not exclusive) sense, and thus, for example, when used to connect a list of elements, the term "or" means one, some, or all of the elements in that list.
[0203] Unless the context clearly indicates otherwise, the terms "comprising," "including," "having," "based on," "encompassing," and the like are used in the foregoing specification and appended claims without limitation and do not exclude additional elements, features, acts, or operations.
[0204] Unless the context clearly dictates otherwise, conjunctive language such as the phrase "at least one of X, Y, and Z" should be understood to convey that an item, term, etc. can be X, Y, or Z, or combinations thereof. Thus, such conjunctive language is not intended to necessarily imply that, by default, there is at least one of X, at least one of Y, and at least one of Z, respectively.
[0205] As used in the foregoing detailed description and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise.
[0206] Unless the context clearly dictates otherwise, in the foregoing detailed description and the appended claims, terms such as "first," "second," and the like are used in some instances to describe various elements herein, but these elements should not be limited by these terms. These terms are used only to distinguish one element from another element. For example, a first computing device can be referred to as a second computing device, and similarly, a second computing device can be referred to as a first computing device. Although the first computing device and the second computing device are both computing devices, they are not the same computing device.
[0207] The foregoing specification describes the technology with reference to numerous specific details that may vary from implementation to implementation. The specification and drawings are therefore to be regarded in an illustrative rather than a restrictive sense.< / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / x> < / x> < / baz> < / baz> < / baz> < / baz> < / x> < / x> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / g> < / g> < / f> < / f> < / f> < / e> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / number> < / g> < / g> < / f> < / f> < / f> < / e> < / f> < / f> < / f> < / g> < / g> < / f> < / f> < / f> < / e> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / g> < / g> < / f> < / f> < / f> < / e> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / g> < / g> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / f> < / g> < / g> < / f> < / f> < / f> < / e>
Claims
1. 1. A method implemented by at least one computing device, comprising: locating definitions of concrete data types in programming language source code of the library; determining whether the definition of the concrete data type allows for a potential reference cycle at run time; and based on determining that the definition of the concrete data type allows for a reference cycle at run-time, stopping compilation of the programming language source code or outputting an alert regarding the detected potential reference cycle to a user interface, a file, a database, or an integrated development environment; A method comprising:
2. Determining whether a definition of the concrete data type allows for a potential reference cycle at run time includes:
2. The method of claim 1, wherein the method is based on determining whether a property definition of the concrete data type in the programming language source code is read-only.
3. Determining whether a definition of the property in a definition of the concrete data type in the programming language source code is read-only includes: identifying a keyword in the property definition that indicates that the property definition is read-only; or inferring that a definition of the property is read-only based on an analysis of the programming language source code determining that any of the programming language source code that could have set a value of the property does not do so after the property has been so assigned an initial value; The method of claim 2, wherein the method is based on
4. Determining whether a definition of the concrete data type allows for a potential reference cycle at run time includes: The method of any one of claims 1 to 3, wherein the method is based on determining whether a definition of a property of the definition of the concrete data type in the programming language source code is initialized early.
5. Determining whether a definition of the property of the concrete data type in the programming language source code is early initialized includes: identifying a keyword in the definition of the property that indicates that the definition of the property is to be early initialized; or inferring that a definition of the property in the concrete data type definition is early initialized based on an analysis of the programming language source code determining that the property is assigned an initial value before any reference to a data object containing the property is used as a value, instead of merely the data object being used to initialize the property of the data object; The method of claim 4 , comprising:
6. Determining whether a definition of the concrete data type allows for a potential reference cycle at run time includes: The method of any one of claims 1 to 3, wherein the method is based on determining whether a definition of the concrete data type in the programming language source code is closed.
7. Determining whether a definition of the concrete data type in the programming language source code is closed includes: identifying a keyword in the concrete data type definition that indicates that the concrete data type definition is closed; or inferring that the concrete data type definition is closed based on determining, based on a static analysis of the programming language source code, that there are no subdata type definitions of the concrete data type definition; The method of claim 6, wherein the method is based on
8. 4. The method of claim 1, further comprising determining that the concrete data type definition is concrete based on identifying keywords in the concrete data type definition that indicate that the concrete data type definition is concrete.
9. 4. The method of claim 1, further comprising: determining that a definition of the concrete data type is concrete based on inferring that a definition of the concrete data type is concrete based on identifying instantiations of the concrete data type as objects in the programming language source code.
10. Determining whether a definition of the concrete data type allows for a potential reference cycle at run time includes:
4. The method of claim 1, based on constructing a data type definition graph for the definition of the concrete data type, the data type definition graph comprising a node representing a data type and one or more nodes corresponding to worst case assumptions on generic type parameters.
11. The method of claim 10 , wherein the worst-case assumptions consider bounds of generic type parameters or data type definitions.
12. The method of claim 10 , wherein the data type definition graph includes one or more edges that correspond to how one data type references another data type.
13. Determining whether a definition of the concrete data type allows for a potential reference cycle at run time includes: The method of claim 10 , based on detecting cycles in the data type definition graph involving edges of particular types.
14. the alert includes a human readable description of the potential reference cycle; 11. The method of claim 10, wherein the human-readable description (a) is obtained from metadata associated with nodes or edges of the data type definition graph, or (b) includes suggestions on how to avoid the potential reference cycles.
15. 15. The method of claim 14, wherein an integrated development environment to which the alert is output uses the alert to automatically modify the programming language source code based on a suggestion selected by a user.
16. 4. The method of claim 1, further comprising: determining that the potential reference cycle is considered safe based on (a) a hint, annotation, or metadata associated with a definition of the concrete data type; or (b) determining that the definition of the concrete data type is defined within a particular designated portion of the programming language source code.
17. In a distributed object system, the method further includes using reference counting to deallocate objects that are instances of the concrete data type; The method of any one of claims 1 to 3, wherein the deallocated objects are distributed across multiple computing processes.
Citation Information
Patent Citations
Program inspection device
JP2013054650A
Grammar-based generation of types and extensions
US20100037213A1
