Skip to content

Commit cadc81d

Browse files
zherczegLaszloLango
authored andcommitted
ECMAScript Parameters cannot be passed in collections anymore, only as arrays.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent cc6fced commit cadc81d

20 files changed

+269
-521
lines changed

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ ecma_builtin_array_prototype_object_to_string (ecma_value_t this_arg) /**< this
113113
/* 4. */
114114
ecma_object_t *join_func_obj_p = ecma_get_object_from_value (join_value);
115115

116-
return_value = ecma_op_function_call (join_func_obj_p, this_arg, NULL);
116+
return_value = ecma_op_function_call (join_func_obj_p, this_arg, NULL, 0);
117117
}
118118

119119
ECMA_FINALIZE (join_value);
@@ -545,8 +545,6 @@ 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-
JERRY_ASSERT (argument_list_p == NULL || arguments_number > 0);
549-
550548
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
551549

552550
/* 1. */
@@ -1013,10 +1011,10 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t j, /**< le
10131011
ecma_value_t compare_args[] = {j, k};
10141012

10151013
ECMA_TRY_CATCH (call_value,
1016-
ecma_op_function_call_array_args (comparefn_obj_p,
1017-
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
1018-
compare_args,
1019-
2),
1014+
ecma_op_function_call (comparefn_obj_p,
1015+
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
1016+
compare_args,
1017+
2),
10201018
ret_value);
10211019

10221020
if (!ecma_is_value_number (call_value))
@@ -2047,7 +2045,7 @@ ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argu
20472045

20482046
ecma_value_t call_args[] = { get_value, current_index, obj_this };
20492047
/* 7.c.ii */
2050-
ECMA_TRY_CATCH (call_value, ecma_op_function_call_array_args (func_object_p, arg2, call_args, 3), ret_value);
2048+
ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
20512049

20522050
/* 7.c.iii, ecma_op_to_boolean always returns a simple value, so no need to free. */
20532051
if (ecma_is_completion_value_normal_false (ecma_op_to_boolean (call_value)))
@@ -2148,7 +2146,7 @@ ecma_builtin_array_prototype_object_some (ecma_value_t this_arg, /**< this argum
21482146

21492147
ecma_value_t call_args[] = { get_value, current_index, obj_this };
21502148
/* 7.c.ii */
2151-
ECMA_TRY_CATCH (call_value, ecma_op_function_call_array_args (func_object_p, arg2, call_args, 3), ret_value);
2149+
ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
21522150

21532151
/* 7.c.iii, ecma_op_to_boolean always returns a simple value, so no need to free. */
21542152
if (ecma_is_completion_value_normal_true (ecma_op_to_boolean (call_value)))
@@ -2248,7 +2246,7 @@ ecma_builtin_array_prototype_object_for_each (ecma_value_t this_arg, /**< this a
22482246

22492247
/* 7.c.ii */
22502248
ecma_value_t call_args[] = {current_value, current_index, obj_this};
2251-
ECMA_TRY_CATCH (call_value, ecma_op_function_call_array_args (func_object_p, arg2, call_args, 3), ret_value);
2249+
ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
22522250

22532251
ECMA_FINALIZE (call_value);
22542252
ECMA_FINALIZE (current_value);
@@ -2345,7 +2343,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t this_arg, /**< this argume
23452343
current_index = ecma_make_number_value (num_p);
23462344
ecma_value_t call_args[] = {current_value, current_index, obj_this};
23472345

2348-
ECMA_TRY_CATCH (mapped_value, ecma_op_function_call_array_args (func_object_p, arg2, call_args, 3), ret_value);
2346+
ECMA_TRY_CATCH (mapped_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
23492347

23502348
/* 8.c.iii */
23512349
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
@@ -2463,7 +2461,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t this_arg, /**< this arg
24632461

24642462
ecma_value_t call_args[] = { get_value, current_index, obj_this };
24652463
/* 9.c.ii */
2466-
ECMA_TRY_CATCH (call_value, ecma_op_function_call_array_args (func_object_p, arg2, call_args, 3), ret_value);
2464+
ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
24672465

24682466
/* 9.c.iii, ecma_op_to_boolean always returns a simple value, so no need to free. */
24692467
if (ecma_is_completion_value_normal_true (ecma_op_to_boolean (call_value)))
@@ -2623,10 +2621,10 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
26232621
ecma_value_t call_args[] = {accumulator, current_value, current_index, obj_this};
26242622

26252623
ECMA_TRY_CATCH (call_value,
2626-
ecma_op_function_call_array_args (func_object_p,
2627-
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
2628-
call_args,
2629-
4),
2624+
ecma_op_function_call (func_object_p,
2625+
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
2626+
call_args,
2627+
4),
26302628
ret_value);
26312629

26322630
ecma_free_value (accumulator, true);
@@ -2769,10 +2767,10 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
27692767
ecma_value_t call_args[] = {accumulator, current_value, current_index, obj_this};
27702768

27712769
ECMA_TRY_CATCH (call_value,
2772-
ecma_op_function_call_array_args (func_object_p,
2773-
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
2774-
call_args,
2775-
4),
2770+
ecma_op_function_call (func_object_p,
2771+
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
2772+
call_args,
2773+
4),
27762774
ret_value);
27772775

27782776
ecma_free_value (accumulator, true);

jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ ecma_builtin_date_prototype_to_json (ecma_value_t this_arg, /**< this argument *
12131213
else
12141214
{
12151215
ecma_object_t *to_iso_obj_p = ecma_get_object_from_value (to_iso);
1216-
ret_value = ecma_op_function_call (to_iso_obj_p, this_arg, NULL);
1216+
ret_value = ecma_op_function_call (to_iso_obj_p, this_arg, NULL, 0);
12171217
}
12181218

12191219
ECMA_FINALIZE (to_iso);

jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this a
9898
/* 2. */
9999
if (ecma_is_value_null (arg2) || ecma_is_value_undefined (arg2))
100100
{
101-
ret_value = ecma_op_function_call (func_obj_p, arg1, NULL);
101+
ret_value = ecma_op_function_call (func_obj_p, arg1, NULL, 0);
102102
}
103103
else
104104
{
@@ -125,33 +125,42 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this a
125125
const uint32_t length = ecma_number_to_uint32 (length_number);
126126

127127
/* 6. */
128-
ecma_collection_header_t *arg_collection_p = ecma_new_values_collection (NULL, 0, true);
128+
MEM_DEFINE_LOCAL_ARRAY (arguments_list_p, length, ecma_value_t);
129+
uint32_t last_index = 0;
129130

130131
/* 7. */
131-
for (uint32_t index = 0; index < length && ecma_is_completion_value_empty (ret_value); index++)
132+
for (uint32_t index = 0;
133+
index < length && ecma_is_completion_value_empty (ret_value);
134+
index++)
132135
{
133136
ecma_string_t *curr_idx_str_p = ecma_new_ecma_string_from_uint32 (index);
134137

135138
ECMA_TRY_CATCH (get_value,
136139
ecma_op_object_get (obj_p, curr_idx_str_p),
137140
ret_value);
138141

139-
ecma_append_to_values_collection (arg_collection_p, get_value, true);
142+
arguments_list_p[index] = ecma_copy_value (get_value, true);
143+
last_index = index + 1;
140144

141145
ECMA_FINALIZE (get_value);
142146
ecma_deref_ecma_string (curr_idx_str_p);
143147
}
144148

145-
JERRY_ASSERT (arg_collection_p->unit_number == length || !ecma_is_completion_value_empty (ret_value));
146-
147149
if (ecma_is_completion_value_empty (ret_value))
148150
{
151+
JERRY_ASSERT (last_index == length);
149152
ret_value = ecma_op_function_call (func_obj_p,
150153
arg1,
151-
arg_collection_p);
154+
arguments_list_p,
155+
length);
152156
}
153157

154-
ecma_free_values_collection (arg_collection_p, true);
158+
for (uint32_t index = 0; index < last_index; index++)
159+
{
160+
ecma_free_value (arguments_list_p[index], true);
161+
}
162+
163+
MEM_FINALIZE_LOCAL_ARRAY (arguments_list_p);
155164

156165
ECMA_OP_TO_NUMBER_FINALIZE (length_number);
157166
ECMA_FINALIZE (length_value);
@@ -187,16 +196,18 @@ ecma_builtin_function_prototype_object_call (ecma_value_t this_arg, /**< this ar
187196

188197
if (arguments_number == 0)
189198
{
199+
/* Even a 'this' argument is missing. */
190200
return ecma_op_function_call (func_obj_p,
191201
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
192-
NULL);
202+
NULL,
203+
0);
193204
}
194205
else
195206
{
196-
return ecma_op_function_call_array_args (func_obj_p,
197-
arguments_list_p[0],
198-
(arguments_number == 1u) ? NULL : (arguments_list_p + 1),
199-
(ecma_length_t) (arguments_number - 1u));
207+
return ecma_op_function_call (func_obj_p,
208+
arguments_list_p[0],
209+
arguments_list_p + 1,
210+
(ecma_length_t) (arguments_number - 1u));
200211
}
201212
}
202213
} /* ecma_builtin_function_prototype_object_call */

jerry-core/ecma/builtin-objects/ecma-builtin-helpers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ ecma_builtin_helper_get_to_locale_string_at_index (ecma_object_t *obj_p, /** < t
158158
ECMA_TRY_CATCH (call_value,
159159
ecma_op_function_call (locale_func_obj_p,
160160
ecma_make_object_value (index_obj_p),
161-
NULL),
161+
NULL,
162+
0),
162163
ret_value);
163164
ret_value = ecma_op_to_string (call_value);
164165
ECMA_FINALIZE (call_value);

jerry-core/ecma/builtin-objects/ecma-builtin-json.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,10 @@ ecma_builtin_json_walk (ecma_object_t *reviver_p, /**< reviver function */
675675
/*
676676
* The completion value can be anything including exceptions.
677677
*/
678-
ret_value = ecma_op_function_call_array_args (reviver_p,
679-
ecma_make_object_value (holder_p),
680-
arguments_list,
681-
2);
678+
ret_value = ecma_op_function_call (reviver_p,
679+
ecma_make_object_value (holder_p),
680+
arguments_list,
681+
2);
682682
}
683683
else
684684
{
@@ -1252,7 +1252,7 @@ ecma_builtin_json_str (ecma_string_t *key_p, /**< property key*/
12521252
ecma_object_t *toJSON_obj_p = ecma_get_object_from_value (toJSON);
12531253

12541254
ECMA_TRY_CATCH (func_ret_val,
1255-
ecma_op_function_call_array_args (toJSON_obj_p, my_val, call_args, 1),
1255+
ecma_op_function_call (toJSON_obj_p, my_val, call_args, 1),
12561256
ret_value);
12571257

12581258
ecma_free_value (my_val, true);
@@ -1274,7 +1274,7 @@ ecma_builtin_json_str (ecma_string_t *key_p, /**< property key*/
12741274
ecma_value_t call_args[] = { key_value, my_val };
12751275

12761276
ECMA_TRY_CATCH (func_ret_val,
1277-
ecma_op_function_call_array_args (context_p->replacer_function_p, holder_value, call_args, 2),
1277+
ecma_op_function_call (context_p->replacer_function_p, holder_value, call_args, 2),
12781278
ret_value);
12791279

12801280
ecma_free_value (my_val, true);

jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /*
110110
{
111111
/* 4. */
112112
ecma_object_t *to_string_func_obj_p = ecma_get_object_from_value (to_string_val);
113-
return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL);
113+
return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL, 0);
114114
}
115115
ECMA_FINALIZE (to_string_val);
116116

jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,10 +844,10 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
844844
arguments_list[match_length + 1] = ecma_copy_value (context_p->input_string, true);
845845

846846
ECMA_TRY_CATCH (result_value,
847-
ecma_op_function_call_array_args (context_p->replace_function_p,
848-
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
849-
arguments_list,
850-
match_length + 2),
847+
ecma_op_function_call (context_p->replace_function_p,
848+
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
849+
arguments_list,
850+
match_length + 2),
851851
ret_value);
852852

853853
ECMA_TRY_CATCH (to_string_value,

jerry-core/ecma/builtin-objects/ecma-builtins.cpp

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -508,26 +508,13 @@ ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**
508508
ecma_completion_value_t
509509
ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
510510
ecma_value_t this_arg_value, /**< 'this' argument value */
511-
ecma_collection_header_t *arg_collection_p) /**< arguments collection */
511+
const ecma_value_t *arguments_list_p, /**< arguments list */
512+
ecma_length_t arguments_list_len) /**< arguments list length */
512513
{
513514
JERRY_ASSERT (ecma_get_object_is_builtin (obj_p));
514515

515516
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
516517

517-
const ecma_length_t arguments_list_len = arg_collection_p != NULL ? arg_collection_p->unit_number : 0;
518-
MEM_DEFINE_LOCAL_ARRAY (arguments_list_p, arguments_list_len, ecma_value_t);
519-
520-
ecma_collection_iterator_t arg_collection_iter;
521-
ecma_collection_iterator_init (&arg_collection_iter,
522-
arg_collection_p);
523-
524-
for (ecma_length_t arg_index = 0;
525-
ecma_collection_iterator_next (&arg_collection_iter);
526-
arg_index++)
527-
{
528-
arguments_list_p[arg_index] = *arg_collection_iter.current_value_p;
529-
}
530-
531518
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION)
532519
{
533520
ecma_property_t *desc_prop_p = ecma_get_internal_property (obj_p,
@@ -598,8 +585,6 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
598585
}
599586
}
600587

601-
MEM_FINALIZE_LOCAL_ARRAY (arguments_list_p);
602-
603588
JERRY_ASSERT (!ecma_is_completion_value_empty (ret_value));
604589

605590
return ret_value;
@@ -612,27 +597,14 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
612597
*/
613598
ecma_completion_value_t
614599
ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
615-
ecma_collection_header_t *arg_collection_p) /**< arguments collection */
600+
const ecma_value_t *arguments_list_p, /**< arguments list */
601+
ecma_length_t arguments_list_len) /**< arguments list length */
616602
{
617603
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION);
618604
JERRY_ASSERT (ecma_get_object_is_builtin (obj_p));
619605

620606
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
621607

622-
const ecma_length_t arguments_list_len = arg_collection_p != NULL ? arg_collection_p->unit_number : 0;
623-
MEM_DEFINE_LOCAL_ARRAY (arguments_list_p, arguments_list_len, ecma_value_t);
624-
625-
ecma_collection_iterator_t arg_collection_iter;
626-
ecma_collection_iterator_init (&arg_collection_iter,
627-
arg_collection_p);
628-
629-
for (ecma_length_t arg_index = 0;
630-
ecma_collection_iterator_next (&arg_collection_iter);
631-
arg_index++)
632-
{
633-
arguments_list_p[arg_index] = *arg_collection_iter.current_value_p;
634-
}
635-
636608
ecma_property_t *built_in_id_prop_p = ecma_get_internal_property (obj_p,
637609
ECMA_INTERNAL_PROPERTY_BUILT_IN_ID);
638610
ecma_builtin_id_t builtin_id = (ecma_builtin_id_t) built_in_id_prop_p->u.internal_property.value;
@@ -674,8 +646,6 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
674646
}
675647
}
676648

677-
MEM_FINALIZE_LOCAL_ARRAY (arguments_list_p);
678-
679649
JERRY_ASSERT (!ecma_is_completion_value_empty (ret_value));
680650

681651
return ret_value;

jerry-core/ecma/builtin-objects/ecma-builtins.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ extern void ecma_init_builtins (void);
3939
extern void ecma_finalize_builtins (void);
4040

4141
extern ecma_completion_value_t
42-
ecma_builtin_dispatch_call (ecma_object_t *, ecma_value_t, ecma_collection_header_t *);
42+
ecma_builtin_dispatch_call (ecma_object_t *, ecma_value_t,
43+
const ecma_value_t *, ecma_length_t);
4344
extern ecma_completion_value_t
44-
ecma_builtin_dispatch_construct (ecma_object_t *, ecma_collection_header_t *);
45+
ecma_builtin_dispatch_construct (ecma_object_t *,
46+
const ecma_value_t *, ecma_length_t);
4547
extern ecma_property_t *
4648
ecma_builtin_try_to_instantiate_property (ecma_object_t *, ecma_string_t *);
4749
extern void

0 commit comments

Comments
 (0)