[pypy-commit] pypy stacklet: backout ceb960318243 and 165a28e7d8ad, will use the
arigo
noreply at buildbot.pypy.org
Tue Aug 9 09:31:56 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: stacklet
Changeset: r46389:23f4df289c80
Date: 2011-08-09 09:33 +0200
http://bitbucket.org/pypy/pypy/changeset/23f4df289c80/
Log: backout ceb960318243 and 165a28e7d8ad, will use the cleaner approach
in the branch effectinfo-cleanup.
diff --git a/pypy/jit/codewriter/call.py b/pypy/jit/codewriter/call.py
--- a/pypy/jit/codewriter/call.py
+++ b/pypy/jit/codewriter/call.py
@@ -6,8 +6,8 @@
from pypy.jit.codewriter import support
from pypy.jit.codewriter.jitcode import JitCode
from pypy.jit.codewriter.effectinfo import (VirtualizableAnalyzer,
- QuasiImmutAnalyzer, HasRandomConsequencesOnGcObjectsAnalyzer,
- effectinfo_from_writeanalyze, EffectInfo, CallInfoCollection)
+ QuasiImmutAnalyzer, CanReleaseGILAnalyzer, effectinfo_from_writeanalyze,
+ EffectInfo, CallInfoCollection)
from pypy.translator.simplify import get_funcobj, get_functype
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.translator.backendopt.canraise import RaiseAnalyzer
@@ -31,8 +31,7 @@
self.readwrite_analyzer = ReadWriteAnalyzer(translator)
self.virtualizable_analyzer = VirtualizableAnalyzer(translator)
self.quasiimmut_analyzer = QuasiImmutAnalyzer(translator)
- self.hasrandomconsequencesongcobject_analyzer = (
- HasRandomConsequencesOnGcObjectsAnalyzer(translator))
+ self.canreleasegil_analyzer = CanReleaseGILAnalyzer(translator)
#
for index, jd in enumerate(jitdrivers_sd):
jd.index = index
@@ -220,9 +219,9 @@
assert not NON_VOID_ARGS, ("arguments not supported for "
"loop-invariant function!")
# build the extraeffect
- has_random_c = self.hasrandomconsequencesongcobject_analyzer.analyze(op)
- # has_random_c implies can_invalidate
- can_invalidate = has_random_c or self.quasiimmut_analyzer.analyze(op)
+ can_release_gil = self.canreleasegil_analyzer.analyze(op)
+ # can_release_gil implies can_invalidate
+ can_invalidate = can_release_gil or self.quasiimmut_analyzer.analyze(op)
if extraeffect is None:
if self.virtualizable_analyzer.analyze(op):
extraeffect = EffectInfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
@@ -240,7 +239,7 @@
#
effectinfo = effectinfo_from_writeanalyze(
self.readwrite_analyzer.analyze(op), self.cpu, extraeffect,
- oopspecindex, can_invalidate, has_random_c)
+ oopspecindex, can_invalidate, can_release_gil)
#
if oopspecindex != EffectInfo.OS_NONE:
assert effectinfo is not None
diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -80,8 +80,7 @@
write_descrs_fields, write_descrs_arrays,
extraeffect=EF_CAN_RAISE,
oopspecindex=OS_NONE,
- can_invalidate=False,
- has_random_consequences_on_gc_objects=False):
+ can_invalidate=False, can_release_gil=False):
key = (frozenset(readonly_descrs_fields),
frozenset(readonly_descrs_arrays),
frozenset(write_descrs_fields),
@@ -89,7 +88,7 @@
extraeffect,
oopspecindex,
can_invalidate,
- has_random_consequences_on_gc_objects)
+ can_release_gil)
if key in cls._cache:
return cls._cache[key]
result = object.__new__(cls)
@@ -105,13 +104,8 @@
result.write_descrs_arrays = write_descrs_arrays
result.extraeffect = extraeffect
result.can_invalidate = can_invalidate
- result.has_random_consequences_on_gc_objects = (
- has_random_consequences_on_gc_objects)
+ result.can_release_gil = can_release_gil
result.oopspecindex = oopspecindex
- #
- if oopspecindex == EffectInfo.OS_LIBFFI_CALL:
- assert has_random_consequences_on_gc_objects
- #
cls._cache[key] = result
return result
@@ -122,13 +116,13 @@
return self.extraeffect >= self.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE
def has_random_effects(self):
- return self.has_random_consequences_on_gc_objects
+ return self.oopspecindex == self.OS_LIBFFI_CALL or self.can_release_gil
def effectinfo_from_writeanalyze(effects, cpu,
extraeffect=EffectInfo.EF_CAN_RAISE,
oopspecindex=EffectInfo.OS_NONE,
can_invalidate=False,
- has_random_consequences_on_gc_objects=False):
+ can_release_gil=False):
from pypy.translator.backendopt.writeanalyze import top_set
if effects is top_set:
return None
@@ -171,7 +165,7 @@
extraeffect,
oopspecindex,
can_invalidate,
- has_random_consequences_on_gc_objects)
+ can_release_gil)
def consider_struct(TYPE, fieldname):
if fieldType(TYPE, fieldname) is lltype.Void:
@@ -207,13 +201,12 @@
def analyze_simple_operation(self, op, graphinfo):
return op.opname == 'jit_force_quasi_immutable'
-class HasRandomConsequencesOnGcObjectsAnalyzer(BoolGraphAnalyzer):
+class CanReleaseGILAnalyzer(BoolGraphAnalyzer):
def analyze_direct_call(self, graph, seen=None):
+ releases_gil = False
if hasattr(graph, "func") and hasattr(graph.func, "_ptr"):
- if graph.func._ptr._obj.has_random_consequences_on_gc_objects:
- return True
- return (super(HasRandomConsequencesOnGcObjectsAnalyzer, self)
- .analyze_direct_call(graph, seen))
+ releases_gil = graph.func._ptr._obj.releases_gil
+ return releases_gil or super(CanReleaseGILAnalyzer, self).analyze_direct_call(graph, seen)
def analyze_simple_operation(self, op, graphinfo):
return False
diff --git a/pypy/jit/codewriter/test/test_call.py b/pypy/jit/codewriter/test/test_call.py
--- a/pypy/jit/codewriter/test/test_call.py
+++ b/pypy/jit/codewriter/test/test_call.py
@@ -191,4 +191,4 @@
[block, _] = list(f_graph.iterblocks())
[op] = block.operations
call_descr = cc.getcalldescr(op)
- assert call_descr.extrainfo.has_random_consequences_on_gc_objects
+ assert call_descr.extrainfo.can_release_gil
\ No newline at end of file
diff --git a/pypy/rlib/_rffi_stacklet.py b/pypy/rlib/_rffi_stacklet.py
--- a/pypy/rlib/_rffi_stacklet.py
+++ b/pypy/rlib/_rffi_stacklet.py
@@ -13,9 +13,9 @@
separate_module_sources = ['#include "src/stacklet/stacklet.c"\n'],
)
-def llexternal(name, args, result, **kwds):
+def llexternal(name, args, result):
return rffi.llexternal(name, args, result, compilation_info=eci,
- _nowrapper=True, **kwds)
+ _nowrapper=True)
# ----- types -----
@@ -37,9 +37,8 @@
deletethread = llexternal('stacklet_deletethread',[thread_handle], lltype.Void)
new = llexternal('stacklet_new', [thread_handle, run_fn, llmemory.Address],
- handle, has_random_consequences_on_gc_objects=True)
-switch = llexternal('stacklet_switch', [thread_handle, handle], handle,
- has_random_consequences_on_gc_objects=True)
+ handle)
+switch = llexternal('stacklet_switch', [thread_handle, handle], handle)
destroy = llexternal('stacklet_destroy', [thread_handle, handle], lltype.Void)
_translate_pointer = llexternal("_stacklet_translate_pointer",
diff --git a/pypy/rlib/clibffi.py b/pypy/rlib/clibffi.py
--- a/pypy/rlib/clibffi.py
+++ b/pypy/rlib/clibffi.py
@@ -303,9 +303,7 @@
else:
c_ffi_call_return_type = lltype.Void
c_ffi_call = external('ffi_call', [FFI_CIFP, rffi.VOIDP, rffi.VOIDP,
- VOIDPP], c_ffi_call_return_type,
- has_random_consequences_on_gc_objects=True)
- #^^^ but should be automatic for now: it releases the GIL
+ VOIDPP], c_ffi_call_return_type)
CALLBACK_TP = rffi.CCallback([FFI_CIFP, rffi.VOIDP, rffi.VOIDPP, rffi.VOIDP],
lltype.Void)
c_ffi_prep_closure = external('ffi_prep_closure', [FFI_CLOSUREP, FFI_CIFP,
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
@@ -56,7 +56,6 @@
sandboxsafe=False, threadsafe='auto',
_nowrapper=False, calling_conv='c',
oo_primitive=None, elidable_function=False,
- has_random_consequences_on_gc_objects='auto',
macro=None):
"""Build an external function that will invoke the C function 'name'
with the given 'args' types and 'result' type.
@@ -113,19 +112,13 @@
# sandboxsafe is a hint for "too-small-ness" (e.g. math functions).
invoke_around_handlers = not sandboxsafe
- if has_random_consequences_on_gc_objects not in (False, True):
- has_random_consequences_on_gc_objects = (
- invoke_around_handlers or # because it can release the GIL
- has_callback) # because the callback can do it
-
funcptr = lltype.functionptr(ext_type, name, external='C',
compilation_info=compilation_info,
_callable=_callable,
_safe_not_sandboxed=sandboxsafe,
_debugexc=True, # on top of llinterp
canraise=False,
- has_random_consequences_on_gc_objects=
- has_random_consequences_on_gc_objects,
+ releases_gil=invoke_around_handlers,
**kwds)
if isinstance(_callable, ll2ctypes.LL2CtypesCallable):
_callable.funcptr = funcptr
@@ -1075,4 +1068,4 @@
[VOIDP, VOIDP, SIZE_T],
lltype.Void,
threadsafe=False
-)
+)
\ No newline at end of file
More information about the pypy-commit
mailing list