[pypy-commit] pypy continulet-jit: Random progress, but I still didn't find the "correct" way...
arigo
noreply at buildbot.pypy.org
Sun Oct 16 15:10:05 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch: continulet-jit
Changeset: r48081:057d18c508bb
Date: 2011-10-16 14:54 +0200
http://bitbucket.org/pypy/pypy/changeset/057d18c508bb/
Log: Random progress, but I still didn't find the "correct" way...
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
@@ -25,6 +25,7 @@
thread_handle = rffi.COpaquePtr(typedef='stacklet_thread_handle',
compilation_info=eci)
run_fn = lltype.Ptr(lltype.FuncType([handle, llmemory.Address], handle))
+id = rffi.COpaquePtr(typedef='stacklet_id', compilation_info=eci)
# ----- constants -----
@@ -47,3 +48,5 @@
_translate_pointer = llexternal("_stacklet_translate_pointer",
[llmemory.Address, llmemory.Address],
llmemory.Address)
+_stacklet_with_id = llexternal("_stacklet_with_id", [thread_handle, id],
+ handle)
diff --git a/pypy/rlib/rstacklet.py b/pypy/rlib/rstacklet.py
--- a/pypy/rlib/rstacklet.py
+++ b/pypy/rlib/rstacklet.py
@@ -10,6 +10,7 @@
@jit.dont_look_inside
def __init__(self, config):
+ stacklet_thread_global.enable()
self._gcrootfinder = _getgcrootfinder(config, we_are_translated())
self._thrd = _c.newthread()
if not self._thrd:
@@ -66,6 +67,19 @@
self._thrd = lltype.nullptr(_c.thread_handle.TO)
_c.deletethread(thrd)
+class StackletThreadGlobal(object):
+ _immutable_fields_ = ['enabled?']
+
+ def _freeze_(self):
+ self.enabled = False
+
+ def enable(self):
+ if not self.enabled:
+ self.enabled = True # change the quasi-immutable field
+
+stacklet_thread_global = StackletThreadGlobal()
+stacklet_thread_global._freeze_()
+
# ____________________________________________________________
def _getgcrootfinder(config, translated):
diff --git a/pypy/translator/c/src/stacklet/stacklet.c b/pypy/translator/c/src/stacklet/stacklet.c
--- a/pypy/translator/c/src/stacklet/stacklet.c
+++ b/pypy/translator/c/src/stacklet/stacklet.c
@@ -344,7 +344,8 @@
break;
}
assert(target->id->stacklet == target);
- free(target->id);
+ if (target->id != &thrd->g_main_id)
+ free(target->id);
free(target);
}
@@ -370,10 +371,3 @@
}
return ptr;
}
-
-stacklet_handle _stacklet_with_id(stacklet_thread_handle thrd, stacklet_id id)
-{
- if (id == NULL)
- id = &thrd->g_main_id;
- return id->stacklet;
-}
diff --git a/pypy/translator/c/src/stacklet/stacklet.h b/pypy/translator/c/src/stacklet/stacklet.h
--- a/pypy/translator/c/src/stacklet/stacklet.h
+++ b/pypy/translator/c/src/stacklet/stacklet.h
@@ -67,7 +67,9 @@
#define _stacklet_id_of_stacklet(stacklet) (*(stacklet_id*)(stacklet))
#define _stacklet_id_current(thrd) (*(stacklet_id*)(thrd))
/* Returns the current stacklet with the given id.
- If 'id' == NULL, returns the main stacklet in the thread. */
+ If 'id' == NULL, returns the main stacklet in the thread.
+ In both cases the return value is NULL if the id specifies the currently
+ running "stacklet". */
stacklet_handle _stacklet_with_id(stacklet_thread_handle thrd, stacklet_id id);
#endif /* _STACKLET_H_ */
More information about the pypy-commit
mailing list