[前][次][番号順一覧][スレッド一覧]

ruby-changes:26543

From: ko1 <ko1@a...>
Date: Tue, 25 Dec 2012 18:57:20 +0900 (JST)
Subject: [ruby-changes:26543] ko1:r38594 (trunk): * vm_core.h, eval_intern.h (CHECK_STACK_OVERFLOW): move

ko1	2012-12-25 18:57:07 +0900 (Tue, 25 Dec 2012)

  New Revision: 38594

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38594

  Log:
    * vm_core.h, eval_intern.h (CHECK_STACK_OVERFLOW): move
      CHECK_STACK_OVERFLOW() to vm_core.h and rename to
      CHECK_VM_STACK_OVERFLOW().
      This change is only move and rename.
    * tool/instruction.rb: catch up above changes.
    * vm.c, vm_insnhelper.c: ditto.
    * vm_insnhelper.c (vm_stackoverflow): add a function to unify
      raising vm stackoverflow exception.

  Modified files:
    trunk/ChangeLog
    trunk/eval_intern.h
    trunk/tool/instruction.rb
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_eval.c
    trunk/vm_insnhelper.c

Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 38593)
+++ eval_intern.h	(revision 38594)
@@ -153,12 +153,6 @@ enum ruby_tag_type { https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L153
 #define SCOPE_CHECK(f) (rb_vm_cref()->nd_visi == (f))
 #define SCOPE_SET(f)   (rb_vm_cref()->nd_visi = (f))
 
-#define CHECK_STACK_OVERFLOW(cfp, margin) do \
-  if ((VALUE *)((char *)(((VALUE *)(cfp)->sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \
-      rb_exc_raise(sysstack_error); \
-  } \
-while (0)
-
 void rb_thread_cleanup(void);
 void rb_thread_wait_other_threads(void);
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38593)
+++ ChangeLog	(revision 38594)
@@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 25 18:53:35 2012  Koichi Sasada  <ko1@a...>
+
+	* vm_core.h, eval_intern.h (CHECK_STACK_OVERFLOW): move
+	  CHECK_STACK_OVERFLOW() to vm_core.h and rename to
+	  CHECK_VM_STACK_OVERFLOW().
+	  This change is only move and rename.
+
+	* tool/instruction.rb: catch up above changes.
+
+	* vm.c, vm_insnhelper.c: ditto.
+
+	* vm_insnhelper.c (vm_stackoverflow): add a function to unify
+	  raising vm stackoverflow exception.
+
 Tue Dec 25 16:16:54 2012  Koichi Sasada  <ko1@a...>
 
 	* vm_core.h (RUBY_VM_THREAD_VM_STACK_SIZE): change default
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 38593)
+++ vm_core.h	(revision 38594)
@@ -853,6 +853,12 @@ int rb_autoloading_value(VALUE mod, ID i https://github.com/ruby/ruby/blob/trunk/vm_core.h#L853
 
 #define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
 
+#define CHECK_VM_STACK_OVERFLOW(cfp, margin) do \
+  if ((VALUE *)((char *)(((VALUE *)(cfp)->sp) + (margin)) + sizeof(rb_control_frame_t)) >= ((VALUE *)(cfp))) { \
+      vm_stackoverflow(); \
+  } \
+while (0)
+
 /* for thread */
 
 #if RUBY_VM_THREAD_MODEL == 2
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 38593)
+++ vm_eval.c	(revision 38594)
@@ -156,7 +156,7 @@ vm_call0_body(rb_thread_t* th, rb_call_i https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L156
 	    rb_control_frame_t *reg_cfp = th->cfp;
 	    int i;
 
-	    CHECK_STACK_OVERFLOW(reg_cfp, ci->argc + 1);
+	    CHECK_VM_STACK_OVERFLOW(reg_cfp, ci->argc + 1);
 
 	    *reg_cfp->sp++ = ci->recv;
 	    for (i = 0; i < ci->argc; i++) {
@@ -1212,7 +1212,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1212
 	}
 
 	/* kick */
-	CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max);
+	CHECK_VM_STACK_OVERFLOW(th->cfp, iseq->stack_max);
 	result = vm_exec(th);
     }
     TH_POP_TAG();
Index: vm.c
===================================================================
--- vm.c	(revision 38593)
+++ vm.c	(revision 38594)
@@ -143,7 +143,7 @@ vm_set_top_stack(rb_thread_t * th, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L143
     }
 
     /* for return */
-    CHECK_STACK_OVERFLOW(th->cfp, iseq->local_size + iseq->stack_max);
+    CHECK_VM_STACK_OVERFLOW(th->cfp, iseq->local_size + iseq->stack_max);
     vm_push_frame(th, iseq, VM_FRAME_MAGIC_TOP | VM_FRAME_FLAG_FINISH,
 		  th->top_self, rb_cObject, VM_ENVVAL_BLOCK_PTR(0),
 		  iseq->iseq_encoded, th->cfp->sp, iseq->local_size, 0);
@@ -155,7 +155,7 @@ vm_set_eval_stack(rb_thread_t * th, VALU https://github.com/ruby/ruby/blob/trunk/vm.c#L155
     rb_iseq_t *iseq;
     GetISeqPtr(iseqval, iseq);
 
-    CHECK_STACK_OVERFLOW(th->cfp, iseq->local_size + iseq->stack_max);
+    CHECK_VM_STACK_OVERFLOW(th->cfp, iseq->local_size + iseq->stack_max);
     vm_push_frame(th, iseq, VM_FRAME_MAGIC_EVAL | VM_FRAME_FLAG_FINISH,
 		  base_block->self, base_block->klass,
 		  VM_ENVVAL_PREV_EP_PTR(base_block->ep), iseq->iseq_encoded,
@@ -612,7 +612,7 @@ invoke_block_from_c(rb_thread_t *th, con https://github.com/ruby/ruby/blob/trunk/vm.c#L612
 	  VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK;
 
 	cfp = th->cfp;
-	CHECK_STACK_OVERFLOW(cfp, argc + iseq->stack_max);
+	CHECK_VM_STACK_OVERFLOW(cfp, argc + iseq->stack_max);
 
 	for (i=0; i<argc; i++) {
 	    cfp->sp[i] = argv[i];
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 38593)
+++ vm_insnhelper.c	(revision 38594)
@@ -24,6 +24,12 @@ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L24
 
 static rb_control_frame_t *vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
 
+static void
+vm_stackoverflow(void)
+{
+    rb_exc_raise(sysstack_error);
+}
+
 static inline rb_control_frame_t *
 vm_push_frame(rb_thread_t *th,
 	      const rb_iseq_t *iseq,
@@ -41,7 +47,7 @@ vm_push_frame(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L47
 
     /* check stack overflow */
     if ((void *)(sp + local_size) >= (void *)cfp) {
-	rb_exc_raise(sysstack_error);
+	vm_stackoverflow();
     }
     th->cfp = cfp;
 
@@ -1048,7 +1054,7 @@ vm_caller_setup_args(const rb_thread_t * https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1054
 	    ptr = RARRAY_PTR(tmp);
 	    cfp->sp -= 1;
 
-	    CHECK_STACK_OVERFLOW(cfp, len);
+	    CHECK_VM_STACK_OVERFLOW(cfp, len);
 
 	    for (i = 0; i < len; i++) {
 		*cfp->sp++ = ptr[i];
@@ -1209,7 +1215,7 @@ vm_call_iseq_setup_normal(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1215
     rb_iseq_t *iseq = ci->me->def->body.iseq;
     VALUE *sp = argv + iseq->arg_size;
 
-    CHECK_STACK_OVERFLOW(cfp, iseq->stack_max);
+    CHECK_VM_STACK_OVERFLOW(cfp, iseq->stack_max);
 
     /* clear local variables */
     for (i = 0; i < iseq->local_size - iseq->arg_size; i++) {
@@ -1236,7 +1242,7 @@ vm_call_iseq_setup_tailcall(rb_thread_t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1242
 
     cfp = th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); /* pop cf */
 
-    CHECK_STACK_OVERFLOW(cfp, iseq->stack_max);
+    CHECK_VM_STACK_OVERFLOW(cfp, iseq->stack_max);
     RUBY_VM_CHECK_INTS(th);
 
     sp_orig = sp = cfp->sp;
@@ -1633,7 +1639,7 @@ vm_call_method_missing(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1639
     ci_entry.me = rb_method_entry(CLASS_OF(ci_entry.recv), idMethodMissing, &ci_entry.defined_class);
 
     /* shift arguments: m(a, b, c) #=> method_missing(:m, a, b, c) */
-    CHECK_STACK_OVERFLOW(reg_cfp, 1);
+    CHECK_VM_STACK_OVERFLOW(reg_cfp, 1);
     if (ci->argc > 0) {
 	MEMMOVE(argv+1, argv, VALUE, ci->argc);
     }
@@ -2090,7 +2096,7 @@ vm_yield_setup_block_args(rb_thread_t *t https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2096
 	argc == 1 && !NIL_P(ary = rb_check_array_type(arg0))) { /* rhs is only an array */
 	th->mark_stack_len = argc = RARRAY_LENINT(ary);
 
-	CHECK_STACK_OVERFLOW(th->cfp, argc);
+	CHECK_VM_STACK_OVERFLOW(th->cfp, argc);
 
 	MEMCPY(argv, RARRAY_PTR(ary), VALUE, argc);
     }
@@ -2208,7 +2214,7 @@ vm_invoke_block(rb_thread_t *th, rb_cont https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2214
 	VALUE * const rsp = GET_SP() - ci->argc;
 	SET_SP(rsp);
 
-	CHECK_STACK_OVERFLOW(GET_CFP(), iseq->stack_max);
+	CHECK_VM_STACK_OVERFLOW(GET_CFP(), iseq->stack_max);
 	opt_pc = vm_yield_setup_args(th, iseq, ci->argc, rsp, 0, block_proc_is_lambda(block->proc));
 
 	vm_push_frame(th, iseq, VM_FRAME_MAGIC_BLOCK, block->self,
Index: tool/instruction.rb
===================================================================
--- tool/instruction.rb	(revision 38593)
+++ tool/instruction.rb	(revision 38594)
@@ -692,7 +692,7 @@ class RubyVM https://github.com/ruby/ruby/blob/trunk/tool/instruction.rb#L692
 
       n = 0
       push_ba.each {|pushs| n += pushs.length}
-      commit "  CHECK_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
+      commit "  CHECK_VM_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
       push_ba.each{|pushs|
         pushs.each{|r|
           commit "  PUSH(SCREG(#{r}));"
@@ -842,7 +842,7 @@ class RubyVM https://github.com/ruby/ruby/blob/trunk/tool/instruction.rb#L842
       each_footer_stack_val(insn){|v|
         n += 1 unless v[2]
       }
-      commit "  CHECK_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
+      commit "  CHECK_VM_STACK_OVERFLOW(REG_CFP, #{n});" if n > 0
       each_footer_stack_val(insn){|v|
         if v[2]
           commit "  SCREG(#{v[2]}) = #{v[1]};"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]