Skip to content
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

Conversation

ruben-ayrapetyan
Copy link
Contributor

  • heap area is now 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.

Related issue: #44

@ruben-ayrapetyan ruben-ayrapetyan added normal memory management Related to memory management or garbage collection development Feature implementation labels May 14, 2015
@ruben-ayrapetyan ruben-ayrapetyan added this to the Core ECMA features milestone May 14, 2015
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])
Copy link
Contributor

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.

Copy link
Contributor Author

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]
@ruben-ayrapetyan ruben-ayrapetyan force-pushed the Ruben-update-get-block-start-for-chunked-blocks branch from c7e0893 to c537b83 Compare May 14, 2015 20:33
@ruben-ayrapetyan
Copy link
Contributor Author

@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)
Copy link
Contributor

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;
}

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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));

@egavrin
Copy link
Contributor

egavrin commented May 14, 2015

make push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Feature implementation memory management Related to memory management or garbage collection normal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants