When executed with -XX:-ScalarizeValueTypes, the test fails with:
# Internal Error (/oracle/valhalla2/open/src/hotspot/share/oops/markOop.hpp:207), pid=20911, tid=20912
# assert(!is_always_locked()) failed: invariant
Current thread (0x00007f8600028000): JavaThread "main" [_thread_in_Java, id=20912, stack(0x00007f8608dff000,0x00007f8608f00000)]
Stack: [0x00007f8608dff000,0x00007f8608f00000], sp=0x00007f8608efbf20, free space=1011k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xaeadc6] Deoptimization::relock_objects(GrowableArray<MonitorInfo*>*, JavaThread*, bool)+0x506
V [libjvm.so+0xaf3b7a] Deoptimization::fetch_unroll_info_helper(JavaThread*, int)+0xaaa
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
v ~UncommonTrapBlob
J 206 c2 compiler.valhalla.valuetypes.TestLWorld.test58()V (16 bytes) @ 0x00007f85fd1f43d0 [0x00007f85fd1f42c0+0x0000000000000110]
j compiler.valhalla.valuetypes.TestLWorld.test58_verifier(Z)V+1
j jdk.internal.reflect.GeneratedMethodAccessor50.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+63
J 175% c2 compiler.valhalla.valuetypes.ValueTypeTest.run([Ljava/lang/Class;)V (699 bytes) @ 0x00007f85fd1d9ce0 [0x00007f85fd1d9400+0x00000000000008e0]
j compiler.valhalla.valuetypes.ValueTypeTest.run([Ljava/lang/String;[Ljava/lang/Class;)V+41
j compiler.valhalla.valuetypes.TestLWorld.main([Ljava/lang/String;)V+45
v ~StubRoutines::call_stub
Register to memory mapping:
Different failure mode without lock elimination:
# Internal Error (/oracle/valhalla1/open/src/hotspot/share/runtime/synchronizer.cpp:305), pid=2005, tid=2006
# assert(!EnableValhalla || !object->klass()->is_value()) failed: monitor op on value type
Stack: [0x00007f8c8b636000,0x00007f8c8b737000], sp=0x00007f8c8b735630, free space=1021k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x1842e09] ObjectSynchronizer::fast_exit(oop, BasicLock*, Thread*)+0x329
V [libjvm.so+0x184303a] ObjectSynchronizer::slow_exit(oop, BasicLock*, Thread*)+0x2a
V [libjvm.so+0xe49c7b] InterpreterRuntime::monitorexit(JavaThread*, BasicObjectLock*)+0x25b
j Test.test58_inline(Ljava/lang/Object;)V+14
j Test.test58(I)V+6
j Test.main([Ljava/lang/String;)V+9
v ~StubRoutines::call_stub
V [libjvm.so+0xe62fbd] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, Thread*)+0x86d
V [libjvm.so+0xf322fb] jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*) [clone .isra.150] [clone .constprop.234]+0x19b
V [libjvm.so+0xf40cce] jni_CallStaticVoidMethod+0x1ee
C [libjli.so+0x4d33] JavaMain+0xbd3
C [libjli.so+0x8239] ThreadJavaMain+0x9