91 Commits

Author SHA1 Message Date
Robert Fancsik
39cb67397d
Remove the usage of ecma_length_t (#4009)
Now the following conventions are applied:
 - passing the number of arguments for a function call is always uint32_t
 - string size/length/position related operation should use lit_utf8_size_t
 - Extended objects internal fields must be uint32_t

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-20 16:36:27 +02:00
Dániel Bátyai
321215fdbb
Update RegExp unicode mode case folding to conform to the standard (#4004)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-20 15:51:43 +02:00
Dániel Bátyai
74781c28c2
Fix sticky flag handling in @@replace (#4005)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-20 12:54:06 +02:00
Dániel Bátyai
c2bfdde806
Restore previous group start after a failed non-capturing group (#4002)
Fixes #3934.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-20 12:47:45 +02:00
Dániel Bátyai
f6cde17bfb
Update @@search to conform to ES11 standard (#4003)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-20 12:46:49 +02:00
Dániel Bátyai
b7fa4afb66
Global @@match result array should always contain strings (#4011)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-20 12:17:07 +02:00
Szilagyi Adam
9dbbcab49d
Remove ecma_op_object_get_own_data_prop and use ecma_op_object_get_by_magic_id instead (#3969)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-13 12:12:46 +02:00
Robert Fancsik
c1e90da0b4
Support Unicode supplementary planes (#3928)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-06 14:21:13 +02:00
Rafal Walczyna
9d2b7334bc
Update Symbol.split functions for String and Regexp to match new standard (#3942)
In newest ES standard limit parameter is calculated using
ToUint32 function instead of ToLength.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-06-30 16:03:11 +02:00
Robert Fancsik
a026a7d713
Fix releasing 'exec' in regexp replace fast path (#3913)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-17 19:24:07 +02:00
Dániel Bátyai
fde0d556ac
Re-target for ES.Next (#3901)
A list of changes:
- 'es2015-subset' profile is deprecated, and an 'es.next' profile is added.
- The default profile is changed to 'es.next'
- Renamed the JERRY_ES2015 guard to JERRY_ESNEXT
- Renamed JERRY_ES2015_BUILTIN_* guards to JERRY_BUILTIN_*
- Moved es2015 specific tests to a new 'es.next' subdirectory
- Updated docs, targets, and test runners to reflect these changes

Resolves #3737.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-12 17:55:00 +02:00
Dániel Bátyai
6d9d2328e9
Fix built-in RegExp allocation with default constructor (#3883)
Fixes #3880.
Fixes #3881.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-09 12:33:41 +02:00
Dániel Bátyai
9ceece8eb4
Fix string position calculation in @@replace (#3831)
Fixes #3817.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-02 16:15:23 +02:00
Dániel Bátyai
8f76a1f382
Rework RegExp engine and add support for proper unicode matching (#3746)
This change includes several bugfixes, general improvements, and support
for additional features.
- Added full support for web compatibility syntax defined in Annex B
- Implemented parsing and matching patterns in unicode mode
- Fixed capture results when iterating with nested capturing groups
- Significantly reduced regexp bytecode size
- Reduced stack usage during regexp execution
- Improved matching performance

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-26 15:28:54 +02:00
Péter Gál
bbb5c9180e
Fix releasing the pattern string in regexp (#3765)
The release of the regexp pattern string during creating
was incorrect as it was dereferenced a bit to early.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-20 12:10:05 +02:00
Dániel Bátyai
48fa2ec01b
Fix the types of builtin prototype objects (#3663)
In ES2015 many builtin prototypes are no longer valid instances of their
respective classes. This change updates affected prototypes to be
regular objects as required.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-04-06 12:00:58 +02:00
Szilagyi Adam
d539d30bf9
Update the RegExp constructor to ECMA-262 v6 (#3538)
The following methods have been implemented:
- RegExpAlloc, based on ECMA-262 v6, 21.2.3.2.1
- RegExpInitialize, based on ECMA-262 v6, 22.2.3.2.2
- RegExpCreate, based on ECMA-262 v6, 21.2.3.2.3

Co-authored-by: Robert Fancsik frobert@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-27 10:37:06 +01:00
Robert Fancsik
bfd2639634
Rework the core of class parsing/runtime semantic (#3598)
Changes:
 - Use the pre-scanner to provide information for the parser about the existence of the class constructor
 - The allocation of the super declarative environment is no longer needed
 - The VM frame context holds the information about the this binding status
 - Reduce the number of class related VM/CBC instructions
 - Improve ecma_op_function_{construct, call} to properly set new.target

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-16 14:37:47 +01:00
Szilagyi Adam
40b38f70ef Refactor ecma_regexp_exec_helper arguments (#3484)
We use pointers instead of ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-06 14:38:09 +01:00
Dániel Bátyai
2a29b72a83 Implement and add support for Symbol.split (#3453)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-12-20 09:10:58 +01:00
Zoltan Herczeg
40d930d62c Implement \u{hex} support. (#3447)
A large rework because surrogate pairs must be combined.

Currently only the 0x10C80..0x10CF2 is accepted as valid identifier character from the non-basic plane.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-16 11:26:02 +01:00
Dániel Bátyai
d3b8bed2c1 Implement and add support for RegExp.prototype[@@search] (#3436)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-12-12 15:59:28 +01:00
Szilagyi Adam
7c0b1ca88a Update String.prototype.match to ECMA-262 v6 (#3375)
The algorithm is based on ECMA-262 v6, 21.1.3.11

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-10 14:40:41 +01:00
Daniella Barsony
89db9253c8 Refactor code to use ToInteger (#3224)
Fixes #3325
Fixes #3237

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2019-12-09 12:07:25 +01:00
Dániel Bátyai
9634ca556e Fix leaking char buffer in RegExp.prototype[@@replace] (#3400)
Fixes #3392.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-12-03 09:34:53 +01:00
Dániel Bátyai
35c0a6e299
Implement RegExp unicode and sticky flags (#3379)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-29 14:08:30 +01:00
Szilagyi Adam
0c6b306429 Implement Regexp.prototype[@@match] method (#3345)
The algorithm is based on ECMA-262 v6, 21.2.5.6

The following helper methods are also implemented:
  - RegExpExec: ECMA-262 v6, 21.2.5.2.1
  - AdvanceStringIndex: ECMA-262 v6, 21.2.5.2.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-26 16:05:48 +01:00
Dániel Bátyai
279d4d4119 Add handling for RegExp unicode and sticky flags (#3341)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-22 14:04:03 +01:00
Dániel Bátyai
923fd128b5
Refactor String.prototype.replace (#3284)
This change brings the replace operation up to date with ES6 by
implementing support for the @@replace well-known symbol, while
also improving performance and memory usage.

Also fixes #3070.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-08 12:15:28 +01:00
Szilagyi Adam
4b352758c1 Refactor ecma_op_to_string (#3171)
Similar to the ecma_op_to_object rework, in this new method we
return directly with the pointer to the ecma string, and we don't
wrap the result into an ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-25 15:58:47 +02:00
Dániel Bátyai
c3bb516e4a Refactor RegExp builtin (#3136)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-10-02 16:55:16 +02:00
Robert Fancsik
1088273bc3 Prevent fast access mode arrays from low-level property management methods (#3047)
This patch fixes #3043 and fixes #3045 and fixes #3046.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-09-04 10:41:29 +02:00
Robert Fancsik
ee1da14577 Optimize ecma_builtin_helper_def_prop. (#3007)
This patch removes the ecma_property_descriptor_t structure bitfields and substitutes it with an uint16_t flag field
to reduce the cost of the transformation from/into the ecma_property_flags_t.
Also the is_throw last arguments is embedded to the property descriptor structure during the property defining process to reduce the number of arguments of the function.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-08-27 18:28:03 +02:00
Dániel Bátyai
d3c78d8c6a Improve lastIndex calculation in RegExp match (#2982)
Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-25 18:20:51 +02:00
Robert Fancsik
4a9e185840
Rework the engine's internal recursion limit (#2969)
This patch unifies the recursion limit checking for RegExp, function call and JSON as well.
Until now the limit was only a counter which was increased/decreased at certain points.
This counter has been substituted with a numeric limit which allows to restrict the stack usage.

This patch fixes #2963 and resolves the closed #2258 issue.

Co-authored-by: Gabor Loki loki@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-07-23 15:31:37 +02:00
Péter Gál
01ecc7bb7b Rework usages/naming of configuration macros [part 2] (#2903)
There are quite a few configuration macros in the project.
As discussed in the #2520 issue there are a few awkward constructs.

Main changes:

* The following macros are now 0/1 switches:
** Renamed CONFIG_ECMA_LCACHE_DISABLE to JERRY_LCACHE.
** Renamed CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE to JERRY_PROPERTY_HASHMAP.
** Renamed CONFIG_DISABLE_UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION.
** Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
** Renamed JERRY_DISABLE_JS_PARSER to JERRY_PARSER.
** Renamed JERRY_ENABLE_ERROR_MESSAGES to JERRY_ERROR_MESSAGES.
** Renamed JERRY_ENABLE_EXTERNAL_CONTEXT to JERRY_EXTERNAL_CONTEXT.
** Renamed JERRY_ENABLE_LINE_INFO to JERRY_LINE_INFO.
** Renamed JERRY_ENABLE_LOGGING to JERRY_LOGGING.
** Renamed JERRY_ENABLE_SNAPSHOT_EXEC to JERRY_SNAPSHOT_EXEC.
** Renamed JERRY_ENABLE_SNAPSHOT_SAVE to JERRY_SNAPSHOT_SAVE.
** Renamed JERRY_SYSTEM_ALLOCATOR to JERRY_SYSTEM_ALLOCATOR.
** Renamed JERRY_VM_EXEC_STOP to JERRY_VM_EXEC_STOP.
** Renamed JMEM_GC_BEFORE_EACH_ALLOC to JERRY_MEM_GC_BEFORE_EACH_ALLOC.
** Renamed JMEM_STATS to JERRY_MEM_STATS.
** Renamed PARSER_DUMP_BYTE_CODE to JERRY_PARSER_DUMP_BYTE_CODE.
** Renamed REGEXP_DUMP_BYTE_CODE to JERRY_REGEXP_DUMP_BYTE_CODE.
* Recursion check changes:
** Renamed REGEXP_RECURSION_LIMIT to JERRY_REGEXP_RECURSION_LIMIT.
** Renamed VM_RECURSION_LIMIT to JERRY_VM_RECURSION_LIMIT.
* Attribute macro changes:
** Renamed JERRY_CONST_DATA to JERRY_ATTR_CONST_DATA.
** Renamed JERRY_HEAP_SECTION_ATTR to JERRY_ATTR_GLOBAL_HEAP.
  Now the macro can specify any attribute for the global heap object.
* Other macro changes:
** Renamed CONFIG_MEM_HEAP_AREA_SIZE to JERRY_GLOBAL_HEAP_SIZE.
   Then new macro now specify the global heap size in kilobytes.
* Updated documentations to reflect the new macro names.

For more deatils please see jerry-core/config.h.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-06-19 12:28:21 +02:00
Robert Fancsik
442e482afa Add missing error check for ecma_regexp_exec_helper (#2887)
This patch fixes #2885.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-05-28 14:22:57 +02:00
Péter Gál
40f7b1c27f Rework usages/naming of configuration macros [part 1] (#2793)
There are quite a few configuration macros in the project.
As discussed in the #2520 issue there are a few awkward constructs.

Main changes:

* Renamed all CONFIG_DISABLE_<name>_BUILTIN macro to JERRY_BUILTIN_<name> format.
* The special JERRY_BUILTINS macro specifies the basic config for all es5.1 builtins.
* Renamed all CONFIG_DISABLE_ES2015_<name> to JERRY_ES2015_<name> format.
* The special JERRY_ES2015 macro specifies the basic config for all es2015 builtins.
* Renamed UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION.
* Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
* All options (in this change) can have a value of 0 or 1.
* Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
  JERRY_REGEXP_STRICT_MODE is set to 0 by default.
* Reworked CONFIG_ECMA_NUMBER_TYPE macro to JERRY_NUMBER_TYPE_FLOAT64 name and now
  it uses the value 1 for 64 bit floating point numbers and 0 for 32 bit floating point
  number.
  By default the 64-bit floating point number mode is enabled.
* All new JERRY_ defines can be used wit the `#if ENABLED (JERRY_...)` construct to
  test if the feature is enabled or not.
* Added/replaced a few config.h includes to correctly propagate the macro values.
* Added sanity checks for each macro to avoid incorrectly set values.
* Updated profile documentation.
* The CMake feature names are not updated at this point.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-04-09 10:14:46 +02:00
Robert Fancsik
044b4ea827 Add missing error checks for ecma_regexp_exec_helper (#2756)
This patch fixes #2755.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-02-13 12:50:01 +01:00
Istvan Miklos
c23cf4176a Add RegExp recursion depth limit (#2543)
The regexp engine does not have any recursion depth check, thus it can cause problems with various regexps. Added a new build option `--regexp-recursion-limit N` whose
default value is 0, which is for unlimited recursion depth. Also added a build-option-test.

Fixes #2448
Fixes #2190

JerryScript-DCO-1.0-Signed-off-by: Istvan Miklos imiklos2@inf.u-szeged.hu
2019-01-17 20:16:50 +01:00
László Langó
2f8c0a168f Removed ECMA_TRY_CATCH macros from RegExp built-in (#2642)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2019-01-04 15:12:03 +01:00
Robert Fancsik
e11c499b4b Reduce ecma_{ref, deref}_object calls while using ecma_builtin_get (#2616)
The following stucture was highly frequented in the code base:

 - Get a builtin object // This operation increases the reference count of the object
 - Use it for create a new object
 - Deref the builtin object

After a builtin has been instantiated there is always at least one reference to "keep it alive",
so increase/decrease the reference count for getting the value only is unnecessary.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2018-11-28 20:23:21 +01:00
Daniel Balla
704eb45cb8 [API] Add RegExp C API (#2542)
This patch supports creating a RegExp object through the C API.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2018-11-19 13:18:00 +01:00
Robert Fancsik
3faec79071 Reduce ecma_builtin_helper_def_prop arguments (#2585)
This patch uses the ECMA_PROPERTY_CONFIGURABLE[_ENUMERABLE_[WRITABLE]] marco to pass the options instead of using 3 boolean arguments for it.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2018-11-06 18:13:38 +01:00
Akos Kiss
4779451284
Cleanup code around JERRY_UNREACHABLEs (#2342)
`JERRY_UNREACHABLE`s often signal code structure that could be
improved: they can usually either be rewritten to `JERRY_ASSERT`s
or eliminated by restructuring loops, `if`s or `#if`s. Roughly,
the only valid occurences are in default cases of `switch`es. And
even they can often be merged into non-default cases.

Moreover, it is dangerous to write meaningful code after
`JERRY_UNREACHABLE` because it pretends as if there was a way to
recover from an impossible situation.

This patch rewrites/eliminates `JERRY_UNREACHABLE`s where possible
and removes misleading code from after them.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-05-25 07:27:30 +02:00
László Langó
64b16bf190 Update Doxygen config file and fix Doxygen warnings (#2324)
A lot of warnings remained hibben because 'EXTRACT_ALL' was previously set to YES.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2018-05-18 15:43:17 +09:00
Akos Kiss
65ae949dc3 Add jerryscript-compiler.h public header to cover compiler incompatibilities (#2313)
In general, public headers should not have compiler-specific
constructs but both the core and the port headers have attributes,
which are non-standard. It's better to factor out such constructs
to a common place (a new header) and hide them behind macros, which
can then be defined on a per-compiler basis.

This patch moves the existing definitions of function attributes and
likely/unlikely builtins to the new header. At the same time, it
unifies the names of these attribute defines and where they are
used. Moreover, it touches on jerry-main and removes the uses of
`__attribute__((unused))` entirely and replaces them with the
elsewhere used `(void) ...` pattern.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-05-14 09:41:26 +09:00
Mátyás Mustoha
63ce292173 Reduce code duplication between RegExp.construct and [[Call]] (#2287)
JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2018-04-20 15:27:33 +02:00
Yuyupo
63e3eaf087 Remove ecma_get_length_string (#2234)
Fixes #2231

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2018-03-05 15:17:29 +01:00
Zoltan Herczeg
d60d4dbba9
Improve magic string handling. (#2221)
Remove unnecessary ref / deref calls when magic strings are used.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-03-01 13:31:15 +01:00