Skip to content

Commit 7b51429

Browse files
Ef55zapster
authored andcommitted
[GR-47832] Support JEP 424 ("Panama") foreign upcalls in Native Image.
PullRequest: graal/15204
2 parents 9f82b63 + 9d8926a commit 7b51429

File tree

40 files changed

+2127
-189
lines changed

40 files changed

+2127
-189
lines changed

docs/reference-manual/native-image/BuildOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ There are some expert level options that a user may find useful or needed. For e
116116

117117
Native Image provides an informative [build output](BuildOutput.md) including various statistics during the build process.
118118
The build output in a JSON-based, machine-readable format can be requested using the `-H:BuildOutputJSONFile` option, and later processed by a monitoring tool.
119-
The JSON files validate against the JSON schema defined in [build-output-schema-v0.9.2.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/build-output-schema-v0.9.2.json).
119+
The JSON files validate against the JSON schema defined in [build-output-schema-v0.9.3.json](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/build-output-schema-v0.9.3.json).
120120
A comprehensive report with additional information can be requested using the `-H:+BuildReport` option.
121121

122122
### Graph Dumping

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ Large numbers can cause significant reflection overheads, slow down the build pr
165165
#### <a name="glossary-jni-access-registrations"></a>JNI Access Registrations
166166
The number of types, fields, and methods that are registered for [JNI](JNI.md) access.
167167
168-
#### <a name="glossary-foreign-downcall-registrations"></a>Foreign functions stubs
169-
The number of downcalls registered for [foreign](ForeignInterface.md) function access.
168+
#### <a name="glossary-foreign-downcall-and-upcall-registrations"></a>Foreign functions stubs
169+
The number of downcalls and upcalls registered for [foreign](ForeignInterface.md) function access.
170170
171171
#### <a name="glossary-runtime-methods"></a>Runtime Compiled Methods
172172
The number of methods marked for runtime compilation.
@@ -356,7 +356,7 @@ This schema also contains descriptions for each possible artifact type and expla
356356
357357
The build output produced by the `native-image` builder is designed for humans, can evolve with new releases, and should thus not be parsed in any way by tools.
358358
Instead, use the `-H:BuildOutputJSONFile=<file.json>` option to instruct the builder to produce machine-readable build output in JSON format that can be used, for example, for building monitoring tools.
359-
Such a JSON file validates against the JSON schema defined in [`build-output-schema-v0.9.2.json`](https://github.com/oracle/graal/tree/master/docs/reference-manual/native-image/assets/build-output-schema-v0.9.2.json).
359+
Such a JSON file validates against the JSON schema defined in [`build-output-schema-v0.9.3.json`](https://github.com/oracle/graal/tree/master/docs/reference-manual/native-image/assets/build-output-schema-v0.9.3.json).
360360
Note that a JSON file is produced if and only if a build succeeds.
361361
362362
The following example illustrates how this could be used in a CI/CD build pipeline to check that the number of reachable methods does not exceed a certain threshold:

docs/reference-manual/native-image/ForeignInterface.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Shared arenas are currently not supported.
2424
The FFM API enables Java code to call _down_ to native functions, and conversely allows native code to call _up_ to invoke Java code via method handles.
2525
These two kinds of calls are referred to as "downcalls" and "upcalls" respectively, and are collectively referred to as "foreign calls".
2626

27-
> Note: Currently, only downcalls are supported, and only on the x64 architecture.
27+
> Note: Currently, foreign calls are supported on the x64 architecture.
28+
> Specifically, downcalls are supported on x64 Linux, Windows and MacOS, while upcalls are supported only on x64 Linux.
2829
2930
### Looking Up Native Functions
3031

@@ -43,8 +44,10 @@ import static java.lang.foreign.ValueLayout.*;
4344
class ForeignRegistrationFeature implements Feature {
4445
public void duringSetup(DuringSetupAccess access) {
4546
RuntimeForeignAccess.registerForDowncall(FunctionDescriptor.ofVoid());
46-
RuntimeForeignAccess.registerForDowncall(FunctionDescriptor.ofVoid(), Linker.Option.isTrivial());
47-
RuntimeForeignAccess.registerForDowncall(FunctionDescriptor.of(JAVA_INT, JAVA_INT, JAVA_INT));
47+
RuntimeForeignAccess.registerForUpcall(FunctionDescriptor.ofVoid());
48+
RuntimeForeignAccess.registerForDowncall(FunctionDescriptor.ofVoid(), Linker.Option.critical(false));
49+
RuntimeForeignAccess.registerForUpcall(FunctionDescriptor.of(JAVA_INT, JAVA_INT));
50+
RuntimeForeignAccess.registerForUpcall(FunctionDescriptor.of(JAVA_INT, JAVA_INT, JAVA_INT));
4851
RuntimeForeignAccess.registerForDowncall(FunctionDescriptor.of(ADDRESS, JAVA_INT, JAVA_INT), Linker.Option.firstVariadicArg(1));
4952
RuntimeForeignAccess.registerForDowncall(FunctionDescriptor.ofVoid(JAVA_INT), Linker.Option.captureCallState("errno"));
5053
}
@@ -53,10 +56,6 @@ class ForeignRegistrationFeature implements Feature {
5356
To activate the custom feature, pass the `--features=com.example.ForeignRegistrationFeature` option (the fully-qualified name of the feature class) to `native-image`.
5457
It is recommended to do so [with a _native-image.properties_ file](BuildConfiguration.md#embed-a-configuration-file).
5558

56-
### Upcalls
57-
58-
Upcalls are not yet supported.
59-
6059
### Related Documentation
6160

6261
- [Interoperability with Native Code](InteropWithNativeCode.md)

0 commit comments

Comments
 (0)