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
58f5115b
Commit
58f5115b
authored
Aug 11, 2017
by
Christopher Aue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored OP_SEND and OP_SUPER and calculate argc right at the top
parent
d077a5f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
72 deletions
+23
-72
src/vm.c
src/vm.c
+23
-72
No files found.
src/vm.c
View file @
58f5115b
...
@@ -1342,21 +1342,18 @@ RETRY_TRY_BLOCK:
...
@@ -1342,21 +1342,18 @@ RETRY_TRY_BLOCK:
/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C)) */
/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C)) */
int
a
=
GETARG_A
(
i
);
int
a
=
GETARG_A
(
i
);
int
n
=
GETARG_C
(
i
);
int
n
=
GETARG_C
(
i
);
int
argc
=
(
n
==
CALL_MAXARGS
)
?
-
1
:
n
;
int
bidx
=
(
argc
<
0
)
?
a
+
2
:
a
+
n
+
1
;
struct
RProc
*
m
;
struct
RProc
*
m
;
struct
RClass
*
c
;
struct
RClass
*
c
;
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
mrb_value
recv
,
result
;
mrb_value
recv
,
result
;
mrb_sym
mid
=
syms
[
GETARG_B
(
i
)];
mrb_sym
mid
=
syms
[
GETARG_B
(
i
)];
int
bidx
;
mrb_value
blk
;
mrb_value
blk
;
recv
=
regs
[
a
];
recv
=
regs
[
a
];
if
(
n
==
CALL_MAXARGS
)
{
bidx
=
a
+
2
;
}
else
{
bidx
=
a
+
n
+
1
;
}
if
(
GET_OPCODE
(
i
)
!=
OP_SENDB
)
{
if
(
GET_OPCODE
(
i
)
!=
OP_SENDB
)
{
if
(
bidx
>=
ci
->
nregs
)
{
if
(
bidx
>=
ci
->
nregs
)
{
stack_extend
(
mrb
,
bidx
+
1
);
stack_extend
(
mrb
,
bidx
+
1
);
...
@@ -1382,24 +1379,17 @@ RETRY_TRY_BLOCK:
...
@@ -1382,24 +1379,17 @@ RETRY_TRY_BLOCK:
mrb_sym
missing
=
mrb_intern_lit
(
mrb
,
"method_missing"
);
mrb_sym
missing
=
mrb_intern_lit
(
mrb
,
"method_missing"
);
m
=
mrb_method_search_vm
(
mrb
,
&
c
,
missing
);
m
=
mrb_method_search_vm
(
mrb
,
&
c
,
missing
);
if
(
!
m
)
{
if
(
!
m
)
{
mrb_value
args
;
mrb_value
args
=
(
argc
<
0
)
?
regs
[
a
+
1
]
:
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
if
(
n
==
CALL_MAXARGS
)
{
args
=
regs
[
a
+
1
];
}
else
{
args
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
}
ERR_PC_SET
(
mrb
,
pc
);
ERR_PC_SET
(
mrb
,
pc
);
mrb_method_missing
(
mrb
,
mid
,
recv
,
args
);
mrb_method_missing
(
mrb
,
mid
,
recv
,
args
);
}
}
if
(
n
!=
CALL_MAXARGS
)
{
if
(
argc
>=
0
)
{
if
(
a
+
2
>=
irep
->
nregs
)
{
if
(
a
+
2
>=
irep
->
nregs
)
{
stack_extend
(
mrb
,
a
+
3
);
stack_extend
(
mrb
,
a
+
3
);
}
}
regs
[
a
+
1
]
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
regs
[
a
+
1
]
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
regs
[
a
+
2
]
=
blk
;
regs
[
a
+
2
]
=
blk
;
n
=
CALL_MAXARGS
;
argc
=
-
1
;
}
}
mrb_ary_unshift
(
mrb
,
regs
[
a
+
1
],
mrb_symbol_value
(
mid
));
mrb_ary_unshift
(
mrb
,
regs
[
a
+
1
],
mrb_symbol_value
(
mid
));
mid
=
missing
;
mid
=
missing
;
...
@@ -1411,6 +1401,7 @@ RETRY_TRY_BLOCK:
...
@@ -1411,6 +1401,7 @@ RETRY_TRY_BLOCK:
ci
->
proc
=
m
;
ci
->
proc
=
m
;
ci
->
stackent
=
mrb
->
c
->
stack
;
ci
->
stackent
=
mrb
->
c
->
stack
;
ci
->
target_class
=
c
;
ci
->
target_class
=
c
;
ci
->
argc
=
argc
;
ci
->
pc
=
pc
+
1
;
ci
->
pc
=
pc
+
1
;
ci
->
acc
=
a
;
ci
->
acc
=
a
;
...
@@ -1419,14 +1410,7 @@ RETRY_TRY_BLOCK:
...
@@ -1419,14 +1410,7 @@ RETRY_TRY_BLOCK:
mrb
->
c
->
stack
+=
a
;
mrb
->
c
->
stack
+=
a
;
if
(
MRB_PROC_CFUNC_P
(
m
))
{
if
(
MRB_PROC_CFUNC_P
(
m
))
{
if
(
n
==
CALL_MAXARGS
)
{
ci
->
nregs
=
(
argc
<
0
)
?
3
:
n
+
2
;
ci
->
argc
=
-
1
;
ci
->
nregs
=
3
;
}
else
{
ci
->
argc
=
n
;
ci
->
nregs
=
n
+
2
;
}
result
=
m
->
body
.
func
(
mrb
,
recv
);
result
=
m
->
body
.
func
(
mrb
,
recv
);
mrb_gc_arena_restore
(
mrb
,
ai
);
mrb_gc_arena_restore
(
mrb
,
ai
);
mrb_gc_arena_shrink
(
mrb
,
ai
);
mrb_gc_arena_shrink
(
mrb
,
ai
);
...
@@ -1468,14 +1452,7 @@ RETRY_TRY_BLOCK:
...
@@ -1468,14 +1452,7 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
syms
=
irep
->
syms
;
ci
->
nregs
=
irep
->
nregs
;
ci
->
nregs
=
irep
->
nregs
;
if
(
n
==
CALL_MAXARGS
)
{
stack_extend
(
mrb
,
(
argc
<
0
&&
irep
->
nregs
<
3
)
?
3
:
irep
->
nregs
);
ci
->
argc
=
-
1
;
stack_extend
(
mrb
,
(
irep
->
nregs
<
3
)
?
3
:
irep
->
nregs
);
}
else
{
ci
->
argc
=
n
;
stack_extend
(
mrb
,
irep
->
nregs
);
}
pc
=
irep
->
iseq
;
pc
=
irep
->
iseq
;
JUMP
;
JUMP
;
}
}
...
@@ -1559,15 +1536,18 @@ RETRY_TRY_BLOCK:
...
@@ -1559,15 +1536,18 @@ RETRY_TRY_BLOCK:
CASE
(
OP_SUPER
)
{
CASE
(
OP_SUPER
)
{
/* A C R(A) := super(R(A+1),... ,R(A+C+1)) */
/* A C R(A) := super(R(A+1),... ,R(A+C+1)) */
int
a
=
GETARG_A
(
i
);
int
n
=
GETARG_C
(
i
);
int
argc
=
(
n
==
CALL_MAXARGS
)
?
-
1
:
n
;
int
bidx
=
(
argc
<
0
)
?
a
+
2
:
a
+
n
+
1
;
mrb_value
recv
;
mrb_value
recv
;
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
struct
RProc
*
m
;
struct
RProc
*
m
;
struct
RClass
*
c
;
struct
RClass
*
c
;
mrb_sym
mid
=
ci
->
mid
;
mrb_sym
mid
=
ci
->
mid
;
int
a
=
GETARG_A
(
i
);
int
n
=
GETARG_C
(
i
);
mrb_value
blk
;
mrb_value
blk
;
int
bidx
;
if
(
mid
==
0
||
!
ci
->
target_class
)
{
if
(
mid
==
0
||
!
ci
->
target_class
)
{
mrb_value
exc
;
mrb_value
exc
;
...
@@ -1577,12 +1557,6 @@ RETRY_TRY_BLOCK:
...
@@ -1577,12 +1557,6 @@ RETRY_TRY_BLOCK:
goto
L_RAISE
;
goto
L_RAISE
;
}
}
recv
=
regs
[
0
];
recv
=
regs
[
0
];
if
(
n
==
CALL_MAXARGS
)
{
bidx
=
a
+
2
;
}
else
{
bidx
=
a
+
n
+
1
;
}
blk
=
regs
[
bidx
];
blk
=
regs
[
bidx
];
if
(
!
mrb_nil_p
(
blk
)
&&
mrb_type
(
blk
)
!=
MRB_TT_PROC
)
{
if
(
!
mrb_nil_p
(
blk
)
&&
mrb_type
(
blk
)
!=
MRB_TT_PROC
)
{
mrb_value
result
;
mrb_value
result
;
...
@@ -1594,31 +1568,24 @@ RETRY_TRY_BLOCK:
...
@@ -1594,31 +1568,24 @@ RETRY_TRY_BLOCK:
result
=
mrb_convert_type
(
mrb
,
blk
,
MRB_TT_PROC
,
"Proc"
,
"to_proc"
);
result
=
mrb_convert_type
(
mrb
,
blk
,
MRB_TT_PROC
,
"Proc"
,
"to_proc"
);
regs
[
bidx
]
=
result
;
regs
[
bidx
]
=
result
;
}
}
c
=
mrb
->
c
->
ci
->
target_class
->
super
;
c
=
ci
->
target_class
->
super
;
m
=
mrb_method_search_vm
(
mrb
,
&
c
,
mid
);
m
=
mrb_method_search_vm
(
mrb
,
&
c
,
mid
);
if
(
!
m
)
{
if
(
!
m
)
{
mrb_sym
missing
=
mrb_intern_lit
(
mrb
,
"method_missing"
);
mrb_sym
missing
=
mrb_intern_lit
(
mrb
,
"method_missing"
);
m
=
mrb_method_search_vm
(
mrb
,
&
c
,
missing
);
m
=
mrb_method_search_vm
(
mrb
,
&
c
,
missing
);
if
(
!
m
)
{
if
(
!
m
)
{
mrb_value
args
;
mrb_value
args
=
(
argc
<
0
)
?
regs
[
a
+
1
]
:
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
if
(
n
==
CALL_MAXARGS
)
{
args
=
regs
[
a
+
1
];
}
else
{
args
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
}
ERR_PC_SET
(
mrb
,
pc
);
ERR_PC_SET
(
mrb
,
pc
);
mrb_method_missing
(
mrb
,
mid
,
recv
,
args
);
mrb_method_missing
(
mrb
,
mid
,
recv
,
args
);
}
}
mid
=
missing
;
mid
=
missing
;
if
(
n
!=
CALL_MAXARGS
)
{
if
(
argc
>=
0
)
{
if
(
a
+
2
>=
ci
->
nregs
)
{
if
(
a
+
2
>=
ci
->
nregs
)
{
stack_extend
(
mrb
,
a
+
3
);
stack_extend
(
mrb
,
a
+
3
);
}
}
regs
[
a
+
1
]
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
regs
[
a
+
1
]
=
mrb_ary_new_from_values
(
mrb
,
n
,
regs
+
a
+
1
);
regs
[
a
+
2
]
=
blk
;
regs
[
a
+
2
]
=
blk
;
n
=
CALL_MAXARGS
;
argc
=
-
1
;
}
}
mrb_ary_unshift
(
mrb
,
regs
[
a
+
1
],
mrb_symbol_value
(
ci
->
mid
));
mrb_ary_unshift
(
mrb
,
regs
[
a
+
1
],
mrb_symbol_value
(
ci
->
mid
));
}
}
...
@@ -1630,12 +1597,7 @@ RETRY_TRY_BLOCK:
...
@@ -1630,12 +1597,7 @@ RETRY_TRY_BLOCK:
ci
->
stackent
=
mrb
->
c
->
stack
;
ci
->
stackent
=
mrb
->
c
->
stack
;
ci
->
target_class
=
c
;
ci
->
target_class
=
c
;
ci
->
pc
=
pc
+
1
;
ci
->
pc
=
pc
+
1
;
if
(
n
==
CALL_MAXARGS
)
{
ci
->
argc
=
argc
;
ci
->
argc
=
-
1
;
}
else
{
ci
->
argc
=
n
;
}
/* prepare stack */
/* prepare stack */
mrb
->
c
->
stack
+=
a
;
mrb
->
c
->
stack
+=
a
;
...
@@ -1643,13 +1605,7 @@ RETRY_TRY_BLOCK:
...
@@ -1643,13 +1605,7 @@ RETRY_TRY_BLOCK:
if
(
MRB_PROC_CFUNC_P
(
m
))
{
if
(
MRB_PROC_CFUNC_P
(
m
))
{
mrb_value
v
;
mrb_value
v
;
ci
->
nregs
=
(
argc
<
0
)
?
3
:
n
+
2
;
if
(
n
==
CALL_MAXARGS
)
{
ci
->
nregs
=
3
;
}
else
{
ci
->
nregs
=
n
+
2
;
}
v
=
m
->
body
.
func
(
mrb
,
recv
);
v
=
m
->
body
.
func
(
mrb
,
recv
);
mrb_gc_arena_restore
(
mrb
,
ai
);
mrb_gc_arena_restore
(
mrb
,
ai
);
if
(
mrb
->
exc
)
goto
L_RAISE
;
if
(
mrb
->
exc
)
goto
L_RAISE
;
...
@@ -1684,12 +1640,7 @@ RETRY_TRY_BLOCK:
...
@@ -1684,12 +1640,7 @@ RETRY_TRY_BLOCK:
pool
=
irep
->
pool
;
pool
=
irep
->
pool
;
syms
=
irep
->
syms
;
syms
=
irep
->
syms
;
ci
->
nregs
=
irep
->
nregs
;
ci
->
nregs
=
irep
->
nregs
;
if
(
n
==
CALL_MAXARGS
)
{
stack_extend
(
mrb
,
(
argc
<
0
&&
irep
->
nregs
<
3
)
?
3
:
irep
->
nregs
);
stack_extend
(
mrb
,
(
irep
->
nregs
<
3
)
?
3
:
irep
->
nregs
);
}
else
{
stack_extend
(
mrb
,
irep
->
nregs
);
}
pc
=
irep
->
iseq
;
pc
=
irep
->
iseq
;
JUMP
;
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