Skip to content

Commit

Permalink
Use rel paths on URLs instead of permalinks
Browse files Browse the repository at this point in the history
  • Loading branch information
olyagpl committed Dec 13, 2021
1 parent 24b0aac commit 15d324e
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion truffle/docs/AOTOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For more information see [TruffleLanguage.patchContext](https://www.graalvm.org/
### Code sharing within the same Isolate/Process

A polyglot engine can be used in order to determine the scope of code sharing between contexts.
An example of how that can be done can be found in the [reference manual](https://www.graalvm.org/reference-manual/embed-languages/#code-caching-across-multiple-contexts).
An example of how that can be done can be found in the [reference manual](../../docs/reference-manual/embedding/embed-languages.md#code-caching-across-multiple-contexts).
When a language is initialized for a polyglot context, a new language instance is requested from an engine.
If the language supports [ContextPolicy.SHARED](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.ContextPolicy.html#SHARED), then the language instance will be reused for an engine instance.
The source parsing cache is associated with a language instance, so parsing happens once per language instance.
Expand Down
2 changes: 1 addition & 1 deletion truffle/docs/AuxiliaryEngineCachingEnterprise.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This includes:
2. Execution and profiling of the guest application in the interpreter.
3. Compilation of the AST to machine code.

Within a single OS process, the work performed during warmup can be shared by specifying an [explicit engine](https://www.graalvm.org/reference-manual/embed-languages/#code-caching-across-multiple-contexts).
Within a single OS process, the work performed during warmup can be shared by specifying an [explicit engine](../../docs/reference-manual/embedding/embed-languages.md#code-caching-across-multiple-contexts).
This requires language implementations to disable context-related optimizations to avoid deoptimizations between contexts that share code.
Auxiliary engine caching builds upon the mechanism for disabling context-related optimizations and adds the capability to persist an engine with ASTs and optimized machine code to disk.
This way, the work performed during warmup can be significantly reduced in the first application context of a new process.
Expand Down
2 changes: 1 addition & 1 deletion truffle/docs/DynamicObjectModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ public abstract class MakePairNode extends BinaryExpressionNode {

A high-level description of the object model has been published in [**An Object Storage Model for the Truffle Language Implementation Framework**](http://dl.acm.org/citation.cfm?id=2647517).

See [Truffle documentation](https://github.com/oracle/graal/tree/master/truffle/docs) and [publications](https://github.com/oracle/graal/blob/master/docs/Publications.md) for more tutorials, presentations, and publications about Truffle and GraalVM.
See [Truffle publications](https://github.com/oracle/graal/blob/master/docs/Publications.md) for more presentations and publications about Truffle and GraalVM.
2 changes: 1 addition & 1 deletion truffle/docs/InteropMigration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permalink: /graalvm-as-a-platform/language-implementation-framework/InteropMigra
# Truffle Interop 2.0

This document is targeted at guest language and tool implementers.
It is recommended to read the [Truffle Library Tutorial](https://github.com/oracle/graal/blob/master/truffle/docs/TruffleLibraries.md) first, before proceeding.
It is recommended to read the [Truffle Library Tutorial](./TruffleLibraries.md) first, before proceeding.

## Motivation

Expand Down
2 changes: 1 addition & 1 deletion truffle/docs/LanguageTutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Conference on Programming Language Design and Implementation [PLDI 2016](http://
Next Steps:
* Start to subclass [TruffleLanguage](http://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.html) for your own language implementation.
* Fork [SimpleLanguage](https://github.com/graalvm/simplelanguage), a toy language that demonstrates how to use many Truffle features.
* Embed Truffle languages in Java host applications using the [Polyglot API](https://graalvm.org/reference-manual/embed-languages/).
* Embed Truffle languages in Java host applications using the [Polyglot API](../../docs/reference-manual/embedding/embed-languages.md).
* Read [GraalVM/Truffle publications](https://github.com/oracle/graal/blob/master/docs/Publications.md).
17 changes: 9 additions & 8 deletions truffle/docs/OnStackReplacement.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: docs
toc_group: truffle
link_title: On-Stack Replacement
link_title: On-Stack Replacement
permalink: /graalvm-as-a-platform/language-implementation-framework/OnStackReplacement/
---
# On-Stack Replacement (OSR)
Expand All @@ -15,7 +15,7 @@ On-stack replacement (OSR) is a technique used in Truffle to "break out" of the
Truffle supports OSR for both AST interpreters (i.e., ASTs with `LoopNode`s) and bytecode interpreters (i.e., nodes with dispatch loops).
In either case, Truffle uses heuristics to detect when a long-running loop is being interpreted and can perform OSR to speed up execution.

## OSR for AST interpreters
## OSR for AST Interpreters

Languages using standard Truffle APIs get OSR for free on Graal.
The runtime tracks the number of times a `LoopNode` (created using `TruffleRuntime.createLoopNode(RepeatingNode)`) executes in the interpreter.
Expand All @@ -25,17 +25,17 @@ When the loop exits in the OSR execution, it returns to the interpreted executio

See the `LoopNode` [javadoc](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/nodes/LoopNode.html) for more details.

## OSR for bytecode interpreters
## OSR for Bytecode Interpreters

OSR for bytecode interpreters requires slightly more cooperation from the language.
A bytecode dispatch node typically looks something like the following:

```java
class BytecodeDispatchNode extends Node {
@CompilationFinal byte[] bytecode;

...

@ExplodeLoop(kind = ExplodeLoop.LoopExplosionKind.MERGE_EXPLODE)
Object execute(VirtualFrame frame) {
int bci = 0;
Expand Down Expand Up @@ -81,7 +81,7 @@ The example above can be refactored to support OSR as follows:
class BytecodeDispatchNode extends Node implements BytecodeOSRNode {
@CompilationFinal byte[] bytecode;
@CompilationFinal private Object osrMetadata;

...

Object execute(VirtualFrame frame) {
Expand Down Expand Up @@ -161,12 +161,14 @@ Bytecode-based OSR can be tricky to implement. Some debugging tips:

See the `BytecodeOSRNode` [javadoc](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/nodes/BytecodeOSRNode.html) for more details.

## Command-line options
## Command-line Options

There are two (experimental) options which can be used to configure OSR:
- `engine.OSR`: whether to perform OSR (default: `true`)
- `engine.OSRCompilationThreshold`: the number of loop iterations/back-edges required to trigger OSR compilation (default: `100,352`).

## Debugging

OSR compilation targets are marked with `<OSR>` (or `<OSR@n>` where `n` is the dispatch target, in the case of bytecode OSR).
These targets can be seen and debugged using standard debugging tools like the compilation log and IGV.
For example, in the compilation log, a bytecode OSR entry may look something like:
Expand All @@ -176,4 +178,3 @@ For example, in the compilation log, a bytecode OSR entry may look something lik
```

See [Debugging](https://github.com/oracle/graal/blob/master/compiler/docs/Debugging.md) for more details on debugging Graal compilations.

2 changes: 1 addition & 1 deletion truffle/docs/Optimizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ The `--engine.TraceCompilation` option also shows CallTarget invalidations with
## Ideal Graph Visualizer
The [Ideal Graph Visualizer (IGV)](https://docs.oracle.com/en/graalvm/enterprise/21/docs/tools/igv/) is a tool to understand Truffle ASTs and the GraalVM compiler graphs.
The [Ideal Graph Visualizer (IGV)](../../docs/tools/ideal-graph-visualizer.md) is a tool to understand Truffle ASTs and the GraalVM compiler graphs.
A typical usage is to run with `--vm.Dgraal.Dump=Truffle:1 --vm.Dgraal.PrintGraph=Network`, which will show you Truffle ASTs, guest-language call graphs, and the Graal graphs as they leave the Truffle phase.
If the `-Dgraal.PrintGraph=Network` flag is omitted then the dump files are placed in the `graal_dumps` directory, which you should then open in IGV.
Expand Down
2 changes: 1 addition & 1 deletion truffle/docs/Profiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permalink: /graalvm-as-a-platform/language-implementation-framework/Profiling/
There is no shortage of tools for profiling interpreters written using Truffle.
When running in JVM mode you can use standard JVM tooling such as VisualVM, Java Flight Recorder, and Oracle Developer Studio. When running in Native Image you can use `callgrind` from the Valgrind tool suite, and other system tools such as `strace`.
As a language running on GraalVM, other GraalVM tools can be used.
For a broad enough definition of profiling, you can also use the [Ideal Graph Visualizer (IGV)](https://docs.oracle.com/en/graalvm/enterprise/21/docs/tools/igv/) and C1 Visualizer to inspect the compiler output.
For a broad enough definition of profiling, you can also use the [Ideal Graph Visualizer (IGV)](../../docs/tools/ideal-graph-visualizer.md) and C1 Visualizer to inspect the compiler output.

This guide is less about how to use each tool and more about suggestions for extracting the most useful information from the tools, assuming a basic knowledge of their usage.

Expand Down
2 changes: 1 addition & 1 deletion truffle/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Consider reading [these publications](https://github.com/oracle/graal/blob/maste
Implementing a language using Truffle offers a way to interoperate with other "Truffle" languages.
To learn more about verifying that your language is a valid polyglot citizen, read more about using the [Polyglot TCK](./TCK.md).
Somewhat related topics worth exploring are [Truffle Libraries](./TruffleLibraries.md), as well as how to use them to implement a language [interoperability](./InteropMigration.md).
Languages implemented with Truffle can also be embedded in Java host applications using the [Polyglot API](https://graalvm.org/reference-manual/embed-languages/).
Languages implemented with Truffle can also be embedded in Java host applications using the [Polyglot API](../../docs/reference-manual/embedding/embed-languages.md).

To better understand how to improve the performance of your language please consult the documentation on [profiling](./Profiling.md) and [optimizing](./Optimizing.md) your language.
Also, to better understand how to use Truffle's automated monomorphization feature (i.e., splitting), look at the [related documentation](./splitting/Monomorphization.md).
Expand Down
21 changes: 14 additions & 7 deletions truffle/docs/StaticObjectModel.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
layout: docs
toc_group: truffle
link_title: Static Object Model
permalink: /graalvm-as-a-platform/language-implementation-framework/StaticObjectModel/
---
# Static Object Model

This guide demonstrates how to get started with using the [StaticShape](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/staticobject/StaticShape.html) and [StaticProperty](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/staticobject/StaticProperty.html) APIs introduced with GraalVM 21.3.0.
Expand Down Expand Up @@ -75,7 +81,7 @@ Properties of the parent shape can then be used to access values stored in stati
In the following example we create a parent shape identical to the one discussed in [the previous section](#getting-started), then we extend it with a child shape that hides one of the properties of the parent shape.
Finally, we demonstrate how the various properties can be accessed.

```java
```
public class Subshapes {
public void simpleSubShape(TruffleLanguage<?> language) {
// Create a shape
Expand Down Expand Up @@ -139,7 +145,7 @@ public interface MyStaticObjectFactory {
```

Finally, this is how to allocate the custom static objects:
```java
```
public void customStaticObject(TruffleLanguage<?> language) {
StaticProperty property = new DefaultStaticProperty("arg1");
StaticShape<MyStaticObjectFactory> shape = StaticShape.newBuilder(language).property(property, Object.class, false).build(MyStaticObject.class, MyStaticObjectFactory.class);
Expand Down Expand Up @@ -197,8 +203,8 @@ new MyField("property1");
On property access, the Static Object Model performs two types of safety checks:
1. That the [StaticProperty](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/staticobject/StaticProperty.html) method matches the type of the static property.

Example of wrong access:
```java
The example of wrong access:
```
public void wrongMethod(TruffleLanguage<?> language) {
StaticShape.Builder builder = StaticShape.newBuilder(language);
StaticProperty property = new DefaultStaticProperty("property");
Expand All @@ -209,7 +215,7 @@ public void wrongMethod(TruffleLanguage<?> language) {

2. That the object passed to the accessor method matches the shape generated by the builder to which the property is associated, or one of its child shapes.

Example of wrong access:
The example of wrong access:
```java
public void wrongShape(TruffleLanguage<?> language) {
StaticShape.Builder builder = StaticShape.newBuilder(language);
Expand All @@ -222,8 +228,9 @@ public void wrongShape(TruffleLanguage<?> language) {
```

While these checks are often useful, they might be redundant if the language implementation already performs them, for example using a verifier.
While the first type of checks (on property type) is very efficient and cannot be disabled, the second type of checks (on the shape) is computationally expensive and can be disabled via a command line argument:
```
While the first type of checks (on property type) is very efficient and cannot be disabled, the second type of checks (on the shape) is computationally expensive and can be disabled via a command line argument:

```shell
--experimental-options --engine.RelaxStaticObjectSafetyChecks=true
```

Expand Down

0 comments on commit 15d324e

Please sign in to comment.