Example #1
0
    def entry_point(argv):
        if withjit:
            from rpython.jit.backend.hlinfo import highleveljitinfo
            highleveljitinfo.sys_executable = argv[0]

        if hashfunc == "siphash24":
            from rpython.rlib import rsiphash
            rsiphash.enable_siphash24()

        #debug("entry point starting")
        #for arg in argv:
        #    debug(" argv -> " + arg)
        if len(argv) > 2 and argv[1] == '--heapsize':
            # Undocumented option, handled at interp-level.
            # It has silently no effect with some GCs.
            # It works in Boehm and in the semispace or generational GCs
            # (but see comments in semispace.py:set_max_heap_size()).
            # At the moment this option exists mainly to support sandboxing.
            from rpython.rlib import rgc
            rgc.set_max_heap_size(int(argv[2]))
            argv = argv[:1] + argv[3:]
        try:
            try:
                space.startup()
                if rlocale.HAVE_LANGINFO:
                    try:
                        rlocale.setlocale(rlocale.LC_CTYPE, '')
                    except rlocale.LocaleError:
                        pass
                w_executable = space.newfilename(argv[0])
                w_argv = space.newlist(
                    [space.newfilename(s) for s in argv[1:]])
                w_exitcode = space.call_function(w_entry_point, w_executable,
                                                 w_argv)
                exitcode = space.int_w(w_exitcode)
                # try to pull it all in
            ##    from pypy.interpreter import main, interactive, error
            ##    con = interactive.PyPyConsole(space)
            ##    con.interact()
            except OperationError as e:
                debug("OperationError:")
                debug(" operror-type: " + e.w_type.getname(space))
                debug(" operror-value: " +
                      space.text_w(space.str(e.get_w_value(space))))
                return 1
        finally:
            try:
                # the equivalent of Py_FinalizeEx
                if space.finish() < 0:
                    # Value unlikely to be confused with a non-error exit status
                    # or other special meaning (from cpython/Modules/main.c)
                    exitcode = 120
            except OperationError as e:
                debug("OperationError:")
                debug(" operror-type: " + e.w_type.getname(space))
                debug(" operror-value: " +
                      space.text_w(space.str(e.get_w_value(space))))
                return 1
        return exitcode
Example #2
0
 def fn():
     from rpython.rlib import rgc
     rgc.set_max_heap_size(500000)
     s1 = s2 = s3 = None
     try:
         s1 = g(10000)
         s2 = g(100000)
         s3 = g(1000000)
     except MemoryError:
         pass
     return (s1 is not None) + (s2 is not None) + (s3 is not None)
Example #3
0
 def fn():
     from rpython.rlib import rgc
     rgc.set_max_heap_size(500000)
     s1 = s2 = s3 = None
     try:
         s1 = g(10000)
         s2 = g(100000)
         s3 = g(1000000)
     except MemoryError:
         pass
     return (s1 is not None) + (s2 is not None) + (s3 is not None)
Example #4
0
 def fn():
     # the semispace size starts at 8MB for now, so setting a
     # smaller limit has no effect
     # set to more than 32MB -- which should be rounded down to 32MB
     rgc.set_max_heap_size(32 * 1024 * 1024 + 20000)
     s1 = s2 = s3 = None
     try:
         s1 = g(400000)      # ~ 400 KB
         s2 = g(4000000)     # ~ 4 MB
         s3 = g(40000000)    # ~ 40 MB
     except MemoryError:
         pass
     return (s1 is not None) + (s2 is not None) + (s3 is not None)
Example #5
0
    def entry_point(argv):
        if withjit:
            from rpython.jit.backend.hlinfo import highleveljitinfo
            highleveljitinfo.sys_executable = argv[0]

        if hashfunc == "siphash24":
            from rpython.rlib import rsiphash
            rsiphash.enable_siphash24()

        #debug("entry point starting")
        #for arg in argv:
        #    debug(" argv -> " + arg)
        if len(argv) > 2 and argv[1] == '--heapsize':
            # Undocumented option, handled at interp-level.
            # It has silently no effect with some GCs.
            # It works in Boehm and in the semispace or generational GCs
            # (but see comments in semispace.py:set_max_heap_size()).
            # At the moment this option exists mainly to support sandboxing.
            from rpython.rlib import rgc
            rgc.set_max_heap_size(int(argv[2]))
            argv = argv[:1] + argv[3:]
        try:
            try:
                space.startup()
                w_executable = space.newtext(argv[0])
                w_argv = space.newlist([space.newtext(s) for s in argv[1:]])
                w_exitcode = space.call_function(w_entry_point, w_executable,
                                                 w_argv)
                exitcode = space.int_w(w_exitcode)
                # try to pull it all in
            ##    from pypy.interpreter import main, interactive, error
            ##    con = interactive.PyPyConsole(space)
            ##    con.interact()
            except OperationError as e:
                debug("OperationError:")
                debug(" operror-type: " + e.w_type.getname(space))
                debug(" operror-value: " +
                      space.text_w(space.str(e.get_w_value(space))))
                return 1
        finally:
            try:
                space.finish()
            except OperationError as e:
                debug("OperationError:")
                debug(" operror-type: " + e.w_type.getname(space))
                debug(" operror-value: " +
                      space.text_w(space.str(e.get_w_value(space))))
                return 1
        return exitcode
Example #6
0
    def entry_point(argv):
        if withjit:
            from rpython.jit.backend.hlinfo import highleveljitinfo
            highleveljitinfo.sys_executable = argv[0]

        #debug("entry point starting")
        #for arg in argv:
        #    debug(" argv -> " + arg)
        if len(argv) > 2 and argv[1] == '--heapsize':
            # Undocumented option, handled at interp-level.
            # It has silently no effect with some GCs.
            # It works in Boehm and in the semispace or generational GCs
            # (but see comments in semispace.py:set_max_heap_size()).
            # At the moment this option exists mainly to support sandboxing.
            from rpython.rlib import rgc
            rgc.set_max_heap_size(int(argv[2]))
            argv = argv[:1] + argv[3:]
        try:
            try:
                space.startup()
                if rlocale.HAVE_LANGINFO:
                    try:
                        rlocale.setlocale(rlocale.LC_CTYPE, '')
                    except rlocale.LocaleError:
                        pass
                w_executable = space.wrap_fsdecoded(argv[0])
                w_argv = space.newlist([space.wrap_fsdecoded(s)
                                        for s in argv[1:]])
                w_exitcode = space.call_function(w_entry_point, w_executable, w_argv)
                exitcode = space.int_w(w_exitcode)
                # try to pull it all in
            ##    from pypy.interpreter import main, interactive, error
            ##    con = interactive.PyPyConsole(space)
            ##    con.interact()
            except OperationError, e:
                debug("OperationError:")
                debug(" operror-type: " + e.w_type.getname(space).encode('utf-8'))
                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                return 1
        finally:
            try:
                space.finish()
            except OperationError, e:
                debug("OperationError:")
                debug(" operror-type: " + e.w_type.getname(space).encode('utf-8'))
                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
                return 1