I’m looking at garbage collection with statepoints in LLVM, and with substantial difficulty I’ve got to a point where I have a working example, which I intend to fit the actual GC into later. This post is my attempt to help others get started on statepoints with less difficulty. It begins with a brief explanation… Continue reading LLVM garbage collection statepoints demo
Tag: programming
A simple Opus audio player with JNI
In this fourth part of the JNI tutorial series, we use the Java native interface to maintain an external resource with a state. Specifically, our example opens and plays an Opus audio file through the opusfile API, but the pattern is general enough to be used for any kind of resource. Getting a handle As… Continue reading A simple Opus audio player with JNI
Moving native data in byte buffers
This third part in the JNI tutorial series focuses on processing chunks of data, either moving them between native code and Java, or just keeping tabs on them in Java while keeping the actual data outside the JVM. We’ve seen how values can be passed to and from native methods as parameters and return values,… Continue reading Moving native data in byte buffers
Error handling in JNI
In this second part of the JNI tutorial series, we attack error handling, to get that annoying subject out of the way as soon and as much as possible. There’s no complete example for this part in the tutorial example zip file (because you can’t write a program that only does error handling), but you… Continue reading Error handling in JNI
Tutorial: The Java native interface to C code
This post is the first in a tutorial series about how JNI, the Java native interface, can be used to call C code from a Java program. We start with the basics and finish with a useful Java class that uses an external library for its core operation. Along the way, we look at some… Continue reading Tutorial: The Java native interface to C code
The things you have to do for an interactive terminal interface
Programming language libraries usually expect terminal interaction to take place one print line or read line at a time, and don’t have much support for detecting keypresses or changing what’s already written on the screen. Still, POSIX and other generally followed standards allow more dynamic interaction techniques that are compatible across many systems, and this… Continue reading The things you have to do for an interactive terminal interface
Ten standard ways of representing binary numbers
If you’ve read the headline and think that ten sounds like an awful lot of different binary-number formats, perhaps you are guessing that it includes floating point, or ones’ complement and other archaic representations, but no, this is all about what’s in common current use, all integers, and all based on two’s complement. This post… Continue reading Ten standard ways of representing binary numbers
Never implement doHickey
I sometimes feel like an impostor when I talk about code design because I have absolutely no formal education in it, and I’ve been imprinted with the attitude that it’s the algorithms, their correctness and efficiency, that you’re supposed to worry about. Working on larger projects, in companies and on my own, I’ve come to… Continue reading Never implement doHickey
Optimization by doing the same thing and expecting different results
The point with a compiler is obviously that it lets us write code in language that’s easier to read than assembly code, and modern optimizing compilers can make it more readable still by saving us from obfuscating hand-optimization. For instance, in the 1980s, it may have been good for the performance of your C code to… Continue reading Optimization by doing the same thing and expecting different results
Computing the integer size of a sample
In PCM audio processing, each sample is an integer of at most 32 bits. This blog post is about finding the number of bytes (octets) that can hold a sample, which is nontrivial when the number of bytes is restricted to match an integer type. Easy case: 1, 2, 3, 4 The smallest number of… Continue reading Computing the integer size of a sample