Author: Remi Meier
Branch:
Changeset: r1109:ef9851277c7c
Date: 2014-03-27 17:54 +0100
http://bitbucket.org/pypy/stmgc/changeset/ef9851277c7c/
Log: wah, some more obvious fixes
diff --git a/htm-c7/stmgc.c b/htm-c7/stmgc.c
--- a/htm-c7/stmgc.c
+++ b/htm-c7/stmgc.c
@@ -4,8 +4,9 @@
#include "htm.h"
pthread_mutex_t _stm_gil = PTHREAD_MUTEX_INITIALIZER;
-stm_thread_local_t *_stm_tloc;
-struct stm_segment_info_s _stm_segment;
+__thread stm_thread_local_t *_stm_tloc;
+//struct stm_segment_info_s _stm_segment;
+__thread struct stm_segment_info_s* _stm_segment;
#define TRANSIENT_RETRY_MAX 5
#define GIL_RETRY_MAX 5
@@ -273,6 +274,7 @@
void stm_register_thread_local(stm_thread_local_t *tl) {
objects_pointing_to_nursery = list_create();
young_weakrefs = list_create();
+ _stm_segment = malloc(sizeof(struct stm_segment_info_s));
tl->thread_local_obj = NULL;
tl->shadowstack_base = (object_t **)malloc(768*1024);
@@ -290,6 +292,7 @@
list_free(objects_pointing_to_nursery);
list_free(young_weakrefs);
+ free(_stm_segment);
}
@@ -323,9 +326,9 @@
#define NB_NURSERY_PAGES 1024 // 4MB
#define NURSERY_SIZE (NB_NURSERY_PAGES * 4096UL)
-char *_stm_nursery_base = NULL;
-char *_stm_nursery_current = NULL;
-char *_stm_nursery_end = NULL;
+__thread char *_stm_nursery_base = NULL;
+__thread char *_stm_nursery_current = NULL;
+__thread char *_stm_nursery_end = NULL;
#define _stm_nursery_start ((uintptr_t)_stm_nursery_base)
static bool _is_in_nursery(object_t *obj)
@@ -427,7 +430,7 @@
static void throw_away_nursery(void)
{
if (_stm_nursery_base == NULL) {
- _stm_nursery_base = malloc(NURSERY_SIZE);
+ _stm_nursery_base = tl_malloc(NURSERY_SIZE);
assert(_stm_nursery_base);
_stm_nursery_end = _stm_nursery_base + NURSERY_SIZE;
_stm_nursery_current = _stm_nursery_base;
@@ -435,6 +438,7 @@
memset(_stm_nursery_base, 0, _stm_nursery_current-_stm_nursery_base);
_stm_nursery_current = _stm_nursery_base;
+ STM_SEGMENT->nursery_current = _stm_nursery_current;
}
#define WEAKREF_PTR(wr, sz) ((object_t * TLPREFIX *)(((char *)(wr)) + (sz) -
sizeof(void*)))
@@ -503,6 +507,7 @@
char *end = p + size_rounded_up;
assert(end <= _stm_nursery_end);
_stm_nursery_current = end;
+ STM_SEGMENT->nursery_current = end;
return (object_t *)p;
}
diff --git a/htm-c7/stmgc.h b/htm-c7/stmgc.h
--- a/htm-c7/stmgc.h
+++ b/htm-c7/stmgc.h
@@ -36,16 +36,17 @@
size_t mem_bytes_to_clear_on_abort; /* compat only -- always NULL */
} stm_thread_local_t;
-extern stm_thread_local_t *_stm_tloc;
-extern char *_stm_nursery_current, *_stm_nursery_end;
+extern __thread stm_thread_local_t *_stm_tloc;
+extern __thread char *_stm_nursery_current, *_stm_nursery_end;
struct stm_segment_info_s {
stm_jmpbuf_t *jmpbuf_ptr; /* compat only -- always NULL */
- char *nursery_current; /* compat only -- always NULL */
+ char *nursery_current; /* updated... */
};
-extern struct stm_segment_info_s _stm_segment;
-#define STM_SEGMENT (&_stm_segment)
+//extern struct stm_segment_info_s _stm_segment;
+extern __thread struct stm_segment_info_s *_stm_segment;
+#define STM_SEGMENT (_stm_segment)
#ifdef NDEBUG
#define OPT_ASSERT(cond) do { if (!(cond)) __builtin_unreachable(); } while (0)
@@ -75,6 +76,7 @@
char *p = _stm_nursery_current;
char *end = p + size_rounded_up;
_stm_nursery_current = end;
+ STM_SEGMENT->nursery_current = end;
if (UNLIKELY(end > _stm_nursery_end))
return _stm_allocate_slowpath(size_rounded_up);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit