@@ -288,13 +288,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
288288 ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
289289 re_opcode_t op;
290290
291- if (re_ctx_p->recursion_depth >= RE_EXECUTE_RECURSION_LIMIT)
292- {
293- ret_value = ecma_raise_range_error (" RegExp executor recursion limit is exceeded." );
294- return ret_value;
295- }
296- re_ctx_p->recursion_depth ++;
297-
298291 while ((op = re_get_opcode (&bc_p)))
299292 {
300293 switch (op)
@@ -303,15 +296,13 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
303296 {
304297 JERRY_DDLOG (" Execute RE_OP_MATCH: match\n " );
305298 *out_iter_p = iter;
306- re_ctx_p->recursion_depth --;
307299 ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
308300 return ret_value; /* match */
309301 }
310302 case RE_OP_CHAR:
311303 {
312304 if (lit_utf8_iterator_is_eos (&iter))
313305 {
314- re_ctx_p->recursion_depth --;
315306 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
316307 }
317308
@@ -323,7 +314,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
323314 if (ch1 != ch2)
324315 {
325316 JERRY_DDLOG (" fail\n " );
326- re_ctx_p->recursion_depth --;
327317 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
328318 }
329319
@@ -335,7 +325,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
335325 {
336326 if (lit_utf8_iterator_is_eos (&iter))
337327 {
338- re_ctx_p->recursion_depth --;
339328 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
340329 }
341330
@@ -345,7 +334,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
345334 if (lit_char_is_line_terminator (ch))
346335 {
347336 JERRY_DDLOG (" fail\n " );
348- re_ctx_p->recursion_depth --;
349337 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
350338 }
351339
@@ -365,7 +353,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
365353 if (!(re_ctx_p->flags & RE_FLAG_MULTILINE))
366354 {
367355 JERRY_DDLOG (" fail\n " );
368- re_ctx_p->recursion_depth --;
369356 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
370357 }
371358
@@ -376,7 +363,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
376363 }
377364
378365 JERRY_DDLOG (" fail\n " );
379- re_ctx_p->recursion_depth --;
380366 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
381367 }
382368 case RE_OP_ASSERT_END:
@@ -392,7 +378,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
392378 if (!(re_ctx_p->flags & RE_FLAG_MULTILINE))
393379 {
394380 JERRY_DDLOG (" fail\n " );
395- re_ctx_p->recursion_depth --;
396381 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
397382 }
398383
@@ -403,7 +388,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
403388 }
404389
405390 JERRY_DDLOG (" fail\n " );
406- re_ctx_p->recursion_depth --;
407391 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
408392 }
409393 case RE_OP_ASSERT_WORD_BOUNDARY:
@@ -435,7 +419,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
435419 if (is_wordchar_left == is_wordchar_right)
436420 {
437421 JERRY_DDLOG (" fail\n " );
438- re_ctx_p->recursion_depth --;
439422 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
440423 }
441424 }
@@ -447,7 +430,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
447430 if (is_wordchar_left != is_wordchar_right)
448431 {
449432 JERRY_DDLOG (" fail\n " );
450- re_ctx_p->recursion_depth --;
451433 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
452434 }
453435 }
@@ -502,8 +484,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
502484
503485 if (!ecma_is_completion_value_throw (match_value))
504486 {
505- re_ctx_p->recursion_depth --;
506-
507487 if (ecma_is_value_true (match_value))
508488 {
509489 *out_iter_p = sub_iter;
@@ -529,7 +509,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
529509 if (lit_utf8_iterator_is_eos (&iter))
530510 {
531511 JERRY_DDLOG (" fail\n " );
532- re_ctx_p->recursion_depth --;
533512 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
534513 }
535514
@@ -559,7 +538,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
559538 if (!is_match)
560539 {
561540 JERRY_DDLOG (" fail\n " );
562- re_ctx_p->recursion_depth --;
563541 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
564542 }
565543 }
@@ -569,7 +547,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
569547 if (is_match)
570548 {
571549 JERRY_DDLOG (" fail\n " );
572- re_ctx_p->recursion_depth --;
573550 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
574551 }
575552 }
@@ -600,7 +577,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
600577 if ((iter.buf_p + iter.buf_pos .offset ) >= re_ctx_p->input_end_p )
601578 {
602579 JERRY_DDLOG (" fail\n " );
603- re_ctx_p->recursion_depth --;
604580 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
605581 }
606582
@@ -610,7 +586,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
610586 if (ch1 != ch2)
611587 {
612588 JERRY_DDLOG (" fail\n " );
613- re_ctx_p->recursion_depth --;
614589 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
615590 }
616591 }
@@ -633,7 +608,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
633608 if (ecma_is_value_true (match_value))
634609 {
635610 *out_iter_p = sub_iter;
636- re_ctx_p->recursion_depth --;
637611 return match_value; /* match */
638612 }
639613 else if (ecma_is_completion_value_throw (match_value))
@@ -647,15 +621,13 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
647621 bc_p = old_bc_p;
648622
649623 re_ctx_p->saved_p [RE_GLOBAL_START_IDX] = old_start_p;
650- re_ctx_p->recursion_depth --;
651624 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
652625 }
653626 case RE_OP_SAVE_AND_MATCH:
654627 {
655628 JERRY_DDLOG (" End of pattern is reached: match\n " );
656629 re_ctx_p->saved_p [RE_GLOBAL_END_IDX] = iter;
657630 *out_iter_p = iter;
658- re_ctx_p->recursion_depth --;
659631 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE); /* match */
660632 }
661633 case RE_OP_ALTERNATIVE:
@@ -720,7 +692,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
720692 if (ecma_is_value_true (match_value))
721693 {
722694 *out_iter_p = sub_iter;
723- re_ctx_p->recursion_depth --;
724695 return match_value; /* match */
725696 }
726697 else if (ecma_is_completion_value_throw (match_value))
@@ -778,7 +749,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
778749 if (ecma_is_value_true (match_value))
779750 {
780751 *out_iter_p = sub_iter;
781- re_ctx_p->recursion_depth --;
782752 return match_value; /* match */
783753 }
784754 else if (ecma_is_completion_value_throw (match_value))
@@ -802,7 +772,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
802772 if (ecma_is_value_true (match_value))
803773 {
804774 *out_iter_p = sub_iter;
805- re_ctx_p->recursion_depth --;
806775 return match_value; /* match */
807776 }
808777 else if (ecma_is_completion_value_throw (match_value))
@@ -812,7 +781,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
812781 }
813782
814783 re_ctx_p->saved_p [start_idx] = old_start;
815- re_ctx_p->recursion_depth --;
816784 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
817785 }
818786 case RE_OP_CAPTURE_NON_GREEDY_GROUP_END:
@@ -857,7 +825,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
857825 if (ecma_is_value_true (match_value))
858826 {
859827 *out_iter_p = sub_iter;
860- re_ctx_p->recursion_depth --;
861828 return match_value; /* match */
862829 }
863830 else if (ecma_is_completion_value_throw (match_value))
@@ -907,7 +874,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
907874 && iter.buf_p == re_ctx_p->saved_p [start_idx].buf_p
908875 && iter.buf_pos .offset == re_ctx_p->saved_p [start_idx].buf_pos .offset )
909876 {
910- re_ctx_p->recursion_depth --;
911877 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
912878 }
913879
@@ -929,7 +895,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
929895 if (ecma_is_value_true (match_value))
930896 {
931897 *out_iter_p = sub_iter;
932- re_ctx_p->recursion_depth --;
933898 return match_value; /* match */
934899 }
935900 else if (ecma_is_completion_value_throw (match_value))
@@ -954,7 +919,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
954919 if (ecma_is_value_true (match_value))
955920 {
956921 *out_iter_p = sub_iter;
957- re_ctx_p->recursion_depth --;
958922 return match_value; /* match */
959923 }
960924 else if (ecma_is_completion_value_throw (match_value))
@@ -976,7 +940,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
976940 if (ecma_is_value_true (match_value))
977941 {
978942 *out_iter_p = sub_iter;
979- re_ctx_p->recursion_depth --;
980943 return match_value; /* match */
981944 }
982945 else if (ecma_is_completion_value_throw (match_value))
@@ -988,7 +951,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
988951 /* restore if fails */
989952 re_ctx_p->saved_p [end_idx] = old_end;
990953 re_ctx_p->num_of_iterations_p [iter_idx]--;
991- re_ctx_p->recursion_depth --;
992954 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
993955 }
994956 case RE_OP_NON_GREEDY_ITERATOR:
@@ -1013,7 +975,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
1013975 if (ecma_is_value_true (match_value))
1014976 {
1015977 *out_iter_p = sub_iter;
1016- re_ctx_p->recursion_depth --;
1017978 return match_value; /* match */
1018979 }
1019980 else if (ecma_is_completion_value_throw (match_value))
@@ -1037,7 +998,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
1037998 iter = sub_iter;
1038999 num_of_iter++;
10391000 }
1040- re_ctx_p->recursion_depth --;
10411001 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
10421002 }
10431003 case RE_OP_GREEDY_ITERATOR:
@@ -1079,7 +1039,6 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
10791039 if (ecma_is_value_true (match_value))
10801040 {
10811041 *out_iter_p = sub_iter;
1082- re_ctx_p->recursion_depth --;
10831042 return match_value; /* match */
10841043 }
10851044 else if (ecma_is_completion_value_throw (match_value))
@@ -1095,13 +1054,11 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
10951054 lit_utf8_iterator_read_prev (&iter);
10961055 num_of_iter--;
10971056 }
1098- re_ctx_p->recursion_depth --;
10991057 return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */
11001058 }
11011059 default :
11021060 {
11031061 JERRY_DDLOG (" UNKNOWN opcode (%d)!\n " , (uint32_t ) op);
1104- re_ctx_p->recursion_depth --;
11051062 return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_COMMON));
11061063 }
11071064 }
@@ -1238,7 +1195,6 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
12381195 re_matcher_ctx_t re_ctx;
12391196 re_ctx.input_start_p = iterator.buf_p ;
12401197 re_ctx.input_end_p = iterator.buf_p + iterator.buf_size ;
1241- re_ctx.recursion_depth = 0 ;
12421198
12431199 /* 1. Read bytecode header and init regexp matcher context. */
12441200 re_ctx.flags = (uint8_t ) re_get_value (&bc_p);
0 commit comments