py: Add MICROPY_PERSISTENT_CODE so code can persist beyond the runtime.

Main changes when MICROPY_PERSISTENT_CODE is enabled are:

- qstrs are encoded as 2-byte fixed width in the bytecode
- all pointers are removed from bytecode and put in const_table (this
  includes const objects and raw code pointers)

Ultimately this option will enable persistence for not just bytecode but
also native code.
diff --git a/py/vm.c b/py/vm.c
index 393b8a1..f9aa0f9 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -65,6 +65,18 @@
     } while ((*ip++ & 0x80) != 0)
 #define DECODE_ULABEL mp_uint_t ulab = (ip[0] | (ip[1] << 8)); ip += 2
 #define DECODE_SLABEL mp_uint_t slab = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2
+
+#if MICROPY_PERSISTENT_CODE
+
+#define DECODE_QSTR \
+    qstr qst = ip[0] | ip[1] << 8; \
+    ip += 2;
+#define DECODE_PTR \
+    DECODE_UINT; \
+    void *ptr = (void*)code_state->const_table[unum]
+
+#else
+
 #define DECODE_QSTR qstr qst = 0; \
     do { \
         qst = (qst << 7) + (*ip & 0x7f); \
@@ -73,6 +85,9 @@
     ip = (byte*)(((mp_uint_t)ip + sizeof(mp_uint_t) - 1) & (~(sizeof(mp_uint_t) - 1))); /* align ip */ \
     void *ptr = (void*)*(mp_uint_t*)ip; \
     ip += sizeof(mp_uint_t)
+
+#endif
+
 #define PUSH(val) *++sp = (val)
 #define POP() (*sp--)
 #define TOP() (*sp)
@@ -1280,8 +1295,14 @@
             if (mp_obj_is_exception_instance(nlr.ret_val) && nlr.ret_val != &mp_const_GeneratorExit_obj && nlr.ret_val != &mp_const_MemoryError_obj) {
                 const byte *ip = code_state->code_info;
                 mp_uint_t code_info_size = mp_decode_uint(&ip);
+                #if MICROPY_PERSISTENT_CODE
+                qstr block_name = ip[0] | (ip[1] << 8);
+                qstr source_file = ip[2] | (ip[3] << 8);
+                ip += 4;
+                #else
                 qstr block_name = mp_decode_uint(&ip);
                 qstr source_file = mp_decode_uint(&ip);
+                #endif
                 mp_uint_t bc = code_state->ip - code_state->code_info - code_info_size;
                 mp_uint_t source_line = 1;
                 mp_uint_t c;