@@ -814,13 +814,12 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
814
814
function_var_idx,
815
815
&call_flags);
816
816
817
- MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number_idx, ecma_value_t );
817
+ ecma_collection_header_t *arg_collection_p = ecma_new_values_collection ( NULL , 0 , true );
818
818
819
- ecma_length_t args_read;
820
- ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
821
- args_number_idx,
822
- arg_values,
823
- &args_read);
819
+ ecma_completion_value_t get_arg_completion = vm_fill_varg_list (frame_ctx_p,
820
+ args_number_idx,
821
+ arg_collection_p);
822
+ ecma_length_t args_read = arg_collection_p->unit_number ;
824
823
825
824
if (ecma_is_completion_value_empty (get_arg_completion))
826
825
{
@@ -839,11 +838,24 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
839
838
840
839
ecma_object_t *func_obj_p = ecma_get_object_from_value (func_value);
841
840
841
+ MEM_DEFINE_LOCAL_ARRAY (arg_values, args_read, ecma_value_t );
842
+
843
+ ecma_collection_iterator_t arg_collection_iter;
844
+ ecma_collection_iterator_init (&arg_collection_iter,
845
+ arg_collection_p);
846
+
847
+ for (ecma_length_t arg_index = 0 ;
848
+ ecma_collection_iterator_next (&arg_collection_iter);
849
+ arg_index++)
850
+ {
851
+ arg_values[arg_index] = *arg_collection_iter.current_value_p ;
852
+ }
853
+
842
854
ECMA_TRY_CATCH (call_ret_value,
843
855
ecma_op_function_call (func_obj_p,
844
856
this_value,
845
857
arg_values,
846
- args_number_idx ),
858
+ args_read ),
847
859
ret_value);
848
860
849
861
ret_value = set_variable_value (frame_ctx_p, lit_oc,
@@ -852,6 +864,8 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
852
864
853
865
ECMA_FINALIZE (call_ret_value);
854
866
867
+ MEM_FINALIZE_LOCAL_ARRAY (arg_values);
868
+
855
869
if (call_flags & OPCODE_CALL_FLAGS_DIRECT_CALL_TO_EVAL_FORM)
856
870
{
857
871
JERRY_ASSERT (frame_ctx_p->is_call_in_direct_eval_form );
@@ -870,15 +884,7 @@ opfunc_call_n (vm_instr_t instr, /**< instruction */
870
884
ret_value = get_arg_completion;
871
885
}
872
886
873
- for (ecma_length_t arg_index = 0 ;
874
- arg_index < args_read;
875
- arg_index++)
876
- {
877
- ecma_free_value (arg_values[arg_index], true );
878
- }
879
-
880
- MEM_FINALIZE_LOCAL_ARRAY (arg_values);
881
-
887
+ ecma_free_values_collection (arg_collection_p, true );
882
888
ecma_free_value (this_value, true );
883
889
884
890
ECMA_FINALIZE (func_value);
@@ -908,15 +914,14 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
908
914
get_variable_value (frame_ctx_p, constructor_name_lit_idx, false ),
909
915
ret_value);
910
916
911
- MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number, ecma_value_t );
912
-
913
917
frame_ctx_p->pos ++;
914
918
915
- ecma_length_t args_read;
916
- ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
917
- args_number,
918
- arg_values,
919
- &args_read);
919
+ ecma_collection_header_t *arg_collection_p = ecma_new_values_collection (NULL , 0 , true );
920
+
921
+ ecma_completion_value_t get_arg_completion = vm_fill_varg_list (frame_ctx_p,
922
+ args_number,
923
+ arg_collection_p);
924
+ ecma_length_t args_read = arg_collection_p->unit_number ;
920
925
921
926
if (ecma_is_completion_value_empty (get_arg_completion))
922
927
{
@@ -930,6 +935,19 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
930
935
{
931
936
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor_value);
932
937
938
+ MEM_DEFINE_LOCAL_ARRAY (arg_values, args_read, ecma_value_t );
939
+
940
+ ecma_collection_iterator_t arg_collection_iter;
941
+ ecma_collection_iterator_init (&arg_collection_iter,
942
+ arg_collection_p);
943
+
944
+ for (ecma_length_t arg_index = 0 ;
945
+ ecma_collection_iterator_next (&arg_collection_iter);
946
+ arg_index++)
947
+ {
948
+ arg_values[arg_index] = *arg_collection_iter.current_value_p ;
949
+ }
950
+
933
951
ECMA_TRY_CATCH (construction_ret_value,
934
952
ecma_op_function_construct (constructor_obj_p,
935
953
arg_values,
@@ -940,6 +958,8 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
940
958
construction_ret_value);
941
959
942
960
ECMA_FINALIZE (construction_ret_value);
961
+
962
+ MEM_FINALIZE_LOCAL_ARRAY (arg_values);
943
963
}
944
964
}
945
965
else
@@ -949,14 +969,7 @@ opfunc_construct_n (vm_instr_t instr, /**< instruction */
949
969
ret_value = get_arg_completion;
950
970
}
951
971
952
- for (ecma_length_t arg_index = 0 ;
953
- arg_index < args_read;
954
- arg_index++)
955
- {
956
- ecma_free_value (arg_values[arg_index], true );
957
- }
958
-
959
- MEM_FINALIZE_LOCAL_ARRAY (arg_values);
972
+ ecma_free_values_collection (arg_collection_p, true );
960
973
961
974
ECMA_FINALIZE (constructor_value);
962
975
@@ -987,18 +1000,30 @@ opfunc_array_decl (vm_instr_t instr, /**< instruction */
987
1000
988
1001
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
989
1002
990
- MEM_DEFINE_LOCAL_ARRAY (arg_values, args_number, ecma_value_t );
1003
+ ecma_collection_header_t *arg_collection_p = ecma_new_values_collection ( NULL , 0 , true );
991
1004
992
- ecma_length_t args_read;
993
- ecma_completion_value_t get_arg_completion = fill_varg_list (frame_ctx_p,
994
- args_number,
995
- arg_values,
996
- &args_read);
1005
+ ecma_completion_value_t get_arg_completion = vm_fill_varg_list (frame_ctx_p,
1006
+ args_number,
1007
+ arg_collection_p);
1008
+ ecma_length_t args_read = arg_collection_p->unit_number ;
997
1009
998
1010
if (ecma_is_completion_value_empty (get_arg_completion))
999
1011
{
1000
1012
JERRY_ASSERT (args_read == args_number);
1001
1013
1014
+ MEM_DEFINE_LOCAL_ARRAY (arg_values, args_read, ecma_value_t );
1015
+
1016
+ ecma_collection_iterator_t arg_collection_iter;
1017
+ ecma_collection_iterator_init (&arg_collection_iter,
1018
+ arg_collection_p);
1019
+
1020
+ for (ecma_length_t arg_index = 0 ;
1021
+ ecma_collection_iterator_next (&arg_collection_iter);
1022
+ arg_index++)
1023
+ {
1024
+ arg_values[arg_index] = *arg_collection_iter.current_value_p ;
1025
+ }
1026
+
1002
1027
ECMA_TRY_CATCH (array_obj_value,
1003
1028
ecma_op_create_array_object (arg_values,
1004
1029
args_number,
@@ -1010,6 +1035,8 @@ opfunc_array_decl (vm_instr_t instr, /**< instruction */
1010
1035
array_obj_value);
1011
1036
1012
1037
ECMA_FINALIZE (array_obj_value);
1038
+
1039
+ MEM_FINALIZE_LOCAL_ARRAY (arg_values);
1013
1040
}
1014
1041
else
1015
1042
{
@@ -1018,14 +1045,7 @@ opfunc_array_decl (vm_instr_t instr, /**< instruction */
1018
1045
ret_value = get_arg_completion;
1019
1046
}
1020
1047
1021
- for (ecma_length_t arg_index = 0 ;
1022
- arg_index < args_read;
1023
- arg_index++)
1024
- {
1025
- ecma_free_value (arg_values[arg_index], true );
1026
- }
1027
-
1028
- MEM_FINALIZE_LOCAL_ARRAY (arg_values);
1048
+ ecma_free_values_collection (arg_collection_p, true );
1029
1049
1030
1050
return ret_value;
1031
1051
} /* opfunc_array_decl */
0 commit comments