Skip to content

Instantly share code, notes, and snippets.

@mattip
Created August 31, 2018 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattip/057554dd7eba64f8cbf2bc1a70c1c6eb to your computer and use it in GitHub Desktop.
Save mattip/057554dd7eba64f8cbf2bc1a70c1c6eb to your computer and use it in GitHub Desktop.
Translation Problem
[Timer] Timings:
[Timer] annotate --- 267.9 s
[Timer] rtype_lltype --- 548.2 s
[Timer] pyjitpl_lltype --- 81.2 s
[Timer] ==========================================
[Timer] Total: --- 897.4 s
[translation:info] Error:
File "/home/matti/pypy_stuff/pypy_35/rpython/translator/goal/translate.py", line 318, in main
drv.proceed(goals)
File "/home/matti/pypy_stuff/pypy_35/rpython/translator/driver.py", line 554, in proceed
result = self._execute(goals, task_skip = self._maybe_skip())
File "/home/matti/pypy_stuff/pypy_35/rpython/translator/tool/taskengine.py", line 114, in _execute
res = self._do(goal, taskcallable, *args, **kwds)
File "/home/matti/pypy_stuff/pypy_35/rpython/translator/driver.py", line 278, in _do
res = func()
File "/home/matti/pypy_stuff/pypy_35/rpython/translator/driver.py", line 361, in task_pyjitpl_lltype
backend_name=self.config.translation.jit_backend, inline=True)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/metainterp/warmspot.py", line 49, in apply_jit
**kwds)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/metainterp/warmspot.py", line 280, in __init__
jitcodes = self.codewriter.make_jitcodes(verbose=verbose)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/codewriter.py", line 73, in make_jitcodes
self.transform_graph_to_jitcode(graph, jitcode, verbose, len(all_jitcodes))
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/codewriter.py", line 40, in transform_graph_to_jitcode
transform_graph(graph, self.cpu, self.callcontrol, portal_jd)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/jtransform.py", line 31, in transform_graph
t.transform(graph)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/jtransform.py", line 72, in transform
self.optimize_block(block)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/jtransform.py", line 96, in optimize_block
oplist = self.rewrite_operation(op)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/jtransform.py", line 242, in rewrite_operation
return rewrite(self, op)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/jtransform.py", line 374, in rewrite_op_direct_call
return getattr(self, 'handle_%s_call' % kind)(op)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/jtransform.py", line 432, in handle_residual_call
calling_graph=self.graph)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/call.py", line 317, in getcalldescr
extradescr, self.collect_analyzer.analyze(op, self.seen_gc),
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/effectinfo.py", line 352, in effectinfo_from_writeanalyze
add_array(write_descrs_arrays, tup)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/effectinfo.py", line 309, in add_array
descr = cpu.arraydescrof(ARRAY)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/backend/llsupport/llmodel.py", line 372, in arraydescrof
return get_array_descr(self.gc_ll_descr, A)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/backend/llsupport/descr.py", line 373, in get_array_descr
ARRAY_INSIDE, get_field_descr=get_interiorfield_descr)
File "/home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/heaptracker.py", line 111, in all_interiorfielddescrs
raise UnsupportedFieldExc("unexpected array(struct(struct))")
[translation:ERROR] UnsupportedFieldExc: unexpected array(struct(struct))
[translation] start debugger...
> /home/matti/pypy_stuff/pypy_35/rpython/jit/codewriter/heaptracker.py(111)all_interiorfielddescrs()
-> raise UnsupportedFieldExc("unexpected array(struct(struct))")
(Pdb+) l
106 if FIELD is lltype.Void:
107 continue
108 if name == 'typeptr':
109 continue # dealt otherwise
110 elif isinstance(FIELD, lltype.Struct):
111 -> raise UnsupportedFieldExc("unexpected array(struct(struct))")
112 res.append(get_field_descr(gccache, ARRAY, name))
113 return res
114
115 def gc_fielddescrs(gccache, STRUCT):
116 return all_fielddescrs(gccache, STRUCT, True)
(Pdb+) up
> /home/matti/pypy_stuff/pypy_35/rpython/jit/backend/llsupport/descr.py(373)get_array_descr()
-> ARRAY_INSIDE, get_field_descr=get_interiorfield_descr)
(Pdb+) l
368 # for single float -> leads to problems
369 arraydescr = ArrayDescr(basesize, itemsize, lendescr, flag, is_pure, concrete_type='f')
370 cache[ARRAY_OR_STRUCT] = arraydescr
371 if isinstance(ARRAY_INSIDE.OF, lltype.Struct):
372 descrs = heaptracker.all_interiorfielddescrs(gccache,
373 -> ARRAY_INSIDE, get_field_descr=get_interiorfield_descr)
374 arraydescr.all_interiorfielddescrs = descrs
375 if ARRAY_OR_STRUCT._gckind == 'gc':
376 gccache.init_array_descr(ARRAY_OR_STRUCT, arraydescr)
377 return arraydescr
378
(Pdb+) p ARRAY_OR_STRUCT
<GcArray of utf8_loc_elem { baseindex: Signed, ofs: FixedSizeArray of 16 Char } >
def _get_index_storage(self):
# XXX write the correct jit.elidable
if self._index_storage == rutf8.null_storage():
storage = rutf8.create_utf8_index_storage(self._utf8, self._length)
else:
storage = self._index_storage
if not jit.isconstant(self):
self._index_storage = storage
return storage
UTF8_INDEX_STORAGE = lltype.GcArray(lltype.Struct('utf8_loc_elem',
('baseindex', lltype.Signed),
('ofs', lltype.FixedSizeArray(lltype.Char, 16)),
))
def null_storage():
return lltype.nullptr(UTF8_INDEX_STORAGE)
def create_utf8_index_storage(utf8, utf8len):
""" Create an index storage which stores index of each 4th character
in utf8 encoded unicode string.
"""
# if len(utf8) == utf8len < ASCII_INDEX_STORAGE_BLOCKS * 64:
# return ASCII_INDEX_STORAGE
arraysize = utf8len // 64 + 1
storage = lltype.malloc(UTF8_INDEX_STORAGE, arraysize)
baseindex = 0
current = 0
while True:
storage[current].baseindex = baseindex
next = baseindex
for i in range(16):
if utf8len == 0:
next += 1 # assume there is an extra '\x00' character
else:
next = next_codepoint_pos(utf8, next)
storage[current].ofs[i] = chr(next - baseindex)
utf8len -= 4
if utf8len < 0:
assert current + 1 == len(storage)
break
next = next_codepoint_pos(utf8, next)
next = next_codepoint_pos(utf8, next)
next = next_codepoint_pos(utf8, next)
else:
current += 1
baseindex = next
continue
break
return storage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment