Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public class EndiveCompilerGenMojo extends AbstractMojo {
/**
* Fully qualified name of a MethodPrefixer implementation used to name the compiled methods.
* Defaults to naming them func_0, func_1 and so on. Set it to
* run.endive.compiler.NameSectionMethodPrefixer to name them after the module's name section,
* which makes thread dumps and profiler output readable, or to your own implementation. A
* custom class must be a dependency of this plugin, not of the project.
* run.endive.compiler.NameSectionMethodPrefixer to name them after the module's name section.
*/
@Parameter(required = false)
String methodPrefixer;
Expand Down
48 changes: 9 additions & 39 deletions docs/docs/execution/build-time-compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ If this happens you can configure your build tool, to just issue warning message

### Method Names

By default the compiler names each generated method `func_0`, `func_1`, etc. The `methodPrefixer`
parameter takes the fully qualified name of a `MethodPrefixer` implementation that supplies a more
recognisable prefix instead, which makes thread dumps, profiler output and stack traces identify
functions by name. `NameSectionMethodPrefixer` uses the function names from the module's name
section:
By default the compiler names each generated method `func_0`, `func_1`, etc. Set `methodPrefixer` to
name them after the module's name section instead, so that thread dumps, profiler output and stack
traces identify functions by name:

```xml
<configuration>
Expand All @@ -53,38 +51,12 @@ section:
</configuration>
```

You can name your own implementation instead, for example one that demangles Rust or C++ symbols.
It must implement `run.endive.compiler.MethodPrefixer` and have a public no-argument constructor.
The class is loaded by the plugin, so it has to be a dependency of the plugin declaration rather
than of the project:
The names are resolved at build time and baked into the generated classes; the name section itself is
not shipped with them.

```xml
<plugin>
<groupId>run.endive</groupId>
<artifactId>endive-compiler-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.acme</groupId>
<artifactId>my-demangler</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<!-- executions, with <methodPrefixer>org.acme.MyDemanglingPrefixer</methodPrefixer> -->
</plugin>
```

Names are resolved once, at build time. This is the only opportunity to do so: the meta Wasm module
emitted next to the compiled classes has all of its custom sections stripped, so the name section is
no longer available when the module is loaded. Resolving names here also costs nothing at runtime.

Whatever the prefixer returns, the compiler appends `_<funcId>` to produce the method name, so names
stay unique and the Wasm function index remains recoverable from any method name. Characters that are
illegal in JVM method names (`. ; [ / < >`) are replaced with underscores. The prefix is a hint for
humans; tools should use the function index instead. See
[Method Names](runtime-compiler.md#method-names) for the full contract.

Since the name section is not retained, mapping a function index back to its original name requires
the original Wasm module, which is a build input rather than something shipped with the classes.
The parameter accepts any `run.endive.compiler.MethodPrefixer` with a public no-argument constructor,
declared as a dependency of the plugin. See [Method Names](runtime-compiler.md#method-names) for the
naming contract.

## Using Maven

Expand Down Expand Up @@ -241,9 +213,7 @@ endive:compile
Fully qualified name of a MethodPrefixer implementation used to name the
compiled methods. Defaults to naming them func_0, func_1 and so on. Set
it to run.endive.compiler.NameSectionMethodPrefixer to name them after
the module's name section, which makes thread dumps and profiler output
readable, or to your own implementation. A custom class must be a
dependency of this plugin, not of the project.
the module's name section.

moduleInterface
Fully qualified name of the user's class for which to generate
Expand Down
Loading