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

Use code unit instead of code point #961

Merged
merged 1 commit into from
Mar 18, 2016

Conversation

LaszloLango
Copy link
Contributor

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]

@LaszloLango LaszloLango added the enhancement An improvement label Mar 11, 2016
lit_read_code_point_from_hex (lit_utf8_byte_t *buf_p, /**< buffer with characters */
lit_utf8_size_t number_of_characters, /**< number of characters to be read */
lit_code_point_t *out_code_point_p) /**< [out] decoded result */
lit_read_code_unit_from_hex (lit_utf8_byte_t *buf_p, /**< buffer with characters */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc still refers to code points.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the help of the non-character markers (as in my previous comment), couldn't we just return a code unit from this function and compare it to U+FFFF to see whether we succeeded or not? (I'm really against out parameters given with pointers, so prefer to replace them wherever possible.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The helper must be able to read "FFFF" and does not have to deal with it a valid code unit or not. Currently it might work on the test suite but this change would be dangerous.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just sweeped through the call sites of this function, and it seems that only three functions call it with number_of_characters being 4: ecma_builtin_json_parse_string, re_parse_char_class, and re_parse_next_token. (Where the param is 2, there can be no possible way of getting a valid value of 0xFFFF.) Also, in a valid json, there must not be a U+FFFF according to the unicode specs. Where I'm not completely sure is the regexes. :/ While googling around I've seen some artificial examples with regex character classes where the upper limit was \uFFFF. What I couldn't find out with certainty is whether they are valid examples.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS supports all characters between 0-0xffff. JS was not designed to be UTF compatible, every character is a two byte number.

@LaszloLango
Copy link
Contributor Author

@akiss77, @zherczeg, updated. Please check.

@LaszloLango
Copy link
Contributor Author

@zherczeg, related discussion: #938 (diff)
This is a follow up work after #938 and #910. The function pointer is wrong and we have to change it's parameters to ecma_char_t so we can avoid unnecessary type casts. It has no measurable benefit on sunspider.

@zherczeg
Copy link
Member

Ok. LGTM

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
@LaszloLango LaszloLango merged commit e1f20ad into jerryscript-project:master Mar 18, 2016
@LaszloLango LaszloLango deleted the code-unit-opt branch April 1, 2016 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants