Checkpointing a javascript program