本文整理匯總了Python中rpython.rtyper.annlowlevel.MixLevelHelperAnnotator.graph2delayed方法的典型用法代碼示例。如果您正苦於以下問題:Python MixLevelHelperAnnotator.graph2delayed方法的具體用法?Python MixLevelHelperAnnotator.graph2delayed怎麽用?Python MixLevelHelperAnnotator.graph2delayed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpython.rtyper.annlowlevel.MixLevelHelperAnnotator
的用法示例。
在下文中一共展示了MixLevelHelperAnnotator.graph2delayed方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _setup_frame_realloc
# 需要導入模塊: from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator [as 別名]
# 或者: from rpython.rtyper.annlowlevel.MixLevelHelperAnnotator import graph2delayed [as 別名]
def _setup_frame_realloc(self, translate_support_code):
FUNC_TP = lltype.Ptr(lltype.FuncType([llmemory.GCREF, lltype.Signed],
llmemory.GCREF))
base_ofs = self.get_baseofs_of_frame_field()
def realloc_frame(frame, size):
try:
if not we_are_translated():
assert not self._exception_emulator[0]
frame = lltype.cast_opaque_ptr(jitframe.JITFRAMEPTR, frame)
if size > frame.jf_frame_info.jfi_frame_depth:
# update the frame_info size, which is for whatever reason
# not up to date
frame.jf_frame_info.update_frame_depth(base_ofs, size)
new_frame = jitframe.JITFRAME.allocate(frame.jf_frame_info)
frame.jf_forward = new_frame
i = 0
while i < len(frame.jf_frame):
new_frame.jf_frame[i] = frame.jf_frame[i]
frame.jf_frame[i] = 0
i += 1
new_frame.jf_savedata = frame.jf_savedata
new_frame.jf_guard_exc = frame.jf_guard_exc
# all other fields are empty
llop.gc_writebarrier(lltype.Void, new_frame)
return lltype.cast_opaque_ptr(llmemory.GCREF, new_frame)
except Exception as e:
print "Unhandled exception", e, "in realloc_frame"
return lltype.nullptr(llmemory.GCREF.TO)
def realloc_frame_crash(frame, size):
print "frame", frame, "size", size
return lltype.nullptr(llmemory.GCREF.TO)
if not translate_support_code:
fptr = llhelper(FUNC_TP, realloc_frame)
else:
FUNC = FUNC_TP.TO
args_s = [lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
s_result = lltype_to_annotation(FUNC.RESULT)
mixlevelann = MixLevelHelperAnnotator(self.rtyper)
graph = mixlevelann.getgraph(realloc_frame, args_s, s_result)
fptr = mixlevelann.graph2delayed(graph, FUNC)
mixlevelann.finish()
self.realloc_frame = heaptracker.adr2int(llmemory.cast_ptr_to_adr(fptr))
if not translate_support_code:
fptr = llhelper(FUNC_TP, realloc_frame_crash)
else:
FUNC = FUNC_TP.TO
args_s = [lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
s_result = lltype_to_annotation(FUNC.RESULT)
mixlevelann = MixLevelHelperAnnotator(self.rtyper)
graph = mixlevelann.getgraph(realloc_frame_crash, args_s, s_result)
fptr = mixlevelann.graph2delayed(graph, FUNC)
mixlevelann.finish()
self.realloc_frame_crash = heaptracker.adr2int(llmemory.cast_ptr_to_adr(fptr))
示例2: BaseGCTransformer
# 需要導入模塊: from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator [as 別名]
# 或者: from rpython.rtyper.annlowlevel.MixLevelHelperAnnotator import graph2delayed [as 別名]
#.........這裏部分代碼省略.........
self.push_alive(var, llops)
if llops:
if link.prevblock.exitswitch is None:
link.prevblock.operations.extend(llops)
else:
insert_empty_block(link, llops)
# remove the empty block at the start of the graph, which should
# still be empty (but let's check)
if starts_with_empty_block(graph) and inserted_empty_startblock:
old_startblock = graph.startblock
graph.startblock = graph.startblock.exits[0].target
checkgraph(graph)
self.links_to_split = None
v = Variable('vanishing_exc_value')
v.concretetype = self.get_lltype_of_exception_value()
llops = LowLevelOpList()
self.pop_alive(v, llops)
graph.exc_cleanup = (v, list(llops))
return is_borrowed # xxx for tests only
def annotate_helper(self, ll_helper, ll_args, ll_result, inline=False):
assert not self.finished_helpers
args_s = map(lltype_to_annotation, ll_args)
s_result = lltype_to_annotation(ll_result)
graph = self.mixlevelannotator.getgraph(ll_helper, args_s, s_result)
# the produced graphs does not need to be fully transformed
self.need_minimal_transform(graph)
if inline:
self.graphs_to_inline[graph] = True
FUNCTYPE = lltype.FuncType(ll_args, ll_result)
return self.mixlevelannotator.graph2delayed(graph, FUNCTYPE=FUNCTYPE)
def inittime_helper(self, ll_helper, ll_args, ll_result, inline=True):
ptr = self.annotate_helper(ll_helper, ll_args, ll_result, inline=inline)
return Constant(ptr, lltype.typeOf(ptr))
def annotate_finalizer(self, ll_finalizer, ll_args, ll_result):
fptr = self.annotate_helper(ll_finalizer, ll_args, ll_result)
self.ll_finalizers_ptrs.append(fptr)
return fptr
def finish_helpers(self, backendopt=True):
if self.translator is not None:
self.mixlevelannotator.finish_annotate()
if self.translator is not None:
self.mixlevelannotator.finish_rtype()
if backendopt:
self.mixlevelannotator.backend_optimize()
self.finished_helpers = True
# Make sure that the database also sees all finalizers now.
# It is likely that the finalizers need special support there
newgcdependencies = self.ll_finalizers_ptrs
return newgcdependencies
def get_finish_helpers(self):
return self.finish_helpers
def finish_tables(self):
pass
def get_finish_tables(self):
return self.finish_tables
示例3: WarmRunnerDesc
# 需要導入模塊: from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator [as 別名]
# 或者: from rpython.rtyper.annlowlevel.MixLevelHelperAnnotator import graph2delayed [as 別名]
#.........這裏部分代碼省略.........
types = jd.jitdriver.get_location._loc_types
del jd.jitdriver.get_location._loc_types
#
for _,type in types:
if type == 's':
items.append(annmodel.SomeString())
elif type == 'i':
items.append(annmodel.SomeInteger())
else:
raise NotImplementedError
s_Tuple = annmodel.SomeTuple(items)
jd._get_location_ptr = self._make_hook_graph(jd,
annhelper, jd.jitdriver.get_location, s_Tuple)
jd._get_loc_types = types
annhelper.finish()
def _make_hook_graph(self, jitdriver_sd, annhelper, func,
s_result, s_first_arg=None, onlygreens=True):
if func is None:
return None
#
if not onlygreens:
assert not jitdriver_sd.jitdriver.autoreds, (
"reds='auto' is not compatible with JitDriver hooks such as "
"confirm_enter_jit")
extra_args_s = []
if s_first_arg is not None:
extra_args_s.append(s_first_arg)
#
args_s = jitdriver_sd._portal_args_s
if onlygreens:
args_s = args_s[:len(jitdriver_sd._green_args_spec)]
graph = annhelper.getgraph(func, extra_args_s + args_s, s_result)
funcptr = annhelper.graph2delayed(graph)
return funcptr
def make_args_specifications(self):
for jd in self.jitdrivers_sd:
self.make_args_specification(jd)
def make_args_specification(self, jd):
graph = jd._jit_merge_point_in
_, _, op = locate_jit_merge_point(graph)
greens_v, reds_v = support.decode_hp_hint_args(op)
ALLARGS = [v.concretetype for v in (greens_v + reds_v)]
jd._green_args_spec = [v.concretetype for v in greens_v]
jd.red_args_types = [history.getkind(v.concretetype) for v in reds_v]
jd.num_green_args = len(jd._green_args_spec)
jd.num_red_args = len(jd.red_args_types)
RESTYPE = graph.getreturnvar().concretetype
(jd._JIT_ENTER_FUNCTYPE,
jd._PTR_JIT_ENTER_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, lltype.Void)
(jd._PORTAL_FUNCTYPE,
jd._PTR_PORTAL_FUNCTYPE) = self.cpu.ts.get_FuncType(ALLARGS, RESTYPE)
#
if jd.result_type == 'v':
ASMRESTYPE = lltype.Void
elif jd.result_type == history.INT:
ASMRESTYPE = lltype.Signed
elif jd.result_type == history.REF:
ASMRESTYPE = llmemory.GCREF
elif jd.result_type == history.FLOAT:
ASMRESTYPE = lltype.Float
else:
assert False
(_, jd._PTR_ASSEMBLER_HELPER_FUNCTYPE) = self.cpu.ts.get_FuncType(