Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
ff0a4f78
Commit
ff0a4f78
authored
Jun 07, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Export `stack_extend` function (renamed `mrb_stack_extend`); fix #3219
This change is required to support #4038.
parent
aa5c5de4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
23 deletions
+24
-23
include/mruby.h
include/mruby.h
+1
-0
src/vm.c
src/vm.c
+23
-23
No files found.
include/mruby.h
View file @
ff0a4f78
...
...
@@ -1235,6 +1235,7 @@ MRB_API mrb_value mrb_fiber_alive_p(mrb_state *mrb, mrb_value fib);
* @mrbgem mruby-fiber
*/
#define E_FIBER_ERROR (mrb_exc_get(mrb, "FiberError"))
MRB_API
void
mrb_stack_extend
(
mrb_state
*
,
int
);
/* memory pool implementation */
typedef
struct
mrb_pool
mrb_pool
;
...
...
src/vm.c
View file @
ff0a4f78
...
...
@@ -217,8 +217,8 @@ stack_extend_alloc(mrb_state *mrb, int room)
}
}
static
inline
void
stack_extend
(
mrb_state
*
mrb
,
int
room
)
MRB_API
void
mrb_
stack_extend
(
mrb_state
*
mrb
,
int
room
)
{
if
(
mrb
->
c
->
stack
+
room
>=
mrb
->
c
->
stend
)
{
stack_extend_alloc
(
mrb
,
room
);
...
...
@@ -446,7 +446,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
mrb_method_missing
(
mrb
,
mid
,
self
,
args
);
}
mrb_ary_unshift
(
mrb
,
args
,
mrb_symbol_value
(
mid
));
stack_extend
(
mrb
,
n
+
2
);
mrb_
stack_extend
(
mrb
,
n
+
2
);
mrb
->
c
->
stack
[
n
+
1
]
=
args
;
argc
=
-
1
;
}
...
...
@@ -464,11 +464,11 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
}
if
(
MRB_METHOD_CFUNC_P
(
m
))
{
ci
->
nregs
=
(
int
)(
argc
+
2
);
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
}
else
if
(
argc
>=
CALL_MAXARGS
)
{
mrb_value
args
=
mrb_ary_new_from_values
(
mrb
,
argc
,
argv
);
stack_extend
(
mrb
,
ci
->
nregs
+
2
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
+
2
);
mrb
->
c
->
stack
[
1
]
=
args
;
ci
->
argc
=
-
1
;
argc
=
1
;
...
...
@@ -478,7 +478,7 @@ mrb_funcall_with_block(mrb_state *mrb, mrb_value self, mrb_sym mid, mrb_int argc
ci
->
proc
=
p
;
if
(
argc
<
0
)
argc
=
1
;
ci
->
nregs
=
(
int
)(
p
->
body
.
irep
->
nregs
+
argc
);
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
}
if
(
voff
>=
0
)
{
argv
=
mrb
->
c
->
stbase
+
voff
;
...
...
@@ -533,10 +533,10 @@ mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p)
if
(
ci
->
argc
<
0
)
keep
=
3
;
else
keep
=
ci
->
argc
+
2
;
if
(
ci
->
nregs
<
keep
)
{
stack_extend
(
mrb
,
keep
);
mrb_
stack_extend
(
mrb
,
keep
);
}
else
{
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
stack_clear
(
mrb
->
c
->
stack
+
keep
,
ci
->
nregs
-
keep
);
}
...
...
@@ -635,14 +635,14 @@ eval_under(mrb_state *mrb, mrb_value self, mrb_value blk, struct RClass *c)
ci
->
argc
=
1
;
ci
->
mid
=
ci
[
-
1
].
mid
;
if
(
MRB_PROC_CFUNC_P
(
p
))
{
stack_extend
(
mrb
,
3
);
mrb_
stack_extend
(
mrb
,
3
);
mrb
->
c
->
stack
[
0
]
=
self
;
mrb
->
c
->
stack
[
1
]
=
self
;
mrb
->
c
->
stack
[
2
]
=
mrb_nil_value
();
return
MRB_PROC_CFUNC
(
p
)(
mrb
,
self
);
}
ci
->
nregs
=
p
->
body
.
irep
->
nregs
;
stack_extend
(
mrb
,
(
ci
->
nregs
<
3
)
?
3
:
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
(
ci
->
nregs
<
3
)
?
3
:
ci
->
nregs
);
mrb
->
c
->
stack
[
0
]
=
self
;
mrb
->
c
->
stack
[
1
]
=
self
;
mrb
->
c
->
stack
[
2
]
=
mrb_nil_value
();
...
...
@@ -749,7 +749,7 @@ mrb_yield_with_class(mrb_state *mrb, mrb_value b, mrb_int argc, const mrb_value
ci
->
acc
=
CI_ACC_SKIP
;
mrb
->
c
->
stack
=
mrb
->
c
->
stack
+
n
;
ci
->
nregs
=
MRB_PROC_CFUNC_P
(
p
)
?
(
int
)(
argc
+
2
)
:
p
->
body
.
irep
->
nregs
;
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
mrb
->
c
->
stack
[
0
]
=
self
;
if
(
argc
>
0
)
{
...
...
@@ -800,7 +800,7 @@ mrb_yield_cont(mrb_state *mrb, mrb_value b, mrb_value self, mrb_int argc, const
p
=
mrb_proc_ptr
(
b
);
ci
=
mrb
->
c
->
ci
;
stack_extend
(
mrb
,
3
);
mrb_
stack_extend
(
mrb
,
3
);
mrb
->
c
->
stack
[
1
]
=
mrb_ary_new_from_values
(
mrb
,
argc
,
argv
);
mrb
->
c
->
stack
[
2
]
=
mrb_nil_value
();
ci
->
argc
=
-
1
;
...
...
@@ -944,7 +944,7 @@ mrb_vm_run(mrb_state *mrb, struct RProc *proc, mrb_value self, unsigned int stac
}
if
(
stack_keep
>
nregs
)
nregs
=
stack_keep
;
stack_extend
(
mrb
,
nregs
);
mrb_
stack_extend
(
mrb
,
nregs
);
stack_clear
(
c
->
stack
+
stack_keep
,
nregs
-
stack_keep
);
c
->
stack
[
0
]
=
self
;
result
=
mrb_vm_exec
(
mrb
,
proc
,
irep
->
iseq
);
...
...
@@ -1373,7 +1373,7 @@ RETRY_TRY_BLOCK:
ci
->
pc
=
pc
;
ci
->
acc
=
ci
[
-
1
].
nregs
;
mrb
->
c
->
stack
+=
ci
->
acc
;
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
regs
[
0
]
=
self
;
pc
=
irep
->
iseq
;
}
...
...
@@ -1437,7 +1437,7 @@ RETRY_TRY_BLOCK:
}
if
(
argc
>=
0
)
{
if
(
a
+
2
>=
irep
->
nregs
)
{
stack_extend
(
mrb
,
a
+
3
);
mrb_
stack_extend
(
mrb
,
a
+
3
);
}
regs
[
a
+
1
]
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
regs
[
a
+
2
]
=
blk
;
...
...
@@ -1510,7 +1510,7 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
ci
->
nregs
=
irep
->
nregs
;
stack_extend
(
mrb
,
(
argc
<
0
&&
ci
->
nregs
<
3
)
?
3
:
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
(
argc
<
0
&&
ci
->
nregs
<
3
)
?
3
:
ci
->
nregs
);
pc
=
irep
->
iseq
;
JUMP
;
}
...
...
@@ -1571,7 +1571,7 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
ci
->
nregs
=
irep
->
nregs
;
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
if
(
ci
->
argc
<
0
)
{
if
(
irep
->
nregs
>
3
)
{
stack_clear
(
regs
+
3
,
irep
->
nregs
-
3
);
...
...
@@ -1648,7 +1648,7 @@ RETRY_TRY_BLOCK:
mid
=
missing
;
if
(
argc
>=
0
)
{
if
(
a
+
2
>=
ci
->
nregs
)
{
stack_extend
(
mrb
,
a
+
3
);
mrb_
stack_extend
(
mrb
,
a
+
3
);
}
regs
[
a
+
1
]
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
regs
[
a
+
2
]
=
blk
;
...
...
@@ -1709,7 +1709,7 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
ci
->
nregs
=
irep
->
nregs
;
stack_extend
(
mrb
,
(
argc
<
0
&&
ci
->
nregs
<
3
)
?
3
:
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
(
argc
<
0
&&
ci
->
nregs
<
3
)
?
3
:
ci
->
nregs
);
pc
=
irep
->
iseq
;
JUMP
;
}
...
...
@@ -1967,7 +1967,7 @@ RETRY_TRY_BLOCK:
if
(
ci
<
ci0
)
{
mrb
->
c
->
stack
=
ci
[
1
].
stackent
;
}
stack_extend
(
mrb
,
irep
->
nregs
);
mrb_
stack_extend
(
mrb
,
irep
->
nregs
);
pc
=
mrb
->
c
->
rescue
[
--
ci
->
ridx
];
}
else
{
...
...
@@ -2200,10 +2200,10 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
if
(
ci
->
argc
<
0
)
{
stack_extend
(
mrb
,
(
irep
->
nregs
<
3
)
?
3
:
irep
->
nregs
);
mrb_
stack_extend
(
mrb
,
(
irep
->
nregs
<
3
)
?
3
:
irep
->
nregs
);
}
else
{
stack_extend
(
mrb
,
irep
->
nregs
);
mrb_
stack_extend
(
mrb
,
irep
->
nregs
);
}
pc
=
irep
->
iseq
;
}
...
...
@@ -2877,7 +2877,7 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
ci
->
nregs
=
irep
->
nregs
;
stack_extend
(
mrb
,
ci
->
nregs
);
mrb_
stack_extend
(
mrb
,
ci
->
nregs
);
stack_clear
(
regs
+
1
,
ci
->
nregs
-
1
);
pc
=
irep
->
iseq
;
JUMP
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment