-
Notifications
You must be signed in to change notification settings - Fork 677
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
Change pool-based allocation to heap-based allocation in jerry.c #936
Change pool-based allocation to heap-based allocation in jerry.c #936
Conversation
@@ -1848,7 +1848,8 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled | |||
|
|||
snapshot_last_compiled_code_offset = snapshot_buffer_write_offset; | |||
|
|||
compiled_code_map_entry_t *new_entry = (compiled_code_map_entry_t *) mem_pools_alloc (); | |||
compiled_code_map_entry_t *new_entry = | |||
(compiled_code_map_entry_t *) mem_heap_alloc_block (sizeof (compiled_code_map_entry_t)); |
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 think this is an incorrect style. A temporary variable could help.
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.
No. Seriously. I - will - not - add - extra - statements, - temporaries, - assignments - just - because - of - a - style - checker.
Style checkers should promote readability. Nicer style. But as soon as they force you to write different (not differently styled!) code than you think it's optimal, then there is something terribly wrong.
(And the other issue is: the temp should be of type compiled_code_map_entry_t *
, I guess. But then, there is no way to get that line under the 120 chars limit. Even a one-character temp would make a 121 chars line. So, that line should be broken somewhere too, which causes the same issue as we have now.)
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.
But the proposed solution looks ugly. Introduce a two parameter macro for allocating, or improve the style checker.
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.
compiled_code_map_entry_t *new_entry;
new_entry = (compiled_code_map_entry_t *) mem_heap_alloc_block (sizeof (compiled_code_map_entry_t));
There was an abuse of memory pools in jerry.c: `compiled_code_map_entry_t` is not an ECMA data model object but was still alocated/freed via mem pool functions. Changed the appropriate calls to heap-related functions. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
Updated. |
LGTM |
1 similar comment
LGTM |
There was an abuse of memory pools in jerry.c:
compiled_code_map_entry_t
is not an ECMA data model object but was still alocated/freed via
mem pool functions. Changed the appropriate calls to heap-related
functions.
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]