Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-53670] Layered HelloWorld #8917

Merged
merged 4 commits into from May 17, 2024
Merged

[GR-53670] Layered HelloWorld #8917

merged 4 commits into from May 17, 2024

Conversation

graalvmbot
Copy link
Collaborator

The image heap of the application layer is now written after the image heap of the base layer. This allow to use constants from the application layer, such as the options, or the String in System.out.print. This caused the cast class error as SubstrateOptions.DumpHeapAndExit is a constant from the application layer.

The methods from the base layer need to be inlined to directly call the main method instead of going through the method handle. Note that allowing the methods from the base layer to be inlined means their graph is parsed a second time in the application layer. We do not want this, but ultimately, the graph should be persisted from the base layer. Executing the method handle currently causes a segfault with the following stack trace:

#0  0x00007ffff240fe0c in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl$MetadataAccessorImpl::getOtherString(int) (this=<optimized out>, index=<optimized out>)
    at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:716
#1  0x00007ffff2412a26 in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::decodeOtherString(jdk.graal.compiler.core.common.util.UnsafeArrayTypeReader*) (buf=<optimized out>)
    at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:637
#2  0x00007ffff240f388 in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::lambda$decodeExecutable$11(jdk.graal.compiler.core.common.util.UnsafeArrayTypeReader*, java.lang.Integer*) (buf=<optimized out>, 
    i=<optimized out>) at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:519
#3  0x00007ffff240f388 in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl$$Lambda/0x68804c6eac6192342c2571d86fa6c35a0::apply(java.lang.Object*) (this=<optimized out>, ::(void)=<optimized out>)
   from /home/scoppey/layered-image-test/application-layer-test/libjavabaselayer.so
#4  0x00007ffff24120c4 in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::decodeArray(jdk.graal.compiler.core.common.util.UnsafeArrayTypeReader*, java.lang.Class*, java.util.function.Function*) (
    buf=<optimized out>, elementType=<optimized out>, elementDecoder=0x7ff7f2d05b38) at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:667
#5  0x00007ffff24105ec in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::decodeExecutable(jdk.graal.compiler.core.common.util.UnsafeArrayTypeReader*, java.lang.Class*, boolean, boolean, boolean) (
    buf=0x7ff7f2d01108, declaringClass=0x7ff7f2bf2658, publicOnly=false, reflectOnly=true, isMethod=true) at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:519
#6  0x00007ffff24114de in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::lambda$parseMethods$2(jdk.graal.compiler.core.common.util.UnsafeArrayTypeReader*, java.lang.Class*, boolean, java.lang.Integer*) (
    reader=<optimized out>, declaringType=<optimized out>, publicOnly=<optimized out>, i=<optimized out>) at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:127
#7  0x00007ffff240f07e in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl$$Lambda/0x3adab872b912379d33c7a8f6b14f6590::apply(java.lang.Object*) (this=<optimized out>, ::(void)=<optimized out>)
   from /home/scoppey/layered-image-test/application-layer-test/libjavabaselayer.so
#8  0x00007ffff24120c4 in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::decodeArray(jdk.graal.compiler.core.common.util.UnsafeArrayTypeReader*, java.lang.Class*, java.util.function.Function*) (
    buf=<optimized out>, elementType=<optimized out>, elementDecoder=0x7ff7f2d01120) at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:667
#9  0x00007ffff2413320 in com.oracle.svm.core.code.RuntimeMetadataDecoderImpl::parseMethods(java.lang.Class*, int, boolean) (this=<optimized out>, declaringType=<optimized out>, index=<optimized out>, 
    publicOnly=<optimized out>) at com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java:127
#10 0x00007ffff32729cb in java.lang.Class::getDeclaredMethods0(boolean) (this=<optimized out>, publicOnly=<optimized out>) at com/oracle/svm/core/hub/DynamicHub.java:1770
#11 0x00007ffff3274445 in java.lang.Class::privateGetDeclaredMethods(boolean) (this=<optimized out>, publicOnly=false) at java/lang/Class.java:3650
#12 0x00007ffff32728fb in java.lang.Class::getDeclaredMethod(java.lang.String*, java.lang.Class[]*) (this=0x7ff7f2bf2658, methodName=0x7ff7f0699cd0, parameterTypes=0x7ff7f2d010a0)
    at com/oracle/svm/core/hub/DynamicHub.java:1275
#13 0x00007ffff24872c0 in com.oracle.svm.core.methodhandles.Util_java_lang_invoke_MethodHandleNatives::lookupMethod(java.lang.Class*, java.lang.String*, java.lang.Class[]*, java.lang.Throwable*) (
    declaringClazz=0x7ff7f2bf2658, name=0x7ff7f0699cd0, parameterTypes=0x7ff7f2d010a0, originalException=0x7ff7efe00000) at com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java:243
#14 0x00007ffff24874ef in com.oracle.svm.core.methodhandles.Util_java_lang_invoke_MethodHandleNatives::lookupMethod(java.lang.Class*, java.lang.String*, java.lang.Class[]*) (declaringClazz=<optimized out>, 
    name=<optimized out>, parameterTypes=<optimized out>) at com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java:238
#15 com.oracle.svm.core.methodhandles.Util_java_lang_invoke_MethodHandleNatives::resolve(java.lang.invoke.MemberName*, java.lang.Class*, boolean) (self=0x7ff7f2c45ac0, caller=<optimized out>, 
    speculativeResolve=false) at com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandleNatives.java:320
#16 0x00007ffff2485c68 in com.oracle.svm.core.methodhandles.Util_java_lang_invoke_MethodHandle::invokeInternal(java.lang.invoke.MemberName*, java.lang.invoke.MethodType*, java.lang.Object[]*) (
    memberName=0x7ff7f2c45ac0, methodType=0x7ff7f2c45b80, args=0x7ff7f2d01090) at com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandle.java:180
#17 0x00007ffff2486d4d in com.oracle.svm.core.methodhandles.Util_java_lang_invoke_MethodHandle::linkTo(java.lang.Object[]*) (args=<optimized out>)
    at com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandle.java:170
#18 0x00007ffff33f99e3 in java.lang.invoke.MethodHandle::linkToStatic(java.lang.Object[]*) (args=<optimized out>) at com/oracle/svm/core/methodhandles/Target_java_lang_invoke_MethodHandle.java:131
#19 0x00000000004212bb in java.lang.invoke.MethodHandle::linkToStatic(java.lang.Object*, java.lang.invoke.MemberName*) (::(void)=<optimized out>, __1=<optimized out>) at java/lang/invoke/MethodHandle.java:1
#20 0x000000000042030a in java.lang.invoke.LambdaForm$DMH/sa346b79c::invokeStaticInit(java.lang.Object*, java.lang.Object*) (::(void)=<optimized out>, __1=<optimized out>)
    at com/oracle/svm/core/JavaMainWrapper.java:167
#21 com.oracle.svm.core.JavaMainWrapper::invokeMain(java.lang.String[]*) (args=<optimized out>) at com/oracle/svm/core/JavaMainWrapper.java:179
#22 0x00000000004203b2 in com.oracle.svm.core.JavaMainWrapper::runCore0() () at com/oracle/svm/core/JavaMainWrapper.java:230
#23 0x0000000000420201 in com.oracle.svm.core.JavaMainWrapper::runCore() () at com/oracle/svm/core/JavaMainWrapper.java:199
#24 com.oracle.svm.core.JavaMainWrapper::doRun(int, org.graalvm.nativeimage.c.type.CCharPointerPointer) (argc=<optimized out>, argv=<optimized out>) at com/oracle/svm/core/JavaMainWrapper.java:297
#25 0x00000000004207ec in com.oracle.svm.core.JavaMainWrapper::run(int, org.graalvm.nativeimage.c.type.CCharPointerPointer) (argc=<optimized out>, argv=<optimized out>)
    at com/oracle/svm/core/JavaMainWrapper.java:282
#26 com.oracle.svm.core.code.IsolateEnterStub::JavaMainWrapper_run_XNhh1mz2Ib2aPR1wdv014D(int, org.graalvm.nativeimage.c.type.CCharPointerPointer) (::(void)=<optimized out>, __1=<optimized out>)
    at com/oracle/svm/core/code/IsolateEnterStub.java:1

This is likely to be caused by the runtime metadata not being accessible in the application at the moment.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 13, 2024
@graalvmbot graalvmbot closed this May 17, 2024
@graalvmbot graalvmbot deleted the scoppey/layered-helloworld branch May 17, 2024 03:07
@graalvmbot graalvmbot merged commit 54384f7 into master May 17, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants