-
Notifications
You must be signed in to change notification settings - Fork 683
Improve the string descriptor. #1036
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
Improve the string descriptor. #1036
Conversation
mem_cpointer_t ascii_collection_cp; | ||
/** Size of ascii string in bytes */ | ||
uint16_t size; | ||
} ascii_string; |
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.
ascii_string_t, and missing comments
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.
Fixed.
ECMA_STRING_CONTAINER_HEAP_CHUNKS, /**< actual data is on the heap | ||
in a ecma_collection_chunk_t chain */ | ||
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 string */ | ||
ECMA_STRING_CONTAINER_HEAP_ASCII_STRING, /**< actual data is on the heap as an ascii string */ |
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 would put ASCII_STRING first.
ECMA_STRING_CONTAINER_HEAP_NUMBER, /**< actual data is on the heap as a ecma_number_t */ | ||
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 string */ |
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.
Please move this right after the ECMA_STRING_CONTAINER_HEAP_ASCII_STRING.
Thanks for the comments, I've updated and rebased with master. |
{ | ||
string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_HEAP_ASCII_STRING | ECMA_STRING_REF_ONE; | ||
const size_t data_size = new_size; | ||
void *data_p = (void *) mem_heap_alloc_block (data_size); |
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 don't you use lit_utf8_byte_t *
here, if you cast void* to it anyway?
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.
Good point, I've updated these pointers.
What is the effect on memory of this patch? |
|
Cool a string based test improved! |
@robertsipka, could you also compare with '--mem-stats'? @bzsolt can help if you don't know how to. |
448d2ee
to
cee537e
Compare
|
string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_HEAP_UTF8_STRING | ECMA_STRING_REF_ONE; | ||
const size_t data_size = new_size + sizeof (ecma_string_heap_header_t); | ||
ecma_string_heap_header_t *data_p = (ecma_string_heap_header_t *) mem_heap_alloc_block (data_size); | ||
lit_utf8_size_t bytes_copied = ecma_string_to_utf8_string (string1_p, | ||
(lit_utf8_byte_t *) (data_p + 1), |
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.
wrong indentation
mem_cpointer_t ascii_collection_cp; | ||
/** Size of ascii string in bytes */ | ||
uint16_t size; | ||
} ascii_string_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.
Rename to ascii_string
, this is not a typedef
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.
Renamed.
LGTM |
1 similar comment
LGTM |
Separate the utf-8 and ascii strings. In case of ascii strings the size is equal to the length, so we able to store this information in the string descriptor instead of using the string header to store it. JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
Thanks, I've rebased it with master. |
Separate the utf-8 and ascii strings.
In case of ascii strings the size is equal to the length, so we able to store this information
in the string descriptor instead of using the string header to store it.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com