-
Notifications
You must be signed in to change notification settings - Fork 672
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
Fast search of data space start for one-chunked blocks #64
Fast search of data space start for one-chunked blocks #64
Conversation
memset (ptrs[j], 0, sizes[j]); | ||
|
||
JERRY_ASSERT (ptrs[j] == NULL | ||
|| mem_heap_get_block_start (ptrs[j] + (size_t) rand () % sizes[j]) == ptrs[j]); | ||
if (is_one_chunked[j]) |
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.
Maybe we can merge this condition into assert
? Same for below.
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.
Yes, we could do it.
But, perhaps, it would be more readable without the merge, because so we see that assertion is intended explicitly for one-chunked blocks.
…for one-chunked blocks, removing general blocks support from the procedure. - heap area is aligned on heap chunk size; - mem_heap_get_block_start is renamed to mem_heap_get_chunked_block_start, now this interface is applicable only to one-chunked blocks, and is significantly faster - instead of iterating list of heap blocks to find block header, it just aligns value of pointer to heap chunk size. JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected]
c7e0893
to
c537b83
Compare
@egavrin , I've fixed the pull request according to your note. |
|| next_block_p == NULL)); | ||
is_found = (ptr > block_iter_p | ||
&& (ptr < next_block_p | ||
|| next_block_p == NULL)); | ||
|
||
if (is_found) |
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.
Not related to this pull request, but I think these lines (922..934), can be revised:
JERRY_ASSERT (is_found && !mem_is_block_free (block_iter_p));
JERRY_ASSERT (is_found && block_iter_p + 1 <= ptr);
JERRY_ASSERT (is_found && ptr < ((uint8_t*) (block_iter_p + 1) + block_iter_p->allocated_bytes));
VALGRIND_NOACCESS_STRUCT (block_iter_p);
if (is_found)
{
break;
}
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.
From what view point?
Could you, please, describe in more details?
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.
Two separate if (is_found)
, as for me, this condition should be inside JERRY_ASSERT
.
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.
Thanks.
The logic here is "if block is found, assert the following its properties", so if (is_found)
is more readable in the case. Considering that the whole loop containing the if
is intended for debug (compiled under !JERRY_NDEBUG condition), this style seems to be suitable for the case.
Otherwise, we would write several lines similar to the following:
JERRY_ASSERT (!is_found || (condition));
|
e67516f
to
c537b83
Compare
now this interface is applicable only to one-chunked blocks,
and is significantly faster - instead of iterating list of heap blocks
to find block header, it just aligns value of pointer to heap chunk size.
Related issue: #44