Skip to content

Commit 4cbb6c2

Browse files
authored
Shorten the method names documentation (#180)
1 parent d0cc4f4 commit 4cbb6c2

2 files changed

Lines changed: 10 additions & 42 deletions

File tree

compiler-maven-plugin/src/main/java/run/endive/build/time/maven/EndiveCompilerGenMojo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ public class EndiveCompilerGenMojo extends AbstractMojo {
7474
/**
7575
* Fully qualified name of a MethodPrefixer implementation used to name the compiled methods.
7676
* Defaults to naming them func_0, func_1 and so on. Set it to
77-
* run.endive.compiler.NameSectionMethodPrefixer to name them after the module's name section,
78-
* which makes thread dumps and profiler output readable, or to your own implementation. A
79-
* custom class must be a dependency of this plugin, not of the project.
77+
* run.endive.compiler.NameSectionMethodPrefixer to name them after the module's name section.
8078
*/
8179
@Parameter(required = false)
8280
String methodPrefixer;

docs/docs/execution/build-time-compiler.md

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ If this happens you can configure your build tool, to just issue warning message
3939

4040
### Method Names
4141

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

4846
```xml
4947
<configuration>
@@ -53,38 +51,12 @@ section:
5351
</configuration>
5452
```
5553

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

61-
```xml
62-
<plugin>
63-
<groupId>run.endive</groupId>
64-
<artifactId>endive-compiler-maven-plugin</artifactId>
65-
<dependencies>
66-
<dependency>
67-
<groupId>org.acme</groupId>
68-
<artifactId>my-demangler</artifactId>
69-
<version>1.0.0</version>
70-
</dependency>
71-
</dependencies>
72-
<!-- executions, with <methodPrefixer>org.acme.MyDemanglingPrefixer</methodPrefixer> -->
73-
</plugin>
74-
```
75-
76-
Names are resolved once, at build time. This is the only opportunity to do so: the meta Wasm module
77-
emitted next to the compiled classes has all of its custom sections stripped, so the name section is
78-
no longer available when the module is loaded. Resolving names here also costs nothing at runtime.
79-
80-
Whatever the prefixer returns, the compiler appends `_<funcId>` to produce the method name, so names
81-
stay unique and the Wasm function index remains recoverable from any method name. Characters that are
82-
illegal in JVM method names (`. ; [ / < >`) are replaced with underscores. The prefix is a hint for
83-
humans; tools should use the function index instead. See
84-
[Method Names](runtime-compiler.md#method-names) for the full contract.
85-
86-
Since the name section is not retained, mapping a function index back to its original name requires
87-
the original Wasm module, which is a build input rather than something shipped with the classes.
57+
The parameter accepts any `run.endive.compiler.MethodPrefixer` with a public no-argument constructor,
58+
declared as a dependency of the plugin. See [Method Names](runtime-compiler.md#method-names) for the
59+
naming contract.
8860

8961
## Using Maven
9062

@@ -241,9 +213,7 @@ endive:compile
241213
Fully qualified name of a MethodPrefixer implementation used to name the
242214
compiled methods. Defaults to naming them func_0, func_1 and so on. Set
243215
it to run.endive.compiler.NameSectionMethodPrefixer to name them after
244-
the module's name section, which makes thread dumps and profiler output
245-
readable, or to your own implementation. A custom class must be a
246-
dependency of this plugin, not of the project.
216+
the module's name section.
247217
248218
moduleInterface
249219
Fully qualified name of the user's class for which to generate

0 commit comments

Comments
 (0)