예제 #1
0
def setup_module(mod):
    from rpython.rtyper.tool.rffi_platform import configure_boehm
    from rpython.translator.platform import CompilationError
    try:
        configure_boehm()
    except CompilationError:
        py.test.skip("Boehm GC not present")
예제 #2
0
def setup_module(mod):
    from rpython.rtyper.tool.rffi_platform import configure_boehm
    from rpython.translator.platform import CompilationError
    try:
        configure_boehm()
    except CompilationError:
        py.test.skip("Boehm GC not present")
예제 #3
0
 def possibly_check_for_boehm(self):
     if self.config.translation.gc == "boehm":
         from rpython.rtyper.tool.rffi_platform import configure_boehm
         from rpython.translator.platform import CompilationError
         try:
             configure_boehm(self.translator.platform)
         except CompilationError as e:
             i = 'Boehm GC not installed.  Try e.g. "translate.py --gc=minimark"'
             raise Exception(str(e) + '\n' + i)
예제 #4
0
파일: driver.py 프로젝트: yuyichao/pypy
 def possibly_check_for_boehm(self):
     if self.config.translation.gc == "boehm":
         from rpython.rtyper.tool.rffi_platform import configure_boehm
         from rpython.translator.platform import CompilationError
         try:
             configure_boehm(self.translator.platform)
         except CompilationError, e:
             i = 'Boehm GC not installed.  Try e.g. "translate.py --gc=hybrid"'
             raise Exception(str(e) + '\n' + i)
예제 #5
0
    def compilation_info(self):
        eci = BasicGcPolicy.compilation_info(self)

        from rpython.rtyper.tool.rffi_platform import configure_boehm
        eci = eci.merge(configure_boehm())

        pre_include_bits = []
        if sys.platform.startswith('linux'):
            pre_include_bits += [
                "#define _REENTRANT 1", "#define GC_LINUX_THREADS 1"
            ]
        if sys.platform != "win32" and not sys.platform.startswith("openbsd"):
            # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]

        hdr_flag = ''
        if not getattr(self.db.gctransformer, 'NO_HEADER', False):
            hdr_flag = '-DPYPY_BOEHM_WITH_HEADER'

        eci = eci.merge(
            ExternalCompilationInfo(
                pre_include_bits=pre_include_bits,
                # The following define is required by the thread module,
                # See module/thread/test/test_rthread.py
                compile_extra=['-DPYPY_USING_BOEHM_GC', hdr_flag],
            ))

        gct = self.db.gctransformer
        gct.finalizer_triggers = tuple(gct.finalizer_triggers)  # stop changing
        sourcelines = ['']
        for trig in gct.finalizer_triggers:
            sourcelines.append('RPY_EXTERN void %s(void);' %
                               (self.db.get(trig), ))
        sourcelines.append('')
        sourcelines.append('void (*boehm_fq_trigger[])(void) = {')
        for trig in gct.finalizer_triggers:
            sourcelines.append('\t%s,' % (self.db.get(trig), ))
        sourcelines.append('\tNULL')
        sourcelines.append('};')
        sourcelines.append('struct boehm_fq_s *boehm_fq_queues[%d];' %
                           (len(gct.finalizer_triggers) or 1, ))
        sourcelines.append('')
        eci = eci.merge(
            ExternalCompilationInfo(
                separate_module_sources=['\n'.join(sourcelines)]))

        return eci
예제 #6
0
파일: gc.py 프로젝트: weijiwei/pypy
    def configure_boehm_once(cls):
        """ Configure boehm only once, since we don't cache failures
        """
        if hasattr(cls, 'malloc_fn_ptr'):
            return cls.malloc_fn_ptr
        from rpython.rtyper.tool import rffi_platform
        compilation_info = rffi_platform.configure_boehm()

        # on some platform GC_init is required before any other
        # GC_* functions, call it here for the benefit of tests
        # XXX move this to tests
        init_fn_ptr = rffi.llexternal("GC_init", [],
                                      lltype.Void,
                                      compilation_info=compilation_info,
                                      sandboxsafe=True,
                                      _nowrapper=True)
        init_fn_ptr()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")

        config = rffi_platform.configure(CConfig)
        if config['HAS_LOCAL_MALLOC']:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"
        malloc_fn_ptr = rffi.llexternal(
            GC_MALLOC,
            [lltype.Signed],  # size_t, but good enough
            llmemory.GCREF,
            compilation_info=compilation_info,
            sandboxsafe=True,
            _nowrapper=True)
        cls.malloc_fn_ptr = malloc_fn_ptr
        return malloc_fn_ptr
예제 #7
0
파일: gc.py 프로젝트: mozillazg/pypy
    def compilation_info(self):
        eci = BasicGcPolicy.compilation_info(self)

        from rpython.rtyper.tool.rffi_platform import configure_boehm
        eci = eci.merge(configure_boehm())

        pre_include_bits = []
        if sys.platform.startswith('linux'):
            pre_include_bits += ["#define _REENTRANT 1",
                                 "#define GC_LINUX_THREADS 1"]
        if sys.platform != "win32" and not sys.platform.startswith("openbsd"):
            # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]

        eci = eci.merge(ExternalCompilationInfo(
            pre_include_bits=pre_include_bits,
            # The following define is required by the thread module,
            # See module/thread/test/test_rthread.py
            compile_extra=['-DPYPY_USING_BOEHM_GC'],
            ))

        gct = self.db.gctransformer
        gct.finalizer_triggers = tuple(gct.finalizer_triggers)  # stop changing
        sourcelines = ['']
        for trig in gct.finalizer_triggers:
            sourcelines.append('RPY_EXTERN void %s(void);' % (
                self.db.get(trig),))
        sourcelines.append('')
        sourcelines.append('void (*boehm_fq_trigger[])(void) = {')
        for trig in gct.finalizer_triggers:
            sourcelines.append('\t%s,' % (self.db.get(trig),))
        sourcelines.append('\tNULL')
        sourcelines.append('};')
        sourcelines.append('struct boehm_fq_s *boehm_fq_queues[%d];' % (
            len(gct.finalizer_triggers) or 1,))
        sourcelines.append('')
        eci = eci.merge(ExternalCompilationInfo(
            separate_module_sources=['\n'.join(sourcelines)]))

        return eci
예제 #8
0
파일: gc.py 프로젝트: abhinavthomas/pypy
    def compilation_info(self):
        eci = BasicGcPolicy.compilation_info(self)

        from rpython.rtyper.tool.rffi_platform import configure_boehm
        eci = eci.merge(configure_boehm())

        pre_include_bits = []
        if sys.platform.startswith('linux'):
            pre_include_bits += ["#define _REENTRANT 1",
                                 "#define GC_LINUX_THREADS 1"]
        if sys.platform != "win32" and not sys.platform.startswith("openbsd"):
            # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]

        eci = eci.merge(ExternalCompilationInfo(
            pre_include_bits=pre_include_bits,
            # The following define is required by the thread module,
            # See module/thread/test/test_rthread.py
            compile_extra=['-DPYPY_USING_BOEHM_GC'],
            ))

        return eci
예제 #9
0
파일: gc.py 프로젝트: mozillazg/pypy
    def configure_boehm_once(cls):
        """ Configure boehm only once, since we don't cache failures
        """
        if hasattr(cls, 'malloc_fn_ptr'):
            return cls.malloc_fn_ptr
        from rpython.rtyper.tool import rffi_platform
        compilation_info = rffi_platform.configure_boehm()

        # on some platform GC_init is required before any other
        # GC_* functions, call it here for the benefit of tests
        # XXX move this to tests
        init_fn_ptr = rffi.llexternal("GC_init",
                                      [], lltype.Void,
                                      compilation_info=compilation_info,
                                      sandboxsafe=True,
                                      _nowrapper=True)
        init_fn_ptr()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")
        config = rffi_platform.configure(CConfig)
        if config['HAS_LOCAL_MALLOC']:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"
        malloc_fn_ptr = rffi.llexternal(GC_MALLOC,
                                        [lltype.Signed], # size_t, but good enough
                                        llmemory.GCREF,
                                        compilation_info=compilation_info,
                                        sandboxsafe=True,
                                        _nowrapper=True)
        cls.malloc_fn_ptr = malloc_fn_ptr
        return malloc_fn_ptr
예제 #10
0
    def compilation_info(self):
        eci = BasicGcPolicy.compilation_info(self)

        from rpython.rtyper.tool.rffi_platform import configure_boehm
        eci = eci.merge(configure_boehm())

        pre_include_bits = []
        if sys.platform.startswith('linux'):
            pre_include_bits += [
                "#define _REENTRANT 1", "#define GC_LINUX_THREADS 1"
            ]
        if sys.platform != "win32" and not sys.platform.startswith("openbsd"):
            # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]

        eci = eci.merge(
            ExternalCompilationInfo(
                pre_include_bits=pre_include_bits,
                # The following define is required by the thread module,
                # See module/thread/test/test_rthread.py
                compile_extra=['-DPYPY_USING_BOEHM_GC'],
            ))

        return eci