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
6a6586ca
Unverified
Commit
6a6586ca
authored
Oct 29, 2018
by
take-cheeze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce unnecessary symbol table entry
parent
486c9d90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
include/mruby/symbol.h
include/mruby/symbol.h
+7
-0
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+7
-3
No files found.
include/mruby/symbol.h
View file @
6a6586ca
...
...
@@ -16,6 +16,7 @@ MRB_BEGIN_DECL
typedef
enum
mrb_reserved_symbol
{
mrb_sym_null
=
0
,
// NULL symbol
mrb_sym_add
=
1
,
// +
mrb_sym_sub
=
2
,
// -
mrb_sym_mul
=
3
,
// *
...
...
@@ -25,9 +26,15 @@ typedef enum mrb_reserved_symbol {
mrb_sym_le
=
7
,
// <=
mrb_sym_gt
=
8
,
// >
mrb_sym_ge
=
9
,
// >=
mrb_sym_method_missing
=
10
,
// method_missing
}
mrb_reserved_symbol
;
static
inline
mrb_bool
mrb_symbol_constsym_send_p
(
mrb_sym
sym
)
{
return
mrb_sym_add
<=
sym
&&
sym
<=
mrb_sym_ge
;
}
MRB_END_DECL
#endif
/* MRUBY_SYMBOL_H */
mrbgems/mruby-compiler/core/codegen.c
View file @
6a6586ca
...
...
@@ -18,6 +18,7 @@
#include <mruby/opcode.h>
#include <mruby/re.h>
#include <mruby/throw.h>
#include <mruby/symbol.h>
#ifndef MRB_CODEGEN_LEVEL_MAX
#define MRB_CODEGEN_LEVEL_MAX 1024
...
...
@@ -982,8 +983,9 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe)
gen_move
(
s
,
cursp
(),
recv
,
1
);
skip
=
genjmp2
(
s
,
OP_JMPNIL
,
cursp
(),
0
,
val
);
}
// TODO: don't new when unused
idx
=
new_sym
(
s
,
sym
);
if
(
!
mrb_symbol_constsym_send_p
(
sym
))
{
idx
=
new_sym
(
s
,
sym
);
}
tree
=
tree
->
cdr
->
cdr
->
car
;
if
(
tree
)
{
n
=
gen_values
(
s
,
tree
->
car
,
VAL
,
sp
?
1
:
0
);
...
...
@@ -2024,7 +2026,9 @@ codegen(codegen_scope *s, node *tree, int val)
push
();
pop
();
pop
();
pop
();
idx
=
new_sym
(
s
,
sym
);
if
(
!
mrb_symbol_constsym_send_p
(
sym
))
{
idx
=
new_sym
(
s
,
sym
);
}
if
(
len
==
1
&&
name
[
0
]
==
'+'
)
{
gen_addsub
(
s
,
OP_ADD
,
cursp
());
}
...
...
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