comparison doc/design/graal_compiler.tex @ 2618:15774da89658

Incorporated comments from Peter. Renamings trap=>guard and guard/split=>anchor.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Mon, 09 May 2011 17:28:10 +0200
parents c9b17ac5c06b
children 1586b1b56f0c
comparison
equal deleted inserted replaced
2615:5768534fd4e5 2618:15774da89658
57 The compiler should work with the Maxine VM and the HotSpot VM. 57 The compiler should work with the Maxine VM and the HotSpot VM.
58 This document contains information about the proposed design and strategy for developing the compiler.} 58 This document contains information about the proposed design and strategy for developing the compiler.}
59 59
60 \section{Context} 60 \section{Context}
61 61
62 In 2009, the Maxine team started with creating C1X, a Java port of the HotSpot client compiler, and integrate it into the Maxine VM. 62 In 2009, the Maxine team started with creating C1X, a Java port of the HotSpot client compiler, and integrated it into the Maxine VM.
63 Part of this effort was the development of a clear and clean compiler-runtime interface that allows the separation of the compiler and the VM. 63 Part of this effort was the development of a clear and clean compiler-runtime interface that allows the separation of the compiler and the VM.
64 This compiler-runtime interface enables the use of one compiler for multiple VMs. 64 This compiler-runtime interface enables the use of one compiler for multiple VMs.
65 In June 2010, we started integrating C1X into the HotSpot VM and we called the resulting system Graal~VM. 65 In June 2010, we started integrating C1X into the HotSpot VM and we called the resulting system Graal~VM.
66 Currently, the Graal~VM is fully functional and runs benchmarks (SciMark, DaCapo) at a similar speed to the HotSpot client compiler. 66 Currently, the Graal~VM is fully functional and runs benchmarks (SciMark, DaCapo) at a similar speed as the HotSpot client compiler.
67 67
68 \section{Goals} 68 \section{Goals}
69 The compiler effort aims at rewriting the high-level intermediate representation of C1X with two main goals: 69 The compiler effort aims at rewriting the high-level intermediate representation of C1X with two main goals:
70 \begin{description} 70 \begin{description}
71 \item[Modularity:] A modular design of the compiler should simplify the implementation of new languages, new back-ends, and new optimizations. 71 \item[Modularity:] A modular design of the compiler should simplify the implementation of new languages, new back-ends, and new optimizations.
72 \item[Peak Performance:] A more powerful intermediate representation should enable the implementation of heavy-weight optimizations that impact the peak performance of the resulting machine code. 72 \item[Peak Performance:] A more powerful intermediate representation should enable the implementation of aggressive optimizations that impact the peak performance of the resulting machine code.
73 \end{description} 73 \end{description}
74 74
75 \section{Design} 75 \section{Design}
76 For the implementation of the compiler, we rely on the following design decisions: 76 For the implementation of the compiler, we rely on the following design decisions:
77 \begin{description} 77 \begin{description}
82 Every edge is classified as either a control flow edge (anti-dependency) or a data flow edge (dependency) and represented as a simple pointer from the source node to the target node. 82 Every edge is classified as either a control flow edge (anti-dependency) or a data flow edge (dependency) and represented as a simple pointer from the source node to the target node.
83 It is possible to replace a node with another node without traversing the full graph. 83 It is possible to replace a node with another node without traversing the full graph.
84 The graph does not allow data flow edge cycles or control flow edge cycles. 84 The graph does not allow data flow edge cycles or control flow edge cycles.
85 We achieve this by explicitely modelling loops (see Section~\ref{sec:loops}). 85 We achieve this by explicitely modelling loops (see Section~\ref{sec:loops}).
86 \item[Extensibility:] 86 \item[Extensibility:]
87 The compiler is extensible by adding new compiler phases and new node subclasses without modifying the compiler's sources. 87 The compiler is extensible by allowing developers to add new compiler phases and new node subclasses without modifying the compiler's sources.
88 A node has an abstract way of expressing its effect and new compiler phases can ask compiler nodes for their properties and capabilities. 88 A node has an abstract way of expressing its semantics and new compiler phases can ask compiler nodes for their properties and capabilities.
89 We use the ``everything is an extension'' concept. 89 We use the ``everything is an extension'' concept.
90 Even standard compiler optimizations are internally modeled as extensions, to show that the extension mechanism exposes all necessary functionality. 90 Even standard compiler optimizations are internally modeled as extensions, to show that the extension mechanism exposes all necessary functionality.
91 \item[Detailing:] 91 \item[Detailing:]
92 The compilation starts with a graph that contains nodes that represent the operations of the source language (e.g., one node for an array store to an object array). 92 The compilation starts with a graph that contains nodes that represent the operations of the source language (e.g., one node for an array store to an object array).
93 During the compilation, the nodes are replaced with more detailed nodes (e.g., the array store node is split into a null check, a bounds check, a store check, and a memory access). 93 During the compilation, the nodes are replaced with more detailed nodes (e.g., the array store node is split into a null check, a bounds check, a store check, and a memory access).
94 Compiler phases can choose whether they want to work on the earlier versions of the graph (e.g., escape analysis) or on later versions (e.g., null check elimination). 94 Compiler phases can choose whether they want to work on the earlier versions of the graph (e.g., escape analysis) or on later versions (e.g., null check elimination).
95 \item[Generality:] 95 \item[Generality:]
96 The compiler does not require Java as its input. 96 The compiler does not require Java as its input.
97 This is achieved by having a graph as the starting point of the compilation and not a Java bytecodes array. 97 This is achieved by having a graph as the starting point of the compilation and not a Java bytecodes array.
98 Building the graph from the Java bytecodes must happen before giving a method to the compiler. 98 Building the graph from the Java bytecodes must happen before giving a method to the compiler.
99 This enables front-ends for different languages (e.g., Ruby) to provide their own graph. 99 This enables front-ends for different languages (e.g., Ruby or JavaScript) to provide their own graph.
100 Also, there is no dependency on a specific back-end, but the output of the compiler is a graph that can then be converted to a different representation in a final compiler phase. 100 Also, there is no dependency on a specific back-end, but the output of the compiler is a graph that can then be converted to a different representation in a final compiler phase.
101 \end{description} 101 \end{description}
102 102
103 \section{Milestones} 103 \section{Milestones}
104 \label{sec:mile} 104 \label{sec:mile}
105 The compiler is developed starting from the current C1X source code base. 105 The compiler is developed starting from the current C1X source code base.
106 This helps us testing the compiler at every intermediate development step on a variety of Java benchmarks. 106 This helps us testing the compiler at every intermediate development step on a variety of Java benchmarks.
107 We define the following development milestones and when they are considered achieved: 107 We define the following development milestones and when they are considered to be achieved (see Section~\ref{sec:conclusions} for planned dates):
108 \begin{description} 108 \begin{description}
109 \item[M1:] We have a fully working Graal~VM version with a stripped down C1X compiler that does not perform any optimizations. 109 \item[M1:] We have a fully working Graal~VM version with a stripped down C1X compiler that does not perform any optimizations.
110 \item[M2:] We modified the high-level intermediate representation to be based on the compiler graph data structure. 110 \item[M2:] We modified the high-level intermediate representation to be based on the compiler graph data structure.
111 \item[M3:] We have reimplemented and reenabled compiler optimizations in the compiler that previously existed in C1X. 111 \item[M3:] We have reimplemented and reenabled compiler optimizations in the compiler that previously existed in C1X.
112 \item[M4:] We have reintegrated the new compiler into the Maxine VM and can use it as a Maxine VM bootstrapping compiler. 112 \item[M4:] We have reintegrated the new compiler into the Maxine VM and can use it as a Maxine VM bootstrapping compiler.
130 \item Each node is always associated with a single graph and this association is immutable. 130 \item Each node is always associated with a single graph and this association is immutable.
131 \item Each node has an immutable id that is unique within its associated graph. 131 \item Each node has an immutable id that is unique within its associated graph.
132 \item Nodes can have a data dependency, which means that one node requires the result of another node as its input. The fact that the result of the first node needs to be computed before the second node can be executed introduces a partial order to the set of nodes. 132 \item Nodes can have a data dependency, which means that one node requires the result of another node as its input. The fact that the result of the first node needs to be computed before the second node can be executed introduces a partial order to the set of nodes.
133 \item Nodes can have a control flow dependency, which means that the execution of one node will be followed by the execution of another node. This includes conditional execution, memory access serialization and other reasons, and again introduces a partial order to the set of nodes. 133 \item Nodes can have a control flow dependency, which means that the execution of one node will be followed by the execution of another node. This includes conditional execution, memory access serialization and other reasons, and again introduces a partial order to the set of nodes.
134 \item Nodes can only have data and control dependencies to nodes which belong to the same graph. 134 \item Nodes can only have data and control dependencies to nodes which belong to the same graph.
135 \item Control dependencies and data dependencies each represent a \emph{directed acyclic graph} (DAG) on the same set of nodes. This means that data dependencies always point upwards, and control dependencies always point downwards in a drawing of the graph. Situations that are normally incur cycles (like loops) are represented by special nodes (see Section~\ref{sec:loops}). 135 \item Control dependencies and data dependencies each represent a \emph{directed acyclic graph} (DAG) on the same set of nodes. This means that data dependencies always point upwards, and control dependencies always point downwards in a drawing of the graph. Situations that normally incur cycles (like loops) are represented by special nodes (see Section~\ref{sec:loops}).
136 \item Ordering between nodes is specified only to the extent which is required to correctly express the semantics of a given program. This gives the compiler flexibility for the possible scheduling of a node and therefore wriggle room for optimizations. For algorithms that require a fixed ordering of nodes, a temporary schedule can always be generated. 136 \item Ordering between nodes is specified only to the extent which is required to correctly express the semantics of a given program. This gives the compiler flexibility for the possible scheduling of a node and therefore wriggle room for optimizations. For algorithms that require a fixed ordering of nodes, a temporary schedule can always be generated.
137 \item Both data and control dependencies can be traversed in both directions, so that each node can be traversed in four directions (see Figure~\ref{fig:directions}): 137 \item Both data and control dependencies can be traversed in both directions, so that each node can be traversed in four directions (see Figure~\ref{fig:directions}):
138 \begin{itemize} 138 \begin{itemize}
139 \item \emph{inputs} are all nodes that this node has data dependencies on. 139 \item \emph{inputs} are all nodes that this node has data dependencies on.
140 \item \emph{usages} are all nodes whose inputs contain this node. 140 \item \emph{usages} are all nodes whose inputs contain this node.
176 In order to support the goal of a modular compiler, the code will be divided into the following source code projects (as subprojects of \textbf{com.oracle.graal}). 176 In order to support the goal of a modular compiler, the code will be divided into the following source code projects (as subprojects of \textbf{com.oracle.graal}).
177 177
178 \begin{description} 178 \begin{description}
179 \item[graph] contains the abstract node implementation, the graph implementation and all the associated tools and auxiliary classes. 179 \item[graph] contains the abstract node implementation, the graph implementation and all the associated tools and auxiliary classes.
180 \item[nodes] contains the implementation of known basic nodes (e.g., phi nodes, control flow nodes, \ldots). 180 \item[nodes] contains the implementation of known basic nodes (e.g., phi nodes, control flow nodes, \ldots).
181 Additional node classes should go into seperate projects and be specializations of the known basic nodes. 181 Additional node classes should go into separate projects and be specializations of the known basic nodes.
182 \item[java] contains code for building graphs from Java bytecodes and Java-specific nodes. 182 \item[java] contains code for building graphs from Java bytecodes and Java-specific nodes.
183 \item[opt] contains optimizations such as global value numbering or conditional constant propagation. 183 \item[opt] contains optimizations such as global value numbering or conditional constant propagation.
184 \item[compiler] contains the compiler, including: 184 \item[compiler] contains the compiler, including:
185 \begin{itemize} 185 \begin{itemize}
186 \item Scheduling of the compilation phases. 186 \item Scheduling of the compilation phases.
187 \item Implementation of the \emph{compiler interface} (CI). 187 \item Implementation of the \emph{compiler interface} (CI).
188 \item Implements the final compilation phase that produces the low-level representation. 188 \item Implementation of the final compilation phase that produces the low-level representation.
189 \item Machine code creation, including debug info. 189 \item Machine code creation, including debug info.
190 \end{itemize} 190 \end{itemize}
191 \end{description} 191 \end{description}
192 192
193 \section{Loops} 193 \section{Loops}
194 \label{sec:loops} 194 \label{sec:loops}
195 Loops form a first-class construct in the IR that is expressed in specialized IR nodes during all optimization phases. 195 Loops form a first-class construct in the IR that is expressed by specialized IR nodes during all optimization phases.
196 We only compile methods with a control flow where every loop has one single entry point. 196 We only compile methods with a control flow where every loop has a single entry point.
197 This entry point is a \nodename{LoopBegin} node. 197 This entry point is a \nodename{LoopBegin} node.
198 This node is connected to a \nodename{LoopEnd} node that merges all control flow paths that do not exit the loop. 198 This node is connected to a \nodename{LoopEnd} node that merges all control flow paths that do not exit the loop.
199 The edge between the \nodename{LoopBegin} and the \nodename{LoopEnd} is the backedge of the loop. 199 The edge between the \nodename{LoopBegin} and the \nodename{LoopEnd} is the backedge of the loop.
200 It goes from the beginning to the end in order to make the graph acyclic. 200 It goes from the beginning to the end in order to make the graph acyclic.
201 An algorithm that traverses the control flow has to explicitely decide whether it wants to incorporate backedges (i.e., special case the treatment of \nodename{LoopEnd}) or ignore them. 201 An algorithm that traverses the control flow has to explicitely decide whether it wants to incorporate backedges (i.e., special case of the treatment of \nodename{LoopEnd}) or ignore them.
202 Figure \ref{fig:loop1} shows a simple example with a loop with a single entry and two exits. 202 Figure \ref{fig:loop1} shows a simple example with a loop with a single entry and two exits.
203 203
204 \begin{figure}[h] 204 \begin{figure}[h]
205 \centering 205 \centering
206 \begin{digraphenv}{scale=0.5}{layout1} 206 \begin{digraphenv}{scale=0.5}{layout1}
264 \label{fig:loop2} 264 \label{fig:loop2}
265 \end{figure} 265 \end{figure}
266 266
267 \subsection{Loop Counters} 267 \subsection{Loop Counters}
268 The compiler is capable of recognizing variables that are only increased within a loop. 268 The compiler is capable of recognizing variables that are only increased within a loop.
269 A potential overflow of such a variable is guarded with a trap before the loop. 269 A potential overflow of such a variable is prohibited with a guard before the loop (this is not necessary in this example, because the loop variable cannot overflow).
270 Figure \ref{fig:loop3} shows the compiler graph of the example loop after the loop counter transformation. 270 Figure \ref{fig:loop3} shows the compiler graph of the example loop after the loop counter transformation.
271 271
272 272
273 \begin{figure}[h] 273 \begin{figure}[h]
274 \centering 274 \centering
366 366
367 367
368 \section{Frame States} 368 \section{Frame States}
369 A frame state captures the state of the program in terms of the Java bytecode specification (i.e., the values of the local variables, the operand stack, and the locked monitors). 369 A frame state captures the state of the program in terms of the Java bytecode specification (i.e., the values of the local variables, the operand stack, and the locked monitors).
370 Every deoptimization point needs a valid frame state. 370 Every deoptimization point needs a valid frame state.
371 A frame state is valid as long as the program performs only actions that can safely be reexecuted. 371 A frame state stays valid as long as the subsequent instructions perform only actions that can safely be reexecuted.
372 Thus, frame states need only be generated for the states after bytecodes that cannot be reexecuted: 372 Thus, frame states need only be generated for the states after bytecodes that cannot be reexecuted:
373 373
374 \begin{itemize} 374 \begin{itemize}
375 \item Array stores: {\tt IASTORE, LASTORE, FASTORE, \\DASTORE, AASTORE, BASTORE, CASTORE, SASTORE} 375 \item Array stores: {\tt IASTORE, LASTORE, FASTORE, \\DASTORE, AASTORE, BASTORE, CASTORE, SASTORE}
376 \item Field stores: {\tt PUTSTATIC, PUTFIELD} 376 \item Field stores: {\tt PUTSTATIC, PUTFIELD}
377 \item Method calls: {\tt INVOKEVIRTUAL, INVOKESPECIAL, \\INVOKESTATIC, INVOKEINTERFACE} 377 \item Method calls: {\tt INVOKEVIRTUAL, INVOKESPECIAL, \\INVOKESTATIC, INVOKEINTERFACE}
378 \item Synchronization: {\tt MONITORENTER, MONITOREXIT} 378 \item Synchronization: {\tt MONITORENTER, MONITOREXIT}
379 \end{itemize} 379 \end{itemize}
380 380
381 Within the graph a frame state is represented as a node that is fixed to the node that caused it to be generated using a control dependency (see Figure~\ref{fig:fs1}). 381 Within the graph a frame state is represented as a node that is attached to the node that caused it to be generated using a control dependency (see Figure~\ref{fig:fs1}).
382 Frame states also have data dependencies on the contents of the state: the local variables and the expression stack. 382 Frame states also have data dependencies on the contents of the state: the local variables and the expression stack.
383 383
384 The frame state at the method beginning does not have to be explicitely in the graph, because it can always be reconstructed at a later stage. 384 The frame state at the method beginning does not have to be explicitely in the graph, because it can always be reconstructed at a later stage.
385 We save the frame state at control flow merges if there is at least one frame state on any control flow path since the immediate dominator. 385 We save the frame state at control flow merges if there is at least one frame state on any control flow path after the immediate dominator.
386 386
387 387
388 \begin{figure}[h] 388 \begin{figure}[h]
389 \centering 389 \centering
390 \begin{digraphenv}{scale=0.5}{fs1} 390 \begin{digraphenv}{scale=0.5}{fs1}
391 \nodetrisplit{store1}{ArrayStore} 391 \nodetrisplit{store1}{ArrayStore}
392 \nodebi{load1}{ArrayLoad} 392 \nodebi{load1}{ArrayLoad}
393 \controllabel{store1:succ1}{load1} 393 \controllabel{store1:succ1}{load1}
394 \nodetrisplit{store2}{ArrayStore} 394 \nodetrisplit{store2}{FieldStore}
395 \control{load1}{store2} 395 \control{load1}{store2}
396 end [shape=plaintext, label="...", width="2.0"] 396 end [shape=plaintext, label="...", width="2.0"]
397 store2:succ1:s -> end:n [color=red]; 397 store2:succ1:s -> end:n [color=red];
398 % 398 %
399 \nodeframestate{fs1}{FrameState} 399 \nodeframestate{fs1}{FrameState}
404 \caption{Simple example using two frame states.} 404 \caption{Simple example using two frame states.}
405 \label{fig:fs1} 405 \label{fig:fs1}
406 \end{figure} 406 \end{figure}
407 407
408 408
409 \subsection{Traps} 409 \subsection{Guards}
410 A trap node is a node that deoptimizes based on a conditional expression. 410 A guard node is a node that deoptimizes based on a conditional expression.
411 Trap nodes are not fixed to a certain frame state node, they can move around freely and will always use the correct frame state when the nodes are scheduled (i.e., the last emitted frame state). 411 Guard nodes are not attached to a certain frame state node, they can move around freely and will always use the correct frame state when the nodes are scheduled (i.e., the last emitted frame state).
412 The node that is guarded by the deoptimization has a data dependency on the trap, and the trap in turn has a data dependency on the condition and on the most distant node that is postdominated by the guarded node. 412 The node that is guarded by the deoptimization has a data dependency on the guard, and the guard in turn has a data dependency on the condition and on the most distant node that is postdominated by the guarded node.
413 413
414 In the example of Figure~\ref{fig:trap1}, the second load is guarded by a trap, because its receiver might be null (the receiver of the first load is assumed to be non-null). 414 In the example of Figure~\ref{fig:guard1}, the second load is guarded by a guard, because its receiver might be null (the receiver of the first load is assumed to be non-null).
415 The trap is anchored to the control split, because as soon as this node is executed, the second load must be executed as well. 415 The guard is anchored to the control split, because as soon as this node is executed, the second load must be executed as well.
416 In the final schedule, the trap can be placed before or after the first load. 416 In the final schedule, the guard can be placed before or after the first load.
417 417
418 \begin{figure}[h] 418 \begin{figure}[h]
419 \centering 419 \centering
420 \begin{digraphenv}{scale=0.5}{trap1} 420 \begin{digraphenv}{scale=0.5}{guard1}
421 \nodesplit{if}{If} 421 \nodesplit{if}{If}
422 \node{split1}{Split}
423 \controllabel{if:succ1}{split1}
424 nop [shape=plaintext, label="..."] 422 nop [shape=plaintext, label="..."]
425 \control{split1}{nop} 423 \controllabel{if:succ1}{nop}
426 % 424 %
427 \node{split2}{Split} 425 \node{split2}{Anchor}
428 \controllabel{if:succ2}{split2} 426 \controllabel{if:succ2}{split2}
429 \nodebi{load1}{MemLoad} 427 \nodebi{load1}{MemLoad}
430 \control{split2}{load1} 428 \control{split2}{load1}
431 \nodebi{load2}{MemLoad} 429 \nodebi{load2}{MemLoad}
432 \control{load1}{load2} 430 \control{load1}{load2}
436 % 434 %
437 \nodeconst{o1}{obj1} 435 \nodeconst{o1}{obj1}
438 \nodeconst{o2}{obj2} 436 \nodeconst{o2}{obj2}
439 \datalabel{load1:in2}{o1} 437 \datalabel{load1:in2}{o1}
440 \datalabel{load2:in2}{o2} 438 \datalabel{load2:in2}{o2}
441 \nodetrap{trap}{Trap} 439 \nodeguard{guard}{Guard}
442 \node{cmpnull}{IsNull} 440 \node{cmpnull}{IsNull}
443 \data{cmpnull}{o2} 441 \data{cmpnull}{o2}
444 \datalabel{trap:in2}{cmpnull} 442 \datalabel{guard:in2}{cmpnull}
445 \datalabel{load2:in1}{trap} 443 \datalabel{load2:in1}{guard}
446 \datalabel{trap:in1}{split2} 444 \datalabel{guard:in1}{split2}
447 \end{digraphenv} 445 \end{digraphenv}
448 \caption{A load guarded by a null check trap.} 446 \caption{A load guarded by a null check guard.}
449 \label{fig:trap1} 447 \label{fig:guard1}
450 \end{figure} 448 \end{figure}
451 449
452 Another type of trap is a guard, which is used to remove branches that have a very low execution frequency and replace them with a conditional jump to deoptimization. 450 A guard can be used to remove branches that have a very low execution frequency and replace them with a conditional jump to deoptimization.
453 451
454 In the example of Figure~\ref{fig:trap2}, an \texttt{If} node was replaced by a guard and a trap. 452 In the example of Figure~\ref{fig:guard2}, an \texttt{If} node was replaced by an anchor and a guard.
455 The guard takes the place of the \texttt{If} node in the control flow, and is connected to the trap node. 453 The anchor takes the place of the \texttt{If} node in the control flow, and is connected to the guard node.
456 The trap is now anchored to the most distant node of which the \texttt{If} node was a postdominator. 454 The guard is now anchored to the most distant node of which the \texttt{If} node was a postdominator.
457 455
458 \begin{figure}[h] 456 \begin{figure}[h]
459 \centering 457 \centering
460 \begin{digraphenv}{scale=0.5}{trap2} 458 \begin{digraphenv}{scale=0.5}{guard2}
461 start [shape=plaintext, label="..."] 459 start [shape=plaintext, label="..."]
462 start2 [shape=plaintext, label=""] 460 start2 [shape=plaintext, label=""]
463 start3 [shape=plaintext, label=""] 461 start3 [shape=plaintext, label=""]
464 \control{start}{guard} 462 \control{start}{guard}
465 \node{guard}{Guard} 463 \node{anchor}{Anchor}
466 \nodebi{load1}{MemLoad} 464 \nodebi{load1}{MemLoad}
467 \control{guard}{load1} 465 \control{anchor}{load1}
468 \control{load1}{nop} 466 \control{load1}{nop}
469 nop [shape=plaintext, label="..."] 467 nop [shape=plaintext, label="..."]
470 % 468 %
471 \nodetrap{trap}{Trap} 469 \nodeguard{guard}{Guard}
472 \datalabel{trap:in1}{start2} 470 \datalabel{guard:in1}{start2}
473 \datalabel{trap:in2}{start3} 471 \datalabel{guard:in2}{start3}
474 \data{guard}{trap} 472 \data{anchor}{guard}
475 \end{digraphenv} 473 \end{digraphenv}
476 \caption{A trap that is fixed to the control flow using a guard instruction.} 474 \caption{A guard that is fixed to the control flow using an anchor instruction.}
477 \label{fig:trap2} 475 \label{fig:guard2}
478 \end{figure} 476 \end{figure}
479 477
480 At some point during the compilation, trap nodes need to be fixed, which means that appropriate data and control dependencies will be inserted so that they cannot move outside the scope of the associated frame state. 478 At some point during the compilation, guard nodes need to be fixed, which means that appropriate data and control dependencies will be inserted so that they cannot move outside the scope of the associated frame state.
481 This will generate deoptimization-free zones that can be targeted by the most aggressive optimizations. 479 This will generate deoptimization-free zones that can be targeted by the most aggressive optimizations.
482 A simple algorithm for this removal of frame states would be to move all traps as far upwards as possible. 480 A simple algorithm for this removal of frame states would be to move all guards as far upwards as possible.
483 Multiple traps with the same condition and anchor can be merged (see Figure~\ref{fig:trap3}). 481 Multiple guards with the same condition and anchor can be merged (see Figure~\ref{fig:guard3}).
484 482
485 \begin{figure}[h] 483 \begin{figure}[h]
486 \centering 484 \centering
487 \begin{digraphenv}{scale=0.5}{trap3} 485 \begin{digraphenv}{scale=0.5}{guard3}
488 \nodesplit{if}{If} 486 \nodesplit{if}{If}
489 \node{split1}{Split}
490 \controllabel{if:succ1}{split1}
491 nop [shape=plaintext, label="..."] 487 nop [shape=plaintext, label="..."]
492 \control{split1}{nop} 488 \controllabel{if:succ1}{nop}
493 % 489 %
494 \node{split2}{Split} 490 \node{split2}{Anchor}
495 \controllabel{if:succ2}{split2} 491 \controllabel{if:succ2}{split2}
496 \nodebi{load1}{MemLoad} 492 \nodebi{load1}{MemLoad}
497 \control{split2}{load1} 493 \control{split2}{load1}
498 \nodebi{load2}{MemLoad} 494 \nodebi{load2}{MemLoad}
499 \control{load1}{load2} 495 \control{load1}{load2}
502 \control{nop}{merge} 498 \control{nop}{merge}
503 % 499 %
504 \nodeconst{o}{obj} 500 \nodeconst{o}{obj}
505 \datalabel{load1:in2}{o} 501 \datalabel{load1:in2}{o}
506 \datalabel{load2:in2}{o} 502 \datalabel{load2:in2}{o}
507 \nodetrap{trap}{Trap} 503 \nodeguard{guard}{Guard}
508 \node{cmpnull}{IsNull} 504 \node{cmpnull}{IsNull}
509 \data{cmpnull}{o} 505 \data{cmpnull}{o}
510 \datalabel{trap:in2}{cmpnull} 506 \datalabel{guard:in2}{cmpnull}
511 \datalabel{load2:in1}{trap} 507 \datalabel{load2:in1}{guard}
512 \datalabel{load1:in1}{trap} 508 \datalabel{load1:in1}{guard}
513 \datalabel{trap:in1}{split2} 509 \datalabel{guard:in1}{split2}
514 \end{digraphenv} 510 \end{digraphenv}
515 \caption{Two loads guarded by the same trap.} 511 \caption{Two loads using the same guard.}
516 \label{fig:trap3} 512 \label{fig:guard3}
517 \end{figure} 513 \end{figure}
518 514
519 Also, if two traps that are anchored to the true and false branch of the same \texttt{If} node have the same condition, they can be merged, so that the resulting trap is anchored at the most distant node of which the \texttt{If} node is a postdominator. 515 Also, if two guards that are anchored to the true and false branch of the same \texttt{If} node have the same condition, they can be merged, so that the resulting guard is anchored at the most distant node of which the \texttt{If} node is a postdominator.
520 516
521 \section{Conclusions} 517 \section{Conclusions}
518 \label{sec:conclusions}
522 This document sketched the strategy for the Graph compiler. 519 This document sketched the strategy for the Graph compiler.
523 We already reached M1 (as defined in Section~\ref{sec:mile}) and have the following plans for M2 to M4: 520 We already reached M1 (as defined in Section~\ref{sec:mile}) and have the following plans for M2 to M4:
524 \begin{description} 521 \begin{description}
525 \item[M2:] June 30th, 2011 522 \item[M2:] June 30th, 2011
526 \item[M3:] August 15th, 2011 523 \item[M3:] August 15th, 2011