[pypy-commit] pypy stm-thread-2: hg merge default
arigo
noreply at buildbot.pypy.org
Sat Feb 16 18:10:35 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r61327:65ec96e15463
Date: 2013-02-16 17:34 +0100
http://bitbucket.org/pypy/pypy/changeset/65ec96e15463/
Log: hg merge default
diff --git a/pypy/interpreter/miscutils.py b/pypy/interpreter/miscutils.py
--- a/pypy/interpreter/miscutils.py
+++ b/pypy/interpreter/miscutils.py
@@ -20,10 +20,10 @@
def signals_enabled(self):
return True
- def enable_signals(self):
+ def enable_signals(self, space):
pass
- def disable_signals(self):
+ def disable_signals(self, space):
pass
def getallvalues(self):
diff --git a/pypy/module/__pypy__/interp_signal.py b/pypy/module/__pypy__/interp_signal.py
--- a/pypy/module/__pypy__/interp_signal.py
+++ b/pypy/module/__pypy__/interp_signal.py
@@ -1,6 +1,6 @@
def signals_enter(space):
- space.threadlocals.enable_signals()
+ space.threadlocals.enable_signals(space)
def signals_exit(space, w_ignored1=None, w_ignored2=None, w_ignored3=None):
- space.threadlocals.disable_signals()
+ space.threadlocals.disable_signals(space)
diff --git a/pypy/module/__pypy__/test/test_signal.py b/pypy/module/__pypy__/test/test_signal.py
--- a/pypy/module/__pypy__/test/test_signal.py
+++ b/pypy/module/__pypy__/test/test_signal.py
@@ -3,18 +3,6 @@
from pypy.module.thread.test.support import GenericTestThread
-class TestThreadSignal:
- spaceconfig = dict(usemodules=['__pypy__', 'thread'])
-
- def test_exit_twice(self, space):
- from pypy.module.__pypy__.interp_signal import signals_exit, signals_enter
- signals_exit(space)
- try:
- raises(KeyError, signals_exit, space)
- finally:
- signals_enter(space)
-
-
class AppTestMinimal:
spaceconfig = dict(usemodules=['__pypy__'])
@@ -28,6 +16,14 @@
class AppTestThreadSignal(GenericTestThread):
spaceconfig = dict(usemodules=['__pypy__', 'thread', 'signal', 'time'])
+ def test_exit_twice(self):
+ from __pypy__ import thread
+ thread._signals_exit()
+ try:
+ raises(KeyError, thread._signals_exit)
+ finally:
+ thread._signals_enter()
+
def test_enable_signals(self):
import __pypy__, thread, signal, time
diff --git a/pypy/module/thread/threadlocals.py b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -1,4 +1,9 @@
from rpython.rlib import rthread
+from pypy.module.thread.error import wrap_thread_error
+from pypy.interpreter.executioncontext import ExecutionContext
+
+
+ExecutionContext._signals_enabled = 0 # default value
class OSThreadLocals:
@@ -11,12 +16,10 @@
def __init__(self):
self._valuedict = {} # {thread_ident: ExecutionContext()}
- self._signalsenabled = {} # {thread_ident: number-of-times}
self._cleanup_()
def _cleanup_(self):
self._valuedict.clear()
- self._signalsenabled.clear()
self._mainthreadident = 0
if self.can_cache:
self._mostrecentkey = 0 # fast minicaching for the common case
@@ -39,7 +42,7 @@
ident = rthread.get_ident()
if value is not None:
if len(self._valuedict) == 0:
- self._signalsenabled[ident] = 1 # the main thread is enabled
+ value._signals_enabled = 1 # the main thread is enabled
self._mainthreadident = ident
self._valuedict[ident] = value
else:
@@ -47,30 +50,26 @@
del self._valuedict[ident]
except KeyError:
pass
- try:
- del self._signalsenabled[ident]
- except KeyError:
- pass
if self.can_cache:
# update the minicache to prevent it from containing an outdated value
self._mostrecentkey = ident
self._mostrecentvalue = value
def signals_enabled(self):
- return rthread.get_ident() in self._signalsenabled
+ ec = self.getvalue()
+ return ec._signals_enabled
- def enable_signals(self):
- ident = rthread.get_ident()
- old = self._signalsenabled.get(ident, 0)
- self._signalsenabled[ident] = old + 1
+ def enable_signals(self, space):
+ ec = self.getvalue()
+ ec._signals_enabled += 1
- def disable_signals(self):
- ident = rthread.get_ident()
- new = self._signalsenabled[ident] - 1
- if new > 0:
- self._signalsenabled[ident] = new
- else:
- del self._signalsenabled[ident]
+ def disable_signals(self, space):
+ ec = self.getvalue()
+ new = ec._signals_enabled - 1
+ if new < 0:
+ raise wrap_thread_error(space,
+ "cannot disable signals in thread not enabled for signals")
+ ec._signals_enabled = new
def getallvalues(self):
return self._valuedict
@@ -85,14 +84,10 @@
def reinit_threads(self, space):
"Called in the child process after a fork()"
- # clear the _signalsenabled dictionary for all other threads
- # (which are now dead); and for the current thread, force an
- # enable_signals() if necessary. That's a hack but I cannot
- # figure out a non-hackish way to handle thread+signal+fork :-(
ident = rthread.get_ident()
- old = self._signalsenabled.get(ident, 0)
- if ident is not self._mainthreadident:
- self._mainthreadident = ident
- old += 1
- self._signalsenabled.clear()
- self._signalsenabled[ident] = old
+ ec = self.getvalue()
+ if ident != self._mainthreadident:
+ ec._signals_enabled += 1
+ self._cleanup_()
+ self.setvalue(ec)
+ self._mainthreadident = ident
diff --git a/rpython/rlib/rstruct/ieee.py b/rpython/rlib/rstruct/ieee.py
--- a/rpython/rlib/rstruct/ieee.py
+++ b/rpython/rlib/rstruct/ieee.py
@@ -255,6 +255,7 @@
l.reverse()
result.append("".join(l))
+ at jit.unroll_safe
def unpack_float(s, be):
unsigned = r_ulonglong(0)
for i in range(min(len(s), 8)):
@@ -262,6 +263,7 @@
unsigned |= r_ulonglong(c) << (i * 8)
return float_unpack(unsigned, len(s))
+ at jit.unroll_safe
def unpack_float80(s, be):
QQ = [r_ulonglong(0), r_ulonglong(0)]
for i in range(8):
More information about the pypy-commit
mailing list