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
5fbea87f
Unverified
Commit
5fbea87f
authored
Sep 10, 2021
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codegen.c: resurrect `s->lastpc` to reduce `iseq` scans.
When parsing scripts frequent scans could cost too much.
parent
3693187b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+10
-5
No files found.
mrbgems/mruby-compiler/core/codegen.c
View file @
5fbea87f
...
...
@@ -55,6 +55,7 @@ typedef struct scope {
uint16_t
sp
;
uint32_t
pc
;
uint32_t
lastpc
;
uint32_t
lastlabel
;
int
ainfo
:
15
;
mrb_bool
mscope
:
1
;
...
...
@@ -226,12 +227,14 @@ gen_S(codegen_scope *s, uint16_t i)
static
void
genop_0
(
codegen_scope
*
s
,
mrb_code
i
)
{
s
->
lastpc
=
s
->
pc
;
gen_B
(
s
,
i
);
}
static
void
genop_1
(
codegen_scope
*
s
,
mrb_code
i
,
uint16_t
a
)
{
s
->
lastpc
=
s
->
pc
;
if
(
a
>
0xff
)
{
gen_B
(
s
,
OP_EXT1
);
gen_B
(
s
,
i
);
...
...
@@ -246,6 +249,7 @@ genop_1(codegen_scope *s, mrb_code i, uint16_t a)
static
void
genop_2
(
codegen_scope
*
s
,
mrb_code
i
,
uint16_t
a
,
uint16_t
b
)
{
s
->
lastpc
=
s
->
pc
;
if
(
a
>
0xff
&&
b
>
0xff
)
{
gen_B
(
s
,
OP_EXT3
);
gen_B
(
s
,
i
);
...
...
@@ -300,6 +304,7 @@ genop_W(codegen_scope *s, mrb_code i, uint32_t a)
uint8_t
a2
=
(
a
>>
8
)
&
0xff
;
uint8_t
a3
=
a
&
0xff
;
s
->
lastpc
=
s
->
pc
;
gen_B
(
s
,
i
);
gen_B
(
s
,
a1
);
gen_B
(
s
,
a2
);
...
...
@@ -468,13 +473,13 @@ rewind_pc(codegen_scope *s)
static
struct
mrb_insn_data
mrb_last_insn
(
codegen_scope
*
s
)
{
return
mrb_decode_insn
(
mrb_prev_pc
(
s
,
pc_addr
(
s
))
);
return
mrb_decode_insn
(
&
s
->
iseq
[
s
->
lastpc
]
);
}
static
mrb_bool
no_peephole
(
codegen_scope
*
s
)
{
return
no_optimize
(
s
)
||
s
->
lastlabel
==
s
->
pc
||
s
->
pc
==
0
;
return
no_optimize
(
s
)
||
s
->
lastlabel
==
s
->
pc
||
s
->
pc
==
0
||
s
->
pc
==
s
->
lastpc
;
}
#define JMPLINK_START UINT32_MAX
...
...
@@ -500,7 +505,7 @@ genjmp(codegen_scope *s, mrb_code i, uint32_t pc)
{
uint32_t
pos
;
gen
_B
(
s
,
i
);
gen
op_0
(
s
,
i
);
pos
=
s
->
pc
;
gen_jmpdst
(
s
,
pc
);
return
pos
;
...
...
@@ -553,11 +558,11 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val)
if
(
a
>
0xff
)
{
gen_B
(
s
,
OP_EXT1
);
gen
_B
(
s
,
i
);
gen
op_0
(
s
,
i
);
gen_S
(
s
,
a
);
}
else
{
gen
_B
(
s
,
i
);
gen
op_0
(
s
,
i
);
gen_B
(
s
,
(
uint8_t
)
a
);
}
pos
=
s
->
pc
;
...
...
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