Commit 49ba1676 authored by John Zhang's avatar John Zhang

merge changes from debug-pypy-interp

parents c20c5683 a1f71b7f
......@@ -26,23 +26,51 @@ index af1d380..7a5c762 100644
got = rffi.cast(lltype.Signed, got)
if got > 0:
target_pos += got
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
index fd29b2d..c1e9d98 100644
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -839,7 +839,9 @@ def make_array(mytype):
return rffi.cast(lltype.Unsigned, self.buffer)
def _charbuf_stop(self):
- keepalive_until_here(self)
+ from rpython.rlib.objectmodel import we_are_translated_to_mu
+ if not we_are_translated_to_mu():
+ keepalive_until_here(self)
def w_getitem(self, space, idx):
item = self.buffer[idx]
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
index e973a94..b9752e8 100644
index e973a94..46484e8 100644
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -472,7 +472,7 @@ def virtual_ref(x):
@@ -472,8 +472,10 @@ def virtual_ref(x):
@specialize.argtype(1)
def virtual_ref_finish(vref, x):
"""See docstring in virtual_ref(x)"""
- keepalive_until_here(x) # otherwise the whole function call is removed
+ # keepalive_until_here(x) # otherwise the whole function call is removed
_virtual_ref_finish(vref, x)
- _virtual_ref_finish(vref, x)
+ from rpython.rlib.objectmodel import we_are_translated_to_mu
+ if not we_are_translated_to_mu():
+ keepalive_until_here(x) # otherwise the whole function call is removed
+ # _virtual_ref_finish(vref, x)
def non_virtual_ref(x):
"""Creates a 'vref' that just returns x when called; nothing more special.
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
index f35e2b7..6aad4b8 100644
index f35e2b7..fd91235 100644
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -640,7 +640,7 @@ if not _WIN32:
DT_DIR = rffi_platform.ConstantInteger('DT_DIR')
DT_LNK = rffi_platform.ConstantInteger('DT_LNK')
- DIRP = rffi.COpaquePtr('DIR')
+ DIRP = rffi.COpaquePtr('DIR', compilation_info=eci)
dirent_config = rffi_platform.configure(CConfig)
DIRENT = dirent_config['DIRENT']
DIRENTP = lltype.Ptr(DIRENT)
@@ -1778,9 +1778,9 @@ def uname():
lltype.free(l_utsbuf, flavor='raw')
......@@ -109,6 +137,19 @@ index b3bc6ed..4edfcaa 100644
@py.test.mark.skipif("not hasattr(os, 'ttyname')")
class TestOsExpect(ExpectTest):
diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py
index e6239b4..64a3490 100644
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1623,7 +1623,7 @@ class _interior_ptr(_abstract_ptr):
if ob is None:
raise RuntimeError
return InteriorPtr(typeOf(ob), self._T, self._offsets)
-## _TYPE = property(_get_TYPE)
+ _TYPE = property(_get_TYPE)
def _expose(self, offset, val):
"""XXX A nice docstring here"""
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
index 1b7a007..48d04d5 100644
--- a/rpython/rtyper/lltypesystem/rffi.py
......@@ -200,16 +241,3 @@ index cafc9b1..380db0d 100644
self._execute_c_compiler(cc, args, exe_name,
cwd=str(exe_name.dirpath()))
return exe_name
diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py
index e6239b4324..64a3490e32 100644
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1623,7 +1623,7 @@ class _interior_ptr(_abstract_ptr):
if ob is None:
raise RuntimeError
return InteriorPtr(typeOf(ob), self._T, self._offsets)
-## _TYPE = property(_get_TYPE)
+ _TYPE = property(_get_TYPE)
def _expose(self, offset, val):
"""XXX A nice docstring here"""
......@@ -83,6 +83,10 @@ def main_(argv=None):
config.objspace.suggest(allworkingmodules=False)
if config.objspace.allworkingmodules:
pypyoption.enable_allworkingmodules(config)
if config.objspace.pytestmodules:
pypyoption.enable_pytestmodules(config)
if config.objspace.pybenchmodules:
pypyoption.enable_pybenchmodules(config)
if config.objspace.usemodules._continuation:
config.translation.continuation = True
if config.objspace.usemodules.thread:
......
......@@ -56,6 +56,16 @@ translation_modules.update([
"termios", "_minimal_curses",
])
pytest_modules = translation_modules.copy()
pytest_modules.update([
'_collections', '_locale',
])
pybench_modules = pytest_modules.copy()
pybench_modules.update([
'unicodedata',
])
# XXX this should move somewhere else, maybe to platform ("is this posixish"
# check or something)
if sys.platform == "win32":
......@@ -163,6 +173,16 @@ pypy_optiondescription = OptionDescription("objspace", "Object Space Options", [
cmdline="--allworkingmodules",
negation=True),
BoolOption("pytestmodules", "modules needed to get basic pytest running",
default=False,
cmdline="--pytestmodules",
suggests=[("objspace.allworkingmodules", False)]),
BoolOption("pybenchmodules", "modules needed to run pybench",
default=False,
cmdline="--pybenchmodules",
suggests=[("objspace.allworkingmodules", False)]),
StrOption("extmodules",
"Comma-separated list of third-party builtin modules",
cmdline="--ext",
......@@ -295,6 +315,15 @@ def enable_translationmodules(config):
modules = [name for name in modules if name not in essential_modules]
config.objspace.usemodules.suggest(**dict.fromkeys(modules, True))
def enable_pytestmodules(config):
modules = pytest_modules
modules = [name for name in modules if name not in essential_modules]
config.objspace.usemodules.suggest(**dict.fromkeys(modules, True))
def enable_pybenchmodules(config):
modules = pybench_modules
modules = [name for name in modules if name not in essential_modules]
config.objspace.usemodules.suggest(**dict.fromkeys(modules, True))
if __name__ == '__main__':
config = get_pypy_config()
......
......@@ -231,6 +231,12 @@ class PyPyTarget(object):
if config.objspace.translationmodules:
from pypy.config.pypyoption import enable_translationmodules
enable_translationmodules(config)
if config.objspace.pytestmodules:
from pypy.config.pypyoption import enable_pytestmodules
enable_pytestmodules(config)
if config.objspace.pybenchmodules:
from pypy.config.pypyoption import enable_pybenchmodules
enable_pybenchmodules(config)
config.translation.suggest(check_str_without_nul=True)
config.translation.suggest(shared=True)
......
......@@ -308,6 +308,15 @@ def we_are_translated():
def sc_we_are_translated(ctx):
return Constant(True)
def we_are_translated_to_mu():
return False
@register_flow_sc(we_are_translated_to_mu)
def sc_we_are_translated_to_mu(ctx):
from rpython.config.translationoption import get_translation_config
config = get_translation_config()
return Constant(config.translation.backend == 'mu')
def register_replacement_for(replaced_function, sandboxed_name=None):
def wrap(func):
from rpython.rtyper.extregistry import ExtRegistryEntry
......
......@@ -53,12 +53,10 @@ class CArrayConst(object):
self.lst = lst
def __str__(self):
if self.c_elm_t == 'MuCString':
return '({type}){value}'.format(type='char*[%d]' % len(self.lst),
value='{%s}' % ', '.join(map(lambda s: str(CStr(s)), self.lst)))
else:
return '({type}){value}'.format(type='%s [%d]' % (self.c_elm_t, len(self.lst)),
value='{%s}' % ', '.join(map(str, self.lst)))
f = lambda s: str(CStr(s)) if self.c_elm_t == 'MuCString' else str(s)
return '({type}){value}'.format(
type='%s [%d]' % (self.c_elm_t, len(self.lst)),
value='{%s}' % ', '.join(map(f, self.lst)))
__repr__ = __str__
......
......@@ -10,7 +10,7 @@ from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.rlib.objectmodel import specialize
import os
zebu_build = os.environ.get('ZEBU_BUILD', 'debug')
zebu_build = os.environ.get('ZEBU_BUILD', 'release')
libmu_dir = os.path.join(os.getenv('MU_ZEBU'), 'target', zebu_build)
eci = ExternalCompilationInfo(libraries=['mu'],
library_dirs=[libmu_dir])
......
......@@ -55,12 +55,10 @@ class CArrayConst(object):
self.lst = lst
def __str__(self):
if self.c_elm_t == 'MuCString':
return '({type}){value}'.format(type='char*[%d]' % len(self.lst),
value='{%s}' % ', '.join(map(lambda s: str(CStr(s)), self.lst)))
else:
return '({type}){value}'.format(type='%s [%d]' % (self.c_elm_t, len(self.lst)),
value='{%s}' % ', '.join(map(str, self.lst)))
f = lambda s: str(CStr(s)) if self.c_elm_t == 'MuCString' else str(s)
return '({type}){value}'.format(
type='%s [%d]' % (self.c_elm_t, len(self.lst)),
value='{%s}' % ', '.join(map(f, self.lst)))
__repr__ = __str__
......@@ -228,7 +226,7 @@ class APILogger:
defs = [
('OBJECTS', ' '.join(['file_%d.o' % i for i in range(num_c_files)]) + ' main.o'),
('INCLUDEDIRS', '-I$(MU_ZEBU)/src/vm/api'),
('LIBDIRS', '-L$(MU_ZEBU)/target/%s' % os.environ.get('ZEBU_BUILD', 'debug')),
('LIBDIRS', '-L$(MU_ZEBU)/target/%s' % os.environ.get('ZEBU_BUILD', 'release')),
('LIBS', '-lmu'),
('TARGET', target),
('CC', platform.cc),
......
......@@ -66,6 +66,8 @@ class MuBundleGen:
config_items.append('automagicReloc=False') # use manual relocation
else:
sep = ' '
# if 'log-level' not in self.mu_config.vmargs:
# config_items.append('--log-level=' + os.environ.get('MU_LOG_LEVEL', 'none'))
if 'emit-dir' not in self.mu_config.vmargs:
config_items.append('--aot-emit-dir=' + 'emit')
for lib in self.db.merged_eci.libraries:
......
This diff is collapsed.
......@@ -44,6 +44,25 @@ def test_map_type_opqptr():
LL_META_CSTR = lltype.Ptr(lltype.GcOpaqueType("MuStr", hints={'mu_render_ptr_as': mutype.META_CSTR}))
assert ll2mu.map_type(LL_META_CSTR) == mutype.META_CSTR
def arrayofbytes(n):
return mutype.MuArray(mutype.MU_INT8, n)
# other opaque types
# try translate the underlying opaque type first
from rpython.rlib._rsocket_rffi import fd_set
assert ll2mu.map_type(fd_set) == mutype.MuUPtr(arrayofbytes(fd_set.TO.hints['getsize']()))
# on Linux the exact definition of DIR struct cannot be found,
# thus there will be problem when querying the size of it
# thus on Linux DIRP will be translated to uptr<int<64>>
from rpython.rlib import rposix
DIRP = rposix.DIRP
import sys
if sys.platform.startswith('linux'):
assert ll2mu.map_type(rposix.DIRP) == mutype.MuUPtr(mutype.MU_INT64)
elif sys.platform == 'darwin':
assert ll2mu.map_type(rposix.DIRP) == mutype.MuUPtr(arrayofbytes(DIRP.TO.hints['getsize']()))
def test_map_type_hybrid():
ll2mu = LL2MuMapper()
from rpython.rtyper.lltypesystem.rstr import STR
......@@ -727,3 +746,22 @@ def test_map_op_mu_meta_lst2carr():
muops = ll2mu.map_op(llop)
assert [op.opname for op in muops] == ['mu_getiref', 'mu_getfieldiref', 'mu_load',
'mu_getiref', 'mu_getvarpartiref', 'mu_shiftiref']
def test_map_op_cast_longdouble_to_double():
ll2mu = LL2MuMapper()
SRC = ll2mu.map_type(rffi.LONGDOUBLE)
DST = ll2mu.map_type(rffi.DOUBLE)
llop = SpaceOperation('force_cast', [varof(SRC)], varof(DST))
muops = ll2mu.map_op(llop)
assert len(muops) == 1
assert muops[0].opname == 'same_as'
def test_map_op_force_cast_uint_to_int():
ll2mu = LL2MuMapper()
SRC = ll2mu.map_type(lltype.Unsigned)
DST = ll2mu.map_type(lltype.Signed)
llop = SpaceOperation('force_cast', [varof(SRC)], varof(DST))
muops = ll2mu.map_op(llop)
assert muops[0].opname == 'same_as'
......@@ -343,3 +343,20 @@ def test_NULL_const():
arg = g.startblock.operations[0].args[0].value.args[0]
assert isinstance(arg, Constant)
assert arg.value._is_null()
def test_malloc_castptr():
POINT = lltype.Struct('Point', ('x', lltype.Signed), ('y', lltype.Signed))
def f():
p = lltype.malloc(POINT, flavor='raw', track_allocation=False)
p.x = 10
p.y = 10
return p
t = Translation(f, [], backend='mu')
t.mutype()
g = graph_of(f, t)
ops = g.startblock.operations
assert ops[1].opname == 'mu_convop' and ops[1].args[0].value == 'PTRCAST'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment