-
Notifications
You must be signed in to change notification settings - Fork 683
[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
@@ -157,6 +157,22 @@ lit_magic_strings_ex_set (const lit_utf8_byte_t **ex_str_items, /**< character a | |||
lit_utf8_size_t string_size = lit_zt_utf8_string_size (lit_get_magic_string_ex_utf8 (id)); | |||
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
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)
} | ||
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 [email protected]
b4859e1
to
f6c6937
Compare
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
@@ -150,8 +150,8 @@ handler_construct (const jerry_value_t func_obj_val, /**< function object */ | |||
*/ | |||
#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).
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 [email protected]
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 [email protected]
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 [email protected]