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
1c361f8a
Unverified
Commit
1c361f8a
authored
Nov 30, 2020
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Nov 30, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5206 from dearblue/dumpirep
Improves dump irep
parents
d56db229
3bc9453c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
38 deletions
+10
-38
src/dump.c
src/dump.c
+10
-38
No files found.
src/dump.c
View file @
1c361f8a
...
...
@@ -48,14 +48,15 @@ write_irep_header(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
return
cur
-
buf
;
}
static
size_t
get_iseq_block_size
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
)
{
size_t
size
=
0
;
size
+=
sizeof
(
uint16_t
);
/* clen */
size
+=
sizeof
(
uint16_t
);
/* ilen */
size
+=
irep
->
ilen
*
sizeof
(
mrb_code
);
/* iseq(n) */
size
+=
irep
->
clen
*
sizeof
(
struct
mrb_irep_catch_handler
);
return
size
;
}
...
...
@@ -64,10 +65,13 @@ static ptrdiff_t
write_iseq_block
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
,
uint8_t
*
buf
,
uint8_t
flags
)
{
uint8_t
*
cur
=
buf
;
size_t
seqlen
=
irep
->
ilen
*
sizeof
(
mrb_code
)
+
irep
->
clen
*
sizeof
(
struct
mrb_irep_catch_handler
);
cur
+=
uint16_to_bin
(
irep
->
clen
,
cur
);
/* number of catch handlers */
cur
+=
uint16_to_bin
(
irep
->
ilen
,
cur
);
/* number of opcode */
memcpy
(
cur
,
irep
->
iseq
,
irep
->
ilen
*
sizeof
(
mrb_code
)
);
cur
+=
irep
->
ilen
*
sizeof
(
mrb_code
)
;
memcpy
(
cur
,
irep
->
iseq
,
seqlen
);
cur
+=
seqlen
;
return
cur
-
buf
;
}
...
...
@@ -136,8 +140,9 @@ get_pool_block_size(mrb_state *mrb, const mrb_irep *irep)
default:
/* packed IREP_TT_STRING */
{
mrb_int
len
=
irep
->
pool
[
pool_no
].
tt
>>
1
;
/* unpack length */
mrb_int
len
=
irep
->
pool
[
pool_no
].
tt
>>
2
;
/* unpack length */
mrb_assert_int_fit
(
mrb_int
,
len
,
size_t
,
SIZE_MAX
);
size
+=
sizeof
(
uint16_t
);
size
+=
(
size_t
)
len
+
1
;
}
break
;
...
...
@@ -261,41 +266,13 @@ write_syms_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
return
cur
-
buf
;
}
static
size_t
get_catch_table_block_size
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
)
{
size_t
size
=
0
;
size
+=
sizeof
(
uint16_t
);
/* number of catch handler */
size
+=
(
sizeof
(
struct
mrb_irep_catch_handler
))
*
irep
->
clen
;
return
size
;
}
static
ptrdiff_t
write_catch_table_block
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
,
uint8_t
*
buf
)
{
uint8_t
*
cur
=
buf
;
const
struct
mrb_irep_catch_handler
*
e
=
mrb_irep_catch_handler_table
(
irep
);
mrb_static_assert1
(
sizeof
(
*
e
)
==
13
);
if
(
e
==
NULL
)
return
0
;
/* irep->clen has already been written before iseq block */
memcpy
(
cur
,
(
const
void
*
)
e
,
sizeof
(
*
e
)
*
irep
->
clen
);
cur
+=
sizeof
(
*
e
)
*
irep
->
clen
;
return
cur
-
buf
;
}
static
size_t
get_irep_record_size_1
(
mrb_state
*
mrb
,
const
mrb_irep
*
irep
)
{
size_t
size
=
0
;
size
+=
get_irep_header_size
(
mrb
);
size
+=
sizeof
(
uint16_t
);
size
+=
get_iseq_block_size
(
mrb
,
irep
);
size
+=
get_catch_table_block_size
(
mrb
,
irep
);
size
+=
get_pool_block_size
(
mrb
,
irep
);
size
+=
get_syms_block_size
(
mrb
,
irep
);
return
size
;
...
...
@@ -325,13 +302,7 @@ write_irep_record(mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, size_t *ir
}
bin
+=
write_irep_header
(
mrb
,
irep
,
bin
);
/*
* The catch handler table is after iseq block, but the number of
* elements is placed before iseq block.
*/
bin
+=
uint16_to_bin
(
irep
->
clen
,
bin
);
bin
+=
write_iseq_block
(
mrb
,
irep
,
bin
,
flags
);
bin
+=
write_catch_table_block
(
mrb
,
irep
,
bin
);
bin
+=
write_pool_block
(
mrb
,
irep
,
bin
);
bin
+=
write_syms_block
(
mrb
,
irep
,
bin
);
...
...
@@ -393,6 +364,7 @@ write_section_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, size_t *l
if
(
result
!=
MRB_DUMP_OK
)
{
return
result
;
}
mrb_assert
(
rsize
==
get_irep_record_size
(
mrb
,
irep
));
*
len_p
=
cur
-
bin
+
rsize
;
write_section_irep_header
(
mrb
,
*
len_p
,
bin
);
...
...
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