[pypy-commit] pypy stm-thread-2: rearrange mallocs in strtod to allow inlining of str2charp
Raemi
noreply at buildbot.pypy.org
Tue Dec 11 15:54:19 CET 2012
Author: Remi Meier <meierrem at student.ethz.ch>
Branch: stm-thread-2
Changeset: r59398:4bc912a4d55c
Date: 2012-11-23 18:12 +0100
http://bitbucket.org/pypy/pypy/changeset/4bc912a4d55c/
Log: rearrange mallocs in strtod to allow inlining of str2charp add
transactionsafe to RPyThreadGetIdent
diff --git a/pypy/module/thread/ll_thread.py b/pypy/module/thread/ll_thread.py
--- a/pypy/module/thread/ll_thread.py
+++ b/pypy/module/thread/ll_thread.py
@@ -46,7 +46,8 @@
# importantly, reacquire it
# around the callback
c_thread_get_ident = llexternal('RPyThreadGetIdent', [], rffi.LONG,
- _nowrapper=True) # always call directly
+ _nowrapper=True,
+ transactionsafe=True) # always call directly
TLOCKP = rffi.COpaquePtr('struct RPyOpaque_ThreadLock',
compilation_info=eci)
diff --git a/pypy/rlib/rdtoa.py b/pypy/rlib/rdtoa.py
--- a/pypy/rlib/rdtoa.py
+++ b/pypy/rlib/rdtoa.py
@@ -52,9 +52,9 @@
compilation_info=eci, sandboxsafe=True)
def strtod(input):
- end_ptr = lltype.malloc(rffi.CCHARPP.TO, 1, flavor='raw')
+ ll_input = rffi.str2charp(input)
try:
- ll_input = rffi.str2charp(input)
+ end_ptr = lltype.malloc(rffi.CCHARPP.TO, 1, flavor='raw')
try:
result = dg_strtod(ll_input, end_ptr)
@@ -66,9 +66,10 @@
return result
finally:
- rffi.free_charp(ll_input)
+ lltype.free(end_ptr, flavor='raw')
finally:
- lltype.free(end_ptr, flavor='raw')
+ rffi.free_charp(ll_input)
+
lower_special_strings = ['inf', '+inf', '-inf', 'nan']
upper_special_strings = ['INF', '+INF', '-INF', 'NAN']
diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -714,6 +714,7 @@
i -= 1
return array
str2charp._annenforceargs_ = [strtype]
+ str2charp._always_inline_ = True
def free_charp(cp):
lltype.free(cp, flavor='raw')
More information about the pypy-commit
mailing list