-
Notifications
You must be signed in to change notification settings - Fork 683
Storing byte code size in the byte code header. #948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -1316,12 +1316,12 @@ void | |||
ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */ | |||
{ | |||
/* Abort program if maximum reference number is reached. */ | |||
if ((bytecode_p->status_flags >> ECMA_BYTECODE_REF_SHIFT) >= 0x3ff) | |||
if (bytecode_p->refs >= 0xffff) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use UINT16_MAX
58ff53e
to
7a46bea
Compare
@zherczeg, please rebase to the current master |
Raspberry Pi2 results:
Binary sizesmaster: 183,388 |
7a46bea
to
66bba0b
Compare
I'd use the |
__extension__ uint32_t is_run_global : 1; /**< flag, indicating whether the snapshot | ||
* was dumped as 'Global scope'-mode code (true) | ||
* or as eval-mode code (false) */ | ||
uint8_t is_run_global; /**< flag, indicating whether the snapshot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply use the type bool
here? I don't see any alignment requirements or need for multiple flags that would necessitate an integer type with fixed bit-length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like using bools in structures because its storage size is unclear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First I thought that exact size does not matter here since the struct is not used that often. Now I realize that it does matter, since this header becomes part of the snapshot buffer and will be written to disk, so we will need to know the exact offsets of fields and data, etc. That's really a point against bool
.
However, there might still be some issues with uint_8
and also with the way the snapshot buffer is constructed (in jerry.c). The size of a struct may differ from machine to machine, AFAIK it's up to the compiler to define alignments, padding, whatnot. Would this struct be packed, then its size would be 13 bytes, on a regular 32 bit machine it would most probably be 16 bytes in unpacked form, but actually there is no guarantee for that (and there may be exotic architectures where we might get a different result). Making the last field uint32_t
makes things a bit more portable IMHO.
As for my just-realized concerns with jerry.c, I'll make a comment there.
66bba0b
to
0396fbe
Compare
Issues fixed. |
6745833
to
b263619
Compare
@@ -165,7 +165,7 @@ util_free_literal (lexer_literal_t *literal_p) /**< literal */ | |||
{ | |||
if (!(literal_p->status_flags & LEXER_FLAG_SOURCE_PTR)) | |||
{ | |||
PARSER_FREE ((uint8_t *) literal_p->u.char_p); | |||
mem_heap_free_block_size_stored ((uint8_t *) literal_p->u.char_p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better cast this to void *
After the casts are fixed, LGTM (FWIW) |
memory consumption, because the new allocator uses less memory if the size as available when a block is freed. Snapshot generation is also simplified. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
b263619
to
d190ca4
Compare
I hope I fixed everything. |
LGTM |
This reduces the memory consumption, because the new allocator uses less memory if
the size as available when a block is freed. Snapshot generation is also simplified.