12 ms·
> unfortunately, the OpenJDK VM does have undefined behavior, although we're attempting to gradually reduce it Is it a goal to remove undefined behavior comple
by saagarjha 7y ago
> unfortunately, the OpenJDK VM does have undefined behavior, although we're attempting to gradually reduce it
Is it a goal to remove undefined behavior completely? Because I seem to recall certain architectural decisions being completely reliant on undefined behavior, such as signal handlers as implicit null checks…
- chrisseaton 7y agoYou can write these little architectural parts in assembly rather than C, to avoid having to write undefined behaviour.
- saagarjha 7y agoDoes the JVM use assembly for this? I’d expect writing all of the VM code that handles Java objects in assembly for each platform would be a bit difficult, and I’m not sure I saw enough assembly files in the project for this…
- chrisseaton 7y agoNo I mean it is an option available to avoid undefined behaviour, not that this is what the JVM does. But moving more of the implementation of the JVM (or all of it!) to Java is the real solution to all this in my opinion.
- saagarjha 7y ago> No I mean it is an option available to avoid undefined behaviour, not that this is what the JVM does. Ah. > But moving more of the implementation of the JVM (or all of it!) to Java is the real solution to all this in my opinion. And what, ship a Graal binary to cut the bootstrapping/startup step?
- chrisseaton 7y agoYes, rewrite all of the JVM into Java and ship an AOT-compiled binary.
- pron 7y agoBTW, there's much more assembly code in OpenJDK than you'd find by looking for assembly files. There's a lot of code (all of the interpreter, for example) that's generated at startup time, and written in assmebly as a C++ DSL. E.g. https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/templateTable_x86.cpp https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x... and https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x...
- pron 7y agoI don't know if there is such a goal, but we certainly try to reduce undefined behavior in OpenJDK; e.g. https://bugs.openjdk.java.net/browse/JDK-8233144 https://bugs.openjdk.java.net/browse/JDK-8233144