Skip to content

Commit 6420631

Browse files
committed
Optimize empty ecma values
Use explicit zero instead of 'ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY)'. JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent a2271fd commit 6420631

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+237
-228
lines changed

jerry-core/ecma/base/ecma-globals.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
*/
5757
typedef enum
5858
{
59-
ECMA_TYPE_SIMPLE, /**< simple value */
59+
ECMA_TYPE_SIMPLE = 0, /**< simple value */
6060
ECMA_TYPE_NUMBER, /**< 64-bit integer */
6161
ECMA_TYPE_STRING, /**< pointer to description of a string */
6262
ECMA_TYPE_OBJECT /**< pointer to description of an object */
@@ -73,7 +73,7 @@ typedef enum
7373
* - values of uninitialized immutable bindings;
7474
* - values of empty register variables.
7575
*/
76-
ECMA_SIMPLE_VALUE_EMPTY,
76+
ECMA_SIMPLE_VALUE_EMPTY = 0, /**< empty value */
7777
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
7878
ECMA_SIMPLE_VALUE_NULL, /**< null value */
7979
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
@@ -83,6 +83,15 @@ typedef enum
8383
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma values */
8484
} ecma_simple_value_t;
8585

86+
87+
/**
88+
* Empty ecma value
89+
*
90+
* Note:
91+
* Speed up for 'ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY)' calls
92+
*/
93+
#define ECMA_VALUE_EMPTY ((ecma_value_t) 0u)
94+
8695
/**
8796
* Type of ecma-property
8897
*/

jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ecma_builtin_array_prototype_helper_set_length (ecma_object_t *object, /**< obje
8787
static ecma_value_t
8888
ecma_builtin_array_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
8989
{
90-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
90+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
9191

9292
/* 1. */
9393
ECMA_TRY_CATCH (obj_this_value,
@@ -137,7 +137,7 @@ ecma_builtin_array_prototype_object_to_string (ecma_value_t this_arg) /**< this
137137
static ecma_value_t
138138
ecma_builtin_array_prototype_object_to_locale_string (const ecma_value_t this_arg) /**< this argument */
139139
{
140-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
140+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
141141

142142
/* 1. */
143143
ECMA_TRY_CATCH (obj_value,
@@ -237,7 +237,7 @@ ecma_builtin_array_prototype_object_concat (ecma_value_t this_arg, /**< this arg
237237
const ecma_value_t args[], /**< arguments list */
238238
ecma_length_t args_number) /**< number of arguments */
239239
{
240-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
240+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
241241

242242
/* 1. */
243243
ECMA_TRY_CATCH (obj_this,
@@ -321,7 +321,7 @@ static ecma_value_t
321321
ecma_op_array_get_to_string_at_index (ecma_object_t *obj_p, /** < this object */
322322
uint32_t index) /** < array index */
323323
{
324-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
324+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
325325
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
326326

327327
ECMA_TRY_CATCH (index_value,
@@ -359,7 +359,7 @@ static ecma_value_t
359359
ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argument */
360360
const ecma_value_t separator_arg) /** < separator argument */
361361
{
362-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
362+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
363363

364364
/* 1. */
365365
ECMA_TRY_CATCH (obj_value,
@@ -464,7 +464,7 @@ ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argume
464464
static ecma_value_t
465465
ecma_builtin_array_prototype_object_pop (ecma_value_t this_arg) /**< this argument */
466466
{
467-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
467+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
468468

469469
/* 1. */
470470
ECMA_TRY_CATCH (obj_this,
@@ -545,7 +545,7 @@ ecma_builtin_array_prototype_object_push (ecma_value_t this_arg, /**< this argum
545545
const ecma_value_t *argument_list_p, /**< arguments list */
546546
ecma_length_t arguments_number) /**< number of arguments */
547547
{
548-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
548+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
549549

550550
/* 1. */
551551
ECMA_TRY_CATCH (obj_this_value, ecma_op_to_object (this_arg), ret_value);
@@ -617,7 +617,7 @@ ecma_builtin_array_prototype_object_push (ecma_value_t this_arg, /**< this argum
617617
static ecma_value_t
618618
ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg) /**< this argument */
619619
{
620-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
620+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
621621

622622
/* 1. */
623623
ECMA_TRY_CATCH (obj_this,
@@ -713,7 +713,7 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg) /**< this ar
713713
static ecma_value_t
714714
ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argument */
715715
{
716-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
716+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
717717

718718
/* 1. */
719719
ECMA_TRY_CATCH (obj_this,
@@ -828,7 +828,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t this_arg, /**< 'this' ar
828828
ecma_value_t arg1, /**< start */
829829
ecma_value_t arg2) /**< end */
830830
{
831-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
831+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
832832

833833
/* 1. */
834834
ECMA_TRY_CATCH (obj_this,
@@ -950,7 +950,7 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t j, /**< le
950950
* compares greater than any other value, undefined property values always
951951
* sort to the end of the result, followed by non-existent property values.
952952
*/
953-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
953+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
954954
ecma_number_t *result_p = ecma_alloc_number ();
955955

956956
bool j_is_undef = ecma_is_value_undefined (j);
@@ -1058,7 +1058,7 @@ ecma_builtin_array_prototype_object_array_to_heap_helper (ecma_value_t array[],
10581058
int right, /**< right index is a maximum index */
10591059
ecma_value_t comparefn) /**< compare function */
10601060
{
1061-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1061+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
10621062

10631063
/* Left child of the current index. */
10641064
int child = index * 2 + 1;
@@ -1146,7 +1146,7 @@ ecma_builtin_array_prototype_object_array_heap_sort_helper (ecma_value_t array[]
11461146
int right, /**< right index */
11471147
ecma_value_t comparefn) /**< compare function */
11481148
{
1149-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1149+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
11501150

11511151
/* First, construct the ordered binary tree from the array. */
11521152
for (int i = right / 2; i >= 0 && ecma_is_value_empty (ret_value); i--)
@@ -1203,7 +1203,7 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
12031203
return ecma_raise_type_error ("");
12041204
}
12051205

1206-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1206+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
12071207

12081208
ECMA_TRY_CATCH (obj_this,
12091209
ecma_op_to_object (this_arg),
@@ -1354,7 +1354,7 @@ ecma_builtin_array_prototype_object_splice (ecma_value_t this_arg, /**< this arg
13541354
const ecma_value_t args[], /**< arguments list */
13551355
ecma_length_t args_number) /**< number of arguments */
13561356
{
1357-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1357+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
13581358

13591359
/* 1. */
13601360
ECMA_TRY_CATCH (obj_this,
@@ -1643,7 +1643,7 @@ ecma_builtin_array_prototype_object_unshift (ecma_value_t this_arg, /**< this ar
16431643
const ecma_value_t args[], /**< arguments list */
16441644
ecma_length_t args_number) /**< number of arguments */
16451645
{
1646-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1646+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
16471647

16481648
/* 1. */
16491649
ECMA_TRY_CATCH (obj_this,
@@ -1741,7 +1741,7 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
17411741
ecma_value_t arg1, /**< searchElement */
17421742
ecma_value_t arg2) /**< fromIndex */
17431743
{
1744-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1744+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
17451745

17461746
/* 1. */
17471747
ECMA_TRY_CATCH (obj_this,
@@ -1840,7 +1840,7 @@ ecma_builtin_array_prototype_object_last_index_of (ecma_value_t this_arg, /**< t
18401840
const ecma_value_t args[], /**< arguments list */
18411841
ecma_length_t args_number) /**< number of arguments */
18421842
{
1843-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1843+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
18441844
ecma_value_t search_element = (args_number > 0) ? args[0] : ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
18451845

18461846
/* 1. */
@@ -1991,7 +1991,7 @@ ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argu
19911991
ecma_value_t arg1, /**< callbackfn */
19921992
ecma_value_t arg2) /**< thisArg */
19931993
{
1994-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
1994+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
19951995

19961996
/* 1. */
19971997
ECMA_TRY_CATCH (obj_this,
@@ -2092,7 +2092,7 @@ ecma_builtin_array_prototype_object_some (ecma_value_t this_arg, /**< this argum
20922092
ecma_value_t arg1, /**< callbackfn */
20932093
ecma_value_t arg2) /**< thisArg */
20942094
{
2095-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
2095+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
20962096

20972097
/* 1. */
20982098
ECMA_TRY_CATCH (obj_this,
@@ -2193,7 +2193,7 @@ ecma_builtin_array_prototype_object_for_each (ecma_value_t this_arg, /**< this a
21932193
ecma_value_t arg1, /**< callbackfn */
21942194
ecma_value_t arg2) /**< thisArg */
21952195
{
2196-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
2196+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
21972197
/* 1. */
21982198
ECMA_TRY_CATCH (obj_this,
21992199
ecma_op_to_object (this_arg),
@@ -2287,7 +2287,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t this_arg, /**< this argume
22872287
ecma_value_t arg1, /**< callbackfn */
22882288
ecma_value_t arg2) /**< thisArg */
22892289
{
2290-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
2290+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
22912291

22922292
/* 1. */
22932293
ECMA_TRY_CATCH (obj_this,
@@ -2401,7 +2401,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t this_arg, /**< this arg
24012401
ecma_value_t arg1, /**< callbackfn */
24022402
ecma_value_t arg2) /**< thisArg */
24032403
{
2404-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
2404+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
24052405

24062406
/* 1. */
24072407
ECMA_TRY_CATCH (obj_this,
@@ -2524,7 +2524,7 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
25242524
const ecma_value_t args[], /**< arguments list */
25252525
ecma_length_t args_number) /**< number of arguments */
25262526
{
2527-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
2527+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
25282528
ecma_value_t callbackfn = (args_number > 0) ? args[0] : ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
25292529
ecma_value_t initial_value = (args_number > 1) ? args[1] : ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
25302530

@@ -2669,7 +2669,7 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
26692669
const ecma_value_t args[], /**< arguments list */
26702670
ecma_length_t args_number) /**< number of arguments */
26712671
{
2672-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
2672+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
26732673
ecma_value_t callbackfn = (args_number > 0) ? args[0] : ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
26742674
ecma_value_t initial_value = (args_number > 1) ? args[1] : ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
26752675

jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
static ecma_value_t
5757
ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
5858
{
59-
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
59+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
6060

6161
ECMA_TRY_CATCH (value_of_ret,
6262
ecma_builtin_boolean_prototype_object_value_of (this_arg),

0 commit comments

Comments
 (0)