• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

mrubyを超漢字で動作させる


Commit MetaInfo

修订版d5dd3e94723fc7754aa5d478e0947479569c25dc (tree)
时间2014-07-15 17:17:58
作者Yukihiro "Matz" Matsumoto <matz@ruby...>
CommiterYukihiro "Matz" Matsumoto

Log Message

fiber stack allocation size should be bigger than irep->nregs

更改概述

差异

--- a/mrbgems/mruby-fiber/src/fiber.c
+++ b/mrbgems/mruby-fiber/src/fiber.c
@@ -69,6 +69,7 @@ fiber_init(mrb_state *mrb, mrb_value self)
6969 struct RProc *p;
7070 mrb_callinfo *ci;
7171 mrb_value blk;
72+ size_t slen;
7273
7374 mrb_get_args(mrb, "&", &blk);
7475
@@ -85,14 +86,18 @@ fiber_init(mrb_state *mrb, mrb_value self)
8586 c = f->cxt;
8687
8788 /* initialize VM stack */
88- c->stbase = (mrb_value *)mrb_malloc(mrb, FIBER_STACK_INIT_SIZE*sizeof(mrb_value));
89- c->stend = c->stbase + FIBER_STACK_INIT_SIZE;
89+ slen = FIBER_STACK_INIT_SIZE;
90+ if (p->body.irep->nregs > slen) {
91+ slen += p->body.irep->nregs;
92+ }
93+ c->stbase = (mrb_value *)mrb_malloc(mrb, slen*sizeof(mrb_value));
94+ c->stend = c->stbase + slen;
9095 c->stack = c->stbase;
9196
9297 #ifdef MRB_NAN_BOXING
9398 {
9499 mrb_value *p = c->stbase;
95- mrb_value *pend = p + FIBER_STACK_INIT_SIZE;
100+ mrb_value *pend = c->stend;
96101
97102 while (p < pend) {
98103 SET_NIL_VALUE(*p);
@@ -100,7 +105,7 @@ fiber_init(mrb_state *mrb, mrb_value self)
100105 }
101106 }
102107 #else
103- memset(c->stbase, 0, FIBER_STACK_INIT_SIZE * sizeof(mrb_value));
108+ memset(c->stbase, 0, slen * sizeof(mrb_value));
104109 #endif
105110
106111 /* copy receiver from a block */