Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java @ 7530:5e3d1a68664e
applied mx eclipseformat to all Java files
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 23 Jan 2013 16:34:57 +0100 |
parents | a4b84ba6dc2e |
children | df1d665ca846 |
comparison
equal
deleted
inserted
replaced
7529:4a11124a3563 | 7530:5e3d1a68664e |
---|---|
28 import com.oracle.truffle.api.frame.*; | 28 import com.oracle.truffle.api.frame.*; |
29 import com.oracle.truffle.api.nodes.*; | 29 import com.oracle.truffle.api.nodes.*; |
30 | 30 |
31 /** | 31 /** |
32 * <h3>Using Final Fields in Node Classes</h3> | 32 * <h3>Using Final Fields in Node Classes</h3> |
33 * | 33 * |
34 * <p> | 34 * <p> |
35 * The usage of final fields in node classes is highly encouraged. It is beneficial for performance to declare every | 35 * The usage of final fields in node classes is highly encouraged. It is beneficial for performance |
36 * field that is not pointing to a child node as final. This gives the Truffle runtime an increased opportunity to | 36 * to declare every field that is not pointing to a child node as final. This gives the Truffle |
37 * optimize this node. | 37 * runtime an increased opportunity to optimize this node. |
38 * </p> | 38 * </p> |
39 * | 39 * |
40 * <p> | 40 * <p> |
41 * If a node has a value which may change at run time, but will rarely do so, it is recommended to speculate on the | 41 * If a node has a value which may change at run time, but will rarely do so, it is recommended to |
42 * field being final. This involves starting executing with a node where this field is final and only if this | 42 * speculate on the field being final. This involves starting executing with a node where this field |
43 * turns out to be no longer the case, the node is replaced with an alternative implementation of the operation (see | 43 * is final and only if this turns out to be no longer the case, the node is replaced with an |
44 * {@link ReplaceTest}). | 44 * alternative implementation of the operation (see {@link ReplaceTest}). |
45 * </p> | 45 * </p> |
46 * | 46 * |
47 * <p> | 47 * <p> |
48 * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.ReplaceTest}. | 48 * The next part of the Truffle API introduction is at |
49 * {@link com.oracle.truffle.api.test.ReplaceTest}. | |
49 * </p> | 50 * </p> |
50 */ | 51 */ |
51 public class FinalFieldTest { | 52 public class FinalFieldTest { |
52 | 53 |
53 @Test | 54 @Test |
76 return sum; | 77 return sum; |
77 } | 78 } |
78 } | 79 } |
79 | 80 |
80 class TestChildNode extends Node { | 81 class TestChildNode extends Node { |
82 | |
81 private final int value; | 83 private final int value; |
82 | 84 |
83 public TestChildNode(int value) { | 85 public TestChildNode(int value) { |
84 this.value = value; | 86 this.value = value; |
85 } | 87 } |
87 public int execute() { | 89 public int execute() { |
88 return value; | 90 return value; |
89 } | 91 } |
90 } | 92 } |
91 } | 93 } |
92 |