Skip to content

Commit ca7ac31

Browse files
committed
pullup r17821.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/win32-unicode-test@17822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent f624127 commit ca7ac31

File tree

164 files changed

+3090
-1372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+3090
-1372
lines changed

ChangeLog

Lines changed: 683 additions & 27 deletions
Large diffs are not rendered by default.

README.EXT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ function to free the pointer allocation. If this is -1, the pointer
458458
will be just freed. The functions mark and free will be called from
459459
garbage collector.
460460

461+
These mark / free functions are invoked during GC execution. No
462+
object allocations are allowed during it, so do not allocate ruby
463+
objects inside them.
464+
461465
You can allocate and wrap the structure in one step.
462466

463467
Data_Make_Struct(klass, type, mark, free, sval)

README.EXT.ja

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ free
527527
�ؿ��������١������쥯������ƤФ�ޤ������줬-1�ξ��ϡ�ñ
528528
��˳�������ޤ���
529529

530+
mark�����free�ؿ���GC�¹���˸ƤӽФ���ޤ�.
531+
�ʤ�, GC�¹����Ruby���֥������ȤΥ������������϶ػߤ����
532+
��. ��ä�, mark�����free�ؿ���Ruby���֥������ȤΥ���������
533+
���ϹԤ�ʤ��Ǥ�������.
534+
530535
C�ι�¤�Τγ�����Data���֥������Ȥ�������Ʊ���˹Ԥ��ޥ�����
531536
���ưʲ��Τ�Τ��󶡤���Ƥ��ޤ���
532537

array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,10 +2145,10 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
21452145
break;
21462146
}
21472147
rb_ary_modify(ary);
2148-
end = beg + len;
2149-
if (end < 0) {
2148+
if (beg >= ARY_MAX_SIZE || len > ARY_MAX_SIZE - beg) {
21502149
rb_raise(rb_eArgError, "argument too big");
21512150
}
2151+
end = beg + len;
21522152
if (RARRAY_LEN(ary) < end) {
21532153
if (end >= ARY_CAPA(ary)) {
21542154
RESIZE_CAPA(ary, end);

common.mk

Lines changed: 76 additions & 136 deletions
Large diffs are not rendered by default.

compile.c

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef struct iseq_link_element {
3535
ISEQ_ELEMENT_NONE = INT2FIX(0x00),
3636
ISEQ_ELEMENT_LABEL = INT2FIX(0x01),
3737
ISEQ_ELEMENT_INSN = INT2FIX(0x02),
38-
ISEQ_ELEMENT_ADJUST = INT2FIX(0x03),
38+
ISEQ_ELEMENT_ADJUST = INT2FIX(0x03)
3939
} type;
4040
struct iseq_link_element *next;
4141
struct iseq_link_element *prev;
@@ -2291,7 +2291,7 @@ compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
22912291
}
22922292
else {
22932293
/* class at cbase Foo */
2294-
ADD_INSN(ret, nd_line(cpath), putcbase);
2294+
ADD_INSN1(ret, nd_line(cpath), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
22952295
return Qtrue;
22962296
}
22972297
}
@@ -3436,7 +3436,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
34363436
}
34373437

34383438
if (node->nd_vid) {
3439-
ADD_INSN (ret, nd_line(node), putcbase);
3439+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
34403440
ADD_INSN1(ret, nd_line(node), setconstant, ID2SYM(node->nd_vid));
34413441
}
34423442
else {
@@ -4227,12 +4227,16 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
42274227

42284228
debugp_param("defn/iseq", iseqval);
42294229

4230-
ADD_INSN (ret, nd_line(node), putnil);
4231-
ADD_INSN3(ret, nd_line(node), definemethod,
4232-
ID2SYM(node->nd_mid), iseqval, INT2FIX(0));
4233-
if (!poped) {
4234-
ADD_INSN(ret, nd_line(node), putnil);
4230+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
4231+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
4232+
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->nd_mid));
4233+
ADD_INSN1(ret, nd_line(node), putiseq, iseqval);
4234+
ADD_SEND (ret, nd_line(node), ID2SYM(id_core_define_method), INT2FIX(3));
4235+
4236+
if (poped) {
4237+
ADD_INSN(ret, nd_line(node), pop);
42354238
}
4239+
42364240
debugp_param("defn", iseqval);
42374241
break;
42384242
}
@@ -4243,41 +4247,48 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
42434247

42444248
debugp_param("defs/iseq", iseqval);
42454249

4250+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
42464251
COMPILE(ret, "defs: recv", node->nd_recv);
4247-
ADD_INSN3(ret, nd_line(node), definemethod,
4248-
ID2SYM(node->nd_mid), iseqval, INT2FIX(1));
4249-
if (!poped) {
4250-
ADD_INSN(ret, nd_line(node), putnil);
4252+
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->nd_mid));
4253+
ADD_INSN1(ret, nd_line(node), putiseq, iseqval);
4254+
ADD_SEND (ret, nd_line(node), ID2SYM(id_core_define_singleton_method), INT2FIX(3));
4255+
4256+
if (poped) {
4257+
ADD_INSN(ret, nd_line(node), pop);
42514258
}
42524259
break;
42534260
}
42544261
case NODE_ALIAS:{
4262+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
4263+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
42554264
COMPILE(ret, "alias arg1", node->u1.node);
42564265
COMPILE(ret, "alias arg2", node->u2.node);
4266+
ADD_SEND(ret, nd_line(node), ID2SYM(id_core_set_method_alias), INT2FIX(3));
42574267

4258-
ADD_INSN1(ret, nd_line(node), alias, Qfalse);
4259-
4260-
if (!poped) {
4261-
ADD_INSN(ret, nd_line(node), putnil);
4268+
if (poped) {
4269+
ADD_INSN(ret, nd_line(node), pop);
42624270
}
42634271
break;
42644272
}
42654273
case NODE_VALIAS:{
4274+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
42664275
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u1.id));
42674276
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u2.id));
4268-
ADD_INSN1(ret, nd_line(node), alias, Qtrue);
4277+
ADD_SEND(ret, nd_line(node), ID2SYM(id_core_set_variable_alias), INT2FIX(2));
42694278

4270-
if (!poped) {
4271-
ADD_INSN(ret, nd_line(node), putnil);
4279+
if (poped) {
4280+
ADD_INSN(ret, nd_line(node), pop);
42724281
}
42734282
break;
42744283
}
42754284
case NODE_UNDEF:{
4285+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
4286+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
42764287
COMPILE(ret, "undef arg", node->u2.node);
4277-
ADD_INSN(ret, nd_line(node), undef);
4288+
ADD_SEND(ret, nd_line(node), ID2SYM(id_core_undef_method), INT2FIX(2));
42784289

4279-
if (!poped) {
4280-
ADD_INSN(ret, nd_line(node), putnil);
4290+
if (poped) {
4291+
ADD_INSN(ret, nd_line(node), pop);
42814292
}
42824293
break;
42834294
}
@@ -4517,9 +4528,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
45174528
}
45184529
case NODE_POSTEXE:{
45194530
VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK);
4520-
ADD_INSN1(ret, nd_line(node), postexe, block);
4521-
if (!poped) {
4522-
ADD_INSN(ret, nd_line(node), putnil);
4531+
4532+
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
4533+
ADD_INSN1(ret, nd_line(node), putiseq, block);
4534+
ADD_SEND (ret, nd_line(node), ID2SYM(id_core_set_postexe), INT2FIX(1));
4535+
4536+
if (poped) {
4537+
ADD_INSN(ret, nd_line(node), pop);
45234538
}
45244539
break;
45254540
}
@@ -4983,22 +4998,16 @@ iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
49834998
VALUE exception, VALUE body)
49844999
{
49855000
int i;
4986-
int opt = 0;
49875001
ID *tbl;
49885002
struct st_table *labels_table = st_init_numtable();
49895003

49905004
DECL_ANCHOR(anchor);
49915005

49925006
INIT_ANCHOR(anchor);
4993-
if (iseq->type == ISEQ_TYPE_METHOD ||
4994-
iseq->type == ISEQ_TYPE_TOP ||
4995-
iseq->type == ISEQ_TYPE_CLASS) {
4996-
opt = 1;
4997-
}
49985007

4999-
iseq->local_table_size = opt + RARRAY_LEN(locals);
5008+
iseq->local_table_size = RARRAY_LEN(locals);
50005009
iseq->local_table = tbl = (ID *)ALLOC_N(ID *, iseq->local_table_size);
5001-
iseq->local_size = opt + iseq->local_table_size;
5010+
iseq->local_size = iseq->local_table_size + 1;
50025011

50035012
for (i=0; i<RARRAY_LEN(locals); i++) {
50045013
VALUE lv = RARRAY_PTR(locals)[i];
@@ -5025,7 +5034,8 @@ iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
50255034
iseq->arg_post_len = FIX2INT(arg_post_len);
50265035
iseq->arg_post_start = FIX2INT(arg_post_start);
50275036
iseq->arg_block = FIX2INT(arg_block);
5028-
iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, RARRAY_LEN(arg_opt_labels));
5037+
iseq->arg_opts = RARRAY_LEN(arg_opt_labels);
5038+
iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, iseq->arg_opts);
50295039

50305040
if (iseq->arg_block != -1) {
50315041
iseq->arg_size = iseq->arg_block + 1;
@@ -5037,7 +5047,7 @@ iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
50375047
iseq->arg_size = iseq->arg_rest + 1;
50385048
}
50395049
else {
5040-
iseq->arg_size = iseq->argc + iseq->arg_opts;
5050+
iseq->arg_size = iseq->argc + (iseq->arg_opts ? iseq->arg_opts - 1 : 0);
50415051
}
50425052

50435053
for (i=0; i<RARRAY_LEN(arg_opt_labels); i++) {

compile.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,13 @@ PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
163163
(VALUE)id, (VALUE)argc, (VALUE)block, (VALUE)flag))
164164

165165
#define ADD_TRACE(seq, line, event) \
166-
if (iseq->compile_data->option->trace_instruction) { \
166+
do { \
167+
if ((event) == RUBY_EVENT_LINE && iseq->coverage && RARRAY_PTR(iseq->coverage)[(line) - 1] == Qnil) { \
168+
RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \
169+
ADD_INSN1(seq, line, trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
170+
} \
167171
ADD_INSN1(seq, line, trace, INT2FIX(event)); \
168-
}
172+
}while(0);
169173

170174
/* add label */
171175
#define ADD_LABEL(seq, label) \

configure.in

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -766,64 +766,6 @@ AC_DEFINE_UNQUOTED([RUBY_SETJMP(env)], [${setjmp_prefix}setjmp(env${setjmp_sigma
766766
AC_DEFINE_UNQUOTED([RUBY_LONGJMP(env,val)], [${setjmp_prefix}longjmp(env,val)])
767767
AC_DEFINE_UNQUOTED(RUBY_JMP_BUF, ${setjmp_sigmask+${setjmp_prefix}}jmp_buf)
768768

769-
770-
case $target_os in
771-
*bsd*|darwin*)
772-
AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
773-
[AC_TRY_RUN([
774-
#include <stdlib.h>
775-
#include <unistd.h>
776-
#include <pthread.h>
777-
#include <stdio.h>
778-
#include <sys/types.h>
779-
#include <sys/wait.h>
780-
#include <signal.h>
781-
782-
void *
783-
thread_func(void *dmy)
784-
{
785-
return dmy;
786-
}
787-
788-
void *use_threads(void)
789-
{
790-
pthread_t tid;
791-
if (pthread_create(&tid, 0, thread_func, 0) != 0) {
792-
exit(1);
793-
}
794-
if (pthread_join(tid, 0) != 0) {
795-
exit(1);
796-
}
797-
}
798-
799-
int
800-
main(int argc, char *argv[])
801-
{
802-
pid_t pid;
803-
use_threads();
804-
pid = fork();
805-
806-
if (pid) {
807-
int loc;
808-
sleep(1);
809-
if (waitpid(pid, &loc, WNOHANG) == 0) {
810-
kill(pid, SIGKILL);
811-
return 1;
812-
}
813-
}
814-
else {
815-
use_threads();
816-
}
817-
818-
return 0;
819-
}]
820-
rb_cv_fork_with_pthread=yes,
821-
rb_cv_fork_with_pthread=no,
822-
rb_cv_fork_with_pthread=yes)])
823-
;;
824-
esac
825-
test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
826-
827769
AC_ARG_ENABLE(setreuid,
828770
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
829771
[use_setreuid=$enableval])
@@ -1161,6 +1103,69 @@ if test x"$ac_cv_header_ucontext_h" = xyes; then
11611103
fi
11621104
fi
11631105

1106+
if test "$ac_cv_func_fork" = "yes" -a "$rb_with_pthread" = "yes"; then
1107+
AC_CACHE_CHECK([if fork works with pthread], rb_cv_fork_with_pthread,
1108+
[AC_TRY_RUN([
1109+
#include <stdlib.h>
1110+
#include <unistd.h>
1111+
#include <pthread.h>
1112+
#include <stdio.h>
1113+
#include <sys/types.h>
1114+
#include <sys/wait.h>
1115+
#include <signal.h>
1116+
#ifndef EXIT_SUCCESS
1117+
#define EXIT_SUCCESS 0
1118+
#endif
1119+
#ifndef EXIT_FAILURE
1120+
#define EXIT_FAILURE 1
1121+
#endif
1122+
1123+
void *
1124+
thread_func(void *dmy)
1125+
{
1126+
return dmy;
1127+
}
1128+
1129+
int
1130+
use_threads(void)
1131+
{
1132+
pthread_t tid;
1133+
if (pthread_create(&tid, 0, thread_func, 0) != 0) {
1134+
return -1;
1135+
}
1136+
if (pthread_join(tid, 0) != 0) {
1137+
return -1;
1138+
}
1139+
return 0;
1140+
}
1141+
1142+
int
1143+
main(int argc, char *argv[])
1144+
{
1145+
pid_t pid;
1146+
if (use_threads()) return EXIT_FAILURE;
1147+
pid = fork();
1148+
1149+
if (pid) {
1150+
int loc;
1151+
sleep(1);
1152+
if (waitpid(pid, &loc, WNOHANG) == 0) {
1153+
kill(pid, SIGKILL);
1154+
return EXIT_FAILURE;
1155+
}
1156+
}
1157+
else {
1158+
if (use_threads()) return EXIT_FAILURE;
1159+
}
1160+
1161+
return EXIT_SUCCESS;
1162+
}],
1163+
rb_cv_fork_with_pthread=yes,
1164+
rb_cv_fork_with_pthread=no,
1165+
rb_cv_fork_with_pthread=yes)])
1166+
test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD)
1167+
fi
1168+
11641169
AC_CHECK_FUNCS(backtrace)
11651170

11661171
AC_ARG_WITH(valgrind,

cont.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
enum context_type {
1818
CONTINUATION_CONTEXT = 0,
1919
FIBER_CONTEXT = 1,
20-
ROOT_FIBER_CONTEXT = 2,
20+
ROOT_FIBER_CONTEXT = 2
2121
};
2222

2323
typedef struct rb_context_struct {

debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const union {
6363
RUBY_NODE_TYPEMASK = NODE_TYPEMASK,
6464
RUBY_NODE_LSHIFT = NODE_LSHIFT,
6565
RUBY_NODE_LMASK = NODE_LMASK,
66-
RUBY_NODE_FL_NEWLINE = NODE_FL_NEWLINE,
66+
RUBY_NODE_FL_NEWLINE = NODE_FL_NEWLINE
6767
} various;
6868
} dummy_gdb_enums;
6969

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy