You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interpreter can speculatively rewrite bytecode instructions to specialized instructions that pass primitive values whenever possible.
14
14
Boxing elimination can also improve compiled performance, because Graal is not always able to remove box-unbox sequences during compilation.
15
15
16
-
To enable boxing elimination, specify a set of `boxingEliminationTypes` on the [`@GenerateBytecode`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode./src/com/oracle/truffle/api/bytecode/GenerateBytecode.java) annotation. For example, the following configuration
16
+
To enable boxing elimination, specify a set of `boxingEliminationTypes` on the [`@GenerateBytecode`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/GenerateBytecode.java) annotation. For example, the following configuration
17
17
18
18
```java
19
19
@GenerateBytecode(
@@ -35,7 +35,7 @@ Quickened operations can be introduced to reduce the work required to evaluate a
35
35
For example, a quickened operation that only accepts `int` inputs might avoid operand boxing and the additional type checks required by the general operation.
36
36
Additionally, a custom operation that has only one active specialization could be quickened to an operation that only supports that single specialization, avoiding extra specialization state checks.
37
37
38
-
At the moment, quickened instructions can only be specified manually using [`@ForceQuickening`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode./src/com/oracle/truffle/api/bytecode/ForceQuickening.java).
38
+
At the moment, quickened instructions can only be specified manually using [`@ForceQuickening`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/ForceQuickening.java).
39
39
In the future, [tracing](#tracing) will be able to automatically infer useful quickenings.
Copy file name to clipboardExpand all lines: truffle/docs/bytecode_dsl/ShortCircuitOperations.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
One limitation of regular operations is that they are *eager*: all of the child operations are evaluated before the operation itself evaluates.
4
4
Many languages define *short-circuiting* operators (e.g., Java's `&&`) which can evaluate a subset of their operands, terminating early when an operand meets a particular condition (e.g., when it is `true`).
5
5
6
-
The Bytecode DSL allows you to define [`@ShortCircuitOperation`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode./src/com/oracle/truffle/api/bytecode/ShortCircuitOperation.java)s to implement short-circuiting behaviour.
6
+
The Bytecode DSL allows you to define [`@ShortCircuitOperation`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/ShortCircuitOperation.java)s to implement short-circuiting behaviour.
7
7
A short-circuit operation implements `AND` or `OR` semantics, executing each child operation until the first `false` or `true` value, respectively.
Copy file name to clipboardExpand all lines: truffle/docs/bytecode_dsl/UserGuide.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ The current state is encapsulated in a [`BytecodeNode`](https://github.com/oracl
106
106
It is worth familiarizing yourself with its APIs.
107
107
108
108
The `BytecodeNode` (and the bytecode itself) can change over the execution of a program for various reasons (e.g., [transitioning from uncached to cached](#cached-and-uncached-execution), [reparsing metadata](#reparsing), [quickening](Optimization.md#quickening)), so you should use `BytecodeRootNode#getBytecodeNode()` to obtain the up-to-date bytecode node each time you need it.
109
-
Custom operations can also `@Bind BytecodeNode` in their specializations (see [Bind parameters](#bind-parameters)).
109
+
Custom operations can also `@Bind BytecodeNode` in their specializations (more about special Bind parameters[here](#expressions-in-operations)).
110
110
111
111
Because the bytecode may change, a bytecode index (obtained using `@Bind("$bytecodeIndex")`) must be paired with a `BytecodeNode` to meaningfully identify a program location.
112
112
You can also instantiate a [`BytecodeLocation`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/BytecodeLocation.java), which logically represents the bytecode node and index, using `BytecodeNode#getBytecodeLocation(int)` or `@Bind BytecodeLocation`.
@@ -271,7 +271,7 @@ The builder will emit code to collect these values into an `Object[]`.
271
271
272
272
An operation can also define _constant operands_, which are embedded in the bytecode and produce partial evaluation constant values, by declaring [`@ConstantOperand`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/ConstantOperand.java)s.
273
273
274
-
An operation may need to produce more than one result, or to modify local variables. For either case, the operation can use [`LocalAccessor`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalAccessor.java) or [`LocalAccessorRange`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalAccessorRange.java).
274
+
An operation may need to produce more than one result, or to modify local variables. For either case, the operation can use [`LocalAccessor`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalAccessor.java) or [`LocalRangeAccessor`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalRangeAccessor.java).
275
275
276
276
277
277
## Locals
@@ -298,7 +298,7 @@ b.endBlock();
298
298
All local accesses must be (directly or indirectly) nested within the operation that created the local.
299
299
300
300
The `LoadLocal` and `StoreLocal` operations are the preferred way to access locals because they are efficient and can be quickened to [avoid boxing](Optimization.md#boxing-elimination).
301
-
Some behaviour cannot be easily implemented using only these operations, in which case an operation can declare a [`LocalAccessor`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalAccessor.java) or [`LocalAccessorRange`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalAccessorRange.java) operand to perform local accesses.
301
+
Some behaviour cannot be easily implemented using only these operations, in which case an operation can declare a [`LocalAccessor`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalAccessor.java) or [`LocalRangeAccessor`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/LocalRangeAccessor.java) operand to perform local accesses.
302
302
For example, an operation producing multiple values cannot "return" both values, and may instead use a local accessor to write one of the values back to a local.
303
303
The [`BytecodeNode`](https://github.com/oracle/graal/blob/master/truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/BytecodeNode.java) class also declares a variety of helper methods for accessing locals.
304
304
These helpers often have extra indirection, so the built-in operations and accessors are preferred.
@@ -533,7 +533,7 @@ It is recommended to enclose the `Root` operation in appropriate `Source` and `S
533
533
The generated root node will override `Node#getSourceSection` to return this information.
534
534
535
535
Source information is designed to have no performance overhead until it is requested (see [Reparsing metadata](#reparsing)).
536
-
This information [should generally not be accessed from compiled code](RuntimeCompilation.md#source-information).
536
+
Take extra care if accessing source information in [compiled code](RuntimeCompilation.md#source-information).
Copy file name to clipboardExpand all lines: truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/GettingStarted.java
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -447,6 +447,7 @@ public void testIfThenElse() {
447
447
* while i < n:
448
448
* i += 1
449
449
* total += i
450
+
* return total
450
451
* </pre>
451
452
*/
452
453
@Test
@@ -507,7 +508,7 @@ public void testLoop() {
507
508
}
508
509
509
510
/**
510
-
* For more advanced control flow, The Bytecode DSL also allows you to define and branch to
511
+
* For more advanced control flow, the Bytecode DSL also allows you to define and branch to
511
512
* labels. Programs can branch forward to labels using the {@code Branch} operation. Let's use
512
513
* labels to implement {@code sumToN} using a {@code break}:
513
514
*
@@ -593,7 +594,7 @@ public void testLoopWithBreak() {
593
594
}
594
595
595
596
/*
596
-
* In addition to the condition and looping contructs, The Bytecode DSL has other control flow
597
+
* In addition to the condition and looping constructs, the Bytecode DSL has other control flow
597
598
* mechanisms for exception handling ({@code TryCatch}, {@code TryFinally}, and {@code
598
599
* TryCatchOtherwise}) and continuations ({@code Yield}). We will not cover those here.
Copy file name to clipboardExpand all lines: truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/ParsingTutorial.java
+19-29Lines changed: 19 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -60,10 +60,6 @@
60
60
* This tutorial demonstrates how to programmatically parse bytecode for a Bytecode DSL interpreter.
61
61
* It refers to the interpreter defined in the {@link GettingStarted} guide. It is recommended to
Copy file name to clipboardExpand all lines: truffle/src/com.oracle.truffle.api.bytecode.test/src/com/oracle/truffle/api/bytecode/test/examples/SerializationTutorial.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ public class SerializationTutorial {
Copy file name to clipboardExpand all lines: truffle/src/com.oracle.truffle.api.bytecode/src/com/oracle/truffle/api/bytecode/serialization/package-info.java
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,12 @@
39
39
* SOFTWARE.
40
40
*/
41
41
42
+
/*
43
+
@ApiInfo(
44
+
group="Truffle"
45
+
)
46
+
*/
47
+
42
48
/**
43
49
* Serialization-specific classes for the Bytecode DSL.
0 commit comments