In the mean time, I got computeHeating to compile as well by not directly assigning to TemperatureMap, but first to an auxiliary variable aux and then TemperatureMap[i] = aux
TemperatureMap[i] = aux
I tried the same trick with computeDiffusion but failed. And compiling computeHeating did not have any noticeable effect on performance - thus, I reverted my changes again.
Amendment: I tried over two dozens of variants for computeDiffusion - even silly ones like byte lookups from a Uint8ClampedArray with the values 0...255 - but all of them failed.
My current impression is that success is nothing but good luck and depends on side effects of compilation (such as overwriting memory areas because of invalid length calculations or similar)
Amendment #2: wow, indeed, success is pure luck! After all my experiments I tried to upload my working example again - and failed because I had also changed Math.random to random in the mean time. After reverting that change, the example started working again.
Which means: simply adding let random = Math.random and replacing all (four) calls of Math.random by random broke a working program!
let random = Math.random
Hopefully, this information may help Gordon et al. finding the reason for this weird compiler bug!
© Espruino, powered by microcosm.
Report a problem