Skip to content

Reduce Math object binary size. #1491

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

Merged
merged 1 commit into from
Dec 19, 2016

Conversation

zherczeg
Copy link
Member

Roughly one KByte saving: 141024 -> 140256

Copy link
Contributor

@LaszloLango LaszloLango left a comment

Choose a reason for hiding this comment

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

LGTM

@LaszloLango LaszloLango added binary size Affects binary size enhancement An improvement labels Dec 14, 2016
Copy link

@tilmannOSG tilmannOSG left a comment

Choose a reason for hiding this comment

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

Some minor issues, also please be more verbose in the commit message (e.g. similar to the previous Date built-in code size reduction). Thanks!

{
JERRY_UNUSED (this_arg);
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* both numbers are zeroes */

Choose a reason for hiding this comment

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

Comment should start with uppercase letter and end with full stop. Though honestly I think you can just drop the comment :)

*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_math_object_exp (ecma_value_t this_arg, /**< 'this' argument */
ecma_value_t arg) /**< routine's argument */
ecma_builtin_math_object_random () /**< 'this' argument */

Choose a reason for hiding this comment

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

Should have a void between the parentheses and the comment removed. Or alternatively a this parameter added :)

*
* See also:
* ECMA-262 v5, 15.8.2.9
* Dispatcher of the built-in's routines

Choose a reason for hiding this comment

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

of -> for
Please add a full stop as well.

@zherczeg
Copy link
Member Author

Fixed all requests.

Copy link

@tilmannOSG tilmannOSG left a comment

Choose a reason for hiding this comment

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

Thanks, it seems you only partially incorporated the feedback though. I highlighted the issues again.


/**
* The Math object's 'atan' routine
* The Math object's 'max' 'min' routines

Choose a reason for hiding this comment

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

Full stop at the line end please.


/**
* The Math object's 'exp' routine
* The Math object's 'random' routine

Choose a reason for hiding this comment

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

Full stop at the end of the sentence please.

*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_math_object_exp (ecma_value_t this_arg, /**< 'this' argument */
ecma_value_t arg) /**< routine's argument */
ecma_builtin_math_object_random ()

Choose a reason for hiding this comment

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

Please replace ecma_builtin_math_object_random() with ecma_builtin_math_object_random(void). In C there's quite a difference between the two, right now you can call ecma_builtin_math_object_random() with an arbitrary number of arguments and the compiler won't complain :)

*
* See also:
* ECMA-262 v5, 15.8.2.9
* Dispatcher for the built-in's routines

Choose a reason for hiding this comment

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

Full stop at the end of the sentence please.

@zherczeg
Copy link
Member Author

Thank you for the review. Issues were fixed.

Although many Math built-in functions have a similar structure
these code paths were implemented as separate C functions.
After this patch only one common dispatcher remains which shares
the common code paths of different built-in functions. This
reduces the binary size by 1 Kbyte.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
Copy link

@tilmannOSG tilmannOSG left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM

@tilmannOSG tilmannOSG merged commit 0c7d99e into jerryscript-project:master Dec 19, 2016
@zherczeg zherczeg deleted the math_builtin_opt branch December 21, 2016 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary size Affects binary size enhancement An improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants