re #2 factorized out some code common to the C & asm.js plugins