[pypy-svn] r27660 - in pypy/branch/njriley-trans/pypy: rpython/lltypesystem translator/c
njriley at codespeak.net
njriley at codespeak.net
Wed May 24 20:48:14 CEST 2006
Author: njriley
Date: Wed May 24 20:48:13 2006
New Revision: 27660
Modified:
pypy/branch/njriley-trans/pypy/rpython/lltypesystem/rclass.py
pypy/branch/njriley-trans/pypy/translator/c/exceptiontransform.py
pypy/branch/njriley-trans/pypy/translator/c/node.py
Log:
Make exceptions thread-local
Modified: pypy/branch/njriley-trans/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/branch/njriley-trans/pypy/rpython/lltypesystem/rclass.py (original)
+++ pypy/branch/njriley-trans/pypy/rpython/lltypesystem/rclass.py Wed May 24 20:48:13 2006
@@ -342,10 +342,10 @@
MkStruct = GcStruct
else:
MkStruct = Struct
-
+
object_type = MkStruct(self.classdef.name,
('super', self.rbase.object_type),
- *llfields)
+ *llfields, **dict(hints=self.gethints()))
self.object_type.become(object_type)
allinstancefields.update(self.rbase.allinstancefields)
allinstancefields.update(fields)
@@ -380,6 +380,9 @@
def getflavor(self):
return self.classdef.classdesc.read_attribute('_alloc_flavor_', Constant('gc')).value
+ def gethints(self):
+ return self.classdef.classdesc.read_attribute('_rpython_hints_', Constant({})).value
+
def null_instance(self):
return nullptr(self.object_type)
Modified: pypy/branch/njriley-trans/pypy/translator/c/exceptiontransform.py
==============================================================================
--- pypy/branch/njriley-trans/pypy/translator/c/exceptiontransform.py (original)
+++ pypy/branch/njriley-trans/pypy/translator/c/exceptiontransform.py Wed May 24 20:48:13 2006
@@ -42,7 +42,7 @@
l2a = annmodel.lltype_to_annotation
class ExcData(object):
- pass
+ _rpython_hints_ = {'thread_local': True}
#exc_type = lltype.nullptr(self.exc_data.lltype_of_exception_type.TO)
#exc_value = lltype.nullptr(self.exc_data.lltype_of_exception_value.TO)
Modified: pypy/branch/njriley-trans/pypy/translator/c/node.py
==============================================================================
--- pypy/branch/njriley-trans/pypy/translator/c/node.py (original)
+++ pypy/branch/njriley-trans/pypy/translator/c/node.py Wed May 24 20:48:13 2006
@@ -365,15 +365,18 @@
self.ptrname = '((%s)(void*)%s)' % (cdecl(ptrtypename, ''),
self.ptrname)
+ def declaration(self):
+ decl = cdecl(self.implementationtypename, self.name)
+ if hasattr(self.T, '_hints') and self.T._hints.get('thread_local'):
+ decl = '__thread ' + decl # XXX make conditional
+ return decl
+
def forward_declaration(self):
- yield '%s;' % (
- cdecl(self.implementationtypename, self.name))
+ yield 'extern %s;' % self.declaration()
def implementation(self):
lines = list(self.initializationexpr())
- lines[0] = '%s = %s' % (
- cdecl(self.implementationtypename, self.name),
- lines[0])
+ lines[0] = '%s = %s' % (self.declaration(), lines[0])
lines[-1] += ';'
return lines
More information about the Pypy-commit
mailing list