Browse Source

Merge pull request #1152 from svaarala/more-varint-initdata

Use varuint encoding for more initdata fields
pull/1134/head
Sami Vaarala 8 years ago
committed by GitHub
parent
commit
6ad71abb1c
  1. 2
      RELEASES.rst
  2. 6
      debugger/duk_classnames.yaml
  3. 18
      src-input/duk_hobject.h
  4. 6
      src-input/duk_hobject_class.c
  5. 46
      src-input/duk_hthread_builtins.c
  6. 25
      src-input/duk_util_bitdecoder.c
  7. 4
      tests/api/test-dump-load-basic.c
  8. 43
      tools/dukutil.py
  9. 58
      tools/genbuiltins.py

2
RELEASES.rst

@ -2013,7 +2013,7 @@ Planned
* Add an fmod() self test (GH-1108)
* Reduce RAM built-ins initdata limitations for custom bindings by using a
shared varuint encoding in the bit-packed initdata stream (GH-1151)
shared varuint encoding in the bit-packed initdata stream (GH-1151, GH-1152)
* Fix JSON stringify fastpath handling of array gaps in JX and JC; they
incorrectly stringified as 'null' (like in JSON) instead of 'undefined'

6
debugger/duk_classnames.yaml

@ -1,16 +1,16 @@
# Must match C header.
class_names:
- none
- Arguments
- Object
- Array
- Function
- Arguments
- Boolean
- Date
- Error
- Function
- JSON
- Math
- Number
- Object
- RegExp
- String
- global

18
src-input/duk_hobject.h

@ -79,16 +79,16 @@
/* E5 Section 8.6.2 + custom classes */
#define DUK_HOBJECT_CLASS_NONE 0
#define DUK_HOBJECT_CLASS_ARGUMENTS 1
#define DUK_HOBJECT_CLASS_OBJECT 1
#define DUK_HOBJECT_CLASS_ARRAY 2
#define DUK_HOBJECT_CLASS_BOOLEAN 3
#define DUK_HOBJECT_CLASS_DATE 4
#define DUK_HOBJECT_CLASS_ERROR 5
#define DUK_HOBJECT_CLASS_FUNCTION 6
#define DUK_HOBJECT_CLASS_JSON 7
#define DUK_HOBJECT_CLASS_MATH 8
#define DUK_HOBJECT_CLASS_NUMBER 9
#define DUK_HOBJECT_CLASS_OBJECT 10
#define DUK_HOBJECT_CLASS_FUNCTION 3
#define DUK_HOBJECT_CLASS_ARGUMENTS 4
#define DUK_HOBJECT_CLASS_BOOLEAN 5
#define DUK_HOBJECT_CLASS_DATE 6
#define DUK_HOBJECT_CLASS_ERROR 7
#define DUK_HOBJECT_CLASS_JSON 8
#define DUK_HOBJECT_CLASS_MATH 9
#define DUK_HOBJECT_CLASS_NUMBER 10
#define DUK_HOBJECT_CLASS_REGEXP 11
#define DUK_HOBJECT_CLASS_STRING 12
#define DUK_HOBJECT_CLASS_GLOBAL 13

6
src-input/duk_hobject_class.c

@ -95,16 +95,16 @@
/* Note: assumes that these string indexes are 8-bit, genstrings.py must ensure that */
DUK_INTERNAL duk_uint8_t duk_class_number_to_stridx[32] = {
DUK_STRIDX_EMPTY_STRING, /* NONE, intentionally empty */
DUK_STRIDX_UC_ARGUMENTS,
DUK_STRIDX_UC_OBJECT,
DUK_STRIDX_ARRAY,
DUK_STRIDX_UC_FUNCTION,
DUK_STRIDX_UC_ARGUMENTS,
DUK_STRIDX_UC_BOOLEAN,
DUK_STRIDX_DATE,
DUK_STRIDX_UC_ERROR,
DUK_STRIDX_UC_FUNCTION,
DUK_STRIDX_JSON,
DUK_STRIDX_MATH,
DUK_STRIDX_UC_NUMBER,
DUK_STRIDX_UC_OBJECT,
DUK_STRIDX_REG_EXP,
DUK_STRIDX_UC_STRING,
DUK_STRIDX_GLOBAL,

46
src-input/duk_hthread_builtins.c

@ -10,19 +10,12 @@
* Encoding constants, must match genbuiltins.py
*/
#define DUK__CLASS_BITS 5
#define DUK__BIDX_BITS 7
#define DUK__STRIDX_BITS 9 /* XXX: try to optimize to 8 (would now be possible, <200 used) */
#define DUK__NATIDX_BITS 8
#define DUK__PROP_FLAGS_BITS 3
#define DUK__LENGTH_PROP_BITS 3
#define DUK__NARGS_BITS 3
#define DUK__PROP_TYPE_BITS 3
#define DUK__NARGS_VARARGS_MARKER 0x07
#define DUK__NO_CLASS_MARKER 0x00 /* 0 = DUK_HOBJECT_CLASS_NONE */
#define DUK__NO_BIDX_MARKER 0x7f
#define DUK__NO_STRIDX_MARKER 0xff
#define DUK__PROP_TYPE_DOUBLE 0
#define DUK__PROP_TYPE_STRING 1
@ -161,7 +154,7 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
DUK_LOCAL void duk__push_stridx(duk_context *ctx, duk_bitdecoder_ctx *bd) {
duk_small_uint_t n;
n = (duk_small_uint_t) duk_bd_decode(bd, DUK__STRIDX_BITS);
n = (duk_small_uint_t) duk_bd_decode_varuint(bd);
DUK_ASSERT_DISABLE(n >= 0); /* unsigned */
DUK_ASSERT(n < DUK_HEAP_NUM_STRINGS);
duk_push_hstring_stridx(ctx, n);
@ -177,10 +170,15 @@ DUK_LOCAL void duk__push_string(duk_context *ctx, duk_bitdecoder_ctx *bd) {
duk_push_lstring(ctx, (const char *) tmp, (duk_size_t) len);
}
DUK_LOCAL void duk__push_stridx_or_string(duk_context *ctx, duk_bitdecoder_ctx *bd) {
if (duk_bd_decode_flag(bd)) {
duk_small_uint_t n;
n = (duk_small_uint_t) duk_bd_decode_varuint(bd);
if (n == 0) {
duk__push_string(ctx, bd);
} else {
duk__push_stridx(ctx, bd);
n--;
DUK_ASSERT(n < DUK_HEAP_NUM_STRINGS);
duk_push_hstring_stridx(ctx, n);
}
}
DUK_LOCAL void duk__push_double(duk_context *ctx, duk_bitdecoder_ctx *bd) {
@ -231,7 +229,7 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
duk_small_uint_t class_num;
duk_small_int_t len = -1; /* must be signed */
class_num = (duk_small_uint_t) duk_bd_decode(bd, DUK__CLASS_BITS);
class_num = (duk_small_uint_t) duk_bd_decode_varuint(bd);
len = (duk_small_int_t) duk_bd_decode_flagged(bd, DUK__LENGTH_PROP_BITS, (duk_int32_t) -1 /*def_value*/);
if (class_num == DUK_HOBJECT_CLASS_FUNCTION) {
@ -243,7 +241,7 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
DUK_DDD(DUK_DDDPRINT("len=%ld", (long) len));
DUK_ASSERT(len >= 0);
natidx = (duk_small_uint_t) duk_bd_decode(bd, DUK__NATIDX_BITS);
natidx = (duk_small_uint_t) duk_bd_decode_varuint(bd);
DUK_ASSERT(natidx != 0);
c_func = duk_bi_native_functions[natidx];
DUK_ASSERT(c_func != NULL);
@ -373,30 +371,33 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
DUK_DDD(DUK_DDDPRINT("initializing built-in object at index %ld", (long) i));
h = duk_known_hobject(ctx, i);
t = (duk_small_uint_t) duk_bd_decode(bd, DUK__BIDX_BITS);
if (t != DUK__NO_BIDX_MARKER) {
t = (duk_small_uint_t) duk_bd_decode_varuint(bd);
if (t > 0) {
t--;
DUK_DDD(DUK_DDDPRINT("set internal prototype: built-in %ld", (long) t));
DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, duk_known_hobject(ctx, t));
}
t = (duk_small_uint_t) duk_bd_decode(bd, DUK__BIDX_BITS);
if (t != DUK__NO_BIDX_MARKER) {
t = (duk_small_uint_t) duk_bd_decode_varuint(bd);
if (t > 0) {
/* 'prototype' property for all built-in objects (which have it) has attributes:
* [[Writable]] = false,
* [[Enumerable]] = false,
* [[Configurable]] = false
*/
t--;
DUK_DDD(DUK_DDDPRINT("set external prototype: built-in %ld", (long) t));
duk_xdef_prop_stridx_builtin(ctx, i, DUK_STRIDX_PROTOTYPE, t, DUK_PROPDESC_FLAGS_NONE);
}
t = (duk_small_uint_t) duk_bd_decode(bd, DUK__BIDX_BITS);
if (t != DUK__NO_BIDX_MARKER) {
t = (duk_small_uint_t) duk_bd_decode_varuint(bd);
if (t > 0) {
/* 'constructor' property for all built-in objects (which have it) has attributes:
* [[Writable]] = true,
* [[Enumerable]] = false,
* [[Configurable]] = true
*/
t--;
DUK_DDD(DUK_DDDPRINT("set external constructor: built-in %ld", (long) t));
duk_xdef_prop_stridx_builtin(ctx, i, DUK_STRIDX_CONSTRUCTOR, t, DUK_PROPDESC_FLAGS_WC);
}
@ -455,8 +456,7 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
case DUK__PROP_TYPE_BUILTIN: {
duk_small_uint_t bidx;
bidx = (duk_small_uint_t) duk_bd_decode(bd, DUK__BIDX_BITS);
DUK_ASSERT(bidx != DUK__NO_BIDX_MARKER);
bidx = (duk_small_uint_t) duk_bd_decode_varuint(bd);
duk_dup(ctx, (duk_idx_t) bidx);
break;
}
@ -473,8 +473,8 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
break;
}
case DUK__PROP_TYPE_ACCESSOR: {
duk_small_uint_t natidx_getter = (duk_small_uint_t) duk_bd_decode(bd, DUK__NATIDX_BITS);
duk_small_uint_t natidx_setter = (duk_small_uint_t) duk_bd_decode(bd, DUK__NATIDX_BITS);
duk_small_uint_t natidx_getter = (duk_small_uint_t) duk_bd_decode_varuint(bd);
duk_small_uint_t natidx_setter = (duk_small_uint_t) duk_bd_decode_varuint(bd);
duk_small_uint_t accessor_magic = (duk_small_uint_t) duk_bd_decode_varuint(bd);
duk_c_function c_func_getter;
duk_c_function c_func_setter;
@ -530,7 +530,7 @@ DUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {
duk__push_stridx_or_string(ctx, bd);
h_key = duk_known_hstring(ctx, -1);
DUK_UNREF(h_key);
natidx = (duk_small_uint_t) duk_bd_decode(bd, DUK__NATIDX_BITS);
natidx = (duk_small_uint_t) duk_bd_decode_varuint(bd);
c_length = (duk_small_uint_t) duk_bd_decode(bd, DUK__LENGTH_PROP_BITS);
c_nargs = (duk_int_t) duk_bd_decode_flagged(bd, DUK__NARGS_BITS, (duk_int32_t) c_length /*def_value*/);

25
src-input/duk_util_bitdecoder.c

@ -73,21 +73,22 @@ DUK_INTERNAL duk_uint32_t duk_bd_decode_flagged(duk_bitdecoder_ctx *ctx, duk_sma
DUK_INTERNAL duk_uint32_t duk_bd_decode_varuint(duk_bitdecoder_ctx *ctx) {
duk_small_uint_t t;
/* Numbers 0-3 dominate input heavily, so use an initial flag byte for
* them, encoding into 3 bits. Other numbers are most often in [4,63]
* so encode that range efficiently with 7 bits. Reserve a few special
* values for rare long encodings.
/* The bit encoding choices here are based on manual testing against
* the actual varuints generated by genbuiltins.py.
*/
if (duk_bd_decode_flag(ctx)) {
t = duk_bd_decode(ctx, 6);
switch (duk_bd_decode(ctx, 2)) {
case 0:
return 0; /* [0,0] */
case 1:
return duk_bd_decode(ctx, 2) + 1; /* [1,4] */
case 2:
return duk_bd_decode(ctx, 5) + 5; /* [5,36] */
default:
t = duk_bd_decode(ctx, 7);
if (t == 0) {
return duk_bd_decode(ctx, 16);
} else if (t == 1) {
return duk_bd_decode(ctx, 32);
return duk_bd_decode(ctx, 20);
}
return (t - 2) + 4; /* Covers [4,65] */
} else {
return duk_bd_decode(ctx, 2);
return (t - 1) + 37; /* [37,163] */
}
}

4
tests/api/test-dump-load-basic.c

@ -40,7 +40,7 @@
/*===
*** test_basic (duk_safe_call)
dump result type: 7
ff000000000e0000000300000001000900000000000100000001300009800000000600000199000103020000049c00040500000505ae8001070380020803000502b00005040000020502000103b000010000000000a100000000057072696e74000000000568656c6c6f0140091eb851eb851f000000030000000000000000000300020000000100000001300c088001000234000200a1000000a2000000020000000561646465720000000f66616b6546696c656e616d652e6a730000000d03000000010000000c000000000000000178000000000000000179000000010000000000000001780000000179000000000000000000000006676c6f62616c0000000f66616b6546696c656e616d652e6a730000000e0e000000010000000c00000000000000000000000000
ff000000000e0000000300000001000900000000000100000001180009800000000600000199000103020000049c00040500000505ae8001070380020803000502b00005040000020502000103b000010000000000a100000000057072696e74000000000568656c6c6f0140091eb851eb851f000000030000000000000000000300020000000100000001180c088001000234000200a1000000a2000000020000000561646465720000000f66616b6546696c656e616d652e6a730000000d03000000010000000c000000000000000178000000000000000179000000010000000000000001780000000179000000000000000000000006676c6f62616c0000000f66616b6546696c656e616d652e6a730000000e0e000000010000000c00000000000000000000000000
load result type: 6
hello 3 3.14
call result type: 1
@ -93,7 +93,7 @@ static duk_ret_t test_basic(duk_context *ctx, void *udata) {
/*===
*** test_mandel (duk_safe_call)
Mandelbrot source length: 884
ff000000005a000000100000000000130000000000010000001e300c0980804c0003801c010380640203000000a5800053a0800005a08000030301030e28000e0032800003a080004da000030e7a7ffffaa001030e40000e0e3e010e083a000100a580003ea0800007a080000403001000b400100d0000040e28000e0032800003a0800036a000040e7a7ffffaa000040e40020e0e3e030e073a000200a5800029a0800008a0800005038000090380000a030004060202050e28000e0032800003a0800020a000050e7a7ffffaa009090b3c0a0a0c3c0c0b0e34050e0e2a000e0030800006a009030e3d0a0e0e3c080e0a340c0b0e38070e09347ffff2a002050e2a000e0030800002a00006060280000da007050e2a000e0030800002a000080602800008a009050e2a000e0030800002a0000a0602800003a0000b0602800001a07fffe0a0000200a6000d0f000c0d0e6e00061000000e01b07fffcaa0000100a6000d0e99000d11000e0d106e000f1202001001b0000e01b07fffb3a0000000a6000000a2014004000000000000013ff400000000000001400800000000000001400000000000000000000000012301401000000000000000000000012e01401400000000000000000000012c01402400000000000000000000012d00000000013d00000000047075736800000000057072696e7400000000046a6f696e000000000000000000000000066d616e64656c000000096d616e64656c2e6a73000000285a000000020000001400000013000000210000002880201001008004244108910080844a04201080000000017700000000000000016800000001000000046974657200000002000000016900000003000000016a00000004000000016b000000050000000163000000060000000278300000000700000002793000000008000000027878000000090000000279790000000a000000037878320000000b000000037979320000000c000000046c696e650000000d0000000000000000
ff000000005a000000100000000000130000000000010000001e180c0980804c0003801c010380640203000000a5800053a0800005a08000030301030e28000e0032800003a080004da000030e7a7ffffaa001030e40000e0e3e010e083a000100a580003ea0800007a080000403001000b400100d0000040e28000e0032800003a0800036a000040e7a7ffffaa000040e40020e0e3e030e073a000200a5800029a0800008a0800005038000090380000a030004060202050e28000e0032800003a0800020a000050e7a7ffffaa009090b3c0a0a0c3c0c0b0e34050e0e2a000e0030800006a009030e3d0a0e0e3c080e0a340c0b0e38070e09347ffff2a002050e2a000e0030800002a00006060280000da007050e2a000e0030800002a000080602800008a009050e2a000e0030800002a0000a0602800003a0000b0602800001a07fffe0a0000200a6000d0f000c0d0e6e00061000000e01b07fffcaa0000100a6000d0e99000d11000e0d106e000f1202001001b0000e01b07fffb3a0000000a6000000a2014004000000000000013ff400000000000001400800000000000001400000000000000000000000012301401000000000000000000000012e01401400000000000000000000012c01402400000000000000000000012d00000000013d00000000047075736800000000057072696e7400000000046a6f696e000000000000000000000000066d616e64656c000000096d616e64656c2e6a73000000285a000000020000001400000013000000210000002880201001008004244108910080844a04201080000000017700000000000000016800000001000000046974657200000002000000016900000003000000016a00000004000000016b000000050000000163000000060000000278300000000700000002793000000008000000027878000000090000000279790000000a000000037878320000000b000000037979320000000c000000046c696e650000000d0000000000000000
..........................,,,,,,,,,,,,,,,,,,,,,,,,,.........................
....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................
................,,,,,,,,,,,,,,,,,,,,,,,,,,,---=----,,,,,,,,,,...............

43
tools/dukutil.py

@ -11,12 +11,14 @@ class BitEncoder:
_bits = None
_varuint_dist = None
_varuint_cats = None
_varuint_count = None
_varuint_bits = None
def __init__(self):
self._bits = []
self._varuint_dist = [ 0 ] * 65536
self._varuint_cats = [0] * 5
self._varuint_count = 0
self._varuint_bits = 0
@ -39,24 +41,31 @@ class BitEncoder:
self._varuint_dist[x] += 1
self._varuint_count += 1
if x <= 3:
self.bits(0, 1)
self.bits(x, 2)
self._varuint_bits += 3
elif x <= 65:
self.bits(1, 1)
self.bits(x - 4 + 2, 6)
self._varuint_bits += 7
elif x <= 65535:
self.bits(1, 1)
self.bits(0, 6)
self.bits(x, 16)
self._varuint_bits += 7 + 16
if x == 0:
self.bits(0, 2)
self._varuint_bits += 2
self._varuint_cats[0] += 1
elif x <= 4:
self.bits(1, 2)
self.bits(x - 1, 2)
self._varuint_bits += 2 + 2
self._varuint_cats[1] += 1
elif x <= 36:
self.bits(2, 2)
self.bits(x - 5, 5)
self._varuint_bits += 2 + 5
self._varuint_cats[2] += 1
elif x <= 163:
self.bits(3, 2)
self.bits(x - 37 + 1, 7)
self._varuint_bits += 2 + 7
self._varuint_cats[3] += 1
else:
self.bits(1, 1)
self.bits(1, 6)
self.bits(x, 32)
self._varuint_bits += 7 + 32
self.bits(3, 2)
self.bits(0, 7)
self.bits(x, 20)
self._varuint_bits += 2 + 7 + 20
self._varuint_cats[4] += 1
def getNumBits(self):
"Get current number of encoded bits."

58
tools/genbuiltins.py

@ -1346,19 +1346,12 @@ ACCESSOR_PROPERTY_ATTRIBUTES = 'c'
DEFAULT_DATA_PROPERTY_ATTRIBUTES = 'wc'
# Encoding constants (must match duk_hthread_builtins.c).
CLASS_BITS = 5
BIDX_BITS = 7
STRIDX_BITS = 9 # would be nice to optimize to 8
NATIDX_BITS = 8
PROP_FLAGS_BITS = 3
LENGTH_PROP_BITS = 3
NARGS_BITS = 3
PROP_TYPE_BITS = 3
NARGS_VARARGS_MARKER = 0x07
NO_CLASS_MARKER = 0x00 # 0 = DUK_HOBJECT_CLASS_NONE
NO_BIDX_MARKER = 0x7f
NO_STRIDX_MARKER = 0xff
PROP_TYPE_DOUBLE = 0
PROP_TYPE_STRING = 1
@ -1378,16 +1371,16 @@ PROPDESC_FLAG_ACCESSOR = (1 << 3) # unused now
# Class names, numeric indices must match duk_hobject.h class numbers.
class_names = [
'Unused',
'Arguments',
'Object',
'Array',
'Function',
'Arguments',
'Boolean',
'Date',
'Error',
'Function',
'JSON',
'Math',
'Number',
'Object',
'RegExp',
'String',
'global',
@ -1395,7 +1388,8 @@ class_names = [
'DecEnv',
'Buffer',
'Pointer',
'Thread',
'Thread'
# Remaining class names are not currently needed.
]
class2num = {}
for i,v in enumerate(class_names):
@ -1517,6 +1511,7 @@ def gen_ramstr_initdata_bitpacked(meta):
if be._varuint_count > 0:
logger.debug('Varuint distribution:')
logger.debug(json.dumps(be._varuint_dist[0:1024]))
logger.debug('Varuint encoding categories: %r' % be._varuint_cats)
logger.debug('Varuint efficiency: %f bits/value' % (float(be._varuint_bits) / float(be._varuint_count)))
res = be.getByteString()
@ -1601,22 +1596,20 @@ def encode_property_flags(flags):
def gen_ramobj_initdata_for_object(meta, be, bi, string_to_stridx, natfunc_name_to_natidx, objid_to_bidx):
def _stridx(strval):
stridx = string_to_stridx[strval]
be.bits(stridx, STRIDX_BITS)
be.varuint(stridx)
def _stridx_or_string(strval):
# XXX: could share the built-in strings decoder, would save ~200 bytes.
stridx = string_to_stridx.get(strval)
if stridx is not None:
be.bits(0, 1) # marker: stridx
be.bits(stridx, STRIDX_BITS)
be.varuint(stridx + 1)
else:
be.bits(1, 1) # marker: raw bytes
be.varuint(0)
bitpack_string(be, strval)
def _natidx(native_name):
natidx = natfunc_name_to_natidx[native_name]
be.bits(natidx, NATIDX_BITS)
be.varuint(natidx)
class_num = class_to_number(bi['class'])
be.bits(class_num, CLASS_BITS)
be.varuint(class_num)
props = [x for x in bi['properties']] # clone
@ -1693,53 +1686,53 @@ def gen_ramobj_initdata_for_props(meta, be, bi, string_to_stridx, natfunc_name_t
count_function_props = 0
def _bidx(bi_id):
be.varuint(objid_to_bidx[bi_id])
def _bidx_or_none(bi_id):
if bi_id is None:
be.bits(NO_BIDX_MARKER, BIDX_BITS)
be.varuint(0)
else:
be.bits(objid_to_bidx[bi_id], BIDX_BITS)
be.varuint(objid_to_bidx[bi_id] + 1)
def _stridx(strval):
stridx = string_to_stridx[strval]
be.bits(stridx, STRIDX_BITS)
be.varuint(stridx)
def _stridx_or_string(strval):
# XXX: could share the built-in strings decoder, would save ~200 bytes.
stridx = string_to_stridx.get(strval)
if stridx is not None:
be.bits(0, 1) # marker: stridx
be.bits(stridx, STRIDX_BITS)
be.varuint(stridx + 1)
else:
be.bits(1, 1) # marker: raw bytes
be.varuint(0)
bitpack_string(be, strval)
def _natidx(native_name):
if native_name is None:
natidx = 0 # 0 is NULL in the native functions table, denotes missing function
else:
natidx = natfunc_name_to_natidx[native_name]
be.bits(natidx, NATIDX_BITS)
be.varuint(natidx)
props = [x for x in bi['properties']] # clone
# internal prototype: not an actual property so not in property list
if bi.has_key('internal_prototype'):
_bidx(bi['internal_prototype'])
_bidx_or_none(bi['internal_prototype'])
else:
_bidx(None)
_bidx_or_none(None)
# external prototype: encoded specially, steal from property list
prop_proto = steal_prop(props, 'prototype')
if prop_proto is not None:
assert(prop_proto['value']['type'] == 'object')
assert(prop_proto['attributes'] == '')
_bidx(prop_proto['value']['id'])
_bidx_or_none(prop_proto['value']['id'])
else:
_bidx(None)
_bidx_or_none(None)
# external constructor: encoded specially, steal from property list
prop_constr = steal_prop(props, 'constructor')
if prop_constr is not None:
assert(prop_constr['value']['type'] == 'object')
assert(prop_constr['attributes'] == 'wc')
_bidx(prop_constr['value']['id'])
_bidx_or_none(prop_constr['value']['id'])
else:
_bidx(None)
_bidx_or_none(None)
# name: encoded specially for function objects, so steal and ignore here
if bi['class'] == 'Function':
@ -1982,6 +1975,7 @@ def gen_ramobj_initdata_bitpacked(meta, native_funcs, natfunc_name_to_natidx, do
if be._varuint_count > 0:
logger.debug('varuint distribution:')
logger.debug(json.dumps(be._varuint_dist[0:1024]))
logger.debug('Varuint encoding categories: %r' % be._varuint_cats)
logger.debug('Varuint efficiency: %f bits/value' % (float(be._varuint_bits) / float(be._varuint_count)))
romobj_init_data = be.getByteString()
#logger.debug(repr(romobj_init_data))

Loading…
Cancel
Save