Skip to content

Commit d9eb662

Browse files
committed
Minor fixes
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent e88d191 commit d9eb662

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

jerry-core/ecma/operations/ecma-regexp-object.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
* @{
3030
*/
3131

32+
/**
33+
* RegExp flags mask (first 10 bits are for reference count and the rest for the actual RegExp flags)
34+
*/
35+
#define RE_FLAGS_MASK 0xFF
36+
3237
/**
3338
* RegExp flags
3439
*/

jerry-core/parser/js/js-lexer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,6 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
18121812
ecma_value_t completion_value;
18131813

18141814
ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p, length);
1815-
// FIXME: check return value of 're_compile_bytecode' and throw an error
18161815
completion_value = re_compile_bytecode (&re_bytecode_p,
18171816
pattern_str_p,
18181817
current_flags);

jerry-core/parser/regexp/re-compiler.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,16 +444,20 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context
444444
return ret_value;
445445
} /* re_parse_alternative */
446446

447+
/**
448+
* RegExp cache
449+
*/
447450
static const re_compiled_code_t *re_cache[RE_CHACHE_SIZE];
448451

449452
/**
450453
* Search for the given pattern in the RegExp cache
451454
*
452455
* @return compiled bytecode - if found
453-
* NULL - otherwise
456+
* NULL - otherwise
454457
*/
455458
static re_compiled_code_t *
456459
re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
460+
uint16_t flags, /**< flags */
457461
uint32_t *idx) /**< [out] index */
458462
{
459463
uint32_t free_idx = RE_CHACHE_SIZE;
@@ -467,7 +471,8 @@ re_find_bytecode_in_cache (ecma_string_t *pattern_str_p, /**< pattern string */
467471
ecma_string_t *cached_pattern_str_p;
468472
cached_pattern_str_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, cached_bytecode_p->pattern_cp);
469473

470-
if (ecma_compare_ecma_strings (cached_pattern_str_p, pattern_str_p))
474+
if ((cached_bytecode_p->flags & RE_FLAGS_MASK) == flags
475+
&& ecma_compare_ecma_strings (cached_pattern_str_p, pattern_str_p))
471476
{
472477
return re_cache[*idx];
473478
}
@@ -511,7 +516,7 @@ re_compile_bytecode (re_compiled_code_t **out_bytecode_p, /**< [out] pointer to
511516
re_ctx.bytecode_ctx_p = &bc_ctx;
512517

513518
uint32_t cache_idx;
514-
*out_bytecode_p = re_find_bytecode_in_cache (pattern_str_p, &cache_idx);
519+
*out_bytecode_p = re_find_bytecode_in_cache (pattern_str_p, flags, &cache_idx);
515520

516521
if (*out_bytecode_p != NULL)
517522
{

0 commit comments

Comments
 (0)