本文整理汇总了Python中pypy.jit.metainterp.warmstate.WarmEnterState类的典型用法代码示例。如果您正苦于以下问题:Python WarmEnterState类的具体用法?Python WarmEnterState怎么用?Python WarmEnterState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WarmEnterState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_make_jitdriver_callbacks_3
def test_make_jitdriver_callbacks_3():
def get_location(x, y):
assert x == 5
assert y == 42.5
return "hi there" # abuse the return type, but nobody checks it
GET_LOCATION = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float], lltype.Ptr(rstr.STR)))
class FakeWarmRunnerDesc:
rtyper = None
cpu = None
memory_manager = None
class FakeJitDriverSD:
jitdriver = None
_green_args_spec = [lltype.Signed, lltype.Float]
_get_printable_location_ptr = llhelper(GET_LOCATION, get_location)
_confirm_enter_jit_ptr = None
_can_never_inline_ptr = None
_get_jitcell_at_ptr = None
_should_unroll_one_iteration_ptr = None
red_args_types = []
state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
state.make_jitdriver_callbacks()
res = state.get_location_str([ConstInt(5), constfloat(42.5)])
assert res == "hi there"
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:27,代码来源:test_warmstate.py
示例2: test_make_jitcell_getter_custom
def test_make_jitcell_getter_custom():
from pypy.rpython.typesystem import LowLevelTypeSystem
class FakeRTyper:
type_system = LowLevelTypeSystem.instance
class FakeJitCell(BaseJitCell):
pass
celldict = {}
def getter(x, y):
return celldict.get((x, y))
def setter(newcell, x, y):
newcell.x = x
newcell.y = y
celldict[x, y] = newcell
GETTER = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float],
llmemory.GCREF))
SETTER = lltype.Ptr(lltype.FuncType([llmemory.GCREF, lltype.Signed,
lltype.Float], lltype.Void))
class FakeWarmRunnerDesc:
rtyper = FakeRTyper()
cpu = None
get_jitcell_at_ptr = llhelper(GETTER, getter)
set_jitcell_at_ptr = llhelper(SETTER, setter)
#
state = WarmEnterState(FakeWarmRunnerDesc())
get_jitcell = state._make_jitcell_getter_custom(FakeJitCell)
cell1 = get_jitcell(5, 42.5)
assert isinstance(cell1, FakeJitCell)
assert cell1.x == 5
assert cell1.y == 42.5
cell2 = get_jitcell(5, 42.5)
assert cell2 is cell1
cell3 = get_jitcell(41, 42.5)
cell4 = get_jitcell(42, 0.25)
assert cell1 is not cell3 is not cell4 is not cell1
开发者ID:alkorzt,项目名称:pypy,代码行数:34,代码来源:test_warmstate.py
示例3: test_make_jitdriver_callbacks_1
def test_make_jitdriver_callbacks_1():
class FakeWarmRunnerDesc:
cpu = None
memory_manager = None
class FakeJitDriverSD:
jitdriver = None
_green_args_spec = [lltype.Signed, lltype.Float]
_get_printable_location_ptr = None
_confirm_enter_jit_ptr = None
_can_never_inline_ptr = None
_should_unroll_one_iteration_ptr = None
red_args_types = []
class FakeCell:
dont_trace_here = False
state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
def jit_getter(build, *args):
return FakeCell()
state.jit_getter = jit_getter
state.make_jitdriver_callbacks()
res = state.get_location_str([ConstInt(5), constfloat(42.5)])
assert res == "(no jitdriver.get_printable_location!)"
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:26,代码来源:test_warmstate.py
示例4: test_make_jitdriver_callbacks_4
def test_make_jitdriver_callbacks_4():
def confirm_enter_jit(x, y, z):
assert x == 5
assert y == 42.5
assert z == 3
return True
ENTER_JIT = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float, lltype.Signed], lltype.Bool))
class FakeWarmRunnerDesc:
rtyper = None
cpu = None
memory_manager = None
class FakeJitDriverSD:
jitdriver = None
_green_args_spec = [lltype.Signed, lltype.Float]
_get_printable_location_ptr = None
_confirm_enter_jit_ptr = llhelper(ENTER_JIT, confirm_enter_jit)
_can_never_inline_ptr = None
_get_jitcell_at_ptr = None
_should_unroll_one_iteration_ptr = None
red_args_types = []
state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
state.make_jitdriver_callbacks()
res = state.confirm_enter_jit(5, 42.5, 3)
assert res is True
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:28,代码来源:test_warmstate.py
示例5: make_enter_function
def make_enter_function(self):
from pypy.jit.metainterp.warmstate import WarmEnterState
state = WarmEnterState(self)
maybe_compile_and_run = state.make_entry_point()
self.state = state
def crash_in_jit(e):
if not we_are_translated():
print "~~~ Crash in JIT!"
print '~~~ %s: %s' % (e.__class__, e)
if sys.stdout == sys.__stdout__:
import pdb; pdb.post_mortem(sys.exc_info()[2])
raise
fatalerror('~~~ Crash in JIT! %s' % (e,), traceback=True)
crash_in_jit._dont_inline_ = True
if self.translator.rtyper.type_system.name == 'lltypesystem':
def maybe_enter_jit(*args):
try:
maybe_compile_and_run(*args)
except JitException:
raise # go through
except Exception, e:
crash_in_jit(e)
maybe_enter_jit._always_inline_ = True
开发者ID:alkorzt,项目名称:pypy,代码行数:25,代码来源:warmspot.py
示例6: test_make_jitdriver_callbacks_5
def test_make_jitdriver_callbacks_5():
def can_never_inline(x, y):
assert x == 5
assert y == 42.5
return True
CAN_NEVER_INLINE = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float], lltype.Bool))
class FakeWarmRunnerDesc:
rtyper = None
cpu = None
memory_manager = None
class FakeJitDriverSD:
jitdriver = None
_green_args_spec = [lltype.Signed, lltype.Float]
_get_printable_location_ptr = None
_confirm_enter_jit_ptr = None
_can_never_inline_ptr = llhelper(CAN_NEVER_INLINE, can_never_inline)
_get_jitcell_at_ptr = None
_should_unroll_one_iteration_ptr = None
red_args_types = []
state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
state.make_jitdriver_callbacks()
res = state.can_never_inline(5, 42.5)
assert res is True
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:27,代码来源:test_warmstate.py
示例7: test_make_unwrap_greenkey
def test_make_unwrap_greenkey():
class FakeJitDriverSD:
_green_args_spec = [lltype.Signed, lltype.Float]
state = WarmEnterState(None, FakeJitDriverSD())
unwrap_greenkey = state.make_unwrap_greenkey()
greenargs = unwrap_greenkey([ConstInt(42), constfloat(42.5)])
assert greenargs == (42, 42.5)
assert type(greenargs[0]) is int
开发者ID:gorakhargosh,项目名称:pypy,代码行数:8,代码来源:test_warmstate.py
示例8: test_make_unwrap_greenkey
def test_make_unwrap_greenkey():
class FakeWarmRunnerDesc:
green_args_spec = [lltype.Signed, lltype.Float]
state = WarmEnterState(FakeWarmRunnerDesc())
unwrap_greenkey = state.make_unwrap_greenkey()
greenargs = unwrap_greenkey([ConstInt(42), ConstFloat(42.5)])
assert greenargs == (42, 42.5)
assert type(greenargs[0]) is int
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_warmstate.py
示例9: test_make_jitcell_getter
def test_make_jitcell_getter():
class FakeWarmRunnerDesc:
green_args_spec = [lltype.Float]
get_jitcell_at_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc())
get_jitcell = state.make_jitcell_getter()
cell1 = get_jitcell(1.75)
cell2 = get_jitcell(1.75)
assert cell1 is cell2
assert get_jitcell is state.make_jitcell_getter()
开发者ID:alkorzt,项目名称:pypy,代码行数:10,代码来源:test_warmstate.py
示例10: test_make_jitdriver_callbacks_1
def test_make_jitdriver_callbacks_1():
class FakeWarmRunnerDesc:
can_inline_ptr = None
get_printable_location_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc())
state.make_jitdriver_callbacks()
res = state.can_inline_callable([BoxInt(5), BoxFloat(42.5)])
assert res is True
res = state.get_location_str([BoxInt(5), BoxFloat(42.5)])
assert res == '(no jitdriver.get_printable_location!)'
开发者ID:enyst,项目名称:plexnet,代码行数:10,代码来源:test_warmstate.py
示例11: test_make_jitcell_getter
def test_make_jitcell_getter():
class FakeJitDriverSD:
_green_args_spec = [lltype.Float]
_get_jitcell_at_ptr = None
state = WarmEnterState(None, FakeJitDriverSD())
get_jitcell = state.make_jitcell_getter()
cell1 = get_jitcell(True, 1.75)
cell2 = get_jitcell(True, 1.75)
assert cell1 is cell2
assert get_jitcell is state.make_jitcell_getter()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:10,代码来源:test_warmstate.py
示例12: test_attach_unoptimized_bridge_from_interp
def test_attach_unoptimized_bridge_from_interp():
class FakeWarmRunnerDesc:
green_args_spec = [lltype.Signed, lltype.Float]
get_jitcell_at_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc())
get_jitcell = state.make_jitcell_getter()
state.attach_unoptimized_bridge_from_interp([BoxInt(5), BoxFloat(2.25)],
"entry loop token")
cell1 = get_jitcell(5, 2.25)
assert cell1.counter < 0
assert cell1.entry_loop_token == "entry loop token"
开发者ID:enyst,项目名称:plexnet,代码行数:11,代码来源:test_warmstate.py
示例13: test_make_jitcell_getter_default
def test_make_jitcell_getter_default():
class FakeJitDriverSD:
_green_args_spec = [lltype.Signed, lltype.Float]
state = WarmEnterState(None, FakeJitDriverSD())
get_jitcell = state._make_jitcell_getter_default()
cell1 = get_jitcell(True, 42, 42.5)
assert isinstance(cell1, JitCell)
cell2 = get_jitcell(True, 42, 42.5)
assert cell1 is cell2
cell3 = get_jitcell(True, 41, 42.5)
assert get_jitcell(False, 42, 0.25) is None
cell4 = get_jitcell(True, 42, 0.25)
assert get_jitcell(False, 42, 0.25) is cell4
assert cell1 is not cell3 is not cell4 is not cell1
开发者ID:gorakhargosh,项目名称:pypy,代码行数:14,代码来源:test_warmstate.py
示例14: test_make_jitcell_getter_default
def test_make_jitcell_getter_default():
class FakeWarmRunnerDesc:
green_args_spec = [lltype.Signed, lltype.Float]
class FakeJitCell(BaseJitCell):
pass
state = WarmEnterState(FakeWarmRunnerDesc())
get_jitcell = state._make_jitcell_getter_default(FakeJitCell)
cell1 = get_jitcell(42, 42.5)
assert isinstance(cell1, FakeJitCell)
cell2 = get_jitcell(42, 42.5)
assert cell1 is cell2
cell3 = get_jitcell(41, 42.5)
cell4 = get_jitcell(42, 0.25)
assert cell1 is not cell3 is not cell4 is not cell1
开发者ID:alkorzt,项目名称:pypy,代码行数:14,代码来源:test_warmstate.py
示例15: test_attach_unoptimized_bridge_from_interp
def test_attach_unoptimized_bridge_from_interp():
class FakeJitDriverSD:
_green_args_spec = [lltype.Signed, lltype.Float]
_get_jitcell_at_ptr = None
state = WarmEnterState(None, FakeJitDriverSD())
get_jitcell = state.make_jitcell_getter()
class FakeLoopToken(object):
pass
looptoken = FakeLoopToken()
state.attach_unoptimized_bridge_from_interp([ConstInt(5),
constfloat(2.25)],
looptoken)
cell1 = get_jitcell(True, 5, 2.25)
assert cell1.counter < 0
assert cell1.get_entry_loop_token() is looptoken
开发者ID:gorakhargosh,项目名称:pypy,代码行数:15,代码来源:test_warmstate.py
示例16: test_make_jitdriver_callbacks_2
def test_make_jitdriver_callbacks_2():
def can_inline(x, y):
assert x == 5
assert y == 42.5
return False
CAN_INLINE = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float],
lltype.Bool))
class FakeWarmRunnerDesc:
rtyper = None
green_args_spec = [lltype.Signed, lltype.Float]
can_inline_ptr = llhelper(CAN_INLINE, can_inline)
get_printable_location_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc())
state.make_jitdriver_callbacks()
res = state.can_inline_callable([BoxInt(5), BoxFloat(42.5)])
assert res is False
开发者ID:enyst,项目名称:plexnet,代码行数:16,代码来源:test_warmstate.py
示例17: test_make_jitdriver_callbacks_3
def test_make_jitdriver_callbacks_3():
def get_location(x, y):
assert x == 5
assert y == 42.5
return "hi there" # abuse the return type, but nobody checks it
GET_LOCATION = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float],
lltype.Ptr(rstr.STR)))
class FakeWarmRunnerDesc:
rtyper = None
green_args_spec = [lltype.Signed, lltype.Float]
can_inline_ptr = None
get_printable_location_ptr = llhelper(GET_LOCATION, get_location)
state = WarmEnterState(FakeWarmRunnerDesc())
state.make_jitdriver_callbacks()
res = state.get_location_str([BoxInt(5), BoxFloat(42.5)])
assert res == "hi there"
开发者ID:enyst,项目名称:plexnet,代码行数:16,代码来源:test_warmstate.py
示例18: test_make_jitdriver_callbacks_4
def test_make_jitdriver_callbacks_4():
def confirm_enter_jit(x, y, z):
assert x == 5
assert y == 42.5
assert z == 3
return True
ENTER_JIT = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float,
lltype.Signed], lltype.Bool))
class FakeWarmRunnerDesc:
rtyper = None
green_args_spec = [lltype.Signed, lltype.Float]
can_inline_ptr = None
get_printable_location_ptr = None
confirm_enter_jit_ptr = llhelper(ENTER_JIT, confirm_enter_jit)
get_jitcell_at_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc())
state.make_jitdriver_callbacks()
res = state.confirm_enter_jit(5, 42.5, 3)
assert res is True
开发者ID:alkorzt,项目名称:pypy,代码行数:20,代码来源:test_warmstate.py
示例19: test_make_set_future_values
def test_make_set_future_values():
future_values = {}
class FakeCPU:
def set_future_value_int(self, j, value):
future_values[j] = "int", value
def set_future_value_float(self, j, value):
future_values[j] = "float", value
class FakeWarmRunnerDesc:
cpu = FakeCPU()
red_args_types = ["int", "float"]
class metainterp_sd:
virtualizable_info = None
#
state = WarmEnterState(FakeWarmRunnerDesc())
set_future_values = state.make_set_future_values()
set_future_values(5, 42.5)
assert future_values == {
0: ("int", 5),
1: ("float", 42.5),
}
assert set_future_values is state.make_set_future_values()
开发者ID:alkorzt,项目名称:pypy,代码行数:21,代码来源:test_warmstate.py
示例20: test_make_jitdriver_callbacks_2
def test_make_jitdriver_callbacks_2():
def can_inline(x, y):
assert x == 5
assert y == 42.5
return False
CAN_INLINE = lltype.Ptr(lltype.FuncType([lltype.Signed, lltype.Float],
lltype.Bool))
class FakeCell:
dont_trace_here = False
class FakeWarmRunnerDesc:
rtyper = None
green_args_spec = [lltype.Signed, lltype.Float]
can_inline_ptr = llhelper(CAN_INLINE, can_inline)
get_printable_location_ptr = None
confirm_enter_jit_ptr = None
state = WarmEnterState(FakeWarmRunnerDesc())
def jit_getter(*args):
return FakeCell()
state.jit_getter = jit_getter
state.make_jitdriver_callbacks()
res = state.can_inline_callable([ConstInt(5), ConstFloat(42.5)])
assert res is False
开发者ID:alkorzt,项目名称:pypy,代码行数:22,代码来源:test_warmstate.py
注:本文中的pypy.jit.metainterp.warmstate.WarmEnterState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论