-
Notifications
You must be signed in to change notification settings - Fork 686
[API] Improve the performance of the external magic id search #1506
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
[API] Improve the performance of the external magic id search #1506
Conversation
jerry-core/lit/lit-magic-strings.c
Outdated
| JERRY_ASSERT (JERRY_CONTEXT (lit_magic_string_ex_sizes)[id] == string_size); | ||
| JERRY_ASSERT (JERRY_CONTEXT (lit_magic_string_ex_sizes)[id] <= LIT_MAGIC_STRING_LENGTH_LIMIT); | ||
|
|
||
| /* Check the order of the strings */ |
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 we should add more description here. What is the right order? Maybe with a small example.
abf81a7 to
b4859e1
Compare
jerry-core/lit/lit-magic-strings.c
Outdated
| const lit_utf8_byte_t *prev_ex_string_p = lit_get_magic_string_ex_utf8 (prev_id); | ||
| const lit_utf8_byte_t *curr_ex_string_p = lit_get_magic_string_ex_utf8 (id); | ||
| const int string_compare = memcmp (prev_ex_string_p, curr_ex_string_p, string_size); | ||
| JERRY_ASSERT (string_compare < 0); |
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.
JERRY_ASSERT (memcmp (prev_ex_string_p, curr_ex_string_p, string_size) < 0)
jerry-core/lit/lit-magic-strings.c
Outdated
| } | ||
| else if (found_size_range) | ||
| { | ||
| 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.
Are you sure this is correct?
a
b
c
d
e
ff
gg
Search e.
First, you find d, and found_size_range is set to 1. Then you find ff, and the loop aborts. If I understand correctly.
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've fixed it, thanks.
After this patch, we have to provide external strings ordered by size and lexicographically. We can do this with jerry_parse_and_save_literals() (jerryscript-project#1500). JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
b4859e1 to
f6c6937
Compare
LaszloLango
left a comment
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.
LGTM
| * Extended Magic Strings | ||
| */ | ||
| #define JERRY_MAGIC_STRING_ITEMS \ | ||
| JERRY_MAGIC_STRING_DEF (GLOBAL, global) \ |
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.
The global is already in the list of ECMA magic strings, so it doesn't have to be an external magic string because the defined magic string id will be found at first. But I think it could be removed in a follow-up patch, otherwise LGTM (informally).
zherczeg
left a comment
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.
LGTM
Magic strings are expected to be sorted by length, then alphabetically after jerryscript-project#1506 landed. This breaks the mbedos5 target against JerryScript master as it emits the pins in the order that it finds the pins. This patch sorts the pin names. JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
Magic strings are expected to be sorted by length, then alphabetically after #1506 landed. This breaks the mbedos5 target against JerryScript master as it emits the pins in the order that it finds the pins. This patch sorts the pin names. JerryScript-DCO-1.0-Signed-off-by: Jan Jongboom janjongboom@gmail.com
After this patch, we have to provide external strings ordered by size and lexicographically.
We can do this with jerry_parse_and_save_literals() (#1500).
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com