• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python longlong.getfloatstorage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.jit.codewriter.longlong.getfloatstorage函数的典型用法代码示例。如果您正苦于以下问题:Python getfloatstorage函数的具体用法?Python getfloatstorage怎么用?Python getfloatstorage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getfloatstorage函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_execute_varargs

def test_execute_varargs():
    cpu = FakeCPU()
    descr = FakeCallDescr()
    argboxes = [BoxInt(99999), BoxInt(321), constfloat(2.25), ConstInt(123),
                BoxPtr(), boxfloat(5.5)]
    box = execute_varargs(cpu, FakeMetaInterp(), rop.CALL, argboxes, descr)
    assert box.getfloat() == 42.5
    assert cpu.fakecalled == (99999, descr, [321, 123],
                              [ConstPtr.value],
                              [longlong.getfloatstorage(2.25),
                               longlong.getfloatstorage(5.5)])
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:11,代码来源:test_executor.py


示例2: test_call_stubs

def test_call_stubs():
    c0 = GcCache(False)
    ARGS = [lltype.Char, lltype.Signed]
    RES = lltype.Char
    descr1 = get_call_descr(c0, ARGS, RES)
    def f(a, b):
        return 'c'

    call_stub = descr1.call_stub
    fnptr = llhelper(lltype.Ptr(lltype.FuncType(ARGS, RES)), f)

    res = call_stub(rffi.cast(lltype.Signed, fnptr), [1, 2], None, None)
    assert res == ord('c')

    ARRAY = lltype.GcArray(lltype.Signed)
    ARGS = [lltype.Float, lltype.Ptr(ARRAY)]
    RES = lltype.Float

    def f(a, b):
        return float(b[0]) + a

    fnptr = llhelper(lltype.Ptr(lltype.FuncType(ARGS, RES)), f)
    descr2 = get_call_descr(c0, ARGS, RES)
    a = lltype.malloc(ARRAY, 3)
    opaquea = lltype.cast_opaque_ptr(llmemory.GCREF, a)
    a[0] = 1
    res = descr2.call_stub(rffi.cast(lltype.Signed, fnptr),
                           [], [opaquea], [longlong.getfloatstorage(3.5)])
    assert longlong.getrealfloat(res) == 4.5
开发者ID:ieure,项目名称:pypy,代码行数:29,代码来源:test_descr.py


示例3: callback

 def callback(asm):
     c = ConstFloat(longlong.getfloatstorage(-42.5))
     loc = self.xrm.convert_to_imm(c)
     asm.mov(loc, xmm5)
     asm.regalloc_push(xmm5)
     asm.regalloc_pop(xmm0)
     asm.mc.CVTTSD2SI(eax, xmm0)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:7,代码来源:test_assembler.py


示例4: test_ResumeDataLoopMemo_other

def test_ResumeDataLoopMemo_other():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    const = ConstFloat(longlong.getfloatstorage(-1.0))
    tagged = memo.getconst(const)
    index, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert memo.consts[index] is const
开发者ID:ieure,项目名称:pypy,代码行数:7,代码来源:test_resume.py


示例5: wrap

def wrap(cpu, value, in_const_box=False):
    if isinstance(lltype.typeOf(value), lltype.Ptr):
        if lltype.typeOf(value).TO._gckind == 'gc':
            value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
            if in_const_box:
                return history.ConstPtr(value)
            else:
                return history.BoxPtr(value)
        else:
            adr = llmemory.cast_ptr_to_adr(value)
            value = heaptracker.adr2int(adr)
            # fall through to the end of the function
    elif isinstance(lltype.typeOf(value), ootype.OOType):
        value = ootype.cast_to_object(value)
        if in_const_box:
            return history.ConstObj(value)
        else:
            return history.BoxObj(value)
    elif isinstance(value, float):
        value = longlong.getfloatstorage(value)
        if in_const_box:
            return history.ConstFloat(value)
        else:
            return history.BoxFloat(value)
    elif isinstance(value, str) or isinstance(value, unicode):
        assert len(value) == 1     # must be a character
        value = ord(value)
    else:
        value = intmask(value)
    if in_const_box:
        return history.ConstInt(value)
    else:
        return history.BoxInt(value)
开发者ID:ieure,项目名称:pypy,代码行数:33,代码来源:warmstate.py


示例6: test_assemble_float_consts

def test_assemble_float_consts():
    ssarepr = SSARepr("test")
    ssarepr.insns = [
        ('float_return', Register('float', 13)),
        ('float_return', Constant(18.0, lltype.Float)),
        ('float_return', Constant(-4.0, lltype.Float)),
        ('float_return', Constant(128.1, lltype.Float)),
        ]
    assembler = Assembler()
    jitcode = assembler.assemble(ssarepr)
    assert jitcode.code == ("\x00\x0D"
                            "\x00\xFF"
                            "\x00\xFE"
                            "\x00\xFD")
    assert assembler.insns == {'float_return/f': 0}
    assert jitcode.constants_f == [longlong.getfloatstorage(18.0),
                                   longlong.getfloatstorage(-4.0),
                                   longlong.getfloatstorage(128.1)]
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:18,代码来源:test_assembler.py


示例7: _prepare_args

 def _prepare_args(self, args, floats, ints):
     local_floats = list(floats)
     local_ints = list(ints)
     expected_result = 0.0
     for i in range(len(args)):
         x = args[i]
         if x[0] == 'f':
             x = local_floats.pop()
             t = longlong.getfloatstorage(x)
             self.cpu.set_future_value_float(i, t)
         else:
             x = local_ints.pop()
             self.cpu.set_future_value_int(i, x)
         expected_result += x
     return expected_result
开发者ID:ieure,项目名称:pypy,代码行数:15,代码来源:calling_convention_test.py


示例8: set_future_value

def set_future_value(cpu, j, value, typecode):
    if typecode == 'ref':
        refvalue = cpu.ts.cast_to_ref(value)
        cpu.set_future_value_ref(j, refvalue)
    elif typecode == 'int':
        intvalue = lltype.cast_primitive(lltype.Signed, value)
        cpu.set_future_value_int(j, intvalue)
    elif typecode == 'float':
        if lltype.typeOf(value) is lltype.Float:
            value = longlong.getfloatstorage(value)
        else:
            assert longlong.is_longlong(lltype.typeOf(value))
            value = rffi.cast(lltype.SignedLongLong, value)
        cpu.set_future_value_float(j, value)
    else:
        assert False
开发者ID:ieure,项目名称:pypy,代码行数:16,代码来源:warmstate.py


示例9: _prepare_args

 def _prepare_args(self, args, floats, ints):
     local_floats = list(floats)
     local_ints = list(ints)
     expected_result = 0.0
     arguments = []
     for i in range(len(args)):
         x = args[i]
         if x[0] == 'f':
             x = local_floats.pop()
             t = longlong.getfloatstorage(x)
             arguments.append(t)
         else:
             x = local_ints.pop()
             arguments.append(x)
         expected_result += x
     return arguments, expected_result
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:16,代码来源:calling_convention_test.py


示例10: emit_const

 def emit_const(self, const, kind, allow_short=False):
     value = const.value
     if kind == 'int':
         TYPE = const.concretetype
         if isinstance(TYPE, lltype.Ptr):
             assert TYPE.TO._gckind == 'raw'
             self.see_raw_object(value)
             value = llmemory.cast_ptr_to_adr(value)
             TYPE = llmemory.Address
         if TYPE == llmemory.Address:
             value = heaptracker.adr2int(value)
         if TYPE is lltype.SingleFloat:
             value = longlong.singlefloat2int(value)
         if not isinstance(value, (llmemory.AddressAsInt,
                                   ComputedIntSymbolic)):
             value = lltype.cast_primitive(lltype.Signed, value)
             if allow_short:
                 try:
                     short_num = -128 <= value <= 127
                 except TypeError:    # "Symbolics cannot be compared!"
                     short_num = False
                 if short_num:
                     # emit the constant as a small integer
                     self.code.append(chr(value & 0xFF))
                     return True
         constants = self.constants_i
     elif kind == 'ref':
         value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
         constants = self.constants_r
     elif kind == 'float':
         if const.concretetype == lltype.Float:
             value = longlong.getfloatstorage(value)
         else:
             assert longlong.is_longlong(const.concretetype)
             value = rffi.cast(lltype.SignedLongLong, value)
         constants = self.constants_f
     else:
         raise AssemblerError('unimplemented %r in %r' %
                              (const, self.ssareprname))
     key = (kind, Constant(value))
     if key not in self.constants_dict:
         constants.append(value)
         self.constants_dict[key] = 256 - len(constants)
     # emit the constant normally, as one byte that is an index in the
     # list of constants
     self.code.append(chr(self.constants_dict[key]))
     return False
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:47,代码来源:assembler.py


示例11: 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()
        memory_manager = None
    class FakeJitDriverSD:
        _red_args_types = ["int", "float"]
        virtualizable_info = None
    #
    state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
    set_future_values = state.make_set_future_values()
    set_future_values(5, 42.5)
    assert future_values == {
        0: ("int", 5),
        1: ("float", longlong.getfloatstorage(42.5)),
    }
    assert set_future_values is state.make_set_future_values()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:22,代码来源:test_warmstate.py


示例12: _run_with_blackhole

def _run_with_blackhole(testself, args):
    from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
    cw = testself.cw
    blackholeinterpbuilder = BlackholeInterpBuilder(cw)
    blackholeinterp = blackholeinterpbuilder.acquire_interp()
    count_i = count_r = count_f = 0
    for value in args:
        T = lltype.typeOf(value)
        if T == lltype.Signed:
            blackholeinterp.setarg_i(count_i, value)
            count_i += 1
        elif T == llmemory.GCREF:
            blackholeinterp.setarg_r(count_r, value)
            count_r += 1
        elif T == lltype.Float:
            value = longlong.getfloatstorage(value)
            blackholeinterp.setarg_f(count_f, value)
            count_f += 1
        else:
            raise TypeError(T)
    [jitdriver_sd] = cw.callcontrol.jitdrivers_sd
    blackholeinterp.setposition(jitdriver_sd.mainjitcode, 0)
    blackholeinterp.run()
    return blackholeinterp._final_result_anytype()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:24,代码来源:support.py


示例13: test_functions

def test_functions():
    xll = longlong.getfloatstorage(3.5)
    assert longlong.getrealfloat(xll) == 3.5
    assert isinstance(longlong.gethash(xll), int)
开发者ID:ieure,项目名称:pypy,代码行数:4,代码来源:test_longlong.py


示例14: convert_to_floatstorage

 def convert_to_floatstorage(arg):
     from pypy.jit.codewriter import longlong
     return longlong.getfloatstorage(float(arg))
开发者ID:gorakhargosh,项目名称:pypy,代码行数:3,代码来源:oparser_model.py


示例15: test_functions

def test_functions():
    xll = longlong.getfloatstorage(3.5)
    assert longlong.getrealfloat(xll) == 3.5
    assert is_valid_int(longlong.gethash(xll))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:test_longlong.py


示例16: do_failure_recovery_func

def do_failure_recovery_func(withfloats):
    import random
    S = lltype.GcStruct('S')

    def get_random_int():
        return random.randrange(-10000, 10000)

    def get_random_ptr():
        return lltype.cast_opaque_ptr(llmemory.GCREF, lltype.malloc(S))

    def get_random_float():
        # Returns <float>, <low word>, <high word>
        # NB: on 64-bit, <low word> will be the entire float and <high word>
        # will be random garbage from malloc!
        assert withfloats
        value = random.random() - 0.5
        # make sure it fits into 64 bits
        tmp = lltype.malloc(rffi.LONGP.TO, 2, flavor='raw',
                            track_allocation=False)
        rffi.cast(rffi.DOUBLEP, tmp)[0] = value
        return rffi.cast(rffi.DOUBLEP, tmp)[0], tmp[0], tmp[1]

    if IS_X86_32:
        main_registers = X86RegisterManager.all_regs
        xmm_registers = X86XMMRegisterManager.all_regs
    elif IS_X86_64:
        main_registers = X86_64_RegisterManager.all_regs
        xmm_registers = X86_64_XMMRegisterManager.all_regs

    # memory locations: 26 integers, 26 pointers, 26 floats
    # main registers: half of them as signed and the other half as ptrs
    # xmm registers: all floats, from xmm0 to xmm(7|15)
    # holes: 8
    locations = []
    baseloc = 4
    for i in range(26+26+26):
        if baseloc < 128:
            baseloc += random.randrange(2, 20)
        else:
            baseloc += random.randrange(2, 1000)
        locations.append(baseloc)
    random.shuffle(locations)
    content = ([('int', locations.pop()) for _ in range(26)] +
               [('ptr', locations.pop()) for _ in range(26)] +
               [(['int', 'ptr'][random.randrange(0, 2)], reg)
                         for reg in main_registers])
    if withfloats:
        content += ([('float', locations.pop()) for _ in range(26)] +
                    [('float', reg) for reg in xmm_registers])
    for i in range(8):
        content.append(('hole', None))
    random.shuffle(content)

    # prepare the expected target arrays, the descr_bytecode,
    # the 'registers' and the 'stack' arrays according to 'content'
    xmmregisters = lltype.malloc(rffi.LONGP.TO, 16+ACTUAL_CPU.NUM_REGS+1,
                                 flavor='raw', immortal=True)
    registers = rffi.ptradd(xmmregisters, 16)
    stacklen = baseloc + 30
    stack = lltype.malloc(rffi.LONGP.TO, stacklen, flavor='raw',
                          immortal=True)
    expected_ints = [0] * len(content)
    expected_ptrs = [lltype.nullptr(llmemory.GCREF.TO)] * len(content)
    expected_floats = [longlong.ZEROF] * len(content)

    def write_in_stack(loc, value):
        assert loc >= 0
        ofs = get_ebp_ofs(loc)
        assert ofs < 0
        assert (ofs % WORD) == 0
        stack[stacklen + ofs//WORD] = value

    descr_bytecode = []
    for i, (kind, loc) in enumerate(content):
        if kind == 'hole':
            num = Assembler386.CODE_HOLE
        else:
            if kind == 'float':
                value, lo, hi = get_random_float()
                expected_floats[i] = longlong.getfloatstorage(value)
                kind = Assembler386.DESCR_FLOAT
                if isinstance(loc, RegLoc):
                    if WORD == 4:
                        xmmregisters[2*loc.value] = lo
                        xmmregisters[2*loc.value+1] = hi
                    elif WORD == 8:
                        xmmregisters[loc.value] = lo
                else:
                    if WORD == 4:
                        write_in_stack(loc, hi)
                        write_in_stack(loc+1, lo)
                    elif WORD == 8:
                        write_in_stack(loc, lo)
            else:
                if kind == 'int':
                    value = get_random_int()
                    expected_ints[i] = value
                    kind = Assembler386.DESCR_INT
                elif kind == 'ptr':
                    value = get_random_ptr()
#.........这里部分代码省略.........
开发者ID:gorakhargosh,项目名称:pypy,代码行数:101,代码来源:test_assembler.py


示例17: bh_call_f

 def bh_call_f(self, func, calldescr, args_i, args_r, args_f):
     self.fakecalled = (func, calldescr, args_i, args_r, args_f)
     return longlong.getfloatstorage(42.5)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:3,代码来源:test_executor.py


示例18: constfloat

def constfloat(x):
    return ConstFloat(longlong.getfloatstorage(x))
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:2,代码来源:test_warmstate.py


示例19: boxfloat

def boxfloat(x):
    return BoxFloat(longlong.getfloatstorage(x))
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:2,代码来源:test_warmstate.py



注:本文中的pypy.jit.codewriter.longlong.getfloatstorage函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python heapcache.HeapCache类代码示例发布时间:2022-05-27
下一篇:
Python jtransform.Transformer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap