Fw: [pypy-dev] Re: [pypy-svn] r22006 - in pypy/dist/pypy/translator/c: . src test

Ben.Young at risk.sungard.com Ben.Young at risk.sungard.com
Thu Jan 12 11:28:14 CET 2006


Cool. That was very quick!

This malloc removal stuff is looking really good! Does it also mean (if it 
works) that the inlining threshold can be reduced a bit as part of the 
reason it needs to be high is to allow the current malloc removal to work? 
This could reduce the codebase size by rather a lot.

Cheers,
Ben

Eric van Riet Paap <eric at vanrietpaap.nl> wrote on 12/01/2006 09:49:38:

> Hi Ben,
> 
> Thank you for that info. I've added some preprocessor stuff to handle 
> this windows case. I hope the test/test_lladdresses.py tests pass on 
> windows too now.
> Using _malloca (together with _freea) is something we have to think 
> about. Mostly because currently is all to easy to exhaust stackspace 
> anyway.
> 
> cheers
> Eric
> 
> 
> On Jan 12, 2006, at 10:41 AM, Ben.Young at risk.sungard.com wrote:
> 
> > Hi Eric,
> >
> > Just to let you know that on Windows, alloca is spelt _alloca. In 
> > later
> > versions the preferred version is _malloca, which needs to be 
> > matched by a
> > _freea, as _malloca can allocate on the heap if the object is too 
> > large.
> >
> > Cheers,
> > Ben
> >
> > pypy-svn-bounces at codespeak.net wrote on 12/01/2006 09:31:21:
> >
> >> Author: ericvrp
> >> Date: Thu Jan 12 10:31:20 2006
> >> New Revision: 22006
> >>
> >> Modified:
> >>    pypy/dist/pypy/translator/c/funcgen.py
> >>    pypy/dist/pypy/translator/c/src/address.h
> >>    pypy/dist/pypy/translator/c/test/test_lladdresses.py
> >> Log:
> >> Added genc support of stack flavored_malloc
> >>
> >>
> >> Modified: pypy/dist/pypy/translator/c/funcgen.py
> >>
> > ====================================================================== 

> > ========
> >> --- pypy/dist/pypy/translator/c/funcgen.py   (original)
> >> +++ pypy/dist/pypy/translator/c/funcgen.py   Thu Jan 12 10:31:20 2006
> >> @@ -568,6 +568,8 @@
> >>          flavor = op.args[0].value
> >>          if flavor == "raw":
> >>              return "OP_RAW_MALLOC(%s, %s, %s);" % (esize, 
> >> eresult, err)
> >
> >> +        elif flavor == "stack":
> >> +            return "OP_STACK_MALLOC(%s, %s, %s);" % (esize, eresult,
> > err)
> >>          else:
> >>              raise NotImplementedError
> >>
> >>
> >> Modified: pypy/dist/pypy/translator/c/src/address.h
> >>
> > ====================================================================== 

> > ========
> >> --- pypy/dist/pypy/translator/c/src/address.h   (original)
> >> +++ pypy/dist/pypy/translator/c/src/address.h   Thu Jan 12 
> >> 10:31:20 2006
> >> @@ -20,5 +20,9 @@
> >>      r = (void*) malloc(size);    \
> >>      if (r == NULL) FAIL_EXCEPTION(err, PyExc_MemoryError, "out of
> > memory");\
> >>
> >> +#define OP_STACK_MALLOC(size,r,err)    \
> >> +    r = (void*) alloca(size);    \
> >> +    if (r == NULL) FAIL_EXCEPTION(err, PyExc_MemoryError, "out of
> > memory");\
> >> +
> >>  #define OP_RAW_FREE(x,r,err)        free(x);
> >>  #define OP_RAW_MEMCOPY(x,y,size,r,err) memcpy(y,x,size);
> >>
> >> Modified: pypy/dist/pypy/translator/c/test/test_lladdresses.py
> >>
> > ====================================================================== 

> > ========
> >> --- pypy/dist/pypy/translator/c/test/test_lladdresses.py   (original)
> >> +++ pypy/dist/pypy/translator/c/test/test_lladdresses.py   Thu Jan
> >> 12 10:31:20 2006
> >> @@ -88,7 +88,7 @@
> >>      res = fc()
> >>      assert res == int('011100' * 2, 2)
> >>
> >> -def test_flavored_malloc():
> >> +def test_flavored_malloc_raw():
> >>      class A(object):
> >>          _alloc_flavor_ = "raw"
> >>          def __init__(self, val):
> >> @@ -100,3 +100,15 @@
> >>          return result
> >>      fn = compile(f, [int])
> >>      assert fn(1) == 2
> >> +
> >> +def test_flavored_malloc_stack():
> >> +    class A(object):
> >> +        _alloc_flavor_ = "stack"
> >> +        def __init__(self, val):
> >> +            self.val = val
> >> +    def f(x):
> >> +        a = A(x + 1)
> >> +        result = a.val
> >> +        return result
> >> +    fn = compile(f, [int])
> >> +    assert fn(1) == 2
> >> _______________________________________________
> >> pypy-svn mailing list
> >> pypy-svn at codespeak.net
> >> http://codespeak.net/mailman/listinfo/pypy-svn
> >>
> >
> > _______________________________________________
> > pypy-dev at codespeak.net
> > http://codespeak.net/mailman/listinfo/pypy-dev
> 
> 




More information about the Pypy-dev mailing list