Iseq_compile_each()でのマジックナンバ

$B$-$?$6$o$G$9!#(B

$B$O$8$a$^$7$F!#(B
$B$O$8$a$F%]%9%H$9$k$N$G!"(Bdev$B$J$N$+(Blist$B$J$N$+LB$C$?$N$G$9$,!"%=!<%9%3!<%I$K4X$9$k(B
$B$3$H$J$N$G!"$3$A$i$K%]%9%H$7$^$9!#(B
[email protected]$C$?$i;XE&$7$F$/[email protected]$5$$!#(B

iseq_compile_each()$B$N(BNODE_BREAK/NODE_NEXT$B$"$?$j$G!"JQ?t(Blevel$B$KBP$9$k(B
$B%^%8%C%/%J%s%P$,5$$K$J$k$N$G%Q%C%A$rEv$F$h$&$+$H;W$C$F$$$^$9!#(B

$B$G!"$I$&$7$F$b$o$+$i$J$$$3$H$,$"$k$N$G65$($F$/[email protected]$5$$!#(B

case NODE_BREAK$B$N$"$H$G!"(B
level++;
if (ip->compile_data->redo_label != 0) {
level = 0x8000;
if (ip->compile_data->loopval_popped == 0) {
/* need value */
level |= 0x4000;
}
goto break_by_insn;
}
$B$H$$$&%3!<%I$,$"$k$N$G$9$,!"(B0x4000$B$N0UL#!JMQES!K$,$o$+$j$^$;$s!#(B
vm_throw()$B$G$O$3$NCM!J%S%C%H!K$r$_$F$$$J$$$h$&$J$N$G$9!#(B
need value$B$H$$$&%3%a%s%H$,$"$k$N$G!“I,MW$C$]$$46$8$J$N$G$9$,!”(B
$B%G%P%C%0MQ$K;H$&$/$i$$$7$+;W$$$D$+$J$$$N$G$9!#(B

$B$h$m$7$/$*4j$$CW$7$^$9!#(B

$B6a1J$H?=$7$^$9!#(B

$B$3$N7o5$$K$J$C$F$$$?$N$G$9$,!"H?1~$,CY$/$J$C$F$9$_$^$;$s!#(B
[email protected]$O(B ruby-dev $B$GE,@[email protected]$H;W$$$^$9!#(B

$B$H$$$&%3!<%I$,$"$k$N$G$9$,!"(B0x4000$B$N0UL#!JMQES!K$,$o$+$j$^$;$s!#(B
vm_throw()$B$G$O$3$NCM!J%S%C%H!K$r$$F$$$J$$$h$&$J$N$G$9!#(B
need value$B$H$$$&%3%a%s%H$,$"$k$N$G!“I,MW$C$]$$46$8$J$N$G$9$,!”(B
$B%G%P%C%0MQ$K;H$&$/$i$$$7$+;W$$$D$+$J$$$N$G$9!#(B
$B3N$+$K;HMQ$5$l$F$$$J$$$h$&$K8+$($^$9$M!#(B
$B$3$3$NB>(B2$B2U=j(B($B7W(B3$B2U=j(B)$B$N(B 0x4000
$B%S%C%H$rN)$F$F$$$k=j$r:o$C$F(B
make check
$B$G%F%9%H$7$F$
$^$7$?$,%(%i!<$,A}$($F$$$k$h$&$G$O$"$j$^$;$s$G$7$?!#(B
$B2a5n$N2?$+$NL>;D$j$G:#$OITMW$K$J$C$F$7$^$C$F$$$k$b$N$G$O$J$$$G$7$g$&$+(B?

$B1sF#$G$9!#(B

$B$3$N%a!<%k$K5$$,$D$$$F$^$;$s$G$7$?!#(B

2011$BG/(B3$B7n(B5$BF|(B0:05 nagachika [email protected]:

$B$H$$$&%3!<%I$,$"$k$N$G$9$,!"(B0x4000$B$N0UL#!JMQES!K$,$o$+$j$^$;$s!#(B
vm_throw()$B$G$O$3$NCM!J%S%C%H!K$r$$F$$$J$$$h$&$J$N$G$9!#(B
need value$B$H$$$&%3%a%s%H$,$"$k$N$G!“I,MW$C$]$$46$8$J$N$G$9$,!”(B
$B%G%P%C%0MQ$K;H$&$/$i$$$7$+;W$$$D$+$J$$$N$G$9!#(B
$B3N$+$K;HMQ$5$l$F$$$J$$$h$&$K8+$($^$9$M!#(B
$B$3$3$NB>(B2$B2U=j(B($B7W(B3$B2U=j(B)$B$N(B 0x4000
$B%S%C%H$rN)$F$F$$$k=j$r:o$C$F(B
make check
$B$G%F%9%H$7$F$
$^$7$?$,%(%i!<$,A}$($F$$$k$h$&$G$O$"$j$^$;$s$G$7$?!#(B
$B2a5n$N2?$+$NL>;D$j$G:#$OITMW$K$J$C$F$7$^$C$F$$$k$b$N$G$O$J$$$G$7$g$&$+(B?

$B$=$&[email protected]$&$N$KG:[email protected]$H$-$O(B git log -p $B$H$+$G2a5n$N5-O?$r8+$F$_$k$H(B
$B$$$$$G$9$h!#(B
$B$3$N%3!<%I$,F~$C$?$N$O(B r11439 (Merge YARV) $B$G!"$=$N;~$O(B 0x4000
$B$r(B
$B;H$&%3!<%I$,3NG’$G$-$^$9(B (insns.def $B$N(B throw) $B!#$=$N%3!<%I$O(B
vm.c
$B$N(B vm_throw $B$K0$j(B (r12887) $B!"$=$N8e(B r16568
$B$G>C$5$l$F$$$^$9!#(B

commit 956dead48069a07eb1211283ae5b276ef45f6768
Author: mame [email protected]
Date: Sat May 24 06:29:48 2008 +0000

* compile.c (iseq_set_exception_table, NODE_WHILE, NODE_NEXT): 

remove
special handling that decrements sp in CATCH_TYPE_NEXT for
NODE_WHILE.

* vm.c (vm_eval_body), vm_insnhelper.c (vm_throw): remove unused 

code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/[email protected]

b2dd03c8-39d4-4d8f-98ff-823fe69b080e

diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index bf9ded1…6fb867a 100644
— a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1204,12 +1204,7 @@ vm_throw(rb_thread_t *th, rb_control_frame_t
*reg_cfp,
VALUE *pt = 0;
int i;
if (flag != 0) {

  •       if (throw_state & 0x4000) {
    
  •           pt = (void *)1;
    
  •       }
    
  •       else {
    
  •           pt = 0;
    
  •       }
    
  •       pt = (void *) 1;
      }
      else {
          if (state == TAG_BREAK) {
    

$B$($C!">C$7$?$N;d$J$s$G$9$M!#%3%_%C%H%m%0$r8+$F;W$$=P$9$H!"(B

  • next $B$O0z?t$r<h$k(B (next val) $B$N$G!"%9%?%C%/$r>CHq$9$k(B

  • $B$7$+$7!"(Bwhile $B$NCf$G(B next
    $B$KCM$rM?$($F$b<[email protected]$1$J$N$G!"(B
    $B%9%?%C%/$NL5BL$K$J$k(B

  • while $B$NCf$N(B next [email protected]$1FCJL07$$$7$F%9%?%C%/>CHq$7$J$$$h$&$K$7(B
    $B$F$$$?(B (0x4000 $B$O%9%?%C%/$r>CHq$9$k>l9g$N%U%i%0(B)

$B$H$$$&[email protected]$C$?$O$:!#(B
$B$G$b!"$J$<$3$N:GE,2=$r$d$a$?$N$+$^$G$O=q$$$F$$$^$;$s$M!#%@%a%@%a!#(B

$B$J$<$+$H$$$&$H!"$3$N:GE,2=$r$7$F$$$k$H%Y%j%U%!%$%":n$k>e$G%9%?%C(B
$B%/D9$N8!>Z$,$H$F$bFq$7$/$J$kLdBj$,[email protected]$C$?$H;W$$$^$9!#(B
$B$5$i$K$3$N:GE,2=$O$b$H$b$H(B /* TODO: Dirty Hack! Fix me */ $B$H=q(B
$B$+$l$k$h$&[email protected]$C$?$3$H$b$"$C$F!"[email protected]$5$s$,>[email protected]$C(B
$B$?$O$:!#(B

$B$A$J$_$K$3$N%3%a%s%H$O:#$G$b(B iseq_set_exception_table $B$NCf$K(B

$B;D$C$F$$$^$9$,!"(BDirty Hack $B<+BN$O>C$($F$$$^$9!#%3%a%s%H$,DI$$(B

$B$D$$$F$J$$!D!D!#(B

$B$-$?$6$o$5$s$,<($5$l$?2U=j(B (NODE_BREAK) $B$G$b(B 0x4000
$B$,4X$o$C$F(B
$B$$$?$s$G$9$M!#(Bwhile $B$NJV$jCM$,;H$o$l$k>l9g(B (loopval_popped
$B$,(B 0
$B$N>l9g(B) [email protected]$1!"(Bbreak
$B$N0z?t$r%9%?%C%/$K:$;$k$H$$$&:GE,[email protected]$C$?$H(B
$B;W$o$l$^$9!#(B
$B$G$b!"(Bloopval_popped $B$,(B 0
[email protected]$,%3!<%[email protected]$;(B
$B$J$$$N$G!"(Bif (ip->compile_data->loopval_popped == 0) $B$NJ,4t$O0U(B
$BL#$,$J$$$s$8$c$J$$$+$J!<$H;W$$$^$9!#(B
$BEv;~(B (2008/05/24) $B$N(B IRC
$B$N%m%0$r8+$F$_$?$H$3$m!"[email protected]$C(B
$B$F$^$7$?!#(B

11:13:10 loopval_popped $B$O$b$&;H$o$l$F$$$J$$$N$G$O$J$$$+(B

$B$H$$$&$o$1$G!"(B0x4000 $B4X78$N%3!<%I$H(B loopval_popped
$B4X78$N%3!<%I(B
$B$OA4It<h$j=|$$$F$h$5$=$&$G$9!#(B

$B$-$?$6$o$G$9!#(B

$B1sF#$5$s!“6a1J$5$s!”$"$j$,$H$&$4$6$$$^$9!#(B

$B$=$&[email protected]$&$N$KG:[email protected]$H$-$O(B git log -p $B$H$+$G2a5n$N5-O?$r8+$F$$k$H(B
$B$$$$$G$9$h!#(B
$B<!$+$i!"$=$&$7$F$
$^$9!#(B

$B$H$$$&$o$1$G!"(B0x4000 $B4X78$N%3!<%I$H(B loopval_popped $B4X78$N%3!<%I(B
$B$OA4It<h$j=|$$$F$h$5$=$&$G$9!#(B
[email protected]|!"%Q%C%A$r(Bpost$B$7$h$&$+$H;W$$$^$9!#(B
$B!t:#HU$N3Z$7$_$,$G$-$?!#%o%$%o%$(B
$B!t$"$l!)$d$C$F$$$k%R%^$"$k$N$+$J!)(B

loopval_popped $B4X78$N%3!<%I$K$D$$$F$O!"$A$g$C$H<+J,$GD4$Y$F$_$^$9!#(B
[email protected]$+!"$o$+$C$F$$$J$$!&!&!&(B

$B$-$?$6$o$G$9!#(B

$B$H$$$&$o$1$G!"(B0x4000 $B4X78$N%3!<%I$H(B loopval_popped $B4X78$N%3!<%I(B
$B$OA4It<h$j=|$$$F$h$5$=$&$G$9!#(B

loopval_popped$BJQ?t$H$O!"(B
struct iseq_compile_data {
$B!JN,!K(B
int loopval_popped; /* used by NODE_BREAK */

$B$G!"$d$O$j(Bcompile.c$BFb$G(B

compile.c:3204: int prev_loopval_popped =
iseq->compile_data->loopval_popped;
compile.c:3216: iseq->compile_data->loopval_popped = 0;
compile.c:3278: iseq->compile_data->loopval_popped =
prev_loopval_popped;
compile.c:3327: COMPILE_(ret, “break val (while/until)”,
node->nd_stts, iseq->compile_data->loopval_popped);

$B$H!"1d!9(B0$B$,7+$jJV$7BeF~$5$l$F$$$k%d%D$G$9$M!#(B

$B$3$l$b$d$C$Q$j;H$C$F$J$$$s$G$9$M!#(B
$B2?EYFI$s$G$b!"IT;W5D$G$?$^$i$+$C$?$s$G$9$h!#(B

$B$C$F$3$H$O!"(BCOMPILE_$B$+$i!"(BCOMPILE(ret, “break val
(while/until)”, node->nd_stts);
$B$G$9$M!#(B

$B$-$?$6$o$G$9!#(B

$B$A$J$_$K$3$N%3%a%s%H$O:#$G$b(B iseq_set_exception_table $B$NCf$K(B

$B;D$C$F$$$^$9$,!"(BDirty Hack $B<+BN$O>C$($F$$$^$9!#%3%a%s%H$,DI$$(B

$B$D$$$F$J$$!D!D!#(B

iseq_set_exception_table(rb_iseq_t iseq)
{
$B!JN,!K(B
/
TODO: Dirty Hack! Fix me */
if (entry->type == CATCH_TYPE_RESCUE ||
entry->type == CATCH_TYPE_BREAK ||
entry->type == CATCH_TYPE_NEXT) {
entry->sp–;
}
}

$B$3$N%3%a%s%H$G$9$M!)(B

[email protected]>!"$J$s$N%3%a%s%[email protected]$+$o$+$i$J$+$C$?$H$3$m$G$9!#(B

[email protected]$G$9!%(B

$B!!$3$NJU$O$b$&$5$C$Q$j3P$($F$$$J$$$N$G$9$,!%(B

(2011/03/06 11:37), $B$-$?$6$o$1$s$$$A(B wrote:

entry->type == CATCH_TYPE_NEXT) {
entry->sp--;
  }

}

$B$3$N%3%a%s%H$G$9$M!)(B

[email protected]>!"$J$s$N%3%a%s%[email protected]$+$o$+$i$J$+$C$?$H$3$m$G$9!#(B

$B!!$3$N(B sp-- $B$9$k$N$,!$$J$s$G(B sp–
[email protected]$1$G$$$$$N$+$o$+$i$J$+$C$?!$$H$$$&(B
$B$+!$3N$+!$JL$N>l9g$b$"$k$h$&$J5$$,$9$k$1$I!$$^$!(B test-all
$B$,F0$/$+$i$$$$(B
$B$+!$$H;W$C$F!$$b$C$H$A$c$s$H$7$J$$$H$$$+$s$J$!!$$H;W$C$F=q$$$F$$$?$s$8$c(B
$B$J$$$+$H;W$$$^$9!%(B

$B!!<B9T;~$N(B sp
$B$NA+0$O!$$b$&$A$g$C$H%U%)!<%^%k$K$-$C$A$j7h$a$i$l$k$h$&$K(B
$B$7$?$$$J$!!$$H;W$C$F$$$?$j$7$F!$J|$C$?$i$+$7$G$9!J:#$O!$%P%0$,$"$C$?$i%"(B
$B%I%[%C%/$KD>$9!$$C$F46$8!K!%1sF#$5$s$,$-$C$A$j7h$^$k$h$&$K!$?’!9JQ99$7$F(B
$B$/$l$?HG$,$"$C$?$H;W$&[email protected]$1$I!$Bg$-$9$.$F(B reject
$B$7$A$c$C$?$s$G$9$+$M!%(B

$B!!K\Ev$O!$%U%m!<%0%i%U$+$J$s$+$r$-$A$s$H:n$C$F!$$-$C$A$j$7$?$$$H$3$m$J$s(B
$B$G$9$,!%(B

$BKL_7$G$9!#(B

iseq_compile_each(compile.c)$B$N(BNODE_BREAK$B$"$?$j$N%^%8%C%/%J%s%P$N%Q%C%A$rAw$j$^$9!#(B
svn diff$B$G:9J,$r$H$C$?$1$I!"$3$l$G$h$$$N$+$7$i!)(B
$B?’!9L$7P83$JItJ,$,$"$k$N$G!";XE&$7$F$/[email protected]$5$$!#(B

Index: vm_core.h

— vm_core.h ($B%j%S%8%g%s(B 31028)
+++ vm_core.h ($B:n6H%3%T!<(B)
@@ -583,6 +583,12 @@
#define RUBYVM_CFUNC_FRAME_P(cfp)
(VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)

+/* vm_throw state /
+#define VM_THROW_GET_DFP 0x8000
+#define VM_THROW_STATE_MASK 0xff
+#define VM_THROW_LVL_SHIFT 16
+#define VM_THROW_LEVEL(s) (s >> VM_THROW_LVL_SHIFT)
+
/
inline cache */
typedef struct iseq_inline_cache_entry *IC;

Index: compile.c

— compile.c ($B%j%S%8%g%s(B 31028)
+++ compile.c ($B:n6H%3%T!<(B)
@@ -15,6 +15,7 @@
#define USE_INSN_STACK_INCREASE 1
#include “vm_core.h”
#include “iseq.h”
+#include “eval_intern.h”
#include “insns.inc”
#include “insns_info.inc”

@@ -3336,7 +3337,7 @@
break_by_insn:
/* escape from block */
COMPILE(ret, “break val (block)”, node->nd_stts);

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x02) /*
    

TAG_BREAK */ );

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | TAG_BREAK)
    

/* TAG_BREAK */ );
if (poped) {
ADD_INSN(ret, nd_line(node), pop);
}
@@ -3355,11 +3356,7 @@

 level++;
 if (ip->compile_data->redo_label != 0) {
  •    level = 0x8000;
    
  •    if (ip->compile_data->loopval_popped == 0) {
    
  •  /* need value */
    
  •  level |= 0x4000;
    
  •    }
    
  •    level = VM_THROW_GET_DFP;
       goto break_by_insn;
    
    }
    else if (ip->type == ISEQ_TYPE_BLOCK) {
    @@ -3419,7 +3416,7 @@
    break;
    }
  • level = 0x8000 | 0x4000;
  • level = VM_THROW_GET_DFP;
    if (ip->compile_data->redo_label != 0) {
    /* while loop */
    break;
    @@ -3435,7 +3432,7 @@
    }
    if (ip != 0) {
    COMPILE(ret, “next val”, node->nd_stts);
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x03) /*
    TAG_NEXT */ );
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | TAG_NEXT) /*
    TAG_NEXT */ );

    if (poped) {
    ADD_INSN(ret, nd_line(node), pop);
    @@ -3481,7 +3478,7 @@
    else {
    rb_iseq_t *ip;
    unsigned long level;

  •  level = 0x8000 | 0x4000;
    
  •  level = VM_THROW_GET_DFP;
     ip = iseq;
     while (ip) {
    
    if (!ip->compile_data) {
    @@ -3503,7 +3500,7 @@
    }
    if (ip != 0) {
    ADD_INSN(ret, nd_line(node), putnil);
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x05) /*
    TAG_REDO */ );
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | TAG_REDO) /*
    TAG_REDO */ );

    if (poped) {
    ADD_INSN(ret, nd_line(node), pop);
    @@ -3518,7 +3515,7 @@
    case NODE_RETRY:{
    if (iseq->type == ISEQ_TYPE_RESCUE) {
    ADD_INSN(ret, nd_line(node), putnil);

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x04) /* TAG_RETRY 
    

*/ );

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(TAG_RETRY) /* 
    

TAG_RETRY */ );

   if (poped) {
 ADD_INSN(ret, nd_line(node), pop);

@@ -4316,7 +4313,7 @@
}
}
else {

  •    ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x01) /* 
    

TAG_RETURN */ );

  •    ADD_INSN1(ret, nd_line(node), throw, INT2FIX(TAG_RETURN) /*
    

TAG_RETURN */ );
if (poped) {
ADD_INSN(ret, nd_line(node), pop);
}
Index: vm_insnhelper.c

— vm_insnhelper.c ($B%j%S%8%g%s(B 31028)
+++ vm_insnhelper.c ($B:n6H%3%T!<(B)
@@ -1432,9 +1432,9 @@
vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
rb_num_t throw_state, VALUE throwobj)
{

  • int state = (int)(throw_state & 0xff);
  • int flag = (int)(throw_state & 0x8000);
  • rb_num_t level = throw_state >> 16;
  • int state = (int)(throw_state & VM_THROW_STATE_MASK);

  • int flag = (int)(throw_state & VM_THROW_GET_DFP);

  • rb_num_t level = VM_THROW_LEVEL(throw_state);

    if (state != 0) {
    VALUE *pt = 0;

[email protected]$G$9!%(B

$B!!$3$NJU$N%3!<%I$r5W!9$K8+$^$7$?!%(B

(2011/03/06 11:25), $B$-$?$6$o$1$s$$$A(B wrote:

Index: vm_core.h

— vm_core.h ($B%j%S%8%g%s(B 31028)
+++ vm_core.h ($B:n6H%3%T!<(B)
@@ -583,6 +583,12 @@
#define RUBYVM_CFUNC_FRAME_P(cfp)
(VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)

+/* vm_throw state */
+#define VM_THROW_GET_DFP 0x8000

$B!!$3$l!$2?$d$C$F$k$s$G$7$?$C$1!%%3!<%I8+$?$1$I;W$$=P$;$J$$(B…$B!%$J$s$+!$(B
$B$3$l$,@_Dj$5$l$F$$$k$H!$5U$K(B dfp $B$r8+$F$$$J$$$h$&$J!%(B

+#define VM_THROW_STATE_MASK 0xff
+#define VM_THROW_LVL_SHIFT 16
+#define VM_THROW_LEVEL(s) (s >> VM_THROW_LVL_SHIFT)

$B!!(Blvl $B$C$F(B level $B$G$7$g$&$+!%(B

Index: compile.c

— compile.c ($B%j%S%8%g%s(B 31028)
+++ compile.c ($B:n6H%3%T!<(B)
@@ -15,6 +15,7 @@
#define USE_INSN_STACK_INCREASE 1
#include “vm_core.h”
#include “iseq.h”
+#include “eval_intern.h”

$B!!$J$<!$(Beval_intern.h $B$r(B include
$B$7$F$$$k$s$G$7$g$&$+!%(BTAG_BREAK $B$H$+$r(B
$B8+$k$?$a$+$J!%;d$O$J$<$3$3$rB([email protected]$m$&!%(Binclude
$B$7$?$/$J$+$C$?$+(B
$B$i$+$J$!!%(B

$B$-$?$6$o$G$9!#(B

$B2?EY$b$9$$$^$;$s!#(B

$B$3$s$J$s$G!"$I$&$G$7$g$&$+!)(B
loopval_popped$B$N7o$O!"0l%+=j$r=|$$$F$^[email protected]~$l$F$^$;$s!#(B

Index: vm_core.h

— vm_core.h ($B%j%S%8%g%s(B 31028)
+++ vm_core.h ($B:n6H%3%T!<(B)
@@ -583,6 +583,11 @@
#define RUBYVM_CFUNC_FRAME_P(cfp)
(VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)

+/* vm_throw state /
+#define VM_THROW_NO_DFP 0x8000
+#define VM_THROW_STATE_MASK 0xff
+#define VM_THROW_LEVEL_SHIFT 16
+
/
inline cache */
typedef struct iseq_inline_cache_entry *IC;

Index: compile.c

— compile.c ($B%j%S%8%g%s(B 31028)
+++ compile.c ($B:n6H%3%T!<(B)
@@ -14,6 +14,7 @@

#define USE_INSN_STACK_INCREASE 1
#include “vm_core.h”
+#include “eval_intern.h”
#include “iseq.h”
#include “insns.inc”
#include “insns_info.inc”
@@ -3355,11 +3356,7 @@

 level++;
 if (ip->compile_data->redo_label != 0) {
  •    level = 0x8000;
    
  •    if (ip->compile_data->loopval_popped == 0) {
    
  •  /* need value */
    
  •  level |= 0x4000;
    
  •    }
    
  •    level = VM_THROW_NO_DFP;
       goto break_by_insn;
    
    }
    else if (ip->type == ISEQ_TYPE_BLOCK) {
    @@ -3419,7 +3416,7 @@
    break;
    }
  • level = 0x8000 | 0x4000;
  • level = VM_THROW_NO_DFP;
    if (ip->compile_data->redo_label != 0) {
    /* while loop */
    break;
    @@ -3481,7 +3478,7 @@
    else {
    rb_iseq_t *ip;
    unsigned long level;
  •  level = 0x8000 | 0x4000;
    
  •  level = VM_THROW_NO_DFP;
     ip = iseq;
     while (ip) {
    
    if (!ip->compile_data) {
    Index: vm_insnhelper.c
    ===================================================================
    — vm_insnhelper.c ($B%j%S%8%g%s(B 31028)
    +++ vm_insnhelper.c ($B:n6H%3%T!<(B)
    @@ -1432,9 +1432,9 @@
    vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
    rb_num_t throw_state, VALUE throwobj)
    {
  • int state = (int)(throw_state & 0xff);
  • int flag = (int)(throw_state & 0x8000);
  • rb_num_t level = throw_state >> 16;
  • int state = (int)throw_state & VM_THROW_STATE_MASK;

  • int flag = (int)throw_state & VM_THROW_NO_DFP;

  • rb_num_t level = (rb_num_t)(throw_state >> VM_THROW_LEVEL_SHIFT);

    if (state != 0) {
    VALUE *pt = 0;

$B$-$?$6$o$G$9!#(B

[email protected]$5$s$HOC$7$,$G$-$k$J$s$F9,$;[email protected]$J$!(B

$B!!$3$l!$2?$d$C$F$k$s$G$7$?$C$1!%%3!<%I8+$?$1$I;W$$=P$;$J$$(B…$B!%$J$s$+!$(B
$B$3$l$,@_Dj$5$l$F$$$k$H!$5U$K(B dfp $B$r8+$F$$$J$$$h$&$J!%(B

$B$"!“MQES$H$7$F$O5U$G$9$M!#(B
[email protected]$H!”(Bdfp$B$r8+$^$9$h$M!#$H$$$&$+!"(Bthrow$BL?Na$NJV$jCM$r(B1$B$K$9$k$+!"(Bdfp$B$K$9$k$+!"$G$9$+$M!#(B

$B5U$K$H$i$($F$7$^$C$?$+(B

VM_THROW_RETRUN_NOT_DFP$B$+$J!)(B

+#define VM_THROW_LVL_SHIFT 16
+#define VM_THROW_LEVEL(s) (s >> VM_THROW_LVL_SHIFT)

$B!!(Blvl $B$C$F(B level $B$G$7$g$&$+!%(B

$B$=$&$G$9!#(BVM_THROW_LEVEL_SHIFT$B$K$7$^$9!#(B

+#include “eval_intern.h”

$B!!$J$<!$(Beval_intern.h $B$r(B include $B$7$F$$$k$s$G$7$g$&$+!%(BTAG_BREAK
$B$H$+$r(B
$B8+$k$?$a$+$J!%;d$O$J$<$3$3$rB([email protected]$m$&!%(Binclude $B$7$?$/$J$+$C$?$+(B
$B$i$+$J$!!%(B

eval_intern.h$B$r(Binclude$B$9$k$N$O!"(BTAG_xxx$B$r8+$k$?$a$G$9!#(B

$B$b$C$H$b!"(B0x8000$B$r%;%C%H$5$l$k$h$&$J%3!<%I$,=q$1$J$/$F!":$$C$F$b$$$k$s$G$9$1$I$M!#(B

$B;d$O$J$<$3$3$rB([email protected]$m$&!%(B
$B?M4V$,A[5/$G$-$k5-21$N$[$&$,>/$J$$$G$9$h!#(B

$B$-$?$6$o$G$9!#(B

$B2?EY$b2?EY$b!"$9$$$^$;$s!#(B
TAG_xxx$B$r%^%8%C%/%J%s%P$N$^$^$G$7$?!#(B
$B$"$H!"$d$C$Q$j(B

  • int state = (int)(throw_state & 0xff);
  • int flag = (int)(throw_state & 0x8000);
  • rb_num_t level = throw_state >> 16;
    $B$N$"$?$j$r%^%/%m$K$7$^$7$?!#(B

Index: vm_core.h

— vm_core.h ($B%j%S%8%g%s(B 31028)
+++ vm_core.h ($B:n6H%3%T!<(B)
@@ -583,6 +583,13 @@
#define RUBYVM_CFUNC_FRAME_P(cfp)
(VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_CFUNC)

+/* vm_throw state /
+#define VM_THROW_NO_DFP 0x8000
+#define VM_THROW_STATE_MASK 0xff
+#define VM_THROW_LEVEL_SHIFT 16
+#define GET_VM_THROW_STATE(s) ((int)(s & VM_THROW_STATE_MASK))
+#define GET_VM_THROW_NO_DFP(s) ((int)(s & VM_THROW_NO_DFP))
+#define GET_VM_THROW_LEVEL(s) ((rb_num_t)(s >> VM_THROW_LEVEL_SHIFT))
/
inline cache */
typedef struct iseq_inline_cache_entry *IC;

Index: compile.c

— compile.c ($B%j%S%8%g%s(B 31028)
+++ compile.c ($B:n6H%3%T!<(B)
@@ -14,6 +14,7 @@

#define USE_INSN_STACK_INCREASE 1
#include “vm_core.h”
+#include “eval_intern.h”
#include “iseq.h”
#include “insns.inc”
#include “insns_info.inc”
@@ -3336,7 +3337,7 @@
break_by_insn:
/* escape from block */
COMPILE(ret, “break val (block)”, node->nd_stts);

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x02) /*
    

TAG_BREAK */ );

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | TAG_BREAK)
    

/* TAG_BREAK */ );
if (poped) {
ADD_INSN(ret, nd_line(node), pop);
}
@@ -3355,11 +3356,7 @@

 level++;
 if (ip->compile_data->redo_label != 0) {
  •    level = 0x8000;
    
  •    if (ip->compile_data->loopval_popped == 0) {
    
  •  /* need value */
    
  •  level |= 0x4000;
    
  •    }
    
  •    level = VM_THROW_NO_DFP;
       goto break_by_insn;
    
    }
    else if (ip->type == ISEQ_TYPE_BLOCK) {
    @@ -3419,7 +3416,7 @@
    break;
    }
  • level = 0x8000 | 0x4000;
  • level = VM_THROW_NO_DFP;
    if (ip->compile_data->redo_label != 0) {
    /* while loop */
    break;
    @@ -3435,7 +3432,7 @@
    }
    if (ip != 0) {
    COMPILE(ret, “next val”, node->nd_stts);
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x03) /*
    TAG_NEXT */ );
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | TAG_NEXT) /*
    TAG_NEXT */ );

    if (poped) {
    ADD_INSN(ret, nd_line(node), pop);
    @@ -3481,7 +3478,7 @@
    else {
    rb_iseq_t *ip;
    unsigned long level;

  •  level = 0x8000 | 0x4000;
    
  •  level = VM_THROW_NO_DFP;
     ip = iseq;
     while (ip) {
    
    if (!ip->compile_data) {
    @@ -3503,7 +3500,7 @@
    }
    if (ip != 0) {
    ADD_INSN(ret, nd_line(node), putnil);
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x05) /*
    TAG_REDO */ );
  • ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | TAG_REDO) /*
    TAG_REDO */ );

    if (poped) {
    ADD_INSN(ret, nd_line(node), pop);
    @@ -3518,7 +3515,7 @@
    case NODE_RETRY:{
    if (iseq->type == ISEQ_TYPE_RESCUE) {
    ADD_INSN(ret, nd_line(node), putnil);

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x04) /* TAG_RETRY 
    

*/ );

  •  ADD_INSN1(ret, nd_line(node), throw, INT2FIX(TAG_RETRY) /* 
    

TAG_RETRY */ );

   if (poped) {
 ADD_INSN(ret, nd_line(node), pop);

@@ -4316,7 +4313,7 @@
}
}
else {

  •    ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x01) /* 
    

TAG_RETURN */ );

  •    ADD_INSN1(ret, nd_line(node), throw, INT2FIX(TAG_RETURN) /*
    

TAG_RETURN */ );
if (poped) {
ADD_INSN(ret, nd_line(node), pop);
}
Index: vm_insnhelper.c

— vm_insnhelper.c ($B%j%S%8%g%s(B 31028)
+++ vm_insnhelper.c ($B:n6H%3%T!<(B)
@@ -1432,9 +1432,9 @@
vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
rb_num_t throw_state, VALUE throwobj)
{

  • int state = (int)(throw_state & 0xff);
  • int flag = (int)(throw_state & 0x8000);
  • rb_num_t level = throw_state >> 16;
  • int state = GET_VM_THROW_STATE(throw_state);

  • int flag = GET_VM_THROW_NO_DFP(throw_state);

  • rb_num_t level = GET_VM_THROW_LEVEL(throw_state);

    if (state != 0) {
    VALUE *pt = 0;

$B1sF#$G$9!#(B

2011$BG/(B3$B7n(B6$BF|(B12:17 SASADA Koichi [email protected]:

          entry->type == CATCH_TYPE_BREAK ||
          entry->type == CATCH_TYPE_NEXT) {
          entry->sp--;
      }
  }

$B$3$N%3%a%s%H$G$9$M!)(B

$B$=$&$G$9!#(B

$B!!$3$N(B sp-- $B$9$k$N$,!$$J$s$G(B sp–
[email protected]$1$G$$$$$N$+$o$+$i$J$+$C$?!$$H$$$&(B
$B$+!$3N$+!$JL$N>l9g$b$"$k$h$&$J5$$,$9$k$1$I!$$^$!(B test-all $B$,F0$/$+$i$$$$(B
$B$+!$$H;W$C$F!$$b$C$H$A$c$s$H$7$J$$$H$$$+$s$J$!!$$H;W$C$F=q$$$F$$$?$s$8$c(B
$B$J$$$+$H;W$$$^$9!%(B

$B$$$d!"85$O$b$C$H$R$I$$%3!<%[email protected]$C$?$s$G$9$h!#(B

       /* TODO: Dirty Hack!  Fix me */
       if (entry->type == CATCH_TYPE_RESCUE ||
           entry->type == CATCH_TYPE_BREAK ||
           (((ptr[0] & 0x10000) == 0)
            && entry->type == CATCH_TYPE_NEXT)) {
           entry->sp--;
       }

rescue $B$H(B break $B$H(B next
$B$K$O0z?t$,$"$k$H$$$&6&[email protected]$,$"$k$N$G!"(B
$B8=>u$N%3!<%[email protected]$H;W$$$^$9!#(B
0x10000 $B$J$s$F%^%8%C%/%J%s%P!<$G$O$J$/(B CATCH_TYPE_NEXT_WITH_NO_ARG
$B$H$+(B CATCH_TYPE_NEXT_FOR_WHILE $B$H$+JL$N%i%Y%k$rDj5A$7$F$$$l$P(B
Dirty $B$H$^$G$O;W$o$J$+$C$?$G$9$,!#(B

$B$A$J$_$KEv;~$N(B IRC $B%m%0H4?h(B

13:44:10 <ko1_ndk> catch_type $B$rA}$d$7$?$i$b$C$HC1=c$K$J$k!)(B
13:46:19 next $B$r%-%c%C%A$9$k$1$I0z?t$r%9%?%C%/$K:$;$J$$(B
catch_type $B$H:$;$k(B catch_type $B$G$9$+(B
13:46:41 <ko1_ndk> $B$=$&$=$&(B
13:47:37 $B$I$C$A$,9,$;$J$N$+$J$"(B
13:50:49 $B$=$b$=$b(B while $B$NCf$N(B next
$B$N0z?t$,L50UL#$G5$;}$A0-$$(B

$B<B9T;~$N(B sp $B$NA+0$O!$$b$&$A$g$C$H%U%)!<%^%k$K$-$C$A$j7h$a$i$l$k$h$&$K(B
$B$7$?$$$J$!!$$H;W$C$F$$$?$j$7$F!$J|$C$?$i$+$7$G$9!J:#$O!$%P%0$,$"$C$?$i%"(B
$B%I%[%C%/$KD>$9!$$C$F46$8!K!%1sF#$5$s$,$-$C$A$j7h$^$k$h$&$K!$?’!9JQ99$7$F(B
$B$/$l$?HG$,$"$C$?$H;W$&[email protected]$1$I!$Bg$-$9$.$F(B reject $B$7$A$c$C$?$s$G$9$+$M!%(B

[email protected]<0$KDs0F$7$?$+$I$&$+3P$($F$J$$$G$9$,!"(Bsp $BA+0\4X78$N%P%0$r(B
$BKPLG$G$-$k(B (+ $B%3!<%I$,$-$l$$$K$J$k(B) $BDxEY$N%a%j%C%H$7$+$J$+$C(B
$B$?$N$G!"@Q6KE*$K<h$jF~$l$kM}M3$,$J$$!"[email protected]$C$?5$$,$7$^$9!#(B

$BK\Ev$O!$%U%m!<%0%i%U$+$J$s$+$r$-$A$s$H:n$C$F!$$-$C$A$j$7$?$$$H$3$m$J$s(B
$B$G$9$,!%(B

$B$$$A$$$A%a%b%j>e$K%0%i%[email protected]$^$G$O$7$J$$$b$N$N!"(Bsp $B$r$-$C(B
$B$A$j7h$a$k$H$$$&;d$N%Q%C%A$O$=$&$$$&%Q%C%[email protected]$C$?$O$:!#(B
$B%3%s%Q%$%i$N%3!<%I$G%U%m!<$rI=8=$7$F$$$k$H$$$&0UL#$G!#(B

$B$-$?$6$o$G$9!#(B

[email protected]$$$V!"D9$/$J$C$A$c$$$^$7$?$M!#(B

$BG0$N$?$aIU$12C$($k$H!"!V<+J,[email protected]$$$?$$$o$1$G$O$J$/!"(B
$B$"$/$^$G$4;29M$G$9!#(B
$B$`$7$m%a!<%k$G$d$j$H$j$7$?$[$&$,5-O?$,;D$C$F$h$$$+$b$7$l$J$$!#(B

$B$G$-$k8B$jD4$Y$?$$$H$O;W$&$N$G$9$,!“C5$7J}$,0-$$$N$+(Bgoogle$B$5$s$K$b0z$C$+$+$C$F$/$l$J$+$C$?!”(B
$B$H$$$&$N$,p$G$9!#(B

$BC5$7J}$NI}$r9-$2$F$$$+$J$$$H$$$1$J$$$G$9$M!#(B
$B$"$j$,$H$&$4$6$$$^$9!#(B

$B1sF#$G$9!#(B

2011$BG/(B3$B7n(B5$BF|(B21:07 $B$-$?$6$o$1$s$$$A(B
[email protected]:

$B$=$&[email protected]$&$N$KG:[email protected]$H$-$O(B git log -p $B$H$+$G2a5n$N5-O?$r8+$F$$k$H(B
$B$$$$$G$9$h!#(B
$B<!$+$i!"$=$&$7$F$
$^$9!#(B

$BG0$N$?$aIU$12C$($k$H!"!V<+J,[email protected]$$$?$$$o$1$G$O$J$/!"(B
$B$"$/$^$G$4;29M$G$9!#(B
$B$`$7$m%a!<%k$G$d$j$H$j$7$?$[$&$,5-O?$,;D$C$F$h$$$+$b$7$l$J$$!#(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs