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

"UnsupportedSpecializationException" when trying to Io with GraalVM #460

Open
PedroBatista opened this issue Dec 23, 2021 · 11 comments
Open

Comments

@PedroBatista
Copy link

Hi,

I'm trying to run the Io vm with Graal, I've managed to compile it but have been unsusessfull at runing Io. Below are the steps I've followed:

  • Compile Io project to LLVM Bitcode ( using Clang )

You might need to set some flags ( although it might be more correct to insert them as argument when calling cmake )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
SET ( CMAKE_C_FLAGS "-emit-llvm")
and defintaly use the Clang that comes with GraalVM:
-DCMAKE_C_COMPILER=[GraalVM folder]/languages/llvm/native/bin/clang

Some reference: https://www.graalvm.org/reference-manual/llvm/Compiling/

  • Run Io using Graal: /[GraalVM folder]/languages/llvm/bin ./lli [Io folder]/build/_build/binaries/io

It would show the Io prompt but instead it gives me this error: ERROR: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for LLVMNeNodeGen#1: [false, 0], [Boolean,Integer]

I've tried to look into IoState_symbols.c but it's way over my head. Looking at GraalVM's issues, there's also other "com.oracle.truffle.api.dsl.UnsupportedSpecializationException" errors and my feeling is when some C code is more "advanced" or "less than plain standard", GraaVM might not know how to read what the compiler produced ( but I might be wrong ).

Operating System: Ubuntu 20.04.3 LTS
Kernel: Linux 5.4.0-91-generic
Architecture: x86-64

(Sorry for the stacktrace taller than the Empire State Building)

ERROR: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for LLVMNeNodeGen#1: [false, 0], [Boolean,Integer] org.graalvm.polyglot.PolyglotException: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for LLVMNeNodeGen#1: [false, 0], [Boolean,Integer] at com.oracle.truffle.llvm.runtime.nodes.op.LLVMCompareNodeFactory$LLVMNeNodeGen.executeAndSpecialize(LLVMCompareNodeFactory.java:1529) at com.oracle.truffle.llvm.runtime.nodes.op.LLVMCompareNodeFactory$LLVMNeNodeGen.executeI1_generic17(LLVMCompareNodeFactory.java:1431) at com.oracle.truffle.llvm.runtime.nodes.op.LLVMCompareNodeFactory$LLVMNeNodeGen.executeI1(LLVMCompareNodeFactory.java:1266) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWriteI1NodeGen.execute(LLVMWriteNodeFactory.java:71) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at <llvm> CHash_at_(Unknown) at <llvm> IoState_symbolWithUArray_copy_(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:44:1123) at <llvm> IoState_symbolWithCString_length_(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:75:2141) at <llvm> IoState_symbolWithCString_(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:79:2268) at <llvm> IoState_retainedSymbol(../../../../Desktop/io/libs/iovm/source/IoState.c:245:8336) at <llvm> IoState_setupQuickAccessSymbols(../../../../Desktop/io/libs/iovm/source/IoState.c:251:8564) at <llvm> IoState_new_atAddress(../../../../Desktop/io/libs/iovm/source/IoState.c:106:2910) at <llvm> IoState_new(../../../../Desktop/io/libs/iovm/source/IoState.c:240:8195) at <llvm> main(../../../../Desktop/io/tools/source/main.c:37:599) at org.graalvm.polyglot.Value.execute(Value.java:839) at com.oracle.truffle.llvm.launcher.LLVMLauncher.execute(LLVMLauncher.java:254) at com.oracle.truffle.llvm.launcher.LLVMLauncher.launch(LLVMLauncher.java:75) at org.graalvm.launcher.AbstractLanguageLauncher.launch(AbstractLanguageLauncher.java:124) at org.graalvm.launcher.AbstractLanguageLauncher.launch(AbstractLanguageLauncher.java:71) at com.oracle.truffle.llvm.launcher.LLVMLauncher.main(LLVMLauncher.java:53) Original Internal Error: com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for LLVMNeNodeGen#1: [false, 0], [Boolean,Integer] at com.oracle.truffle.llvm.runtime.nodes.op.LLVMCompareNodeFactory$LLVMNeNodeGen.executeAndSpecialize(LLVMCompareNodeFactory.java:1529) at com.oracle.truffle.llvm.runtime.nodes.op.LLVMCompareNodeFactory$LLVMNeNodeGen.executeI1_generic17(LLVMCompareNodeFactory.java:1431) at com.oracle.truffle.llvm.runtime.nodes.op.LLVMCompareNodeFactory$LLVMNeNodeGen.executeI1(LLVMCompareNodeFactory.java:1266) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWriteI1NodeGen.execute(LLVMWriteNodeFactory.java:71) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:87) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen.executeGeneric_generic5(LLVMToAddressNodeGen.java:162) at com.oracle.truffle.llvm.runtime.nodes.cast.LLVMToAddressNodeGen.executeGeneric(LLVMToAddressNodeGen.java:87) at com.oracle.truffle.llvm.runtime.nodes.memory.store.LLVMPointerStoreNodeGen.execute_generic1(LLVMPointerStoreNodeGen.java:273) at com.oracle.truffle.llvm.runtime.nodes.memory.store.LLVMPointerStoreNodeGen.execute(LLVMPointerStoreNodeGen.java:213) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:87) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute_generic1(LLVMWriteNodeFactory.java:1031) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute(LLVMWriteNodeFactory.java:1008) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:87) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute_generic1(LLVMWriteNodeFactory.java:1031) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute(LLVMWriteNodeFactory.java:1008) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:87) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:79) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute_generic1(LLVMWriteNodeFactory.java:1031) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute(LLVMWriteNodeFactory.java:1008) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeAndSpecialize(LLVMDispatchNodeGen.java:255) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:214) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute_generic1(LLVMWriteNodeFactory.java:1031) at com.oracle.truffle.llvm.runtime.nodes.vars.LLVMWriteNodeFactory$LLVMWritePointerNodeGen.execute(LLVMWriteNodeFactory.java:1008) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeAndSpecialize(LLVMDispatchNodeGen.java:255) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:214) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.api.LLVMVoidStatementNodeGen.execute(LLVMVoidStatementNodeGen.java:22) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeAndSpecialize(LLVMDispatchNodeGen.java:255) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:214) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.api.LLVMVoidStatementNodeGen.execute(LLVMVoidStatementNodeGen.java:22) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectCodeFast(LLVMDispatchNode.java:165) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeAndSpecialize(LLVMDispatchNodeGen.java:255) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:214) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.memory.store.LLVMPointerStoreNodeGen.execute_generic1(LLVMPointerStoreNodeGen.java:273) at com.oracle.truffle.llvm.runtime.nodes.memory.store.LLVMPointerStoreNodeGen.execute(LLVMPointerStoreNodeGen.java:213) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNode.doDirectFunction(LLVMDispatchNode.java:180) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeAndSpecialize(LLVMDispatchNodeGen.java:316) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMDispatchNodeGen.executeDispatch(LLVMDispatchNodeGen.java:214) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:82) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.api.LLVMFrameNullerExpression.doGeneric(LLVMFrameNullerExpression.java:72) at com.oracle.truffle.llvm.runtime.nodes.api.LLVMFrameNullerExpressionNodeGen.executeGeneric(LLVMFrameNullerExpressionNodeGen.java:21) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNode.doCall(LLVMCallNode.java:79) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMCallNodeGen.executeGeneric(LLVMCallNodeGen.java:28) at com.oracle.truffle.llvm.runtime.nodes.api.LLVMVoidStatementNodeGen.execute(LLVMVoidStatementNodeGen.java:22) at com.oracle.truffle.llvm.runtime.nodes.base.LLVMBasicBlockNode$InitializedBlockNode.execute(LLVMBasicBlockNode.java:173) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNode.doDispatch(LLVMDispatchBasicBlockNode.java:97) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMDispatchBasicBlockNodeGen.executeGeneric(LLVMDispatchBasicBlockNodeGen.java:24) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNode.doRun(LLVMFunctionRootNode.java:85) at com.oracle.truffle.llvm.runtime.nodes.control.LLVMFunctionRootNodeGen.executeGeneric(LLVMFunctionRootNodeGen.java:25) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMFunctionStartNode.execute(LLVMFunctionStartNode.java:93) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMGlobalRootNode.executeWithoutFrame(LLVMGlobalRootNode.java:86) at com.oracle.truffle.llvm.runtime.nodes.func.LLVMGlobalRootNode.execute(LLVMGlobalRootNode.java:75) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:481) at org.graalvm.compiler.truffle.runtime.OptimizedDirectCallNode.call(OptimizedDirectCallNode.java:71) at com.oracle.truffle.llvm.runtime.SulongLibrary$Execute.doCached(SulongLibrary.java:236) at com.oracle.truffle.llvm.runtime.SulongLibraryGen$InteropLibraryExports$Cached.executeAndSpecialize(SulongLibraryGen.java:151) at com.oracle.truffle.llvm.runtime.SulongLibraryGen$InteropLibraryExports$Cached.execute(SulongLibraryGen.java:111) at com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.execute(InteropLibraryGen.java:7592) at com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$AbstractExecuteNode.executeShared(PolyglotValueDispatch.java:4231) at com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$ExecuteNoArgsNode.executeImpl(PolyglotValueDispatch.java:4338) at com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:127) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:650) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:622) at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:555) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:121) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTargetInstalledCode.doInvoke(SubstrateOptimizedCallTargetInstalledCode.java:176) at com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.doInvoke(SubstrateOptimizedCallTarget.java:104) at org.graalvm.compiler.truffle.runtime.GraalRuntimeSupport.callProfiled(GraalRuntimeSupport.java:202) at com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.execute(PolyglotValueDispatch.java:2374) at org.graalvm.polyglot.Value.execute(Value.java:839) at com.oracle.truffle.llvm.launcher.LLVMLauncher.execute(LLVMLauncher.java:254) at com.oracle.truffle.llvm.launcher.LLVMLauncher.launch(LLVMLauncher.java:75) at org.graalvm.launcher.AbstractLanguageLauncher.launch(AbstractLanguageLauncher.java:124) at org.graalvm.launcher.AbstractLanguageLauncher.launch(AbstractLanguageLauncher.java:71) at com.oracle.truffle.llvm.launcher.LLVMLauncher.main(LLVMLauncher.java:53) Caused by: Attached Guest Language Frames (12)

@stevedekorte
Copy link
Member

stevedekorte commented Dec 23, 2021

Could this be the result of some IoVM C code that treats an integer as a boolean? Is there any way to get the C source file and line number that caused the issue?

@PedroBatista
Copy link
Author

It appears it's having an hard time with CHash_at here:

IoSymbol *ioSymbol = CHash_at_(self->symbols, ba);

Judging by the stack trace part that matters:
at CHash_at_(Unknown)
at IoState_symbolWithUArray_copy_(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:44:1123)
at IoState_symbolWithCString_length_(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:75:2141)
at IoState_symbolWithCString_(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:79:2268)
at IoState_retainedSymbol(../../../../Desktop/io/libs/iovm/source/IoState.c:245:8336)
at IoState_setupQuickAccessSymbols(../../../../Desktop/io/libs/iovm/source/IoState.c:251:8564)
at IoState_new_atAddress(../../../../Desktop/io/libs/iovm/source/IoState.c:106:2910)
at IoState_new(../../../../Desktop/io/libs/iovm/source/IoState.c:240:8195)
at main(../../../../Desktop/io/tools/source/main.c:37:599)
at org.graalvm.polyglot.Value.execute(Value.java:839)

@stevedekorte
Copy link
Member

stevedekorte commented Dec 23, 2021

Looks like CHash_at_ is an inline function:

IOINLINE void *CHash_at_(CHash *self, void *k) {
    CHashRecord *r;

    r = CHash_record1_(self, k);

    if (r->k && self->equals(k, r->k)) {
        return r->v;
    }

    r = CHash_record2_(self, k);

    if (r->k && self->equals(k, r->k)) {
        return r->v;
    }

    return 0x0;
}

So maybe it wants some explicit type conversions for r->k and self->equals (which we should do anyways as it would be more proper C code)?

@stevedekorte
Copy link
Member

stevedekorte commented Dec 27, 2021

Here's what you might try swapping in (if I remember my C correctly):

IOINLINE void *CHash_at_(CHash *self, void *k) {
    CHashRecord *r;

    r = CHash_record1_(self, k);

    if (r->k != NULL && self->equals(k, r->k) == 1) {
        return r->v;
    }

    r = CHash_record2_(self, k);

    if (r->k != NULL && self->equals(k, r->k) == 1) {
        return r->v;
    }

    return 0x0;
}

@PedroBatista
Copy link
Author

Hi Steve,
unfortunately your code results in the same error:
com.oracle.truffle.api.dsl.UnsupportedSpecializationException: Unexpected values provided for LLVMEqNodeGen#1: [false, 1], [Boolean,Integer]

but with a different value "[false, 1], [Boolean,Integer]" , before its was "[false, 0], [Boolean,Integer]".

I've been poking around and if I explicitly cast self->equals to uint8_t in all problematic functions (CHash_at_, CHash_at_put_, and CHash_removeKey_ in CHash.c ) it starts initialized the VM up until:

self->endTime = 0;

Somewhere after that it segfaults. Executing the same binary without the GraalVM works fine even with all the changes I've made.

However, with the original CHash_at_ code and with the explicit uint8_t cast, execution keeps going until it stack overflows somewhere inside IoCoroutine_rawRun()

void IoCoroutine_rawRun(IoCoroutine *self) {

Now, I'm not sure uint8_t is the correct cast to use and if the stack overflow problems are related to this but I've tried int, intptr_t and others but with uint8_t it's the farthest I've manage to come until it blows up.

Since I've doing printf() based debugging with not much knowledge it will take a while but I'm sure I can find a more exact location where the execution goes wrong.

@stevedekorte
Copy link
Member

stevedekorte commented Dec 29, 2021

I'm wondering if some of these issues would be easier to resolve if we removed all the inlines from the implementation. I'd be willing to do that if it makes the implementation easier to maintain. Any thoughts?

@stevedekorte
Copy link
Member

Maybe we could also add stdbool.h to the standard set of includes and use bool and bool casts for all branch/loops, etc?

@PedroBatista
Copy link
Author

I think both would help, at least to make the code "more clear" and decrease the chance of errors/problems.

Meanwhile I tracked down the stack-overflow problem to swapcontext() at:

swapcontext(&self->env, &next->env);

swapcontext() is a function from ucontext.h, I'm afraid we are entering hyper-space and I can't go there... 😕

@rubyFeedback
Copy link

Having Io on GraalVM would be interesting, if only in comparison to e. g. python and ruby (truffleruby etc...).

@stevedekorte
Copy link
Member

stevedekorte commented Mar 31, 2023

I've ported Io to WASM, including coroutines using empscripten's fiber API. Might that be helpful with GRAAL?

https://github.com/stevedekorte/ioWasm

@PedroBatista
Copy link
Author

PedroBatista commented Apr 4, 2023

Hi Steve,

sorry for the late reply. I've tried running it with: wasm --Builtins=env:emscripten iovm.wasm

but it gives me the following error:
ERROR: The imported function 'emscripten_glCopyTexImage2D', referenced in the module 'main', does not exist in the imported module 'env'.

"emscripten_glCopyTexImage2D" Looks something OpenGL related, I'll probably have to find a way to recompile the VM and not include any module that doesn't really need to be there in order to minimize the chance of this problems. At least for now just to see it works.

For anyone who also might try, you must run the latest version of GraalVM ( 22.3 ), 22.1 will not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants