IoLanguage / io

Io programming language. Inspired by Self, Smalltalk and LISP.
http://iolanguage.org
Other
2.67k stars 299 forks source link

"UnsupportedSpecializationException" when trying to Io with GraalVM #460

Open PedroBatista opened 2 years ago

PedroBatista commented 2 years ago

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:

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/

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 commented 2 years ago

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 commented 2 years ago

It appears it's having an hard time with CHash_at here: https://github.com/IoLanguage/io/blob/4ff086d9a7f3c4bd23c7f28ececdd159737ae0c1/libs/iovm/source/IoState_symbols.c#L44

Judging by the stack trace part that matters: at CHashat(Unknown) at IoState_symbolWithUArraycopy(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:44:1123) at IoState_symbolWithCStringlength(../../../../Desktop/io/libs/iovm/source/IoState_symbols.c:75:2141) at IoStatesymbolWithCString(../../../../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 commented 2 years ago

Looks like CHashat 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 commented 2 years ago

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 commented 2 years ago

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 (CHashat, CHash_atput, and CHashremoveKey in CHash.c ) it starts initialized the VM up until: https://github.com/IoLanguage/io/blob/6be164890ad08c2edd6770176a5bcde5524bbb1c/libs/iovm/source/IoState.c#L69 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 CHashat code and with the explicit uint8_t cast, execution keeps going until it stack overflows somewhere inside IoCoroutine_rawRun() https://github.com/IoLanguage/io/blob/6be164890ad08c2edd6770176a5bcde5524bbb1c/libs/iovm/source/IoCoroutine.c#L386

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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: https://github.com/IoLanguage/io/blob/6be164890ad08c2edd6770176a5bcde5524bbb1c/libs/coroutine/source/Coro.c#L275

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

rubyFeedback commented 1 year ago

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

stevedekorte commented 1 year ago

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 commented 1 year ago

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.