summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--common.mk8
-rw-r--r--regcomp.c9
-rw-r--r--regint.h6
-rw-r--r--regparse.c93
-rw-r--r--ruby_atomic.h5
6 files changed, 50 insertions, 80 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e200e97d0..f7a6a25cda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,15 +6,6 @@ Wed Dec 9 16:10:37 2015 Koichi Sasada <ko1@atdot.net>
* test/ruby/test_method.rb: add a test.
-Wed Dec 9 15:48:12 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * regcomp.c (onig_chain_link_add): use atomic operation instead of
- mutex.
-
- * regint.h (ONIG_STATE_{INC,DEC}_THREAD): ditto.
-
- * regparse.c (PopFreeNode, node_recycle): ditto.
-
Wed Dec 9 14:45:27 2015 Koichi Sasada <ko1@atdot.net>
* gc.c (gc_mark_stacked_objects): fix typo.
diff --git a/common.mk b/common.mk
index 78127429c9..dde72e30ee 100644
--- a/common.mk
+++ b/common.mk
@@ -1345,7 +1345,6 @@ enc/unicode.$(OBJEXT): {$(VPATH)}missing.h
enc/unicode.$(OBJEXT): {$(VPATH)}oniguruma.h
enc/unicode.$(OBJEXT): {$(VPATH)}regenc.h
enc/unicode.$(OBJEXT): {$(VPATH)}regint.h
-enc/unicode.$(OBJEXT): {$(VPATH)}ruby_atomic.h
enc/unicode.$(OBJEXT): {$(VPATH)}st.h
enc/unicode.$(OBJEXT): {$(VPATH)}subst.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}config.h
@@ -1988,7 +1987,6 @@ re.$(OBJEXT): {$(VPATH)}re.h
re.$(OBJEXT): {$(VPATH)}regenc.h
re.$(OBJEXT): {$(VPATH)}regex.h
re.$(OBJEXT): {$(VPATH)}regint.h
-re.$(OBJEXT): {$(VPATH)}ruby_atomic.h
re.$(OBJEXT): {$(VPATH)}st.h
re.$(OBJEXT): {$(VPATH)}subst.h
re.$(OBJEXT): {$(VPATH)}util.h
@@ -2001,7 +1999,6 @@ regcomp.$(OBJEXT): {$(VPATH)}oniguruma.h
regcomp.$(OBJEXT): {$(VPATH)}regcomp.c
regcomp.$(OBJEXT): {$(VPATH)}regenc.h
regcomp.$(OBJEXT): {$(VPATH)}regint.h
-regcomp.$(OBJEXT): {$(VPATH)}ruby_atomic.h
regcomp.$(OBJEXT): {$(VPATH)}regparse.h
regcomp.$(OBJEXT): {$(VPATH)}st.h
regcomp.$(OBJEXT): {$(VPATH)}subst.h
@@ -2014,7 +2011,6 @@ regenc.$(OBJEXT): {$(VPATH)}oniguruma.h
regenc.$(OBJEXT): {$(VPATH)}regenc.c
regenc.$(OBJEXT): {$(VPATH)}regenc.h
regenc.$(OBJEXT): {$(VPATH)}regint.h
-regenc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
regenc.$(OBJEXT): {$(VPATH)}st.h
regenc.$(OBJEXT): {$(VPATH)}subst.h
regerror.$(OBJEXT): $(hdrdir)/ruby/ruby.h
@@ -2026,7 +2022,6 @@ regerror.$(OBJEXT): {$(VPATH)}oniguruma.h
regerror.$(OBJEXT): {$(VPATH)}regenc.h
regerror.$(OBJEXT): {$(VPATH)}regerror.c
regerror.$(OBJEXT): {$(VPATH)}regint.h
-regerror.$(OBJEXT): {$(VPATH)}ruby_atomic.h
regerror.$(OBJEXT): {$(VPATH)}st.h
regerror.$(OBJEXT): {$(VPATH)}subst.h
regexec.$(OBJEXT): $(hdrdir)/ruby/ruby.h
@@ -2038,7 +2033,6 @@ regexec.$(OBJEXT): {$(VPATH)}oniguruma.h
regexec.$(OBJEXT): {$(VPATH)}regenc.h
regexec.$(OBJEXT): {$(VPATH)}regexec.c
regexec.$(OBJEXT): {$(VPATH)}regint.h
-regexec.$(OBJEXT): {$(VPATH)}ruby_atomic.h
regexec.$(OBJEXT): {$(VPATH)}st.h
regexec.$(OBJEXT): {$(VPATH)}subst.h
regparse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
@@ -2051,7 +2045,6 @@ regparse.$(OBJEXT): {$(VPATH)}regenc.h
regparse.$(OBJEXT): {$(VPATH)}regint.h
regparse.$(OBJEXT): {$(VPATH)}regparse.c
regparse.$(OBJEXT): {$(VPATH)}regparse.h
-regparse.$(OBJEXT): {$(VPATH)}ruby_atomic.h
regparse.$(OBJEXT): {$(VPATH)}st.h
regparse.$(OBJEXT): {$(VPATH)}subst.h
regsyntax.$(OBJEXT): $(hdrdir)/ruby/ruby.h
@@ -2063,7 +2056,6 @@ regsyntax.$(OBJEXT): {$(VPATH)}oniguruma.h
regsyntax.$(OBJEXT): {$(VPATH)}regenc.h
regsyntax.$(OBJEXT): {$(VPATH)}regint.h
regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c
-regsyntax.$(OBJEXT): {$(VPATH)}ruby_atomic.h
regsyntax.$(OBJEXT): {$(VPATH)}st.h
regsyntax.$(OBJEXT): {$(VPATH)}subst.h
ruby.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
diff --git a/regcomp.c b/regcomp.c
index 176aa6b8ef..23cb0ead9a 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5663,11 +5663,10 @@ onig_transfer(regex_t* to, regex_t* from)
extern void
onig_chain_link_add(regex_t* to, regex_t* add)
{
- /* THREAD_ATOMIC_START; */
- do {
- REGEX_CHAIN_HEAD(to);
- } while (IS_NOT_NULL(ATOMIC_PTR_CAS(to->chain, (regex_t* )NULL, add)));
- /* THREAD_ATOMIC_END; */
+ THREAD_ATOMIC_START;
+ REGEX_CHAIN_HEAD(to);
+ to->chain = add;
+ THREAD_ATOMIC_END;
}
extern void
diff --git a/regint.h b/regint.h
index 79867f7b6d..9fda5509a9 100644
--- a/regint.h
+++ b/regint.h
@@ -95,7 +95,6 @@
#ifndef RUBY_DEFINES_H
#include "ruby/ruby.h"
-#include "ruby_atomic.h"
#undef xmalloc
#undef xrealloc
#undef xcalloc
@@ -239,10 +238,6 @@ extern pthread_mutex_t gOnigMutex;
#define ONIG_STATE_INC(reg) (reg)->state++
#define ONIG_STATE_DEC(reg) (reg)->state--
-#if SIZEOF_ATOMIC_T == SIZEOF_INT
-#define ONIG_STATE_INC_THREAD(reg) (ATOMIC_INC((reg)->state))
-#define ONIG_STATE_DEC_THREAD(reg) (ATOMIC_DEC((reg)->state))
-#else
#define ONIG_STATE_INC_THREAD(reg) do {\
THREAD_ATOMIC_START;\
(reg)->state++;\
@@ -253,7 +248,6 @@ extern pthread_mutex_t gOnigMutex;
(reg)->state--;\
THREAD_ATOMIC_END;\
} while(0)
-#endif
#else
#define ONIG_STATE_INC(reg) /* Nothing */
#define ONIG_STATE_DEC(reg) /* Nothing */
diff --git a/regparse.c b/regparse.c
index 0baf02c145..094332f90e 100644
--- a/regparse.c
+++ b/regparse.c
@@ -1031,43 +1031,7 @@ typedef struct _FreeNode {
} FreeNode;
static FreeNode* FreeNodeList = (FreeNode* )NULL;
-
-#define PopFreeNode(n, popped) \
- do { \
- FreeNode* n = FreeNodeList; \
- while (IS_NOT_NULL(n)) { \
- FreeNode* next = n->next; \
- FreeNode *head = ATOMIC_PTR_CAS(FreeNodeList, n, next); \
- if (head == n) { \
- popped; \
- n = next; \
- } \
- else { \
- n = head; /* modified, retry */ \
- } \
- } \
- } while (0)
-
-#endif
-
-static void
-node_recycle(Node* node)
-{
-#ifdef USE_PARSE_TREE_NODE_RECYCLE
- FreeNode* n = (FreeNode* )node;
- FreeNode* list = FreeNodeList;
- FreeNode* l;
-
- /* THREAD_ATOMIC_START; */
- do {
- n->next = l = list;
- list = ATOMIC_PTR_CAS(FreeNodeList, list, n);
- } while (list != l);
- /* THREAD_ATOMIC_END; */
-#else
- xfree(node);
#endif
-}
extern void
onig_node_free(Node* node)
@@ -1089,7 +1053,18 @@ onig_node_free(Node* node)
{
Node* next_node = NCDR(node);
- node_recycle(node);
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+ {
+ FreeNode* n = (FreeNode* )node;
+
+ THREAD_ATOMIC_START;
+ n->next = FreeNodeList;
+ FreeNodeList = n;
+ THREAD_ATOMIC_END;
+ }
+#else
+ xfree(node);
+#endif
node = next_node;
goto start;
}
@@ -1126,15 +1101,32 @@ onig_node_free(Node* node)
break;
}
- node_recycle(node);
+#ifdef USE_PARSE_TREE_NODE_RECYCLE
+ {
+ FreeNode* n = (FreeNode* )node;
+
+ THREAD_ATOMIC_START;
+ n->next = FreeNodeList;
+ FreeNodeList = n;
+ THREAD_ATOMIC_END;
+ }
+#else
+ xfree(node);
+#endif
}
#ifdef USE_PARSE_TREE_NODE_RECYCLE
extern int
onig_free_node_list(void)
{
+ FreeNode* n;
+
/* THREAD_ATOMIC_START; */
- PopFreeNode(n, xfree(n));
+ while (IS_NOT_NULL(FreeNodeList)) {
+ n = FreeNodeList;
+ FreeNodeList = FreeNodeList->next;
+ xfree(n);
+ }
/* THREAD_ATOMIC_END; */
return 0;
}
@@ -1146,9 +1138,14 @@ node_new(void)
Node* node;
#ifdef USE_PARSE_TREE_NODE_RECYCLE
- /* THREAD_ATOMIC_START; */
- PopFreeNode(n, return (Node* )n);
- /* THREAD_ATOMIC_END; */
+ THREAD_ATOMIC_START;
+ if (IS_NOT_NULL(FreeNodeList)) {
+ node = (Node* )FreeNodeList;
+ FreeNodeList = FreeNodeList->next;
+ THREAD_ATOMIC_END;
+ return node;
+ }
+ THREAD_ATOMIC_END;
#endif
node = (Node* )xmalloc(sizeof(Node));
@@ -1158,14 +1155,17 @@ node_new(void)
#if defined(USE_MULTI_THREAD_SYSTEM) && \
defined(USE_SHARED_CCLASS_TABLE) && \
- defined(USE_PARSE_TREE_NODE_RECYCLE) && \
- 0
+ defined(USE_PARSE_TREE_NODE_RECYCLE)
static Node*
node_new_locked(void)
{
Node* node;
- PopFreeNode(n, return (Node* )n);
+ if (IS_NOT_NULL(FreeNodeList)) {
+ node = (Node* )FreeNodeList;
+ FreeNodeList = FreeNodeList->next;
+ return node;
+ }
node = (Node* )xmalloc(sizeof(Node));
/* xmemset(node, 0, sizeof(Node)); */
@@ -1195,8 +1195,7 @@ node_new_cclass(void)
#if defined(USE_MULTI_THREAD_SYSTEM) && \
defined(USE_SHARED_CCLASS_TABLE) && \
- defined(USE_PARSE_TREE_NODE_RECYCLE) && \
- 0
+ defined(USE_PARSE_TREE_NODE_RECYCLE)
static Node*
node_new_cclass_locked(void)
{
diff --git a/ruby_atomic.h b/ruby_atomic.h
index 52b93efbd1..4bc9f37e0d 100644
--- a/ruby_atomic.h
+++ b/ruby_atomic.h
@@ -42,7 +42,6 @@ typedef unsigned int rb_atomic_t; /* Anything OK */
#pragma intrinsic(_InterlockedOr)
#endif
typedef LONG rb_atomic_t;
-#define SIZEOF_ATOMIC_T SIZEOF_LONG
# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
# define ATOMIC_INC(var) InterlockedIncrement(&(var))
@@ -144,10 +143,6 @@ ruby_atomic_size_exchange(size_t *ptr, size_t val)
}
#endif
-#ifndef SIZEOF_ATOMIC_T
-#define SIZEOF_ATOMIC_T SIZEOF_INT
-#endif
-
#ifndef ATOMIC_SIZE_INC
# define ATOMIC_SIZE_INC(var) ATOMIC_INC(var)
#endif