758 Commits

Author SHA1 Message Date
Renáta Hodován b7069350c2 cmake: avoid Apple ranlib flags when not using AppleClang (#5258)
On macOS, `-no_warning_for_no_symbols -c` options are specific to the
Apple `ranlib` tool. When using other toolchains (e.g. Homebrew clang),
these flags cause errors since `llvm-ranlib` does not recognize them.

The patch ensures these flags are only passed when using AppleClang.

JerryScript-DCO-1.0-Signed-off-by: Renata Hodovan reni@inf.u-szeged.hu
2025-10-08 19:35:32 +02:00
Roland Takacs 355ab24cdc Bump RIOT target to 25.04 (#5231)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2025-06-03 13:04:20 +02:00
László Langó 50200152fe Update the README.md for release 3.0 (#5200)
JerryScript-DCO-1.0-Signed-off-by: Laszlo Lango laszlo.lango@h-lab.eu
2024-12-18 11:36:32 +01:00
László Langó 4cda596060 Updated the "Getting Started" and "Migration Guide" for the 3.0 release (#5202)
JerryScript-DCO-1.0-Signed-off-by: Laszlo Lango laszlo.lango@h-lab.eu
2024-12-18 11:28:38 +01:00
Yonggang Luo d2d30df420 Revise tools scripts to be python3 compatible on win32 (#4856)
We introduce setup_stdio function to setup stdout/stderr properly.
For python <-> python pipe, we always use 'utf8'/'ignore' encoding for not lost characters.
For tty <-> python, we using native encoding with xmlcharrefreplace to encode, to preserve maximal information.
For python <-> native program, we use naive encoding with 'ignore' to not cause error

update_exclude_list with binary mode so that on win32 would not generate \r\n

run-test-suite.py: Handling skiplist properly on win32

Fixes #4854

Fixes test262-harness.py complain cannot use a string pattern on a bytes-like object with running test262 with python3

For reading/writing to file, we use 'utf8' /'ignore' encoding for not lost characters.
For decoding from process stdout, using native encoding with decoding error ignored for not lost data.
Execute commands also ignore errors
Fixes #4853

Fixes running test262-esnext failed with installed python3.9 on win32 with space in path
Fixes #4852

support both / \ in --test262-test-list arg

On win32.
python tools/run-tests.py  --test262-es2015=update --test262-test-list=built-ins/decodeURI/
python tools/run-tests.py  --test262-es2015=update --test262-test-list=built-ins\decodeURI\
should be both valid,
currently only --test262-test-list=built-ins\decodeURI\ are valid.

Support snapshot-tests-skiplist.txt on win32 by use os.path.normpath

Guard run-tests.py with timer.

All run-tests.py are finished in 30 minutes in normal situation.
May change the timeout by command line option

Move Windows CI to github actions
Define TERM colors for win32 properly

flush stderr.write stdout.write

On CI, the stderr are redirect to stdout, and if we don't flush stderr and stdout,
The output from stderr/stdout would out of sync.

`Testing new Date(-8640000000000000) and fixes date for win32`
So that the CI can passed

if sys.version_info.major >= 3: remove, as we do not support python2 anymore

Fixes compiling warnings/errors for mingw/gcc

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 10:41:12 +01:00
Yonggang Luo a1e4bd859e 02.API-REFERENCE.md format the *Note*: (#5195)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 10:20:20 +01:00
Yonggang Luo f322f603f5 Fixes nuttx target warning (#4984)
The warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 10:17:57 +01:00
Yonggang Luo f0a249dfd3 CMake update cmake_minimum_required (VERSION 3.10) (#5187)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 10:12:34 +01:00
Yonggang Luo b4bc23078a Improve the jerry port api documents. (#4977)
Notable changes:
  - Remove the comments in port impl, that's easily getting to in-consistence
  - Sync the jerryscript-port.h and 05.PORT-API.md
  - Fixes the invalid comment in port codes

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 10:10:37 +01:00
Yonggang Luo 77c72d4da7 docs: Fixes test code (#5193)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 09:43:35 +01:00
Yonggang Luo 5480cc3973 Doxygen comment update and PREDEFINED in Doxyfile is properly defined (#5186)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 09:02:54 +01:00
Gergo Csizi 718a439db1 Fix some style issues in debugger documentation (#5181)
There was some style issues in debugger documentation.
This patch fixes these issues.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-12-12 20:44:36 +01:00
László Langó a746a1d29a Update the API documentation (#5178)
- Minor fixes, typos, version numbers, etc.
 - Followup fix after "Merge Promise Guard with ESNEXT #4725"
 - Added documentation for the new implemented API functions

JerryScript-DCO-1.0-Signed-off-by: Laszlo Lango laszlo.lango@h-lab.eu
2024-12-12 20:39:48 +01:00
Yonggang Luo 8d44eed661 Fixes dead loop when abort called in Win32/CI (#5197)
Disable the debug popup on MSVC/win32 by introduce new jerry_port_init function

For not popup dialog when crash happend on MSVC/win32
Closed: #4463

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-11 08:52:05 +01:00
László Langó aa7861daf2 Fix the return type of 'jerry_string_substr'. (#5185)
Also added new unit test to test basic functionality of 'jerry_string_substr'.

JerryScript-DCO-1.0-Signed-off-by: Laszlo Lango laszlo.lango@h-lab.eu
2024-12-10 21:56:23 +01:00
Gergo Csizi c509a06669 Added jerry-ext amalgamation (#5184)
Added option to enable jerry-ext amalgamation

The implementation is based on PR #4992. Only applied the requested changes
and rebase to master.

Co-authored-by: Damiano Mazzella damianomazzella@gmail.com
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-12-03 08:33:28 +01:00
Gergo Csizi b3fa5e0e03 Add missing configuration information to CONFIGURATION.md (#5183)
There was some missing configuration options in the CONFIGURATION documentation.
This patch adds these missing configurations.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-29 15:26:10 +01:00
Gergo Csizi 0b1d75a7db Update and fix some issues in EXT-REFERENCE documentation (#5180)
There was some issues and typos in the EXT-REFERENCE documentation.
This patch fixes these issues and typos.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-28 13:35:19 +01:00
Gergo Csizi 5f467a658b Fix check-string.sh to check every generated strings (#5179)
The original implementation only checked lit-magic-strings.inc.h.
This patch adds checking for ecma-error-messages.inc.h and parser-error-messages.inc.h

This patch fixes #5172 issue.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-27 13:56:51 +01:00
Gergo Csizi ba8957697a Fix Typedarray.slice fastpath when the content type is matching (#5177)
This patch fixes #4888.

The implementation is based on PR #4898, only resolved the conflicts and
applied requested changes.

Co-authored-by: Robert Fancsik robert.fancsik@h-lab.eu
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-26 14:27:24 +01:00
maciej m. 59649fc222 fix building without BIGINT (#5047)
* fix building without BIGINT

Co-authored-by: Maciej Musiał <xt1@o2.pl>
JerryScript-DCO-1.0-Signed-off-by: aksdfauytv rdkifk@jadamspam.pl
2024-11-26 11:01:34 +01:00
Gergo Csizi 7db6a9a372 Implement operations of atomics (#5166)
The following methods were implemented:
 - Atomics.compareExchange
 - Atomics.store

The implementation is based on PR #4956, only resolved the conflicts.

Co-authored-by: Csaba Repasi repasics@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-26 10:56:28 +01:00
Yonggang Luo dfa9afbf6e Introduce JERRY_ZSTR_ARG macro to avoid jerryx_print_string, jerryx_print_byte, jerry_port_print_byte, strlen (#4982)
Replace usage of jerryx_print_byte, jerryx_print_string with jerryx_print_buffer.

As we now have JERRY_ZSTR_ARG, so we can take advantage of it

With this, the jerry_port_print_byte port api won't need any more
this reduced the port api surface

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-11-25 17:28:55 +01:00
Csaba Osztrogonác e4017f0b3a Use regular expressions to parse the YAML headers of the tests (#4910)
instead of the imported thirdparty YAML parser.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2024-11-25 14:00:21 +01:00
LJ 95cc5e992a Fix the private field crash for the Array object. (#5139)
Fixes 5097, 5100, 5138

Additional regression test cases added by: Robert Sipka <robert.sipka@h-lab.eu>

JerryScript-DCO-1.0-Signed-off-by: Baihe Jiang <baihe.jiang@outlook.com>
JerryScript-DCO-1.0-Signed-off-by: Lily Jiang bhjiang.whu@hotmail.com
2024-11-25 13:04:00 +01:00
Gergo Csizi 00d12c0265 Implement BigInt asIntN and asUintN methods (#5165)
The following methods were implemented:
- BigInt.asIntN
- BigInt.asUintN

Custom dispatcher also added to builtin_bigint.

The implementation is based on PR #4736, only applied the requested changes.

Co-authored-by: Daniel Batiz batizjob@gmail.com
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-22 09:33:08 +01:00
Robert Fancsik a7e24fe89a Const literal marker should be processed before group assignment marker (#4948)
This patch fixes #4925.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2024-11-21 11:10:09 +01:00
Yonggang Luo 82ca949850 Update document 10.EXT-REFERENCE-HANDLER.md (#5163)
The handler prototype did not match it's implementation

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-11-20 17:46:10 +01:00
Gergo Csizi f54f2d3a7b Implement optional chaining (#5164)
The work is based on PR #4843, only fixed some conflicts and cppcheck errors.

Co-authored-by: Robert Fancsik robert.fancsik@h-lab.eu
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-20 11:57:58 +01:00
Gergo Csizi e9f08a7879 Put reference on executable object's this_binding to avoid unwanted f… (#5169)
…rees before exiting execution

This patch fixes #4870.

The implementation is based on PR #4966, only resolved the conflicts
and applied requested changes.

Co-authored-by: Martin Negyokru negyokru@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-19 14:52:33 +01:00
Gergo Csizi 348e6a470e Accessors should be kept alive during their invocation (#5167)
This patch fixes #4900.

The implementation is based on PR #4943, only resolved the conflicts.

Co-authored-by: Robert Fancsik robert.fancsik@h-lab.eu
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2024-11-18 09:47:07 +01:00
Robert Sipka 38e05b4569 Minor fix to ensure Python 3 support in the debugger (#5168)
The default value for length in to_bytes was added in Python version 3.11.
This small fix ensures the compatibility with older Python3 versions.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu
2024-11-15 14:35:24 +01:00
Yonggang Luo d2e0d71101 Revise implementation of jerry_port_get_local_time_zone_adjustment on Win32 (#4589)
Handle the limitation of Win32 date API properly.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-11-14 13:38:46 +01:00
Yonggang Luo 43f5026eb2 Add testcase that cleanup error throw from javascript properly. (#4581)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-11-12 21:24:35 +01:00
Yonggang Luo 3f314f387d Fixes unit-test-date-helpers failure on win32 (#4654)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-11-12 13:39:00 +01:00
László Langó bd0d391ee3 Fixes the GH actions by resolving the deprecated API usage. (#5160)
JerryScript-DCO-1.0-Signed-off-by: Laszlo Lango laszlo.lango@h-lab.eu
2024-11-07 10:07:57 +01:00
batizdaniel 5f3428becb Fix runtime error Date object (#4914)
This patch fixes #4704

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
2024-11-06 16:15:37 +01:00
winsoft666 4a39946ef6 Add build argument: --arch (#5147)
Signed-off-by: winsoft666 <mioktiar@gmail.com>
2024-11-04 15:28:36 +01:00
winsoft666 f5d3d9004a Add build argument: --static-crt (#5148)
Signed-off-by: winsoft666 <mioktiar@gmail.com>
2024-11-04 15:27:57 +01:00
kulcsaradam de515316cf Fix parsing of invalid asterix symbol after private field symbol (#5155)
Raise syntax error instead of crashing.

JerryScript-DCO-1.0-Signed-off-by: Ádám Kulcsár kuladam@inf.u-szeged.hu
2024-08-14 18:09:09 +02:00
Máté Tokodi 2dbb6f79ef Fix parsing class body that includes stray semicolon after a static block (#5145)
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-06-18 20:02:48 +02:00
Máté Tokodi 4e89e1828e Fix parsing of invalid private class properties (#5144)
Raise syntax error instead of failing with an assert

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-06-18 20:00:07 +02:00
Máté Tokodi d7e21259fe Fix arguments object in eval-ed functions in static class initializers (#5140)
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-05-28 06:59:13 +02:00
Máté Tokodi 35465ed78e Fix CI for macos (#5142)
Due to compiler bugs present in the latest version of clang on macos:

Roll back macos version used by github actions from `macos-latest`
(`macos-14`) to `macos-13`: Some modulo operations were failing,
such as `-1 % -1` when compiler optimizations were enabled

Disable `-Wliteral-range` for test-math.c on macos, because it was
falsely raised for `isnan`, `isinf`, and `isfinite ` macros.

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-05-24 18:34:26 +02:00
Renáta Hodován 47bd5d4b91 Fix typo in the CMake setup of libFuzzer (#5136)
JerryScript-DCO-1.0-Signed-off-by: Renata Hodovan reni@inf.u-szeged.hu
2024-04-09 10:05:11 +02:00
Máté Tokodi cefd391772 Fix rare crash caused by get method of proxy object (#5129)
This fixes #5101
In rare cases the proxy object could get used after
being incorrectly removed by the gc

Add stack checks to the start of all function calls

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-03-13 12:08:41 +01:00
Máté Tokodi bac7ee3acd Fix gc of async destructuring assignments of strings (#5126)
This fixes #5089

When garbage collection is running on a paused async function that
includes destructuring assignments of strings, the string can be a
direct string, and not an object, which cannot be marked as visited, as
it does not have a visited flag.

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-02-06 08:10:14 +01:00
Máté Tokodi 52debe8589 Fix arrow function parsing (#5093)
This fixes #5085

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2024-02-01 00:34:37 +01:00
Máté Tokodi 514fa6735a Update MbedOS, RIOT and ESP_IDF CI checkers (#5120)
Update MbedOS and RIOT CI checkers to use `gcc-arm-none-eabi` on top of
ubuntu-latest

Upgrade to mbed-tools and mbed-os 6.17

Bump xtensa version to `2021r2-patch5` and re-enable `ESP_IDF_Build_Test`

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2023-12-15 12:12:59 +01:00
Máté Tokodi 3b876f7392 Update clang-format (#5112)
Bump minimum clang-format version to 15 (the previously used 10 is not
in the ubuntu-22.04 repo)

Reformat several files

Re-enable format and strings CI checkers

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2023-12-11 23:21:52 +01:00
Máté Tokodi ef4cb2bf74 Update cppcheck (#5108)
Re-enable cppcheck CI job

Update cppcheck suppression list:
    The new version of cppcheck raises warnings for many potential
    issues that are guarded against, so those warnings have been
    supressed.

Handle realloc failures:
    - jerry-ext/util/sources.c
    - jerry-port/common/jerry-port-io.c

Refactor test-snapshot: move each test to separate functions like some
others already were.

Rename `handler` variables inside `main` of `test-api.c` as they
shadowed the `handler` function in the same file.

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2023-11-22 11:36:45 +01:00
Máté Tokodi ff9ff8f36c Update doxygen and fix documentation (#5106)
Update Doxyfile to version 1.9.1

Re-enable doxygen CI checker

Fix some regular comments that should have been doc comments

Document void return types for some inline functions explicitly

Move start of some doxygen groups so they are included always, and not left
out of certain ifdefs

Ignore some doxygen warnings:
    Member (function) is not documented in headers
    Documented empty return type in headers
    Argument has multiple @param documentation sections

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2023-11-15 09:49:04 +01:00
Máté Tokodi bc408b159b Modernize python and update pylint (#5096)
Update code to conform to the newer version of pylint available in
ubuntu-22.04, with few exceptions:
    - disabled `import-outside-toplevel` for `main()` in
      `jerry_client.py`
    - disabled `consider-using-with` for the logfile of `TestSuite` in
      `test262-harness.py` as using `with` is not practical in that case

Update test262-harness.py to use argparse instead of the now deprecated
optparse

Rename variables in jerry_client_main.py that redefined python builtins
or shadowed variables from an outer scope

Update python files to use f-stirngs

Add minimum python versions (3.6 and 3.8) to the CI jobs: without it the
default python version did not support the `with` statement for
`subprocess.Popen` used in `build.py` on macos, or in some cases f-stirngs

Remove `from __future__` imports that are no-ops in python 3

Remove shebang from non executable files

Re-enable most pylint checkers, except `missing-docstring`

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2023-10-25 17:32:14 +02:00
Máté Tokodi a588e49661 Update tests and CI to python3 (#5095)
Update debugger and test262 tests to python3
Disable CI jobs that need ubuntu-18.04 (EOL) until they are updated

JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi matet@inf.u-szeged.hu
2023-09-20 15:38:30 +02:00
Akos Kiss 05dbbd134c Fix line info guard comment (#5049)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2023-03-27 11:53:34 +02:00
Roland Takacs 1a2c04763a Ensure command prompt is displayed when REPL is used (#5033)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2023-01-09 14:28:34 +01:00
Csaba Osztrogonác f5a8dc02b4 Fix failing CI jobs (#5032)
Test262 test runner needs python2, we need to install it manually on Ubuntu 22.04.
Disable ESP_IDF_Build_Test CI job temporarily, because it is broken.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2023-01-04 13:09:24 +01:00
Zoltan Herczeg 6fe763f191 Allow redefining global variables as imports (#5023)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2022-09-09 16:36:08 +02:00
Damiano Mazzella b143b050cc Replace global inclusions with local ones (#4991)
Resolve compiler errors created by amalgam.py tool.
2022-08-22 16:06:21 +02:00
Zoltan Herczeg 368641043f Mark generator as running during yield* (#5014)
Fixes #5013

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2022-08-08 17:36:59 +02:00
Zoltan Herczeg 3360e352bf Fix exception printing. (#5012)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2022-08-08 08:14:37 +02:00
Gergo Csizi baf308a7ae Fix ESPIDF_Build_Test (#5019)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi gergocs@inf.u-szeged.hu
2022-08-01 22:10:42 +02:00
Roland Takacs 0d49696618 Merge esp8266-rtos-sdk and esp-idf targets (#4958)
This patch bumps esp8266-rtos-sdk to the latest release. This required to
modify the directory structure and the build system to conform to ESP-IDF
Style. Since esp-idf target already supports ESP-IDF Style, the espressif
targets has been merged to eliminate code duplication.
The target application code has been modified from blinking leds to hello
world to be aligned to other targets.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2022-02-22 10:58:18 +01:00
Roland Takacs c9e9f8e818 Add support for Mbed-OS 6.15.0 (#4909)
The default Mbed OS device (STM32F4) had been changed to FRDM-K64F that is
supported by both Mbed OS 5 and Mbed OS 6 versions. Makefile had also been
modified to have a flash recipe.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2022-02-22 10:29:07 +01:00
Yonggang Luo d00f4810b0 Fix import paths in negative module tests (#4973)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2022-02-03 11:36:39 +01:00
Yonggang Luo c5bc3786cf Remove abandoned es5.1 profile from API reference (#4972)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2022-02-03 11:35:42 +01:00
Szilagyi Adam 4924f9fd31 Remove ES_NEXT macro (#4915)
- remove all '#JERRY_ESNEXT' macro
- remove 5.1 build profile, update test runner accordingly (Note: all builtins are turn on by default)
- move tests from tests/jerry/esnext into tests/jerry, concatenate files with same names
- add skiplist to some snapshot tests that were supported only in 5.1
- fix doxygen issues that were hidden before (bc. of es.next macro)

Co-authored-by: Martin Negyokru negyokru@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2022-01-31 16:46:00 +01:00
Dániel Bátyai 76403606d0 Fix logging related issues (#4971)
PR #4907 moved the log level into the engine context, however this caused
issues with logging without the engine being initialized. This commit
reverts the log level to be a static variable.

This commit also implements missing format specifiers for jerry_log.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2022-01-21 10:02:35 +01:00
Robert Fancsik aead4b79a9 Fix format string in main-benchmark.c (#4970)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-20 19:50:23 +01:00
batizdaniel 0ef509458e Fix runtime error: left shift of negative value (#4957)
This patch fixes #4701

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
2022-01-20 14:00:47 +01:00
Dániel Bátyai ac1c48eeff Update jerry-port and jerry-ext (#4907)
Notable changes:
  - Updated and the port API interface, new functions have been added
    and some have been changed. The port library is now cleaned up to
    not have any dependency on jerry-core, as it should be. The port library
    is now strictly a collection of functions that implement
    embedding/platform specific behavior.
  - The default port implementation has been split for windows and unix.
    Implemented port functions have been categorized and reorganized,
    and marked with attribute((weak)) for better reusability.
  - External context allocation has been moved to the port API instead
    of a core API callback. The iterface has also been extended with a
    function to free the allocated context. When external context is
    enabled, jerry_init now automatically calls the port implementation
    to allocate the context and jerry_cleanup automatically calls the port
    to free the context.
  - jerry_port_log has been changed to no longer require formatting to
    be implemented by the port. The reason beind this is that it was vague what
    format specifiers were used by the engine, and in what manner. The port
    function now takes a zero-terminated string, and should only implement
    how the string should be logged.
  - Logging and log message formatting is now handled by the core jerry library
    where it can be implemented as necessary. Logging can be done through a new
    core API function, which uses the port to output the final log message.
  - Log level has been moved into jerry-core, and an API function has
    been added to set the log level. It should be the library that
    filters log messages based on the requested log level, instead of
    logging everything and requiring the user to do so.
  - Module resolving logic has been moved into jerry-core. There's no
    reason to have it in the port library and requiring embedders to
    duplicate the code. It also added an unnecessary dependency on
    jerry-core to the port. Platform specific behavior is still used through
    the port API, like resolving module specifiers, and reading source file
    contents. If necessary, the resolving logic can still be overridden as
    previously.
  - The jerry-ext library has also been cleaned up, and many utility
    functions have been added that previously were implemented in
    jerry-main. This allows easier reusability for some common operations,
    like printing unhandled exceptions or providing a repl console.
  - Debugger interaction with logged/printed messages has been fixed, so
    that it's no longer the port implementations responsibility to send
    the output to the debugger, as the port should have no notion of what a
    debugger is.  The printing and logging functions will now pass the
    result message to the debugger, if connected.
  - Cleaned up TZA handling in the date port implementation, and simplified
    the API function prototype.
  - Moved property access helper functions that use ASCII strings as
    keys from jerry-ext to the core API.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2022-01-20 13:53:47 +01:00
Robert Fancsik 79fd540ec9 Fix duplicated private identifier lookup (#4947)
This patch fixes #4921.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-18 13:22:45 +01:00
Robert Fancsik 85c798705a Add missing toObject conversion for PrivateSet operation (#4953)
This patch fixes #4936.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-18 13:16:02 +01:00
Csaba Osztrogonác dfbd89d94f Update test262 hash to the latest master (#4959)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2022-01-14 11:04:52 +01:00
mnegyokru c68f6e79e1 Add stack-overflow check to 'lexer_construct_function_object' (#4965)
This patch fixes #4887.

JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu
2022-01-14 11:02:50 +01:00
mnegyokru 57547d1261 Ban setting 'Object.prototype.__proto__' as Proxy to prevent circular referencing (#4961)
in prototype chain.

This patch fixes #4941

JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu
2022-01-14 11:02:19 +01:00
Robert Fancsik e9da834385 Fix async identifier parsing in class field position (#4949)
This patch fixes #4927

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-14 10:16:23 +01:00
Robert Fancsik 47d025c74f Check rest initializer existence after pattern finalization (#4950)
Since the scanner info is not present for invalid destructuring patterns we can only ensure the existence of the rest element after the pattern is finalized.
This patch fixes #4928.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-14 10:15:48 +01:00
Robert Fancsik 799583e5c8 Private identifier resolving should always construct new literal object (#4951)
This patch fixes #4930.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-14 10:14:04 +01:00
Robert Fancsik 2a3782141c Fix fast array objects cannot hold private properties (#4952)
This patch fixes #4934.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-14 10:13:03 +01:00
Robert Fancsik 8fa7819c1f Fix memory leak in AtomicModifyWrite (#4944)
This patch fixes #4894.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-14 10:05:39 +01:00
Robert Fancsik d681f201c2 Fix invalid assertion CESU8-UTF8 buffer copy (#4946)
The UTF8 buffer size can be smaller then the CESU8 string's size so the UTF8 output is may truncated. Therefore we cannot ensure that the CESU8 buffer is read until the end.
This patch fixes #4920.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-14 10:03:47 +01:00
mnegyokru 85bad33fbf Fix scanning bracketed expressions (#4964)
Scan 'async' literal with different depth of brackets

This patch fixes #4924.
This patch fixes #4748.

JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu
2022-01-13 13:48:34 +01:00
Csaba Osztrogonác 5467ac4608 Fix RIOT CI job (#4962)
Use https instead of the unsupported git protocol.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2022-01-11 11:03:44 +01:00
Robert Fancsik 0aa182c378 Date.prototype.setYear should invalidate cached tza (#4955)
This patch fixes #4939 and fixes #4940.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-10 17:35:49 +01:00
Robert Fancsik 6efe14d1bd Add missing object types for ecma_object_get_class_name (#4954)
This patch fixes #4937 and fixes #4938.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2022-01-10 16:37:35 +01:00
mnegyokru 58e504f1f4 Add stack-overflow check for general [[Construct]] method of function objects (#4945)
This patch fixes #4901

JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu
2022-01-10 16:27:39 +01:00
mnegyokru f3a420b672 Fix class static block opening brace parsing (#4942)
The next character should not be consumed after finding the static block opening brace.
This patch fixes #4916.

JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu
2022-01-10 14:53:04 +01:00
Roland Takacs 69f30977d9 Remove curie-bsp target (#4960)
Intel Corporation has announced the timeline for End of Life status for
Intel Curie Module (Intel Quark SE SoC) products.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2022-01-10 14:31:23 +01:00
Virag Orkenyi 49a1a80aa8 Clean up Math builtin max,min and hypot methods (#4904)
Nan_found, Inf_found variables and ecma_is_value_number check have been deleted.

JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2022-01-03 11:14:23 +01:00
batizdaniel a6ab5e9abe Fix runtime error: left shift (#4912)
This patch fixes #4703
This patch fixes #4702

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
2021-12-23 11:33:21 +01:00
Csaba Osztrogonác a63e1d294d Drop legacy test262-ES2015 testing support (#4908)
ES2015 features are already covered by ES.Next tests,
there is no need to run duplicated and outdated tests.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-12-23 11:31:56 +01:00
mnegyokru 077eaeb4e7 Update build profile to es.next on esp8266 (#4913)
- fix amalgam build issue with es.next profile
  - update esp linker script according to: Table 4-1. in
    https://www.espressif.com/sites/default/files/documentation/2a-esp8266-sdk_getting_started_guide_en.pdf

JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru negyokru@inf.u-szeged.hu
2021-12-23 11:30:19 +01:00
batizdaniel 26c6031530 Fix class literal scan (#4906)
This patch fixes #4892

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
2021-12-22 14:50:46 +01:00
Szilagyi Adam 53b61c1f6f Implement ECMAScript 2022 class static block (#4841)
Co-authored-by: Martin Negyokru negyokru@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2021-12-15 15:45:53 +01:00
Roland Takacs c51b268276 Minimize mbedos5 target (#4905)
* Removed hardware specific implementations
  * Added simple 'hello world' demo code to be aligned to other targets
  * Added ability to use external resources from outside JerryScript folder

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2021-12-15 12:52:40 +01:00
Szilagyi Adam d650390e47 Fix redeclaration related eval corner cases (#4886)
- Fix cases where a function parameter binding is redeclared inside a parameter initializer eval
- Fix cases where a let- or function arguments binding is redeclared inside a function block because
  there is a declaration in a function parameter initializer eval
- Also remove the ECMA_PARSE_CHAIN_INDEX_SHIFT macro, added a debugger_eval_chain_index named field to the jerry context instead

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2021-12-15 12:45:10 +01:00
Csaba Repasi 768a209544 Implement 'hasOwn' routine of Object object (#4835)
JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu
2021-12-15 11:38:02 +01:00
Robert Fancsik ce5c8492b8 Fix arguments object detection in non-complex param list (#4867)
This patch is the followup of #4849.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 11:35:27 +01:00
Robert Fancsik dfc001d373 Prevent stack-overflow in json internalize property (#4877)
This patch fixes #4848.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 11:34:22 +01:00
Robert Fancsik 070096f30f Fix arrow function this binding resolving if environment record is present (#4878)
This patch fixes #4872 and fixes #4876.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 11:32:31 +01:00
Robert Fancsik 7e0aa086ec Adjust fast array growth (#4868)
Since we allow large buffer allocations during array constructor we could extend this behavior to [[Set]] operation as well.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 10:35:28 +01:00
Robert Fancsik dbba83fe40 Fix typedarray validation in Atomics read_modify_write (#4879)
This patch fixes #4875.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 10:33:21 +01:00
Robert Fancsik d37ff33dbe Fix class constructor as accessor check (#4880)
This patch fixes #4874.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 10:32:11 +01:00
Robert Fancsik ee59c226d9 Fix invalid argument reference in Promise.all executor (#4885)
This patch fixes #4871.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 10:31:09 +01:00
Robert Fancsik c2eb9ce35c Fix object class check for builtin Atomics (#4889)
This patch fixes #4884.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 10:29:29 +01:00
Robert Fancsik bcc711e731 Add stack-overflow check for Array.prototype.{flat, flatMap} (#4899)
This patch fixes #4890

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-15 10:28:18 +01:00
Csaba Repasi 42523bd6e2 Use external string when raising error (#4881)
JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu
2021-12-10 18:15:00 +01:00
Szilagyi Adam 4cbc77d709 Update detached arraybuffer handling (#4840)
- Fix isValidIntegerIndex usage in IntegerIndexed objects, [[Get]], [[Set]], [[DefineOwnProperty]] internal methods.
- The test262 revision is updated to the latest master hash.
- The PR is not separated into individual PRs since the standard change couldn't be tested without the new test262 revision.

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2021-12-10 13:09:16 +01:00
Yonggang Luo d5f048e961 Add FEATURE_INIT_FINI support on Windows. (#4859)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-12-10 13:01:24 +01:00
Robert Fancsik 55acdf2048 Fix buffer overflow in string radix conversion (#4850)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-07 15:28:10 +01:00
Robert Fancsik 18dd9aa75a Prevent arguments object creation if 'arguments' function argument is present (#4849)
This patch fixes #4847.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-07 14:05:48 +01:00
Yonggang Luo f8faf574b6 Rename resource_name to source_name (#4846)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-12-07 14:05:04 +01:00
Robert Fancsik 51da15516e Build fix after #4811 (#4845)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-06 16:46:46 +01:00
Robert Fancsik bfc1121e35 Fix AsyncGeneratorPrototype routines 'this' argument validation (#4811)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-12-06 12:03:26 +01:00
Roland Takacs af297bc578 Separate targets into os and baremetal-sdk parts (#4842)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2021-12-06 11:02:52 +01:00
Dániel Bátyai 9860d66a56 Rework the public API (#4829)
Related to #4186.

Some notable changes:
  - The term 'Error' now strictly refers to native Error objects defined in
    the ECMA standard, which are ordinary objects. All other uses of
    'error' or 'error reference' where the term refers to a thrown value is
    now called 'exception'.

  - Simplified the naming scheme of many String API functions. These functions
    will now also take an 'encoding' argument to specify the desired
    encoding in which to operate.

  - Removed the substring-copy-to-buffer functions. These functions
    behaved awkwardly, as they use character index to specify the
    start/end positions, and were mostly used incorrectly with byte
    offsets instead. The functionality can still be replicated with
    other functions if necessary.

  - String-to-buffer functions will no longer fail if the buffer is not
    sufficiently large, the string will instead be cropped.

  - Fixed the usage of the '_sz' prefix in many API functions. The term
    'sz' means zero-terminated string in hungarian notation, this was
    used incorrectly in many cases.

  - Renamed most of the public API functions to have shorter, more on-point
    names, rather than the often too long descriptive names. Functions are now
    also grouped by the type of value they operate on, where this makes
    sense.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2021-12-06 10:20:09 +01:00
Dániel Bátyai 81d2319144 Improve float number handling and conversion (#4820)
Fixes #4739.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2021-12-03 12:58:37 +01:00
Roland Takacs a1c1d42710 Update Zephyr target to 2.7.0 (#4838)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2021-12-02 15:33:29 +01:00
Robert Fancsik d69ac0e070 Implement logical assignment operators (#4834)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-30 10:44:27 +01:00
Szilagyi Adam 70e275e92f Implement ECMAScript 2022 private class methods and fields (#4831)
Co-authored-by: Robert Fancsik robert.fancsik@h-lab.eu
Co-authored-by: Martin Negyokru mnegyokru@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2021-11-26 12:24:59 +01:00
Csaba Repasi 841e21a970 Generate parser error messages (#4836)
Support parser error messages generation in tools/gen-strings.py.

JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu
2021-11-26 10:26:46 +01:00
Csaba Repasi 271d9b2463 Outsource magic error messages (#4821)
Modify tools/gen-magic-strings.py to generate error messages.

JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu
2021-11-25 14:06:40 +01:00
batizdaniel fc4168f2b4 Fix numeric literal with leading decimal point in accessor property name (#4832)
JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
2021-11-24 17:07:57 +01:00
Roland Takacs 3737a28eaf Update NuttX target to releases/10.2 (#4822)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2021-11-23 13:21:24 +01:00
Roland Takacs 2899582080 Update RIOT target to 2021.10 (#4826)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
2021-11-23 13:17:46 +01:00
Jacques Germishuys 06b4c02204 Restore esp-idf port (#4828)
This also cleans up all the files, moving them into a single file for
the port itself and module support respectively.

JerryScript-DCO-1.0-Signed-off-by: Jacques Germishuys jacques@beakbooklimited.com
2021-11-23 13:13:50 +01:00
Csaba Osztrogonác a7d5594d30 Fix JERRY_VLA macro on Windows (#4827)
Fixes #4824. The last macro argument should be inside parentheses.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-11-23 13:11:45 +01:00
batizdaniel 6b9e24aa51 Fix function name evaluation order (#4830)
JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz daniel.batiz@h-lab.eu
2021-11-23 11:58:12 +01:00
Robert Sipka 4592143400 Generator declaration is not allowed in single statement position (#4815)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu
2021-11-09 08:38:09 +01:00
Robert Fancsik 80777799f6 Fix goto labels indentation (#4818)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-05 16:58:41 +01:00
Robert Fancsik badfdf4dba Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-05 14:15:47 +01:00
Robert Fancsik bc091e1742 Optimize ecma_op_function_call (#4817)
Remove redundant isCallable checks

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-04 17:26:28 +01:00
Robert Sipka 7ea0000ee0 Minor fix in for-of statement parsing (#4814)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu
2021-11-02 19:12:30 +01:00
Zsolt Borbély 6a995e2887 Fix typos in the documentation and related files (#4809)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2021-11-02 11:37:05 +01:00
Zoltan Herczeg 89e367bbfd Optimize typed array access (#4806)
Use uint32 indexes instead of double indexes.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-11-02 11:07:56 +01:00
Zoltan Herczeg 960b99766c Allocate buffers when the buffer pointer is requested (#4812)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-11-02 09:36:55 +01:00
Robert Fancsik 3ad76f932c Fix for-in collection cleanup on abrupt 'has' result (#4807)
This patch fixes #4747

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-02 08:40:07 +01:00
Robert Fancsik efe63a5bbc Fix parsing unterminated let statement (#4808)
This patch fixes #4754

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-11-02 08:36:16 +01:00
Robert Sipka 9ed695f9d2 Assignment Expression is not allowed in for of head's expression position (#4810)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu
2021-10-29 09:52:30 +02:00
Csaba Osztrogonác 3c742bef57 Test262 runner shouldn't change newline characters (#4805)
It fixes the following test on Windows:
built-ins/Function/prototype/toString/line-terminator-normalisation-LF.js

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-10-28 13:56:52 +02:00
Zoltan Herczeg a024eb2118 Add allocate/free callbacks to ArrayBuffers (#4801)
Larger buffer allocations will throw error instead of calling jerry_fatal.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-28 13:51:34 +02:00
Robert Fancsik d2388e907f Implement CreateAsyncFromSyncIterator (#4802)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-10-28 12:45:47 +02:00
Csaba Osztrogonác dd77ec914a Fine-tune test262-esnext jobs on the CI (#4566)
Previously test262-esnext was separated to 2 jobs: language and other tests.
But now tests run in parallel and CI runs release and debug tests too,
separating jobs to release and debug mode is much more obvious. But
debug tests are still slow (~10-11 minutes), let's split only debug job.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-10-27 13:07:58 +02:00
Robert Fancsik 24c1a93d91 Remove block result (#4799)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-10-27 10:59:00 +02:00
Robert Sipka c6f9ea65ce Declaration in the head of a for-of loop can't have an initializer (#4804)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka robert.sipka@h-lab.eu

Co-authored-by: Robert Sipka <robert.sipka@h-lab.eu>
2021-10-27 09:51:14 +02:00
Péter Gál 499cdea75c Fix jerry_value_is_{true,false} documentation (#4803)
The API doc for jerry_value_is_{true,false} incorrectly stated
that it is a replacment for the `jerry_value_is_boolean` method.
The `jerry_value_is_true` is the direct replacement of the
`jerry_get_boolean_value` method and the "false" version is a new
method.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-10-26 09:43:51 +02:00
Csaba Osztrogonác 100b6f577e Test262 exludelist fix after #4721 (#4800)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-10-26 06:45:19 +02:00
ChrisPei 2a4fb19157 Add missing "jerryscript.h" include to esp-idf target (#4759)
JerryScript-DCO-1.0-Signed-off-by: ChrisPei spoppig5@gmail.com
2021-10-21 12:15:44 +02:00
Gergo Csizi 74f98ec4d7 Add Atomics support (#4721)
Creating atomics interface

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-10-20 15:50:12 +02:00
Gergo Csizi c446871214 Optimize lit_is_valid_utf8_string (#4762)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-10-20 15:45:47 +02:00
Péter Gál 4e8d6344a8 Force value conversion in case of TypedArray filter method (#4794)
During the execution of the TypedArray filter method it is possible
to have a different sized output TypedArray than the input one.
When copying the data to the output array the values must be
correctly converted to the output TypedArray's value range.

Fixes: #4793

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-10-20 15:40:52 +02:00
Péter Gál dae234f416 Correctly convert data in case of TypedArray slice (#4796)
When executin the TypedArray's slice method it is possible to have
the a different element sized output TypedArray. In such case
the data must be converted to the desired element type/size.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-10-20 15:40:33 +02:00
Péter Gál 4912e3b739 Avoid buffer-overflow in Array.slice when using fast arrays (#4797)
In the Array.slice method when the engine uses fast arrays the "end" value
was not updated if the input array's length changed. This can occur when the start/end
index normalization executes a method and the length is changed forcefully.
This leads to a buffer-overflow as the element copy reads too much data from the input
array.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-10-20 15:40:19 +02:00
Zoltan Herczeg b52c114423 Implement eval check for ECMAScript code (#4788)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-15 22:25:20 +02:00
Gergo Csizi fe3a5c08b2 Fix magic-string generation (#4751)
In some cases the magic-string generator creates conditions like: A || !A . These conditions can be simplified.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-10-15 19:09:04 +02:00
Zoltan Herczeg d4231e7251 Split main promise event filter into multiple filters (#4792)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-11 12:48:50 +02:00
Mate Dabis f6eac3afdc Add notes to jerry_create_undefined, jerry_create_null and jerry_create_boolean (#4790)
JerryScript-DCO-1.0-Signed-off-by: Mate Dabis mdabis@inf.u-szeged.hu
2021-10-11 11:07:55 +02:00
Zoltan Herczeg c696bc9327 Implement vm throw capture status management for API errors (#4783)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-07 11:35:49 +02:00
Zoltan Herczeg 7c21fb89b2 Reorder list of function built-in properties (#4791)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-07 09:52:07 +02:00
Zoltan Herczeg d98ff6fd30 Support getting script object in the backtrace callback. (#4789)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-06 11:09:01 +02:00
Csaba Osztrogonác 54b1a3c739 Date.prototype.setTime should invalidate local TZA cache (#4786)
Fixes #4749.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-10-01 12:59:38 +02:00
Csaba Osztrogonác f3cd586094 Fix leaking lastIndex values in RegExp built-ins (#4787)
Fixes #4781. This is a followup fix after #4166.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-10-01 12:56:53 +02:00
Zoltan Herczeg 7d355b0f8e Change error message description (#4785)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-10-01 12:24:20 +02:00
Zoltan Herczeg 2a82da62ad Implement source info retrieval API function (#4780)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-29 12:34:38 +02:00
Zoltan Herczeg 8b3eb93167 Add property key filters for general object property enumeration (#4778)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-28 11:01:15 +02:00
Zoltan Herczeg 14ff5bfb52 Add property key filters for built-in functions (#4776)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-23 14:21:47 +02:00
Zoltan Herczeg 35058cde31 Fix incorrect line info computation (#4775)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-22 12:35:24 +02:00
Zoltan Herczeg ca185acded Implement built-in flag support for arguments (#4774)
Duplicate check can be removed from property enumeration.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-22 11:33:13 +02:00
Zoltan Herczeg 053bfa0f9f Support resource name and user value for implicit class constructors (#4771)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-17 16:28:10 +02:00
Zoltan Herczeg 430289b27d Fix built-in types (#4772)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-17 08:18:28 +02:00
Zoltan Herczeg 77c2602205 Implement import.meta object (#4766)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-15 17:44:16 +02:00
Zoltan Herczeg 386ec44d4d Double the maximum number of object references (#4768)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-15 11:08:57 +02:00
Zoltan Herczeg d08b5be57f Remove built-in flag from object type (#4763)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-13 19:25:22 +02:00
Zoltan Herczeg 723b26392d Fix property enumeration order of built-in properties (#4761)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-13 15:32:14 +02:00
Zoltan Herczeg 2c2539c6b8 Throw SyntaxError when module resolving is failed (#4765)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-09 22:11:42 +02:00
Zoltan Herczeg fea10bb7e3 Add name to the function property names (#4760)
Furthermore prototype should be the first property.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-03 12:42:06 +02:00
Zoltan Herczeg 1523ca3b26 Fix prototype of the values returned by Promise.allSettled (#4758)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-03 12:15:06 +02:00
Zoltan Herczeg e1ce7dd727 Fix invalid typed array construction (#4757)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-02 12:13:00 +02:00
Zoltan Herczeg f94a3c80bd Fix line info computation (#4756)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-09-01 18:39:38 +02:00
Zoltan Herczeg 6649940ea6 Implement function.toString operation (#4752)
May increase the memory consumtpion heavily.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-31 13:37:25 +02:00
Péter Gál 1c6b18ecdf Add missing info in API doc (#4733)
As a few methods were removed and replaced it is a good idea to describe
which method(s) can reproduce the same functionality. In addition add a
bit of extra comments for various methods/structs.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-08-30 17:27:37 +02:00
batizdaniel bf049fbe2d Remove redundant checks from builtin-dispatchers (#4741)
We don't need to check arguments length inside the custom dispatchers,
because we have already checked within ecma_bultin_dispatch_routine.

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz batizjob@gmail.com
2021-08-30 14:13:31 +02:00
Zoltan Herczeg 8cbe1b59c1 Implement getter function for external string user pointer (#4742)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-30 14:04:13 +02:00
Péter Gál 4175037fb0 Disable IRC notification action to have a green master (#4753)
IRC notification GitHub action returns an error at the moment
and makes the master red (even if all builds passed).

Disable this action till we fix the notification.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-08-30 13:27:30 +02:00
Gergo Csizi b4fc591398 Add new test for resource_name (#4737)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-08-30 10:04:14 +02:00
Gergo Csizi 5a69b183c3 Rename jerry_string_set_external_string_free_callback (#4743)
jerry_string_set_external_string_free_callback -> jerry_string_set_external_free_callback

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-08-27 20:02:32 +02:00
Paul Sokolovsky be910b9867 targets: zephyr: Update for Zephyr 2.x (#4731)
targets: zephyr: Update for Zephyr 2.2

Zephyr 2.2 removed some deprecated compatibility headers, use the new
location.

targets: zephyr: Update for Zephyr 2.3

Rename CONFIG_FLOAT -> CONFIG_FPU based on the change done in Zephyr 2.3.

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org

targets: zephyr: Update CI and docs for Zephyr 2.6

And to the latest Zephyr SDK 0.13.0. arduino_101 board is no longer
supported by Zephyr 2.x, so replace it with qemu_x86 (i.e. QEMU
emulation target) in CI and with frdm_k64f in docs.

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2021-08-26 14:55:30 +02:00
batizdaniel 3bcd48f72d Improve parse_identifier (#4691)
Ascii string length is no longer computed during string allocation.

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz batizjob@gmail.com
2021-08-17 12:16:58 +02:00
Zoltan Herczeg e7ffb70ae0 Rework external string free operation (#4690)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-17 08:31:30 +02:00
Zoltan Herczeg 74e5ccd434 Improve storing the line info data during parsing (#4735)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-17 08:29:30 +02:00
Gergo Csizi fc29019165 Simplify jerry_get_resource_name (#4730)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-08-12 17:21:37 +02:00
Zoltan Herczeg 3ed93cfb51 Support parsing of scripts / functions stored in string values (#4728)
Function arguments must be passed as string values.
Snapshots are generated from compiled code rather than source code.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-11 17:37:12 +02:00
Gergo Csizi b7dead7b05 Add guards for SharedArrayBuffer (#4723)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-08-10 17:21:06 +02:00
batizdaniel a25b824509 Implement {Array, %TypedArray%, String}.prototype.at method (#4681)
The following methods were implemented:
- Array.prototype.at based on ECMA-262 Stage 3 Draft Relative Indexing Method proposal
- String.prototype.at based on ECMA-262 Stage 3 Draft Relative Indexing Method proposal
- TypedArray.prototype.at based on ECMA-262 Stage 3 Draft Relative Indexing Method proposal

https://tc39.es/proposal-relative-indexing-method/

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz batizjob@gmail.com
2021-08-10 17:19:25 +02:00
Zoltan Herczeg 444806d78a Implement vm_throw callback (#4726)
Slightly improve the description of vm_exec_stop callback.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-10 15:50:26 +02:00
Virag Orkenyi b6ec9275aa Add custom dispatcher to error-prototype (#4692)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-08-03 11:09:33 +02:00
Zoltan Herczeg c438d5fa92 Support string iterator for strings longer than 64K (#4727)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-08-03 10:44:19 +02:00
Tóth Béla f71a4a6975 Merge Promise Guard with ESNEXT (#4725)
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-08-02 17:35:32 +02:00
Zoltan Herczeg 951044c036 Change resource name to a string. (#4724)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-27 13:40:19 +02:00
Tóth Béla d99905aca6 Implement container operators API function (#4697)
Basically re-opening and updating #4275

Co-authored-by: bence gabor kis <kisbg@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu

Co-authored-by: bence gabor kis <kisbg@inf.u-szeged.hu>
2021-07-27 12:25:52 +02:00
Zoltan Herczeg d69fe41085 Improve garbage collection of scripts and modules (#4722)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-26 14:03:43 +02:00
Zoltan Herczeg d4178ae386 Support dynamic import calls (#4652)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-24 09:26:46 +02:00
Gergo Csizi d9360f51d0 Add SharedArrayBuffer support (#4689)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-07-23 17:29:06 +02:00
Virag Orkenyi bbf1c0105b Add custom dispatcher to builtin-json. (#4679)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:32:20 +02:00
Virag Orkenyi b25b640ff5 Add custom dispatcher to array-iterator-prototype (#4693)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:31:25 +02:00
Virag Orkenyi 298228abdd Add custom dispatcher to map-iterator-prototype (#4694)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:30:55 +02:00
Virag Orkenyi 57a09cbc9d Add custom dispatcher to async-iterator-prototype (#4714)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:30:13 +02:00
Virag Orkenyi d65d035a36 Add custom dispatcher to builtin-string-iterator-prototype (#4715)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:29:38 +02:00
Virag Orkenyi 6296a8251c Add custom dispatcher to builtin-iterator-prototype (#4716)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:29:10 +02:00
Virag Orkenyi 7de391931a Add custom dispatcher to set-iterator-prototype (#4717)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-07-20 11:28:30 +02:00
Zoltan Herczeg 713d90b5a0 Support shared user data for scripts (#4710)
The same data is returned for the script and all of its functions,
including those which are created by an eval call.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-20 10:33:23 +02:00
Zoltan Herczeg 9ff25dbc12 Replace jerry_load_function_snapshot function with a flag (#4719)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-16 16:09:51 +02:00
Zoltan Herczeg 252d68936f Improve line info construction (#4718)
- Simplify small encoding
- Better line info for some corner cases

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-16 16:08:38 +02:00
Péter Gál d5a7839632 Improve Proxy recrusion check in their internal methods. (#4568)
In some parts of Proxy internal methods the compiler can do a bit of
tail call optimalization which would be ok, but the current stack limit
check framework in Jerry uses the stack pointer to calculate the stack depth.
This way of stack depth calculation is affected by the tail call optimalization
(as the stack does not increase).

By disabling the tail call optimalization at given points the stack limit calculation
will work as expected. This causes a bit of stack overhead, but the Proxy in it self
is a fairly big chunk of code and this stack limit would only be relevant if the Proxy
already does recusion which already very edge case.

The stack limit (--stack-limit=..) should be enabled to correctly report such stack
depth errors.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-07-15 14:02:53 +02:00
Zoltan Herczeg 998e49a969 Rework storing the line/column/bytecode info (#4707)
This information is stored in a separate memory block instead
of being part of the byte code. Snapshot does not supported.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-15 13:45:10 +02:00
Zoltan Herczeg 4be05a74eb Remove ecma_parse_options_t in favor of jerry_parse_options_t (#4713)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-15 13:44:52 +02:00
Tóth Béla 305741a608 Merge Map and Set Guards with Container (#4709)
Remove JERRY_BUILTIN_MAP/SET/WEAKMAP/WEAKSET
and replace them with JERRY_BUILTIN_CONTAINER.

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-07-12 11:20:38 +02:00
Zoltan Herczeg 7f6a699700 Implement namespace exports in modules (#4708)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-09 07:23:28 +02:00
Jiawen Geng e3a299b3d6 Add clang build to CI (#4706)
A follow up to https://github.com/jerryscript-project/jerryscript/pull/4684

JerryScript-DCO-1.0-Signed-off-by: Jiawen Geng technicalcute@gmail.com
2021-07-06 17:58:19 +02:00
Zoltan Herczeg d1204ab1c9 Rework resolving references and namespace creation in modules (#4695)
- Properties of namespace objects are ordered in lexical order
- The namespace object is created and imports are bound during linking phase
- Namespace imports are changed to read-only
- Reduced memory consumption

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-07-06 14:50:19 +02:00
Tóth Béla ccc152594a Fix failing container unit-test (#4696)
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-06-28 15:46:03 +02:00
Virag Orkenyi 811fd4c054 Add custom dispatcher to builtin_string (#4661)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-06-24 15:40:48 +02:00
Gergo Csizi 8f71871a39 Remove jerry_get_boolean_value (#4685)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-06-24 15:40:14 +02:00
batizdaniel 6de17b204e Fix implicit conversion error (#4684)
This patch fixes the #4682

JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz batizjob@gmail.com
2021-06-24 15:38:56 +02:00
Virag Orkenyi d97d407eee Add custom dispatcher to builtin_weakref_prototype. (#4686)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-06-24 15:36:47 +02:00
Virag Orkenyi dddd37d38f Add custom dispatcher to builtin-proxy (#4687)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-06-24 15:36:25 +02:00
Tóth Béla 9471515dae Add container related API function (#4666)
The new function returns with an array, containing the
elements of the given Container or Container iterator.

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-06-16 07:41:13 +02:00
Zoltan Herczeg 5729dd8cec Object.assign should copy undefined values (#4688)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-06-10 10:59:54 +02:00
Gergo Csizi e8ed543677 Add test_dataview (#4677)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-05-31 14:24:38 +02:00
csdkamikaze 703ddae194 Typo fix in 02.API-REFERENCE.md (#4680)
JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz batizjob@gmail.com

Co-authored-by: Daniel Batiz <batizjob@gmail.com>
2021-05-26 14:37:22 +02:00
Gergo Csizi ce5e4d49b1 Fix documentation and add back some tests (#4673)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-05-26 12:28:32 +02:00
Jiawen Geng 7be339ad61 Fix typo in property hashmap define (#4664)
Fixes jerryscript-project/jerryscript#4648

JerryScript-DCO-1.0-Signed-off-by: Jiawen Geng technicalcute@gmail.com
2021-05-26 12:26:11 +02:00
Gergo Csizi 800031c62b Change jerry_get_own_property_descriptor return type (#4675)
JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi csgergo92@gmail.com
2021-05-26 06:54:26 +02:00
Zoltan Herczeg 431a28b902 Fix native error check (#4674)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-05-21 12:36:07 +02:00
Zoltan Herczeg 3c512d937b Add getter for Proxy handler objects (#4676)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-05-21 12:35:53 +02:00
Zoltan Herczeg 67a61bc211 Support this binding retrieval for backtrace frames (#4669)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-05-17 11:41:29 +02:00
Philippe Coval a67f198134 build: Support cmake -DPYTHON=python3 (#4667)
This will help debian packaging of iotjs

JerryScript-DCO-1.0-Signed-off-by: Philippe Coval rzr@users.sf.net
2021-05-17 11:37:09 +02:00
Zoltan Herczeg 5180680030 Support line info for class fields (#4670)
Furthermore fix function info for call frames.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-05-17 11:15:02 +02:00
Zoltan Herczeg 26f604ce1e Change error message format of DefineProperty (#4672)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-05-17 11:14:38 +02:00
Zoltan Herczeg e042998f02 Support function object retrieval for async functions (#4668)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-05-11 12:22:37 +02:00
kisbg a58884c169 Update TypedArray internals methods (#4653)
releated test262 test-cases has been removed from the skip list.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-04-27 09:45:26 +02:00
Zoltan Herczeg 823a8b128d Fix error throw in jerry_define_own_property (#4662)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-27 09:42:20 +02:00
Zoltan Herczeg 8aaabd8b01 Do not mark the unused items of a WeakMap (#4663)
The new method is slower, but correctly release unused objects.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-27 09:42:03 +02:00
kisbg ce24edae24 Add check Proxy object [[SetPrototypeOf]] (#4631)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-04-26 09:21:29 +02:00
Zoltan Herczeg b4bea25f13 Export assignment expression must not track variables (#4660)
Only export the result of the assignment expression. This value cannot be changed later.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-21 08:56:50 +02:00
Zoltan Herczeg dead11cdd0 Fix external pointer allocation issues. (#4658)
The allocations during the update of external pointers may trigger
the GC. Due to a new feature, the GC uses the external pointer data
to mark objects, which caused crashes in some cases.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-20 11:53:58 +02:00
Zoltan Herczeg 10002aef60 Throw ReferenceError when a property of a native module is not found (#4659)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-20 11:04:26 +02:00
Zoltan Herczeg 4f15332e95 Export default in namespace object (#4657)
Fix a crash when the exported value is a reference.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-19 18:31:59 +02:00
Zoltan Herczeg ec3ed65b56 Add reference support for native pointers. (#4615)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-19 14:47:17 +02:00
Tóth Béla cc1a263657 Continue replacing duplicate ecma definitions (#4644)
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-04-19 13:44:01 +02:00
Zoltan Herczeg 1f2a8d4ac1 Add notification callback for module state changes (#4656)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-16 17:50:57 +02:00
Zoltan Herczeg a7a4cb29e4 Native modules should be unlinked state after creation (#4655)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-16 15:55:12 +02:00
Zoltan Herczeg 7b6743403f Support native modules (#4649)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-13 16:26:38 +02:00
Zoltan Herczeg 05a4e45ece Fix uninitialized data in create native property (#4650)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-13 15:17:25 +02:00
kisbg 60cbc93cd7 Update TypedArray Builtin function (#4633)
Also create TypedArray object with object method has been added.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-04-13 13:37:04 +02:00
Zoltan Herczeg 053389de80 Add info to external pointer free callback. (#4642)
Furthermore reduce memory consumption when only
one external pointer is assigned to an object.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-13 09:51:39 +02:00
Zoltan Herczeg b3ec217b50 Create namespace with references for modules (#4646)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-12 15:58:56 +02:00
Zoltan Herczeg ef35c0329c Remove class id storing for class objects (#4645)
The two bytes which stored the id is free to use. Currently the only exception is containers.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-08 14:46:16 +02:00
kisbg 2381078e80 Add constant error messages (#4640)
added two new file ecma-errors.h and ecma-erros.c

it contains the most used errors messages.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-04-07 12:46:12 +02:00
Zoltan Herczeg d85020f709 Remove pseudo array object type from the project (#4643)
A new class type enum is introduced to describe the class of objects.
This enum is organized to improve property resolve and GC performance.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-04-06 18:46:48 +02:00
Zoltan Herczeg 4377ef684d Add module C API functions (#4636)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-31 19:40:58 +02:00
Tóth Béla 6677fa0a12 Replace duplicate ecma definitions (#4637)
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-03-31 11:52:33 +02:00
Zoltan Herczeg 6c484f3529 Rework module linking (#4632)
The module linking process from jerry_parse is moved out into
a new jerry_module_link function, and jerry_parse is limited to
create unlinked modules.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-30 15:40:09 +02:00
Zoltan Herczeg 874a6a49d5 Extract type defintions from jerryscript-core.h into jerryscript-types.h (#4634)
The function declarations in jerryscript-core.h should not be visible
internally, only the type declarations in jerryscript-types.h

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-24 05:51:59 +01:00
kisbg 22ebb00a4c Implement Promise.any and AggregateError Object (#4623)
JerryScript-DCO-1.0-Signed-off-by: Bence Gabor Kis kisbg@inf.u-szeged.hu
2021-03-22 12:42:20 +01:00
Zoltan Herczeg edd2f20397 Remove jerry_port_track_promise_rejection (#4613)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-11 19:58:44 +01:00
Zoltan Herczeg e739f11ed2 Return early when checking logical operators (#4626)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-11 19:35:39 +01:00
kisbg 8321640c4e Remove unnecessary ecma_deref_ecma_string in regExpStringIterator (#4625)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-03-11 09:14:45 +01:00
Zoltan Herczeg 546422161e Add custom configuration to jerry_parse and its variants (#4620)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-10 09:56:48 +01:00
Zoltan Herczeg 7a2665621b Reorganize property descriptor flags (#4622)
Furthermore rename JERRY_PROP_IS_THROW to JERRY_PROP_SHOULD_THROW
and add more invalid descriptor checks.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-10 08:17:20 +01:00
kisbg dc3ae4ff06 Implement Promise.allsettled (#4616)
Also i updated the promise race and all method to the latest standart

The two jerry/es.next test-cases has been update to support the latest standart

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-03-08 11:43:42 +01:00
Peter Marki 96cd542bf5 Refactor jerry_property_descriptor_t to use status flags (#4594)
JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2021-03-08 09:08:24 +01:00
kisbg 9254cd4e7a Add ThrowTypeError name property (#4618)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-03-05 10:40:17 +01:00
Zoltan Herczeg 29b7c8f8ff Implement jerry_get_own_property API function (#4612)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-03 18:02:40 +01:00
Zoltan Herczeg a95e3e37e1 Add more skip check options for Proxy objects (#4614)
Reorganize the flags to follow the list in ES2020 section 9.5

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-03-03 17:12:36 +01:00
kisbg 129ca4946c Implement WeakRef Object (#4546)
Related test262 test-cases has been removed from skip list.
Execpt two test-case since they need other feature to work (Finalization registry and async GC)

JerryScript-DCO-1.0-Signed-off-by: Bence Gabor Kis kisbg@inf.u-szeged.hu
2021-03-01 13:46:54 +01:00
Péter Gál 9556701742 Add size checks before using JERRY_VLA in unittests (#4601)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-02-26 10:53:54 +01:00
Zoltan Herczeg 17ed855df5 Default handlers should count as resolvers (#4611)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-25 12:27:21 +01:00
Zoltan Herczeg c27047da03 Add filters and more events to Promise callback. (#4605)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-24 10:31:08 +01:00
Robert Fancsik f0f2a28109 Improve ecma_reject to give more detailed error messages (#4565)
Note: TypedArray.[[DefineOwnProperty]] has been slightly reworked (without semantical changes) for better error messages.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-24 09:36:55 +01:00
Péter Gál 1623c8db1e Limit the string size in jerry_port_track_promise_rejection (#4603)
The maximum Promise reject reason string is now limited to a 5 kib string.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-02-24 09:14:14 +01:00
Zoltan Herczeg a3bdd36556 Reduce memory consumption of Promise objects (#4607)
No need to keep a reference to resolver functions.
Unused resolvers are cleaned up sooner by GC.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-24 08:51:23 +01:00
Zoltan Herczeg 1cf2989a64 Add new.target argument to Promise create (#4606)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-24 08:50:05 +01:00
Zoltan Herczeg 5c35370327 Create special objects for scripts instead of functions (#4610)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-23 15:34:09 +01:00
Robert Fancsik 322265bfb9 Move push literal number opcodes to basic opcodes (#4609)
`obj[number]` is a widely used structure especially for array element indexing, however super property assignment is not.
This patch moves super-assignment opcodes to ext opcodes and fills the freed 3 basic opcodes with push-literal-number ones.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-02-23 10:00:00 +01:00
Dániel Bátyai 2240a9153a Optimize the copying/freeing of ecma values (#4602)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2021-02-22 08:32:10 +01:00
Dániel Bátyai 242c3a55e3 Always run all checks regardless of the previous job result (#4604)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2021-02-18 19:40:21 +01:00
Zoltan Herczeg 01e0388d77 Add notification callback for Promise operations (#4595)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-18 11:29:52 +01:00
Robert Fancsik c14702c129 Keep GNU fastpath for jerry_port_get_local_time_zone_adjustment (#4600)
PR #4513 caused a measurable slowdown by removing the GNU specific TZA calculation.
This patch reverts this removal but also keeps the general implementation introduced in #4513

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-02-17 20:44:00 +01:00
Zoltan Herczeg 112ad83aaa Rework external function handlers (#4599)
Instead of a fixed number of arguments, a call info structure is passed
to the handlers, which can be extended in the future without breaknig the
API. This structure holds new.target value, so its getter function is removed.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-17 17:52:19 +01:00
Robert Fancsik 488a0bf7e8 Improve date internals (#4593)
- Optimize year from time calculation
- Force arithmetic operations to int32_t/int64_t whenever possible
- Optimize number conversion in date parse
- Cache local TZA of the date object
- Fix a bug in Date.parse timezone parsing

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-02-17 16:07:54 +01:00
Virag Orkenyi 67e7e89c8e Implement BigInt.prototype.toLocaleString (#4355)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-02-17 14:20:44 +01:00
Yonggang Luo 3afb007123 Optimize bit operation in vm.c (#4591)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-16 13:17:21 +01:00
kisbg a2f22cf888 Update jerry debugger test-runner (#4597)
Now the test-runner will check the jerry (server) return code.

Fixed do_eval_at TC crash if jerry was build with --debug option.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-02-16 12:48:40 +01:00
Péter Gál a95a0b3539 Use C99 flexible array member notation in parser memory struct (#4592)
The usage of a single byte sized array as a flexible array member can lead to
compiler/analyzer errors or warnings. Not specifying the size in the array is
correct as per C99 standard.

Flexible array members are defined in the C Standard, 6.7.2.1 (ISO/IEC 9899:1999).

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-02-11 14:18:35 +01:00
Peter Marki a9c83020df Fix failing Date tests in test262-esnext (#4561)
JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2021-02-11 14:01:58 +01:00
Yonggang Luo 34a6a93597 Fix indent in documentation of cmake options (#4588)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-10 10:45:29 +01:00
Yonggang Luo 2a6917b5a5 Fix documentation of cmake options (#4587)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-10 01:31:27 +01:00
Yonggang Luo 3df7998084 --engine parameter should be a file (#4585)
The --test262-object option should be passed independently,
otherwise os.path.dirname(args.engine) in tools\runners\run-test-suite-test262.py
makes no sense

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-09 19:02:26 +01:00
Yonggang Luo 818cc8ddab Split globalThis to be configurable. (#4575)
JERRY_BUILTIN_GLOBAL_THIS can be enabled without JERRY_ESNEXT

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-09 16:20:05 +01:00
Yonggang Luo f7c817efcf Take care of year before 1601 on win32. (#4580)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-09 15:23:28 +01:00
Zoltan Herczeg ec872818c2 Add implementation specific date parsing (#4576)
It is compatible with Firefox and Chrome.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-09 15:03:06 +01:00
Zoltan Herczeg 53aed02762 Fix null getters/setters in jerry_property_descriptor_from_ecma (#4573)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-09 15:01:50 +01:00
Zoltan Herczeg 6fd0dfec35 Fix template memory leak when debugger is running (#4572)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-09 14:59:45 +01:00
Yonggang Luo c2e016ec06 Add space between JERRY_ATTR_PURE and type (#4583)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-09 09:45:08 +01:00
Yonggang Luo 75b0378bc5 Move static before inline. (#4582)
Make this consistence with other static inline definition.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-09 09:43:43 +01:00
kisbg 76a0b18287 Add cross-realm support to RegExp.prototype (#4567)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-02-08 16:35:40 +01:00
Tóth Béla 35ecf4c4a3 Fix "Invalid prefix operation" errors (#4577)
`--(-a);` returned with a postfix error before this patch.
The changes introduce a new warning for prefix errors, and
returns with the corresponding one based on current opcode.

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-02-08 16:13:37 +01:00
Zoltan Herczeg b1f73e698a Fix deleting native pointers (#4570)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-05 19:35:30 +01:00
Péter Gál ca6c2194bb Fix incorrect assert expression in lexer_check_property_modifier (#4569)
In the lexer_check_property_modifier the assert incorrectly does
an assignment instead of a simple equals check.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-02-05 11:24:29 +01:00
Robert Fancsik 0628ae1e7b Remove the ENABLED/DISABLED macros (#4515)
The removal of these macros enabled cppcheck to reveal new errors.
These errors are also fixed by the patch.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-04 23:47:05 +01:00
Yonggang Luo e01c2549d7 Add --build-debug options for run-tests.py script. (#4456)
This makes have option to running test262-es2015 and test262-esnext with debug version
of jerryscript.
On OSX, the $RUNNER -q --jerry-tests are in dead loop, disable it first.

Increase TEST262_CASE_TIMEOUT to 180, so that --build-debug can pass the tests
without timeout
An side effect of this are
```
  <test id="built-ins/decodeURIComponent/S15.1.3.2_A2.5_T1.js"><reason></reason></test>
  <test id="built-ins/decodeURI/S15.1.3.1_A2.5_T1.js"><reason></reason></test>
```
passed

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 18:25:14 +01:00
Zoltan Herczeg 3623ac789d Introduce generic backtrace capturing (#4555)
Remove jerry_get_backtrace_from function

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-04 16:33:59 +01:00
Robert Fancsik feb2855f0c Fix cleanup in VM_OC_INITIALIZER_PUSH_PROP on abrupt completion (#4564)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-04 16:05:56 +01:00
Zoltan Herczeg 9ca046b670 Add non-standard behaviour support for Proxies (#4562)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-02-04 15:58:16 +01:00
kisbg e9df2ca814 Add newtarget support AsyncFunction (#4560)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-02-04 14:30:11 +01:00
Yonggang Luo dd698f8d83 logging the crash properly when running test262-harness.py (#4472)
When running tests262 cases, the jerry program may exit with error code other than 1,
that's means a crash or JERRY_ASSERT triggered and should be resolved, so dump the test
name and stderr/stdout for tracking those crash in CI.

related issue: #4463

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 13:28:54 +01:00
Yonggang Luo 4bb9e2b878 Move get_platform_cmd_prefix into util.py (#4495)
get_platform_cmd_prefix implement multiple times in multiple function.
Also add function get_python_cmd_prefix, call to python script always
add python command so that on windows, the python script doesn't have
executable permission also can be called.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 13:23:57 +01:00
Yonggang Luo 9db4ec7d77 Disable conversion warning on win32/gnu-mingw (#4516)
It's a mingw-runtime issue, but we disable conversion warning on win32/gnu-mingw
for getting jerryscript compile with mingw first.
The bug url are: https://sourceforge.net/p/mingw-w64/bugs/874/

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 13:23:45 +01:00
Yonggang Luo aa941ed58e Fixes math library compiling on msvc (#4511)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 13:19:13 +01:00
Yonggang Luo 9dbb594170 Make install_jerry work with MinGW (#4517)
On windows, the generator can be Visual Studio or Ninja, when targeting mingw,
the generator can be Ninja or Makefile, they both use 'install' instead MSVC 'INSTALL',
so check the solution file for MSVC

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 13:15:07 +01:00
Yonggang Luo 982cd08083 Rename unix to jerry for entrance files. (#4536)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-02-04 13:13:57 +01:00
Robert Fancsik e7d11eaf9e Improve destructuring patterns (#4527)
- Fix evaluation order of the operands
- Implement proper iterator closing of array destructuring
- Support next method caching

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-04 13:11:11 +01:00
Robert Fancsik 3bb67397a0 Fix lexical declaration check for let variables (#4529)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-04 13:07:38 +01:00
Robert Fancsik a1b682a83d Fix literal index decoding for CBC_MOV_IDENT (#4539)
This patch fixes #4532.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-04 13:01:14 +01:00
Robert Fancsik f369c84c24 Ensure that [[Set]] operation does not reject for TypedArray objects (#4558)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-04 13:00:24 +01:00
Péter Gál d7843be2e8 Add unittest to check realm object and realm this types (#4548)
Make sure that realm object and realm this types are tested.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-02-04 11:19:05 +01:00
Péter Gál dd0b00fdad Add missing tests for realm object type via jerry_object_get_type (#4552)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-02-04 10:39:05 +01:00
Robert Fancsik c82f184f00 Ensure that fast arrays length property is always writable (#4559)
Also remove legacy `ecma_array_object_set_length_flags_t`.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-03 19:12:15 +01:00
Robert Fancsik 1712ad5dc4 Ensure that fast array objects are always extensible (#4557)
This patch helps to eliminate some extra checks from Array.prototype methods

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-02-03 16:17:50 +01:00
Peter Marki 090b6307a6 Fix failing AsyncFunction tests in test262-esnext (#4545)
JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2021-02-02 12:35:58 +01:00
kisbg 748e1be041 Minor fix in create ArrayBuffer object (#4556)
JerryScript-DCO-1.0-Signed-off-by: Bence Gabor Kis kisbg@inf.u-szeged.hu
2021-02-01 16:49:12 +01:00
Zoltan Herczeg e191a5cf47 Increase the maximum reference count of objects when cpointer 32 is enabled (#4550)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-29 14:45:27 +01:00
Péter Gál 62dc782e5c Extend jerry_create_realm API docs a bit (#4549)
Add additional information for jerry_create_realm method and rework the
example to be a compilable/runnable doctest.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-29 13:15:37 +01:00
Akos Kiss 87d30b8088 Refactoring time-related default port implementations (#4513)
In the non-Windows code paths:
- New approach to compute TZA without the need for GNU-specific
  `struct tm.tm_gmtoff`.
- Always using `usleep` to sleep. (No real need for `nanosleep` as
  port API has sleep granularity of milliseconds.)
- Not checking for "time.h" at build configuration time as that
  header is mandated by the C standard.
- Not checking for "unistd.h" at build configuration time as that
  header is mandated by the POSIX standard (the default port is
  targeting POSIX systems -- and Windows).
- Fixing some macro guards.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-29 10:45:46 +01:00
Zoltan Herczeg ba06d492a3 Remove full stop after error messages (#4524)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-28 12:10:13 +01:00
Csaba Osztrogonác e081cbc2f0 Remove a wrong test not to slow down test262-es2015 (#4542)
Since ES2018 iterator's next method is called once during the prologue of iteration,
rather than during each step. The test is incorrect and stuck in an infinite loop.
https://github.com/tc39/test262/pull/1248 fixed the test and it passes on test262-esnext.

Removing test/language/statements/for-of/iterator-next-reference.js from test262-es2015
is necessary, because it won't pass ever and only slow down testing.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-01-26 18:29:56 +01:00
Zoltan Herczeg b5bf97c657 Stop after the first matching property in the prototype chain (#4543)
If multiple properties with the same name is in the
prototype chain, only the first one should be inspected

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-26 14:57:10 +01:00
kisbg ff1a99b999 Date.prototype.setTime should return with clipped date (#4520)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-01-26 11:00:45 +01:00
Péter Gál 0e21c17080 Add missing version info to API docs (#4541)
A few new methods did not have the version info to describe
in which version were they introduced.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-25 15:59:00 +01:00
Virag Orkenyi b8a0ffd913 Fix the number_tobigint conversion problem (#4519)
JerryScript-DCO-1.0-Signed-off-by: Orkenyi Virag orkvi@inf.u-szeged.hu
2021-01-25 11:54:55 +01:00
Yonggang Luo 8be6aec50d Fix Clang compilation error when comparing double with int64_t (#4531)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-23 13:38:22 +01:00
Yonggang Luo 1db0905889 Fix MinGW compilation errors in jerry-ext (#4510)
MinGW also needs linking to ws2_32.
Defining socket types for unix/win32 for compatibility.
Also fixes #4512

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-22 17:54:36 +01:00
Csaba Osztrogonác 9900cacb15 Fix test262 harness to handle async negative tests properly (#4526)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-01-22 15:09:16 +01:00
Péter Gál 8ba0d1b6ee Update profile README file (#4523)
Add previously missed new defines to the documentation and update the
defines to be in lexicographical order.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-22 10:27:57 +01:00
Zoltan Herczeg d646cf51ee Set the correct realm when global code is running (#4522)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-22 09:17:38 +01:00
Robert Fancsik bf7fa39581 Rework export default parsing (#4505)
- Remove SCANNER_LITERAL_POOL_DEFAULT_CLASS_NAME workaround
- Add async and generator function support
- Fix auto semicolon insertion after export statement
- fixes #4150.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-19 16:30:41 +01:00
Robert Fancsik 3e548401fd Invalid regexp literals should throw syntax error in ES11 (#4506)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-19 16:20:23 +01:00
Yonggang Luo d97540e883 Add expm1 test case to cover the k==1024 case (#4508)
-7.095e+02 won't trigger the  k==1024 case, so we didn't add it into the test list

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-18 23:23:57 +01:00
Yonggang Luo cb85797ab5 Fix comment in log1p.c (#4507)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-18 21:26:21 +01:00
Dániel Bátyai 8e83638daa Update the name handling of anonymous functions to ES11 (#4279)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2021-01-18 18:20:24 +01:00
Szilagyi Adam 6ec4455111 Implement Symbol.matchAll (#4082)
The following methods were implemented:
- String.prototype.matchAll based on ECMA-262 v11, 21.1.3.12
- RegExp.prototype[@@matchAll] based on ECMA-262 v11, 21.2.5.8
- RegExp String Iterator Object based on 21.2.7

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2021-01-18 18:08:35 +01:00
Akos Kiss 1d42d17ab6 Make all dynamic memory allocations via core API functions in jerry-ext (#4480)
Direct calls to `malloc` and `free` should be avoided,
`jerry_heap_alloc` and `jerry_heap_free` should be used in their
place. Build-time configuration should decide whether those calls
manage dynamic memory on the engine's heap or on the system heap.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-18 18:07:07 +01:00
Péter Gál b313824228 Update API docs for 2.4 release (#4504)
Replace the [[NEXT_VERSION]] entries with the exact version number
in the API reference documentation.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-18 18:01:10 +01:00
Robert Fancsik 2ade072e53 Optimize lexenv binding creation (#4502)
- Declarative environment no longer need to lookup the created binding for setting it's value
- Unfold vm_decl_var and vm_set_var into vm_loop to reduce error checks
- Reduce code duplication in ecma_module_connect_imports
- Fix deleted binding setting in `ecma_op_set_mutable_binding` (fixes #4468)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-18 17:38:54 +01:00
Zoltan Herczeg 3b77117a2e Add a callback which is called when Error objects are created (#4465)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-18 16:56:38 +01:00
Robert Fancsik e00964176d compile_commands.json should be generated for the whole project (#4503)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-18 16:15:40 +01:00
Dániel Bátyai 0fec9135ec Rework module parsing and execution (#4462)
This patch disables automatic detection of module code, and instead
requires the user to explicitly specify whether to parse a source
as a module or as a script.

To achieve this the jerry_parse API function now takes a new option
which signals that the source should be parsed as a module.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2021-01-18 15:33:43 +01:00
Akos Kiss ef8a6a9f39 Get isfinite, isinf, and isnan right in jerry-math (#4497)
- `finite` is not C99 but a BSD fp classification function, so it
  is removed.
- The standard specifies that `isnan` is a macro (just like
  `isfinite` and `isinf`), so the `isnan` function implementation
  is removed.
- `isfinite` incorrectly classified NAN as finite, which is fixed.
- `isinf` returned 1 for negative infinity. This is not a bug
  according to the standard, but is not aligned with recent glibc,
  which returns -1. This is changed to simplify testing.
- Added test cases for `isfinite` and `isinf` to the unit test of
  jerry-math.
- Added a new pass to unittests to ensure that jerry-math is
  tested.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-18 15:07:25 +01:00
Robert Fancsik c4676a21fe Introduce jerry_port_track_promise_rejection (#4451)
This patch resolves #2931.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-18 14:59:42 +01:00
Robert Fancsik 79a2392b79 Remove template array flag from arrays after the collection is freed (#4500)
This patch fixes #4469.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-18 12:10:49 +01:00
Yonggang Luo 90d206dcee Fix free of NULL value in function ecma_typedarray_helper_dispatch_construct (#4473)
Currently, ecma_op_get_prototype_from_constructor may return NULL
and the function didn't raise that exception.
Also optimize multiple assignment of prototype_obj_p and
multiple access of JERRY_CONTEXT (current_new_target) out.

This fixes https://github.com/jerryscript-project/jerryscript/issues/4463

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-18 10:35:47 +01:00
Yonggang Luo f894a8fad5 Fixes module-resource-name.js on win32. (#4481)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-18 10:32:48 +01:00
Yonggang Luo ccf511a544 new_target_object -> new_target_object_p (#4498)
Depends on https://github.com/jerryscript-project/jerryscript/pull/4478

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-18 10:25:14 +01:00
Yonggang Luo 69ce755593 Add ${PYTHON_EXECUTABLE} for "Generating doctests" (#4496)
On win32, the ${PYTHON_EXECUTABLE} should be specified, otherwise the python script
can not be executed properly.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-17 20:39:21 +01:00
Akos Kiss 9bc0f2fd3f Unify asserts in jerry-ext (#4488)
Some components of the jerry-ext library re-declared their own
assert and/or static assert macros. No need to re-invent the wheel
all the time. This patch makes all components use the assert macros
defined in jext-common.h. This also makes maintenance easier.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-17 15:21:46 +01:00
Yonggang Luo 11894a6032 current_new_target -> current_new_target_p (#4478)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-17 14:53:25 +01:00
Yonggang Luo f2e9062cfc Fixes timezone get on win32 (#4494)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-17 14:13:19 +01:00
Yonggang Luo 2bad20abf8 Fix the test262 timeout on Windows (#4378)
Use the platform independent python threading.Timer instead of the unix only timeout tool.

The timeout error are like the following things:

```
C:\Users\lygstate>timeout -version
Error: The specified timeout (/T) value is invalid. The valid range is from -1 to 99999 seconds.

C:\Users\lygstate>timeout 0 python
Error: invalid syntax. The default option does not allow more than '1' times.
Type "TIMEOUT /?" to learn how to use it.
```

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-16 21:41:28 +01:00
Akos Kiss 1fe7c3531a Sort source and header lists in cmake files (#4487)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-16 21:39:18 +01:00
Yonggang Luo abaf9637d7 Use approxEq to judge double compare in math-cbrt.js (#4483)
Number.EPSILON used as maximal differences.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-16 21:25:41 +01:00
Yonggang Luo 3ce4dce805 Use _WIN32 instead WIN32. (#4484)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-16 21:22:28 +01:00
Yonggang Luo fe3b0a8435 Fixes ENABLE_AMALGAM need FORCE set to ON when building with MSVC (#4392)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-16 16:44:55 +01:00
Yonggang Luo fd0ca7da69 exclude test-ext-autorelease.c in SOURCE_UNIT_TEST_EXT_MODULES properly (#4485)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-16 16:33:48 +01:00
Péter Gál 5e483633f3 Fix prototype chain traversing (#4458)
After the introduction of the Proxy builtin object there was
a possibility to traverse the prototype chain with an invalid object.
The prototype was freed before it's data/properties were queried resulting
in accessing invalid information.

By forcing the allocator to always do a gc (`--mem-stres-test=on` build option)
it was possible to trigger the issue without complicated tests.

New internal method:
* `ecma_op_object_get_prototype_of` which always returns the prototype
  of an object and the return value must be freed (if it is valid).

Updated prototype chain traversing in:
* `jerry_object_get_property_names`
* `ecma_builtin_object_prototype_lookup_getter_setter`
* `ecma_op_function_has_instance`
* `ecma_op_function_get_super_constructor`
* `ecma_op_object_is_prototype_of`
* `ecma_op_object_enumerate`

Removed method `ecma_proxy_object_prototype_to_cp`

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-15 20:54:09 +01:00
Péter Gál abedab5ac2 Fix objects foreach unittest in case of mem-stress-test (#4460)
When the mem-stress-test is enabled for the objects foreach unittest
the object counting is off by one. This was due to incorrect assumption
on when the gc is triggered.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-15 20:50:26 +01:00
Robert Fancsik ad7fc07ca4 Add missing error check for for-in HasNext check (#4471)
This patch fixes #4464.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-15 20:48:49 +01:00
Péter Gál b0ca537a34 Correctly release values in Proxy.[[Get]] (#4477)
In Proxy.[[Get]] if the target.[[GetOwnPropertyDescriptor]] fails the
trap result should be freed.

Fixes: #4466

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-15 20:48:13 +01:00
Yonggang Luo 9ce7e49073 rename misspell regression tests file name. (#4479)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2021-01-15 20:46:57 +01:00
Robert Fancsik aefd381cf1 Rename 'this' to 'this_arg' in function arguments (#4476)
'this' is a restricted keyword in C++ so it's a good practice to avoid it's usage as an identifier.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-15 18:24:25 +01:00
Tóth Béla 91baa17c51 Update TypedArray builtins to latest standard (#4210)
- Introduce `ecma_typedarray_species_create` and `ecma_typedarray_create`
- Update Typedarray's filter method

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2021-01-15 15:21:50 +01:00
Robert Fancsik b46535cb8d Add strict flag check for ecma_op_object_put_apply_receiver (#4450)
This patch fixes #4441.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-15 14:11:47 +01:00
Robert Fancsik 363bc92529 Remove new target workaround from super call (#4447)
After #4372 and #4369 all builtin constructors have new target support.

This patch fixes #4446.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-15 13:28:59 +01:00
Szilagyi Adam df6d430289 Refactor ecma_builtin_global_object_unescape (#4115)
based on ECMA-262 v11, B.2.1.2

Fixed tests from the exclude list:
* annexB/built-ins/unescape/four-ignore-bad-u.js
* annexB/built-ins/unescape/four.js
* annexB/built-ins/unescape/two.js

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2021-01-14 16:16:32 +01:00
Akos Kiss 4541524256 Drop -fno-... compiler flags from CMakeLists (#4457)
- `-fno-builtin` should not be necessary: a) by default, we assume
  that a libc exists on the system the project is compiled for, but
  b) even if the assumption does not hold, `-fno-builtin` can be
  passed as an external CFLAG to the build system, plus c) the use
  of builtins is expected to help both code size and performance.
  (Except when jerry-math is enabled.)
- `-fno-stack-protector` should not be necessary: it is the default
  not to instrument code with stack protection.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-14 10:31:59 +01:00
Péter Gál 75586242ba Fix error instance query if the error is from a Proxy (#4459)
When accessing an error's type there is no need to check the Proxy
prototype (as there is none).

Fixes: #4440

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-13 15:14:04 +01:00
Zoltan Herczeg 3dc6ed0dd5 Fix internal property listing in ecma_op_object_own_property_keys (#4461)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-13 15:13:43 +01:00
Csaba Osztrogonác c84afefd47 Fix the build and timezone offset with MinGW (#4449)
Changes:
- Use _WIN32 macro instead of _WINDOWS
- Fix build error - "no previous declaration for 'UnixTimeToFileTime'"
- Fix conversion build errors
- Remove useless _tzset() call
- Use GetSystemTimeAsFileTime() on Windows to get current time
- Unify and simplify time conversion Windows helper functions

Fixes #4240

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-01-13 11:39:16 +01:00
Zoltan Herczeg 3193e6d0dc Implement jerry_get_backtrace_from API function (#4454)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-12 19:52:05 +01:00
Akos Kiss c46f4c3e40 Improve the path normalization of the default port (#4444)
Determine the length of strings as early as possible and use that
to prevent unnecessary memory allocations, and in memory copies
instead of string concatenations.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-12 19:31:20 +01:00
Akos Kiss 053fe4b331 Make the whole GH Actions Notification job conditional (#4443)
Don't even start the job if the workflow event is not a push to the
master repo.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-12 16:36:59 +01:00
Zoltan Herczeg 6f0391dd66 Unify internal property creation (#4373)
Furthermore free up a bit in the property descriptor.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-12 13:12:44 +01:00
Robert Fancsik 4399744588 Remove file(GLOB ...) usage from CMakeLists.txt (#4427)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-12 10:47:36 +01:00
Robert Fancsik 5cef002ed6 Fix underscore lookahead in hex literal parsing (#4448)
This patch fixes #4442.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-11 18:48:53 +01:00
kisbg 8ddd24f870 Add new target support to Error object and NativeErrors (#4372)
EcmaScript 11 19.5.1.1 Error
EcmaScript 11 19.5.6.1.1 NativeError

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-01-11 15:08:21 +01:00
kisbg 2919a6463f Add new target support for ArrayBuffer and TypedArray (#4369)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-01-11 14:20:28 +01:00
Akos Kiss fdaacde667 Officially introduce amalgamated builds (#4416)
Remove redundancy between all-in-one and all-in-one-source builds
by keeping only the second, and adopt the more established term
"amalgamated" build for it. This change includes the following:

- Replace `ENABLE_ALL_IN_ONE` and `ENABLE_ALL_IN_ONE_SOURCE` cmake
  options with `ENABLE_AMALGAM` top-level option.
- Replace `--all-in-one` option of `build.py` helper with
  `--amalgam`.
- Merge the `srcmerger.py` and `srcgenerator.py` tool scripts into
  `amalgam.py` (with improvements).
- Update documentation.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-11 13:07:40 +01:00
Robert Fancsik dcf9252892 Fix mapped arguments legacy argument definition initialization (#4434)
This patch fixes #4432.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-11 12:30:52 +01:00
Akos Kiss edb01f63d5 Replace isnan with inequality check to avoid conversion warning in older Clang (#4438)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-11 12:29:00 +01:00
kisbg 4c41f8ee07 Add proxy and bound function support for GetRealm method(#4407)
ecma_op_function_get_function_realm now can process proxy and bound functions.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-01-11 11:31:27 +01:00
Csaba Osztrogonác daba2b76fc Fix HAVE_M_LIB check for older CMake (#4437)
With older CMake (for example 2.8.12.2) the feature check of HAVE_M_LIB
reports false positive fail due to -Werror=strict-prototypes. It is already
fixed in CMake https://gitlab.kitware.com/cmake/cmake/-/commit/4bc17345

The feature is present and works, so we should only ignore this build warning.

Additionally the necessary GCC/Clang guard added to the similar
CMake feature check in jerry-port/default/CMakeLists.txt

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2021-01-11 11:26:47 +01:00
Akos Kiss 99ec5b9bab Farewell to Travis CI (#4436)
Travis CI became very slow lately. Most of the jobs have already
been moved to GH Actions. This commit finishes the migration.

- IRC notification is adapted (result of jobs is not reported).
- Sonar integration is dropped without replacement, as its GH
  Action does not support C projects.
- Coverity Scan integration is dropped without replacement as it
  has no GH Action at all.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-10 16:30:58 +01:00
Robert Fancsik b7b2e0360e Move ARM and target checks to Github Actions from Travis (#4430)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-08 20:08:03 +01:00
Robert Fancsik 7b00db4079 Fix unavailable source file handling in main_print_unhandled_exception (#4424)
This patch fixes #4403.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-08 16:03:33 +01:00
Akos Kiss 4350401b5b Add --build-type to tools/build.py (#4409)
This allows users to specify a build type other than `MinSizeRel`
or `Debug` for `tools/build.py`. (Build type was already freely
configurable by invoking cmake directly with a custom
`CMAKE_BUILD_TYPE` option.)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-08 16:01:06 +01:00
Akos Kiss 29785b2af3 Fix the include directory in the pkgconfig of the math lib (#4414)
The pkgconfig specified `include/jerry-math` as the include
directory, but cmake installs header to `include/jerryscript-math`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-08 16:00:44 +01:00
Robert Fancsik 0e829cc41a Enable generating compile_commands.json (#4417)
This feature is useful for intellisense users.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-08 16:00:17 +01:00
Akos Kiss f50728ef8d Rework GitHub Actions workflow configuration (#4412)
- Make jobs run on latest versions of the OS's (except for
  "Checks", which relies on specific versions of checkers coming
  with Ubuntu 18.04)
- Bump actions/checkout to v2
- Rewrite `apt-get` to `apt` (almost the same, but `apt` is the
  2nd gen tool)
- Drop step names (they took too much vertical space, didn't add
  too much useful information, and were very typo-prone)
- Move superfluous environment variables (e.g., `BUILD_OPTIONS` or
  `SKIP_LIST`) to their expansion sites (use YAML block scalars
  `>-` where appropriate to enhance readability)
- Fix duplicate installation of pylint in the "Checks" job

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-08 15:59:35 +01:00
Robert Fancsik b56fa43aa3 Fix VM stack size calculation for class initializer assignments (#4426)
This patch fixes #4413.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-08 14:08:55 +01:00
Robert Fancsik 238f9aab4a Tagged template literal array should be marked after construction (#4420)
This patch fixes #4385.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-08 13:07:34 +01:00
Akos Kiss d161e2d9ed Disable libjerry-math by default (#4428)
Normally, it is more usual and safe to use a toolchain's native
math library. Especially, if multiple components of a project use
math functions, in which case all components should be linked
against the same libm.

The libjerry-math can be used, of course, but as it needs extra
care and consideration, it should be opt-in.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-08 11:37:46 +01:00
Robert Fancsik 0a3aa0f48b Proxy.[[Set]] should reject falsish trap result in strict mode (#4418)
This patch fixes #4398.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-07 17:25:29 +01:00
Robert Fancsik 979a0c7826 Fix bytecode emitting for invalid regexp literals (#4422)
This patch fixes #4408.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-07 17:19:52 +01:00
Péter Gál 7972386412 Fix shifting a negative value when using BigInts (#4429)
When shifting a negative BigInt value if the
shift count is very "big" the result should be -1.

eg.:
```
(-2n >> (2n*32n)) === -1n
```

Note: the `-2n >> (2n*31n)` already returned `-1n` prior this change.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-07 12:45:10 +01:00
Robert Fancsik 6dfd02a08c Bound function 'length' property should be early initialized (#4421)
This patch fixes #4402.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-07 12:10:54 +01:00
Robert Fancsik fc701aef6d Fix reference count management in %TypedArray%.prototype.reduce{Right} (#4419)
This patch fixes #4397.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-07 11:59:16 +01:00
Péter Gál 61d172aaaf Don't use property list pointer to store Proxy flags (#4415)
Proxy flags (IsCallable, IsConstructor) can't be stored on the
property list compressed pointer. As adding a Proxy to a WeakSet
would add a property to the Proxy object causing failures down the line.

The prototype internal "slot" can be used to store there flags as
it is not used in case of Proxies (as per standard).

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2021-01-07 11:53:59 +01:00
Zoltan Herczeg 128f18a225 Fix mutable binding creation for realms with proxy this binding (#4370)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-07 11:09:33 +01:00
Zoltan Herczeg 7baaafa405 Fix the return value of jerry_to_property_descriptor function (#4371)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2021-01-07 11:09:07 +01:00
Robert Fancsik cab266f21d Fix inherited property type check in ordinary object.[[Set]] (#4425)
This patch fixes #4405.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-06 11:25:14 +01:00
kisbg 2ac3c08c14 Add proxy check in ecma_op_object_put_with_receiver (#4411)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2021-01-06 08:44:48 +01:00
Robert Fancsik 6279670484 Fix lookahead in lexer_check_numbers (#4423)
This patch fixes #4375.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-06 07:30:09 +01:00
Akos Kiss 257814d063 Rename jerry-libm to jerry-math (#4410)
That "libm" in the name of the library resulted in awkward naming
on *nix systems (`libjerry-libm.*`, "lib" occurring twice). And the
name of the corresponding header is `math.h` anyway.

Note that this is a breaking change in some sense. The commit
contains no API change, but the build system does change for users
of the math library.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-05 12:50:07 +01:00
Akos Kiss 5962562e2d Run CI on pushes and PRs to all branches (#4395)
This helps testing on forks before opening a PR to the main repo.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2021-01-05 11:56:32 +01:00
Yonggang Luo 2faafa4cfc Make test262-harness.py Python 3-compatible (#4381)
Less operator is not supported between int and None in Python 3. Fix
that Python 2 legacy in test262-harness.py.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2020-12-30 12:55:17 +01:00
Robert Fancsik 68b47f5f30 Update packages before installing them (#4388)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-12-29 21:17:10 +01:00
Yonggang Luo 83f9c38ed1 Completely remove JERRY_ATTR_SECTION (#4383)
PR #2903 removed only a part of JERRY_ATTR_SECTION.

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2020-12-29 09:02:20 +01:00
Zoltan Herczeg 9676500add Implement get proxy target (#4367)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-18 10:58:48 +01:00
kisbg 1937f820e1 Added new target support to Boolean, String, Number Object (#4368)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-12-17 09:44:59 +01:00
Zoltan Herczeg e2be8f4c79 Get the 'this' binding of a realm value (#4365)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-16 13:21:20 +01:00
Péter Gál 6083259030 Add missing version information in API reference document (#4363)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-15 11:19:22 +01:00
Péter Gál 035e5a27fa Correctly release wrapper object in JSON stringify (#4361)
When an error occurs accessing a property during JSON stringify call
the wrapper object is not freed at the correct place.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-15 11:18:14 +01:00
Péter Gál fe216d4710 Add missing BigInt type for value type query API (#4362)
Extended the `jerry_type_t` enum with `JERRY_TYPE_BIGINT` and added it to
the `jerry_value_get_type`.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-15 11:17:11 +01:00
Péter Gál 9380d93416 Fix assert in BigInt TypedArray filter and reduce methods (#4364)
The assert in the reduce and filter methods did not checked if the given value
is a BigInt. This missing check caused the assert to fail.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-15 11:14:58 +01:00
Peter Marki 0b72150190 Add cbc flush before statement parsing in constructors (#4358)
Fixes #4238

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-12-15 11:13:32 +01:00
Zoltan Herczeg 29be24f056 Fix var and function declaration in eval (#4360)
Fixes #4149

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-14 11:30:45 +01:00
Zoltan Herczeg fe29bf7390 Allow changing the 'this' binding of a realm (#4357)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-14 10:05:30 +01:00
Zoltan Herczeg 7e135b04ed Fix literal printing in byte code dump. (#4359)
Fixes #4353

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-11 13:59:48 +01:00
Zoltan Herczeg cc1e8d2dee Continue working on realms (#4356)
- Rework symbols to have the same value across realms
- Support realms for native functions
- Support test262
- Use new.target realms for constructing intrinsics

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-09 17:44:21 +01:00
Zoltan Herczeg df92c86ecf Implement realm object and support realms for built-ins and JS functions (#4354)
- Type for realm objects is introduced (ecma_global_object_t)
- Realm reference is added to built-in objects and ECMAScript functions
- Resolving built-ins, global environments, and scopes require realm object
- Unnecessary global object accesses are removed from the code

Missing: external functions and static snapshot functions have no realm reference

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-08 14:36:36 +01:00
kisbg 7cb9f808f7 Add support test262 $262 global object support (#4329)
Few test-cases in test262 uses a $262 object to run a few method (for example detachedArrayBuffer)

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-12-07 17:06:15 +01:00
Dániel Bátyai 1cb18f0ca6 Run tests with mem-stress-test enabled (#4278)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-12-04 10:58:06 +01:00
Péter Gál 89ff0fcf1f Handle revoked Proxy during [[Get]] operation (#4349)
The handling of Proxy.[[Get]] was not fully correctly in the case when the
Proxy was revoked during the execution of the handler.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-04 10:49:40 +01:00
Zoltan Herczeg de37e1e049 Template literal arrays should not be marked. (#4352)
Make array object big endian compatible.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-04 10:41:14 +01:00
Zoltan Herczeg c0fc67f5bd Rework built-in processing of JerryScript (#4347)
- All built-ins are native functions now
- Native handlers have a built-in id: ECMA_BUILTIN_ID_HANDLER
- Built-in routine identifiers start from 1
- Built-in routines have an own flag set
- Name property of routines is resolved dynamically
- Style fixes

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-12-01 11:37:08 +01:00
Péter Gál 577a605ead Correct syntax error printing in case of end of file (#4350)
The old variant of the syntax error printing method could incorrectly
over-read the source file contents.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-01 11:29:54 +01:00
Leesoo Ahn 290e845759 Do not check call_arguments twice through parsing call expression (#4346)
Checking call_arguments twice happens in a special case that
only if call_arguments <= 1 and opcode variable has CBC_EXT_SUPER_CALL.

JerryScript-DCO-1.0-Signed-off-by: Leesoo Ahn lsahn@ooseel.net
2020-12-01 11:29:25 +01:00
Péter Gál 5bd88e2723 Correct Regexp literal error release (#4351)
The error object for an incorrect Regexp literal was derefed then the error message
was accessed. This could lead to a state where the message was not available but
it was still accessed.

This could occur in case of heavy memory load or with mem stress mode.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-12-01 11:28:04 +01:00
Peter Marki 8eda7cb7d8 Remove LITERAL_POOL_IN_EXPORT flag at class statement end (#4348)
Fixes #4265

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-11-30 10:50:13 +01:00
Virag Orkenyi 19011258d8 Fix the optional argument problem in typedarray_prototype_reduce_... (#4323)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-11-26 12:06:22 +01:00
Péter Gál 3af3597f2e The constructor check should return false for arrow and generator functions (#4328)
The previous `ecma_is_constructor` implementation did not checked if the
target function was an arrow or generator function. This resulted in
an incorrect execution for these function types.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-11-24 12:46:44 +01:00
Péter Gál cc52282f34 Correctly mark the arguments.callee value in gc (#4345)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-11-24 05:19:16 +01:00
Zoltan Herczeg cbc3a5d291 Fix function calls which name is async and has an extra comma (#4340)
Fixes #4132

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-11-19 11:27:29 +01:00
Péter Gál d2c523b2c0 Use correct flag when checking for static snapshot in arguments object (#4343)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-11-19 11:23:44 +01:00
kisbg 7de7c2168e Implement asInteger, asUint32 and asInt32 jerry api methods (#4325)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-11-18 07:37:56 +01:00
Péter Gál 5d916fb8d4 Correctly handle the Proxy IsCallable and IsConstructor information (#4264)
The `IsCallable(target)` and `IsConstructor(target)` info
can't be stored in the target/handler values.
If the input for the ProxyCreate was a revocable Proxy the original target's
callable/constructor information must be retained even after the
Proxy was revoked.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-11-17 10:38:25 +01:00
Akos Kiss 7262b98021 Add script to extract JerryScript version from headers (#4333)
This can be used at configuration time to
- display version in diagnostics, and
- to write proper version number in pkgconfig files.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2020-11-17 10:36:13 +01:00
Péter Gál 65db83561f Implement rest parameter support for destructuring object patterns in for (#4338)
In case of `for (const {...rest} ...) ` there was an incorrectly handling
of the destructuring pattern.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-11-17 10:35:27 +01:00
Virag Orkenyi fab35c3f93 Fix the indexing problem in typedarray_prototype_index_of & last_index_of (#4305)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-11-16 15:43:55 +01:00
Virag Orkenyi f7b7873a02 Extend Jerry API & API documentation with regex flags (#4246)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-11-16 15:42:27 +01:00
Zoltan Herczeg 1237bef0f0 Variables created by eval in strict mode should ignore the properties of their parent function. (#4339)
Fixes #4018

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-11-16 15:04:22 +01:00
Zoltan Herczeg 640a7d33b3 Support byte code dump when snapshot is executed. (#4327)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-11-16 12:17:41 +01:00
Akos Kiss 81702ff5ea Drop the minimal variant of the default port implementation (#4331)
The minimal variant became quite meaningless lately. There were two
port APIs originally that had extra functions in the default port
in addition to the core-mandated implementations: the I/O and
Termination port APIs. However, the extra Termination API code was
removed a year ago, leaving some minimal extension in the I/O port
only. As the overhead of the extension is negligible, it is not
worth maintaining two library variants.

Therefore
- this commit removes the minimal variant of the default port lib,
- rewrites uses of the minimal variant to use the variant with the
  I/O extension, and
- updates targets where I/O port code was copy-n-pasted.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2020-11-16 11:54:01 +01:00
Csaba Osztrogonác c57938e0c7 Run test262-esnext tests with larger heap (#4337)
built-ins/RegExp/CharacterClassEscapes tests need more memory than 512Kb.
Additionally increase the timeout to make all tests pass on GitHub CI.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-11-16 11:52:35 +01:00
Akos Kiss 32674f9733 Fix name of install directory of jerry-libm header(s) (#4332)
All installed headers and header directories of the project have
the `jerryscript-` prefix, except the math library, which installed
its `math.h` under `jerry-libm` directory.

This commit changes the name of the include directory to
`jerryscript-libm` to align it with the rest of the project.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2020-11-12 11:00:11 +01:00
Akos Kiss 40004da163 Fix tabulation of configuration messages (#4330)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2020-11-12 10:57:59 +01:00
Peter Marki 25bb5083be Fix await parsing in modules (#4266)
Fixes #4189

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-11-10 09:53:00 +01:00
kisbg b2084e0a02 Implement from and to property descriptor API function (#4245)
Also added two new helper method:
ecma_property_descriptor -> jerry_property_descriptor converter method
jerry_property_descriptor -> ecma_property_descriptor converter method

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-11-03 14:27:26 +01:00
Ádám Kallai d0e385f9eb Fix the ESNext build with disabled JERRY_BUILTIN_PROXY (#4320)
With a disabled JERRY_BUILTIN_PROXY option the build fails becouse
of missing guards.

The run-test buildoption_test is also extended with this.

JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2020-11-02 09:30:43 +01:00
kisbg 11f7463986 Support decimal create with leading zero (#4286)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-30 14:32:32 +01:00
Daniella Barsony 3bad85b83b Add Boolean Prototype Dispatcher (#4308)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-10-29 12:24:32 +01:00
Daniel Balla b7ca097436 Property key filter API (#4311)
Co-authored-by: Robert Fancsik <frobert@inf.u-szeged.hu>

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-10-29 11:10:21 +01:00
Daniel Balla e681adce05 Fix sweeping ecma_promise_value_thunk function objects (#4312)
Fixes #4214

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-10-29 10:50:37 +01:00
Daniella Barsony 72c92d6b36 Add Array Builtin Dispatcher (#4310)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-10-29 10:49:36 +01:00
Zoltan Herczeg c7986fd2c5 Implement rest parameter support for destructuring object patterns. (#4318)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-10-29 10:49:08 +01:00
Daniella Barsony 484e999dec Add Promise Prototype Dispatcher (#4309)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-10-28 15:09:17 +01:00
Csaba Osztrogonác 3115d4dc16 Implement DataView.prototype.{set, get}Big{U}int64 methods (#4315)
Co-authored by Adam Szilagyi aszilagy@inf.u-szeged.hu

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-28 11:46:52 +01:00
Ádám Kallai 2007188373 Add lazy load of exclude_list in test262-harness (#4317)
This PR aims to avoid serializing the exclude_list
before each test_case.

test-262-esnext execution takes only ~2 mins (8-thread).

JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2020-10-28 10:34:08 +01:00
Csaba Osztrogonác 24a5489331 Implement ToIndex abstract operation (#4287)
https://www.ecma-international.org/ecma-262/11.0/#sec-toindex

Made DataView constructor, DataView.prototype.setXXX/getXXX methods ES11 conform.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-27 10:37:50 +01:00
Daniella Barsony d5d27afd39 Add Dispatcher for Promise Builtin (#4307)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-10-22 13:21:33 +02:00
Virag Orkenyi 49c633210a Fix assertion fail in typedarray_prototype_to locale_string (#4285)
Change typedarray_prototype_to_locale_string_helper to use ecma_op_invoke_magic_id instead

JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-10-22 12:49:40 +02:00
Zoltan Herczeg 91e0cfc767 Implement ES11 globalThis (#4306)
Also improve symbol built-in instantiation.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-10-22 10:59:54 +02:00
Csaba Osztrogonác a65988798c Uncontrolled memory allocation in jerry_port_read_source function (#4282)
jerry_port_read_source should exit with error message
if its parameter is a directory and not a regular file.

Fixes #4251.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-22 09:05:51 +02:00
Philippe f303017542 espressif's ESP-IDF port (#4270)
JerryScript-DCO-1.0-Signed-off-by: Philippe pgu-swir@users.noreply.github.com


Co-authored-by: Philippe <pgu-swir@users.noreply.github.com>
2020-10-21 19:56:59 +02:00
Csaba Osztrogonác 8a0a86e3c7 Fix the build without BigInt support (#4304)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-21 10:04:59 +02:00
Zoltan Herczeg 6f25d6ed31 Improve JerryScript debugger (#4299)
- Support print (p) as alias to eval (e)
- Fix backtrace processing (incorrect increment when cpointer is 4 byte long)
- Support partial names for pending breakpoints (similar to normal breakpoints)
- Don't print newline after pending breakpoint dialog text
- Add jerryscript-debugger-transport.h to all-in-one build

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-10-19 15:26:19 +02:00
Roland Takacs 3c9a7915e1 Initialize variable to eliminate may be used uninitialized warnings (#4297)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu

Co-authored-by: Roland Takacs <roland.takacs@h-lab.eu>
2020-10-19 14:32:40 +02:00
Daniel Balla 870dbff1c7 Don't ref arguments object bytecode in case of static snapshots (#4298)
JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-10-19 14:31:55 +02:00
Ádám Kallai 23e9e773e0 Fix implicit 'double' conversion reported by Clang (#4296)
JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2020-10-19 14:30:43 +02:00
Csaba Osztrogonác 01c0ca3b6c Fix sign-compare compiler warning in js-scanner-util.c (#4293)
Found by mingw32-gcc (MinGW.org GCC Build-2) 9.2.0.

comparison of integer expressions of different signedness:
'intptr_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare]

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-19 14:29:13 +02:00
Zoltan Herczeg f384642409 Implement proper function length support (#4290)
Comma after last destructuring argument has been fixed as well

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-10-19 10:55:26 +02:00
Csaba Osztrogonác 9da1211e26 Fix HAVE_TM_GMTOFF check for older CMake. (#4292)
Older CMake (for example 2.8.12.2) generates feature check with unused
variable, which reports false positive fail due to -Werror=unused-value.
The feature is present and works, so we should only ignore this build warning.

Fixes #2791.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-17 11:32:47 +02:00
Dániel Bátyai 080abb94ca Check for prototype bound name in class static accessors (#4257)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-16 17:02:17 +02:00
Robert Fancsik d8955552d7 Revise internal array creation operations (#4291)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-10-16 15:24:50 +02:00
Zoltan Herczeg 841d536fce Implement proper arguments support (#4289)
- Store arguments in a register when possible
- Create separate arguments object for function argument initializer when necessary

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-10-16 11:02:36 +02:00
Dániel Bátyai 650269feca Exporting undeclared variables should throw a SyntaxError (#4276)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-15 14:48:25 +02:00
Ádám Kallai f6cf1400bd Fix implicit 'double' conversion reported by Clang 12.0.0 (#4288)
JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2020-10-14 11:43:27 +02:00
Csaba Osztrogonác 2a8f1dcbc3 Annotate test262-esnext-excludelist.xml (#4281)
Group unsupported ES features and add comments
to clarify which test files test which feature.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-12 14:24:31 +02:00
Zoltan Herczeg 3c2a3f5dd9 Implement environment record for class constructors (#4207)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-10-12 13:13:38 +02:00
kisbg d317124650 Update JSON stringify to conform ES11 standard (#4176)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-12 13:04:08 +02:00
kisbg da1a4bbd44 Implement numeric-separator (#4158)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-12 11:33:03 +02:00
Dániel Bátyai d1f73752ff Error should be thrown later when calling super multiple times (#4256)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-10 18:58:31 +02:00
Daniel Balla 596964ae0d Update jerry_run_all_enqueued_jobs() function and documentation (#4283)
Make sure it always returns an error or an undefined value.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-10-10 09:03:52 +02:00
Robert Fancsik e3481d431b Revise the API ArrayBuffer related operations (#4284)
- External ArrayBuffer construction with 0 length should be equivalent to `new ArrayBuffer(0)`
- Internally allocated ArrayBuffers should be detachable
- Externally allocated ArrayBuffers free callback should be called when underlying buffer is detached

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-10-09 15:12:45 +02:00
Dániel Bátyai 5b9a6deb93 Replace fast path should keep a reference to the executed bytecode (#4277)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-08 10:02:43 +02:00
Péter Gál 4df833e7ad Propagate strict mode for Proxy targets during delete (#4273)
After ES5.1 if the delete returns false a TypeError should be thrown
in strict mode.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-10-08 10:00:47 +02:00
Dániel Bátyai c905c21abb Fix flag handling when creating arguments objects (#4272)
Member variables of the object must be initialized before setting the
required flags, otherwise the uninitalized values can cause problems
during garbage collection.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-08 09:58:44 +02:00
kisbg 148f69f4a5 Add new target support for object create (#4203)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-07 15:07:25 +02:00
kisbg 99c7099eaa Update object.prototype.toString to conform ES11 standard (#4196)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-07 15:05:17 +02:00
kisbg 17fe441819 Add AsyncFunc proto id check in ecma_object_check_class_name_is_object (#4274)
fixes #4147

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-07 08:48:11 +02:00
Robert Fancsik 53a085cd28 Builtin objects symbol properties should be lazy listed (#4271)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-10-06 14:52:25 +02:00
Dániel Bátyai 17c8ec57bb Propagate strict mode flag from scanner when parsing functions (#4262)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-06 10:25:13 +02:00
Virag Orkenyi fb1c21beb7 Change guarding of ecma_is_value_bigint and ecma_is_value_symbol (#4269)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-10-05 14:43:04 +02:00
kisbg a084fdbe45 Add a new check for array.prototype.sort in array prototype dispatch (#4208)
Bugfix: first check arguments callable then the length of the this value.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-10-05 11:26:01 +02:00
Péter Gál 8edf8d6eea Remove revoked Proxy checks when creating a Proxy (#4261)
In the newer ecma262 standard (post ES11) the ProxyCreate was
changed and the revoked Proxy handler/target is not checked.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-10-05 10:03:49 +02:00
Robert Fancsik 37d6b13891 Fix Symbol.description API reference count management (#4267)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-10-02 11:08:57 +02:00
Csaba Osztrogonác 7458766033 Date.parse should reject out of range values (#4248)
The spec doesn't say explicitly that Date.parse should call TimeClip
abstract operation at the end. But Date object can represent time
values only in the range 1970 Jan 01 +/-8,640,000,000,000,000 ms.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-02 10:39:52 +02:00
Péter Gál 261a55c6b5 Fix class handling with disabled module system (#4247)
If the module system is disabled however the es.next is enabled the following
code triggers an assert:

```js
class Demo {}
```

This was due to an incorrect scanner data processing where it was always
assumed that there is a module related information.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-10-01 16:36:48 +02:00
Csaba Osztrogonác 8fe3891b15 Fix Date.parse to handle times without timezone properly (#4249)
https://www.ecma-international.org/ecma-262/11.0/#sec-date.parse
"When the UTC offset representation is absent, date-only forms are
interpreted as a UTC time and date-time forms are interpreted as a local time."

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-01 16:34:59 +02:00
Csaba Osztrogonác e227634b45 Make Date.UTC to conform to the latest ES11 spec (#4250)
Date.UTC should work with only one argument too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-10-01 16:34:09 +02:00
Zsolt Borbély aa89d38df3 Various minor improvements to reference document (#4259)
- add version notes in case of JERRY_TYPEDARRAY_BIGINT64, JERRY_TYPEDARRAY_BIGUINT64
 - add code highlight to type values (JERRY_INIT_MEM_STATS_SEPARATE, JERRY_INIT_MEM_STATS_SEPARATE)
 - add newlines to break the version notes into separate lines
 - add missing periods

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2020-10-01 13:10:42 +02:00
Dániel Bátyai b9e4897c71 Fix the value of the caller property of function instances (#4258)
We do not support the caller information for functions, and since a
'null' value represents that there has been no caller, the default value
should be changed to 'undefined' to signal that the information is not
available.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-01 12:10:11 +02:00
Dániel Bátyai 69d9b2c326 Check that this binding is initialized before forming a super reference (#4255)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-10-01 11:21:00 +02:00
Zoltan Herczeg 4b2dbd5c21 Correctly set flags of identifiers related to classes (#4233)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-30 12:45:53 +02:00
Péter Gál 0ffe1665bd Fix a typo in case of single thread/process execution in test262 harness (#4223)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-09-28 16:14:23 +02:00
Philippe f97c0134d7 Fix compilation warnings when using 32-bit floats (#4199)
JerryScript-DCO-1.0-Signed-off-by: Philippe pgu-swir@users.noreply.github.com
2020-09-28 16:12:21 +02:00
Dániel Bátyai 9f93b0a8ee Fix Symbol to Object comparison (#4226)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-28 16:01:38 +02:00
Robert Fancsik 75385a6045 Improve arguments object (#4145)
- Enhancement: Arguments object properties are now lazy instantiated
 - Bugfix: Mapped arguments object instantiated properties cannot be lcached
 - Bugfix: Mapped arguments should be constructed even if 0 formal parameters or arguments are provided
 - Update: remove 'caller' property of unmapped arguments object

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-09-28 15:57:58 +02:00
Zoltan Herczeg 32de38198a Fix invalid free in TypedArray find method. (#4230)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-28 10:48:14 +02:00
Csaba Osztrogonác c4388e2c19 Fix memory leak in ecma_op_abstract_relational_compare (#4235)
Fixes #4234.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-09-28 10:29:25 +02:00
Dániel Bátyai f58f15077f Bound names of for-in/of statements cannot contain let (#4225)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-25 16:33:11 +02:00
Csaba Osztrogonác de38764e88 Fix heap buffer overflow in Array.prototype.copyWithin (#4211)
2nd and 3rd argument evaluation of Array.prototype.copyWithin can change
the length of the array as a side-effect. But ES11 spec says that the
algorithm should use the original length. In this case it could happen
that the underlying buffer should be extended.

Fixes #4204

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-09-25 15:06:29 +02:00
Zoltan Herczeg bc64957d19 Properly implement static class fields. (#4221)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-25 14:23:02 +02:00
Csaba Osztrogonác e478640d80 Add --buildoption-test to CI (#4236)
run-tests --buildoption-test was previously tested on Travis CI,
but wasn't added to GitHub CI accidentally.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-09-25 14:20:49 +02:00
Péter Gál 0745feb670 Do module cleanup at a later stage (#4209)
Module info should be freed at a later stage to correctly have
all module data in every step during the execution.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-09-25 14:05:46 +02:00
Dániel Bátyai 629a0e51c4 Legacy octal escapes should not be allowed in template strings (#4227)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-25 10:14:28 +02:00
Dániel Bátyai 43e03a1ac6 Fix continue label lookup in for statements that have a private scope (#4224)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-25 10:06:19 +02:00
Csaba Osztrogonác 3b7409f3a7 Run test262 tests on CI on Ubuntu 20.04 (#4232)
The timeout utility in Ubuntu 18.04 (GNU CoreUtils 8.28) has a bug which
caused false positive test failures regulary. This bug is already fixed
in CoreUtils, and Ubuntu 20.04 LTS shipped the fixed version of timeout.

https://github.com/coreutils/coreutils/commit/cbf35912da66a17a6113d5a434214dd7651f403a

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-09-24 13:32:32 +02:00
Virag Orkenyi be180ba159 Delete ECMA_OP_TO_NUMBER_TRY_CATCH macro (#4229)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-09-24 10:50:12 +02:00
Zoltan Herczeg 3c723c9bc1 New jerry_get_symbol_description API function (#4206)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-21 10:39:38 +02:00
Zoltan Herczeg 4d135bec5d Rework frame context (#4200)
A new shared frame context data is created which allows sharing
data between the function call and vm main loop. Furthermore
rest arguments and current function object handling is reworked.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-21 10:25:17 +02:00
Dániel Bátyai 55554535b2 Update Promise.all/race to ES11 (#4202)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-18 14:05:48 +02:00
Dániel Bátyai 74f66879c2 Improve support for built-in native handlers (#4184)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-17 18:35:11 +02:00
Dániel Bátyai f4af997935 Update NuttX repository URLs (#4201)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-09-17 18:15:40 +02:00
Virag Orkenyi 1be9573925 Separate ecma_builtin_helper_string_find_index into two parts (#3978)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-09-17 15:38:36 +02:00
Péter Gál da2299d277 Convert fast array to normal array when the prototype is changed (#4198)
If the prototype of a fast array is changed, for example to a Proxy object,
the array should be converted back to a normal array. This is required to
correctly handle any [[Get]]/[[Set]]/etc... calls which should trigger
these method calls on the before mentioned Proxy object.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-09-17 15:23:37 +02:00
Zoltan Herczeg d9653823ca Initial implementation of class fields (#4191)
Missing features:
 - this binding in static fields are not supported
 - static field evaluation order is wrong
 - function names are not supported

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-17 15:22:55 +02:00
Rafal Walczyna 7345c83af7 Update TypedArray properties to conform with newest standard (#4194)
name and length properties has been updated.
Enabling BigInt support in TypedArray.prototype.sort when no
comparefn function is provided.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-09-14 17:32:26 +02:00
Péter Gál f8983cd2b5 Allow parallel test execution in test262 for ES2015 and ESNEXT (#4182)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-09-14 17:30:38 +02:00
Csaba Osztrogonác f834340608 Fix test262 excludelist update on Windows (#4185)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-09-14 17:29:57 +02:00
Daniella Barsony c013fade26 Add TypedArray custom dispatcher (#4040)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-09-08 10:05:15 +02:00
Szilagyi Adam 9bffc981cd Refactor Array.prototype.splice to conform ES11 standard (#4172)
The algorithm is based on ECMA-262 v11, 22.1.3.28

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-09-08 10:04:13 +02:00
Péter Gál 6f29e48fc6 Correctly handle strict mode in case of Proxy.[[Set]] (#4180)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-09-08 10:03:27 +02:00
Peter Marki 861bb82749 Update ES6 exclude list: Reflect.enumerate is obsolete since ES2016 (#4181)
JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-09-08 10:02:52 +02:00
Zoltan Herczeg 2bc3111e31 Improve error detection of nullish coalescing operator (#4179)
Also rename LEXER_IS_BINARY_LVALUE_TOKEN to LEXER_IS_BINARY_LVALUE_OP_TOKEN
because its name is wrong.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-09-07 14:43:41 +02:00
Péter Gál f03bf9074f Correctly set the define property flags during [[Set] in case of Proxy (#4178)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-09-02 17:34:15 +02:00
Rafal Walczyna 074945dafa Add missing value release to TypedArray fill method (#4177)
Value was not freed when error occurs. It caused assertion to fail
when BigInt was used.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-09-01 15:28:12 +02:00
Tóth Béla ed63665901 Fix whitespaces in BigInt constructor (#4152)
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2020-09-01 15:26:43 +02:00
Robert Fancsik 1fd0cac8c9 Introduce new API function to obtain well-known symbols (#4163)
- jerry_get_well_known_symbol

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-08-31 10:03:05 +02:00
Robert Fancsik 2f08d8ac08 Fix evaluation order in non-binding destructuring patterns (#4173)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-08-28 15:13:02 +02:00
Szilagyi Adam 28c186c98f Refactor ArrayBuffer.prototype.slice to conform ES11 standard (#4174)
The algorithm is based on ECMA-262 v11, 24.1.4.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-28 14:00:49 +02:00
Robert Fancsik cd1c06510e Support BigInt64/BigUint64 typedarray creation from API (#4170)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-08-28 13:14:40 +02:00
Szilagyi Adam 9589771f7a Refactor ecma_op_check_object_coercible (#4169)
The method returns bool now instead of an ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-28 13:12:50 +02:00
Dániel Bátyai e98f5342f9 Fix leaking lastIndex values in RegExp built-ins (#4166)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-28 13:09:53 +02:00
Robert Fancsik 6d0e948bef Introduce new API functions to obtain detailed object type information (#4162)
- jerry_object_get_type
- jerry_function_get_type
- jerry_iterator_get_type
- jerry_value_is_async_function

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-08-28 12:53:56 +02:00
Péter Gál 4ed9e2c033 Correctly report error in for-in start in case of proxies (#4165)
In case of Proxies the "ownKeys" call can return an incompatible
value for a for-in statement. In such cases the error should be
propagated to the user.

Fixes: #4159

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-08-28 12:46:35 +02:00
kisbg a470fef8a5 Add length check in copy_within's fast path (#4168)
fixes #4146

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-28 10:55:26 +02:00
Szilagyi Adam 2aa5f136a4 Implement String.prototype.replaceAll (#4088)
The algorithm is based on ECMA-262 v12, 21.1.3.18

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-28 10:41:11 +02:00
kisbg 1ec216e573 Fixing test262 built-ins symbol test-cases (#4123)
The remaining test-cases needs realm feature

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-27 13:39:04 +02:00
Virag Orkenyi 777b7e9c87 Cleanup toNumber and toNumeric abstract operations (#4034)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-08-27 13:32:30 +02:00
Csaba Osztrogonác a6cd19fa6e Annotate test262-esnext-excludelist.xml (#4171)
Group stage 4 and stage 3 tests by proposals.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-27 13:20:18 +02:00
Szilagyi Adam 24753ddd70 Minor fix to ecma_builtin_object_object_define_property (#4124)
DefineOwnProperty result could be false, and we should throw an error in that case.

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-27 09:52:14 +02:00
kisbg 59ab36088f Check argument is bigint in create_object_arg (#4142)
fixed #4138

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-27 09:04:46 +02:00
Szilagyi Adam 138151832a Minor fix to RegExp.prototype.compile (#4112)
Fixed tests from the exclude list:
<test id="annexB/built-ins/RegExp/prototype/compile/length.js"><reason></reason></test>
<test id="annexB/built-ins/RegExp/prototype/compile/pattern-regexp-flags-defined.js"><reason></reason></test>
<test id="annexB/built-ins/RegExp/prototype/compile/pattern-regexp-immutable-lastindex.js"><reason></reason></test>

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-26 15:16:55 +02:00
Tóth Béla 09c8d28b2c Implement TrimStart TrimEnd and aliases (#4102)
Based on: https://tc39.es/ecma262/#sec-string.prototype.trim

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2020-08-25 13:10:36 +02:00
Szilagyi Adam 85981457e6 Implement BigInt64 and BigUint64 typedArrays (#4151)
Also implemented ToBigInt conversion method based on ECMA-262 v11, 7.1.13

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-24 18:03:12 +02:00
Csaba Osztrogonác 55b6b1aed7 Fix memory corruption (bad-free) in ecma_string_pad (#4164)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-24 15:01:49 +02:00
Tóth Béla 1bcfb711a3 Fix BigInt.prototype.toString length (#4161)
JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2020-08-24 14:51:03 +02:00
Péter Gál f2ff0d082f Correctly release values in TypedArray's toLocaleString (#4156)
When the `toLocaleString` was called on a TypedArray's value
the resulting object's `toString/valueOf` invocations could
create errors. These error values were not released.

In addition the input element value for the toString operation
was released twice in case of an error.

Fixes: #4148.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-08-24 14:50:18 +02:00
Zoltan Herczeg 84bc1e03fb Detect assignment pattern for for-in/of (#4140)
Furthermore do not allow default value for rest parameter

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-24 14:47:10 +02:00
Zoltan Herczeg 5b3f01af9d Add missing error support for API functions. (#4153)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-19 11:13:08 +02:00
Csaba Osztrogonác b828d1c15f Fix heap-buffer-overflow in ecma_builtin_json_quote (#4143)
Fixes #4129.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-18 13:56:01 +02:00
kisbg d9cb2c60f2 fix check order in ecma_op_abstract_equality_compare (#4141)
Fixes #4139

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-18 13:50:58 +02:00
kisbg 086d1cc127 Added missing object deref in ecma_promise_reject_or_resolve (#4144)
fixes #4131

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-17 11:06:44 +02:00
Péter Gál 9d586fea76 Handle errors in JSON.parse triggered by Proxies (#4134)
Fixes: #4130

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-08-14 08:25:43 +02:00
Csaba Osztrogonác 8964a2bd18 Optimize test262 runner (#4120)
Changes:
- Add new option to run-tests.py: --test262-test-list to run selected tests only
- Fix exclude list updater accordingly
- Run ESNext tests on GitHub CI in two batches to decrease runtime

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-13 13:47:14 +02:00
Csaba Osztrogonác 409ead7415 Fix memory leak in ecma_op_object_get_enumerable_property_names (#4136)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-13 13:46:50 +02:00
Csaba Osztrogonác ea07052869 Make Array.prototype.unshift method conform to ES11 (#4128)
Changes:
- Since ES6 Array.prototype.unshift shouldn't iterate
over the array elements if argument count is 0.
- Add proper guard for a check introduced in ES6.
- Update comments to reference to ES5.1 and ES11 specs too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-13 10:09:25 +02:00
Dániel Bátyai 5ce95be174 Mark the lexical environments of running executable objects (#4133)
Fixes #4094.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-12 20:50:48 +02:00
Dániel Bátyai 79540727ab Append promise reaction values in a gc safe manner (#4127)
Fixes #4096.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-12 20:45:07 +02:00
kisbg cd34bfa4c3 Implement Array.flat and Array.flatMap (#3925)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-12 16:51:04 +02:00
Csaba Osztrogonác 0bb4626ddb Fix Array.prototype.slice, splice and map builtin methods (#4122)
CreateDataPropertyOrThrow is introduced in ES2015, and these methods should use it
to throw TypeError exception if the requested property update cannot be performed.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-12 16:35:27 +02:00
Zoltan Herczeg 6adf0c1a87 Support BigInt to number conversion using Number constructor (#4121)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-12 16:33:31 +02:00
Dániel Bátyai 0c154306a8 Fix yield* with undefined return method. (#4126)
Fixes #4097.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-11 14:01:18 +02:00
Zoltan Herczeg f761427a3e Improve BigInt support (#4118)
This patch adds several small features:
- Support right shift with negative numbers
- Support exponentation operator
- BigInts can be enabled in ES5.1 mode
- Remove dead code from ecma_deref_bigint
- Support longer BigInt literals in the parser
- Fix various BigInt comparison issues
- Do not discard unary plus for BigInt constants

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-11 11:25:01 +02:00
Dániel Bátyai 286e515f9f Fix mem-stress-test to properly run gc before allocs (#4125)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-11 09:51:43 +02:00
Zoltan Herczeg 39fe04814e Implement unary operators: bitwise not, pre/post increment/decrement (#4116)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-10 22:38:34 +02:00
kisbg 43a82cddb9 Implement Object.prototype.fromEntries (#4065)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-07 15:08:12 +02:00
kisbg cebb6aee5c Fix Symbol's description default value (#4077)
In the standard if we create a Symbol object without adding a description value
default value is undefined not empty string.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-07 15:00:44 +02:00
kisbg 58a649ffe8 Fixed Array.prototype.concat error type (#4117)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-07 14:34:57 +02:00
Zoltan Herczeg f4f9cde3e7 Fix evaluation order for binary operators (#4114)
Furthermore fix toBoolean for BigInts as well.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-07 14:32:46 +02:00
Zoltan Herczeg cb14682983 Create API for handling BigInts (#4111)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-07 13:43:29 +02:00
Daniella Barsony 082085a8fd Add Number builtin custom dispatcher (#4113)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-08-06 16:45:18 +02:00
Dániel Bátyai 25117ad56b Fix whitespace ranges for ES.next profile (#4110)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-06 14:26:41 +02:00
Dániel Bátyai 3d44b26aeb Update RegExp.prototype accessors for ES11 (#4103)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-06 14:24:48 +02:00
Zoltan Herczeg 531f724926 Change BigInt zero representation to a constant (#4109)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-06 12:17:39 +02:00
kisbg 7d479ad91b Update proxy to ES2020 (#4085)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-08-06 11:25:29 +02:00
Csaba Osztrogonác c76736eadf Methods shouldn't have prototype property (#3964)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-05 14:01:58 +02:00
Szilagyi Adam b82bd76175 Minor fixes to ecma_builtin_object_prototype_define_getter_setter (#4104)
Fixed tests from the exclude list:
annexB/built-ins/Object/prototype/__defineGetter__/define-non-configurable.js
annexB/built-ins/Object/prototype/__defineGetter__/define-non-extensible.js
annexB/built-ins/Object/prototype/__defineGetter__/getter-non-callable.js
annexB/built-ins/Object/prototype/__defineGetter__/this-non-obj.js
annexB/built-ins/Object/prototype/__defineSetter__/define-non-configurable.js
annexB/built-ins/Object/prototype/__defineSetter__/define-non-extensible.js
annexB/built-ins/Object/prototype/__defineSetter__/setter-non-callable.js
annexB/built-ins/Object/prototype/__defineSetter__/this-non-obj.js

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-05 12:06:28 +02:00
Szilagyi Adam 019dd03fcc Implement JSON superset (#4099)
JSON strings can contain unescaped LINE SEPARATOR and PARAGRAPH SEPARATOR in ES11

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-04 16:56:08 +02:00
Csaba Osztrogonác 621a5ddb8f Test262 results should be uploaded always (#4106)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-04 16:54:53 +02:00
Csaba Osztrogonác 401b36d406 Make test262 output less verbose (#4108)
Changes:
- Progress meter is precise and less verbose
- Omit list of failures, test262.report file contains it

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-04 16:54:06 +02:00
Zoltan Herczeg bdb39f1f03 Implement binary bitwise BigInt operators (#4105)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-04 16:53:38 +02:00
Péter Gál b749c4c267 Allow error reporting during property creation in Array.prototype.filter (#4091)
In case of ES.next the Array.prototype.filter should raise an error
if the property on the target array's data property creation fails.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-08-04 16:52:08 +02:00
Szilagyi Adam 945b22976a Implement Object.prototype.{__lookupGetter__, __lookupSetter__} (#4039)
__lookupGetter__ is based on ECMA-262 v11, B.2.2.4
__lookupSetter__ is based on ECMA-262 v11, B.2.2.5

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-08-04 16:41:05 +02:00
Zoltan Herczeg b5a96c9eca Implement BigInt literal parsing in the parser. (#4089)
Support octal literals for BigInts.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-04 14:16:38 +02:00
Dániel Bátyai be9dbeffdb Fix AdvanceStringIndex to return an ecma_length_t (#4100)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-08-04 09:08:34 +02:00
Rafal Walczyna 4ce4b617fd Add Symbol support to integrity testing routine (#4101)
Properties with Symbol caused assertion to fail

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-08-03 17:29:34 +02:00
Péter Gál e9b794f629 Fix propery name duplication check in case of empty collection (#4098)
Fixes: #4093

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-08-03 17:27:50 +02:00
Zoltan Herczeg cfd69d3b70 Implement relational operators for BigInts (#4087)
Improve BigInt constructor as well

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-08-03 13:46:34 +02:00
Csaba Osztrogonác f1eba9f826 Make Test262 results less verbose (#4090)
Changes:
- Don't dump each test output to stdout
- Upload test outputs as artifact to GitHub

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-08-03 10:40:26 +02:00
Dániel Bátyai 26a299adf0 Fix block-scoped var/function redeclarations (#4080)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-31 17:43:15 +02:00
Dániel Bátyai 84125275ea Make sure modules are evaluated when creating a namespace object (#4081)
Fixes #4076.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-31 17:19:05 +02:00
Dániel Bátyai 611c8827ba Improve case conversion related fast paths (#4083)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-31 16:25:32 +02:00
Csaba Osztrogonác 40ad8c6e45 Add --test262-esnext option to run-tests.py (#4027)
Changes:
- Imported and unified test262 test harness for ES2015 and ESNext
- Simplified runner scripts accordingly
- Run tests on CI to be able detect regressions and progressions too

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-07-31 15:52:45 +02:00
Péter Gál 26c1ffaf71 Fix build with disabled ES2015 module system (#4084)
With a disabled ES2015 module system the build fails as an enum value
is incorrectly guarded and used.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-31 15:51:43 +02:00
Szilagyi Adam b4a4619a6c Implement Object.prototype.{__defineGetter__, __defineSetter__} (#4032)
__defineGetter__ is based on ECMA-262 v11, B.2.2.2
__defineSetter__ is based on ECMA-262 v11, B.2.2.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-30 16:34:43 +02:00
Péter Gál b27f40303b Fix TypeError name property value (#4086)
The TypeError.name incorrectly returned the "SyntaxError" value.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-30 16:24:26 +02:00
Szilagyi Adam a4312d614f Fix prototype chain traversal in ecma_op_object_put_with_receiver (#4066)
The ECMA_OBJECT_IS_PROXY(proto_p) check is necessary throughout the prototype chain
not just at the beginning

Fixes #4045

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-30 14:35:18 +02:00
Zoltan Herczeg df2f7782f7 Implement BigInt primitve type and some of its operations (#4062)
Supported operations:
- parse BigInt (decimal, hexadecimal, binary)
- toString with any radix between 2 and 36
- arithmetic operations: negate, add, subtract, multiply, divide, modulo
- left and right shift

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-30 12:08:34 +02:00
Robert Fancsik 3eb69075f7 Update ToLength operation to conform ES6 spec (#4007)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-29 11:13:34 +02:00
Péter Gál 56e328be41 Fix conversion and signedness warnings (#4079)
In case of ARM Nuttx build with IoT.js there are small conversion
and signedness warnings resulting in a build failure.

```
ecma-builtin-regexp-prototype.c: error: conversion from 'int' to '_Bool8' {aka 'unsigned char'}
  may change value [-Werror=conversion]
  116 |   return ecma_make_boolean_value (flags & re_flags[offset]);
      |                                   ~~~~~~^~~~~~~~~~~~~~~~~~

js-scanner-util.c: In function 'scanner_pop_literal_pool':
js-scanner-util.c:628:43: error: comparison of integer expressions of different signedness:
  'intptr_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare]
  628 |       else if (diff >= -UINT8_MAX && diff <= UINT16_MAX)
      |                                           ^~
js-scanner-util.c:891:43: error: comparison of integer expressions of different signedness:
  'intptr_t' {aka 'int'} and 'unsigned int' [-Werror=sign-compare]
  891 |       else if (diff >= -UINT8_MAX && diff <= UINT16_MAX)
```

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-29 00:05:35 +02:00
Robert Fancsik 2832bdc94d Fix surrogate pair lookahead in String.prototype.toUpper (#4073)
This patch fixes #4013.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 15:53:17 +02:00
Zoltan Herczeg dff2a2a6da Rework ascii string to use less memory. (#4030)
Furthermore rename utf8_string to short_string.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-28 15:47:07 +02:00
Péter Gál 51aee962a4 Fix inline errors with fPIC (#4078)
In case of `-fPIC` and single file build one of the Regexp's method
raises an error during linking:

```
ecma-regexp-object.c: In function ‘ecma_regexp_run’:
re-bytecode.c:258:1: error: inlining failed in call to ‘always_inline’ ‘re_get_value’:
 function body can be overwritten at link time
```

By adding the `inline` keyword for the method the build error can be resolved.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-28 14:36:45 +02:00
Robert Fancsik dbea5e6a22 Indentifier should be expected after static in class body. (#4061)
This patch fixes #4055.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 10:58:09 +02:00
Robert Fancsik 2e2b0dafb0 Fix scope stack lookup for literal indices (#4067)
This patch fixes #4051.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 10:55:13 +02:00
Robert Fancsik 4d5757d1b1 Fix argument list end validation after destructuring argument (#4070)
This patch fixes #4050.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 10:53:08 +02:00
Dániel Bátyai edab1964c2 Improve source file handling in jerry-main (#4037)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-28 10:51:16 +02:00
Dániel Bátyai 20f83d963b Fix a use-after-free in RegExp.prototype.compile (#4068)
Fixes #4056.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-28 10:47:37 +02:00
Robert Fancsik 7e0b478fe9 Update Array.prototype.concat error handling to ES11 (#4071)
This patch fixes #4044.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 10:45:51 +02:00
Robert Fancsik d420811a0e BoundFunctions [[Length]] property should be ecma_number_t (#4072)
This patch fixes #4043.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 10:45:01 +02:00
Robert Fancsik 9872c441e3 Fix invalid destructuring function arguments parsing (#4074)
This patch fixes #4016 and fixes #4019.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-28 10:41:45 +02:00
Péter Gál 227007eda7 Fix TypedArray construction with incorrect offset (#4075)
In case of a TypedArray the input `byteOffset` argument must be a
multiple of the `BYTES_PER_ELEMENT` value.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-27 20:05:51 +02:00
Péter Gál 435c9cadcf Correctly free descriptors in Object.assign (#4069)
The property descriptors must be free'd during the iteration in the
Object.assign even if the property is not enumerable (or there is no value/getter).

Fixes: #4048

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-27 19:47:55 +02:00
Robert Fancsik 9a026f54ac Fix error handling in SetIntegrityLevel (#4064)
This patch fixes #4052.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-27 19:38:58 +02:00
Robert Fancsik daa409a09a Remove invalid assertion from parser_flush_cbc (#4063)
This patch fixes #4054.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-27 19:38:19 +02:00
Robert Fancsik 39e2bc4df4 Fix new.target saving in OrdinaryObject.[[Construct]] (#4060)
This patch fixes #4059.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-27 19:32:54 +02:00
Szilagyi Adam ff36f3579d Implement %TypedArray%.prototype.includes (#4025)
The algorithm is based on ECMA-262 v11, 22.2.3.13

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-27 18:09:39 +02:00
Szilagyi Adam ff47c84bc4 Rework Object's [[OwnPropertyKeys]] (#4001)
I've removed the ecma_op_object_get_property_names method, and implemented the following ones:
- ecma_op_object_own_property_keys: this is now the internal [[OwnPropertyKeys]] method
- ecma_op_object_enumerate: this is used for the for-in iterator
- ecma_object_sort_property_names: this is used for sorting the property names of an object
- ecma_object_list_lazy_property_names: this is for getting the lazy instantiated properties
- ecma_object_prop_name_is_duplicated: this is for checking if a given property is duplicated in an object

Also the for-in operation with Proxy object works with this patch, #3992 should be closed

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-27 11:37:04 +02:00
Dániel Bátyai 3f0f9589c4 Fix the length values of Promise built-in functions (#4041)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-27 11:07:25 +02:00
Robert Fancsik 11c2ae30d1 Invalid regexp patterns should not throw syntax error during parsing (#4038)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-27 09:28:26 +02:00
Szilagyi Adam da5b058dec Fix argument boundary check order during number format conversion (#4031)
Also added some tests related to the issues caused by the wrong order

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-24 15:55:12 +02:00
kisbg d39a076b2e Added RegExp dotAll flag (#4000)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-07-24 13:42:57 +02:00
Dániel Bátyai cf097ca16b Fix values of properties that reference intrinsic function objects (#4024)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-24 12:54:54 +02:00
Szilagyi Adam 54bfd2ba37 Implement Promise.prototype.onFinally (#3987)
The algorith is based on ECMA-262 v11, 25.6.5.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-24 12:54:16 +02:00
Csaba Osztrogonác 539928dbdb Fix date-construct.js test (#4020)
Removed an undeterministic subtest.

date-construct.js fails intermittently, because it expects that
two Date() calls return the same date string. But the second one
can be 1 second later. This subtest is undeterministic and already
covered by test262/es2015/test/built-ins/Date/S15.9.2.1_A2.js with
1 second epsilon.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-07-24 12:48:31 +02:00
Tóth Béla 2f2a4e066c Implement String.padStart and String.padEnd (#3999)
Based on: https://tc39.es/ecma262/#sec-string.prototype.padstart

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
2020-07-24 11:24:18 +02:00
Robert Fancsik f596211553 Fix tagged template literal call precedence for new operator (#3998)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-24 11:22:09 +02:00
Mátyás Mustoha fdb5d893bf Update Mbed OS target to 5.15.4 (#4035)
JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha matyas.mustoha@h-lab.eu
2020-07-23 13:35:54 +02:00
Zoltan Herczeg d92d9db40f Fix property name comparison when external strings are used. (#4033)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-22 15:17:39 +02:00
Rafal Walczyna a4952da831 Change heap sort to merge sort for Array.prototype (#4026)
ES11 requires Array.prototype.sort to be stable

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-07-22 13:33:07 +02:00
Zoltan Herczeg 0124368ae7 Implement external strings. (#4028)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-22 12:27:12 +02:00
Szilagyi Adam 04f0a7a670 Add missing error check to ecma_builtin_regexp_prototype_compile (#4022)
Fixes #4017

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-21 16:06:35 +02:00
Dániel Bátyai 1eef69f24d Update lastIndex handling in RegExpBuiltinExec (#4010)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-21 15:13:51 +02:00
Dániel Bátyai 69f6bc6566 Fix word boundary assertions with both unicode and ignoreCase flags (#4008)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-07-21 15:13:06 +02:00
Daniella Barsony 12ee41602e Add custom Regexp.prototype dispatcher (#3979)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-07-21 12:46:59 +02:00
Szilagyi Adam 2fac7cc85e Refactor Number.prototype methods toFixed, toExponential, toPrecision (#3911)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-21 12:46:03 +02:00
Csaba Osztrogonác fee3c295a2 Fix test262 excludelist updater (#4023)
The previous fix was buggy, header and footer shouldn't be duplicated.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-07-20 19:09:44 +02:00
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
Szilagyi Adam 33359ac506 Implement UnicodeEscape abstract method (#3959)
Also refactored ecma_builtin_json_quote to use the method above

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-20 13:51:06 +02:00
Csaba Osztrogonác b162e27418 Fix test262 excludelist updater (#4021)
tools/run-tests.py --test262-es2015 update shouldn't
remove comments and newlines in the excludelist file.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-07-20 13:47:45 +02:00
Szilagyi Adam e8c5c46894 Implement Symbol.prototype.description (#3995)
The algorithm is based on ECMA-262 v11, 19.4.3.2

Also added a custom dispatcher for the Symbol prototype

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-20 13:47:25 +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
kisbg dfd9d4497a Implement nullish coalescing operator (#3997)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-07-17 15:42:51 +02:00
Csaba Osztrogonác f60e16d9d5 Fix GetCapabilitiesExecutor function (#4006)
Changes:
- Remove false assert, executor can be invoked by 0 or 1 parameters too
- Update steps and spec references

Already covered by test262 (ESnext) tests:
- built-ins/Promise/*/capability-executor-called-twice.js
- built-ins/Promise/*/capability-executor-not-callable.js

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác csaba.osztrogonac@h-lab.eu
2020-07-16 16:05:48 +02:00
Szilagyi Adam 604cfaced4 Implement Array.prototype.includes (#3991)
The algorithm is based on ECMA-262 v11, 22.1.3.13

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-15 19:21:24 +02:00
Péter Gál c8d15ddbf7 Date.protoype.toJSON should look for toISOString once (#3996)
The toJSON method should be searched on the `this` object
only once. In case of normal objects there were no problems
however when a Proxy object is used as the `this` argument
for the Date.prototype.toJSON method the Proxy's `get` method
was invoked twice.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-15 17:12:55 +02:00
Roland Takacs 8fdbc6a85b Implement Object.{entries, values} built-in methods (#3993)
Object.keys also updated to follow the ES11 standard.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-07-14 15:59:40 +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
Mátyás Mustoha 870a3d3ffb Update the NuttX-STM32 documentation (#3986)
Fixed and updated some of the repository locations and the
relevant build commands.

- Updating `stlink` fixes a CMake build error on the 1.5.1 branch
- Updating the `kconfig` build command allows creating `kconfig-tweak`,
  which fixes a warning during the NuttX configuration

JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2020-07-10 16:09:13 +02:00
Robert Fancsik 37906baa25 Rework promise internal structures (#3985)
- Capabilities
- Promise all resolver

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-10 16:08:34 +02:00
Szilagyi Adam dfabfe7a56 Add missing isArray checks based on the ES11 standard (#3983)
Added checks to the following methods:
- ecma_builtin_json_stringify, ECMA-262 v11, 24.5.2
- ecma_builtin_json_internalize_property, ECMA-262 v11, 24.5.1.1

Fixes #3945
Fixes #3950

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-10 16:06:27 +02:00
Robert Fancsik b90fa63255 LEXER_ASSIGN_GROUP_EXPR should not be emitted when parsing LHS expression (#3990)
This patch fixes #3935.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-10 08:35:33 +02:00
Roland Takacs 35e1e98008 Fix Object.assign to call [[GetOwnProperty]] Proxy handler only once (#3988)
Removed the enumerable option when listing properties to prevent an extra
[[GetOwnProperty]] function call for Proxy objects.
In this case all the property names are collected, but the Object.assign()
implementation has already taken care of the enumerable property filtering.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-07-09 10:23:43 +02:00
Péter Gál ae5cfae3e7 Implement ToPropertyKey operation (#3966)
From ES 6 the ToPropertyKey operation is used to convert elements to a valid property key.
This "new" method uses the ToPrimitive operation which can call the `@@ToPrimitive`
well-known symbol to convert the given element to a key.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-06 15:17:18 +02:00
Csaba Osztrogonác ed9e3eccf9 Make Date constructor conform to the latest spec (#3972)
Date constructor called with 1 argument should accept Date objects too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-06 14:47:10 +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
László Langó 7353b253ab Fixed memory leak in %TypedArray%.prototype object's 'sort' routine. (#3981)
The buffer of values were not freed properly when an exception was
thrown in the compare function.

Fixes #3975

JerryScript-DCO-1.0-Signed-off-by: László Langó lango@inf.u-szeged.hu
2020-07-06 13:42:27 +02:00
Csaba Osztrogonác b6183baf84 Fix tools/runners/run-test-suite.py with Python 3.6 (#3982)
text parameter of Popen introduced in Python 3.7,
we should use the equivalent universal_newlines.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-06 13:38:50 +02:00
Szilagyi Adam 69f917650e Update parser early return type in ESNEXT (#3742)
This patch updates the early return types in the parser to SyntaxError instead of ReferenceError
in ESNEXT

This patch also includes a lot of tests for LeftHandSideExpression validation when using the = operator

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-06 13:36:28 +02:00
Szilagyi Adam 97fc48132a Use the Invoke method where the ES10 standard says (#3963)
We can apply this change to methods which use older standards, because
of the backward compatibility the result is the same

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-06 09:05:04 +02:00
Csaba Osztrogonác 5f951bb4f1 Fix TimeWithinDay(t) abstract operation (#3974)
Fixes #3973.

TimeWithinDay(t) = t modulo msPerDay, where msPerDay = 86400000.
The sign of the modulo operation result should be same as the right side
per definition, conseqently TimeWithinDay(t) >= 0.

References:
- https://www.ecma-international.org/ecma-262/11.0/#sec-mathematical-operations
- https://www.ecma-international.org/ecma-262/11.0/#sec-overview-of-date-objects-and-definitions-of-abstract-operations

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-06 08:12:07 +02:00
Szilagyi Adam 392ee71712 Remove ECMA_TRY_CATCH macro (#3829)
also refactored the touched methods a little bit

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-03 15:06:49 +02:00
Robert Fancsik 19ecd8717f Fix property redefinition (#3970)
The previously allocated property should not be deleted only it's type should be change.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-03 14:13:47 +02:00
Robert Fancsik f98d7f24a7 Support super property reference in object methods/accessors (#3940)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-07-03 12:16:23 +02:00
Zoltan Herczeg 80716cca90 Implement missing async function and async iterator prototypes. (#3962)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-03 11:04:27 +02:00
Zsolt Borbély f86b78a886 Fix the configuration of stack measurement in jerry-test (#3971)
Build command via CMake parameter:
```
tools/build.py --jerry-cmdline-test=on --cmake-param=-DJERRY_TEST_STACK_MEASURE=ON --compile-flag=-static
```

Build command via compile flag:
```
tools/build.py --jerry-cmdline-test=on --compile-flag=-DJERRY_TEST_STACK_MEASURE=1 --compile-flag=-static
```

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2020-07-02 17:12:13 +02:00
Zoltan Herczeg 9e18ff29c6 Implement ... support for object initializers. (#3968)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-02 15:04:21 +02:00
Péter Gál eb77f96d20 Add simple stack measure for jerry-test (#3717)
This change introduces simple stack measuring by coloring the stack
before doing the actual JS work.

The dynamic linking should be avoided as it will use the stack during
the symbol resolving.

At this moment the `JERRY_STACK_MEASURE` compile time define will enable
the measurement for the jerry-test binary.

A usable build configuration:

```
./tools/build.py --jerry-cmdline-test=on --compile-flag=-DJERRY_STACK_MEASURE=1 --compile-flag=-static
```

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-02 11:54:52 +02:00
Szilagyi Adam cd1e067671 Update Promise.race and Promise.all to ES11 (#3954)
Changes based on ECMA-262 v11, 25.6.4.4 and 26.6.4.1 step 3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-07-02 11:46:07 +02:00
Péter Gál 55d6637da5 Fix Date.prototype[@@toPrimitive] hint handling (#3967)
The Date.prototype[@@toPrimitive] only allows the "string", "default" and "number"
hint values. Any other value should throw a TypeError.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-02 11:40:08 +02:00
Csaba Osztrogonác e943d12286 Speedup AppVeyor CI runtime (#3965)
There is no good reason to test JERRY_DEBUGGER=OFF configuration too,
because debugger itself contains Windows specific codepath. If the
build works with debugger, it has to work without debugger too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-01 19:51:58 +02:00
Péter Gál 0c61aee597 Improve the JSON C API (#3943)
* Added more details into documentation.
* Moved the C unit-test into its own file.
* Added extra test cases.
* Extended the API reference documentation with doctests.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-01 14:50:39 +02:00
Péter Gál ca12a8f8f4 Fix JSON.stringify empty array replacer handling (#3938)
In case of an empty array is used as a replacer for the JSON.stringify,
the output string should not contain any keys.

Fixes: #3926

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-07-01 12:41:34 +02:00
Zoltan Herczeg 6389816f67 Implement AsyncIteratorClose for for-await-of statement. (#3955)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-07-01 12:40:39 +02:00
Roland Takacs dc3165533e Support symbol property names in Object.defineProperties (#3933)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-07-01 12:38:20 +02:00
Csaba Osztrogonác 0deeb39ebf Fix Object.prototype.toLocaleString() and Array.prototype.toLocaleString() (#3953)
Since ES6 Object.prototype.toLocaleString() shouldn't call ToObject() and
Array.prototype.toLocaleString() shouldn't call ToObject() for each element.
References:
- https://www.ecma-international.org/ecma-262/11.0/index.html#sec-array.prototype.tolocalestring
- https://www.ecma-international.org/ecma-262/11.0/index.html#sec-object.prototype.tolocalestring

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-01 12:05:54 +02:00
Csaba Osztrogonác 1064b19cfb Class accessors shouldn't be enumerable. (#3961)
Reference:
https://www.ecma-international.org/ecma-262/11.0/index.html#sec-runtime-semantics-classdefinitionevaluation 21.a,b

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-01 12:03:49 +02:00
Csaba Osztrogonác b57e9cbc27 Symbol.prototype[Symbol.toPrimitive].length should be 1 (#3960)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-07-01 08:54:58 +02:00
Zoltan Herczeg 37049c4968 Support catch statement without argument. (#3956)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-30 18:00:40 +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
Mátyás Mustoha 3e866258db Update NuttX to 9.0 on Travis (#3958)
Update the Travis builds to use NuttX 9.0, which was
released on April 26, 2020.

JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2020-06-30 15:53:29 +02:00
Ruzsinszki Gábor ed6689ab8f Adds support for compiling with MSYS and MINGW under windows (#3949)
JerryScript-DCO-1.0-Signed-off-by: Ruzsinszki Gábor ruzsinszki.gabor@gmail.com
2020-06-30 14:07:08 +02:00
Zoltan Herczeg cd949d9d64 Rework flags representing arrow functions and complex arguments (#3957)
This allows detecting cases which was not possible before.

Fixes #3944

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-30 14:00:35 +02:00
Csaba Osztrogonác 122480aa61 JERRY_BUILTIN_xxx macros should depend on JERRY_ESNEXT (#3920)
JERRY_BUILTIN_xxx (ES2015+) features don't build without enabling
JERRY_ESNEXT macro, this invalid configuration shouldn't be allowed.
Additionally remove unnecessary JERRY_ESNEXT ifdef guards.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-30 13:54:50 +02:00
Szilagyi Adam c0b594fa69 Remove duplicate is_object check when calling ecma_op_to_primtive (#3899)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-30 13:18:40 +02:00
Roland Takacs 034b3b63f5 Correct Object.keys to collect only enumerable property names (#3952)
In case of Proxy objects, there were no property descriptor checks when
collecting enumerable properties. Therefore, all the non-enumerable
Proxy.target properties were listed as well.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-06-30 13:13:18 +02:00
Csaba Osztrogonác 89342ea503 Make test262-es2015 output more verbose (#3924)
It makes easier to debug unexpected failures on the CI.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-30 12:47:54 +02:00
Zoltan Herczeg 5535ea88ac Implement for-await-of statement. (#3946)
AsyncIteratorClose has not supported yet.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-30 11:21:50 +02:00
Zoltan Herczeg 0b404ea893 Support caching of next method in for-of and built-in methods. (#3939)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-26 14:47:39 +02:00
Csaba Osztrogonác 264bb210c1 Fix profile file parsing in CMake (#3932)
Changes:
- Comment can be started anywhere, not only at the beginning of the input.
- The end of the comment isn't the end of the input, but the first newline.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-26 13:46:08 +02:00
Dániel Bátyai 2523323310 Simplify resource name handling (#3929)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-26 12:10:14 +02:00
Zoltan Herczeg b7e3baeecb Support caching of next method in generators. (#3937)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-26 12:09:36 +02:00
Zoltan Herczeg f88489beef Implement yield* operator (#3923)
Missing features:
- caching next() method (this also true for normal generators)
- automatic sync to async generator conversion

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-25 17:11:16 +02:00
Péter Gál c12c60c550 Fix DataView argument handling in case of undefined value (#3930)
The DataView's third argument incorrectly processed the "undefined"
value resulting in a RangeError.

Fixes: #3927

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-06-25 14:05:08 +02:00
Roland Takacs ae17c1184c Implement Object.getOwnPropertyDescriptors built-in method (#3921)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-06-25 12:08:46 +02:00
Zoltan Herczeg 5d8c5f3e92 Support comma after last argument for function declarations (#3910)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-24 10:41:03 +02:00
Rafal Walczyna e64fc9aca9 Remove "arguments" and "caller" from specific functions (#3918)
As stated in ES 16.1, "arguments" and "caller" must not be created in:
- strict functions created using the Function constructor
- generator functions created using the Generator constructor
- async functions created using the AsyncFunction constructor
- functions created using the bind

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-06-22 19:08:13 +02:00
Csaba Osztrogonác 281635cb40 Fix the types of builtin prototype objects (#3922)
ES2015 spec made an incompatible change, many builtin prototypes became
no longer valid instances of their respective classes. But unfortunately
it broke the web, so ES2016 reverted String, Boolean and Number prototype
to the original behaviour (ES5.1). JerryScript should match the latest spec.

references:
- ES11 19.3.3 Properties of the Boolean Prototype Object
- ES11 20.1.3 Properties of the Number Prototype Object
- ES11 21.1.3 Properties of the String Prototype Object

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-22 16:31:13 +02:00
Zoltan Herczeg 8ccccd9705 Fix a few small issues in generators (#3919)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-22 13:55:33 +02:00
Zoltan Herczeg b2a6109430 Implement async generators (#3916)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-22 13:54:18 +02:00
Szilagyi Adam 0f0041d720 Make the Set.prototype values, keys and [@@iterator] methods to be one intrinsic method (#3777)
After this patch these methods will be the same function objects

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-18 13:59:31 +02:00
Szilagyi Adam 16750e8171 Use stringbuilder in ecma_builtin_helper_object_to_string (#3807)
Also added steps 4-6 from ECMA-262 v6, 19.1.3.6

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-18 13:55:55 +02:00
kisbg 6a877185fe Added new target support for dataview object (#3764)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-06-18 13:53:30 +02:00
Robert Fancsik fb6ea035d3 Fix signed-off check in tolerant mode (#3915)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-18 13:04:46 +02:00
Szilagyi Adam 5e34a5e978 Refactor ecma_builtin_global_object_decode_uri_helper (#3895)
The main change is the usage of stringbuilder

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-18 11:19:52 +02:00
Szilagyi Adam 0fa07c1275 Refactor ecma_builtin_global_object_encode_uri_helper (#3890)
The main change is the usage of stringbuilder

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-18 11:11:19 +02:00
Szilagyi Adam 59b8e91c39 Refactor ecma_builtin_global_object_escape (#3887)
The main change is the usage of stringbuilder

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-18 11:10:06 +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
Robert Fancsik e0b2f8e0d8 Extend CI list with Github actions (#3905)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-17 17:19:05 +02:00
Daniella Barsony 5d6467930a Add custom dispatcher to Set/Map/WeakSet/WeakMap (#3790)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-06-17 16:07:02 +02:00
Csaba Osztrogonác c55a0baaf8 Improve test262 ES2015 runner (#3892)
Changes:
 - Add options to the test runner to be able to update exclude list
 - Update the exclude list
 - Make Travis CI signal if the exclude list isn't up-to-date

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-17 15:42:51 +02:00
Zoltan Herczeg b1912e7224 Fix async function call parsing. (#3909)
The "async" identifier processing is delayed until it is detected that it cannot
be part of an arrow expression. The "async" identifier should be processed at this
point, but it was not happened in this case.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-17 15:35:02 +02:00
Zoltan Herczeg 8e010146a9 Reduce try context stack consumption to 1 from 2. (#3898)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-17 14:39:53 +02:00
Rafal Walczyna 5bcb78482a Remove arguments and caller properties from ArrowFunction (#3906)
As stated in ES11 16.1, ArrowFunction should not have caller and arguments
properties.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-06-17 13:01:16 +02:00
Robert Fancsik cc4ac497b7 Merge jerry-test-suite into jerry tests (#3907)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-17 13:00:41 +02:00
Zoltan Herczeg 8719f72e61 Implement async function execution. (#3897)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-17 12:08:01 +02:00
Daniella Barsony eb8e81d682 Add Generator Prototype custom dispatcher (#3864)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-06-17 11:23:53 +02:00
Csaba Osztrogonác b469f0e9a8 Documentation typo fixes (#3904)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-16 18:54:36 +02:00
Zoltan Herczeg 1b2e0aec8c Create extend byte code flags with function types. (#3802)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-15 13:40:55 +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 c0270c4887 Update API version to 2.4 (#3900)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-12 14:46:59 +02:00
3159 changed files with 133112 additions and 91788 deletions
+87
View File
@@ -0,0 +1,87 @@
---
Language: Cpp
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: AllDefinitions
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '<windows.h>'
Priority: 0
- Regex: '<[-./a-z]*>'
Priority: 1
- Regex: '"jerryscript[-.a-z]*"'
Priority: 2
- Regex: '"ecma[-.a-z]*"'
Priority: 3
- Regex: '.*'
Priority: 4
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Always
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Auto
StatementMacros:
- JERRY_ASSERT
- JERRY_STATIC_ASSERT
- JERRY_UNREACHABLE
TabWidth: 0
UseCRLF: false
UseTab: Never
...
+401
View File
@@ -0,0 +1,401 @@
name: JerryScript CI
on: [push, pull_request]
env:
RUNNER: tools/run-tests.py
jobs:
Checks:
runs-on: ubuntu-22.04 # needed for checker version stability
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- run: sudo apt update
- run: sudo apt install pylint doxygen cppcheck clang-format-15
- run: $RUNNER --check-signed-off=gh-actions
if: ${{ always() }}
- run: $RUNNER --check-doxygen
if: ${{ always() }}
- run: $RUNNER --check-format
if: ${{ always() }}
- run: $RUNNER --check-license
if: ${{ always() }}
- run: $RUNNER --check-strings
if: ${{ always() }}
- run: $RUNNER --check-pylint
if: ${{ always() }}
- run: $RUNNER --check-cppcheck
if: ${{ always() }}
Linux_x86-64_Build_Correctness_Debugger_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER -q --jerry-tests
- run: $RUNNER -q --jerry-tests --build-debug
- run: $RUNNER -q --jerry-debugger
- run: $RUNNER -q --jerry-debugger --build-debug
Linux_x86_cpointer-32bit_Build_Correctness_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: $RUNNER -q --jerry-tests --buildoptions=--compile-flag=-m32,--cpointer-32bit=on
- run: $RUNNER -q --jerry-tests --buildoptions=--compile-flag=-m32,--cpointer-32bit=on --build-debug
Win_x86-64_Conformance_Tests_ESNext:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: python $env:RUNNER --test262 update
Win_x86-64_Conformance_Tests_ESNext_Debug:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: python $env:RUNNER --test262 update --build-debug
Win_x86-64_Tests-MINGW:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: >-
mingw-w64-x86_64-python
mingw-w64-x86_64-cmake
mingw-w64-x86_64-make
mingw-w64-x86_64-toolchain
- run: python $RUNNER -q --jerry-tests
- run: python $RUNNER -q --unittests --build-config=''
# FIXME: enable it with upgrade valgrind - run: python $RUNNER -q --buildoption-test
Win_x86-64_Tests:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: python $env:RUNNER -q --jerry-tests
- run: python $env:RUNNER -q --unittests
- run: python $env:RUNNER -q --buildoption-test
Win_x86-64_Tests_Debug:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- run: python $env:RUNNER -q --jerry-tests --build-debug
- run: python $env:RUNNER -q --unittests --build-debug
- run: python $env:RUNNER -q --buildoption-test --build-debug
OSX_x86-64_Build_Correctness_Unit_Tests:
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER -q --jerry-tests
- run: $RUNNER -q --unittests
OSX_x86-64_Build_Correctness_Unit_Tests_Debug:
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER -q --jerry-tests --build-debug
- run: $RUNNER -q --unittests --build-debug
Linux_x86-64_Build_Option_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: $RUNNER --buildoption-test
Conformance_Tests_ESNext:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER --test262 update
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Test262-ESNext-results
path: |
build/tests/test262_tests_esnext/local/bin/test262.report
Conformance_Tests_ESNext_Debug_A:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER --test262 update --build-debug --test262-test-list=built-ins,annexB,harness,intl402
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Test262-ESNext-Debug-A-results
path: |
build/tests/test262_tests_esnext-debug/local/bin/test262.report
Conformance_Tests_ESNext_Debug_B:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER --test262 update --build-debug --test262-test-list=language
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Test262-ESNext-Debug-B-results
path: |
build/tests/test262_tests_esnext-debug/local/bin/test262.report
Unit_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: $RUNNER -q --unittests
- run: $RUNNER -q --unittests --build-debug
Clang_Unit_Build_Option_Tests:
runs-on: ubuntu-latest
env:
CC: clang
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: $RUNNER -q --unittests
# clang has bug in supporting lto
- run: $RUNNER -q --buildoption-test --buildoptions=--lto=off
ASAN_Tests:
runs-on: ubuntu-latest
env:
ASAN_OPTIONS: detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: >-
$RUNNER -q --jerry-tests
--buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4870.js,regression-test-issue-4901.js,regression-test-issue-4848.js,regression-test-issue-4890.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js,proxy-evil-recursion.js,regression-test-issue-5101.js
ASAN_Tests_Debug:
runs-on: ubuntu-latest
env:
ASAN_OPTIONS: detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: >-
$RUNNER -q --jerry-tests --build-debug
--buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4870.js,regression-test-issue-4901.js,regression-test-issue-4848.js,regression-test-issue-4890.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js,proxy-evil-recursion.js,regression-test-issue-5101.js
UBSAN_Tests:
runs-on: ubuntu-latest
env:
UBSAN_OPTIONS: print_stacktrace=1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: >-
$RUNNER -q --jerry-tests
--buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
--skip-list=parser-oom.js,parser-oom2.js
- run: >-
$RUNNER -q --jerry-tests --build-debug
--buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
--skip-list=parser-oom.js,parser-oom2.js
Linux_ARMv7l_Tests:
runs-on: ubuntu-latest
env:
RUNTIME: qemu-arm-static
TIMEOUT: 300
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
- run: >-
$RUNNER -q --jerry-tests
--buildoptions=--toolchain=cmake/toolchain_linux_armv7l.cmake,--linker-flag=-static
Linux_ARMv7l_Tests_Debug:
runs-on: ubuntu-latest
env:
RUNTIME: qemu-arm-static
TIMEOUT: 300
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
- run: >-
$RUNNER -q --jerry-tests --build-debug
--buildoptions=--toolchain=cmake/toolchain_linux_armv7l.cmake,--linker-flag=-static
Linux_AArch64_Tests:
runs-on: ubuntu-latest
env:
RUNTIME: qemu-aarch64-static
TIMEOUT: 300
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-aarch64-linux-gnu libc6-dev-armhf-cross qemu-user-static
- run: >-
$RUNNER -q --jerry-tests
--buildoptions=--toolchain=cmake/toolchain_linux_aarch64.cmake,--linker-flag=-static
Linux_AArch64_Tests_Debug:
runs-on: ubuntu-latest
env:
RUNTIME: qemu-aarch64-static
TIMEOUT: 300
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-aarch64-linux-gnu libc6-dev-armhf-cross qemu-user-static
- run: >-
$RUNNER -q --jerry-tests --build-debug
--buildoptions=--toolchain=cmake/toolchain_linux_aarch64.cmake,--linker-flag=-static
MbedOS_K64F_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-arm-none-eabi ninja-build
- run: make -f ./targets/os/mbedos/Makefile.travis install
- run: make -f ./targets/os/mbedos/Makefile.travis script
Zephyr_STM32F4_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gperf dfu-util device-tree-compiler
- run: make -f ./targets/os/zephyr/Makefile.travis install
- run: make -f ./targets/os/zephyr/Makefile.travis script
NuttX_STM32F4_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.6'
- run: sudo apt update
- run: sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi gperf
- run: make -f ./targets/os/nuttx/Makefile.travis install-noapt
- run: make -f ./targets/os/nuttx/Makefile.travis script
RIOT_STM32F4_Build_Test:
runs-on: ubuntu-latest
env:
CC: clang
steps:
- uses: actions/checkout@v2
- run: sudo apt -y install clang gcc-arm-none-eabi
- run: make -f ./targets/os/riot/Makefile.travis install-noapt
- run: make -f ./targets/os/riot/Makefile.travis script
ESP8266_RTOS_SDK_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '>=3.8'
- run: make -f ./targets/baremetal-sdk/espressif/esp8266-rtos-sdk/Makefile.travis install-noapt
- run: make -f ./targets/baremetal-sdk/espressif/esp8266-rtos-sdk/Makefile.travis script
ESP_IDF_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '==3.8'
- run: make -f ./targets/baremetal-sdk/espressif/esp-idf/Makefile.travis install-noapt
- run: make -f ./targets/baremetal-sdk/espressif/esp-idf/Makefile.travis script
Notification:
runs-on: ubuntu-latest
if: false && github.event_name == 'push' && github.repository == 'jerryscript-project/jerryscript'
steps:
- uses: rectalogic/notify-irc@v1
with:
channel: '#jerryscript'
nickname: jerryscript-notification
message: |
@${{ github.actor }}: ${{ github.repository }} (${{ github.ref }}#${{ github.sha }})
${{ join(github.event.commits.*.message) }}
${{ github.event.compare }}
-180
View File
@@ -1,180 +0,0 @@
language: c
# Default environment: Ubuntu Bionic 18.04.
os: linux
dist: bionic
# Default job task: run tests as defined in the $OPT environment variable.
# Jobs can redefine the 'script' stage in the matrix below.
script: tools/run-tests.py $OPTS
# All the job definitions in the matrix.
matrix:
include:
- name: "Checks"
script:
- tools/run-tests.py --check-signed-off=travis --check-doxygen --check-vera --check-license --check-magic-strings --check-pylint
- travis_wait 40 tools/run-tests.py --check-cppcheck
addons:
apt:
packages: [doxygen, cppcheck, vera++, pylint]
- name: "Linux/x86-64 Build, Correctness & Debugger Tests"
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --jerry-debugger"
- name: "Linux/x86 (cpointer-32bit) Build & Correctness Tests"
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --buildoptions=--compile-flag=-m32,--cpointer-32bit=on"
addons:
apt:
packages: [gcc-multilib]
- name: "Linux/ARM Build & Correctness Tests"
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake --buildoptions=--linker-flag=-static"
- RUNTIME=qemu-arm-static
- TIMEOUT=300
addons:
apt:
packages: [gcc-arm-linux-gnueabihf, libc6-dev-armhf-cross, qemu-user-static]
- name: "Linux/AArch64 Native Build & Correctness Tests"
arch: arm64
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --buildoptions=--linker-flag=-static"
- TIMEOUT=300
- name: "OSX/x86-64 Build, Correctness & Unit Tests"
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --unittests"
os: osx
osx_image: xcode11.4
addons:
homebrew:
packages: [cmake, cppcheck, vera++]
- name: "Build Tests"
env:
- OPTS="--buildoption-test"
addons:
apt:
packages: [gcc-multilib]
- name: "Conformance Tests - ES5.1"
env:
- OPTS="--test262"
- name: "Conformance Tests - ES2015"
env:
- OPTS="--test262-es2015"
- name: "Unit Tests"
env:
- OPTS="--unittests"
- name: "ASAN Tests"
env:
# Skipping maximum stack usage related tests due to 'detect_stack_use_after_return=1' ASAN option.
# For more detailed description: https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#compatibility
- OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js --buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold"
- ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
- TIMEOUT=600
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: [gcc-multilib]
- name: "UBSAN Tests"
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js,parser-oom2.js --buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
- TIMEOUT=600
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: [gcc-multilib]
- name: "Coverity Scan & SonarQube"
env:
# Declaration of the encrypted COVERITY_SCAN_TOKEN, created via the
# "travis encrypt" command using the project repo's public key.
- secure: "V7BdXv3FCVkFGEfKfWto6I+Sytou1zTCGyn49xurkBfKNsG/3vbkXfsbK1m6lCZxmY7W/1odpfjixpAPZgy2L4FgPZK6/UyVvC8pIFjDOubcEniN48haleSvm/ZFPLDifxDL2+VVFtK1oRYPtDBzzSoUCcfwovgk+Wy+tSBnhnyRLqO/WaI6PqFof7ECYMTRlJVjioZARVP4YmkBruIPmGDdR/3EvwowlxfuiFoPheix61ug4x3tpTBW2qWgvFjDyCZXFz4pJrBQPTAIbyKMxHcBykJjl9eR+dWAOsvE1Uw48tFOJxjKDfUttVQUPsyKFllmcCVS0fDYB5pzZOmRUPxJmox1jt8J1FY85Ri1PGY0THBPM2H7to4Yf2418Y3539epbN8p+79dwaM7e2OiJ2owukbWI7PoNqIz5DV5zxpIKsOQfeWuNLJOgsBePEIU7lz133Si/2d5W/7If46B1d+hZRBJfSYksgDqDU6G/voZkPf0K5bKe2O2BxiIW1DYk4yQ1ecZAkqGjZ8jG3zYGMG3mSF4VyuU4UGFG1Pg8fw7Ap5zuHxSVY1H9dtu4T6JQG3aj/x1omlzfw48DjgkwxVhf7Xvl3yfR7pzydYheLX3MZYtcVo7rWnglZFZoUjWDK1StbmzsvPftvwWtoDTWlzo4xeSXhahSJvJyc4U8Wc="
addons:
coverity_scan:
project:
name: "jerryscript-project/jerryscript"
description: "Ultra-lightweight JavaScript engine for the Internet of Things."
notification_email: rsipka.uszeged@partner.samsung.com
build_command: "tools/build.py --clean"
branch_pattern: master
sonarcloud:
organization: "jerryscript-project"
# Coverity Scan has already built the project by the time 'script' stage is reached.
script: tools/check-sonarqube.sh
cache:
directories:
- '${HOME}/.sonar/cache'
- name: "Mbed OS 5/K64F Build Test"
addons:
apt:
sources:
- sourceline: ppa:team-gcc-arm-embedded/ppa
packages: [gcc-arm-embedded]
language: python # NOTE: only way to ensure python>=2.7.10 on Trusty image
python: 3.6
install: make -f ./targets/mbedos5/Makefile.travis install
script: make -f ./targets/mbedos5/Makefile.travis script
- name: "Zephyr/Arduino 101 Build Test"
language: python # NOTE: only way to ensure python>=2.7.10 on Trusty image
python: 3.6
install: make -f ./targets/zephyr/Makefile.travis install-noapt
script: make -f ./targets/zephyr/Makefile.travis script
addons:
apt:
packages: [gperf, dfu-util, device-tree-compiler]
- name: "NuttX/STM32F4 Build Test"
install: make -f targets/nuttx-stm32f4/Makefile.travis install-noapt
script: make -f targets/nuttx-stm32f4/Makefile.travis script
addons:
apt:
packages: [gcc-arm-none-eabi, libnewlib-arm-none-eabi, gperf]
- name: "RIOT/STM32F4 Build Test"
install: make -f ./targets/riot-stm32f4/Makefile.travis install-noapt
script: make -f ./targets/riot-stm32f4/Makefile.travis script
compiler: clang-3.9
addons:
apt:
sources:
- sourceline: ppa:team-gcc-arm-embedded/ppa
packages: [clang-3.9, gcc-arm-embedded, gcc-multilib]
- name: "ESP8266 Build Test"
install: make -f ./targets/esp8266/Makefile.travis install-noapt
script: make -f ./targets/esp8266/Makefile.travis script
addons:
apt:
packages: [wget]
fast_finish: true
# The channel name "chat.freenode.net#jerryscript"
# is encrypted against Samsung/jerryscript
# to prevent IRC spam of forks.
#
# travis encrypt -r "Samsung/jerryscript" "chat.freenode.net#jerryscript"
notifications:
irc:
channels:
- secure: "4kML4uZywOPaT3r/bHCvZCeQWooyzZumESmKuHG2Y8/B29WtMBobsoRQZRfOmlUP5kshfjh0Itp5WFpdACiBCoorHch/8z3VT7fIbKF4UnxrAvNiFArqxXC0OWGIu93e7uyyXJCsQ/JiOXU7bD31Mh8LbnfS1z3wBAMXi+AwcaGiVVH4VTL6O8sR3ij5WmsqpECWhyWTgTP3MiLquZ+09Lv9mp5GGciEemq4p8VnaQt2BdyEBmUJJ1EAyMCJlKNObQudegOzYsY3CVON9C87dCuHf7DYstsxb8AzwRAKn8LHiaWhYaWLfvHqoXmc4w1ZgN0HZ5Qyx8KMkZkXKUiHxuCSoXDxNAHWTGQBsTDid5drZeqOFucOHEKJzkqaWSUKUF3pY/hq/h2kjAn230DlBNkJt+ikSxwy6Mm8GG8LnH5gRMl37zHDHrtyRsKR8GIst9B1B95LAOLA5t8U/ucGKXqLsohS8glXaM4jjh69it3GeHj6NhB8NbC/LsmRrhjKzV+VnjPI6gZvN+5tDiuxMbsMal+0DdWVNCst/aO3Jz0iaA5ahyo2ZwBb2efw3CekRLMKmHtnjqB0SWWXT3/t2+5zNoM6gBjo4RPOg7k5eTOXcfk8okWtQ5d3n8UtvZ5rSiDl3rssHwp1yHuuC8rGGov74DLvyDlpM6p/dmtu2o8="
on_success: always
on_failure: always
use_notice: true
template:
- "%{repository_name} (%{branch}@%{commit}): %{author} - %{commit_subject} [%{result}]"
- "Commit: %{compare_url}"
- "Build: %{build_url}"
+97 -47
View File
@@ -12,19 +12,32 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
cmake_minimum_required (VERSION 2.8.12) cmake_minimum_required (VERSION 3.10)
project (Jerry C) project (Jerry C)
if(NOT DEFINED PYTHON)
set(PYTHON "python")
endif()
# Determining version
execute_process(COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tools/version.py
OUTPUT_VARIABLE JERRY_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Determining platform # Determining platform
set(PLATFORM "${CMAKE_SYSTEM_NAME}") set(PLATFORM "${CMAKE_SYSTEM_NAME}")
string(TOUPPER "${PLATFORM}" PLATFORM) string(TOUPPER "${PLATFORM}" PLATFORM)
# Determining compiler # Determining compiler
if(MSVC)
set(USING_MSVC 1)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU") if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(USING_GCC 1) set(USING_GCC 1)
endif() endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang") # Clang may support for MSVC
if(NOT USING_MSVC AND CMAKE_C_COMPILER_ID MATCHES "Clang")
set(USING_CLANG 1) set(USING_CLANG 1)
endif() endif()
@@ -32,10 +45,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "TI")
set(USING_TI 1) set(USING_TI 1)
endif() endif()
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(USING_MSVC 1)
endif()
# Determining build type # Determining build type
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "MinSizeRel") set(CMAKE_BUILD_TYPE "MinSizeRel")
@@ -46,16 +55,22 @@ set(JERRY_CMDLINE ON CACHE BOOL "Build jerry command line tool?")
set(JERRY_CMDLINE_TEST OFF CACHE BOOL "Build jerry test command line tool?") set(JERRY_CMDLINE_TEST OFF CACHE BOOL "Build jerry test command line tool?")
set(JERRY_CMDLINE_SNAPSHOT OFF CACHE BOOL "Build jerry snapshot command line tool?") set(JERRY_CMDLINE_SNAPSHOT OFF CACHE BOOL "Build jerry snapshot command line tool?")
set(JERRY_LIBFUZZER OFF CACHE BOOL "Build jerry with libfuzzer support?") set(JERRY_LIBFUZZER OFF CACHE BOOL "Build jerry with libfuzzer support?")
set(JERRY_PORT_DEFAULT ON CACHE BOOL "Build default jerry port implementation?") set(JERRY_PORT ON CACHE BOOL "Build default jerry port implementation?")
set(JERRY_EXT ON CACHE BOOL "Build jerry-ext?") set(JERRY_EXT ON CACHE BOOL "Build jerry-ext?")
set(JERRY_LIBM ON CACHE BOOL "Build and use jerry-libm?") set(JERRY_MATH OFF CACHE BOOL "Build and use jerry-math?")
set(UNITTESTS OFF CACHE BOOL "Build unit tests?") set(UNITTESTS OFF CACHE BOOL "Build unit tests?")
set(DOCTESTS OFF CACHE BOOL "Build doc tests?") set(DOCTESTS OFF CACHE BOOL "Build doc tests?")
# Optional build settings # Optional build settings
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?") set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?")
set(ENABLE_LTO ON CACHE BOOL "Enable LTO build?") set(ENABLE_AMALGAM OFF CACHE BOOL "Enable amalgamated build?")
set(ENABLE_STRIP ON CACHE BOOL "Enable stripping all symbols from release binary?") set(ENABLE_LTO ON CACHE BOOL "Enable LTO build?")
set(ENABLE_STRIP ON CACHE BOOL "Enable stripping all symbols from release binary?")
set(ENABLE_COMPILE_COMMANDS ON CACHE BOOL "Enable generating compile_commands.json?")
if(USING_MSVC)
set(ENABLE_STATIC_CRT OFF CACHE BOOL "Enable MSVC static CRT?")
endif()
# Option overrides # Option overrides
if(NOT USING_CLANG) if(NOT USING_CLANG)
@@ -65,9 +80,9 @@ if(NOT USING_CLANG)
endif() endif()
if(JERRY_CMDLINE OR JERRY_CMDLINE_TEST OR JERRY_CMDLINE_SNAPSHOT OR JERRY_LIBFUZZER OR UNITTESTS OR DOCTESTS) if(JERRY_CMDLINE OR JERRY_CMDLINE_TEST OR JERRY_CMDLINE_SNAPSHOT OR JERRY_LIBFUZZER OR UNITTESTS OR DOCTESTS)
set(JERRY_PORT_DEFAULT ON) set(JERRY_PORT ON)
set(JERRY_PORT_DEFAULT_MESSAGE " (FORCED BY CMDLINE OR LIBFUZZER OR TESTS)") set(JERRY_PORT_MESSAGE " (FORCED BY CMDLINE OR LIBFUZZER OR TESTS)")
endif() endif()
if(JERRY_CMDLINE OR DOCTESTS) if(JERRY_CMDLINE OR DOCTESTS)
@@ -77,11 +92,17 @@ if(JERRY_CMDLINE OR DOCTESTS)
endif() endif()
if("${PLATFORM}" STREQUAL "DARWIN") if("${PLATFORM}" STREQUAL "DARWIN")
set(JERRY_LIBM OFF)
set(ENABLE_LTO OFF) set(ENABLE_LTO OFF)
set(ENABLE_STRIP OFF) set(ENABLE_STRIP OFF)
set(JERRY_LIBM_MESSAGE " (FORCED BY PLATFORM)") set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)")
endif()
if("${PLATFORM}" STREQUAL "ESP-IDF")
set(ENABLE_LTO OFF)
set(ENABLE_STRIP OFF)
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)") set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)") set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)")
endif() endif()
@@ -93,36 +114,41 @@ if(USING_TI)
endif() endif()
if(USING_MSVC) if(USING_MSVC)
set(JERRY_LIBM OFF)
set(ENABLE_STRIP OFF) set(ENABLE_STRIP OFF)
set(JERRY_LIBM_MESSAGE " (FORCED BY COMPILER)")
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)") set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
endif() endif()
if(CYGWIN) if(CYGWIN OR MINGW OR MSYS)
set(ENABLE_LTO OFF) set(ENABLE_LTO OFF)
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)") set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
endif() endif()
# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ${ENABLE_COMPILE_COMMANDS})
# Status messages # Status messages
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE}) message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID}) message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME}) message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR}) message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS}) message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
message(STATUS "ENABLE_LTO " ${ENABLE_LTO} ${ENABLE_LTO_MESSAGE}) message(STATUS "ENABLE_AMALGAM " ${ENABLE_AMALGAM} ${ENABLE_AMALGAM_MESSAGE})
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP} ${ENABLE_STRIP_MESSAGE}) message(STATUS "ENABLE_LTO " ${ENABLE_LTO} ${ENABLE_LTO_MESSAGE})
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE} ${JERRY_CMDLINE_MESSAGE}) message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP} ${ENABLE_STRIP_MESSAGE})
message(STATUS "JERRY_CMDLINE_TEST " ${JERRY_CMDLINE_TEST} ${JERRY_CMDLINE_TEST_MESSAGE}) message(STATUS "ENABLE_STATIC_CRT " ${ENABLE_STATIC_CRT})
message(STATUS "JERRY_CMDLINE_SNAPSHOT " ${JERRY_CMDLINE_SNAPSHOT} ${JERRY_CMDLINE_SNAPSHOT_MESSAGE}) message(STATUS "ENABLE_COMPILE_COMMANDS " ${ENABLE_COMPILE_COMMANDS})
message(STATUS "JERRY_LIBFUZZER " ${JERRY_LIBFUZZER} ${JERRY_LIBFUZZER_MESSAGE}) message(STATUS "JERRY_VERSION " ${JERRY_VERSION})
message(STATUS "JERRY_PORT_DEFAULT " ${JERRY_PORT_DEFAULT} ${JERRY_PORT_DEFAULT_MESSAGE}) message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE} ${JERRY_CMDLINE_MESSAGE})
message(STATUS "JERRY_EXT " ${JERRY_EXT} ${JERRY_EXT_MESSAGE}) message(STATUS "JERRY_CMDLINE_TEST " ${JERRY_CMDLINE_TEST} ${JERRY_CMDLINE_TEST_MESSAGE})
message(STATUS "JERRY_LIBM " ${JERRY_LIBM} ${JERRY_LIBM_MESSAGE}) message(STATUS "JERRY_CMDLINE_SNAPSHOT " ${JERRY_CMDLINE_SNAPSHOT} ${JERRY_CMDLINE_SNAPSHOT_MESSAGE})
message(STATUS "UNITTESTS " ${UNITTESTS}) message(STATUS "JERRY_LIBFUZZER " ${JERRY_LIBFUZZER} ${JERRY_LIBFUZZER_MESSAGE})
message(STATUS "DOCTESTS " ${DOCTESTS}) message(STATUS "JERRY_PORT " ${JERRY_PORT} ${JERRY_PORT_MESSAGE})
message(STATUS "JERRY_EXT " ${JERRY_EXT} ${JERRY_EXT_MESSAGE})
message(STATUS "JERRY_MATH " ${JERRY_MATH} ${JERRY_MATH_MESSAGE})
message(STATUS "UNITTESTS " ${UNITTESTS})
message(STATUS "DOCTESTS " ${DOCTESTS})
# Setup directories # Setup directories
# Note: This mimics a conventional file system layout in the build directory for # Note: This mimics a conventional file system layout in the build directory for
@@ -183,17 +209,25 @@ endif()
if("${PLATFORM}" STREQUAL "DARWIN") if("${PLATFORM}" STREQUAL "DARWIN")
jerry_add_link_flags(-lSystem) jerry_add_link_flags(-lSystem)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>") if("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
else()
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
elseif(NOT CYGWIN AND (USING_GCC OR USING_CLANG)) elseif((NOT CYGWIN AND NOT MINGW AND NOT MSYS) AND (USING_GCC OR USING_CLANG))
jerry_add_link_flags(-Wl,-z,noexecstack) jerry_add_link_flags(-Wl,-z,noexecstack)
endif() endif()
if(USING_GCC OR USING_CLANG) if(USING_GCC OR USING_CLANG)
jerry_add_compile_flags(-std=c99 -pedantic) jerry_add_compile_flags(-std=c99 -pedantic)
# Turn off stack protector if(JERRY_MATH)
jerry_add_compile_flags(-fno-builtin -fno-stack-protector) jerry_add_compile_flags(-fno-builtin)
jerry_add_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations shadow strict-prototypes undef old-style-definition) endif()
jerry_add_compile_warnings(all extra format-nonliteral init-self sign-conversion format-security missing-declarations shadow strict-prototypes undef old-style-definition)
if(NOT "${PLATFORM}" STREQUAL "WINDOWS")
jerry_add_compile_warnings(conversion)
endif()
jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes -Werror) jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes -Werror)
endif() endif()
@@ -217,6 +251,22 @@ if(USING_MSVC)
jerry_add_link_flags(/OPT:NOREF) jerry_add_link_flags(/OPT:NOREF)
# Disable MSVC warning 4996 globally because it stops us from using standard C functions. # Disable MSVC warning 4996 globally because it stops us from using standard C functions.
jerry_add_compile_flags(/wd4996) jerry_add_compile_flags(/wd4996)
if(ENABLE_STATIC_CRT)
# Replace the existing /MD and /MDd values with /MT and /MTd.
set(COMPILER_FLAGS
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(_flag ${COMPILER_FLAGS})
string(REPLACE "/MD" "/MT" ${_flag} "${${_flag}}")
endforeach()
endif()
endif() endif()
if(JERRY_LIBFUZZER) if(JERRY_LIBFUZZER)
@@ -237,12 +287,12 @@ if(DEFINED EXTERNAL_LINKER_FLAGS)
jerry_add_link_flags(${EXTERNAL_LINKER_FLAGS}) jerry_add_link_flags(${EXTERNAL_LINKER_FLAGS})
endif() endif()
# Used for placeholder to attach single source build targets # Used as placeholder to attach amalgamated build targets to
add_custom_target(generate-single-source) add_custom_target(amalgam)
# Jerry's libm # Jerry's libm
if(JERRY_LIBM) if(JERRY_MATH)
add_subdirectory(jerry-libm) add_subdirectory(jerry-math)
endif() endif()
# Jerry's core # Jerry's core
@@ -254,8 +304,8 @@ if(JERRY_EXT)
endif() endif()
# Jerry's default port implementation # Jerry's default port implementation
if(JERRY_PORT_DEFAULT) if(JERRY_PORT)
add_subdirectory(jerry-port/default) add_subdirectory(jerry-port)
endif() endif()
# Jerry command line tool # Jerry command line tool
@@ -266,8 +316,8 @@ endif()
# Unittests # Unittests
if(UNITTESTS) if(UNITTESTS)
add_subdirectory(tests/unit-core) add_subdirectory(tests/unit-core)
if(JERRY_LIBM) if(JERRY_MATH)
add_subdirectory(tests/unit-libm) add_subdirectory(tests/unit-math)
endif() endif()
if(JERRY_EXT) if(JERRY_EXT)
add_subdirectory(tests/unit-ext) add_subdirectory(tests/unit-ext)
+384 -154
View File
File diff suppressed because it is too large Load Diff
+15 -14
View File
@@ -1,18 +1,17 @@
![](https://github.com/jerryscript-project/jerryscript/blob/master/LOGO.png) ![](https://github.com/jerryscript-project/jerryscript/blob/master/LOGO.png)
# JerryScript: JavaScript engine for the Internet of Things # JerryScript: JavaScript engine for the Internet of Things
[![License](https://img.shields.io/badge/licence-Apache%202.0-brightgreen.svg?style=flat)](LICENSE) [![License](https://img.shields.io/badge/licence-Apache%202.0-brightgreen.svg?style=flat)](LICENSE)
[![Travis CI Build Status](https://travis-ci.org/jerryscript-project/jerryscript.svg?branch=master)](https://travis-ci.org/jerryscript-project/jerryscript) [![GitHub Actions Status](https://github.com/jerryscript-project/jerryscript/workflows/JerryScript%20CI/badge.svg)](https://github.com/jerryscript-project/jerryscript/actions)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/ct8reap35u2vooa5/branch/master?svg=true)](https://ci.appveyor.com/project/jerryscript-project/jerryscript/branch/master)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/12127/badge.svg)](https://scan.coverity.com/projects/jerryscript-project)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript?ref=badge_shield) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript?ref=badge_shield)
[![SonarQube](https://sonarcloud.io/api/project_badges/measure?project=jerryscript-project_jerryscript&metric=ncloc)](https://sonarcloud.io/dashboard?id=jerryscript-project_jerryscript)
[![IRC Channel](https://img.shields.io/badge/chat-on%20freenode-brightgreen.svg)](https://kiwiirc.com/client/irc.freenode.net/#jerryscript) [![IRC Channel](https://img.shields.io/badge/chat-on%20freenode-brightgreen.svg)](https://kiwiirc.com/client/irc.freenode.net/#jerryscript)
JerryScript is a lightweight JavaScript engine for resource-constrained devices such as microcontrollers. It can run on devices with less than 64 KB of RAM and less than 200 KB of flash memory. JerryScript is a lightweight JavaScript engine for resource-constrained devices such as microcontrollers. It can run on devices with less than 64 KB of RAM and less than 200 KB of flash memory.
Key characteristics of JerryScript: Key characteristics of JerryScript:
* Full ECMAScript 5.1 standard compliance * Full ECMAScript 5.1 standard compliance
* 160K binary size when compiled for ARM Thumb-2 * ECMAScript 2025 standard compliance is 70%
* [Kangax Compatibilty Table](https://compat-table.github.io/compat-table/es2016plus/)
* 258K binary size when compiled for ARM Thumb-2
* Heavily optimized for low memory consumption * Heavily optimized for low memory consumption
* Written in C99 for maximum portability * Written in C99 for maximum portability
* Snapshot support for precompiling JavaScript source code to byte code * Snapshot support for precompiling JavaScript source code to byte code
@@ -20,14 +19,6 @@ Key characteristics of JerryScript:
Additional information can be found on our [project page](http://jerryscript.net) and [Wiki](https://github.com/jerryscript-project/jerryscript/wiki). Additional information can be found on our [project page](http://jerryscript.net) and [Wiki](https://github.com/jerryscript-project/jerryscript/wiki).
Memory usage and Binary footprint are measured at [here](https://jerryscript-project.github.io/jerryscript-test-results) with real target daily.
The latest results on **Raspberry Pi 2**:
[![Remote Testrunner](https://firebasestorage.googleapis.com/v0/b/jsremote-testrunner.appspot.com/o/status%2Fjerryscript%2Frpi2.svg?alt=media&token=1)](https://jerryscript-project.github.io/jerryscript-test-results/?view=rpi2)
IRC channel: #jerryscript on [freenode](https://freenode.net)
Mailing list: jerryscript-dev@groups.io, you can subscribe [here](https://groups.io/g/jerryscript-dev) and access the mailing list archive [here](https://groups.io/g/jerryscript-dev/topics). Mailing list: jerryscript-dev@groups.io, you can subscribe [here](https://groups.io/g/jerryscript-dev) and access the mailing list archive [here](https://groups.io/g/jerryscript-dev/topics).
## Quick Start ## Quick Start
@@ -49,7 +40,17 @@ For additional information see [Getting Started](docs/00.GETTING-STARTED.md).
- [Configuration](docs/01.CONFIGURATION.md) - [Configuration](docs/01.CONFIGURATION.md)
- [API Reference](docs/02.API-REFERENCE.md) - [API Reference](docs/02.API-REFERENCE.md)
- [API Example](docs/03.API-EXAMPLE.md) - [API Example](docs/03.API-EXAMPLE.md)
- [Internals](docs/04.INTERNALS.md) - [Port API](docs/05.PORT-API.md)
- [Reference Couting](docs/06.REFERENCE-COUNTING.md)
- [Debugger](docs/07.DEBUGGER.md)
- [Coding Standards](docs/08.CODING-STANDARDS.md)
- [Arguments Extension API](docs/09.EXT-REFERENCE-ARG.md)
- [Property Extension API](docs/10.EXT-REFERENCE-HANDLER.md)
- [Autorelease Extension API](docs/11.EXT-REFERENCE-AUTORELEASE.md)
- [Module Extension API](docs/12.EXT-REFERENCE-MODULE.md)
- [Debugger Transport Interface](docs/13.DEBUGGER-TRANSPORT.md)
- [Scope Extension API](docs/14.EXT-REFERENCE-HANDLE-SCOPE.md)
- [Module System](docs/15.MODULE-SYSTEM.md)
- [Migration Guide](docs/16.MIGRATION-GUIDE.md) - [Migration Guide](docs/16.MIGRATION-GUIDE.md)
## Contributing ## Contributing
-32
View File
@@ -1,32 +0,0 @@
version: "{build}"
branches:
except:
- coverity_scan
- gh_pages
skip_tags: true
# Build matrix setup.
image:
- Visual Studio 2017
configuration:
- Debug
- Release
platform:
- x64
- Win32
environment:
matrix:
- JERRY_DEBUGGER: ON
- JERRY_DEBUGGER: OFF
# Steps of a job.
init:
- cmake -version
before_build:
- if "%PLATFORM%"=="Win32" cmake -G"Visual Studio 15 2017" -Bbuild -H. -DJERRY_DEBUGGER=%JERRY_DEBUGGER%
- if "%PLATFORM%"=="x64" cmake -G"Visual Studio 15 2017 Win64" -Bbuild -H. -DJERRY_DEBUGGER=%JERRY_DEBUGGER%
build:
project: build\Jerry.sln
parallel: true
verbosity: minimal
+29
View File
@@ -0,0 +1,29 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(CMAKE_SYSTEM_NAME esp-idf)
set(CMAKE_SYSTEM_PROCESSOR xtensa)
set(CMAKE_C_COMPILER xtensa-esp32-elf-gcc)
set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++)
set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc)
# uncomment that if you want 4-bytes float (much faster on esp32)
#add_definitions(-DJERRY_NUMBER_TYPE_FLOAT64=0)
set(CMAKE_C_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C Compiler Base Flags")
set(CMAKE_CXX_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C++ Compiler Base Flags")
# Can be removed after gcc 5.2.0 support is removed (ref GCC_NOT_5_2_0)
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib" CACHE STRING "Linker Base Flags")
+10 -16
View File
@@ -5,17 +5,17 @@ Currently, only Ubuntu 18.04+ is officially supported as primary development env
There are several dependencies, that should be installed manually. The following list is the absolute minimum for building: There are several dependencies, that should be installed manually. The following list is the absolute minimum for building:
- `gcc` or any C99-compliant compiler (native or cross, e.g., arm-none-eabi) - `gcc` or any C99-compliant compiler (native or cross, e.g., arm-none-eabi)
- `cmake` >= `2.8.12.2` - `cmake` >= `3.10`
Several scripts and tools help the building and development process, thus it is recommended to have the following installed as well: Several scripts and tools help the building and development process, thus it is recommended to have the following installed as well:
- `bash` >= `4.3.11` - `bash` >= `4.3.11`
- `cppcheck` >= `1.61` - `cppcheck` >= `2.7`
- `vera++` >= `1.2.1` - `clang-format-15`
- `python` >= `2.7.6` - `python` >= `3.10`
```bash ```bash
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck vera++ python sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck clang-format-15 python
``` ```
To make our scripts run correctly, several shell utilities should be available on the system: To make our scripts run correctly, several shell utilities should be available on the system:
@@ -51,13 +51,13 @@ tools/build.py --debug --logging=on --error-messages=on --line-info=on
python tools/build.py --cmake-param=CMAKE_PARAM python tools/build.py --cmake-param=CMAKE_PARAM
``` ```
**Set a profile mode (ES5.1, subset of ES2015, minimal)** **Set a profile mode (es.next, minimal)**
```bash ```bash
python tools/build.py --profile=es5.1|es2015-subset|minimal python tools/build.py --profile=es.next|minimal
``` ```
See also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md). See also the related [README.md](../jerry-core/profiles/README.md).
**Use (compiler-default, external) libc** **Use (compiler-default, external) libc**
@@ -161,12 +161,6 @@ python tools/run-tests.py --unittests
python tools/run-tests.py --jerry-tests python tools/run-tests.py --jerry-tests
``` ```
**To run jerry-test-suite**
```bash
python tools/run-tests.py --jerry-test-suite
```
**To run signed-off check** **To run signed-off check**
```bash ```bash
@@ -179,10 +173,10 @@ python tools/run-tests.py --check-signed-off
python tools/run-tests.py --check-cppcheck python tools/run-tests.py --check-cppcheck
``` ```
**To run vera check** **To run format check**
```bash ```bash
python tools/run-tests.py --check-vera python tools/run-tests.py --check-format
``` ```
**To get a list of all the available test options** **To get a list of all the available test options**
+93 -26
View File
@@ -1,20 +1,23 @@
# Configuration # Configuration
JerryScript provides a large number of configuration options which can be used to enable or disable specific features, allowing users to fine tune the engine to best suit their needs. JerryScript provides a large number of configuration options which can be used to enable or disable specific features, allowing users to fine tune the engine to best suit their needs.
A configuration option's value can be changed either by providing specific C preprocessor definitions, by adding CMake defininitions, or by using the arguments of the `tools/build.py` script. A configuration option's value can be changed either by providing specific C preprocessor definitions, by adding CMake definitions, or by using the arguments of the `tools/build.py` script.
This document lists the available configuration options, shows the configuration name for C, CMake, and python, and provides a brief description that explains the effect of the options. This document lists the available configuration options, shows the configuration name for C, CMake, and python, and provides a brief description that explains the effect of the options.
### All-in-one build ### Amalgamated build
Enables the All-in-one build process, which aggregates the contents of each source file, and uses this combined file to compile the JerryScript library. Enables the amalgamated build process, which aggregates the contents of each source file per library
This process can provide comparable results to link time optimization, and can be useful when LTO is not available otherwise. (i.e., JerryScript's core, port, and math libraries), and uses these combined files to compile the project.
This process can provide comparable results to link-time optimization, and can be useful when LTO is not available otherwise.
| Options | | | Options | |
|---------|----------------------------------------------| |---------|----------------------------------------------|
| C: | `<none>` | | C: | `<none>` |
| CMake: | `-DENABLE_ALL_IN_ONE=ON/OFF` | | CMake: | `-DENABLE_AMALGAM=ON/OFF` |
| Python: | `--all-in-one=ON/OFF` | | Python: | `--amalgam=ON/OFF` |
See also: [Amalgamated sources](#amalgamated-sources)
### Jerry debugger ### Jerry debugger
@@ -41,7 +44,7 @@ that can be used by the debugger to identify the currently executed source conte
### Profiles ### Profiles
This option can be used to enable/disable available JavaScript language features by providing profile files. Profile files contain a list of C definitions that configure each individual feature. This option can be used to enable/disable available JavaScript language features by providing profile files. Profile files contain a list of C definitions that configure each individual feature.
The `path` value for CMake and Python arguments should be a file path to the profile file, or one of `es2015-subset`, `es5.1`, or `minimal`, which are the pre-defined profiles. The `path` value for CMake and Python arguments should be a file path to the profile file, or one of `es.next` or `minimal`, which are the pre-defined profiles.
To see how a profile file should be created, or what configuration options are available in C, see the profile [README](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md). To see how a profile file should be created, or what configuration options are available in C, see the profile [README](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).
| Options | | | Options | |
@@ -50,6 +53,17 @@ To see how a profile file should be created, or what configuration options are a
| CMake: | `-DJERRY_PROFILE="path"` | | CMake: | `-DJERRY_PROFILE="path"` |
| Python: | `--profile="path"` | | Python: | `--profile="path"` |
### Promise callback
Enables Promise event notification support. This feature allows setting a user callback, which is called when certain Promise related events occur such as
creating a new Promise, resolving a Promise with a value, etc.
| Options | |
|---------|----------------------------------------------|
| C: | `-DJERRY_PROMISE_CALLBACK=0/1` |
| CMake: | `-DJERRY_PROMISE_CALLBACK=ON/OFF` |
| Python: | `--promise-callback=ON/OFF` |
### External context ### External context
Enables external context support in the engine. By default, JerryScript uses a statically allocated context to store the current state of the engine internals. Enables external context support in the engine. By default, JerryScript uses a statically allocated context to store the current state of the engine internals.
@@ -136,7 +150,7 @@ Enabling this feature provides detailed error messages where available, like lin
| Options | | | Options | |
|---------|----------------------------------------------| |---------|----------------------------------------------|
| C: | `-DJERRY_ERROR_MESSAGES=0/1` | | C: | `-DJERRY_ERROR_MESSAGES=0/1` |
| CMake: | `--DJERRY_ERROR_MESSAGES=ON/OFF` | | CMake: | `-DJERRY_ERROR_MESSAGES=ON/OFF` |
| Python: | `--error-messages=ON/OFF` | | Python: | `--error-messages=ON/OFF` |
### Logging ### Logging
@@ -152,7 +166,7 @@ This feature is disabled by default.
### LCache ### LCache
This option enables the LCache, allowing faster access to object properties. The LCache usases a statically allocated hash-map, which increases memory consumption. This option enables the LCache, allowing faster access to object properties. The LCache uses a statically allocated hash-map, which increases memory consumption.
See [Internals](04.INTERNALS.md#lcache) for further details. See [Internals](04.INTERNALS.md#lcache) for further details.
This option is enabled by default. This option is enabled by default.
@@ -170,13 +184,13 @@ This option is enabled by default.
| Options | | | Options | |
|---------|----------------------------------------------| |---------|----------------------------------------------|
| C: | `-DJERRY_PROPRETY_HASHMAP=0/1` | | C: | `-DJERRY_PROPERTY_HASHMAP=0/1` |
| CMake: | `<none>` | | CMake: | `<none>` |
| Python: | `<none>` | | Python: | `<none>` |
### Memory statistics ### Memory statistics
This option can be used to provide memory usage statistics either upon engine termination, or during runtime using the `jerry_get_memory_stats` jerry API function. This option can be used to provide memory usage statistics either upon engine termination, or during runtime using the `jerry_heap_stats` jerry API function.
The feature can create a significant performance overhead, and should only be used for measurement purposes. This option is disabled by default. The feature can create a significant performance overhead, and should only be used for measurement purposes. This option is disabled by default.
| Options | | | Options | |
@@ -193,7 +207,7 @@ The default value is 512.
| Options | | | Options | |
|---------|----------------------------------------------| |---------|----------------------------------------------|
| C: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` | | C: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` |
| CMake: | `--DJERRY_GLOBAL_HEAP_SIZE=(int)` | | CMake: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` |
| Python: | `--mem-heap=(int)` | | Python: | `--mem-heap=(int)` |
### Garbage collection limit ### Garbage collection limit
@@ -277,26 +291,79 @@ This option is disabled by default.
| CMake: | `-DJERRY_MEM_GC_BEFORE_EACH_ALLOC=ON/OFF` | | CMake: | `-DJERRY_MEM_GC_BEFORE_EACH_ALLOC=ON/OFF` |
| Python: | `--mem-stress-test=ON/OFF` | | Python: | `--mem-stress-test=ON/OFF` |
### MSVC CRT
# Single source build mode This option enables the use of the MSVC CRT library and is disabled by default.
There is a special mode to use/"build" JerryScript. That is generating a single C file which can be | Options | |
included into projects quickly. To achive this the following command can be executed to create |---------|----------------------------------------------|
a set of files into the `gen_src` directory (Note that the command is executed in the jerryscript root directory | C: | `<none>` |
but can be adapted to run outside of the project root dir): | CMake: | `-DENABLE_STATIC_CRT=ON/OFF` |
| Python: | `--static-crt=ON/OFF` |
### Architecture
Specify the platform name if it is supported by the generator.
| Options | |
|---------|----------------------------------------------|
| C: | `<none>` |
| CMake: | `-A (string)` |
| Python: | `--arch=(string)` |
### Tostring function
Enable function toString.
| Options | |
|---------|----------------------------------------------|
| C: | `-DJERRY_FUNCTION_TO_STRING=0/1` |
| CMake: | `-DJERRY_FUNCTION_TO_STRING=ON/OFF` |
| Python: | `--function-to-string=ON/OFF` |
### VM throw
Enable VM throw.
| Options | |
|---------|----------------------------------------------|
| C: | `-DJERRY_VM_THROW=0/1` |
| CMake: | `-DJERRY_VM_THROW=ON/OFF` |
| Python: | `--vm-throw=ON/OFF` |
### Promise callback
Enable Promise callback.
| Options | |
|---------|----------------------------------------------|
| C: | `-DJERRY_PROMISE_CALLBACK=0/1` |
| CMake: | `-DJERRY_PROMISE_CALLBACK=ON/OFF` |
| Python: | `--promise-callback=ON/OFF` |
# Amalgamated sources
The sources of JerryScript can be combined into a handful of files to allow their easy integration
in other projects. To achieve this, the following command can be executed to create a set of files
into the `amalgam` directory:
```sh ```sh
$ python tools/srcgenerator.py --output-dir gen_src --jerry-core --jerry-port-default --jerry-libm $ python tools/amalgam.py --output-dir amalgam --jerry-core --jerry-port --jerry-math
``` ```
The command creates the following files in the `gen_src` dir: (Note: In the example above, the command is executed from the project's root directory, but that is
not mandatory.)
The command creates the following files in the `amalgam` dir:
* `jerryscript.c` * `jerryscript.c`
* `jerryscript.h` * `jerryscript.h`
* `jerryscript-config.h` * `jerryscript-config.h`
* `jerryscript-port-default.c` * `jerryscript-port.c`
* `jerryscript-port-default.h` * `jerryscript-math.c`
* `jerryscript-libm.c`
* `math.h` * `math.h`
**Important**: the `jerryscript-config.h` contains the configurations mentioned above and **Important**: the `jerryscript-config.h` contains the configurations mentioned above and
@@ -304,15 +371,15 @@ should be adapted to the required use-case. See the file contents for more detai
default configuration. (Note: This config file is created from the the `jerry-core/config.h` file.) default configuration. (Note: This config file is created from the the `jerry-core/config.h` file.)
These files can be directly compiled with an application using the JerryScript API. These files can be directly compiled with an application using the JerryScript API.
For example with the following command: E.g., using a command similar to the one below:
```sh ```sh
$ gcc -Wall -o demo_app demo_app.c gen_src/jerryscript.c gen_src/jerryscript-port-default.c jerryscript-libm.c -Igen_src/ $ gcc -Wall -o demo_app demo_app.c amalgam/jerryscript.c amalgam/jerryscript-port.c amalgam/jerryscript-math.c -Iamalgam/
``` ```
Please note that the headers must be available on the include path. (Note: The headers must be available on the include path.)
In addition there is a `-DENABLE_ALL_IN_ONE_SOURCE=ON` CMake option to use this kind of sources during the build. This approach is also under the hood of the [amalgamated build](#amalgamated-build) process.
# Target specific information # Target specific information
+7903 -2838
View File
File diff suppressed because it is too large Load Diff
+152 -189
View File
@@ -32,40 +32,7 @@ $ export PKG_CONFIG_PATH=$(pwd)/example_install/lib/pkgconfig/
Test if the `pkg-config` works for JerryScript: Test if the `pkg-config` works for JerryScript:
```sh ```sh
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-libm $ pkg-config --cflags --libs libjerry-core libjerry-port libjerry-ext libjerry-math
```
## Example 1. Execute JavaScript from your application
The most basic example to test the engine is to create an `api-example-1.c` file containing the following code:
[doctest]: # ()
```c
#include "jerryscript.h"
int
main (void)
{
const jerry_char_t script[] = "var str = 'Hello, World!';";
bool ret_value = jerry_run_simple (script, sizeof (script) - 1, JERRY_INIT_EMPTY);
return (ret_value ? 0 : 1);
}
```
To compile it one can use the following command:
```sh
$ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
```
If everything is correct the application returns with a zero exit code:
```
$ ./api-example-1
$ echo $?
``` ```
## Example 2. Split engine initialization and script execution. ## Example 2. Split engine initialization and script execution.
@@ -73,9 +40,9 @@ $ echo $?
In this example the engine is initialized directly with the `jerry_init` method In this example the engine is initialized directly with the `jerry_init` method
and cleaned up with the `jerry_cleanup` method. The example JavaScript code and cleaned up with the `jerry_cleanup` method. The example JavaScript code
is directly parsed and executed via the `jerry_eval` method. Each `jerry_value_t` is directly parsed and executed via the `jerry_eval` method. Each `jerry_value_t`
returned by the API methods is freed with the `jerry_release_value` method. returned by the API methods is freed with the `jerry_value_free` method.
To make sure that the code parsing and execution was ok, the `jerry_value_is_error` To make sure that the code parsing and execution was ok, the `jerry_value_is_exception`
method is used to check for any errors. method is used to check for any errors.
Use the following code for the `api-example-2.c` file: Use the following code for the `api-example-2.c` file:
@@ -103,10 +70,10 @@ main (void)
JERRY_PARSE_NO_OPTS); JERRY_PARSE_NO_OPTS);
/* Check if there was any error (syntax or runtime) */ /* Check if there was any error (syntax or runtime) */
bool run_ok = !jerry_value_is_error (eval_ret); bool run_ok = !jerry_value_is_exception (eval_ret);
/* Parsed source code must be freed */ /* Parsed source code must be freed */
jerry_release_value (eval_ret); jerry_value_free (eval_ret);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -118,7 +85,7 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
```sh ```sh
$ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm) $ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
``` ```
If everything is correct the application returns with a zero exit code: If everything is correct the application returns with a zero exit code:
@@ -153,23 +120,23 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Setup Global scope code */ /* Setup Global scope code */
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS); jerry_value_t parsed_code = jerry_parse (script, sizeof (script) - 1, NULL);
/* Check if there is any JS code parse error */ /* Check if there is any JS code parse error */
if (!jerry_value_is_error (parsed_code)) if (!jerry_value_is_exception (parsed_code))
{ {
/* Execute the parsed source code in the Global scope */ /* Execute the parsed source code in the Global scope */
jerry_value_t ret_value = jerry_run (parsed_code); jerry_value_t ret_value = jerry_run (parsed_code);
/* Check the execution return value if there is any error */ /* Check the execution return value if there is any error */
run_ok = !jerry_value_is_error (ret_value); run_ok = !jerry_value_is_exception (ret_value);
/* Returned value must be freed */ /* Returned value must be freed */
jerry_release_value (ret_value); jerry_value_free (ret_value);
} }
/* Parsed source code must be freed */ /* Parsed source code must be freed */
jerry_release_value (parsed_code); jerry_value_free (parsed_code);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -181,7 +148,7 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
```sh ```sh
$ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm) $ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
``` ```
If everything is correct the application returns with a zero exit code: If everything is correct the application returns with a zero exit code:
@@ -200,10 +167,10 @@ In this example a very simple "print" method is added which prints out a static
This method will be implemented in C and will be called from the JavaScript code. This method will be implemented in C and will be called from the JavaScript code.
For this a few extra API methods are required: For this a few extra API methods are required:
- `jerry_get_global_object` - `jerry_current_realm`
- `jerry_create_string` - `jerry_string_sz`
- `jerry_set_property` - `jerry_object_set`
- `jerry_create_external_function` - `jerry_function_external`
The `api-example-4.c` file should contain the following code: The `api-example-4.c` file should contain the following code:
@@ -214,8 +181,7 @@ The `api-example-4.c` file should contain the following code:
#include "jerryscript.h" #include "jerryscript.h"
static jerry_value_t static jerry_value_t
print_handler (const jerry_value_t function_object, print_handler (const jerry_call_info_t *call_info_p,
const jerry_value_t function_this,
const jerry_value_t arguments[], const jerry_value_t arguments[],
const jerry_length_t argument_count) const jerry_length_t argument_count)
{ {
@@ -224,7 +190,7 @@ print_handler (const jerry_value_t function_object,
printf ("Print handler was called\n"); printf ("Print handler was called\n");
/* Return an "undefined" value to the JavaScript engine */ /* Return an "undefined" value to the JavaScript engine */
return jerry_create_undefined (); return jerry_undefined ();
} }
int int
@@ -239,40 +205,40 @@ main (void)
/* Add the "print" method for the JavaScript global object */ /* Add the "print" method for the JavaScript global object */
{ {
/* Get the "global" object */ /* Get the "global" object */
jerry_value_t global_object = jerry_get_global_object (); jerry_value_t global_object = jerry_current_realm ();
/* Create a "print" JS string */ /* Create a "print" JS string */
jerry_value_t property_name_print = jerry_create_string ((const jerry_char_t *) "print"); jerry_value_t property_name_print = jerry_string_sz ("print");
/* Create a function from a native C method (this function will be called from JS) */ /* Create a function from a native C method (this function will be called from JS) */
jerry_value_t property_value_func = jerry_create_external_function (print_handler); jerry_value_t property_value_func = jerry_function_external (print_handler);
/* Add the "print" property with the function value to the "global" object */ /* Add the "print" property with the function value to the "global" object */
jerry_value_t set_result = jerry_set_property (global_object, property_name_print, property_value_func); jerry_value_t set_result = jerry_object_set (global_object, property_name_print, property_value_func);
/* Check if there was no error when adding the property (in this case it should never happen) */ /* Check if there was no error when adding the property (in this case it should never happen) */
if (jerry_value_is_error (set_result)) { if (jerry_value_is_exception (set_result)) {
printf ("Failed to add the 'print' property\n"); printf ("Failed to add the 'print' property\n");
} }
/* Release all jerry_value_t-s */ /* Release all jerry_value_t-s */
jerry_release_value (set_result); jerry_value_free (set_result);
jerry_release_value (property_value_func); jerry_value_free (property_value_func);
jerry_release_value (property_name_print); jerry_value_free (property_name_print);
jerry_release_value (global_object); jerry_value_free (global_object);
} }
/* Setup Global scope code */ /* Setup Global scope code */
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_value_t parsed_code = jerry_parse (script, script_size, NULL);
if (!jerry_value_is_error (parsed_code)) if (!jerry_value_is_exception (parsed_code))
{ {
/* Execute the parsed source code in the Global scope */ /* Execute the parsed source code in the Global scope */
jerry_value_t ret_value = jerry_run (parsed_code); jerry_value_t ret_value = jerry_run (parsed_code);
/* Returned value must be freed */ /* Returned value must be freed */
jerry_release_value (ret_value); jerry_value_free (ret_value);
} }
/* Parsed source code must be freed */ /* Parsed source code must be freed */
jerry_release_value (parsed_code); jerry_value_free (parsed_code);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -285,7 +251,7 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
```sh ```sh
$ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm) $ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
``` ```
If everything is correct the application should print out the message present in the `print_handler` method: If everything is correct the application should print out the message present in the `print_handler` method:
@@ -305,7 +271,7 @@ argument (which probably comes from a JavaScript source) to a JS string and prin
New API methods used: New API methods used:
- `jerry_value_to_string` - `jerry_value_to_string`
- `jerry_string_to_utf8_char_buffer` - `jerry_string_to_buffer`
The `api-example-5.c` file should contain the following code: The `api-example-5.c` file should contain the following code:
@@ -316,8 +282,7 @@ The `api-example-5.c` file should contain the following code:
#include "jerryscript.h" #include "jerryscript.h"
static jerry_value_t static jerry_value_t
print_handler (const jerry_value_t function_object, print_handler (const jerry_call_info_t *call_info_p,
const jerry_value_t function_this,
const jerry_value_t arguments[], const jerry_value_t arguments[],
const jerry_length_t arguments_count) const jerry_length_t arguments_count)
{ {
@@ -334,17 +299,17 @@ print_handler (const jerry_value_t function_object,
* Please note that if the string does not fit into the buffer nothing will be copied. * Please note that if the string does not fit into the buffer nothing will be copied.
* More details on the API reference page * More details on the API reference page
*/ */
jerry_size_t copied_bytes = jerry_string_to_utf8_char_buffer (string_value, buffer, sizeof (buffer) - 1); jerry_size_t copied_bytes = jerry_string_to_buffer (string_value, JERRY_ENCODING_UTF8, buffer, sizeof (buffer) - 1);
buffer[copied_bytes] = '\0'; buffer[copied_bytes] = '\0';
/* Release the "toString" result */ /* Release the "toString" result */
jerry_release_value (string_value); jerry_value_free (string_value);
printf ("%s\n", (const char *)buffer); printf ("%s\n", (const char *)buffer);
} }
/* Return an "undefined" value to the JavaScript engine */ /* Return an "undefined" value to the JavaScript engine */
return jerry_create_undefined (); return jerry_undefined ();
} }
int int
@@ -359,40 +324,40 @@ main (void)
/* Add the "print" method for the JavaScript global object */ /* Add the "print" method for the JavaScript global object */
{ {
/* Get the "global" object */ /* Get the "global" object */
jerry_value_t global_object = jerry_get_global_object (); jerry_value_t global_object = jerry_current_realm ();
/* Create a "print" JS string */ /* Create a "print" JS string */
jerry_value_t property_name_print = jerry_create_string ((const jerry_char_t *) "print"); jerry_value_t property_name_print = jerry_string_sz ("print");
/* Create a function from a native C method (this function will be called from JS) */ /* Create a function from a native C method (this function will be called from JS) */
jerry_value_t property_value_func = jerry_create_external_function (print_handler); jerry_value_t property_value_func = jerry_function_external (print_handler);
/* Add the "print" property with the function value to the "global" object */ /* Add the "print" property with the function value to the "global" object */
jerry_value_t set_result = jerry_set_property (global_object, property_name_print, property_value_func); jerry_value_t set_result = jerry_object_set (global_object, property_name_print, property_value_func);
/* Check if there was no error when adding the property (in this case it should never happen) */ /* Check if there was no error when adding the property (in this case it should never happen) */
if (jerry_value_is_error (set_result)) { if (jerry_value_is_exception (set_result)) {
printf ("Failed to add the 'print' property\n"); printf ("Failed to add the 'print' property\n");
} }
/* Release all jerry_value_t-s */ /* Release all jerry_value_t-s */
jerry_release_value (set_result); jerry_value_free (set_result);
jerry_release_value (property_value_func); jerry_value_free (property_value_func);
jerry_release_value (property_name_print); jerry_value_free (property_name_print);
jerry_release_value (global_object); jerry_value_free (global_object);
} }
/* Setup Global scope code */ /* Setup Global scope code */
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_value_t parsed_code = jerry_parse (script, script_size, NULL);
if (!jerry_value_is_error (parsed_code)) if (!jerry_value_is_exception (parsed_code))
{ {
/* Execute the parsed source code in the Global scope */ /* Execute the parsed source code in the Global scope */
jerry_value_t ret_value = jerry_run (parsed_code); jerry_value_t ret_value = jerry_run (parsed_code);
/* Returned value must be freed */ /* Returned value must be freed */
jerry_release_value (ret_value); jerry_value_free (ret_value);
} }
/* Parsed source code must be freed */ /* Parsed source code must be freed */
jerry_release_value (parsed_code); jerry_value_free (parsed_code);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -405,7 +370,7 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
```sh ```sh
$ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm) $ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
``` ```
If everything is correct the application should print out the string passed for the `print` method in the JS code: If everything is correct the application should print out the string passed for the `print` method in the JS code:
@@ -423,14 +388,14 @@ can be used by other applications.
In this example the following extension methods are used: In this example the following extension methods are used:
- `jerryx_handler_register_global` - `jerryx_register_global`
- `jerryx_handler_print` - `jerryx_handler_print`
In further examples this "print" handler will be used. In further examples this "print" handler will be used.
```c ```c
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
int int
main (void) main (void)
@@ -442,23 +407,22 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Register 'print' function from the extensions to the global object */ /* Register 'print' function from the extensions to the global object */
jerryx_handler_register_global ((const jerry_char_t *) "print", jerryx_register_global ("print", jerryx_handler_print);
jerryx_handler_print);
/* Setup Global scope code */ /* Setup Global scope code */
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_value_t parsed_code = jerry_parse (script, script_size, NULL);
if (!jerry_value_is_error (parsed_code)) if (!jerry_value_is_exception (parsed_code))
{ {
/* Execute the parsed source code in the Global scope */ /* Execute the parsed source code in the Global scope */
jerry_value_t ret_value = jerry_run (parsed_code); jerry_value_t ret_value = jerry_run (parsed_code);
/* Returned value must be freed */ /* Returned value must be freed */
jerry_release_value (ret_value); jerry_value_free (ret_value);
} }
/* Parsed source code must be freed */ /* Parsed source code must be freed */
jerry_release_value (parsed_code); jerry_value_free (parsed_code);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -470,10 +434,10 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call. (**Note** that the `libjerry-ext` was added **before** the `libjerry-port` entry for the `pkg-config` call.
```sh ```sh
$ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm) $ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
``` ```
If everything is correct the application should print out the string passed for the `print` method in the JS code: If everything is correct the application should print out the string passed for the `print` method in the JS code:
@@ -492,8 +456,10 @@ Use the following code as the `api-example-7.c` file:
[doctest]: # () [doctest]: # ()
```c ```c
#include <stdio.h>
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
int int
main (void) main (void)
@@ -504,30 +470,29 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Register 'print' function from the extensions */ /* Register 'print' function from the extensions */
jerryx_handler_register_global ((const jerry_char_t *) "print", jerryx_register_global ("print", jerryx_handler_print);
jerryx_handler_print);
/* Getting pointer to the Global object */ /* Getting pointer to the Global object */
jerry_value_t global_object = jerry_get_global_object (); jerry_value_t global_object = jerry_current_realm ();
/* Constructing strings */ /* Constructing strings */
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "my_var"); jerry_value_t prop_name = jerry_string_sz ("my_var");
jerry_value_t prop_value = jerry_create_string ((const jerry_char_t *) "Hello from C!"); jerry_value_t prop_value = jerry_string_sz ("Hello from C!");
/* Setting the string value as a property of the Global object */ /* Setting the string value as a property of the Global object */
jerry_value_t set_result = jerry_set_property (global_object, prop_name, prop_value); jerry_value_t set_result = jerry_object_set (global_object, prop_name, prop_value);
/* The 'set_result' should be checked if there was any error */ /* The 'set_result' should be checked if there was any error */
if (jerry_value_is_error (set_result)) { if (jerry_value_is_exception (set_result)) {
printf ("Failed to add the 'my_var' property\n"); printf ("Failed to add the 'my_var' property\n");
} }
jerry_release_value (set_result); jerry_value_free (set_result);
/* Releasing string values, as it is no longer necessary outside of engine */ /* Releasing string values, as it is no longer necessary outside of engine */
jerry_release_value (prop_name); jerry_value_free (prop_name);
jerry_release_value (prop_value); jerry_value_free (prop_value);
/* Releasing the Global object */ /* Releasing the Global object */
jerry_release_value (global_object); jerry_value_free (global_object);
/* Now starting script that would output value of just initialized field */ /* Now starting script that would output value of just initialized field */
jerry_value_t eval_ret = jerry_eval (script, jerry_value_t eval_ret = jerry_eval (script,
@@ -535,7 +500,7 @@ main (void)
JERRY_PARSE_NO_OPTS); JERRY_PARSE_NO_OPTS);
/* Free JavaScript value, returned by eval */ /* Free JavaScript value, returned by eval */
jerry_release_value (eval_ret); jerry_value_free (eval_ret);
/* Freeing engine */ /* Freeing engine */
jerry_cleanup (); jerry_cleanup ();
@@ -546,10 +511,10 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call. (**Note** that the `libjerry-ext` was added **before** the `libjerry-port` entry for the `pkg-config` call.
```sh ```sh
$ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm) $ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
``` ```
The sample will output 'Hello from C!'. However, now it is not just a part of the source script, but the value, dynamically supplied to the engine: The sample will output 'Hello from C!'. However, now it is not just a part of the source script, but the value, dynamically supplied to the engine:
@@ -563,9 +528,9 @@ $ ./api-example-7
JerryScript value can be a boolean, number, null, object, string, undefined or some special type of objects (arraybuffer, symbols, etc). JerryScript value can be a boolean, number, null, object, string, undefined or some special type of objects (arraybuffer, symbols, etc).
There is a special "error" value which wraps another value. This "error" can be created by throwing a JavaScript value from JS code There is a special "error" value which wraps another value. This "error" can be created by throwing a JavaScript value from JS code
or via API method(s). It is advised to check for this error with the `jerry_value_is_error` method as not all API methods or via API method(s). It is advised to check for this error with the `jerry_value_is_exception` method as not all API methods
can process error values. To extract the value from the "error" the API method `jerry_get_value_from_error` should be used. can process error values. To extract the value from the "error" the API method `jerry_exception_value` should be used.
If an error object is created via API method (for example with `jerry_create_error`) the "error" value is automatically created. If an error object is created via API method (for example with `jerry_error`) the "error" value is automatically created.
Notice the difference between error value and error object: Notice the difference between error value and error object:
- The error object is a object which was constructed via one of the `Error` objects (available from the global object or from API). - The error object is a object which was constructed via one of the `Error` objects (available from the global object or from API).
@@ -582,7 +547,7 @@ var error_object = new Error ("error message");
throw "message"; throw "message";
``` ```
To check what type a given `jerry_value_t` is the `jerry_value_is_*` methods or the `jerry_value_get_type` could be used. To check what type a given `jerry_value_t` is the `jerry_value_is_*` methods or the `jerry_value_type` could be used.
For example the following code snippet could print out a few types (not all types are checked): For example the following code snippet could print out a few types (not all types are checked):
[doctest]: # (test="compile") [doctest]: # (test="compile")
@@ -597,14 +562,14 @@ print_value (const jerry_value_t jsvalue)
{ {
jerry_value_t value; jerry_value_t value;
/* If there is an error extract the object from it */ /* If there is an error extract the object from it */
if (jerry_value_is_error (jsvalue)) if (jerry_value_is_exception (jsvalue))
{ {
printf ("Error value detected: "); printf ("Error value detected: ");
value = jerry_get_value_from_error (jsvalue, false); value = jerry_exception_value (jsvalue, false);
} }
else else
{ {
value = jerry_acquire_value (jsvalue); value = jerry_value_copy (jsvalue);
} }
if (jerry_value_is_undefined (value)) if (jerry_value_is_undefined (value))
@@ -617,7 +582,7 @@ print_value (const jerry_value_t jsvalue)
} }
else if (jerry_value_is_boolean (value)) else if (jerry_value_is_boolean (value))
{ {
if (jerry_get_boolean_value (value)) if (jerry_value_is_true (value))
{ {
printf ("true"); printf ("true");
} }
@@ -629,7 +594,7 @@ print_value (const jerry_value_t jsvalue)
/* Float value */ /* Float value */
else if (jerry_value_is_number (value)) else if (jerry_value_is_number (value))
{ {
printf ("number: %lf", jerry_get_number_value (value)); printf ("number: %lf", jerry_value_as_number (value));
} }
/* String value */ /* String value */
else if (jerry_value_is_string (value)) else if (jerry_value_is_string (value))
@@ -637,11 +602,11 @@ print_value (const jerry_value_t jsvalue)
jerry_char_t str_buf_p[256]; jerry_char_t str_buf_p[256];
/* Determining required buffer size */ /* Determining required buffer size */
jerry_size_t req_sz = jerry_get_string_size (value); jerry_size_t req_sz = jerry_string_size (value, JERRY_ENCODING_CESU8);
if (req_sz <= 255) if (req_sz <= 255)
{ {
jerry_string_to_char_buffer (value, str_buf_p, req_sz); jerry_string_to_buffer (value, JERRY_ENCODING_CESU8, str_buf_p, req_sz);
str_buf_p[req_sz] = '\0'; str_buf_p[req_sz] = '\0';
printf ("%s", (const char *) str_buf_p); printf ("%s", (const char *) str_buf_p);
} }
@@ -657,7 +622,7 @@ print_value (const jerry_value_t jsvalue)
} }
printf ("\n"); printf ("\n");
jerry_release_value (value); jerry_value_free (value);
} }
``` ```
@@ -684,21 +649,22 @@ See the following `api-example-8-shell.c` file:
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
static void static void
print_value (const jerry_value_t jsvalue) print_value (const jerry_value_t jsvalue)
{ {
jerry_value_t value; jerry_value_t value;
/* If there is an error extract the object from it */ /* If there is an error extract the object from it */
if (jerry_value_is_error (jsvalue)) if (jerry_value_is_exception (jsvalue))
{ {
printf ("Error value detected: "); printf ("Error value detected: ");
value = jerry_get_value_from_error (jsvalue, false); value = jerry_exception_value (jsvalue, false);
} }
else else
{ {
value = jerry_acquire_value (jsvalue); value = jerry_value_copy (jsvalue);
} }
if (jerry_value_is_undefined (value)) if (jerry_value_is_undefined (value))
@@ -711,7 +677,7 @@ print_value (const jerry_value_t jsvalue)
} }
else if (jerry_value_is_boolean (value)) else if (jerry_value_is_boolean (value))
{ {
if (jerry_get_boolean_value (value)) if (jerry_value_is_true (value))
{ {
printf ("true"); printf ("true");
} }
@@ -723,7 +689,7 @@ print_value (const jerry_value_t jsvalue)
/* Float value */ /* Float value */
else if (jerry_value_is_number (value)) else if (jerry_value_is_number (value))
{ {
printf ("number: %lf", jerry_get_number_value (value)); printf ("number: %lf", jerry_value_as_number (value));
} }
/* String value */ /* String value */
else if (jerry_value_is_string (value)) else if (jerry_value_is_string (value))
@@ -731,11 +697,11 @@ print_value (const jerry_value_t jsvalue)
jerry_char_t str_buf_p[256]; jerry_char_t str_buf_p[256];
/* Determining required buffer size */ /* Determining required buffer size */
jerry_size_t req_sz = jerry_get_string_size (value); jerry_size_t req_sz = jerry_string_size (value, JERRY_ENCODING_CESU8);
if (req_sz <= 255) if (req_sz <= 255)
{ {
jerry_string_to_char_buffer (value, str_buf_p, req_sz); jerry_string_to_buffer (value, JERRY_ENCODING_CESU8, str_buf_p, req_sz);
str_buf_p[req_sz] = '\0'; str_buf_p[req_sz] = '\0';
printf ("%s", (const char *) str_buf_p); printf ("%s", (const char *) str_buf_p);
} }
@@ -751,7 +717,7 @@ print_value (const jerry_value_t jsvalue)
} }
printf ("\n"); printf ("\n");
jerry_release_value (value); jerry_value_free (value);
} }
int int
@@ -763,8 +729,7 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Register 'print' function from the extensions */ /* Register 'print' function from the extensions */
jerryx_handler_register_global ((const jerry_char_t *) "print", jerryx_register_global ("print", jerryx_handler_print);
jerryx_handler_print);
while (!is_done) while (!is_done)
{ {
@@ -807,7 +772,7 @@ main (void)
/* Print out the value */ /* Print out the value */
print_value (ret_val); print_value (ret_val);
jerry_release_value (ret_val); jerry_value_free (ret_val);
} }
/* Cleanup engine */ /* Cleanup engine */
@@ -819,10 +784,10 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call. (**Note** that the `libjerry-ext` was added **before** the `libjerry-port` entry for the `pkg-config` call.
```sh ```sh
$ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm) $ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
``` ```
The application reads lines from standard input and evaluates them, one after another. To try out run: The application reads lines from standard input and evaluates them, one after another. To try out run:
@@ -840,7 +805,8 @@ In this example (`api-example-9.c`) an object with a native function is added to
```c ```c
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
struct my_struct struct my_struct
{ {
@@ -851,12 +817,11 @@ struct my_struct
* Get a string from a native object * Get a string from a native object
*/ */
static jerry_value_t static jerry_value_t
get_msg_handler (const jerry_value_t func_value, /**< function object */ get_msg_handler (const jerry_call_info_t *call_info_p, /**< call information */
const jerry_value_t this_value, /**< this arg */
const jerry_value_t *args_p, /**< function arguments */ const jerry_value_t *args_p, /**< function arguments */
const jerry_length_t args_cnt) /**< number of function arguments */ const jerry_length_t args_cnt) /**< number of function arguments */
{ {
return jerry_create_string ((const jerry_char_t *) my_struct.msg); return jerry_string_sz (my_struct.msg);
} /* get_msg_handler */ } /* get_msg_handler */
int int
@@ -866,33 +831,32 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Register 'print' function from the extensions */ /* Register 'print' function from the extensions */
jerryx_handler_register_global ((const jerry_char_t *) "print", jerryx_register_global ("print", jerryx_handler_print);
jerryx_handler_print);
/* Do something with the native object */ /* Do something with the native object */
my_struct.msg = "Hello, World!"; my_struct.msg = "Hello, World!";
/* Create an empty JS object */ /* Create an empty JS object */
jerry_value_t object = jerry_create_object (); jerry_value_t object = jerry_object ();
/* Create a JS function object and wrap into a jerry value */ /* Create a JS function object and wrap into a jerry value */
jerry_value_t func_obj = jerry_create_external_function (get_msg_handler); jerry_value_t func_obj = jerry_function_external (get_msg_handler);
/* Set the native function as a property of the empty JS object */ /* Set the native function as a property of the empty JS object */
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "myFunc"); jerry_value_t prop_name = jerry_string_sz ("myFunc");
jerry_release_value (jerry_set_property (object, prop_name, func_obj)); jerry_value_free (jerry_object_set (object, prop_name, func_obj));
jerry_release_value (prop_name); jerry_value_free (prop_name);
jerry_release_value (func_obj); jerry_value_free (func_obj);
/* Wrap the JS object (not empty anymore) into a jerry api value */ /* Wrap the JS object (not empty anymore) into a jerry api value */
jerry_value_t global_object = jerry_get_global_object (); jerry_value_t global_object = jerry_current_realm ();
/* Add the JS object to the global context */ /* Add the JS object to the global context */
prop_name = jerry_create_string ((const jerry_char_t *) "MyObject"); prop_name = jerry_string_sz ("MyObject");
jerry_release_value (jerry_set_property (global_object, prop_name, object)); jerry_value_free (jerry_object_set (global_object, prop_name, object));
jerry_release_value (prop_name); jerry_value_free (prop_name);
jerry_release_value (object); jerry_value_free (object);
jerry_release_value (global_object); jerry_value_free (global_object);
/* Now we have a "builtin" object called MyObject with a function called myFunc() /* Now we have a "builtin" object called MyObject with a function called myFunc()
* *
@@ -908,7 +872,7 @@ main (void)
jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS); jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
/* Free JavaScript value, returned by eval */ /* Free JavaScript value, returned by eval */
jerry_release_value (eval_ret); jerry_value_free (eval_ret);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -919,10 +883,10 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call. (**Note** that the `libjerry-ext` was added **before** the `libjerry-port` entry for the `pkg-config` call.
```sh ```sh
$ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm) $ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
``` ```
Execute the example with: Execute the example with:
@@ -949,14 +913,14 @@ Use the following code for `api-example-10.c`:
```c ```c
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
/** /**
* Add param to 'this.x' * Add param to 'this.x'
*/ */
static jerry_value_t static jerry_value_t
add_handler (const jerry_value_t func_value, /**< function object */ add_handler (const jerry_call_info_t *call_info_p, /**< call information */
const jerry_value_t this_val, /**< this arg */
const jerry_value_t args_p[], /**< function arguments */ const jerry_value_t args_p[], /**< function arguments */
const jerry_length_t args_cnt) /**< number of function arguments */ const jerry_length_t args_cnt) /**< number of function arguments */
{ {
@@ -964,27 +928,27 @@ add_handler (const jerry_value_t func_value, /**< function object */
/* Note: that the argument count check is ignored for the example's case */ /* Note: that the argument count check is ignored for the example's case */
/* Get 'this.x' */ /* Get 'this.x' */
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "x"); jerry_value_t prop_name = jerry_string_sz ("x");
jerry_value_t x_val = jerry_get_property (this_val, prop_name); jerry_value_t x_val = jerry_object_get (call_info_p->this_value, prop_name);
if (!jerry_value_is_error (x_val)) if (!jerry_value_is_exception (x_val))
{ {
/* Convert Jerry API values to double */ /* Convert Jerry API values to double */
double x = jerry_get_number_value (x_val); double x = jerry_value_as_number (x_val);
double d = jerry_get_number_value (args_p[0]); double d = jerry_value_as_number (args_p[0]);
/* Add the parameter to 'x' */ /* Add the parameter to 'x' */
jerry_value_t res_val = jerry_create_number (x + d); jerry_value_t res_val = jerry_number (x + d);
/* Set the new value of 'this.x' */ /* Set the new value of 'this.x' */
jerry_release_value (jerry_set_property (this_val, prop_name, res_val)); jerry_value_free (jerry_object_set (call_info_p->this_value, prop_name, res_val));
jerry_release_value (res_val); jerry_value_free (res_val);
} }
jerry_release_value (x_val); jerry_value_free (x_val);
jerry_release_value (prop_name); jerry_value_free (prop_name);
return jerry_create_undefined (); return jerry_undefined ();
} /* add_handler */ } /* add_handler */
int int
@@ -994,8 +958,7 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Register 'print' function from the extensions */ /* Register 'print' function from the extensions */
jerryx_handler_register_global ((const jerry_char_t *) "print", jerryx_register_global ("print", jerryx_handler_print);
jerryx_handler_print);
/* Create a JS object */ /* Create a JS object */
const jerry_char_t my_js_object[] = " \ const jerry_char_t my_js_object[] = " \
@@ -1017,16 +980,16 @@ main (void)
JERRY_PARSE_NO_OPTS); JERRY_PARSE_NO_OPTS);
/* Create a JS function object and wrap into a jerry value */ /* Create a JS function object and wrap into a jerry value */
jerry_value_t add_func_obj = jerry_create_external_function (add_handler); jerry_value_t add_func_obj = jerry_function_external (add_handler);
/* Set the native function as a property of previously created MyObject */ /* Set the native function as a property of previously created MyObject */
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "add2x"); jerry_value_t prop_name = jerry_string_sz ("add2x");
jerry_release_value (jerry_set_property (my_js_obj_val, prop_name, add_func_obj)); jerry_value_free (jerry_object_set (my_js_obj_val, prop_name, add_func_obj));
jerry_release_value (add_func_obj); jerry_value_free (add_func_obj);
jerry_release_value (prop_name); jerry_value_free (prop_name);
/* Free JavaScript value, returned by eval (my_js_object) */ /* Free JavaScript value, returned by eval (my_js_object) */
jerry_release_value (my_js_obj_val); jerry_value_free (my_js_obj_val);
const jerry_char_t script[] = " \ const jerry_char_t script[] = " \
var str = MyObject.foo (); \ var str = MyObject.foo (); \
@@ -1039,7 +1002,7 @@ main (void)
jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS); jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
/* Free JavaScript value, returned by eval */ /* Free JavaScript value, returned by eval */
jerry_release_value (eval_ret); jerry_value_free (eval_ret);
/* Cleanup engine */ /* Cleanup engine */
jerry_cleanup (); jerry_cleanup ();
@@ -1050,10 +1013,10 @@ main (void)
To compile it one can use the following command: To compile it one can use the following command:
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call. (**Note** that the `libjerry-ext` was added **before** the `libjerry-port` entry for the `pkg-config` call.
```sh ```sh
$ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm) $ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
``` ```
Execute the example with: Execute the example with:
@@ -1070,7 +1033,7 @@ Value of x is 17
## Example 11. Changing the seed of pseudorandom generated numbers ## Example 11. Changing the seed of pseudorandom generated numbers
If you want to change the seed of `Math.random()` generated numbers, you have to initialize the seed value with `srand`. If you want to change the seed of `Math.random()` generated numbers, you have to initialize the seed value with `srand`.
A recommended method is using `jerry_port_get_current_time()` or something based on a constantly changing value, therefore every run produces truly random numbers. A recommended method is using `jerry_port_current_time()` or something based on a constantly changing value, therefore every run produces truly random numbers.
[doctest]: # () [doctest]: # ()
@@ -1078,13 +1041,14 @@ A recommended method is using `jerry_port_get_current_time()` or something based
#include <stdlib.h> #include <stdlib.h>
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-port.h" #include "jerryscript-port.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
int int
main (void) main (void)
{ {
/* Initialize srand value */ /* Initialize srand value */
union { double d; unsigned u; } now = { .d = jerry_port_get_current_time () }; union { double d; unsigned u; } now = { .d = jerry_port_current_time () };
srand (now.u); srand (now.u);
/* Generate a random number, and print it */ /* Generate a random number, and print it */
@@ -1094,14 +1058,13 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
/* Register the print function */ /* Register the print function */
jerryx_handler_register_global ((const jerry_char_t *) "print", jerryx_register_global ("print", jerryx_handler_print);
jerryx_handler_print);
/* Evaluate the script */ /* Evaluate the script */
jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS); jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
/* Free the JavaScript value returned by eval */ /* Free the JavaScript value returned by eval */
jerry_release_value (eval_ret); jerry_value_free (eval_ret);
/* Cleanup the engine */ /* Cleanup the engine */
jerry_cleanup (); jerry_cleanup ();
+4 -3
View File
@@ -78,7 +78,7 @@ Argument combinations are limited to the following seven forms:
## Literals ## Literals
Literals are organized into groups whose represent various literal types. Having these groups consuming less space than assigning flag bits to each literal. Literals are organized into groups whose represent various literal types. Having these groups consuming less space than assigning flag bits to each literal.
(In the followings, the mentioned ranges represent those indicies which are greater than or equal to the left side and less than the right side of the range. For example a range between `ident_end` and `literal_end` fields of the byte-code header contains those indicies, which are greater than or equal to `ident_end` (In the followings, the mentioned ranges represent those indices which are greater than or equal to the left side and less than the right side of the range. For example a range between `ident_end` and `literal_end` fields of the byte-code header contains those indices, which are greater than or equal to `ident_end`
and less than `literal_end`. If `ident_end` equals to `literal_end` the range is empty.) and less than `literal_end`. If `ident_end` equals to `literal_end` the range is empty.)
The two major group of literals are _identifiers_ and _values_. The two major group of literals are _identifiers_ and _values_.
@@ -271,7 +271,7 @@ An object can be a conventional data object or a lexical environment object. Unl
[Lexical environments](http://www.ecma-international.org/ecma-262/5.1/#sec-10.2) are implemented as objects in JerryScript, since lexical environments contains key-value pairs (called bindings) like objects. This simplifies the implementation and reduces code size. [Lexical environments](http://www.ecma-international.org/ecma-262/5.1/#sec-10.2) are implemented as objects in JerryScript, since lexical environments contains key-value pairs (called bindings) like objects. This simplifies the implementation and reduces code size.
![Object/Lexicat environment structures](img/ecma_object.png) ![Object/Lexical environment structures](img/ecma_object.png)
The objects are represented as following structure: The objects are represented as following structure:
@@ -284,7 +284,8 @@ The objects are represented as following structure:
![Object properties](img/ecma_object_property.png) ![Object properties](img/ecma_object_property.png)
Objects have a linked list that contains their properties. This list actually contains property pairs, in order to save memory described in the followings: Objects have a linked list that contains their properties. This list actually contains property pairs, in order to save memory described in the followings:
A property is 7 bit long and its type field is 2 bit long which consumes 9 bit which does not fit into 1 byte but consumes 2 bytes. Hence, placing together two properties (14 bit) with the 2 bit long type field fits into 2 bytes. A property has a one byte long descriptor, a two byte long name and four byte long value. Hence 14 bytes consumed by a property pair. Another two bytes is
used to show the next property pair, so the total size (16 byte) is divisible by 8.
#### Property Hashmap #### Property Hashmap
+207 -323
View File
@@ -1,9 +1,16 @@
# Reference # Reference
## Termination ## Process management
It is questionable whether a library should be able to terminate an application. Any API function can signal an error (ex.: cannot allocate memory), so the engine use the termination approach with this port function. It is questionable whether a library should be able to terminate an application. Any API function can signal an error (ex.: cannot allocate memory), so the engine use the termination approach with this port function.
```c
/**
* Init the program
*/
void jerry_port_init (void);
```
```c ```c
/** /**
* Signal the port that jerry experienced a fatal failure from which it cannot * Signal the port that jerry experienced a fatal failure from which it cannot
@@ -24,206 +31,14 @@ Error codes
```c ```c
typedef enum typedef enum
{ {
ERR_OUT_OF_MEMORY = 10, JERRY_FATAL_OUT_OF_MEMORY = 10,
ERR_REF_COUNT_LIMIT = 12, JERRY_FATAL_REF_COUNT_LIMIT = 12,
ERR_DISABLED_BYTE_CODE = 13, JERRY_FATAL_DISABLED_BYTE_CODE = 13,
ERR_FAILED_INTERNAL_ASSERTION = 120 JERRY_FATAL_UNTERMINATED_GC_LOOPS = 14,
JERRY_FATAL_FAILED_ASSERTION = 120
} jerry_fatal_code_t; } jerry_fatal_code_t;
``` ```
## I/O
These are the only I/O functions jerry calls.
```c
/**
* Jerry log levels. The levels are in severity order
* where the most serious levels come first.
*/
typedef enum
{
JERRY_LOG_LEVEL_ERROR, /**< the engine will terminate after the message is printed */
JERRY_LOG_LEVEL_WARNING, /**< a request is aborted, but the engine continues its operation */
JERRY_LOG_LEVEL_DEBUG, /**< debug messages from the engine, low volume */
JERRY_LOG_LEVEL_TRACE /**< detailed info about engine internals, potentially high volume */
} jerry_log_level_t;
/**
* Display or log a debug/error message, and sends it to the debugger client as well.
* The function should implement a printf-like interface, where the first argument
* specifies the log level and the second argument specifies a format string on how
* to stringify the rest of the parameter list.
*
* This function is only called with messages coming from the jerry engine as
* the result of some abnormal operation or describing its internal operations
* (e.g., data structure dumps or tracing info).
*
* It should be the port that decides whether error and debug messages are logged to
* the console, or saved to a database or to a file.
*
* Example: a libc-based port may implement this with vfprintf(stderr) or
* vfprintf(logfile), or both, depending on log level.
*
* Note:
* This port function is called by jerry-core when JERRY_LOGGING is
* enabled. It is also common practice though to use this function in
* application code.
*/
void jerry_port_log (jerry_log_level_t level, const char *fmt, ...);
```
The `jerry_port_print_char` is currenlty not used by the jerry-core directly.
However, it provides a port specifc way for `jerry-ext` components to print
information.
```c
/**
* Print a character to stdout.
*/
void jerry_port_print_char (char c);
```
### ES2015 Module system
The port API provides functions that can be used by the module system to open
and close source files, and normalize file paths.
The `jerry_port_get_native_module` port function can be used to provide native
modules to the engine. This function will be called when an import/export
statement is encountered with an unknown module specifier, which embedders can
use to supply native module objects based on the module name argument.
```c
/**
* Opens file with the given path and reads its source.
* @return the source of the file
*/
uint8_t *
jerry_port_read_source (const char *file_name_p, /**< file name */
size_t *out_size_p) /**< [out] read bytes */
{
// open file from given path
// return its source
} /* jerry_port_read_source */
/**
* Release the previously opened file's content.
*/
void
jerry_port_release_source (uint8_t *buffer_p) /**< buffer to free */
{
free (buffer_p);
} /* jerry_port_release_source */
/**
* Normalize a file path
*
* @return length of the path written to the output buffer
*/
size_t
jerry_port_normalize_path (const char *in_path_p, /**< input file path */
char *out_buf_p, /**< output buffer */
size_t out_buf_size, /**< size of output buffer */
char *base_file_p) /**< base file path */
{
// normalize in_path_p by expanding relative paths etc.
// if base_file_p is not NULL, in_path_p is relative to that file
// write to out_buf_p the normalized path
// return length of written path
} /* jerry_port_normalize_path */
/**
* Get the module object of a native module.
*
* Note:
* This port function is called by jerry-core when ES2015_MODULE_SYSTEM
* is enabled.
*
* @param name String value of the module specifier.
*
* @return Undefined, if 'name' is not a native module
* jerry_value_t containing the module object, otherwise
*/
jerry_value_t
jerry_port_get_native_module (jerry_value_t name) /**< module specifier */
{
(void) name;
return jerry_create_undefined ();
}
```
## Date
```c
/**
* Get local time zone adjustment, in milliseconds, for the given timestamp.
* The timestamp can be specified in either UTC or local time, depending on
* the value of is_utc. Adding the value returned from this function to
* a timestamp in UTC time should result in local time for the current time
* zone, and subtracting it from a timestamp in local time should result in
* UTC time.
*
* Ideally, this function should satisfy the stipulations applied to LocalTZA
* in section 20.3.1.7 of the ECMAScript version 9.0 spec.
*
* See Also:
* ECMA-262 v9, 20.3.1.7
*
* Note:
* This port function is called by jerry-core when
* JERRY_BUILTIN_DATE is set to 1. Otherwise this function is
* not used.
*
* @param unix_ms The unix timestamp we want an offset for, given in
* millisecond precision (could be now, in the future,
* or in the past). As with all unix timestamps, 0 refers to
* 1970-01-01, a day is exactly 86 400 000 milliseconds, and
* leap seconds cause the same second to occur twice.
* @param is_utc Is the given timestamp in UTC time? If false, it is in local
* time.
*
* @return milliseconds between local time and UTC for the given timestamp,
* if available
*. 0 if not available / we are in UTC.
*/
double jerry_port_get_local_time_zone_adjustment (double unix_ms, bool is_utc);
/**
* Get system time
*
* Note:
* This port function is called by jerry-core when
* JERRY_BUILTIN_DATE is set to 1. It is also common practice
* in application code to use this function for the initialization of the
* random number generator.
*
* @return milliseconds since Unix epoch
*/
double jerry_port_get_current_time (void);
```
## External context
Allow user to provide external buffer for isolated engine contexts, so that user
can configure the heap size at runtime and run multiple JS applications
simultaneously.
```c
/**
* Get the current context of the engine. Each port should provide its own
* implementation of this interface.
*
* Note:
* This port function is called by jerry-core when
* JERRY_EXTERNAL_CONTEXT is enabled. Otherwise this function is not
* used.
*
* @return the pointer to the engine context.
*/
struct jerry_context_t *jerry_port_get_current_context (void);
```
## Sleep
```c ```c
/** /**
* Makes the process sleep for a given time. * Makes the process sleep for a given time.
@@ -237,158 +52,227 @@ struct jerry_context_t *jerry_port_get_current_context (void);
void jerry_port_sleep (uint32_t sleep_time); void jerry_port_sleep (uint32_t sleep_time);
``` ```
# How to port JerryScript ## External context
This section describes a basic port implementation which was created for Unix based systems. Allows the user to provide external buffer for isolated engine contexts, so that user
can configure the heap size at runtime and run multiple JS applications
## Termination simultaneously.
```c ```c
#include <stdlib.h>
#include "jerryscript-port.h"
/** /**
* Default implementation of jerry_port_fatal. * Allocate a new context for the engine.
*
* This port function is called by jerry_init when JERRY_EXTERNAL_CONTEXT is enabled. Otherwise this function is not
* used. The engine will pass the size required for the context structure. An implementation must make sure to
* allocate at least this amount.
*
* Excess allocated space will be used as the engine heap when jerryscript is configured to use it's internal allocator,
* this can be used to control the internal heap size.
*
* NOTE: The allocated memory must be pointer-aligned, otherwise the behavior is
* undefined.
*
* @param context_size: the size of the internal context structure
*
* @return total size of the allocated buffer
*/ */
void jerry_port_fatal (jerry_fatal_code_t code) size_t jerry_port_context_alloc (size_t context_size);
{ ```
exit (code);
} /* jerry_port_fatal */ ```c
/**
* Get the currently active context of the engine.
*
* This port function is called by jerry-core when JERRY_EXTERNAL_CONTEXT is enabled.
* Otherwise this function is not used.
*
* @return the pointer to the currently used engine context.
*/
struct jerry_context_t *jerry_port_context_get (void);
```
```c
/**
* Free the currently used context.
*
* This port function is called by jerry_cleanup when JERRY_EXTERNAL_CONTEXT is enabled.
* Otherwise this function is not used.
*
* @return the pointer to the engine context.
*/
void jerry_port_context_free (void);
``` ```
## I/O ## I/O
```c ```c
#include <stdarg.h>
#include "jerryscript-port.h"
/** /**
* Provide log message implementation for the engine. * Display or log a debug/error message.
* *
* Note: * The message is passed as a zero-terminated string. Messages may be logged in parts, which
* This example ignores the log level. * will result in multiple calls to this functions. The implementation should consider
* this before appending or prepending strings to the argument.
*
* This function is called with messages coming from the jerry engine as
* the result of some abnormal operation or describing its internal operations
* (e.g., data structure dumps or tracing info).
*
* The implementation can decide whether error and debug messages are logged to
* the console, or saved to a database or to a file.
*
* @param message_p: the message to log.
*/ */
void void jerry_port_log (const char *message_p);
jerry_port_log (jerry_log_level_t level, /**< log level */
const char *format, /**< format string */
...) /**< parameters */
{
va_list args;
va_start (args, format);
vfprintf (stderr, format, args);
va_end (args);
} /* jerry_port_log */
``` ```
```c ```c
/** /**
* Print a character to stdout with putchar. * Print a buffer to standard output
*
* This port function is never called from jerry-core directly, it is only used by jerry-ext components to print
* information.
*
* @param buffer_p: input buffer
* @param buffer_size: data size
*/ */
void void jerry_port_print_buffer (const jerry_char_t *buffer_p, jerry_size_t buffer_size);
jerry_port_print_char (char c) ```
{
putchar (c); ```c
} /* jerr_port_print_char */ /**
* Read a line from standard input.
*
* The implementation should allocate storage necessary for the string. The result string should include the ending line
* terminator character(s) and should be zero terminated.
*
* An implementation may return NULL to signal that the end of input is reached, or an error occured.
*
* When a non-NULL value is returned, the caller will pass the returned value to `jerry_port_line_free` when the line is
* no longer needed. This can be used to finalize dynamically allocated buffers if necessary.
*
* This port function is never called from jerry-core directly, it is only used by some jerry-ext components that
* require user input.
*
* @param out_size_p: size of the input string in bytes, excluding terminating zero byte
*
* @return pointer to the buffer storing the string,
* or NULL if end of input
*/
jerry_char_t *jerry_port_line_read (jerry_size_t *out_size_p);
```
```c
/**
* Free a line buffer allocated by jerry_port_line_read
*
* @param buffer_p: buffer returned by jerry_port_line_read
*/
void jerry_port_line_free (jerry_char_t *buffer_p);
```
## Filesystem
```
/**
* Canonicalize a file path.
*
* If possible, the implementation should resolve symbolic links and other directory references found in the input path,
* and create a fully canonicalized file path as the result.
*
* The function may return with NULL in case an error is encountered, in which case the calling operation will not
* proceed.
*
* The implementation should allocate storage for the result path as necessary. Non-NULL return values will be passed
* to `jerry_port_path_free` when the result is no longer needed by the caller, which can be used to finalize
* dynamically allocated buffers.
*
* NOTE: The implementation must not return directly with the input, as the input buffer is released after the call.
*
* @param path_p: zero-terminated string containing the input path
* @param path_size: size of the input path string in bytes, excluding terminating zero
*
* @return buffer with the normalized path if the operation is successful,
* NULL otherwise
*/
jerry_char_t *jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size);
```
```c
/**
* Free a path buffer returned by jerry_port_path_normalize.
*
* @param path_p: the path buffer to free
*/
void jerry_port_path_free (jerry_char_t *path_p);
```
```c
/**
* Get the offset of the basename component in the input path.
*
* The implementation should return the offset of the first character after the last path separator found in the path.
* This is used by the caller to split the path into a directory name and a file name.
*
* @param path_p: input zero-terminated path string
*
* @return offset of the basename component in the input path
*/
jerry_size_t jerry_port_path_base (const jerry_char_t *path_p);
```
```c
/**
* Open a source file and read its contents into a buffer.
*
* When the source file is no longer needed by the caller, the returned pointer will be passed to
* `jerry_port_source_free`, which can be used to finalize the buffer.
*
* @param file_name_p: Path that points to the source file in the filesystem.
* @param out_size_p: The opened file's size in bytes.
*
* @return pointer to the buffer which contains the content of the file.
*/
jerry_char_t *jerry_port_source_read (const char *file_name_p, jerry_size_t *out_size_p);
```
```c
/**
* Free a source file buffer.
*
* @param buffer_p: buffer returned by jerry_port_source_read
*/
void jerry_port_source_free (jerry_char_t *buffer_p);
``` ```
## Date ## Date
```c ```c
#include <time.h>
#include <sys/time.h>
#include "jerryscript-port.h"
/** /**
* Default implementation of jerry_port_get_local_time_zone_adjustment. * Get local time zone adjustment in milliseconds for the given input time.
*/
double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since unix epoch */
bool is_utc) /**< is the time above in UTC? */
{
struct tm tm;
time_t now = (time_t) (unix_ms / 1000);
localtime_r (&now, &tm);
if (!is_utc)
{
now -= tm.tm_gmtoff;
localtime_r (&now, &tm);
}
return ((double) tm.tm_gmtoff) * 1000;
} /* jerry_port_get_local_time_zone_adjustment */
/**
* Default implementation of jerry_port_get_current_time.
*/
double jerry_port_get_current_time (void)
{
struct timeval tv;
if (gettimeofday (&tv, NULL) != 0)
{
return 0;
}
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
} /* jerry_port_get_current_time */
```
## External context
```c
#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
/**
* Pointer to the current context.
* Note that it is a global variable, and is not a thread safe implementation.
*/
static jerry_context_t *current_context_p = NULL;
/**
* Set the current_context_p as the passed pointer.
*/
void
jerry_port_default_set_current_context (jerry_context_t *context_p) /**< points to the created context */
{
current_context_p = context_p;
} /* jerry_port_default_set_current_context */
/**
* Get the current context.
* *
* @return the pointer to the current context * The argument is a time value representing milliseconds since unix epoch.
*
* Ideally, this function should satisfy the stipulations applied to LocalTZA
* in section 21.4.1.7 of the ECMAScript version 12.0, as if called with isUTC true.
*
* This port function can be called by jerry-core when JERRY_BUILTIN_DATE is enabled.
* Otherwise this function is not used.
*
* @param unix_ms: time value in milliseconds since unix epoch
*
* @return local time offset in milliseconds applied to UTC for the given time value
*/ */
jerry_context_t * int32_t jerry_port_local_tza (double unix_ms);
jerry_port_get_current_context (void)
{
return current_context_p;
} /* jerry_port_get_current_context */
``` ```
## Sleep
```c ```c
#include "jerryscript-port.h" /**
#include "jerryscript-port-default.h" * Get the current system time in UTC.
*
#ifdef HAVE_TIME_H * This port function is called by jerry-core when JERRY_BUILTIN_DATE is enabled.
#include <time.h> * It can also be used in the implementing application to initialize the random number generator.
#elif defined (HAVE_UNISTD_H) *
#include <unistd.h> * @return milliseconds since Unix epoch
#endif /* HAVE_TIME_H */ */
double jerry_port_current_time (void);
#if defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1)
void jerry_port_sleep (uint32_t sleep_time)
{
#ifdef HAVE_TIME_H
nanosleep (&(const struct timespec)
{
(time_t) sleep_time / 1000, ((long int) sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */
}
, NULL);
#elif defined (HAVE_UNISTD_H)
usleep ((useconds_t) sleep_time * 1000);
#endif /* HAVE_TIME_H */
(void) sleep_time;
} /* jerry_port_sleep */
#endif /* defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1) */
``` ```
+31 -31
View File
@@ -3,10 +3,10 @@
In JerryScript all `jerry_value_t` values are independent In JerryScript all `jerry_value_t` values are independent
references to internal objects. Values returned by JerryScript references to internal objects. Values returned by JerryScript
API functions are always live references and must be released API functions are always live references and must be released
by `jerry_release_value`. by `jerry_value_free`.
```c ```c
jerry_value_t global = jerry_get_global_object (); jerry_value_t global = jerry_current_realm ();
/* The value stored in the 'global' variable contains a live /* The value stored in the 'global' variable contains a live
* reference to the global object. The system also keeps its * reference to the global object. The system also keeps its
@@ -14,9 +14,9 @@ by `jerry_release_value`.
* are independent, and both must be destroyed before the global * are independent, and both must be destroyed before the global
* object can be freed. */ * object can be freed. */
jerry_release_value (global); jerry_value_free (global);
/* Without jerry_release_value() the global object will not /* Without jerry_value_free() the global object will not
* be freed even by jerry_cleanup(). After the reference * be freed even by jerry_cleanup(). After the reference
* is released it becomes a dead reference and cannot be * is released it becomes a dead reference and cannot be
* used anymore. */ * used anymore. */
@@ -26,15 +26,15 @@ Multiple references might refer to the same internal object
even though their `jerry_value_t` representation might be different. even though their `jerry_value_t` representation might be different.
```c ```c
jerry_value_t pi_ref1 = jerry_create_number (3.14); jerry_value_t pi_ref1 = jerry_number (3.14);
jerry_value_t pi_ref2 = jerry_acquire_value (pi_ref1); jerry_value_t pi_ref2 = jerry_value_copy (pi_ref1);
/* Both pi_ref1 and pi_ref2 refer to the same 3.14 value /* Both pi_ref1 and pi_ref2 refer to the same 3.14 value
* although they might not be equal in C (pi_ref1 != pi_ref2). */ * although they might not be equal in C (pi_ref1 != pi_ref2). */
/* Both references must be released. */ /* Both references must be released. */
jerry_release_value (pi_ref1); jerry_value_free (pi_ref1);
jerry_release_value (pi_ref2); jerry_value_free (pi_ref2);
``` ```
Releasing the same `jerry_value_t` twice to release two live Releasing the same `jerry_value_t` twice to release two live
@@ -42,8 +42,8 @@ references is not allowed and it might cause crashes. Hence the
following code is an **INCORRECT WAY** of releasing the 3.14 value. following code is an **INCORRECT WAY** of releasing the 3.14 value.
```c ```c
jerry_release_value (pi_ref1); jerry_value_free (pi_ref1);
jerry_release_value (pi_ref1); jerry_value_free (pi_ref1);
``` ```
JerryScript API functions returning with a `jerry_value_t` always JerryScript API functions returning with a `jerry_value_t` always
@@ -53,7 +53,7 @@ stated in the documentation). The next example shows this
behaviour through property getting and setting. behaviour through property getting and setting.
```c ```c
jerry_value_t prop_value = jerry_get_property (...); jerry_value_t prop_value = jerry_object_get (...);
/* The prop_value must be released later because both the base /* The prop_value must be released later because both the base
* object and the prop_value have an independent reference to * object and the prop_value have an independent reference to
@@ -61,7 +61,7 @@ behaviour through property getting and setting.
* prop_value contains a live reference to an error object. * prop_value contains a live reference to an error object.
* This reference must be released as well. */ * This reference must be released as well. */
if (jerry_value_is_error (prop_value)) if (jerry_value_is_exception (prop_value))
{ {
/* Errors can be handled here. */ /* Errors can be handled here. */
} }
@@ -73,12 +73,12 @@ behaviour through property getting and setting.
} }
/* The prop_value must be released. */ /* The prop_value must be released. */
jerry_release_value (prop_value); jerry_value_free (prop_value);
/* Property setting is the same. */ /* Property setting is the same. */
jerry_value_t new_prop_value = jerry_create_number (2.718); jerry_value_t new_prop_value = jerry_number (2.718);
jerry_value_t result = jerry_set_property (..., new_prop_value); jerry_value_t result = jerry_object_set (..., new_prop_value);
/* If the property set is successful, a new reference is created /* If the property set is successful, a new reference is created
* for the value referenced by new_prop_value. The new_prop_value * for the value referenced by new_prop_value. The new_prop_value
@@ -86,14 +86,14 @@ behaviour through property getting and setting.
* is successful. */ * is successful. */
/* The new_prop_value can be passed to other JerryScript API /* The new_prop_value can be passed to other JerryScript API
* functions before the jerry_release_value () call. */ * functions before the jerry_value_free () call. */
jerry_release_value (new_prop_value); jerry_value_free (new_prop_value);
/* The reference stored in the 'result' variable is live whether /* The reference stored in the 'result' variable is live whether
* the operation is successful or not, and must also be freed. */ * the operation is successful or not, and must also be freed. */
if (jerry_value_is_error (result)) if (jerry_value_is_exception (result))
{ {
/* Errors can be handled here. */ /* Errors can be handled here. */
} }
@@ -102,7 +102,7 @@ behaviour through property getting and setting.
/* A reference to a true primitive value is returned. */ /* A reference to a true primitive value is returned. */
} }
jerry_release_value (result); jerry_value_free (result);
``` ```
The simplest form of setting a property without error checking The simplest form of setting a property without error checking
@@ -110,8 +110,8 @@ is the following:
```c ```c
/* There are no 'ifs' in this snippet. */ /* There are no 'ifs' in this snippet. */
jerry_release_value (jerry_set_property (..., new_prop_value)); jerry_value_free (jerry_object_set (..., new_prop_value));
jerry_release_value (new_prop_value); jerry_value_free (new_prop_value);
``` ```
The reference returned by a `jerry_external_handler_t` callback The reference returned by a `jerry_external_handler_t` callback
@@ -128,48 +128,48 @@ jerry_value_t my_external_handler (const jerry_value_t function_obj,
* these references are automatically released after the handler * these references are automatically released after the handler
* is returned. This approach reduces code size which is useful * is returned. This approach reduces code size which is useful
* on embedded systems. However you can create other references * on embedded systems. However you can create other references
* to them by calling jerry_acquire_value () if needed. */ * to them by calling jerry_value_copy () if needed. */
/* Since the ownership of the reference is transferred to the /* Since the ownership of the reference is transferred to the
* caller the following snippet is valid. */ * caller the following snippet is valid. */
/* If the value to be returned is needed for other purposes the /* If the value to be returned is needed for other purposes the
* jerry_acquire_value () can be used to create new references. */ * jerry_value_copy () can be used to create new references. */
return jerry_create_string (...); return jerry_string (...);
} }
``` ```
Duplicating a `jerry_value_t` in C does not create another live reference. Duplicating a `jerry_value_t` in C does not create another live reference.
```c ```c
jerry_value_t undef = jerry_create_undefined (); jerry_value_t undef = jerry_undefined ();
jerry_value_t undef2 = undef; jerry_value_t undef2 = undef;
/* Releasing either undef or undef2 is valid but not both. /* Releasing either undef or undef2 is valid but not both.
* After the release both references become dead (invalid). */ * After the release both references become dead (invalid). */
jerry_release_value (undef2); jerry_value_free (undef2);
/* Dead references can be reassigned again. */ /* Dead references can be reassigned again. */
undef = jerry_create_boolean (true); undef = jerry_boolean (true);
``` ```
References can be duplicated in C as long as only one of them is freed. References can be duplicated in C as long as only one of them is freed.
```c ```c
jerry_value_t a = jerry_create_boolean (true); jerry_value_t a = jerry_boolean (true);
jerry_value_t b = a; jerry_value_t b = a;
jerry_value_t c = a; jerry_value_t c = a;
/* A new reference is assigned to 'a'. */ /* A new reference is assigned to 'a'. */
a = jerry_create_boolean (false); a = jerry_boolean (false);
[...] [...]
jerry_release_value (a); jerry_value_free (a);
/* The 'a' (boolean false) reference becomes dead (invalid). */ /* The 'a' (boolean false) reference becomes dead (invalid). */
jerry_release_value (c); jerry_value_free (c);
/* Both 'b' and 'c' (boolean true) references become dead. */ /* Both 'b' and 'c' (boolean true) references become dead. */
/* Since all references are released, no memory leak occurs. */ /* Since all references are released, no memory leak occurs. */
+28 -56
View File
@@ -74,8 +74,8 @@ Currently, `jerryx_debugger_rp_create ()` for raw packet transport layer and
`jerryx_debugger_serial_create (const char* config)` for serial protocol `jerryx_debugger_serial_create (const char* config)` for serial protocol
are also available.) are also available.)
The resource name provided to `jerry_parse ()` is used by the client The source name provided to `jerry_parse ()` is used by the client
to identify the resource name of the source code. This resource name to identify the source name of the source code. This source name
is usually a file name. is usually a file name.
## JerryScript debugger C-API interface ## JerryScript debugger C-API interface
@@ -97,14 +97,15 @@ when a source code is received successfully.
```c ```c
typedef jerry_value_t typedef jerry_value_t
(*jerry_debugger_wait_for_source_callback_t) (const jerry_char_t *resource_name_p, (*jerry_debugger_wait_for_source_callback_t) (const jerry_char_t *source_name_p,
size_t resource_name_size, size_t source_name_size,
const jerry_char_t *source_p, const jerry_char_t *source_p,
size_t source_size, void *user_p); size_t source_size,
void *user_p);
``` ```
- `resource_name_p` - resource (usually a file) name of the source code - `source_name_p` - source (usually a file) name of the source code
- `resource_name_size` - size of resource name - `source_name_size` - size of source name
- `source_p` - source code character data - `source_p` - source code character data
- `source_size` - size of source code - `source_size` - size of source code
- `user_p` - custom pointer passed to [jerry_debugger_wait_for_client_source](#jerry_debugger_wait_for_client_source) - `user_p` - custom pointer passed to [jerry_debugger_wait_for_client_source](#jerry_debugger_wait_for_client_source)
@@ -130,6 +131,8 @@ jerry_debugger_is_connected (void);
[doctest]: # (test="link") [doctest]: # (test="link")
```c ```c
#include <stdio.h>
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/debugger.h" #include "jerryscript-ext/debugger.h"
@@ -291,7 +294,8 @@ return value of the function.
```c ```c
jerry_debugger_wait_for_source_status_t jerry_debugger_wait_for_source_status_t
jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t callback_p, jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t callback_p,
void *user_p, jerry_value_t *return_value) void *user_p,
jerry_value_t *return_value)
``` ```
**Example** **Example**
@@ -306,25 +310,30 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
* Runs the source code received by jerry_debugger_wait_for_client_source. * Runs the source code received by jerry_debugger_wait_for_client_source.
*/ */
static jerry_value_t static jerry_value_t
wait_for_source_callback (const jerry_char_t *resource_name_p, /**< resource name */ wait_for_source_callback (const jerry_char_t *source_name_p, /**< source name */
size_t resource_name_size, /**< size of resource name */ size_t source_name_size, /**< size of source name */
const jerry_char_t *source_p, /**< source code */ const jerry_char_t *source_p, /**< source code */
size_t source_size, /**< source code size */ size_t source_size, /**< source code size */
void *user_p /**< user pointer */) void *user_p /**< user pointer */)
{ {
(void) user_p; (void) user_p;
jerry_value_t ret_val = jerry_parse (resource_name_p, jerry_parse_options_t parse_options;
resource_name_size, parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME;
source_p, parse_options.source_name = jerry_string ((const jerry_char_t *) source_name_p,
source_size, (jerry_size_t) source_name_size,
JERRY_PARSE_NO_OPTS); JERRY_ENCODING_UTF8);
if (!jerry_value_is_error (ret_val)) jerry_value_t ret_val = jerry_parse (source_p,
source_size,
&parse_options);
jerry_value_free (parse_options.source_name);
if (!jerry_value_is_exception (ret_val))
{ {
jerry_value_t func_val = ret_val; jerry_value_t func_val = ret_val;
ret_val = jerry_run (func_val); ret_val = jerry_run (func_val);
jerry_release_value (func_val); jerry_value_free (func_val);
} }
return ret_val; return ret_val;
@@ -352,7 +361,7 @@ main (void)
NULL, NULL,
&run_result); &run_result);
jerry_release_value (run_result); jerry_value_free (run_result);
} }
while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED); while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED);
@@ -378,7 +387,7 @@ Sends the program's output to the debugger client.
```c ```c
void void
jerry_debugger_send_output (const jerry_char_t *buffer, jerry_size_t string_size) jerry_debugger_send_output (const jerry_char_t *buffer, jerry_size_t str_size)
``` ```
**Example** **Example**
@@ -404,40 +413,3 @@ main (void)
jerry_cleanup (); jerry_cleanup ();
} }
``` ```
### jerry_debugger_send_log
**Summary**
Sends the program's log to the debugger client.
**Prototype**
```c
void
jerry_debugger_send_log (jerry_log_level_t level, const jerry_char_t *buffer, jerry_size_t string_size)
```
**Example**
[doctest]: # (test="link")
```c
#include "jerryscript.h"
#include "jerryscript-ext/debugger.h"
int
main (void)
{
jerry_init (JERRY_INIT_EMPTY);
jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
&& jerryx_debugger_ws_create ());
jerry_char_t my_log[] = "Custom diagnostics";
jerry_size_t my_log_size = sizeof (my_log);
jerry_debugger_send_log (JERRY_LOG_LEVEL_DEBUG, my_log, my_log_size);
jerry_cleanup ();
}
```
+10 -4
View File
@@ -12,7 +12,7 @@ review.
* Tab characters are not allowed. * Tab characters are not allowed.
* Maximum line length is 120 characters (excluding newline). * Maximum line length is 120 characters (excluding newline).
* No trailing white space is allowed. * No trailing white space is allowed.
* Run `tools/run-tests.py --check-vera` to check several * Run `tools/run-tests.py --check-format` to check several
of the coding conventions automatically. of the coding conventions automatically.
## Comments ## Comments
@@ -46,7 +46,7 @@ is doing.
/* not a complete sentence */ /* not a complete sentence */
/* A bad mulitiline /* A bad multiline
comment. */ comment. */
``` ```
@@ -369,7 +369,7 @@ a = 6;
b = 7; b = 7;
/* No newlines are allowed between control staments /* No newlines are allowed between control statements
* and their code blocks. */ * and their code blocks. */
if (a > 6) if (a > 6)
@@ -419,7 +419,7 @@ a=b+c;
a = b+c; a = b+c;
a += c + ( d ); a += c + ( d );
/* Introduce temporary variables or macros /* Introduce temporary variables or macros
* if the expression is too long. Occures rarely.. */ * if the expression is too long. Occurs rarely.. */
a = b a = b
+ c; + c;
if ( a + b > 0 ) if ( a + b > 0 )
@@ -739,6 +739,12 @@ typedef
char wrong_newlines_again_t; char wrong_newlines_again_t;
``` ```
### Type usage conventions
- 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`
## Function declarations ## Function declarations
Function declarations in JerryScript are verbose but this format Function declarations in JerryScript are verbose but this format
+47 -8
View File
@@ -244,7 +244,7 @@ my_external_handler (const jerry_value_t function_obj,
mapping, mapping,
4); 4);
if (jerry_value_is_error (rv)) if (jerry_value_is_exception (rv))
{ {
/* Handle error. */ /* Handle error. */
return rv; return rv;
@@ -255,7 +255,7 @@ my_external_handler (const jerry_value_t function_obj,
* required_bool, required_str and optional_num can now be used. * required_bool, required_str and optional_num can now be used.
*/ */
return jerry_create_undefined (); /* Or return something more meaningful. */ return jerry_undefined (); /* Or return something more meaningful. */
} }
``` ```
@@ -361,6 +361,28 @@ jerryx_arg_transform_array (const jerry_value_t array_val,
- [jerryx_arg_array](#jerryx_arg_array) - [jerryx_arg_array](#jerryx_arg_array)
## jerryx_arg_transform_optional
**Summary**
The common function to deal with optional arguments. The core transform function is provided by argument `func`.
**Prototype**
```c
jerry_value_t jerryx_arg_transform_optional (jerryx_arg_js_iterator_t *js_arg_iter_p,
const jerryx_arg_t *c_arg_p,
jerryx_arg_transform_func_t func);
```
- `js_arg_iter_p` - the JS arg iterator.
- `c_arg_p` - the native arg.
- `func` - the core transform function.
- return value - a `jerry_value_t` representing `undefined` if all validators passed or an `Error` if a validator failed.
**See also**
- [jerryx_arg_transform_func_t](#jerryx_arg_transform_func_t)
# Helpers for commonly used validations # Helpers for commonly used validations
@@ -577,11 +599,11 @@ User should prepare the `jerryx_arg_object_props_t` instance, and pass it to thi
```c ```c
static inline jerryx_arg_t static inline jerryx_arg_t
jerryx_arg_object_properties (const jerryx_arg_object_props_t *object_props_p, jerryx_arg_object_properties (const jerryx_arg_object_props_t *obj_prop_p,
jerryx_arg_optional_t opt_flag); jerryx_arg_optional_t opt_flag);
``` ```
- return value - the created `jerryx_arg_t` instance. - return value - the created `jerryx_arg_t` instance.
- `object_props_p` - provides information for properties transform. - `obj_prop_p` - provides information for properties transform.
- `opt_flag` - whether the argument is optional. - `opt_flag` - whether the argument is optional.
**Example** **Example**
@@ -640,7 +662,7 @@ my_external_handler (const jerry_value_t function_obj,
mapping, mapping,
1); 1);
if (jerry_value_is_error (rv)) if (jerry_value_is_exception (rv))
{ {
/* Handle error. */ /* Handle error. */
return rv; return rv;
@@ -651,7 +673,7 @@ my_external_handler (const jerry_value_t function_obj,
* required_bool, required_num and optional_num can now be used. * required_bool, required_num and optional_num can now be used.
*/ */
return jerry_create_undefined (); /* Or return something more meaningful. */ return jerry_undefined (); /* Or return something more meaningful. */
} }
``` ```
@@ -731,7 +753,7 @@ my_external_handler (const jerry_value_t function_obj,
mapping, mapping,
1); 1);
if (jerry_value_is_error (rv)) if (jerry_value_is_exception (rv))
{ {
/* Handle error. */ /* Handle error. */
return rv; return rv;
@@ -742,7 +764,7 @@ my_external_handler (const jerry_value_t function_obj,
* required_bool, required_num and optional_num can now be used. * required_bool, required_num and optional_num can now be used.
*/ */
return jerry_create_undefined (); /* Or return something more meaningful. */ return jerry_undefined (); /* Or return something more meaningful. */
} }
``` ```
@@ -754,6 +776,23 @@ my_external_handler (const jerry_value_t function_obj,
# Functions to create custom validations # Functions to create custom validations
## jerryx_arg_ignore
**Summary**
Create a jerryx_arg_t instance for ignored argument.
**Prototype**
```c
static inline jerryx_arg_t jerryx_arg_ignore (void);
```
- return value - the created `jerryx_arg_t` instance.
**See also**
- [jerryx_arg_t](#jerryx_arg_t)
## jerryx_arg_custom ## jerryx_arg_custom
**Summary** **Summary**
+61 -258
View File
@@ -1,173 +1,8 @@
# Common methods to handle properties # Common methods to handle properties
The `jerryscript-ext/handler.h` header defines a set of convenience methods The `jerryscript-ext/properties.h` header defines a set of convenience methods
which makes the property access a bit straightforward. which makes the property access a bit straightforward.
## jerryx_set_property_str
**Summary**
Set a property on a target object with a given name.
*Note*:
- The property name must be a zero terminated UTF-8 string.
- There should be no '\0' (NULL) character in the name excluding the string terminator.
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
is no longer needed.
**Prototype**
```c
jerry_value_t
jerryx_set_property_str (const jerry_value_t target_object,
const char *name,
const jerry_value_t value);
```
- `target_object` - the object where the property should be set
- `name` - name of the property
- `value` - property value to be set
- return value
- JS true value, if success
- thrown error, if there was a problem setting the property
**Example**
[doctest]: # ()
```c
#include "jerryscript.h"
#include "jerryscript-ext/handler.h"
int
main (int argc, char **argv)
{
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t global = jerry_get_global_object ();
jerry_value_t value = jerry_create_number (3.3);
jerry_value_t result = jerryx_set_property_str (global, "value", value);
if (jerry_value_is_error (result))
{
/* The error type/reason can be extracted via the `jerry_get_value_from_error` method */
printf ("Error during property configuration\r\n");
}
jerry_release_value (result);
jerry_release_value (value);
jerry_release_value (global);
jerry_cleanup();
return 0;
}
```
## jerryx_get_property_str
**Summary**
Get the value of a property from the specified object with the given name.
*Notes*:
- The property name must be a zero terminated UTF-8 string.
- There should be no '\0' (NULL) character in the name excluding the string terminator.
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
is no longer needed.
**Prototype**
```
jerry_value_t
jerryx_get_property_str (const jerry_value_t target_object,
const char *name);
```
- `target_object` - object on which the property name is accessed
- `name` - property name as an UTF-8 `char*`
- return value
- value of property, if success
- thrown error, if there was a problem accessing the property
**Example**
[doctest]: # ()
```c
#include "jerryscript.h"
#include "jerryscript-ext/handler.h"
int
main (int argc, char **argv)
{
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t global = jerry_get_global_object ();
jerry_value_t math_object = jerryx_get_property_str (global, "Math");
/* use math_object */
jerry_release_value (math_object);
jerry_release_value (global);
jerry_cleanup();
return 0;
}
```
## jerryx_has_property_str
**Summary**
Check if a property exists on an object.
*Notes*:
- The operation performed is the same as what the `jerry_has_property` method.
- The property name must be a zero terminated UTF-8 string.
- There should be no '\0' (NULL) character in the name excluding the string terminator.
**Prototype**
```
bool
jerryx_has_property_str (const jerry_value_t target_object,
const char *name);
```
- `target_object` - object on which the property name is accessed
- `name` - property name as an UTF-8 `char*`
- return value
- true, if the given property name exsits on the object
- false, if there is no such property name or there was an error accessing the property
**Example**
[doctest]: # ()
```c
#include "jerryscript.h"
#include "jerryscript-ext/handler.h"
int
main (int argc, char **argv)
{
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t global = jerry_get_global_object ();
bool have_math = jerryx_has_property_str (global, "Math");
jerry_release_value (global);
jerry_cleanup();
return have_math ? 0 : 1;
}
```
# Utility to register multiple properties in bulk # Utility to register multiple properties in bulk
In some cases it is useful to register multiple properties for a given object In some cases it is useful to register multiple properties for a given object
@@ -180,7 +15,7 @@ for this the following utility structures and methods are provided.
Structure to define an array of properties with `name` and `value` fields which Structure to define an array of properties with `name` and `value` fields which
can be registered to a target object. can be registered to a target object.
The engine must be initialied before specifying the `jerry_value_t` in the struct. The engine must be initialized before specifying the `jerry_value_t` in the struct.
**Prototype** **Prototype**
@@ -189,7 +24,7 @@ The engine must be initialied before specifying the `jerry_value_t` in the struc
typedef struct { typedef struct {
const char *name; const char *name;
jerry_value_t value; jerry_value_t value;
} jerryx_function_list_entry; } jerryx_property_entry;
``` ```
**See also** **See also**
@@ -209,7 +44,7 @@ successfully registered methods.
This must be passed for the [jerryx_release_property_entry](#jerryx_release_property_entry) method This must be passed for the [jerryx_release_property_entry](#jerryx_release_property_entry) method
after the property registration. after the property registration.
If any error occured during the property registration the `result` field of the structure If any error occurred during the property registration the `result` field of the structure
must be manually released after processing the error value. must be manually released after processing the error value.
**Prototype** **Prototype**
@@ -263,18 +98,19 @@ jerryx_set_properties (const jerry_value_t target_object,
[doctest]: # () [doctest]: # ()
```c ```c
#include <stdio.h>
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
static jerry_value_t static jerry_value_t
handler (const jerry_value_t function_obj, handler (const jerry_call_info_t *call_info_p,
const jerry_value_t this_val,
const jerry_value_t args_p[], const jerry_value_t args_p[],
const jerry_length_t args_cnt) const jerry_length_t args_cnt)
{ {
printf ("native handler called!\n"); printf ("native handler called!\n");
return jerry_create_boolean (true); return jerry_boolean (true);
} }
int int
@@ -284,24 +120,24 @@ main (int argc, char **argv)
jerryx_property_entry methods[] = jerryx_property_entry methods[] =
{ {
{ "demo", jerry_create_external_function (handler) }, { "demo", jerry_function_external (handler) },
{ NULL, 0 }, { NULL, 0 },
}; };
jerry_value_t global = jerry_get_global_object (); jerry_value_t global = jerry_current_realm ();
jerryx_register_result reg = jerryx_set_properties (global, methods); jerryx_register_result reg = jerryx_set_properties (global, methods);
/* if `reg.result` is undefined all methods are registered */ /* if `reg.result` is undefined all methods are registered */
if (jerry_value_is_error (reg.result)) if (jerry_value_is_exception (reg.result))
{ {
printf ("Only registered %d properties\r\n", reg.registered); printf ("Only registered %d properties\r\n", reg.registered);
/* clean up not registered property values */ /* clean up not registered property values */
jerryx_release_property_entry (methods, reg); jerryx_release_property_entry (methods, reg);
/* clean up the error */ /* clean up the error */
jerry_release_value (reg.result); jerry_value_free (reg.result);
} }
jerry_release_value (global); jerry_value_free (global);
jerry_cleanup(); jerry_cleanup();
@@ -315,8 +151,8 @@ To make property registration convenient, there are a set of macros to use
when setting a property entry: when setting a property entry:
* `JERRYX_PROPERTY_NUMBER(NAME, NUMBER)` - creates a number entry. * `JERRYX_PROPERTY_NUMBER(NAME, NUMBER)` - creates a number entry.
* `JERRYX_PROPERTY_STRING(NAME, STR)` - creates an UTF-8 string entry. This string must be zero terminated. * `JERRYX_PROPERTY_STRING(NAME, STR, SIZE)` - creates an UTF-8 string entry using `SIZE` bytes from the string.
* `JERRYX_PROPERTY_STRING_SZ(NAME, STR, SIZE)` - creates an UTF-8 string entry using only `SIZE` bytes from the string. * `JERRYX_PROPERTY_STRING_SZ(NAME, STR)` - creates an ASCII string entry. This string must be zero terminated.
* `JERRYX_PROPERTY_BOOLEAN(NAME, VALUE)` - creates a boolean entry. * `JERRYX_PROPERTY_BOOLEAN(NAME, VALUE)` - creates a boolean entry.
* `JERRYX_PROPERTY_FUNCTION(NAME, NATIVE)` - creates a native C function entry. * `JERRYX_PROPERTY_FUNCTION(NAME, NATIVE)` - creates a native C function entry.
* `JERRYX_PROPERTY_UNDEFINED(NAME)` - creates an undefined property entry. * `JERRYX_PROPERTY_UNDEFINED(NAME)` - creates an undefined property entry.
@@ -327,18 +163,19 @@ when setting a property entry:
[doctest]: # () [doctest]: # ()
```c ```c
#include <stdio.h>
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
static jerry_value_t static jerry_value_t
handler (const jerry_value_t function_obj, handler (const jerry_call_info_t *call_info_p,
const jerry_value_t this_val,
const jerry_value_t args_p[], const jerry_value_t args_p[],
const jerry_length_t args_cnt) const jerry_length_t args_cnt)
{ {
printf ("native handler called!\n"); printf ("native handler called!\n");
return jerry_create_boolean (true); return jerry_boolean (true);
} }
int int
@@ -359,20 +196,20 @@ main (int argc, char **argv)
JERRYX_PROPERTY_LIST_END(), JERRYX_PROPERTY_LIST_END(),
}; };
jerry_value_t global = jerry_get_global_object (); jerry_value_t global = jerry_current_realm ();
jerryx_register_result reg = jerryx_set_properties (global, methods); jerryx_register_result reg = jerryx_set_properties (global, methods);
/* if `reg.result` is undefined all methods are registered */ /* if `reg.result` is undefined all methods are registered */
if (jerry_value_is_error (reg.result)) if (jerry_value_is_exception (reg.result))
{ {
printf ("Only registered %d properties\r\n", reg.registered); printf ("Only registered %d properties\r\n", reg.registered);
/* clean up not registered property values */ /* clean up not registered property values */
jerryx_release_property_entry (methods, reg); jerryx_release_property_entry (methods, reg);
/* clean up the error */ /* clean up the error */
jerry_release_value (reg.result); jerry_value_free (reg.result);
} }
jerry_release_value (global); jerry_value_free (global);
jerry_cleanup(); jerry_cleanup();
@@ -395,7 +232,7 @@ Release all `jerry_value_t` in a `jerryx_property_entry` array based on a previo
and also the error value (if any) in the `jerryx_register_result` structure. and also the error value (if any) in the `jerryx_register_result` structure.
In case of a successful registration it is safe to call this method. In case of a successful registration it is safe to call this method.
After the method call the `ęntries` array should not be used as all values are released. After the method call the `entries` array should not be used as all values are released.
**Prototype** **Prototype**
@@ -405,7 +242,7 @@ jerryx_release_property_entry (const jerryx_property_entry entries[],
const jerryx_register_result register_result); const jerryx_register_result register_result);
``` ```
- `entires` - array of [jerryx_property_entry](#jerryx_property_entry). - `entries` - array of [jerryx_property_entry](#jerryx_property_entry).
- `register_result` - result of a previous [jerryx_set_properties](#jerryx_set_properties) call. - `register_result` - result of a previous [jerryx_set_properties](#jerryx_set_properties) call.
**Example** **Example**
@@ -415,7 +252,7 @@ For example usage see [jerryx_set_properties](#jerryx_set_properties).
# Common external function handlers # Common external function handlers
## jerryx_handler_assert_fatal ## jerryx_handler_assert
**Summary** **Summary**
@@ -428,12 +265,13 @@ a backtrace is also printed out.
```c ```c
jerry_value_t jerry_value_t
jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, const jerry_value_t this_p, jerryx_handler_assert (const jerry_call_info_t *call_info_p,
const jerry_value_t args_p[], const jerry_length_t args_cnt); const jerry_value_t args_p[],
const jerry_length_t args_cnt);
``` ```
- `func_obj_val` - the function object that was called (unused). - `call_info_p` - pointer to a [jerry_call_info_t](#jerry_call_info_t)
- `this_p` - the `this` value of the call (unused). structure which holds call related information (unused).
- `args_p` - the array of function arguments. - `args_p` - the array of function arguments.
- `args_cnt` - the number of function arguments. - `args_cnt` - the number of function arguments.
- return value - `jerry_value_t` representing boolean true, if only one argument - return value - `jerry_value_t` representing boolean true, if only one argument
@@ -442,44 +280,7 @@ jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, const jerry_value
**See also** **See also**
- [jerryx_handler_register_global](#jerryx_handler_register_global) - [jerryx_register_global](#jerryx_register_global)
## jerryx_handler_assert_throw
**Summary**
Soft assert for scripts. The routine throws an error on assertion failure.
**Prototype**
```c
jerry_value_t
jerryx_handler_assert_throw (const jerry_value_t func_obj_val, const jerry_value_t this_p,
const jerry_value_t args_p[], const jerry_length_t args_cnt);
```
- `func_obj_val` - the function object that was called (unused).
- `this_p` - the `this` value of the call (unused).
- `args_p` - the array of function arguments.
- `args_cnt` - the number of function arguments.
- return value - `jerry_value_t` representing boolean true, if only one argument
was passed and that argument was a boolean true, an error otherwise.
**See also**
- [jerryx_handler_register_global](#jerryx_handler_register_global)
## jerryx_handler_assert
**Summary**
An alias to `jerryx_handler_assert_fatal`.
**See also**
- [jerryx_handler_assert_fatal](#jerryx_handler_assert_fatal)
## jerryx_handler_gc ## jerryx_handler_gc
@@ -494,19 +295,20 @@ gc is performed, which is also the default if no parameters passed.
```c ```c
jerry_value_t jerry_value_t
jerryx_handler_gc (const jerry_value_t func_obj_val, const jerry_value_t this_p, jerryx_handler_gc (const jerry_call_info_t *call_info_p,
const jerry_value_t args_p[], const jerry_length_t args_cnt); const jerry_value_t args_p[],
const jerry_length_t args_cnt);
``` ```
- `func_obj_val` - the function object that was called (unused). - `call_info_p` - pointer to a [jerry_call_info_t](#jerry_call_info_t)
- `this_p` - the `this` value of the call (unused). structure which holds call related information (unused).
- `args_p` - the array of function arguments (unused). - `args_p` - the array of function arguments (unused).
- `args_cnt` - the number of function arguments (unused). - `args_cnt` - the number of function arguments (unused).
- return value - `jerry_value_t` representing `undefined`. - return value - `jerry_value_t` representing `undefined`.
**See also** **See also**
- [jerryx_handler_register_global](#jerryx_handler_register_global) - [jerryx_register_global](#jerryx_register_global)
## jerryx_handler_print ## jerryx_handler_print
@@ -514,26 +316,26 @@ jerryx_handler_gc (const jerry_value_t func_obj_val, const jerry_value_t this_p,
**Summary** **Summary**
Provide a `print` implementation for scripts. The routine converts all of its Provide a `print` implementation for scripts. The routine converts all of its
arguments to strings and outputs them char-by-char using arguments to strings and outputs them by using `jerry_port_print_buffer`.
`jerry_port_print_char`. The NUL character is output as "\u0000", The NULL character is output as "\u0000", other characters are output bytewise.
other characters are output bytewise.
*Note*: This implementation does not use standard C `printf` to print its *Note*: This implementation does not use standard C `printf` to print its
output. This allows more flexibility but also extends the core JerryScript output. This allows more flexibility but also extends the core JerryScript
engine port API. Applications that want to use `jerryx_handler_print` must engine port API. Applications that want to use `jerryx_handler_print` must
ensure that their port implementation also provides ensure that their port implementation also provides
`jerry_port_print_char`. `jerry_port_print_buffer`.
**Prototype** **Prototype**
```c ```c
jerry_value_t jerry_value_t
jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this_p, jerryx_handler_print (const jerry_call_info_t *call_info_p,
const jerry_value_t args_p[], const jerry_length_t args_cnt); const jerry_value_t args_p[],
const jerry_length_t args_cnt);
``` ```
- `func_obj_val` - the function object that was called (unused). - `call_info_p` - pointer to a [jerry_call_info_t](#jerry_call_info_t)
- `this_p` - the `this` value of the call (unused). structure which holds call related information (unused).
- `args_p` - the array of function arguments. - `args_p` - the array of function arguments.
- `args_cnt` - the number of function arguments. - `args_cnt` - the number of function arguments.
- return value - `jerry_value_t` representing `undefined` if all arguments could - return value - `jerry_value_t` representing `undefined` if all arguments could
@@ -541,27 +343,27 @@ jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this
**See also** **See also**
- [jerryx_handler_register_global](#jerryx_handler_register_global) - [jerryx_register_global](#jerryx_register_global)
- [jerry_port_print_char](05.PORT-API.md#jerry_port_print_char) - [jerry_port_print_buffer](05.PORT-API.md#jerry_port_print_buffer)
# Handler registration helper # Handler registration helper
## jerryx_handler_register_global ## jerryx_register_global
**Summary** **Summary**
Register a JavaScript function in the global object. Register a JavaScript function in the global object.
*Note*: Returned value must be freed with `jerry_release_value`, when it is no *Note*: Returned value must be freed with `jerry_value_free`, when it is no
longer needed. longer needed.
**Prototype** **Prototype**
```c ```c
jerry_value_t jerry_value_t
jerryx_handler_register_global (const jerry_char_t *name_p, jerryx_register_global (const char *name_p,
jerry_external_handler_t handler_p); jerry_external_handler_t handler_p);
``` ```
- `name_p` - the name of the function to be registered. - `name_p` - the name of the function to be registered.
@@ -575,7 +377,8 @@ jerryx_handler_register_global (const jerry_char_t *name_p,
```c ```c
#include "jerryscript.h" #include "jerryscript.h"
#include "jerryscript-ext/handler.h" #include "jerryscript-ext/handlers.h"
#include "jerryscript-ext/properties.h"
static const struct { static const struct {
const char *name_p; const char *name_p;
@@ -591,14 +394,14 @@ static const struct {
static void static void
register_common_functions (void) register_common_functions (void)
{ {
jerry_value_t ret = jerry_create_undefined (); jerry_value_t ret = jerry_undefined ();
for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_is_error (ret); i++) for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_is_exception (ret); i++)
{ {
ret = jerryx_handler_register_global ((const jerry_char_t *) common_functions[i].name_p, ret = jerryx_register_global (common_functions[i].name_p,
common_functions[i].handler_p); common_functions[i].handler_p);
} }
jerry_release_value (ret); jerry_value_free (ret);
} }
``` ```
+7 -7
View File
@@ -4,7 +4,7 @@
**Summary** **Summary**
Macro for `const jerry_value_t` for which jerry_release_value() is Macro for `const jerry_value_t` for which jerry_value_free() is
automatically called when the variable goes out of scope. automatically called when the variable goes out of scope.
*Note*: The macro depends on compiler support. For GCC and LLVM/clang, the macro is implemented *Note*: The macro depends on compiler support. For GCC and LLVM/clang, the macro is implemented
@@ -21,23 +21,23 @@ using the `__cleanup__` variable attribute. For other compilers, no support has
static void static void
foo (bool enable) foo (bool enable)
{ {
JERRYX_AR_VALUE_T bar = jerry_create_string ((const jerry_char_t *) "..."); JERRYX_AR_VALUE_T bar = jerry_string_sz ("...");
if (enable) if (enable)
{ {
JERRYX_AR_VALUE_T baz = jerry_get_global_object (); JERRYX_AR_VALUE_T baz = jerry_current_realm ();
/* bar and baz can now be used. */ /* bar and baz can now be used. */
/* /*
* jerry_release_value (baz) and jerry_release_value (bar) is called automatically before * jerry_value_free (baz) and jerry_value_free (bar) is called automatically before
* returning, because `baz` and `bar` go out of scope. * returning, because `baz` and `bar` go out of scope.
*/ */
return; return;
} }
/* /*
* jerry_release_value (bar) is called automatically when the function returns, * jerry_value_free (bar) is called automatically when the function returns,
* because `bar` goes out of scope. * because `bar` goes out of scope.
*/ */
} }
@@ -46,5 +46,5 @@ foo (bool enable)
**See also** **See also**
- [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t) - [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t)
- [jerry_acquire_value](../docs/02.API-REFERENCE.md#jerry_acquire_value) - [jerry_value_copy](../docs/02.API-REFERENCE.md#jerry_value_copy)
- [jerry_release_value](../docs/02.API-REFERENCE.md#jerry_release_value) - [jerry_value_free](../docs/02.API-REFERENCE.md#jerry_value_free)
+9 -9
View File
@@ -37,8 +37,8 @@ resolved using the native JerryScript module resolver `jerryx_module_native_reso
`jerryx_module_resolve()`. Native modules are registered during application startup and by calling `dlopen()` by means `jerryx_module_resolve()`. Native modules are registered during application startup and by calling `dlopen()` by means
of library constructors, support for which can be turned on using the `FEATURE_INIT_FINI` build flag. In the absence of of library constructors, support for which can be turned on using the `FEATURE_INIT_FINI` build flag. In the absence of
such a flag, the module registration and unregistration functions are exposed as global symbols which can be called such a flag, the module registration and unregistration functions are exposed as global symbols which can be called
explicitly. Note: `FEATURE_INIT_FINI` build flag isn't supported on Windows, because Microsoft Visual C/C++ Compiler explicitly. Note: On windows, `FEATURE_INIT_FINI` build flag only supported with GNU toolchain or Microsoft Visual C/C++ Compiler
doesn't support library constructors and destructors. 2008 and upper.
## jerryx_module_resolve ## jerryx_module_resolve
@@ -63,7 +63,7 @@ to `jerryx_module_resolve` with a module name whose canonical name matches an al
```c ```c
jerry_value_t jerry_value_t
jerryx_module_resolve (const jerry_value_t name, jerryx_module_resolve (const jerry_value_t name,
const jerryx_module_resolver_t *resolvers_p, const jerryx_module_resolver_t **resolvers_p,
size_t resolver_count); size_t resolver_count);
``` ```
@@ -84,7 +84,7 @@ Remove a module from the current context's cache, or clear the cache entirely.
```c ```c
void void
jerryx_module_clear_cache (const jerry_value_t name, jerryx_module_clear_cache (const jerry_value_t name,
const jerryx_module_resolver_t *resolvers_p, const jerryx_module_resolver_t **resolvers_p,
size_t resolver_count); size_t resolver_count);
``` ```
@@ -164,9 +164,9 @@ load_and_evaluate_js_file (const jerry_value_t name, jerry_value_t *result)
char *js_file_contents = NULL; char *js_file_contents = NULL;
int file_size = 0; int file_size = 0;
jerry_size_t name_size = jerry_get_utf8_string_size (name); jerry_size_t name_size = jerry_string_size (name, JERRY_ENCODING_UTF8);
jerry_char_t name_string[name_size + 1]; jerry_char_t name_string[name_size + 1];
jerry_string_to_utf8_char_buffer (name, name_string, name_size); jerry_string_to_buffer (name, JERRY_ENCODING_UTF8, name_string, name_size);
name_string[name_size] = 0; name_string[name_size] = 0;
FILE *js_file = fopen (name_string, "r"); FILE *js_file = fopen (name_string, "r");
@@ -205,7 +205,7 @@ canonicalize_file_path (const jerry_value_t name)
/** /**
* Since a file on the file system can be referred to by multiple relative paths, but only by one absolute path, the * Since a file on the file system can be referred to by multiple relative paths, but only by one absolute path, the
* absolute path becomes the canonical name for the module. Thus, to establish this canonical name, we must search * absolute path becomes the canonical name for the module. Thus, to establish this canonical name, we must search
* name for "./" and "../", follow symlinks, etc., then create absolute_path via jerry_create_string () and return * name for "./" and "../", follow symlinks, etc., then create absolute_path via jerry_string () and return
* it, because it is the canonical name for this module. Thus, we avoid loading the same JavaScript file twice. * it, because it is the canonical name for this module. Thus, we avoid loading the same JavaScript file twice.
*/ */
@@ -257,7 +257,7 @@ symbols so that they may be called explicitly from within the application.
#define JERRYX_NATIVE_MODULE(module_name, on_resolve_cb) #define JERRYX_NATIVE_MODULE(module_name, on_resolve_cb)
``` ```
- `module_name` - the name of the module without quotes. This value is used as the prefix for the registration and unregistration funtions. For example, when `module_name` is `example_module`, this results in the declaration of two functions `example_module_register()` and `example_module_unregister()`. These functions are declared global if support for library constructors/destructors is absent, allowing you to call them from other parts of the code by - `module_name` - the name of the module without quotes. This value is used as the prefix for the registration and unregistration functions. For example, when `module_name` is `example_module`, this results in the declaration of two functions `example_module_register()` and `example_module_unregister()`. These functions are declared global if support for library constructors/destructors is absent, allowing you to call them from other parts of the code by
first forward-declaring them. first forward-declaring them.
- `on_resolve_cb` - the function of type `jerryx_native_module_on_resolve_t` that will be called when the module needs to be - `on_resolve_cb` - the function of type `jerryx_native_module_on_resolve_t` that will be called when the module needs to be
loaded. loaded.
@@ -271,7 +271,7 @@ loaded.
static jerry_value_t static jerry_value_t
my_module_on_resolve (void) my_module_on_resolve (void)
{ {
return jerry_create_external_function (very_useful_function); return jerry_function_external (very_useful_function);
} /* my_module_on_resolve */ } /* my_module_on_resolve */
/* Note that there is no semicolon at the end of the next line. This is how it must be. */ /* Note that there is no semicolon at the end of the next line. This is how it must be. */
+8 -5
View File
@@ -77,7 +77,8 @@ the `header_p->next_p->send()` method.
```c ```c
typedef bool (*jerry_debugger_transport_send_t) (struct jerry_debugger_transport_interface_t *header_p, typedef bool (*jerry_debugger_transport_send_t) (struct jerry_debugger_transport_interface_t *header_p,
uint8_t *message_p, size_t message_length); uint8_t *message_p,
size_t message_length);
``` ```
## jerry_debugger_transport_receive_t ## jerry_debugger_transport_receive_t
@@ -100,18 +101,20 @@ typedef bool (*jerry_debugger_transport_receive_t) (struct jerry_debugger_transp
**Summary** **Summary**
Add a new interface to the transporation interface chain. The interface Add a new interface to the transportation interface chain. The interface
will be the first item of the interface chain. will be the first item of the interface chain.
**Prototype** **Prototype**
```c ```c
void jerry_debugger_transport_add (jerry_debugger_transport_header_t *header_p, void jerry_debugger_transport_add (jerry_debugger_transport_header_t *header_p,
size_t send_message_header_size, size_t max_send_message_size, size_t send_message_header_size,
size_t receive_message_header_size, size_t max_receive_message_size); size_t max_send_message_size,
size_t receive_message_header_size,
size_t max_receive_message_size);
``` ```
- `header_p`: header of a transporation interface. - `header_p`: header of a transportation interface.
- `send_message_header_size`: size of the outgoing message header, can be 0. - `send_message_header_size`: size of the outgoing message header, can be 0.
- `max_send_message_size`: maximum outgoing message size supported by the interface. - `max_send_message_size`: maximum outgoing message size supported by the interface.
- `receive_message_header_size`: size of the incoming message header, can be 0. - `receive_message_header_size`: size of the incoming message header, can be 0.
+8 -8
View File
@@ -11,7 +11,7 @@ JerryScript only supports a single nested hierarchy of scopes. There is only one
**Example** **Example**
[doctest]: # (test="compile") [doctest]: # ()
```c ```c
#include "jerryscript.h" #include "jerryscript.h"
@@ -20,7 +20,7 @@ JerryScript only supports a single nested hierarchy of scopes. There is only one
static jerry_value_t static jerry_value_t
create_object (void) create_object (void)
{ {
jerry_value_t obj = jerry_create_object (); jerry_value_t obj = jerry_object ();
return obj; return obj;
} /* create_object */ } /* create_object */
@@ -41,7 +41,7 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
test_handle_scope_val (); test_handle_scope_val ();
jerry_gc (JERRY_GC_PRESSURE_LOW); jerry_heap_gc (JERRY_GC_PRESSURE_LOW);
jerry_cleanup (); jerry_cleanup ();
} /* main */ } /* main */
@@ -55,7 +55,7 @@ It is necessary in common cases that a handle has to be promote to outer scope a
**Example** **Example**
[doctest]: # (test="compile") [doctest]: # ()
```c ```c
#include "jerryscript.h" #include "jerryscript.h"
@@ -66,7 +66,7 @@ create_object (void)
{ {
jerryx_escapable_handle_scope scope; jerryx_escapable_handle_scope scope;
jerryx_open_escapable_handle_scope (&scope); jerryx_open_escapable_handle_scope (&scope);
jerry_value_t obj = jerryx_create_handle (jerry_create_object ()); jerry_value_t obj = jerryx_create_handle (jerry_object ());
jerry_value_t escaped_obj; jerry_value_t escaped_obj;
jerryx_escape_handle(scope, obj, &escaped_obj); jerryx_escape_handle(scope, obj, &escaped_obj);
@@ -93,7 +93,7 @@ main (void)
jerry_init (JERRY_INIT_EMPTY); jerry_init (JERRY_INIT_EMPTY);
test_handle_scope_val (); test_handle_scope_val ();
jerry_gc (JERRY_GC_PRESSURE_LOW); jerry_heap_gc (JERRY_GC_PRESSURE_LOW);
jerry_cleanup (); jerry_cleanup ();
} /* main */ } /* main */
@@ -102,8 +102,8 @@ main (void)
**See also** **See also**
- [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t) - [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t)
- [jerry_acquire_value](../docs/02.API-REFERENCE.md#jerry_acquire_value) - [jerry_value_copy](../docs/02.API-REFERENCE.md#jerry_value_copy)
- [jerry_release_value](../docs/02.API-REFERENCE.md#jerry_release_value) - [jerry_value_free](../docs/02.API-REFERENCE.md#jerry_value_free)
## Pre-allocated list of handle scopes and handles ## Pre-allocated list of handle scopes and handles
+4 -4
View File
@@ -2,12 +2,12 @@
The module system allows users to write import and export statements in scripts, which can be used to separate the logic of the application into custom modules. The module system allows users to write import and export statements in scripts, which can be used to separate the logic of the application into custom modules.
The standard's relevant part can be found [here](https://www.ecma-international.org/ecma-262/6.0/#sec-modules). The standard's relevant part can be found [here](https://www.ecma-international.org/ecma-262/6.0/#sec-modules).
Embedders wishing to use native builtin modules with ES6 imports can use the [Port API](05.PORT-API.md#es2015-module-system) to do so. Embedders wishing to use native builtin modules with ES6 imports can use the [Port API](05.PORT-API.md#jerry-module-system) to do so.
## General ## General
If a script contains import statements, then JerryScript will open and evaluate the the referenced modules before the main script runs, resolving and creating bindings for the referenced identifiers in the process. If a script contains import statements, then JerryScript will open and evaluate the the referenced modules before the main script runs, resolving and creating bindings for the referenced identifiers in the process.
It is not necessary to use any specific filename extensions for modules, JerryScript will try to open the given file paths as they are, but will try to normalize them before doing so. The exact normalization process is dependant on the port implementation provided. It is the user's responsibility to verify that the given files are valid EcmaScript modules. It is not necessary to use any specific filename extensions for modules, JerryScript will try to open the given file paths as they are, but will try to normalize them before doing so. The exact normalization process is dependant on the port implementation provided. It is the user's responsibility to verify that the given files are valid ECMAScript modules.
main.js main.js
@@ -76,7 +76,7 @@ export var version = "1.0 (e92ae0fb)";
```js ```js
// module_2.js // module_2.js
var featureName = "EcmaScript 2015 modules"; var featureName = "ECMAScript modules";
var year = 2018; var year = 2018;
export function getFeatureDetails() { export function getFeatureDetails() {
@@ -86,7 +86,7 @@ export function getFeatureDetails() {
### Module namespace import statements ### Module namespace import statements
A module namespace object can be imported. In this case the local binding will contain an object holding the exported values of the module, including local exports and all indirect exports. Ambiguous exported names are exluded from the namespace object. A module namespace object can be imported. In this case the local binding will contain an object holding the exported values of the module, including local exports and all indirect exports. Ambiguous exported names are excluded from the namespace object.
```js ```js
import * as module from './module.js'; import * as module from './module.js';
+12 -3
View File
@@ -1,11 +1,11 @@
# Migration guide # Migration guide
This guide intends to describe the major changes between the JerryScript 1.0 and 2.0 versions. This guide intends to describe the major changes between the JerryScript 1.0 and 2.0 versions.
In addtion it is designed to provide a guide on how to modify the 1.0 version code to a In addition it is designed to provide a guide on how to modify the 1.0 version code to a
2.0 compliant code. 2.0 compliant code.
During the development it was important to minimize the changes in the API functions and types. During the development it was important to minimize the changes in the API functions and types.
Each API method removal or chang is described below providing a ***before*** and ***after*** Each API method removal or change is described below providing a ***before*** and ***after***
code example. code example.
For more information on the current API methods please check the [API reference](02.API-REFERENCE.md) document. For more information on the current API methods please check the [API reference](02.API-REFERENCE.md) document.
@@ -53,7 +53,7 @@ For more information on the current API methods please check the [API reference]
## Error manipulating functions ## Error manipulating functions
The most important changes in the API are releated to error handling and manipulation. The most important changes in the API are related to error handling and manipulation.
### jerry_value_set_abort_flag ### jerry_value_set_abort_flag
@@ -770,3 +770,12 @@ In this section the new API functions are listed.
- [`jerry_port_get_current_context`](05.PORT-API.md#jerry_port_get_current_context) - [`jerry_port_get_current_context`](05.PORT-API.md#jerry_port_get_current_context)
- [`jerry_port_fatal`](05.PORT-API.md#jerry_port_fatal) - [`jerry_port_fatal`](05.PORT-API.md#jerry_port_fatal)
- [`jerry_port_sleep`](05.PORT-API.md#jerry_port_sleep) - [`jerry_port_sleep`](05.PORT-API.md#jerry_port_sleep)
- [`jerry_port_print_byte`](05.PORT-API.md#jerry_port_print_byte)
# Migrating from 2.x to 3.x
The most significant change in JerryScript 3.0 was the API rework. Most of the API functions had been
renamed in this version. There are notes for every such function in the [API Reference](02.API-REFERENCE.md)
to help you to migrate from an older version. For example:
*Renamed in version 3.0, it was previously known as `jerry_get_global_object` in earlier versions.*
+451 -91
View File
@@ -12,44 +12,40 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
cmake_minimum_required (VERSION 2.8.12) cmake_minimum_required (VERSION 3.10)
set(JERRY_CORE_NAME jerry-core) set(JERRY_CORE_NAME jerry-core)
project (${JERRY_CORE_NAME} C) project (${JERRY_CORE_NAME} C)
# Optional build settings include(CheckLibraryExists)
set(ENABLE_ALL_IN_ONE OFF CACHE BOOL "Enable all-in-one build?")
# Optional features # Optional features
set(JERRY_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?") set(JERRY_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?") set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?") set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?") set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?") set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?")
set(JERRY_LINE_INFO OFF CACHE BOOL "Enable line info?") set(JERRY_FUNCTION_TO_STRING OFF CACHE BOOL "Enable function toString operation?")
set(JERRY_LOGGING OFF CACHE BOOL "Enable logging?") set(JERRY_LINE_INFO OFF CACHE BOOL "Enable line info?")
set(JERRY_MEM_STATS OFF CACHE BOOL "Enable memory statistics?") set(JERRY_LOGGING OFF CACHE BOOL "Enable logging?")
set(JERRY_MEM_GC_BEFORE_EACH_ALLOC OFF CACHE BOOL "Enable mem-stress test?") set(JERRY_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
set(JERRY_PARSER_DUMP_BYTE_CODE OFF CACHE BOOL "Enable parser byte-code dumps?") set(JERRY_MEM_GC_BEFORE_EACH_ALLOC OFF CACHE BOOL "Enable mem-stress test?")
set(JERRY_PROFILE "es5.1" CACHE STRING "Use default or other profile?") set(JERRY_PARSER_DUMP_BYTE_CODE OFF CACHE BOOL "Enable parser byte-code dumps?")
set(JERRY_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?") set(JERRY_PROFILE "es.next" CACHE STRING "Use default or other profile?")
set(JERRY_REGEXP_DUMP_BYTE_CODE OFF CACHE BOOL "Enable regexp byte-code dumps?") set(JERRY_PROMISE_CALLBACK OFF CACHE BOOL "Enable Promise callbacks?")
set(JERRY_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?") set(JERRY_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?")
set(JERRY_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?") set(JERRY_REGEXP_DUMP_BYTE_CODE OFF CACHE BOOL "Enable regexp byte-code dumps?")
set(JERRY_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?") set(JERRY_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
set(JERRY_VALGRIND OFF CACHE BOOL "Enable Valgrind support?") set(JERRY_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
set(JERRY_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?") set(JERRY_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
set(JERRY_GLOBAL_HEAP_SIZE "(512)" CACHE STRING "Size of memory heap, in kilobytes") set(JERRY_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
set(JERRY_GC_LIMIT "(0)" CACHE STRING "Heap usage limit to trigger garbage collection") set(JERRY_VM_HALT OFF CACHE BOOL "Enable VM execution stop callback?")
set(JERRY_STACK_LIMIT "(0)" CACHE STRING "Maximum stack usage size, in kilobytes") set(JERRY_VM_THROW OFF CACHE BOOL "Enable VM throw callback?")
set(JERRY_GC_MARK_LIMIT "(8)" CACHE STRING "Maximum depth of recursion during GC mark phase") set(JERRY_GLOBAL_HEAP_SIZE "(512)" CACHE STRING "Size of memory heap, in kilobytes")
set(JERRY_GC_LIMIT "(0)" CACHE STRING "Heap usage limit to trigger garbage collection")
set(JERRY_STACK_LIMIT "(0)" CACHE STRING "Maximum stack usage size, in kilobytes")
set(JERRY_GC_MARK_LIMIT "(8)" CACHE STRING "Maximum depth of recursion during GC mark phase")
# Option overrides # Option overrides
if(USING_MSVC)
set(ENABLE_ALL_IN_ONE ON) # FIXME: This should not be needed but right now it is. To be tracked down and followed up.
set(ENABLE_ALL_IN_ONE_MESSAGE " (FORCED BY COMPILER)")
endif()
if(JERRY_SYSTEM_ALLOCATOR) if(JERRY_SYSTEM_ALLOCATOR)
set(JERRY_CPOINTER_32_BIT ON) set(JERRY_CPOINTER_32_BIT ON)
@@ -83,25 +79,27 @@ if(JERRY_MEM_STATS OR JERRY_PARSER_DUMP_BYTE_CODE OR JERRY_REGEXP_DUMP_BYTE_CODE
endif() endif()
# Status messages # Status messages
message(STATUS "ENABLE_ALL_IN_ONE " ${ENABLE_ALL_IN_ONE} ${ENABLE_ALL_IN_ONE_MESSAGE})
message(STATUS "JERRY_CPOINTER_32_BIT " ${JERRY_CPOINTER_32_BIT} ${JERRY_CPOINTER_32_BIT_MESSAGE}) message(STATUS "JERRY_CPOINTER_32_BIT " ${JERRY_CPOINTER_32_BIT} ${JERRY_CPOINTER_32_BIT_MESSAGE})
message(STATUS "JERRY_DEBUGGER " ${JERRY_DEBUGGER}) message(STATUS "JERRY_DEBUGGER " ${JERRY_DEBUGGER})
message(STATUS "JERRY_ERROR_MESSAGES " ${JERRY_ERROR_MESSAGES}) message(STATUS "JERRY_ERROR_MESSAGES " ${JERRY_ERROR_MESSAGES})
message(STATUS "JERRY_EXTERNAL_CONTEXT " ${JERRY_EXTERNAL_CONTEXT}) message(STATUS "JERRY_EXTERNAL_CONTEXT " ${JERRY_EXTERNAL_CONTEXT})
message(STATUS "JERRY_PARSER " ${JERRY_PARSER}) message(STATUS "JERRY_PARSER " ${JERRY_PARSER})
message(STATUS "JERRY_FUNCTION_TO_STRING " ${JERRY_FUNCTION_TO_STRING})
message(STATUS "JERRY_LINE_INFO " ${JERRY_LINE_INFO}) message(STATUS "JERRY_LINE_INFO " ${JERRY_LINE_INFO})
message(STATUS "JERRY_LOGGING " ${JERRY_LOGGING} ${JERRY_LOGGING_MESSAGE}) message(STATUS "JERRY_LOGGING " ${JERRY_LOGGING} ${JERRY_LOGGING_MESSAGE})
message(STATUS "JERRY_MEM_STATS " ${JERRY_MEM_STATS}) message(STATUS "JERRY_MEM_STATS " ${JERRY_MEM_STATS})
message(STATUS "JERRY_MEM_GC_BEFORE_EACH_ALLOC " ${JERRY_MEM_GC_BEFORE_EACH_ALLOC}) message(STATUS "JERRY_MEM_GC_BEFORE_EACH_ALLOC " ${JERRY_MEM_GC_BEFORE_EACH_ALLOC})
message(STATUS "JERRY_PARSER_DUMP_BYTE_CODE " ${JERRY_PARSER_DUMP_BYTE_CODE} ${JERRY_PARSER_DUMP_MESSAGE}) message(STATUS "JERRY_PARSER_DUMP_BYTE_CODE " ${JERRY_PARSER_DUMP_BYTE_CODE} ${JERRY_PARSER_DUMP_MESSAGE})
message(STATUS "JERRY_PROFILE " ${JERRY_PROFILE}) message(STATUS "JERRY_PROFILE " ${JERRY_PROFILE})
message(STATUS "JERRY_PROMISE_CALLBACK " ${JERRY_PROMISE_CALLBACK})
message(STATUS "JERRY_REGEXP_STRICT_MODE " ${JERRY_REGEXP_STRICT_MODE}) message(STATUS "JERRY_REGEXP_STRICT_MODE " ${JERRY_REGEXP_STRICT_MODE})
message(STATUS "JERRY_REGEXP_DUMP_BYTE_CODE " ${JERRY_REGEXP_DUMP_BYTE_CODE}) message(STATUS "JERRY_REGEXP_DUMP_BYTE_CODE " ${JERRY_REGEXP_DUMP_BYTE_CODE})
message(STATUS "JERRY_SNAPSHOT_EXEC " ${JERRY_SNAPSHOT_EXEC} ${JERRY_SNAPSHOT_EXEC_MESSAGE}) message(STATUS "JERRY_SNAPSHOT_EXEC " ${JERRY_SNAPSHOT_EXEC} ${JERRY_SNAPSHOT_EXEC_MESSAGE})
message(STATUS "JERRY_SNAPSHOT_SAVE " ${JERRY_SNAPSHOT_SAVE} ${JERRY_SNAPSHOT_SAVE_MESSAGE}) message(STATUS "JERRY_SNAPSHOT_SAVE " ${JERRY_SNAPSHOT_SAVE} ${JERRY_SNAPSHOT_SAVE_MESSAGE})
message(STATUS "JERRY_SYSTEM_ALLOCATOR " ${JERRY_SYSTEM_ALLOCATOR}) message(STATUS "JERRY_SYSTEM_ALLOCATOR " ${JERRY_SYSTEM_ALLOCATOR})
message(STATUS "JERRY_VALGRIND " ${JERRY_VALGRIND}) message(STATUS "JERRY_VALGRIND " ${JERRY_VALGRIND})
message(STATUS "JERRY_VM_EXEC_STOP " ${JERRY_VM_EXEC_STOP}) message(STATUS "JERRY_VM_HALT " ${JERRY_VM_HALT})
message(STATUS "JERRY_VM_THROW " ${JERRY_VM_THROW})
message(STATUS "JERRY_GLOBAL_HEAP_SIZE " ${JERRY_GLOBAL_HEAP_SIZE}) message(STATUS "JERRY_GLOBAL_HEAP_SIZE " ${JERRY_GLOBAL_HEAP_SIZE})
message(STATUS "JERRY_GC_LIMIT " ${JERRY_GC_LIMIT}) message(STATUS "JERRY_GC_LIMIT " ${JERRY_GC_LIMIT})
message(STATUS "JERRY_STACK_LIMIT " ${JERRY_STACK_LIMIT}) message(STATUS "JERRY_STACK_LIMIT " ${JERRY_STACK_LIMIT})
@@ -125,81 +123,423 @@ set(INCLUDE_CORE_PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/parser/regexp" "${CMAKE_CURRENT_SOURCE_DIR}/parser/regexp"
"${CMAKE_CURRENT_SOURCE_DIR}/vm") "${CMAKE_CURRENT_SOURCE_DIR}/vm")
# Third-party
# Valgrind
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
if(JERRY_VALGRIND)
set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} ${INCLUDE_THIRD_PARTY_VALGRIND})
endif()
set(INCLUDE_CORE_PUBLIC ${INCLUDE_CORE_PUBLIC} PARENT_SCOPE) # for jerry-port set(INCLUDE_CORE_PUBLIC ${INCLUDE_CORE_PUBLIC} PARENT_SCOPE) # for jerry-port
set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} PARENT_SCOPE) # for tests/unit-core set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} PARENT_SCOPE) # for tests/unit-core
# Sources # Sources
# Jerry core # Jerry core
file(GLOB SOURCE_CORE_FILES set(SOURCE_CORE_FILES
api/*.c api/jerry-debugger-transport.c
debugger/*.c api/jerry-debugger.c
ecma/base/*.c api/jerry-module.c
ecma/builtin-objects/*.c api/jerry-snapshot.c
ecma/builtin-objects/typedarray/*.c api/jerryscript.c
ecma/operations/*.c debugger/debugger.c
jcontext/*.c ecma/base/ecma-alloc.c
jmem/*.c ecma/base/ecma-gc.c
jrt/*.c ecma/base/ecma-errors.c
lit/*.c ecma/base/ecma-extended-info.c
parser/js/*.c ecma/base/ecma-helpers-collection.c
parser/regexp/*.c ecma/base/ecma-helpers-conversion.c
vm/*.c) ecma/base/ecma-helpers-errol.c
ecma/base/ecma-helpers-external-pointers.c
ecma/base/ecma-helpers-number.c
ecma/base/ecma-helpers-string.c
ecma/base/ecma-helpers-value.c
ecma/base/ecma-helpers.c
ecma/base/ecma-init-finalize.c
ecma/base/ecma-lcache.c
ecma/base/ecma-line-info.c
ecma/base/ecma-literal-storage.c
ecma/base/ecma-module.c
ecma/base/ecma-property-hashmap.c
ecma/builtin-objects/ecma-builtin-aggregateerror.c
ecma/builtin-objects/ecma-builtin-aggregateerror-prototype.c
ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.c
ecma/builtin-objects/ecma-builtin-array-prototype.c
ecma/builtin-objects/ecma-builtin-array.c
ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c
ecma/builtin-objects/ecma-builtin-arraybuffer.c
ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-async-function-prototype.c
ecma/builtin-objects/ecma-builtin-async-function.c
ecma/builtin-objects/ecma-builtin-async-generator-function.c
ecma/builtin-objects/ecma-builtin-async-generator-prototype.c
ecma/builtin-objects/ecma-builtin-async-generator.c
ecma/builtin-objects/ecma-builtin-async-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-atomics.c
ecma/builtin-objects/ecma-builtin-bigint-prototype.c
ecma/builtin-objects/ecma-builtin-bigint.c
ecma/builtin-objects/ecma-builtin-boolean-prototype.c
ecma/builtin-objects/ecma-builtin-boolean.c
ecma/builtin-objects/ecma-builtin-dataview-prototype.c
ecma/builtin-objects/ecma-builtin-dataview.c
ecma/builtin-objects/ecma-builtin-date-prototype.c
ecma/builtin-objects/ecma-builtin-date.c
ecma/builtin-objects/ecma-builtin-error-prototype.c
ecma/builtin-objects/ecma-builtin-error.c
ecma/builtin-objects/ecma-builtin-evalerror-prototype.c
ecma/builtin-objects/ecma-builtin-evalerror.c
ecma/builtin-objects/ecma-builtin-function-prototype.c
ecma/builtin-objects/ecma-builtin-function.c
ecma/builtin-objects/ecma-builtin-generator-function.c
ecma/builtin-objects/ecma-builtin-generator-prototype.c
ecma/builtin-objects/ecma-builtin-generator.c
ecma/builtin-objects/ecma-builtin-global.c
ecma/builtin-objects/ecma-builtin-handlers.c
ecma/builtin-objects/ecma-builtin-helpers-date.c
ecma/builtin-objects/ecma-builtin-helpers-error.c
ecma/builtin-objects/ecma-builtin-helpers-json.c
ecma/builtin-objects/ecma-builtin-helpers-sort.c
ecma/builtin-objects/ecma-builtin-helpers.c
ecma/builtin-objects/ecma-builtin-intrinsic.c
ecma/builtin-objects/ecma-builtin-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-json.c
ecma/builtin-objects/ecma-builtin-map-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-map-prototype.c
ecma/builtin-objects/ecma-builtin-map.c
ecma/builtin-objects/ecma-builtin-math.c
ecma/builtin-objects/ecma-builtin-number-prototype.c
ecma/builtin-objects/ecma-builtin-number.c
ecma/builtin-objects/ecma-builtin-object-prototype.c
ecma/builtin-objects/ecma-builtin-object.c
ecma/builtin-objects/ecma-builtin-promise-prototype.c
ecma/builtin-objects/ecma-builtin-promise.c
ecma/builtin-objects/ecma-builtin-proxy.c
ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c
ecma/builtin-objects/ecma-builtin-rangeerror.c
ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c
ecma/builtin-objects/ecma-builtin-referenceerror.c
ecma/builtin-objects/ecma-builtin-reflect.c
ecma/builtin-objects/ecma-builtin-regexp-prototype.c
ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-regexp.c
ecma/builtin-objects/ecma-builtin-set-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-set-prototype.c
ecma/builtin-objects/ecma-builtin-set.c
ecma/builtin-objects/ecma-builtin-shared-arraybuffer-prototype.c
ecma/builtin-objects/ecma-builtin-shared-arraybuffer.c
ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c
ecma/builtin-objects/ecma-builtin-string-prototype.c
ecma/builtin-objects/ecma-builtin-string.c
ecma/builtin-objects/ecma-builtin-symbol-prototype.c
ecma/builtin-objects/ecma-builtin-symbol.c
ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c
ecma/builtin-objects/ecma-builtin-syntaxerror.c
ecma/builtin-objects/ecma-builtin-type-error-thrower.c
ecma/builtin-objects/ecma-builtin-typeerror-prototype.c
ecma/builtin-objects/ecma-builtin-typeerror.c
ecma/builtin-objects/ecma-builtin-urierror-prototype.c
ecma/builtin-objects/ecma-builtin-urierror.c
ecma/builtin-objects/ecma-builtin-weakmap-prototype.c
ecma/builtin-objects/ecma-builtin-weakmap.c
ecma/builtin-objects/ecma-builtin-weakref-prototype.c
ecma/builtin-objects/ecma-builtin-weakref.c
ecma/builtin-objects/ecma-builtin-weakset-prototype.c
ecma/builtin-objects/ecma-builtin-weakset.c
ecma/builtin-objects/ecma-builtins.c
ecma/builtin-objects/typedarray/ecma-builtin-bigint64array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c
ecma/builtin-objects/typedarray/ecma-builtin-biguint64array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c
ecma/builtin-objects/typedarray/ecma-builtin-float32array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-float32array.c
ecma/builtin-objects/typedarray/ecma-builtin-float64array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-float64array.c
ecma/builtin-objects/typedarray/ecma-builtin-int16array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-int16array.c
ecma/builtin-objects/typedarray/ecma-builtin-int32array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-int32array.c
ecma/builtin-objects/typedarray/ecma-builtin-int8array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-int8array.c
ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c
ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c
ecma/builtin-objects/typedarray/ecma-builtin-uint16array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c
ecma/builtin-objects/typedarray/ecma-builtin-uint32array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c
ecma/builtin-objects/typedarray/ecma-builtin-uint8array-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c
ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray-prototype.c
ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c
ecma/operations/ecma-arguments-object.c
ecma/operations/ecma-array-object.c
ecma/operations/ecma-arraybuffer-object.c
ecma/operations/ecma-async-generator-object.c
ecma/operations/ecma-atomics-object.c
ecma/operations/ecma-big-uint.c
ecma/operations/ecma-bigint-object.c
ecma/operations/ecma-bigint.c
ecma/operations/ecma-boolean-object.c
ecma/operations/ecma-comparison.c
ecma/operations/ecma-container-object.c
ecma/operations/ecma-conversion.c
ecma/operations/ecma-dataview-object.c
ecma/operations/ecma-eval.c
ecma/operations/ecma-exceptions.c
ecma/operations/ecma-function-object.c
ecma/operations/ecma-get-put-value.c
ecma/operations/ecma-iterator-object.c
ecma/operations/ecma-jobqueue.c
ecma/operations/ecma-lex-env.c
ecma/operations/ecma-number-object.c
ecma/operations/ecma-objects-general.c
ecma/operations/ecma-objects.c
ecma/operations/ecma-promise-object.c
ecma/operations/ecma-proxy-object.c
ecma/operations/ecma-reference.c
ecma/operations/ecma-regexp-object.c
ecma/operations/ecma-shared-arraybuffer-object.c
ecma/operations/ecma-string-object.c
ecma/operations/ecma-symbol-object.c
ecma/operations/ecma-typedarray-object.c
jcontext/jcontext.c
jmem/jmem-allocator.c
jmem/jmem-heap.c
jmem/jmem-poolman.c
jrt/jrt-fatals.c
jrt/jrt-logging.c
lit/lit-char-helpers.c
lit/lit-magic-strings.c
lit/lit-strings.c
parser/js/byte-code.c
parser/js/common.c
parser/js/js-lexer.c
parser/js/js-parser-expr.c
parser/js/js-parser-line-info-create.c
parser/js/js-parser-mem.c
parser/js/js-parser-module.c
parser/js/js-parser-statm.c
parser/js/js-parser-tagged-template-literal.c
parser/js/js-parser-util.c
parser/js/js-parser.c
parser/js/js-scanner-ops.c
parser/js/js-scanner-util.c
parser/js/js-scanner.c
parser/js/parser-errors.c
parser/regexp/re-bytecode.c
parser/regexp/re-compiler.c
parser/regexp/re-parser.c
vm/opcodes-ecma-arithmetics.c
vm/opcodes-ecma-bitwise.c
vm/opcodes-ecma-relational-equality.c
vm/opcodes.c
vm/vm-stack.c
vm/vm-utils.c
vm/vm.c
)
# All-in-one build # Amalgamated JerryScript source/header build.
if(ENABLE_ALL_IN_ONE)
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
list(SORT SOURCE_CORE_FILES)
file(REMOVE ${ALL_IN_FILE})
foreach(FILE ${SOURCE_CORE_FILES})
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
endforeach()
set(SOURCE_CORE_FILES ${ALL_IN_FILE})
endif()
# "Single" JerryScript source/header build.
# The process will create the following files: # The process will create the following files:
# * jerryscript.c # * jerryscript.c
# * jerryscript.h # * jerryscript.h
# * jerryscript-config.h # * jerryscript-config.h
if(ENABLE_ALL_IN_ONE_SOURCE) if(ENABLE_AMALGAM)
# Create single C/H file # Create single C/H file
file(GLOB HEADER_CORE_FILES *.h) set(HEADER_CORE_FILES
api/jerry-snapshot.h
debugger/debugger.h
ecma/base/ecma-alloc.h
ecma/base/ecma-error-messages.inc.h
ecma/base/ecma-errors.h
ecma/base/ecma-gc.h
ecma/base/ecma-globals.h
ecma/base/ecma-helpers.h
ecma/base/ecma-init-finalize.h
ecma/base/ecma-lcache.h
ecma/base/ecma-line-info.h
ecma/base/ecma-literal-storage.h
ecma/base/ecma-module.h
ecma/base/ecma-property-hashmap.h
ecma/builtin-objects/ecma-builtin-aggregateerror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-aggregateerror.inc.h
ecma/builtin-objects/ecma-builtin-array-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.inc.h
ecma/builtin-objects/ecma-builtin-array-prototype.inc.h
ecma/builtin-objects/ecma-builtin-array.inc.h
ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.inc.h
ecma/builtin-objects/ecma-builtin-arraybuffer.inc.h
ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-async-function-prototype.inc.h
ecma/builtin-objects/ecma-builtin-async-function.inc.h
ecma/builtin-objects/ecma-builtin-async-generator-function.inc.h
ecma/builtin-objects/ecma-builtin-async-generator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-async-generator.inc.h
ecma/builtin-objects/ecma-builtin-async-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-atomics.inc.h
ecma/builtin-objects/ecma-builtin-bigint-prototype.inc.h
ecma/builtin-objects/ecma-builtin-bigint.inc.h
ecma/builtin-objects/ecma-builtin-boolean-prototype.inc.h
ecma/builtin-objects/ecma-builtin-boolean.inc.h
ecma/builtin-objects/ecma-builtin-dataview-prototype.inc.h
ecma/builtin-objects/ecma-builtin-dataview.inc.h
ecma/builtin-objects/ecma-builtin-date-prototype.inc.h
ecma/builtin-objects/ecma-builtin-date.inc.h
ecma/builtin-objects/ecma-builtin-error-prototype.inc.h
ecma/builtin-objects/ecma-builtin-error.inc.h
ecma/builtin-objects/ecma-builtin-evalerror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-evalerror.inc.h
ecma/builtin-objects/ecma-builtin-function-prototype.h
ecma/builtin-objects/ecma-builtin-function-prototype.inc.h
ecma/builtin-objects/ecma-builtin-function.inc.h
ecma/builtin-objects/ecma-builtin-generator-function.inc.h
ecma/builtin-objects/ecma-builtin-generator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-generator.inc.h
ecma/builtin-objects/ecma-builtin-global.inc.h
ecma/builtin-objects/ecma-builtin-handlers.h
ecma/builtin-objects/ecma-builtin-handlers.inc.h
ecma/builtin-objects/ecma-builtin-helpers-macro-defines.inc.h
ecma/builtin-objects/ecma-builtin-helpers-macro-undefs.inc.h
ecma/builtin-objects/ecma-builtin-helpers.h
ecma/builtin-objects/ecma-builtin-internal-routines-template.inc.h
ecma/builtin-objects/ecma-builtin-intrinsic.inc.h
ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-json.inc.h
ecma/builtin-objects/ecma-builtin-map-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-map-prototype.inc.h
ecma/builtin-objects/ecma-builtin-map.inc.h
ecma/builtin-objects/ecma-builtin-math.inc.h
ecma/builtin-objects/ecma-builtin-number-prototype.inc.h
ecma/builtin-objects/ecma-builtin-number.inc.h
ecma/builtin-objects/ecma-builtin-object-prototype.inc.h
ecma/builtin-objects/ecma-builtin-object.h
ecma/builtin-objects/ecma-builtin-object.inc.h
ecma/builtin-objects/ecma-builtin-promise-prototype.inc.h
ecma/builtin-objects/ecma-builtin-promise.inc.h
ecma/builtin-objects/ecma-builtin-proxy.inc.h
ecma/builtin-objects/ecma-builtin-rangeerror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-rangeerror.inc.h
ecma/builtin-objects/ecma-builtin-referenceerror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-referenceerror.inc.h
ecma/builtin-objects/ecma-builtin-reflect.inc.h
ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h
ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-regexp.inc.h
ecma/builtin-objects/ecma-builtin-set-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-set-prototype.inc.h
ecma/builtin-objects/ecma-builtin-set.inc.h
ecma/builtin-objects/ecma-builtin-shared-arraybuffer-prototype.inc.h
ecma/builtin-objects/ecma-builtin-shared-arraybuffer.inc.h
ecma/builtin-objects/ecma-builtin-string-iterator-prototype.inc.h
ecma/builtin-objects/ecma-builtin-string-prototype.inc.h
ecma/builtin-objects/ecma-builtin-string.inc.h
ecma/builtin-objects/ecma-builtin-symbol-prototype.inc.h
ecma/builtin-objects/ecma-builtin-symbol.inc.h
ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-syntaxerror.inc.h
ecma/builtin-objects/ecma-builtin-type-error-thrower.inc.h
ecma/builtin-objects/ecma-builtin-typeerror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-typeerror.inc.h
ecma/builtin-objects/ecma-builtin-urierror-prototype.inc.h
ecma/builtin-objects/ecma-builtin-urierror.inc.h
ecma/builtin-objects/ecma-builtin-weakmap-prototype.inc.h
ecma/builtin-objects/ecma-builtin-weakmap.inc.h
ecma/builtin-objects/ecma-builtin-weakref-prototype.inc.h
ecma/builtin-objects/ecma-builtin-weakref.inc.h
ecma/builtin-objects/ecma-builtin-weakset-prototype.inc.h
ecma/builtin-objects/ecma-builtin-weakset.inc.h
ecma/builtin-objects/ecma-builtins-internal.h
ecma/builtin-objects/ecma-builtins.h
ecma/builtin-objects/ecma-builtins.inc.h
ecma/operations/ecma-arguments-object.h
ecma/operations/ecma-array-object.h
ecma/operations/ecma-arraybuffer-object.h
ecma/operations/ecma-async-generator-object.h
ecma/operations/ecma-atomics-object.h
ecma/operations/ecma-big-uint.h
ecma/operations/ecma-bigint-object.h
ecma/operations/ecma-bigint.h
ecma/operations/ecma-boolean-object.h
ecma/operations/ecma-comparison.h
ecma/operations/ecma-container-object.h
ecma/operations/ecma-conversion.h
ecma/operations/ecma-dataview-object.h
ecma/operations/ecma-eval.h
ecma/operations/ecma-exceptions.h
ecma/operations/ecma-function-object.h
ecma/operations/ecma-iterator-object.h
ecma/operations/ecma-jobqueue.h
ecma/operations/ecma-lex-env.h
ecma/operations/ecma-number-object.h
ecma/operations/ecma-objects-general.h
ecma/operations/ecma-objects.h
ecma/operations/ecma-promise-object.h
ecma/operations/ecma-proxy-object.h
ecma/operations/ecma-reference.h
ecma/operations/ecma-regexp-object.h
ecma/operations/ecma-shared-arraybuffer-object.h
ecma/operations/ecma-string-object.h
ecma/operations/ecma-symbol-object.h
ecma/operations/ecma-typedarray-object.h
include/jerryscript-compiler.h
include/jerryscript-core.h
include/jerryscript-debugger-transport.h
include/jerryscript-debugger.h
include/jerryscript-port.h
include/jerryscript-snapshot.h
include/jerryscript.h
jcontext/jcontext.h
jmem/jmem-allocator-internal.h
jmem/jmem.h
jrt/jrt-bit-fields.h
jrt/jrt-libc-includes.h
jrt/jrt-types.h
jrt/jrt.h
lit/lit-char-helpers.h
lit/lit-globals.h
lit/lit-magic-strings.h
lit/lit-magic-strings.inc.h
lit/lit-strings.h
lit/lit-unicode-conversions-sup.inc.h
lit/lit-unicode-conversions.inc.h
lit/lit-unicode-folding.inc.h
lit/lit-unicode-ranges-sup.inc.h
lit/lit-unicode-ranges.inc.h
vm/opcodes.h
vm/vm-defines.h
vm/vm-stack.h
vm/vm.h
)
# Generated files # Generated files
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/src/jerryscript.c") set(AMALGAM_CORE_C "${CMAKE_BINARY_DIR}/amalgam/jerryscript.c")
set(ALL_IN_FILE_H "${CMAKE_BINARY_DIR}/src/jerryscript.h") set(AMALGAM_CORE_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript.h")
set(JERRYSCRIPT_CONFIG_H "${CMAKE_BINARY_DIR}/src/jerryscript-config.h") set(AMALGAM_CONFIG_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript-config.h")
add_custom_command(OUTPUT ${ALL_IN_FILE} ${ALL_IN_FILE_H} add_custom_command(OUTPUT ${AMALGAM_CORE_C} ${AMALGAM_CORE_H}
COMMAND python ${CMAKE_SOURCE_DIR}/tools/srcgenerator.py COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tools/amalgam.py
--jerry-core --jerry-core
--output-dir ${CMAKE_BINARY_DIR}/src --output-dir ${CMAKE_BINARY_DIR}/amalgam
DEPENDS ${SOURCE_CORE_FILES} DEPENDS ${SOURCE_CORE_FILES}
${HEADER_CORE_FILES} ${HEADER_CORE_FILES}
${CMAKE_SOURCE_DIR}/tools/srcgenerator.py ${CMAKE_SOURCE_DIR}/tools/amalgam.py
${CMAKE_SOURCE_DIR}/tools/srcmerger.py
) )
# The "true" jerryscript-config.h will be generated by the configure_file below, # The "true" jerryscript-config.h will be generated by the configure_file below,
# which contains the default options and the ones passed for the CMake. # which contains the default options and the ones passed for the CMake.
# The input for this is the jerryscript-config.h generated by the command above. # The input for this is the jerryscript-config.h generated by the command above.
set(JERRYSCRIPT_GEN_CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/jerryscript-config.h) set(JERRYSCRIPT_GEN_CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/jerryscript-config.h)
add_custom_command(OUTPUT ${JERRYSCRIPT_CONFIG_H} add_custom_command(OUTPUT ${AMALGAM_CONFIG_H}
COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${JERRYSCRIPT_CONFIG_H} COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${AMALGAM_CONFIG_H}
DEPENDS ${ALL_IN_FILE_C} ${ALL_IN_FILE_H}) DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H})
add_custom_target(generate-single-source-jerry DEPENDS ${ALL_IN_FILE} ${ALL_IN_FILE_H}) add_custom_target(amalgam-jerry DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
add_dependencies(generate-single-source generate-single-source-jerry) add_dependencies(amalgam amalgam-jerry)
set(SOURCE_CORE_FILES ${ALL_IN_FILE} ${ALL_IN_FILE_H} ${JERRYSCRIPT_CONFIG_H}) set(SOURCE_CORE_FILES ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
set(INCLUDE_CORE_PUBLIC PARENT_SCOPE)
set(INCLUDE_CORE_PRIVATE PARENT_SCOPE)
endif() endif()
# Third-party
# Valgrind
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
# build mode specific compile/link flags # build mode specific compile/link flags
set(DEFINES_JERRY ${DEFINES_JERRY} $<$<NOT:$<CONFIG:Debug>>:JERRY_NDEBUG>) set(DEFINES_JERRY ${DEFINES_JERRY} $<$<NOT:$<CONFIG:Debug>>:JERRY_NDEBUG>)
@@ -235,6 +575,9 @@ jerry_add_define01(JERRY_EXTERNAL_CONTEXT)
# JS-Parser # JS-Parser
jerry_add_define01(JERRY_PARSER) jerry_add_define01(JERRY_PARSER)
# JS function toString
jerry_add_define01(JERRY_FUNCTION_TO_STRING)
# JS line info # JS line info
jerry_add_define01(JERRY_LINE_INFO) jerry_add_define01(JERRY_LINE_INFO)
@@ -254,14 +597,18 @@ jerry_add_define01(JERRY_MEM_GC_BEFORE_EACH_ALLOC)
jerry_add_define01(JERRY_PARSER_DUMP_BYTE_CODE) jerry_add_define01(JERRY_PARSER_DUMP_BYTE_CODE)
# Profile # Profile
if (${JERRY_PROFILE} STREQUAL "es2015-subset")
message(DEPRECATION "'es2015-subset' profile is deprecated, please use 'es.next' instead.")
endif()
if (NOT IS_ABSOLUTE ${JERRY_PROFILE}) if (NOT IS_ABSOLUTE ${JERRY_PROFILE})
set(JERRY_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/profiles/${JERRY_PROFILE}.profile") set(JERRY_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/profiles/${JERRY_PROFILE}.profile")
endif() endif()
if(EXISTS ${JERRY_PROFILE}) if(EXISTS ${JERRY_PROFILE})
file(READ "${JERRY_PROFILE}" PROFILE_SETTINGS) file(READ "${JERRY_PROFILE}" PROFILE_SETTINGS)
string(REGEX REPLACE "^#.*$" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}") string(REGEX REPLACE "[ \t]*#[^\n]*" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
string(REGEX REPLACE "[\r|\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}") string(REGEX REPLACE "[\r\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
# Process entries and save them as CMake variables. # Process entries and save them as CMake variables.
# This is required to correctly generate the jerryscript-config.h file. # This is required to correctly generate the jerryscript-config.h file.
@@ -277,6 +624,9 @@ else()
message(FATAL_ERROR "Profile file: '${JERRY_PROFILE}' doesn't exist!") message(FATAL_ERROR "Profile file: '${JERRY_PROFILE}' doesn't exist!")
endif() endif()
# Promise callback
jerry_add_define01(JERRY_PROMISE_CALLBACK)
# RegExp strict mode # RegExp strict mode
jerry_add_define01(JERRY_REGEXP_STRICT_MODE) jerry_add_define01(JERRY_REGEXP_STRICT_MODE)
@@ -294,12 +644,12 @@ jerry_add_define01(JERRY_SYSTEM_ALLOCATOR)
# Valgrind # Valgrind
jerry_add_define01(JERRY_VALGRIND) jerry_add_define01(JERRY_VALGRIND)
if(JERRY_VALGRIND)
set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} ${INCLUDE_THIRD_PARTY_VALGRIND})
endif()
# Enable VM execution stopping # Enable VM execution stop callback
jerry_add_define01(JERRY_VM_EXEC_STOP) jerry_add_define01(JERRY_VM_HALT)
# Enable VM throw callback
jerry_add_define01(JERRY_VM_THROW)
# Size of heap # Size of heap
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GLOBAL_HEAP_SIZE=${JERRY_GLOBAL_HEAP_SIZE}) set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GLOBAL_HEAP_SIZE=${JERRY_GLOBAL_HEAP_SIZE})
@@ -397,6 +747,7 @@ add_library(${JERRY_CORE_NAME} ${SOURCE_CORE_FILES})
target_compile_definitions(${JERRY_CORE_NAME} PUBLIC ${DEFINES_JERRY}) target_compile_definitions(${JERRY_CORE_NAME} PUBLIC ${DEFINES_JERRY})
target_include_directories(${JERRY_CORE_NAME} PUBLIC ${INCLUDE_CORE_PUBLIC}) target_include_directories(${JERRY_CORE_NAME} PUBLIC ${INCLUDE_CORE_PUBLIC})
target_include_directories(${JERRY_CORE_NAME} PRIVATE ${INCLUDE_CORE_PRIVATE}) target_include_directories(${JERRY_CORE_NAME} PRIVATE ${INCLUDE_CORE_PRIVATE})
add_dependencies(${JERRY_CORE_NAME} amalgam)
set(JERRY_CORE_PKGCONFIG_REQUIRES) set(JERRY_CORE_PKGCONFIG_REQUIRES)
set(JERRY_CORE_PKGCONFIG_LIBS) set(JERRY_CORE_PKGCONFIG_LIBS)
@@ -406,9 +757,18 @@ if(ENABLE_LTO)
set(JERRY_CORE_PKGCONFIG_CFLAGS "${JERRY_CORE_PKGCONFIG_CFLAGS} -flto") set(JERRY_CORE_PKGCONFIG_CFLAGS "${JERRY_CORE_PKGCONFIG_CFLAGS} -flto")
endif() endif()
if(JERRY_LIBM) if(JERRY_MATH)
target_link_libraries(${JERRY_CORE_NAME} jerry-libm) target_link_libraries(${JERRY_CORE_NAME} jerry-math)
set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-libm) set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-math)
else()
if(USING_GCC OR USING_CLANG)
set(CMAKE_REQUIRED_FLAGS "-Wno-error -Wno-error=strict-prototypes")
endif()
check_library_exists(m sin "" HAVE_M_LIB)
if(HAVE_M_LIB)
target_link_libraries(${JERRY_CORE_NAME} m)
set(JERRY_CORE_PKGCONFIG_LIBS "${JERRY_CORE_PKGCONFIG_LIBS} -lm")
endif()
endif() endif()
separate_arguments(EXTERNAL_LINK_LIBS) separate_arguments(EXTERNAL_LINK_LIBS)
+9 -11
View File
@@ -13,11 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "debugger.h"
#include "jcontext.h"
#include "jerryscript.h" #include "jerryscript.h"
#if ENABLED (JERRY_DEBUGGER) #include "debugger.h"
#include "jcontext.h"
#if JERRY_DEBUGGER
/** /**
* Minimum number of bytes transmitted or received. * Minimum number of bytes transmitted or received.
@@ -137,10 +138,9 @@ jerry_debugger_transport_close (void)
current_p->close (current_p); current_p->close (current_p);
current_p = next_p; current_p = next_p;
} } while (current_p != NULL);
while (current_p != NULL);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n"); jerry_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n");
jerry_debugger_free_unreferenced_byte_code (); jerry_debugger_free_unreferenced_byte_code ();
} /* jerry_debugger_transport_close */ } /* jerry_debugger_transport_close */
@@ -164,8 +164,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
do do
{ {
size_t fragment_length = (message_length <= max_send_size ? message_length size_t fragment_length = (message_length <= max_send_size ? message_length : max_send_size);
: max_send_size);
memcpy (payload_p, message_p, fragment_length); memcpy (payload_p, message_p, fragment_length);
@@ -176,8 +175,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
message_p += fragment_length; message_p += fragment_length;
message_length -= fragment_length; message_length -= fragment_length;
} } while (message_length > 0);
while (message_length > 0);
return true; return true;
} /* jerry_debugger_transport_send */ } /* jerry_debugger_transport_send */
@@ -247,4 +245,4 @@ jerry_debugger_transport_sleep (void)
jerry_port_sleep (JERRY_DEBUGGER_TRANSPORT_TIMEOUT); jerry_port_sleep (JERRY_DEBUGGER_TRANSPORT_TIMEOUT);
} /* jerry_debugger_transport_sleep */ } /* jerry_debugger_transport_sleep */
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
+26 -48
View File
@@ -13,9 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerryscript.h"
#include "debugger.h" #include "debugger.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript.h"
/** /**
* Checks whether the debugger is connected. * Checks whether the debugger is connected.
@@ -26,11 +27,11 @@
bool bool
jerry_debugger_is_connected (void) jerry_debugger_is_connected (void)
{ {
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
return JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED; return JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED;
#else /* !ENABLED (JERRY_DEBUGGER) */ #else /* !JERRY_DEBUGGER */
return false; return false;
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
} /* jerry_debugger_is_connected */ } /* jerry_debugger_is_connected */
/** /**
@@ -39,14 +40,14 @@ jerry_debugger_is_connected (void)
void void
jerry_debugger_stop (void) jerry_debugger_stop (void)
{ {
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE)) && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{ {
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP); JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL; JERRY_CONTEXT (debugger_stop_context) = NULL;
} }
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
} /* jerry_debugger_stop */ } /* jerry_debugger_stop */
/** /**
@@ -55,14 +56,14 @@ jerry_debugger_stop (void)
void void
jerry_debugger_continue (void) jerry_debugger_continue (void)
{ {
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE)) && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{ {
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_STOP); JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL; JERRY_CONTEXT (debugger_stop_context) = NULL;
} }
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
} /* jerry_debugger_continue */ } /* jerry_debugger_continue */
/** /**
@@ -71,7 +72,7 @@ jerry_debugger_continue (void)
void void
jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/disable stop at breakpoint */ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/disable stop at breakpoint */
{ {
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE)) && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{ {
@@ -84,9 +85,9 @@ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/d
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE); JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
} }
} }
#else /* !ENABLED (JERRY_DEBUGGER) */ #else /* !JERRY_DEBUGGER */
JERRY_UNUSED (enable_stop_at_breakpoint); JERRY_UNUSED (enable_stop_at_breakpoint);
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
} /* jerry_debugger_stop_at_breakpoint */ } /* jerry_debugger_stop_at_breakpoint */
/** /**
@@ -102,9 +103,9 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
void *user_p, /**< user pointer passed to the callback */ void *user_p, /**< user pointer passed to the callback */
jerry_value_t *return_value) /**< [out] parse and run return value */ jerry_value_t *return_value) /**< [out] parse and run return value */
{ {
*return_value = jerry_create_undefined (); *return_value = jerry_undefined ();
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE)) && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{ {
@@ -145,13 +146,13 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
{ {
JERRY_ASSERT (client_source_data_p != NULL); JERRY_ASSERT (client_source_data_p != NULL);
jerry_char_t *resource_name_p = (jerry_char_t *) (client_source_data_p + 1); jerry_char_t *source_name_p = (jerry_char_t *) (client_source_data_p + 1);
size_t resource_name_size = strlen ((const char *) resource_name_p); size_t source_name_size = strlen ((const char *) source_name_p);
*return_value = callback_p (resource_name_p, *return_value = callback_p (source_name_p,
resource_name_size, source_name_size,
resource_name_p + resource_name_size + 1, source_name_p + source_name_size + 1,
client_source_data_p->uint8_size - resource_name_size - 1, client_source_data_p->uint8_size - source_name_size - 1,
user_p); user_p);
ret_type = JERRY_DEBUGGER_SOURCE_RECEIVED; ret_type = JERRY_DEBUGGER_SOURCE_RECEIVED;
@@ -176,12 +177,12 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
} }
return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED; return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
#else /* !ENABLED (JERRY_DEBUGGER) */ #else /* !JERRY_DEBUGGER */
JERRY_UNUSED (callback_p); JERRY_UNUSED (callback_p);
JERRY_UNUSED (user_p); JERRY_UNUSED (user_p);
return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED; return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
} /* jerry_debugger_wait_for_client_source */ } /* jerry_debugger_wait_for_client_source */
/** /**
@@ -192,39 +193,16 @@ void
jerry_debugger_send_output (const jerry_char_t *buffer, /**< buffer */ jerry_debugger_send_output (const jerry_char_t *buffer, /**< buffer */
jerry_size_t str_size) /**< string size */ jerry_size_t str_size) /**< string size */
{ {
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{ {
jerry_debugger_send_string (JERRY_DEBUGGER_OUTPUT_RESULT, jerry_debugger_send_string (JERRY_DEBUGGER_OUTPUT_RESULT,
JERRY_DEBUGGER_OUTPUT_OK, JERRY_DEBUGGER_OUTPUT_PRINT,
(const uint8_t *) buffer, (const uint8_t *) buffer,
sizeof (uint8_t) * str_size); sizeof (uint8_t) * str_size);
} }
#else /* !ENABLED (JERRY_DEBUGGER) */ #else /* !JERRY_DEBUGGER */
JERRY_UNUSED (buffer); JERRY_UNUSED (buffer);
JERRY_UNUSED (str_size); JERRY_UNUSED (str_size);
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
} /* jerry_debugger_send_output */ } /* jerry_debugger_send_output */
/**
* Send the log of the program to the debugger client.
*/
void
jerry_debugger_send_log (jerry_log_level_t level, /**< level of the diagnostics message */
const jerry_char_t *buffer, /**< buffer */
jerry_size_t str_size) /**< string size */
{
#if ENABLED (JERRY_DEBUGGER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
{
jerry_debugger_send_string (JERRY_DEBUGGER_OUTPUT_RESULT,
(uint8_t) (level + 2),
(const uint8_t *) buffer,
sizeof (uint8_t) * str_size);
}
#else /* !ENABLED (JERRY_DEBUGGER) */
JERRY_UNUSED (level);
JERRY_UNUSED (buffer);
JERRY_UNUSED (str_size);
#endif /* ENABLED (JERRY_DEBUGGER) */
} /* jerry_debugger_send_log */
+247
View File
@@ -0,0 +1,247 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "jerryscript-core.h"
#include "jerryscript-port.h"
#include "ecma-errors.h"
#include "lit-magic-strings.h"
#include "lit-strings.h"
#if JERRY_MODULE_SYSTEM
/**
* A module descriptor.
*/
typedef struct jerry_module_t
{
struct jerry_module_t *next_p; /**< next_module */
jerry_char_t *path_p; /**< path to the module */
jerry_size_t basename_offset; /**< offset of the basename in the module path*/
jerry_value_t realm; /**< the realm of the module */
jerry_value_t module; /**< the module itself */
} jerry_module_t;
/**
* Native info descriptor for modules.
*/
static const jerry_object_native_info_t jerry_module_native_info JERRY_ATTR_CONST_DATA = {
.free_cb = NULL,
};
/**
* Default module manager.
*/
typedef struct
{
jerry_module_t *module_head_p; /**< first module */
} jerry_module_manager_t;
/**
* Release known modules.
*/
static void
jerry_module_free (jerry_module_manager_t *manager_p, /**< module manager */
const jerry_value_t realm) /**< if this argument is object, release only those modules,
* which realm value is equal to this argument. */
{
jerry_module_t *module_p = manager_p->module_head_p;
bool release_all = !jerry_value_is_object (realm);
jerry_module_t *prev_p = NULL;
while (module_p != NULL)
{
jerry_module_t *next_p = module_p->next_p;
if (release_all || module_p->realm == realm)
{
jerry_port_path_free (module_p->path_p);
jerry_value_free (module_p->realm);
jerry_value_free (module_p->module);
jerry_heap_free (module_p, sizeof (jerry_module_t));
if (prev_p == NULL)
{
manager_p->module_head_p = next_p;
}
else
{
prev_p->next_p = next_p;
}
}
else
{
prev_p = module_p;
}
module_p = next_p;
}
} /* jerry_module_free */
/**
* Initialize the default module manager.
*/
static void
jerry_module_manager_init (void *user_data_p)
{
((jerry_module_manager_t *) user_data_p)->module_head_p = NULL;
} /* jerry_module_manager_init */
/**
* Deinitialize the default module manager.
*/
static void
jerry_module_manager_deinit (void *user_data_p) /**< context pointer to deinitialize */
{
jerry_value_t undef = jerry_undefined ();
jerry_module_free ((jerry_module_manager_t *) user_data_p, undef);
jerry_value_free (undef);
} /* jerry_module_manager_deinit */
/**
* Declare the context data manager for modules.
*/
static const jerry_context_data_manager_t jerry_module_manager JERRY_ATTR_CONST_DATA = {
.init_cb = jerry_module_manager_init,
.deinit_cb = jerry_module_manager_deinit,
.bytes_needed = sizeof (jerry_module_manager_t)
};
#endif /* JERRY_MODULE_SYSTEM */
/**
* Default module resolver.
*
* @return a module object if resolving is successful, an error otherwise
*/
jerry_value_t
jerry_module_resolve (const jerry_value_t specifier, /**< module specifier string */
const jerry_value_t referrer, /**< parent module */
void *user_p) /**< user data */
{
#if JERRY_MODULE_SYSTEM
JERRY_UNUSED (user_p);
const jerry_char_t *directory_p = lit_get_magic_string_utf8 (LIT_MAGIC_STRING__EMPTY);
jerry_size_t directory_size = lit_get_magic_string_size (LIT_MAGIC_STRING__EMPTY);
jerry_module_t *module_p = jerry_object_get_native_ptr (referrer, &jerry_module_native_info);
if (module_p != NULL)
{
directory_p = module_p->path_p;
directory_size = module_p->basename_offset;
}
jerry_size_t specifier_size = jerry_string_size (specifier, JERRY_ENCODING_UTF8);
jerry_size_t reference_size = directory_size + specifier_size;
jerry_char_t *reference_path_p = jerry_heap_alloc (reference_size + 1);
memcpy (reference_path_p, directory_p, directory_size);
jerry_string_to_buffer (specifier, JERRY_ENCODING_UTF8, reference_path_p + directory_size, specifier_size);
reference_path_p[reference_size] = '\0';
jerry_char_t *path_p = jerry_port_path_normalize (reference_path_p, reference_size);
jerry_heap_free (reference_path_p, reference_size + 1);
if (path_p == NULL)
{
return jerry_throw_sz (JERRY_ERROR_SYNTAX, "Failed to resolve module");
}
jerry_value_t realm = jerry_current_realm ();
jerry_module_manager_t *manager_p;
manager_p = (jerry_module_manager_t *) jerry_context_data (&jerry_module_manager);
module_p = manager_p->module_head_p;
while (module_p != NULL)
{
if (module_p->realm == realm && strcmp ((const char *) module_p->path_p, (const char *) path_p) == 0)
{
jerry_value_free (realm);
jerry_port_path_free (path_p);
return jerry_value_copy (module_p->module);
}
module_p = module_p->next_p;
}
jerry_size_t source_size;
jerry_char_t *source_p = jerry_port_source_read ((const char *) path_p, &source_size);
if (source_p == NULL)
{
jerry_value_free (realm);
jerry_port_path_free (path_p);
return jerry_throw_sz (JERRY_ERROR_SYNTAX, "Module file not found");
}
jerry_parse_options_t parse_options;
parse_options.options = JERRY_PARSE_MODULE | JERRY_PARSE_HAS_SOURCE_NAME;
parse_options.source_name = jerry_value_copy (specifier);
jerry_value_t ret_value = jerry_parse (source_p, source_size, &parse_options);
jerry_value_free (parse_options.source_name);
jerry_port_source_free (source_p);
if (jerry_value_is_exception (ret_value))
{
jerry_port_path_free (path_p);
jerry_value_free (realm);
return ret_value;
}
module_p = (jerry_module_t *) jerry_heap_alloc (sizeof (jerry_module_t));
module_p->next_p = manager_p->module_head_p;
module_p->path_p = path_p;
module_p->basename_offset = jerry_port_path_base (module_p->path_p);
module_p->realm = realm;
module_p->module = jerry_value_copy (ret_value);
jerry_object_set_native_ptr (ret_value, &jerry_module_native_info, module_p);
manager_p->module_head_p = module_p;
return ret_value;
#else /* JERRY_MODULE_SYSTEM */
JERRY_UNUSED (specifier);
JERRY_UNUSED (referrer);
JERRY_UNUSED (user_p);
return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_MODULE_NOT_SUPPORTED));
#endif /* JERRY_MODULE_SYSTEM */
} /* jerry_module_resolve */
/**
* Release known modules.
*/
void
jerry_module_cleanup (const jerry_value_t realm) /**< if this argument is object, release only those modules,
* whose realm value is equal to this argument. */
{
#if JERRY_MODULE_SYSTEM
jerry_module_free ((jerry_module_manager_t *) jerry_context_data (&jerry_module_manager), realm);
#else /* JERRY_MODULE_SYSTEM */
JERRY_UNUSED (realm);
#endif /* JERRY_MODULE_SYSTEM */
} /* jerry_module_cleanup */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+283 -294
View File
@@ -29,95 +29,96 @@
* By default all built-ins are enabled if they are not defined. * By default all built-ins are enabled if they are not defined.
*/ */
#ifndef JERRY_BUILTINS #ifndef JERRY_BUILTINS
# define JERRY_BUILTINS 1 #define JERRY_BUILTINS 1
#endif /* !defined (JERRY_BUILTINS) */ #endif /* !defined (JERRY_BUILTINS) */
#ifndef JERRY_BUILTIN_ANNEXB #ifndef JERRY_BUILTIN_ANNEXB
# define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS #define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ANNEXB) */ #endif /* !defined (JERRY_BUILTIN_ANNEXB) */
#ifndef JERRY_BUILTIN_ARRAY #ifndef JERRY_BUILTIN_ARRAY
# define JERRY_BUILTIN_ARRAY JERRY_BUILTINS #define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ARRAY) */ #endif /* !defined (JERRY_BUILTIN_ARRAY) */
#ifndef JERRY_BUILTIN_BOOLEAN
#define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
#ifndef JERRY_BUILTIN_DATE #ifndef JERRY_BUILTIN_DATE
# define JERRY_BUILTIN_DATE JERRY_BUILTINS #define JERRY_BUILTIN_DATE JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_DATE) */ #endif /* !defined (JERRY_BUILTIN_DATE) */
#ifndef JERRY_BUILTIN_ERRORS #ifndef JERRY_BUILTIN_ERRORS
# define JERRY_BUILTIN_ERRORS JERRY_BUILTINS #define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ERRORS) */ #endif /* !defined (JERRY_BUILTIN_ERRORS) */
#ifndef JERRY_BUILTIN_BOOLEAN
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
#ifndef JERRY_BUILTIN_JSON #ifndef JERRY_BUILTIN_JSON
# define JERRY_BUILTIN_JSON JERRY_BUILTINS #define JERRY_BUILTIN_JSON JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_JSON) */ #endif /* !defined (JERRY_BUILTIN_JSON) */
#ifndef JERRY_BUILTIN_MATH #ifndef JERRY_BUILTIN_MATH
# define JERRY_BUILTIN_MATH JERRY_BUILTINS #define JERRY_BUILTIN_MATH JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_MATH) */ #endif /* !defined (JERRY_BUILTIN_MATH) */
#ifndef JERRY_BUILTIN_NUMBER #ifndef JERRY_BUILTIN_NUMBER
# define JERRY_BUILTIN_NUMBER JERRY_BUILTINS #define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_NUMBER) */ #endif /* !defined (JERRY_BUILTIN_NUMBER) */
#ifndef JERRY_BUILTIN_REGEXP #ifndef JERRY_BUILTIN_REGEXP
# define JERRY_BUILTIN_REGEXP JERRY_BUILTINS #define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_REGEXP) */ #endif /* !defined (JERRY_BUILTIN_REGEXP) */
#ifndef JERRY_BUILTIN_STRING #ifndef JERRY_BUILTIN_STRING
# define JERRY_BUILTIN_STRING JERRY_BUILTINS #define JERRY_BUILTIN_STRING JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_STRING) */ #endif /* !defined (JERRY_BUILTIN_STRING) */
/** #ifndef JERRY_BUILTIN_BIGINT
* ES2015 (a.k.a es6) related features, by default all of them are enabled. #define JERRY_BUILTIN_BIGINT JERRY_BUILTINS
*/ #endif /* !defined (JERRY_BUILTIN_BIGINT) */
#ifndef JERRY_ES2015
# define JERRY_ES2015 1
#endif /* !defined (JERRY_ES2015) */
#ifndef JERRY_ES2015_BUILTIN_DATAVIEW #ifndef JERRY_BUILTIN_CONTAINER
# define JERRY_ES2015_BUILTIN_DATAVIEW JERRY_ES2015 #define JERRY_BUILTIN_CONTAINER JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_DATAVIEW) */ #endif /* !defined (JERRY_BUILTIN_CONTAINER) */
#ifndef JERRY_ES2015_BUILTIN_MAP #ifndef JERRY_BUILTIN_DATAVIEW
# define JERRY_ES2015_BUILTIN_MAP JERRY_ES2015 #define JERRY_BUILTIN_DATAVIEW JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_MAP) */ #endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
#ifndef JERRY_ES2015_BUILTIN_SET #ifndef JERRY_BUILTIN_GLOBAL_THIS
# define JERRY_ES2015_BUILTIN_SET JERRY_ES2015 #define JERRY_BUILTIN_GLOBAL_THIS JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_SET) */ #endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
#ifndef JERRY_ES2015_BUILTIN_WEAKMAP #ifndef JERRY_BUILTIN_PROXY
# define JERRY_ES2015_BUILTIN_WEAKMAP JERRY_ES2015 #define JERRY_BUILTIN_PROXY JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_WEAKMAP) */ #endif /* !defined (JERRY_BUILTIN_PROXY) */
#ifndef JERRY_ES2015_BUILTIN_WEAKSET #ifndef JERRY_BUILTIN_REALMS
# define JERRY_ES2015_BUILTIN_WEAKSET JERRY_ES2015 #define JERRY_BUILTIN_REALMS JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_WEAKSET) */ #endif /* !defined (JERRY_BUILTIN_REALMS) */
#ifndef JERRY_ES2015_BUILTIN_PROMISE #ifndef JERRY_BUILTIN_REFLECT
# define JERRY_ES2015_BUILTIN_PROMISE JERRY_ES2015 #define JERRY_BUILTIN_REFLECT JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_PROMISE) */ #endif /* !defined (JERRY_BUILTIN_REFLECT) */
#ifndef JERRY_ES2015_BUILTIN_PROXY #ifndef JERRY_BUILTIN_TYPEDARRAY
# define JERRY_ES2015_BUILTIN_PROXY JERRY_ES2015 #define JERRY_BUILTIN_TYPEDARRAY JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_PROXY) */ #endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
#ifndef JERRY_ES2015_BUILTIN_REFLECT #ifndef JERRY_BUILTIN_SHAREDARRAYBUFFER
# define JERRY_ES2015_BUILTIN_REFLECT JERRY_ES2015 #define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_REFLECT) */ #endif /* !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) */
#ifndef JERRY_ES2015_BUILTIN_TYPEDARRAY #ifndef JERRY_BUILTIN_ATOMICS
# define JERRY_ES2015_BUILTIN_TYPEDARRAY JERRY_ES2015 #define JERRY_BUILTIN_ATOMICS JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* !defined (JERRY_BUILTIN_ATOMICS) */
#ifndef JERRY_ES2015_MODULE_SYSTEM #ifndef JERRY_BUILTIN_WEAKREF
# define JERRY_ES2015_MODULE_SYSTEM JERRY_ES2015 #define JERRY_BUILTIN_WEAKREF JERRY_BUILTINS
#endif /* !defined (JERRY_ES2015_MODULE_SYSTEM) */ #endif /* !defined (JERRY_BUILTIN_WEAKREF) */
#ifndef JERRY_MODULE_SYSTEM
#define JERRY_MODULE_SYSTEM JERRY_BUILTINS
#endif /* !defined (JERRY_MODULE_SYSTEM) */
/** /**
* Engine internal and misc configurations. * Engine internal and misc configurations.
@@ -134,7 +135,7 @@
* For more details see: jmem/jmem.h * For more details see: jmem/jmem.h
*/ */
#ifndef JERRY_CPOINTER_32_BIT #ifndef JERRY_CPOINTER_32_BIT
# define JERRY_CPOINTER_32_BIT 0 #define JERRY_CPOINTER_32_BIT 0
#endif /* !defined (JERRY_CPOINTER_32_BIT) */ #endif /* !defined (JERRY_CPOINTER_32_BIT) */
/** /**
@@ -145,7 +146,7 @@
* 1: Enable the debugger. * 1: Enable the debugger.
*/ */
#ifndef JERRY_DEBUGGER #ifndef JERRY_DEBUGGER
# define JERRY_DEBUGGER 0 #define JERRY_DEBUGGER 0
#endif /* !defined (JERRY_DEBUGGER) */ #endif /* !defined (JERRY_DEBUGGER) */
/** /**
@@ -158,7 +159,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_ERROR_MESSAGES #ifndef JERRY_ERROR_MESSAGES
# define JERRY_ERROR_MESSAGES 0 #define JERRY_ERROR_MESSAGES 0
#endif /* !defined (JERRY_ERROR_MESSAGES) */ #endif /* !defined (JERRY_ERROR_MESSAGES) */
/** /**
@@ -171,7 +172,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_EXTERNAL_CONTEXT #ifndef JERRY_EXTERNAL_CONTEXT
# define JERRY_EXTERNAL_CONTEXT 0 #define JERRY_EXTERNAL_CONTEXT 0
#endif /* !defined (JERRY_EXTERNAL_CONTEXT) */ #endif /* !defined (JERRY_EXTERNAL_CONTEXT) */
/** /**
@@ -180,7 +181,7 @@
* Default value: 512 KiB * Default value: 512 KiB
*/ */
#ifndef JERRY_GLOBAL_HEAP_SIZE #ifndef JERRY_GLOBAL_HEAP_SIZE
# define JERRY_GLOBAL_HEAP_SIZE (512) #define JERRY_GLOBAL_HEAP_SIZE (512)
#endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */ #endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */
/** /**
@@ -189,7 +190,7 @@
* If value is 0, the default is 1/32 of JERRY_HEAP_SIZE * If value is 0, the default is 1/32 of JERRY_HEAP_SIZE
*/ */
#ifndef JERRY_GC_LIMIT #ifndef JERRY_GC_LIMIT
# define JERRY_GC_LIMIT 0 #define JERRY_GC_LIMIT 0
#endif /* !defined (JERRY_GC_LIMIT) */ #endif /* !defined (JERRY_GC_LIMIT) */
/** /**
@@ -202,7 +203,7 @@
* Default value: 0, unlimited * Default value: 0, unlimited
*/ */
#ifndef JERRY_STACK_LIMIT #ifndef JERRY_STACK_LIMIT
# define JERRY_STACK_LIMIT (0) #define JERRY_STACK_LIMIT (0)
#endif /* !defined (JERRY_STACK_LIMIT) */ #endif /* !defined (JERRY_STACK_LIMIT) */
/** /**
@@ -211,7 +212,7 @@
* Default value: 8 * Default value: 8
*/ */
#ifndef JERRY_GC_MARK_LIMIT #ifndef JERRY_GC_MARK_LIMIT
# define JERRY_GC_MARK_LIMIT (8) #define JERRY_GC_MARK_LIMIT (8)
#endif /* !defined (JERRY_GC_MARK_LIMIT) */ #endif /* !defined (JERRY_GC_MARK_LIMIT) */
/** /**
@@ -224,9 +225,22 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_LCACHE #ifndef JERRY_LCACHE
# define JERRY_LCACHE 1 #define JERRY_LCACHE 1
#endif /* !defined (JERRY_LCACHE) */ #endif /* !defined (JERRY_LCACHE) */
/**
* Enable/Disable function toString operation.
*
* Allowed values:
* 0: Disable function toString operation.
* 1: Enable function toString operation.
*
* Default value: 0
*/
#ifndef JERRY_FUNCTION_TO_STRING
#define JERRY_FUNCTION_TO_STRING 0
#endif /* !defined (JERRY_FUNCTION_TO_STRING) */
/** /**
* Enable/Disable line-info management inside the engine. * Enable/Disable line-info management inside the engine.
* *
@@ -237,7 +251,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_LINE_INFO #ifndef JERRY_LINE_INFO
# define JERRY_LINE_INFO 0 #define JERRY_LINE_INFO 0
#endif /* !defined (JERRY_LINE_INFO) */ #endif /* !defined (JERRY_LINE_INFO) */
/** /**
@@ -250,7 +264,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_LOGGING #ifndef JERRY_LOGGING
# define JERRY_LOGGING 0 #define JERRY_LOGGING 0
#endif /* !defined (JERRY_LOGGING) */ #endif /* !defined (JERRY_LOGGING) */
/** /**
@@ -265,7 +279,7 @@
* Only enable it for debugging purposes. * Only enable it for debugging purposes.
*/ */
#ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC #ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC
# define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0 #define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
#endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */ #endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */
/** /**
@@ -278,7 +292,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_MEM_STATS #ifndef JERRY_MEM_STATS
# define JERRY_MEM_STATS 0 #define JERRY_MEM_STATS 0
#endif /* !defined (JERRY_MEM_STATS) */ #endif /* !defined (JERRY_MEM_STATS) */
/** /**
@@ -292,7 +306,7 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_NUMBER_TYPE_FLOAT64 #ifndef JERRY_NUMBER_TYPE_FLOAT64
# define JERRY_NUMBER_TYPE_FLOAT64 1 #define JERRY_NUMBER_TYPE_FLOAT64 1
#endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */ #endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */
/** /**
@@ -305,7 +319,7 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_PARSER #ifndef JERRY_PARSER
# define JERRY_PARSER 1 #define JERRY_PARSER 1
#endif /* !defined (JERRY_PARSER) */ #endif /* !defined (JERRY_PARSER) */
/** /**
@@ -320,7 +334,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_PARSER_DUMP_BYTE_CODE #ifndef JERRY_PARSER_DUMP_BYTE_CODE
# define JERRY_PARSER_DUMP_BYTE_CODE 0 #define JERRY_PARSER_DUMP_BYTE_CODE 0
#endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */ #endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */
/** /**
@@ -332,9 +346,18 @@
* *
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_PROPRETY_HASHMAP #ifndef JERRY_PROPERTY_HASHMAP
# define JERRY_PROPRETY_HASHMAP 1 #define JERRY_PROPERTY_HASHMAP 1
#endif /* !defined (JERRY_PROPRETY_HASHMAP) */ #endif /* !defined (JERRY_PROPERTY_HASHMAP) */
/**
* Enables/disables the Promise event callbacks
*
* Default value: 0
*/
#ifndef JERRY_PROMISE_CALLBACK
#define JERRY_PROMISE_CALLBACK 0
#endif /* !defined (JERRY_PROMISE_CALLBACK) */
/** /**
* Enable/Disable byte code dump functions for RegExp objects. * Enable/Disable byte code dump functions for RegExp objects.
@@ -349,7 +372,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_REGEXP_DUMP_BYTE_CODE #ifndef JERRY_REGEXP_DUMP_BYTE_CODE
# define JERRY_REGEXP_DUMP_BYTE_CODE 0 #define JERRY_REGEXP_DUMP_BYTE_CODE 0
#endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */ #endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */
/** /**
@@ -358,7 +381,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_REGEXP_STRICT_MODE #ifndef JERRY_REGEXP_STRICT_MODE
# define JERRY_REGEXP_STRICT_MODE 0 #define JERRY_REGEXP_STRICT_MODE 0
#endif /* !defined (JERRY_REGEXP_STRICT_MODE) */ #endif /* !defined (JERRY_REGEXP_STRICT_MODE) */
/** /**
@@ -371,7 +394,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_SNAPSHOT_EXEC #ifndef JERRY_SNAPSHOT_EXEC
# define JERRY_SNAPSHOT_EXEC 0 #define JERRY_SNAPSHOT_EXEC 0
#endif /* !defined (JERRY_SNAPSHOT_EXEC) */ #endif /* !defined (JERRY_SNAPSHOT_EXEC) */
/** /**
@@ -382,7 +405,7 @@
* 1: Enable snapshot save functions. * 1: Enable snapshot save functions.
*/ */
#ifndef JERRY_SNAPSHOT_SAVE #ifndef JERRY_SNAPSHOT_SAVE
# define JERRY_SNAPSHOT_SAVE 0 #define JERRY_SNAPSHOT_SAVE 0
#endif /* !defined (JERRY_SNAPSHOT_SAVE) */ #endif /* !defined (JERRY_SNAPSHOT_SAVE) */
/** /**
@@ -395,7 +418,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_SYSTEM_ALLOCATOR #ifndef JERRY_SYSTEM_ALLOCATOR
# define JERRY_SYSTEM_ALLOCATOR 0 #define JERRY_SYSTEM_ALLOCATOR 0
#endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */ #endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */
/** /**
@@ -403,7 +426,7 @@
* By default Unicode case conversion is enabled. * By default Unicode case conversion is enabled.
*/ */
#ifndef JERRY_UNICODE_CASE_CONVERSION #ifndef JERRY_UNICODE_CASE_CONVERSION
# define JERRY_UNICODE_CASE_CONVERSION 1 #define JERRY_UNICODE_CASE_CONVERSION 1
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */ #endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
/** /**
@@ -414,19 +437,30 @@
* 1: Enable the Valgrind specific allocation notifications. * 1: Enable the Valgrind specific allocation notifications.
*/ */
#ifndef JERRY_VALGRIND #ifndef JERRY_VALGRIND
# define JERRY_VALGRIND 0 #define JERRY_VALGRIND 0
#endif /* !defined (JERRY_VALGRIND) */ #endif /* !defined (JERRY_VALGRIND) */
/** /**
* Enable/Disable the vm execution stop callback function. * Enable/Disable the vm execution stop callback function.
* *
* Allowed values: * Allowed values:
* 0: Disable vm exec stop callbacks. * 0: Disable vm exec stop callback support.
* 1: Enable vm exec stop callback functionality. * 1: Enable vm exec stop callback support.
*/ */
#ifndef JERRY_VM_EXEC_STOP #ifndef JERRY_VM_HALT
# define JERRY_VM_EXEC_STOP 0 #define JERRY_VM_HALT 0
#endif /* !defined (JERRY_VM_EXEC_STOP) */ #endif /* !defined (JERRY_VM_HALT) */
/**
* Enable/Disable the vm throw callback function.
*
* Allowed values:
* 0: Disable vm throw callback support.
* 1: Enable vm throw callback support.
*/
#ifndef JERRY_VM_THROW
#define JERRY_VM_THROW 0
#endif /* !defined (JERRY_VM_THROW) */
/** /**
* Advanced section configurations. * Advanced section configurations.
@@ -446,7 +480,7 @@
* # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const"))) * # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const")))
*/ */
#ifndef JERRY_ATTR_CONST_DATA #ifndef JERRY_ATTR_CONST_DATA
# define JERRY_ATTR_CONST_DATA #define JERRY_ATTR_CONST_DATA
#endif /* !defined (JERRY_ATTR_CONST_DATA) */ #endif /* !defined (JERRY_ATTR_CONST_DATA) */
/** /**
@@ -456,7 +490,7 @@
* #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap"))) * #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap")))
*/ */
#ifndef JERRY_ATTR_GLOBAL_HEAP #ifndef JERRY_ATTR_GLOBAL_HEAP
# define JERRY_ATTR_GLOBAL_HEAP #define JERRY_ATTR_GLOBAL_HEAP
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */ #endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
/** /**
@@ -467,230 +501,185 @@
/** /**
* Check base builtins. * Check base builtins.
*/ */
#if !defined (JERRY_BUILTIN_ANNEXB) \ #if (JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1)
|| ((JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1)) #error "Invalid value for JERRY_BUILTIN_ANNEXB macro."
# error "Invalid value for JERRY_BUILTIN_ANNEXB macro." #endif /* (JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1) */
#endif #if (JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1)
#if !defined (JERRY_BUILTIN_ARRAY) \ #error "Invalid value for JERRY_BUILTIN_ARRAY macro."
|| ((JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1)) #endif /* (JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1) */
# error "Invalid value for JERRY_BUILTIN_ARRAY macro." #if (JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1)
#endif #error "Invalid value for JERRY_BUILTIN_BOOLEAN macro."
#if !defined (JERRY_BUILTIN_BOOLEAN) \ #endif /* (JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1) */
|| ((JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1)) #if (JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1)
# error "Invalid value for JERRY_BUILTIN_BOOLEAN macro." #error "Invalid value for JERRY_BUILTIN_DATE macro."
#endif #endif /* (JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1) */
#if !defined (JERRY_BUILTIN_DATE) \ #if (JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1)
|| ((JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1)) #error "Invalid value for JERRY_BUILTIN_ERRORS macro."
# error "Invalid value for JERRY_BUILTIN_DATE macro." #endif /* (JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1) */
#endif #if (JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1)
#if !defined (JERRY_BUILTIN_ERRORS) \ #error "Invalid value for JERRY_BUILTIN_JSON macro."
|| ((JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1)) #endif /* (JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1) */
# error "Invalid value for JERRY_BUILTIN_ERRORS macro." #if (JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1)
#endif #error "Invalid value for JERRY_BUILTIN_MATH macro."
#if !defined (JERRY_BUILTIN_JSON) \ #endif /* (JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1) */
|| ((JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1)) #if (JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1)
# error "Invalid value for JERRY_BUILTIN_JSON macro." #error "Invalid value for JERRY_BUILTIN_NUMBER macro."
#endif #endif /* (JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1) */
#if !defined (JERRY_BUILTIN_MATH) \ #if (JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1)
|| ((JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1)) #error "Invalid value for JERRY_BUILTIN_REGEXP macro."
# error "Invalid value for JERRY_BUILTIN_MATH macro." #endif /* (JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1) */
#endif #if (JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1)
#if !defined (JERRY_BUILTIN_NUMBER) \ #error "Invalid value for JERRY_BUILTIN_STRING macro."
|| ((JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1)) #endif /* (JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1) */
# error "Invalid value for JERRY_BUILTIN_NUMBER macro." #if (JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1)
#endif #error "Invalid value for JERRY_BUILTINS macro."
#if !defined (JERRY_BUILTIN_REGEXP) \ #endif /* (JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1) */
|| ((JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1)) #if (JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1)
# error "Invalid value for JERRY_BUILTIN_REGEXP macro." #error "Invalid value for JERRY_BUILTIN_REALMS macro."
#endif #endif /* (JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1) */
#if !defined (JERRY_BUILTIN_STRING) \ #if (JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1)
|| ((JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1)) #error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
# error "Invalid value for JERRY_BUILTIN_STRING macro." #endif /* (JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1) */
#endif #if (JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1)
#if !defined (JERRY_BUILTINS) \ #error "Invalid value for JERRY_BUILTIN_GLOBAL_THIS macro."
|| ((JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1)) #endif /* (JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1) */
# error "Invalid value for JERRY_BUILTINS macro." #if (JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1)
#endif #error "Invalid value for JERRY_BUILTIN_REFLECT macro."
#endif /* (JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1) */
/** #if (JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1)
* Check ES2015 features #error "Invalid value for JERRY_BUILTIN_WEAKREF macro."
*/ #endif /* (JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1) */
#if !defined (JERRY_ES2015) \ #if (JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1)
|| ((JERRY_ES2015 != 0) && (JERRY_ES2015 != 1)) #error "Invalid value for JERRY_BUILTIN_PROXY macro."
# error "Invalid value for JERRY_ES2015 macro." #endif /* (JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1) */
#endif #if (JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1)
#if !defined (JERRY_ES2015_BUILTIN_DATAVIEW) \ #error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro."
|| ((JERRY_ES2015_BUILTIN_DATAVIEW != 0) && (JERRY_ES2015_BUILTIN_DATAVIEW != 1)) #endif /* (JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1) */
# error "Invalid value for JERRY_ES2015_BUILTIN_DATAVIEW macro." #if (JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1)
#endif #error "Invalid value for JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
#if !defined (JERRY_ES2015_BUILTIN_MAP) \ #endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1) */
|| ((JERRY_ES2015_BUILTIN_MAP != 0) && (JERRY_ES2015_BUILTIN_MAP != 1)) #if (JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1)
# error "Invalid value for JERRY_ES2015_BUILTIN_MAP macro." #error "Invalid value for JERRY_BUILTIN_ATOMICS macro."
#endif #endif /* (JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1) */
#if !defined (JERRY_ES2015_BUILTIN_REFLECT) \ #if (JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1)
|| ((JERRY_ES2015_BUILTIN_REFLECT != 0) && (JERRY_ES2015_BUILTIN_REFLECT != 1)) #error "Invalid value for JERRY_BUILTIN_BIGINT macro."
# error "Invalid value for JERRY_ES2015_BUILTIN_REFLECT macro." #endif /* (JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1) */
#endif #if (JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1)
#if !defined (JERRY_ES2015_BUILTIN_SET) \ #error "Invalid value for JERRY_MODULE_SYSTEM macro."
|| ((JERRY_ES2015_BUILTIN_SET != 0) && (JERRY_ES2015_BUILTIN_SET != 1)) #endif /* (JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1) */
# error "Invalid value for JERRY_ES2015_BUILTIN_SET macro." #if (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1)
#endif #error "JERRY_BUILTIN_TYPEDARRAY should be enabled too to enable JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
#if !defined (JERRY_ES2015_BUILTIN_WEAKMAP) \ #endif /* (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1) */
|| ((JERRY_ES2015_BUILTIN_WEAKMAP != 0) && (JERRY_ES2015_BUILTIN_WEAKMAP != 1)) #if (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1)
# error "Invalid value for JERRY_ES2015_BUILTIN_WEAKMAP macro." #error "JERRY_BUILTIN_SHAREDARRAYBUFFER should be enabled too to enable JERRY_BUILTIN_ATOMICS macro."
#endif #endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1) */
#if !defined (JERRY_ES2015_BUILTIN_WEAKSET) \
|| ((JERRY_ES2015_BUILTIN_WEAKSET != 0) && (JERRY_ES2015_BUILTIN_WEAKSET != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_WEAKSET macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_PROMISE) \
|| ((JERRY_ES2015_BUILTIN_PROMISE != 0) && (JERRY_ES2015_BUILTIN_PROMISE != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_PROMISE macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_PROXY) \
|| ((JERRY_ES2015_BUILTIN_PROXY != 0) && (JERRY_ES2015_BUILTIN_PROXY != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_PROXY macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_TYPEDARRAY) \
|| ((JERRY_ES2015_BUILTIN_TYPEDARRAY != 0) && (JERRY_ES2015_BUILTIN_TYPEDARRAY != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_TYPEDARRAY macro."
#endif
#if !defined (JERRY_ES2015_MODULE_SYSTEM) \
|| ((JERRY_ES2015_MODULE_SYSTEM != 0) && (JERRY_ES2015_MODULE_SYSTEM != 1))
# error "Invalid value for JERRY_ES2015_MODULE_SYSTEM macro."
#endif
/** /**
* Internal options. * Internal options.
*/ */
#if !defined (JERRY_CPOINTER_32_BIT) \ #if (JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1)
|| ((JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1)) #error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro."
# error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro." #endif /* (JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1) */
#endif #if (JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1)
#if !defined (JERRY_DEBUGGER) \ #error "Invalid value for 'JERRY_DEBUGGER' macro."
|| ((JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1)) #endif /* (JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1) */
# error "Invalid value for 'JERRY_DEBUGGER' macro." #if (JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1)
#endif #error "Invalid value for 'JERRY_ERROR_MESSAGES' macro."
#if !defined (JERRY_ERROR_MESSAGES) \ #endif /* (JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1) */
|| ((JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1)) #if (JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1)
# error "Invalid value for 'JERRY_ERROR_MESSAGES' macro." #error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro."
#endif #endif /* (JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1) */
#if !defined (JERRY_EXTERNAL_CONTEXT) \ #if JERRY_GLOBAL_HEAP_SIZE <= 0
|| ((JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1)) #error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro."
# error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro." #endif /* JERRY_GLOBAL_HEAP_SIZE <= 0 */
#endif #if JERRY_GC_LIMIT < 0
#if !defined (JERRY_GLOBAL_HEAP_SIZE) || (JERRY_GLOBAL_HEAP_SIZE <= 0) #error "Invalid value for 'JERRY_GC_LIMIT' macro."
# error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro." #endif /* JERRY_GC_LIMIT < 0 */
#endif #if JERRY_STACK_LIMIT < 0
#if !defined (JERRY_GC_LIMIT) || (JERRY_GC_LIMIT < 0) #error "Invalid value for 'JERRY_STACK_LIMIT' macro."
# error "Invalid value for 'JERRY_GC_LIMIT' macro." #endif /* JERRY_STACK_LIMIT < 0 */
#endif #if JERRY_GC_MARK_LIMIT < 0
#if !defined (JERRY_STACK_LIMIT) || (JERRY_STACK_LIMIT < 0) #error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro."
# error "Invalid value for 'JERRY_STACK_LIMIT' macro." #endif /* JERRY_GC_MARK_LIMIT < 0 */
#endif #if (JERRY_LCACHE != 0) && (JERRY_LCACHE != 1)
#if !defined (JERRY_GC_MARK_LIMIT) || (JERRY_GC_MARK_LIMIT < 0) #error "Invalid value for 'JERRY_LCACHE' macro."
# error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro." #endif /* (JERRY_LCACHE != 0) && (JERRY_LCACHE != 1) */
#endif #if (JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1)
#if !defined (JERRY_LCACHE) \ #error "Invalid value for 'JERRY_FUNCTION_TO_STRING' macro."
|| ((JERRY_LCACHE != 0) && (JERRY_LCACHE != 1)) #endif /* (JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1) */
# error "Invalid value for 'JERRY_LCACHE' macro." #if (JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1)
#endif #error "Invalid value for 'JERRY_LINE_INFO' macro."
#if !defined (JERRY_LINE_INFO) \ #endif /* (JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1) */
|| ((JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1)) #if (JERRY_LOGGING != 0) && (JERRY_LOGGING != 1)
# error "Invalid value for 'JERRY_LINE_INFO' macro." #error "Invalid value for 'JERRY_LOGGING' macro."
#endif #endif /* (JERRY_LOGGING != 0) && (JERRY_LOGGING != 1) */
#if !defined (JERRY_LOGGING) \ #if (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1)
|| ((JERRY_LOGGING != 0) && (JERRY_LOGGING != 1)) #error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro."
# error "Invalid value for 'JERRY_LOGGING' macro." #endif /* (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1) */
#endif #if (JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1)
#if !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) \ #error "Invalid value for 'JERRY_MEM_STATS' macro."
|| ((JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1)) #endif /* (JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1) */
# error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro." #if (JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1)
#endif #error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro."
#if !defined (JERRY_MEM_STATS) \ #endif /* (JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1) */
|| ((JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1)) #if (JERRY_PARSER != 0) && (JERRY_PARSER != 1)
# error "Invalid value for 'JERRY_MEM_STATS' macro." #error "Invalid value for 'JERRY_PARSER' macro."
#endif #endif /* (JERRY_PARSER != 0) && (JERRY_PARSER != 1) */
#if !defined (JERRY_NUMBER_TYPE_FLOAT64) \ #if (JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1)
|| ((JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1)) #error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro."
# error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro." #endif /* (JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1) */
#endif #if (JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1)
#if !defined (JERRY_PARSER) \ #error "Invalid value for 'JERRY_PROPERTY_HASHMAP' macro."
|| ((JERRY_PARSER != 0) && (JERRY_PARSER != 1)) #endif /* (JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1) */
# error "Invalid value for 'JERRY_PARSER' macro." #if (JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1)
#endif #error "Invalid value for 'JERRY_PROMISE_CALLBACK' macro."
#if !defined (JERRY_PARSER_DUMP_BYTE_CODE) \ #endif /* (JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1) */
|| ((JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1)) #if (JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1)
# error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro." #error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro."
#endif #endif /* (JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1) */
#if !defined (JERRY_PROPRETY_HASHMAP) \ #if (JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1)
|| ((JERRY_PROPRETY_HASHMAP != 0) && (JERRY_PROPRETY_HASHMAP != 1)) #error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro."
# error "Invalid value for 'JERRY_PROPRETY_HASHMAP' macro." #endif /* (JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1) */
#endif #if (JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1)
#if !defined (JERRY_REGEXP_DUMP_BYTE_CODE) \ #error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro."
|| ((JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1)) #endif /* (JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1) */
# error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro." #if (JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1)
#endif #error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro."
#if !defined (JERRY_REGEXP_STRICT_MODE) \ #endif /* (JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1) */
|| ((JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1)) #if (JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1)
# error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro." #error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro."
#endif #endif /* (JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1) */
#if !defined (JERRY_SNAPSHOT_EXEC) \ #if (JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1)
|| ((JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1)) #error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
# error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro." #endif /* (JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1) */
#endif #if (JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1)
#if !defined (JERRY_SNAPSHOT_SAVE) \ #error "Invalid value for 'JERRY_VALGRIND' macro."
|| ((JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1)) #endif /* (JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1) */
# error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro." #if (JERRY_VM_HALT != 0) && (JERRY_VM_HALT != 1)
#endif #error "Invalid value for 'JERRY_VM_HALT' macro."
#if !defined (JERRY_SYSTEM_ALLOCATOR) \ #endif /* (JERRY_VM_HALT != 0) && (JERRY_VM_HALT != 1) */
|| ((JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1)) #if (JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1)
# error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro." #error "Invalid value for 'JERRY_VM_THROW' macro."
#endif #endif /* (JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1) */
#if !defined (JERRY_UNICODE_CASE_CONVERSION) \
|| ((JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1))
# error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
#endif
#if !defined (JERRY_VALGRIND) \
|| ((JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1))
# error "Invalid value for 'JERRY_VALGRIND' macro."
#endif
#if !defined (JERRY_VM_EXEC_STOP) \
|| ((JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1))
# error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
#endif
#define ENABLED(FEATURE) ((FEATURE) == 1)
#define DISABLED(FEATURE) ((FEATURE) != 1)
/** /**
* Cross component requirements check. * Cross component requirements check.
*/ */
/** /**
* The date module can only use the float 64 number types. * The date module can only use the float 64 number types.
* Do a check for this.
*/ */
#if ENABLED (JERRY_BUILTIN_DATE) && !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) #if JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64
# error "Date does not support float32" #error "Date does not support float32"
#endif #endif /* JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 */
/** /**
* Wrap container types into a single guard * Source name related types into a single guard
*/ */
#if ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) \ #if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM
|| ENABLED (JERRY_ES2015_BUILTIN_WEAKMAP) || ENABLED (JERRY_ES2015_BUILTIN_WEAKSET) #define JERRY_SOURCE_NAME 1
# define JERRY_ES2015_BUILTIN_CONTAINER 1 #else /* !(JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM) */
#else #define JERRY_SOURCE_NAME 0
# define JERRY_ES2015_BUILTIN_CONTAINER 0 #endif /* JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM */
#endif
/**
* Resource name relatey types into a single guard
*/
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
# define JERRY_RESOURCE_NAME 1
#else
# define JERRY_RESOURCE_NAME 0
#endif
#endif /* !JERRYSCRIPT_CONFIG_H */ #endif /* !JERRYSCRIPT_CONFIG_H */
+62 -72
View File
@@ -13,19 +13,22 @@
* limitations under the License. * limitations under the License.
*/ */
#include "byte-code.h"
#include "debugger.h" #include "debugger.h"
#include "jerryscript-debugger.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-eval.h" #include "ecma-eval.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "byte-code.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript-port.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#if ENABLED (JERRY_DEBUGGER) #if JERRY_DEBUGGER
/** /**
* Incoming message: next message of string data. * Incoming message: next message of string data.
@@ -39,16 +42,14 @@ typedef struct
* The number of message types in the debugger should reflect the * The number of message types in the debugger should reflect the
* debugger versioning. * debugger versioning.
*/ */
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33 JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33 && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21 && JERRY_DEBUGGER_VERSION == 9,
&& JERRY_DEBUGGER_VERSION == 9,
debugger_version_correlates_to_message_type_count); debugger_version_correlates_to_message_type_count);
/** /**
* Waiting for data from the client. * Waiting for data from the client.
*/ */
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE \ #define JERRY_DEBUGGER_RECEIVE_DATA_MODE (JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
(JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
/** /**
* Type cast the debugger send buffer into a specific type. * Type cast the debugger send buffer into a specific type.
@@ -59,8 +60,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33
/** /**
* Type cast the debugger receive buffer into a specific type. * Type cast the debugger receive buffer into a specific type.
*/ */
#define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) \ #define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) type *name_p = ((type *) recv_buffer_p)
type *name_p = ((type *) recv_buffer_p)
/** /**
* Free all unreferenced byte code structures which * Free all unreferenced byte code structures which
@@ -71,17 +71,15 @@ jerry_debugger_free_unreferenced_byte_code (void)
{ {
jerry_debugger_byte_code_free_t *byte_code_free_p; jerry_debugger_byte_code_free_t *byte_code_free_p;
byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p =
JERRY_CONTEXT (debugger_byte_code_free_tail)); JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, JERRY_CONTEXT (debugger_byte_code_free_tail));
while (byte_code_free_p != NULL) while (byte_code_free_p != NULL)
{ {
jerry_debugger_byte_code_free_t *prev_byte_code_free_p; jerry_debugger_byte_code_free_t *prev_byte_code_free_p;
prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p->prev_cp);
byte_code_free_p->prev_cp);
jmem_heap_free_block (byte_code_free_p, jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
byte_code_free_p = prev_byte_code_free_p; byte_code_free_p = prev_byte_code_free_p;
} }
@@ -131,7 +129,7 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
uint32_t frame_count = 0; uint32_t frame_count = 0;
while (iter_frame_ctx_p != NULL) while (iter_frame_ctx_p != NULL)
{ {
if (!(iter_frame_ctx_p->bytecode_header_p->status_flags & (CBC_CODE_FLAGS_STATIC_FUNCTION))) if (!(iter_frame_ctx_p->shared_p->bytecode_header_p->status_flags & (CBC_CODE_FLAGS_STATIC_FUNCTION)))
{ {
frame_count++; frame_count++;
} }
@@ -164,7 +162,7 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
while (frame_ctx_p != NULL && min_depth_offset++ < max_depth) while (frame_ctx_p != NULL && min_depth_offset++ < max_depth)
{ {
if (frame_ctx_p->bytecode_header_p->status_flags if (frame_ctx_p->shared_p->bytecode_header_p->status_flags
& (CBC_CODE_FLAGS_DEBUGGER_IGNORE | CBC_CODE_FLAGS_STATIC_FUNCTION)) & (CBC_CODE_FLAGS_DEBUGGER_IGNORE | CBC_CODE_FLAGS_STATIC_FUNCTION))
{ {
frame_ctx_p = frame_ctx_p->prev_context_p; frame_ctx_p = frame_ctx_p->prev_context_p;
@@ -183,10 +181,10 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
jerry_debugger_frame_t *frame_p = backtrace_p->frames + current_frame; jerry_debugger_frame_t *frame_p = backtrace_p->frames + current_frame;
jmem_cpointer_t byte_code_cp; jmem_cpointer_t byte_code_cp;
JMEM_CP_SET_NON_NULL_POINTER (byte_code_cp, frame_ctx_p->bytecode_header_p); JMEM_CP_SET_NON_NULL_POINTER (byte_code_cp, frame_ctx_p->shared_p->bytecode_header_p);
memcpy (frame_p->byte_code_cp, &byte_code_cp, sizeof (jmem_cpointer_t)); memcpy (frame_p->byte_code_cp, &byte_code_cp, sizeof (jmem_cpointer_t));
uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->bytecode_header_p); uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->shared_p->bytecode_header_p);
memcpy (frame_p->offset, &offset, sizeof (uint32_t)); memcpy (frame_p->offset, &offset, sizeof (uint32_t));
frame_ctx_p = frame_ctx_p->prev_context_p; frame_ctx_p = frame_ctx_p->prev_context_p;
@@ -488,8 +486,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
continue; continue;
} }
ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i], ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i]);
prop_pair_p->names_cp[i]);
if (!jerry_debugger_copy_variables_to_string_message (JERRY_DEBUGGER_VALUE_NONE, if (!jerry_debugger_copy_variables_to_string_message (JERRY_DEBUGGER_VALUE_NONE,
prop_name, prop_name,
@@ -509,10 +506,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
ecma_string_t *str_p = ecma_op_to_string (prop_value_p.value); ecma_string_t *str_p = ecma_op_to_string (prop_value_p.value);
JERRY_ASSERT (str_p != NULL); JERRY_ASSERT (str_p != NULL);
if (!jerry_debugger_copy_variables_to_string_message (variable_type, if (!jerry_debugger_copy_variables_to_string_message (variable_type, str_p, message_string_p, &buffer_pos))
str_p,
message_string_p,
&buffer_pos))
{ {
ecma_deref_ecma_string (str_p); ecma_deref_ecma_string (str_p);
return; return;
@@ -546,9 +540,14 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
uint32_t chain_index; uint32_t chain_index;
memcpy (&chain_index, eval_string_p, sizeof (uint32_t)); memcpy (&chain_index, eval_string_p, sizeof (uint32_t));
uint32_t parse_opts = ECMA_PARSE_DIRECT_EVAL | (chain_index << ECMA_PARSE_CHAIN_INDEX_SHIFT); uint32_t parse_opts = ECMA_PARSE_DIRECT_EVAL;
JERRY_CONTEXT (debugger_eval_chain_index) = (uint16_t) chain_index;
ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p + 5, eval_string_size - 5, parse_opts); parser_source_char_t source_char;
source_char.source_p = eval_string_p + 5;
source_char.source_size = eval_string_size - 5;
ecma_value_t result = ecma_op_eval_chars_buffer ((void *) &source_char, parse_opts);
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE); JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
if (!ECMA_IS_VALUE_ERROR (result)) if (!ECMA_IS_VALUE_ERROR (result))
@@ -587,21 +586,17 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
if (ecma_is_value_object (result)) if (ecma_is_value_object (result))
{ {
message = ecma_op_object_find (ecma_get_object_from_value (result), message =
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE)); ecma_op_object_find (ecma_get_object_from_value (result), ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
if (!ecma_is_value_string (message) if (!ecma_is_value_string (message) || ecma_string_is_empty (ecma_get_string_from_value (message)))
|| ecma_string_is_empty (ecma_get_string_from_value (message)))
{ {
ecma_free_value (message); ecma_free_value (message);
lit_magic_string_id_t id = ecma_object_get_class_name (ecma_get_object_from_value (result)); lit_magic_string_id_t id = ecma_object_get_class_name (ecma_get_object_from_value (result));
ecma_free_value (result); ecma_free_value (result);
const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id); const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id);
jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, string_p, strlen ((const char *) string_p));
type,
string_p,
strlen ((const char *) string_p));
return false; return false;
} }
} }
@@ -631,12 +626,12 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
/** /**
* Check received packet size. * Check received packet size.
*/ */
#define JERRY_DEBUGGER_CHECK_PACKET_SIZE(type) \ #define JERRY_DEBUGGER_CHECK_PACKET_SIZE(type) \
if (message_size != sizeof (type)) \ if (message_size != sizeof (type)) \
{ \ { \
JERRY_ERROR_MSG ("Invalid message size\n"); \ JERRY_ERROR_MSG ("Invalid message size\n"); \
jerry_debugger_transport_close (); \ jerry_debugger_transport_close (); \
return false; \ return false; \
} }
/** /**
@@ -654,8 +649,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
{ {
/* Process the received message. */ /* Process the received message. */
if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{ {
JERRY_ERROR_MSG ("Message requires breakpoint mode\n"); JERRY_ERROR_MSG ("Message requires breakpoint mode\n");
jerry_debugger_transport_close (); jerry_debugger_transport_close ();
@@ -700,9 +694,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
} }
lit_utf8_byte_t *string_p = (lit_utf8_byte_t *) (uint8_data_p + 1); lit_utf8_byte_t *string_p = (lit_utf8_byte_t *) (uint8_data_p + 1);
memcpy (string_p + uint8_data_p->uint8_offset, memcpy (string_p + uint8_data_p->uint8_offset, (lit_utf8_byte_t *) (uint8_data_part_p + 1), message_size);
(lit_utf8_byte_t *) (uint8_data_part_p + 1),
message_size);
if (message_size < expected_data) if (message_size < expected_data)
{ {
@@ -750,8 +742,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
} }
jerry_debugger_byte_code_free_t *byte_code_free_p; jerry_debugger_byte_code_free_t *byte_code_free_p;
byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_cp);
byte_code_free_cp);
if (byte_code_free_p->prev_cp != ECMA_NULL_POINTER) if (byte_code_free_p->prev_cp != ECMA_NULL_POINTER)
{ {
@@ -763,12 +754,11 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
JERRY_CONTEXT (debugger_byte_code_free_tail) = ECMA_NULL_POINTER; JERRY_CONTEXT (debugger_byte_code_free_tail) = ECMA_NULL_POINTER;
} }
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_byte_code_bytes (((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG); jmem_stats_free_byte_code_bytes (((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_heap_free_block (byte_code_free_p, jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
return true; return true;
} }
@@ -1019,8 +1009,8 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
client_source_data_p = (jerry_debugger_uint8_data_t *) jmem_heap_alloc_block (client_source_data_size); client_source_data_p = (jerry_debugger_uint8_data_t *) jmem_heap_alloc_block (client_source_data_size);
client_source_data_p->uint8_size = client_source_size; client_source_data_p->uint8_size = client_source_size;
client_source_data_p->uint8_offset = (uint32_t) (message_size client_source_data_p->uint8_offset =
- sizeof (jerry_debugger_receive_client_source_first_t)); (uint32_t) (message_size - sizeof (jerry_debugger_receive_client_source_first_t));
lit_utf8_byte_t *client_source_string_p = (lit_utf8_byte_t *) (client_source_data_p + 1); lit_utf8_byte_t *client_source_string_p = (lit_utf8_byte_t *) (client_source_data_p + 1);
memcpy (client_source_string_p, memcpy (client_source_string_p,
@@ -1167,10 +1157,10 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p); vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
jmem_cpointer_t byte_code_header_cp; jmem_cpointer_t byte_code_header_cp;
JMEM_CP_SET_NON_NULL_POINTER (byte_code_header_cp, frame_ctx_p->bytecode_header_p); JMEM_CP_SET_NON_NULL_POINTER (byte_code_header_cp, frame_ctx_p->shared_p->bytecode_header_p);
memcpy (breakpoint_hit_p->byte_code_cp, &byte_code_header_cp, sizeof (jmem_cpointer_t)); memcpy (breakpoint_hit_p->byte_code_cp, &byte_code_header_cp, sizeof (jmem_cpointer_t));
uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->bytecode_header_p); uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->shared_p->bytecode_header_p);
memcpy (breakpoint_hit_p->offset, &offset, sizeof (uint32_t)); memcpy (breakpoint_hit_p->offset, &offset, sizeof (uint32_t));
if (!jerry_debugger_send (sizeof (jerry_debugger_send_breakpoint_hit_t))) if (!jerry_debugger_send (sizeof (jerry_debugger_send_breakpoint_hit_t)))
@@ -1189,8 +1179,7 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
if (uint8_data != NULL) if (uint8_data != NULL)
{ {
jmem_heap_free_block (uint8_data, jmem_heap_free_block (uint8_data, uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
} }
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE); JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE);
@@ -1378,7 +1367,7 @@ jerry_debugger_send_memstats (void)
memstats_p->type = JERRY_DEBUGGER_MEMSTATS_RECEIVE; memstats_p->type = JERRY_DEBUGGER_MEMSTATS_RECEIVE;
#if ENABLED (JERRY_MEM_STATS) /* if memory statistics feature is enabled */ #if JERRY_MEM_STATS /* if memory statistics feature is enabled */
jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats); jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats);
uint32_t allocated_bytes = (uint32_t) heap_stats->allocated_bytes; uint32_t allocated_bytes = (uint32_t) heap_stats->allocated_bytes;
@@ -1391,13 +1380,13 @@ jerry_debugger_send_memstats (void)
memcpy (memstats_p->object_bytes, &object_bytes, sizeof (uint32_t)); memcpy (memstats_p->object_bytes, &object_bytes, sizeof (uint32_t));
uint32_t property_bytes = (uint32_t) heap_stats->property_bytes; uint32_t property_bytes = (uint32_t) heap_stats->property_bytes;
memcpy (memstats_p->property_bytes, &property_bytes, sizeof (uint32_t)); memcpy (memstats_p->property_bytes, &property_bytes, sizeof (uint32_t));
#else /* !ENABLED (JERRY_MEM_STATS) if not, just put zeros */ #else /* !JERRY_MEM_STATS if not, just put zeros */
memset (memstats_p->allocated_bytes, 0, sizeof (uint32_t)); memset (memstats_p->allocated_bytes, 0, sizeof (uint32_t));
memset (memstats_p->byte_code_bytes, 0, sizeof (uint32_t)); memset (memstats_p->byte_code_bytes, 0, sizeof (uint32_t));
memset (memstats_p->string_bytes, 0, sizeof (uint32_t)); memset (memstats_p->string_bytes, 0, sizeof (uint32_t));
memset (memstats_p->object_bytes, 0, sizeof (uint32_t)); memset (memstats_p->object_bytes, 0, sizeof (uint32_t));
memset (memstats_p->property_bytes, 0, sizeof (uint32_t)); memset (memstats_p->property_bytes, 0, sizeof (uint32_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jerry_debugger_send (sizeof (jerry_debugger_send_memstats_t)); jerry_debugger_send (sizeof (jerry_debugger_send_memstats_t));
} /* jerry_debugger_send_memstats */ } /* jerry_debugger_send_memstats */
@@ -1421,8 +1410,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
ecma_object_t *prototype_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, prototype_cp); ecma_object_t *prototype_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, prototype_cp);
if (ecma_get_object_type (prototype_p) != ECMA_OBJECT_TYPE_GENERAL if (ecma_get_object_type (prototype_p) != ECMA_OBJECT_TYPE_BUILT_IN_GENERAL)
|| !ecma_get_object_is_builtin (prototype_p))
{ {
return NULL; return NULL;
} }
@@ -1431,7 +1419,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
switch (((ecma_extended_object_t *) prototype_p)->u.built_in.id) switch (((ecma_extended_object_t *) prototype_p)->u.built_in.id)
{ {
#if ENABLED (JERRY_BUILTIN_ERRORS) #if JERRY_BUILTIN_ERRORS
case ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE: case ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE:
{ {
string_id = LIT_MAGIC_STRING_EVAL_ERROR_UL; string_id = LIT_MAGIC_STRING_EVAL_ERROR_UL;
@@ -1457,12 +1445,17 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL; string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL;
break; break;
} }
case ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE:
{
string_id = LIT_MAGIC_STRING_AGGREGATE_ERROR_UL;
break;
}
case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE: case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE:
{ {
string_id = LIT_MAGIC_STRING_URI_ERROR_UL; string_id = LIT_MAGIC_STRING_URI_ERROR_UL;
break; break;
} }
#endif /* ENABLED (JERRY_BUILTIN_ERRORS) */ #endif /* JERRY_BUILTIN_ERRORS */
case ECMA_BUILTIN_ID_ERROR_PROTOTYPE: case ECMA_BUILTIN_ID_ERROR_PROTOTYPE:
{ {
string_id = LIT_MAGIC_STRING_ERROR_UL; string_id = LIT_MAGIC_STRING_ERROR_UL;
@@ -1482,8 +1475,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
property_p = ecma_find_named_property (ecma_get_object_from_value (exception_obj_value), property_p = ecma_find_named_property (ecma_get_object_from_value (exception_obj_value),
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE)); ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
if (property_p == NULL if (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_DATA))
|| ECMA_PROPERTY_GET_TYPE (*property_p) != ECMA_PROPERTY_TYPE_NAMEDDATA)
{ {
return ecma_stringbuilder_finalize (&builder); return ecma_stringbuilder_finalize (&builder);
} }
@@ -1535,10 +1527,8 @@ jerry_debugger_send_exception_string (ecma_value_t exception_value)
ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size); ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size);
bool result = jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR, bool result =
JERRY_DEBUGGER_NO_SUBTYPE, jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR, JERRY_DEBUGGER_NO_SUBTYPE, string_data_p, string_size);
string_data_p,
string_size);
ECMA_FINALIZE_UTF8_STRING (string_data_p, string_size); ECMA_FINALIZE_UTF8_STRING (string_data_p, string_size);
@@ -1546,4 +1536,4 @@ jerry_debugger_send_exception_string (ecma_value_t exception_value)
return result; return result;
} /* jerry_debugger_send_exception_string */ } /* jerry_debugger_send_exception_string */
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
+10 -13
View File
@@ -16,10 +16,11 @@
#ifndef DEBUGGER_H #ifndef DEBUGGER_H
#define DEBUGGER_H #define DEBUGGER_H
#include "ecma-globals.h"
#include "jerryscript-debugger-transport.h" #include "jerryscript-debugger-transport.h"
#if ENABLED (JERRY_DEBUGGER) #include "ecma-globals.h"
#if JERRY_DEBUGGER
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */ /* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
@@ -51,8 +52,7 @@
/** /**
* Calculate the size of a message when a count number of items transmitted. * Calculate the size of a message when a count number of items transmitted.
*/ */
#define JERRY_DEBUGGER_SEND_SIZE(count, type) \ #define JERRY_DEBUGGER_SEND_SIZE(count, type) ((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
/** /**
* Debugger operation modes: * Debugger operation modes:
@@ -113,8 +113,8 @@ typedef enum
* Set and clear debugger flags. * Set and clear debugger flags.
*/ */
#define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \ #define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \
JERRY_CONTEXT (debugger_flags) = ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) \ JERRY_CONTEXT (debugger_flags) = \
& (uint32_t) ~(flags_to_clear)) ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) & (uint32_t) ~(flags_to_clear))
/** /**
* Types for the package. * Types for the package.
@@ -227,11 +227,8 @@ typedef enum
*/ */
typedef enum typedef enum
{ {
JERRY_DEBUGGER_OUTPUT_OK = 1, /**< output result, no error */ JERRY_DEBUGGER_OUTPUT_PRINT = 1, /**< printed output */
JERRY_DEBUGGER_OUTPUT_ERROR = 2, /**< output result, error */ JERRY_DEBUGGER_OUTPUT_LOG = 2, /**< logged output */
JERRY_DEBUGGER_OUTPUT_WARNING = 3, /**< output result, warning */
JERRY_DEBUGGER_OUTPUT_DEBUG = 4, /**< output result, debug */
JERRY_DEBUGGER_OUTPUT_TRACE = 5, /**< output result, trace */
} jerry_debugger_output_subtype_t; } jerry_debugger_output_subtype_t;
/** /**
@@ -455,7 +452,7 @@ typedef struct
/** /**
* Incoming message: get scope variables * Incoming message: get scope variables
*/ */
typedef struct typedef struct
{ {
uint8_t type; /**< type of the message */ uint8_t type; /**< type of the message */
@@ -486,6 +483,6 @@ bool jerry_debugger_send_parse_function (uint32_t line, uint32_t column);
void jerry_debugger_send_memstats (void); void jerry_debugger_send_memstats (void);
bool jerry_debugger_send_exception_string (ecma_value_t exception_value); bool jerry_debugger_send_exception_string (ecma_value_t exception_value);
#endif /* ENABLED (JERRY_DEBUGGER) */ #endif /* JERRY_DEBUGGER */
#endif /* !DEBUGGER_H */ #endif /* !DEBUGGER_H */
+70 -40
View File
@@ -14,10 +14,12 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-globals.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "jrt.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
#include "jrt.h"
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t); size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
@@ -51,7 +53,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
ecma_number_t * extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_number (void) ecma_alloc_number (void)
{ {
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t)); return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
@@ -60,7 +62,7 @@ ecma_alloc_number (void)
/** /**
* Dealloc memory from an ecma-number * Dealloc memory from an ecma-number
*/ */
void extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
{ {
jmem_pools_free ((uint8_t *) number_p, sizeof (ecma_number_t)); jmem_pools_free ((uint8_t *) number_p, sizeof (ecma_number_t));
@@ -71,12 +73,12 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_object (void) ecma_alloc_object (void)
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_allocate_object_bytes (sizeof (ecma_object_t)); jmem_stats_allocate_object_bytes (sizeof (ecma_object_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
return (ecma_object_t *) jmem_pools_alloc (sizeof (ecma_object_t)); return (ecma_object_t *) jmem_pools_alloc (sizeof (ecma_object_t));
} /* ecma_alloc_object */ } /* ecma_alloc_object */
@@ -84,12 +86,12 @@ ecma_alloc_object (void)
/** /**
* Dealloc memory from an ecma-object * Dealloc memory from an ecma-object
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_object_bytes (sizeof (ecma_object_t)); jmem_stats_free_object_bytes (sizeof (ecma_object_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_pools_free (object_p, sizeof (ecma_object_t)); jmem_pools_free (object_p, sizeof (ecma_object_t));
} /* ecma_dealloc_object */ } /* ecma_dealloc_object */
@@ -99,12 +101,12 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_extended_object_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_extended_object (size_t size) /**< size of object */ ecma_alloc_extended_object (size_t size) /**< size of object */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_allocate_object_bytes (size); jmem_stats_allocate_object_bytes (size);
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
return jmem_heap_alloc_block (size); return jmem_heap_alloc_block (size);
} /* ecma_alloc_extended_object */ } /* ecma_alloc_extended_object */
@@ -112,13 +114,13 @@ ecma_alloc_extended_object (size_t size) /**< size of object */
/** /**
* Dealloc memory of an extended object * Dealloc memory of an extended object
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
size_t size) /**< size of object */ size_t size) /**< size of object */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_object_bytes (size); jmem_stats_free_object_bytes (size);
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_heap_free_block (object_p, size); jmem_heap_free_block (object_p, size);
} /* ecma_dealloc_extended_object */ } /* ecma_dealloc_extended_object */
@@ -128,12 +130,12 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_string (void) ecma_alloc_string (void)
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_allocate_string_bytes (sizeof (ecma_string_t)); jmem_stats_allocate_string_bytes (sizeof (ecma_string_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
return (ecma_string_t *) jmem_pools_alloc (sizeof (ecma_string_t)); return (ecma_string_t *) jmem_pools_alloc (sizeof (ecma_string_t));
} /* ecma_alloc_string */ } /* ecma_alloc_string */
@@ -141,12 +143,12 @@ ecma_alloc_string (void)
/** /**
* Dealloc memory from ecma-string descriptor * Dealloc memory from ecma-string descriptor
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_string_bytes (sizeof (ecma_string_t)); jmem_stats_free_string_bytes (sizeof (ecma_string_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_pools_free (string_p, sizeof (ecma_string_t)); jmem_pools_free (string_p, sizeof (ecma_string_t));
} /* ecma_dealloc_string */ } /* ecma_dealloc_string */
@@ -156,12 +158,12 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_extended_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_extended_string (void) ecma_alloc_extended_string (void)
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_allocate_string_bytes (sizeof (ecma_extended_string_t)); jmem_stats_allocate_string_bytes (sizeof (ecma_extended_string_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
return (ecma_extended_string_t *) jmem_heap_alloc_block (sizeof (ecma_extended_string_t)); return (ecma_extended_string_t *) jmem_heap_alloc_block (sizeof (ecma_extended_string_t));
} /* ecma_alloc_extended_string */ } /* ecma_alloc_extended_string */
@@ -169,27 +171,55 @@ ecma_alloc_extended_string (void)
/** /**
* Dealloc memory from extended ecma-string descriptor * Dealloc memory from extended ecma-string descriptor
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extended string to be freed */ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extended string to be freed */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_string_bytes (sizeof (ecma_extended_string_t)); jmem_stats_free_string_bytes (sizeof (ecma_extended_string_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t)); jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t));
} /* ecma_dealloc_extended_string */ } /* ecma_dealloc_extended_string */
/**
* Allocate memory for external ecma-string descriptor
*
* @return pointer to allocated memory
*/
extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_external_string (void)
{
#if JERRY_MEM_STATS
jmem_stats_allocate_string_bytes (sizeof (ecma_external_string_t));
#endif /* JERRY_MEM_STATS */
return (ecma_external_string_t *) jmem_heap_alloc_block (sizeof (ecma_external_string_t));
} /* ecma_alloc_external_string */
/**
* Dealloc memory from external ecma-string descriptor
*/
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< external string to be freed */
{
#if JERRY_MEM_STATS
jmem_stats_free_string_bytes (sizeof (ecma_external_string_t));
#endif /* JERRY_MEM_STATS */
jmem_heap_free_block (ext_string_p, sizeof (ecma_external_string_t));
} /* ecma_dealloc_external_string */
/** /**
* Allocate memory for an string with character data * Allocate memory for an string with character data
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_string_buffer (size_t size) /**< size of string */ ecma_alloc_string_buffer (size_t size) /**< size of string */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_allocate_string_bytes (size); jmem_stats_allocate_string_bytes (size);
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
return jmem_heap_alloc_block (size); return jmem_heap_alloc_block (size);
} /* ecma_alloc_string_buffer */ } /* ecma_alloc_string_buffer */
@@ -197,13 +227,13 @@ ecma_alloc_string_buffer (size_t size) /**< size of string */
/** /**
* Dealloc memory of a string with character data * Dealloc memory of a string with character data
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
size_t size) /**< size of string */ size_t size) /**< size of string */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_string_bytes (size); jmem_stats_free_string_bytes (size);
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_heap_free_block (string_p, size); jmem_heap_free_block (string_p, size);
} /* ecma_dealloc_string_buffer */ } /* ecma_dealloc_string_buffer */
@@ -213,12 +243,12 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_property_pair_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_property_pair (void) ecma_alloc_property_pair (void)
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_allocate_property_bytes (sizeof (ecma_property_pair_t)); jmem_stats_allocate_property_bytes (sizeof (ecma_property_pair_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
return jmem_heap_alloc_block (sizeof (ecma_property_pair_t)); return jmem_heap_alloc_block (sizeof (ecma_property_pair_t));
} /* ecma_alloc_property_pair */ } /* ecma_alloc_property_pair */
@@ -226,12 +256,12 @@ ecma_alloc_property_pair (void)
/** /**
* Dealloc memory of an ecma-property * Dealloc memory of an ecma-property
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_dealloc_property_pair (ecma_property_pair_t *property_pair_p) /**< property pair to be freed */ ecma_dealloc_property_pair (ecma_property_pair_t *property_pair_p) /**< property pair to be freed */
{ {
#if ENABLED (JERRY_MEM_STATS) #if JERRY_MEM_STATS
jmem_stats_free_property_bytes (sizeof (ecma_property_pair_t)); jmem_stats_free_property_bytes (sizeof (ecma_property_pair_t));
#endif /* ENABLED (JERRY_MEM_STATS) */ #endif /* JERRY_MEM_STATS */
jmem_heap_free_block (property_pair_p, sizeof (ecma_property_pair_t)); jmem_heap_free_block (property_pair_p, sizeof (ecma_property_pair_t));
} /* ecma_dealloc_property_pair */ } /* ecma_dealloc_property_pair */
+12
View File
@@ -85,6 +85,18 @@ ecma_extended_string_t *ecma_alloc_extended_string (void);
*/ */
void ecma_dealloc_extended_string (ecma_extended_string_t *string_p); void ecma_dealloc_extended_string (ecma_extended_string_t *string_p);
/**
* Allocate memory for external ecma-string descriptor
*
* @return pointer to allocated memory
*/
ecma_external_string_t *ecma_alloc_external_string (void);
/**
* Dealloc memory from external ecma-string descriptor
*/
void ecma_dealloc_external_string (ecma_external_string_t *string_p);
/** /**
* Allocate memory for string with character data * Allocate memory for string with character data
* *
@@ -0,0 +1,759 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* This file is automatically generated by the gen-strings.py script
* from ecma-error-messages.ini. Do not edit! */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_GROUP, "Invalid group")
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ESCAPE, "Invalid escape")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INVALID_LENGTH, "Invalid length")
#endif /* JERRY_BUILTIN_ATOMICS \
|| JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INVALID_OFFSET, "Invalid offset")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_EXPECTED, "Object expected")
#if JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT, "Invalid argument")
#endif /* JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ENCODING, "Invalid encoding")
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_NOTHING_TO_REPEAT, "Nothing to repeat")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_AN_OBJECT, "Expected an object")
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CAPABILITY, "Invalid capability")
#if JERRY_BUILTIN_STRING
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CODE_POINT, "Invalid code point")
#endif /* JERRY_BUILTIN_STRING */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_QUANTIFIER, "Invalid quantifier")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_NO_SOURCE_ARGUMENT, "No source argument")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_UNTERMINATED_GROUP, "Unterminated group")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_FUNCTION, "Expected a function")
#if JERRY_BUILTIN_JSON
ECMA_ERROR_DEF (ECMA_ERR_INVALID_JSON_FORMAT, "Invalid JSON format")
#endif /* JERRY_BUILTIN_JSON */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_STRING, "Invalid UTF8 string")
#if JERRY_BUILTIN_STRING
ECMA_ERROR_DEF (ECMA_ERR_INVALID_COUNT_VALUE, "Invalid count value")
#endif /* JERRY_BUILTIN_STRING */
#if !(JERRY_BUILTIN_REALMS)
ECMA_ERROR_DEF (ECMA_ERR_REALMS_ARE_DISABLED, "Realms are disabled")
#endif /* !(JERRY_BUILTIN_REALMS) */
ECMA_ERROR_DEF (ECMA_ERR_UNDEFINED_REFERENCE, "Undefined reference")
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARRAY_LENGTH, "Invalid Array length")
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_REGEXP_FLAGS, "Invalid RegExp flags")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_JSON
ECMA_ERROR_DEF (ECMA_ERR_JSON_STRINGIFY_ERROR, "JSON stringify error")
#endif /* JERRY_BUILTIN_JSON */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_STACK_LIMIT_EXCEEDED, "Stack limit exceeded")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_WEAKREF
ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_OBJECT, "Target is not Object")
#endif /* JERRY_BUILTIN_WEAKREF */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_VALUE_EXCPECTED, "BigInt value expected")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_BINDING_CANNOT_SET, "Binding cannot be set")
#if JERRY_BUILTIN_STRING
ECMA_ERROR_DEF (ECMA_ERR_INVALID_STRING_, "Invalid string length")
#endif /* JERRY_BUILTIN_STRING */
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_KEY_MUST_BE_AN_OBJECT, "Key must be an object")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_MISSING_ARRAY_ELEMENT, "Missing Array element")
#endif /* JERRY_BUILTIN_ARRAY */
#if JERRY_BUILTIN_WEAKREF
ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_WEAKREF, "Target is not weakRef")
#endif /* JERRY_BUILTIN_WEAKREF */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE, "Target not extensible")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_ANNEXB
ECMA_ERROR_DEF (ECMA_ERR_GETTER_IS_NOT_CALLABLE, "Getter is not callable")
#endif /* JERRY_BUILTIN_ANNEXB */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_HANDLER_CANNOT_BE_NULL, "Handler cannot be null")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_CHARACTER, "Invalid UTF8 character")
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_CODEPOINT, "Invalid UTF8 codepoint")
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CONTAINER_TYPE, "Invalid container type")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INVALID_RANGE_OF_INDEX, "Invalid range of index")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if !(JERRY_BUILTIN_PROXY)
ECMA_ERROR_DEF (ECMA_ERR_PROXY_IS_NOT_SUPPORTED, "Proxy is not supported")
#endif /* !(JERRY_BUILTIN_PROXY) */
#if !(JERRY_BUILTIN_REALMS)
ECMA_ERROR_DEF (ECMA_ERR_REALM_IS_NOT_AVAILABLE, "Realm is not available")
#endif /* !(JERRY_BUILTIN_REALMS) */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_ZERO_DIVISION, "BigInt division by zero")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_AN_ARRAYBUFFER, "Expected an ArrayBuffer")
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CHARACTER_CLASS, "Invalid character class")
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ESCAPE_SEQUENCE, "Invalid escape sequence")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_SNAPSHOT_EXEC
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SNAPSHOT_FORMAT, "Invalid snapshot format")
#endif /* JERRY_SNAPSHOT_EXEC */
#if JERRY_BUILTIN_JSON
ECMA_ERROR_DEF (ECMA_ERR_JSON_STRING_PARSE_ERROR, "JSON string parse error")
#endif /* JERRY_BUILTIN_JSON */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_LONE_QUANTIFIER_BRACKET, "Lone quantifier bracket")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_CANNOT_BE_FROZEN, "Object cannot be frozen")
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_CANNOT_BE_SEALED, "Object cannot be sealed")
#endif /* JERRY_BUILTIN_PROXY */
#if !(JERRY_BUILTIN_REGEXP)
ECMA_ERROR_DEF (ECMA_ERR_REGEXP_IS_NOT_SUPPORTED, "RegExp is not supported")
#endif /* !(JERRY_BUILTIN_REGEXP) */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_UNMATCHED_CLOSE_BRACKET, "Unmatched close bracket")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_NOT_MODULE, "Argument is not a module")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_SET_PROTOTYPE, "Cannot set [[Prototype]]")
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_INVALID_NEW_ARRAY_LENGTH, "Invalid new Array length")
#endif /* JERRY_BUILTIN_ARRAY */
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_IS_NOT_CALLABLE, "Iterator is not callable")
#if !(JERRY_BUILTIN_JSON)
ECMA_ERROR_DEF (ECMA_ERR_JSON_NOT_SUPPORTED, "JSON support is disabled")
#endif /* !(JERRY_BUILTIN_JSON) */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_MODULE_IS_IN_ERROR_STATE, "Module is in error state")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_REJECT_MUST_BE_UNDEFINED, "Reject must be undefined")
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_REQUEST_IS_NOT_AVAILABLE, "Request is not available")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT, "Argument is not an object")
#if JERRY_BUILTIN_ATOMICS
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_SUPPORTED, "Argument is not supported")
#endif /* JERRY_BUILTIN_ATOMICS */
#if JERRY_BUILTIN_STRING
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CODE_POINT_ERROR, "Error: Invalid code point")
#endif /* JERRY_BUILTIN_STRING */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INVALID_TYPEDARRAY_LENGTH, "Invalid TypedArray length")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_HEXADECIMAL_VALUE, "Invalid hexadecimal value")
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT, "Iterator is not an object")
ECMA_ERROR_DEF (ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED, "Resolve must be undefined")
#if JERRY_SNAPSHOT_SAVE
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_BUFFER_SMALL, "Snapshot buffer too small")
#endif /* JERRY_SNAPSHOT_SAVE */
#if JERRY_BUILTIN_JSON
ECMA_ERROR_DEF (ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL, "The structure is cyclical")
#endif /* JERRY_BUILTIN_JSON */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_UNEXPECTED_END_OF_PATTERN, "Unexpected end of pattern")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_SNAPSHOT_SAVE
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_UNSUPPORTED_COMPILED_CODE, "Unsupported compiled code")
#endif /* JERRY_SNAPSHOT_SAVE */
#if !(JERRY_BUILTIN_BIGINT)
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_NOT_SUPPORTED, "BigInt support is disabled")
#endif /* !(JERRY_BUILTIN_BIGINT) */
#if JERRY_BUILTIN_DATAVIEW
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT, "Expected a DataView object")
#endif /* JERRY_BUILTIN_DATAVIEW */
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT, "Expected a function object")
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH, "Invalid ArrayBuffer length")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if !(JERRY_MODULE_SYSTEM)
ECMA_ERROR_DEF (ECMA_ERR_MODULE_NOT_SUPPORTED, "Module support is disabled")
#endif /* !(JERRY_MODULE_SYSTEM) */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY, "Object is not a TypedArray")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT, "Receiver must be an object")
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_JSON
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_SERIALIZED, "BigInt cannot be serialized")
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_JSON */
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT, "Container is not an object.")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE, "Invalid hex escape sequence")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR, "Invalid species constructor")
ECMA_ERROR_DEF (ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH, "Proxy trap returned falsish")
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_MIN_GREATER_THAN_MAX, "Quantifier error: min > max")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR, "Symbol is not a constructor")
#if JERRY_BUILTIN_REFLECT
ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR, "Target is not a constructor")
#endif /* JERRY_BUILTIN_REFLECT */
ECMA_ERROR_DEF (ECMA_ERR_ACCESSOR_WRITABLE, "Accessors cannot be writable")
#if !(JERRY_BUILTIN_DATAVIEW)
ECMA_ERROR_DEF (ECMA_ERR_DATA_VIEW_NOT_SUPPORTED, "DataView support is disabled")
#endif /* !(JERRY_BUILTIN_DATAVIEW) */
#if JERRY_BUILTIN_DATE
ECMA_ERROR_DEF (ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER, "Date must be a finite number")
#endif /* JERRY_BUILTIN_DATE */
ECMA_ERROR_DEF (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED, "Local variable is redeclared")
ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_BINARY_OPERATION, "Unsupported binary operation")
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_UNTERMINATED_CHARACTER_CLASS, "Unterminated character class")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_ARRAYBUFFER_IS_DETACHED, "ArrayBuffer has been detached")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT, "Constructor must be an object")
#if !(JERRY_BUILTIN_CONTAINER)
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_NOT_SUPPORTED, "Container support is disabled")
#endif /* !(JERRY_BUILTIN_CONTAINER) */
#if JERRY_BUILTIN_REALMS
ECMA_ERROR_DEF (ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM, "First argument is not a realm")
#endif /* JERRY_BUILTIN_REALMS */
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES, "Incompatible TypedArray types")
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY, "Incorrect type for TypedArray")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX, "Invalid or out-of-range index")
#if JERRY_SNAPSHOT_SAVE
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE, "Maximum snapshot size reached")
#endif /* JERRY_SNAPSHOT_SAVE */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED, "Module cannot be instantiated")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR, "Species must be a constructor")
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY, "Argument is not a Proxy object")
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER, "Argument is not an ArrayBuffer")
#endif /* JERRY_BUILTIN_ATOMICS \
|| JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW, "Constructor Map requires 'new'")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW, "Constructor Set requires 'new'")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE, "Module must be in linked state")
ECMA_ERROR_DEF (ECMA_ERR_UNKNOWN_EXPORT, "Native module export not found")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM, "Passed argument is not a realm")
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_METHOD_IS_NOT_WRITABLE, "Private method is not writable")
#if JERRY_BUILTIN_BIGINT || JERRY_BUILTIN_NUMBER
ECMA_ERROR_DEF (ECMA_ERR_RADIX_IS_OUT_OF_RANGE, "Radix must be between 2 and 36")
#endif /* JERRY_BUILTIN_BIGINT \
|| JERRY_BUILTIN_NUMBER */
#if !(JERRY_SNAPSHOT_EXEC)
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_EXEC_DISABLED, "Snapshot execution is disabled")
#endif /* !(JERRY_SNAPSHOT_EXEC) */
#if !(JERRY_BUILTIN_TYPEDARRAY)
ECMA_ERROR_DEF (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED, "TypedArray support is disabled")
#endif /* !(JERRY_BUILTIN_TYPEDARRAY) */
ECMA_ERROR_DEF (ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING, "Unicode surrogate pair missing")
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE, "Invalid control escape sequence")
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE, "Invalid unicode escape sequence")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE, "Iterator 'next' is not callable")
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT, "Iterator value is not an object")
ECMA_ERROR_DEF (ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE, "Resolve method must be callable")
#if !(JERRY_SNAPSHOT_SAVE)
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_SAVE_DISABLED, "Snapshot generation is disabled")
#endif /* !(JERRY_SNAPSHOT_SAVE) */
#if !(JERRY_PARSER)
ECMA_ERROR_DEF (ECMA_ERR_PARSER_NOT_SUPPORTED, "Source code parsing is disabled")
#endif /* !(JERRY_PARSER) */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT, "Trap must return with an object")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION, "Unsupported container operation")
#endif /* JERRY_BUILTIN_CONTAINER */
ECMA_ERROR_DEF (ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE, "method 'return' is not callable")
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE, "Argument 'this' is not a Promise")
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT, "Argument 'this' is not an object")
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL, "Argument 'this' must be a Symbol")
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_CALLBACK_RESULT_NOT_MODULE, "Callback result must be a module")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW, "Class constructor requires 'new'")
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE, "Compare function is not callable")
#endif /* JERRY_BUILTIN_ARRAY */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW, "Constructor Proxy requires 'new'")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY, "Expected a configurable property")
ECMA_ERROR_DEF (ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE, "First parameter must be callable")
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE, "Function add/set is not callable")
#endif /* JERRY_BUILTIN_CONTAINER */
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT, "Iterator result is not an object")
#if (JERRY_STACK_LIMIT != 0)
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED, "Maximum call stack size exceeded")
#endif /* (JERRY_STACK_LIMIT != 0) */
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED, "Maximum string length is reached")
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE, "Module must be in unlinked state")
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_SNAPSHOT_EXEC
ECMA_ERROR_DEF (ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED, "Static snapshots are not enabled")
#endif /* JERRY_SNAPSHOT_EXEC */
#if JERRY_BUILTIN_WEAKREF
ECMA_ERROR_DEF (ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT, "WeakRef target must be an object")
#endif /* JERRY_BUILTIN_WEAKREF */
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION, "Argument 'this' is not a function")
#if JERRY_BUILTIN_ARRAY || JERRY_BUILTIN_CONTAINER || JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE, "Callback function is not callable")
#endif /* JERRY_BUILTIN_ARRAY \
|| JERRY_BUILTIN_CONTAINER \
|| JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED, "Initial value cannot be undefined")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH, "Invalid Shared ArrayBuffer length")
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
ECMA_ERROR_DEF (ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL, "Invalid type for constructor call")
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE, "Iterator 'throw' is not available")
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE, "Namespace object is not available")
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR, "Proxy target is not a constructor")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_REALMS
ECMA_ERROR_DEF (ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT, "Second argument must be an object")
#endif /* JERRY_BUILTIN_REALMS */
#if JERRY_BUILTIN_DATAVIEW
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT, "Argument 'buffer' is not an object")
#endif /* JERRY_BUILTIN_DATAVIEW */
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR, "Argument 'this' is not an iterator")
ECMA_ERROR_DEF (ECMA_ERR_VALUE_MSG, "Argument cannot be marked as error")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW, "Constructor Promise requires 'new'")
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW, "Constructor WeakMap requires 'new'")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW, "Constructor WeakSet requires 'new'")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_DEBUGGER
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL, "Invalid scope chain index for eval")
#endif /* JERRY_DEBUGGER */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED, "Maximum TypedArray size is reached")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL, "The given argument is not a Symbol")
ECMA_ERROR_DEF (ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE, "'reject' parameter must be callable")
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY, "Argument 'this' is not a TypedArray")
#endif /* JERRY_BUILTIN_ATOMICS \
|| JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_SNAPSHOT_SAVE
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS, "Cannot allocate memory for literals")
#endif /* JERRY_SNAPSHOT_SAVE */
ECMA_ERROR_DEF (ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD, "Cannot invoke nullable super method")
#if JERRY_BUILTIN_DATAVIEW
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW, "Constructor DataView requires 'new'")
#endif /* JERRY_BUILTIN_DATAVIEW */
#if JERRY_BUILTIN_WEAKREF
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW, "Constructor WeakRef requires 'new'.")
#endif /* JERRY_BUILTIN_WEAKREF */
ECMA_ERROR_DEF (ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR, "Super binding must be a constructor")
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT, "Value cannot be converted to BigInt")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE, "'resolve' parameter must be callable")
#if JERRY_BUILTIN_DATE
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT, "Argument 'this' is not a Date object")
#endif /* JERRY_BUILTIN_DATE */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR, "Argument 'this' is not a constructor")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR, "BigInt function is not a constructor")
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY, "Constructed object is not TypedArray")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW, "Constructor Int8Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT, "Container is not a container object.")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_DATE
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE, "Invalid argument type in toPrimitive")
#endif /* JERRY_BUILTIN_DATE */
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_METHODS_INVOKE_WITH_NEW, "Methods cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES, "Module exports must be string values")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL, "Prototype is neither object nor null")
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE, "The 'mapfn' argument is not callable")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE, "The two descriptors are incompatible")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_WRONG_ARGS_MSG, "This type of argument is not allowed")
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_NEEDED, "Value is not a Container or Iterator")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP, "Argument 'this' is not a valid RegExp")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ARRAY_BUFFER_DETACHED, "ArrayBuffer has already been detached")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR, "Built-in routines have no constructor")
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW, "Constructor Int16Array requires 'new'")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW, "Constructor Int32Array requires 'new'")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW, "Constructor Uint8Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_SNAPSHOT_EXEC
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM, "Function index is higher than maximum")
#endif /* JERRY_SNAPSHOT_EXEC */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS, "Range out of order in character class")
#endif /* JERRY_BUILTIN_REGEXP */
ECMA_ERROR_DEF (ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID, "Result of [[DefaultValue]] is invalid")
ECMA_ERROR_DEF (ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT, "Right value of 'in' must be an object")
#if !(JERRY_BUILTIN_SHAREDARRAYBUFFER)
ECMA_ERROR_DEF (ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED, "SharedArrayBuffer support is disabled")
#endif /* !(JERRY_BUILTIN_SHAREDARRAYBUFFER) */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL, "Trap returned neither object nor null")
ECMA_ERROR_DEF (ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES, "Trap returned with duplicated entries")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS, "Unary plus is not allowed for BigInts")
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP, "Argument 'this' is not a RegExp object")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_ARRAY_BUFFER, "Cannot allocate memory for ArrayBuffer")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED, "Constant bindings cannot be reassigned")
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW, "Constructor ArrayBuffer requires 'new'")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW, "Constructor Uint16Array requires 'new'")
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW, "Constructor Uint32Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION, "Generator is currently under execution")
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT, "Iterator 'return' result is not object")
ECMA_ERROR_DEF (ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP, "Search string can't be of type: RegExp")
ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT, "Value received by yield* is not object")
#if JERRY_BUILTIN_BOOLEAN
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT, "Argument 'this' is not a Boolean object")
#endif /* JERRY_BUILTIN_BOOLEAN */
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE, "Cannot declare same private field twice")
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW, "Constructor Float32Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW, "Constructor Float64Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64 */
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR, "Function.prototype is not a constructor")
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE, "Imported binding shadows local variable")
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID, "Prototype from revoked Proxy is invalid")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_REGEXP && JERRY_BUILTIN_STRING
ECMA_ERROR_DEF (ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG, "RegExp argument should have global flag")
#endif /* JERRY_BUILTIN_REGEXP && JERRY_BUILTIN_STRING */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED, "Trap is neither an object nor undefined")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_PROMISE_RESOLVE_ITSELF, "A promise cannot be resolved with itself")
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW, "Constructor BigInt64Array requires 'new'")
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS, "Module exports must be valid identifiers")
#endif /* JERRY_MODULE_SYSTEM */
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT, "Argument 'this' is not a generator object")
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT, "Argument cannot be converted to an object")
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_VALUE, "Cannot allocate memory for a BigInt value")
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_BIGINT_TO_NUMBER, "Cannot convert a BigInt value to a number")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER, "Cannot convert a Symbol value to a number")
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_STRING, "Cannot convert a Symbol value to a string")
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW, "Constructor BigUInt64Array requires 'new'")
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_NUMBER
ECMA_ERROR_DEF (ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE, "Fraction digits must be between 0 and 100")
#endif /* JERRY_BUILTIN_NUMBER */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT, "Return value is not an ArrayBuffer object")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE, "Super constructor may only be called once")
ECMA_ERROR_DEF (ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED, "Binding does not exist or is uninitialised")
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT, "Cannot convert undefined or null to object")
#endif /* JERRY_BUILTIN_ARRAY */
#if JERRY_BUILTIN_NUMBER
ECMA_ERROR_DEF (ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE, "Precision digits must be between 1 and 100")
#endif /* JERRY_BUILTIN_NUMBER */
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_GETTER, "Private field was defined without a getter")
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_SETTER, "Private field was defined without a setter")
ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING, "Property name is neither Symbol nor string")
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE, "String cannot be converted to BigInt value")
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_BUILTIN_CONTAINER
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_TYPE_CALL, "Operator called on incorrect container type")
#endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE, "Reduce of empty Array with no initial value")
#endif /* JERRY_BUILTIN_ARRAY */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP_OBJECT, "Argument 'this' is not a valid RegExp object")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT, "Argument 'this' is not an ArrayBuffer object")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW, "Arrow functions cannot be invoked with 'new'")
ECMA_ERROR_DEF (ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW, "Async functions cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_SET_EXTENSIBLE_PROPERTY, "Cannot set [[Extensible]] property of object")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW, "Constructor SharedArrayBuffer requires 'new'")
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW, "Constructor Uint8ClampedArray requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS, "Negative exponent is not allowed for BigInts")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED, "Promise.all remaining elements limit reached")
ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT, "Value received by for-async-of is not object")
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT, "Infinity or NaN cannot be converted to BigInt")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE, "Operator delete returned false in strict mode")
ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT, "Property 'prototype' is not an object or null")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION, "Proxy handler is null for 'isArray' operation")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_SNAPSHOT_SAVE
ECMA_ERROR_DEF (ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED, "Regular expression literals are not supported")
#endif /* JERRY_SNAPSHOT_SAVE */
ECMA_ERROR_DEF (ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT, "Right value of 'instanceof' must be an object")
#if JERRY_SNAPSHOT_EXEC
ECMA_ERROR_DEF (ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY, "Static snapshots cannot be copied into memory")
#endif /* JERRY_SNAPSHOT_EXEC */
#if JERRY_SNAPSHOT_SAVE
ECMA_ERROR_DEF (ECMA_ERR_TAGGED_TEMPLATE_LITERALS, "Unsupported feature: tagged template literals")
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED, "Unsupported generate snapshot flags specified")
#endif /* JERRY_SNAPSHOT_SAVE */
#if JERRY_SNAPSHOT_EXEC
ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED, "Unsupported snapshot exec flags are specified")
#endif /* JERRY_SNAPSHOT_EXEC */
ECMA_ERROR_DEF (ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR, "Value for class heritage is not a constructor")
ECMA_ERROR_DEF (ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY,
"Too many arguments declared for Function.apply")
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW, "Accessor functions cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE, "Cannot link to a module which is in error state")
#endif /* JERRY_MODULE_SYSTEM */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT,
"Only integer numbers can be converted to BigInt")
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED, "TypedArray intrinstic cannot be directly called")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS,
"Unsigned right shift is not allowed for BigInts")
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR, "Argument 'this' is not an async generator object")
ECMA_ERROR_DEF (ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR, "Class extends value is not a constructor or null")
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW, "Generator functions cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_BUILTIN_REGEXP
ECMA_ERROR_DEF (ECMA_ERR_RETURN_VALUE_OF_EXEC_MUST_BE_AN_OBJECT_OR_NULL,
"Return value of 'exec' must be an object or null")
#endif /* JERRY_BUILTIN_REGEXP */
#if JERRY_BUILTIN_DATAVIEW
ECMA_ERROR_DEF (ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER,
"Start offset is outside the bounds of the buffer")
#endif /* JERRY_BUILTIN_DATAVIEW */
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER, "Argument 'this' is not a SharedArrayBuffer object")
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
ECMA_ERROR_DEF (ECMA_ERR_CLASS_CONSTRUCTOR_NEW, "Class constructor cannot be invoked without 'new'")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP, "Incorrect value is returned by a Proxy 'get' trap")
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP, "Incorrect value is returned by a Proxy 'set' trap")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE, "Prototype property of a class is non-configurable")
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT, "Pushing element over 2**53-1 length is disallowed")
#endif /* JERRY_BUILTIN_ARRAY */
ECMA_ERROR_DEF (ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED,
"The requested property update cannot be performed")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS,
"Trap result did not include all configurable keys")
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE, "Trap returned truish for target is not extensible")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_NUMBER
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER, "Argument 'this' is not a number or a Number object")
#endif /* JERRY_BUILTIN_NUMBER */
#if JERRY_BUILTIN_STRING
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT, "Argument 'this' is not a string or a String object")
#endif /* JERRY_BUILTIN_STRING */
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT,
"Argument 'this' is not an SharedArrayBuffer object")
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW, "Async arrow functions cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_BUILTIN_ARRAY
ECMA_ERROR_DEF (ECMA_ERR_UNSHIFT_TOO_HIGH, "Unshift elements over 2**53-1 length is disallowed")
#endif /* JERRY_BUILTIN_ARRAY */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS,
"Trap result did not include all non-configurable keys")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW,
"Async generator functions cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_BUILTIN_REFLECT
ECMA_ERROR_DEF (ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT,
"Reflect.construct expects an object as second argument")
#endif /* JERRY_BUILTIN_REFLECT */
#if JERRY_ERROR_MESSAGES
ECMA_ERROR_DEF (ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW,
"Script (global) functions cannot be invoked with 'new'")
#endif /* JERRY_ERROR_MESSAGES */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CREATE_PROXY, "Cannot create Proxy with a non-object target or handler")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED,
"Derived constructors may only return object or undefined")
#if JERRY_SNAPSHOT_EXEC
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES,
"Invalid snapshot version or unsupported features present")
#endif /* JERRY_SNAPSHOT_EXEC */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT,
"Constructed TypedArray is smaller than filter call result")
ECMA_ERROR_DEF (ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL,
"Derived ArrayBuffer constructor created a too small buffer")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY,
"Trap result does not reflect extensibility of Proxy target")
ECMA_ERROR_DEF (ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET,
"Trap returned extra keys for a non-extensible Proxy target")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR,
"ArrayBuffer subclass returned this from species constructor")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_DATAVIEW
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER,
"Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer")
#endif /* JERRY_BUILTIN_DATAVIEW */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY,
"Trap result does not reflect inextensibility of Proxy target")
#endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION,
"TypedArray intrinstic cannot be called by a 'new' expression")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE,
"TypedArray returned by [[ContentType]] does not match source")
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_STRING, "Cannot allocate memory for a string representation of a BigInt value")
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED,
"Target object is non-extensible and trap returned different prototype")
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET,
"Trap returned truish for adding property to the non-extensible target")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_READ_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT,
"Cannot read private member to an object whose class did not declare it")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE,
"Given property is a non-configurable data property on the proxy target")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_WRITE_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT,
"Cannot write private member to an object whose class did not declare it")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE,
"Trap returned falsish for property but the proxy target is not extensible")
ECMA_ERROR_DEF (ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER,
"Property of a Proxy is non-configurable and does not have a getter function")
ECMA_ERROR_DEF (ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER,
"The property of a Proxy target is a non configurable accessor without a setter")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_LET_CONST_NOT_INITIALIZED,
"Variables declared by let/const must be initialized before reading their value")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE,
"Trap returned truish for property which is non-configurable in the proxy target")
ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE,
"Proxy target is non-extensible, but the trap did not return its actual prototype")
ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE,
"Trap returned falsish for property which exists in the proxy target as non-configurable")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS,
"Must call super constructor in derived class before accessing 'this' or returning from it")
#if JERRY_BUILTIN_PROXY
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY,
"Trap returned truish for defining non-configurable property which is non-existent in the target")
ECMA_ERROR_DEF (
ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP,
"Trap returned truish for adding property that is incompatible with the existing property in the target")
#endif /* JERRY_BUILTIN_PROXY */
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS,
"'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the "
"arguments objects for calls to them")
@@ -0,0 +1,330 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[ECMA_ERROR_MESSAGES]
ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS = "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"
ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE = "'reject' parameter must be callable"
ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE = "'resolve' parameter must be callable"
ECMA_ERR_PROMISE_RESOLVE_ITSELF = "A promise cannot be resolved with itself"
ECMA_ERR_ACCESSOR_WRITABLE = "Accessors cannot be writable"
ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER = "Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer"
ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT = "Argument 'buffer' is not an object"
ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT = "Argument 'this' is not an ArrayBuffer object"
ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT = "Argument 'this' is not a Boolean object"
ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT = "Argument 'this' is not a Date object"
ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE = "Argument 'this' is not a Promise"
ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER = "Argument 'this' is not a SharedArrayBuffer object"
ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY = "Argument 'this' is not a TypedArray"
ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR = "Argument 'this' is not a constructor"
ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION = "Argument 'this' is not a function"
ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT = "Argument 'this' is not a generator object"
ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER = "Argument 'this' is not a number or a Number object"
ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT = "Argument 'this' is not a string or a String object"
ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP = "Argument 'this' is not a valid RegExp"
ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP_OBJECT = "Argument 'this' is not a valid RegExp object"
ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT = "Argument 'this' is not an SharedArrayBuffer object"
ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR = "Argument 'this' is not an async generator object"
ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR = "Argument 'this' is not an iterator"
ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT = "Argument 'this' is not an object"
ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL = "Argument 'this' must be a Symbol"
ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT = "Argument cannot be converted to an object"
ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER = "Argument is not an ArrayBuffer"
ECMA_ERR_ARGUMENT_NOT_SUPPORTED = "Argument is not supported"
ECMA_ERR_ARRAY_BUFFER_DETACHED = "ArrayBuffer has already been detached"
ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR = "ArrayBuffer subclass returned this from species constructor"
ECMA_ERR_BIGINT_SERIALIZED = "BigInt cannot be serialized"
ECMA_ERR_BIGINT_ZERO_DIVISION = "BigInt division by zero"
ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR = "BigInt function is not a constructor"
ECMA_ERR_BIGINT_VALUE_EXCPECTED = "BigInt value expected"
ECMA_ERR_BINDING_CANNOT_SET = "Binding cannot be set"
ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED = "Binding does not exist or is uninitialised"
ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR = "Built-in routines have no constructor"
ECMA_ERR_CALLBACK_RESULT_NOT_MODULE = "Callback result must be a module"
ECMA_ERR_ALLOCATE_ARRAY_BUFFER = "Cannot allocate memory for ArrayBuffer"
ECMA_ERR_ALLOCATE_BIGINT_VALUE = "Cannot allocate memory for a BigInt value"
ECMA_ERR_ALLOCATE_BIGINT_STRING = "Cannot allocate memory for a string representation of a BigInt value"
ECMA_ERR_CONVERT_BIGINT_TO_NUMBER = "Cannot convert a BigInt value to a number"
ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER = "Cannot convert a Symbol value to a number"
ECMA_ERR_CONVERT_SYMBOL_TO_STRING = "Cannot convert a Symbol value to a string"
ECMA_ERR_CANNOT_CREATE_PROXY = "Cannot create Proxy with a non-object target or handler"
ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD = "Cannot invoke nullable super method"
ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE = "Cannot link to a module which is in error state"
ECMA_ERR_SET_EXTENSIBLE_PROPERTY = "Cannot set [[Extensible]] property of object"
ECMA_ERR_SET_PROTOTYPE = "Cannot set [[Prototype]]"
ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW = "Class constructor requires 'new'"
ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR = "Class extends value is not a constructor or null"
ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE = "Compare function is not callable"
ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED = "Constant bindings cannot be reassigned"
ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT = "Constructed TypedArray is smaller than filter call result"
ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY = "Constructed object is not TypedArray"
ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW = "Constructor ArrayBuffer requires 'new'"
ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW = "Constructor BigInt64Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW = "Constructor BigUInt64Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW = "Constructor DataView requires 'new'"
ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW = "Constructor Float32Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW = "Constructor Float64Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW = "Constructor Int16Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW = "Constructor Int32Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW = "Constructor Int8Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW = "Constructor Map requires 'new'"
ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW = "Constructor Promise requires 'new'"
ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW = "Constructor Proxy requires 'new'"
ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW = "Constructor Set requires 'new'"
ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW = "Constructor SharedArrayBuffer requires 'new'"
ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW = "Constructor Uint16Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW = "Constructor Uint32Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW = "Constructor Uint8Array requires 'new'"
ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW = "Constructor Uint8ClampedArray requires 'new'"
ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW = "Constructor WeakMap requires 'new'"
ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW = "Constructor WeakRef requires 'new'."
ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW = "Constructor WeakSet requires 'new'"
ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT = "Constructor must be an object"
ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT = "Container is not a container object."
ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT = "Container is not an object."
ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER = "Date must be a finite number"
ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL = "Derived ArrayBuffer constructor created a too small buffer"
ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED = "Derived constructors may only return object or undefined"
ECMA_ERR_INVALID_CODE_POINT_ERROR = "Error: Invalid code point"
ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT = "Expected a DataView object"
ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY = "Expected a configurable property"
ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT = "Expected a function object"
ECMA_ERR_EXPECTED_AN_ARRAYBUFFER = "Expected an ArrayBuffer"
ECMA_ERR_EXPECTED_AN_OBJECT = "Expected an object"
ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM = "First argument is not a realm"
ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE = "First parameter must be callable"
ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE = "Fraction digits must be between 0 and 100"
ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE = "Function add/set is not callable"
ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM = "Function index is higher than maximum"
ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR = "Function.prototype is not a constructor"
ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION = "Generator is currently under execution"
ECMA_ERR_GETTER_IS_NOT_CALLABLE = "Getter is not callable"
ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE = "Given property is a non-configurable data property on the proxy target"
ECMA_ERR_HANDLER_CANNOT_BE_NULL = "Handler cannot be null"
ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE = "Imported binding shadows local variable"
ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES = "Incompatible TypedArray types"
ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY = "Incorrect type for TypedArray"
ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP = "Incorrect value is returned by a Proxy 'get' trap"
ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP = "Incorrect value is returned by a Proxy 'set' trap"
ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT = "Infinity or NaN cannot be converted to BigInt"
ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED = "Initial value cannot be undefined"
ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH = "Invalid ArrayBuffer length"
ECMA_ERR_INVALID_JSON_FORMAT = "Invalid JSON format"
ECMA_ERR_INVALID_REGEXP_FLAGS = "Invalid RegExp flags"
ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH = "Invalid Shared ArrayBuffer length"
ECMA_ERR_INVALID_TYPEDARRAY_LENGTH = "Invalid TypedArray length"
ECMA_ERR_INVALID_UTF8_CHARACTER = "Invalid UTF8 character"
ECMA_ERR_INVALID_UTF8_CODEPOINT = "Invalid UTF8 codepoint"
ECMA_ERR_INVALID_UTF8_STRING = "Invalid UTF8 string"
ECMA_ERR_INVALID_ENCODING = "Invalid encoding"
ECMA_ERR_INVALID_ARGUMENT = "Invalid argument"
ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE = "Invalid argument type in toPrimitive"
ECMA_ERR_INVALID_CAPABILITY = "Invalid capability"
ECMA_ERR_INVALID_CHARACTER_CLASS = "Invalid character class"
ECMA_ERR_INVALID_CODE_POINT = "Invalid code point"
ECMA_ERR_INVALID_CONTAINER_TYPE = "Invalid container type"
ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE = "Invalid control escape sequence"
ECMA_ERR_INVALID_COUNT_VALUE = "Invalid count value"
ECMA_ERR_INVALID_ESCAPE = "Invalid escape"
ECMA_ERR_INVALID_ESCAPE_SEQUENCE = "Invalid escape sequence"
ECMA_ERR_INVALID_GROUP = "Invalid group"
ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE = "Invalid hex escape sequence"
ECMA_ERR_INVALID_HEXADECIMAL_VALUE = "Invalid hexadecimal value"
ECMA_ERR_INVALID_LENGTH = "Invalid length"
ECMA_ERR_INVALID_NEW_ARRAY_LENGTH = "Invalid new Array length"
ECMA_ERR_INVALID_OFFSET = "Invalid offset"
ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX = "Invalid or out-of-range index"
ECMA_ERR_INVALID_QUANTIFIER = "Invalid quantifier"
ECMA_ERR_INVALID_RANGE_OF_INDEX = "Invalid range of index"
ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL = "Invalid scope chain index for eval"
ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR = "Invalid species constructor"
ECMA_ERR_INVALID_STRING_ = "Invalid string length"
ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE = "Invalid unicode escape sequence"
ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE = "Iterator 'next' is not callable"
ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT = "Iterator 'return' result is not object"
ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE = "Iterator 'throw' is not available"
ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT = "Iterator is not an object"
ECMA_ERR_ITERATOR_IS_NOT_CALLABLE = "Iterator is not callable"
ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT = "Iterator result is not an object"
ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT = "Iterator value is not an object"
ECMA_ERR_JSON_STRING_PARSE_ERROR = "JSON string parse error"
ECMA_ERR_JSON_STRINGIFY_ERROR = "JSON stringify error"
ECMA_ERR_KEY_MUST_BE_AN_OBJECT = "Key must be an object"
ECMA_ERR_LONE_QUANTIFIER_BRACKET = "Lone quantifier bracket"
ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED = "Maximum TypedArray size is reached"
ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED = "Maximum string length is reached"
ECMA_ERR_MISSING_ARRAY_ELEMENT = "Missing Array element"
ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED = "Module cannot be instantiated"
ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES = "Module exports must be string values"
ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS = "Module exports must be valid identifiers"
ECMA_ERR_MODULE_IS_IN_ERROR_STATE = "Module is in error state"
ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE = "Module must be in linked state"
ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE = "Module must be in unlinked state"
ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS = "Must call super constructor in derived class before accessing 'this' or returning from it"
ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE = "Namespace object is not available"
ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS = "Negative exponent is not allowed for BigInts"
ECMA_ERR_NO_SOURCE_ARGUMENT = "No source argument"
ECMA_ERR_NOTHING_TO_REPEAT = "Nothing to repeat"
ECMA_ERR_OBJECT_CANNOT_BE_FROZEN = "Object cannot be frozen"
ECMA_ERR_OBJECT_CANNOT_BE_SEALED = "Object cannot be sealed"
ECMA_ERR_OBJECT_EXPECTED = "Object expected"
ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY = "Object is not a TypedArray"
ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT = "Only integer numbers can be converted to BigInt"
ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE = "Operator delete returned false in strict mode"
ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM = "Passed argument is not a realm"
ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE = "Precision digits must be between 1 and 100"
ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED = "Promise.all remaining elements limit reached"
ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT = "Property 'prototype' is not an object or null"
ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING = "Property name is neither Symbol nor string"
ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER = "Property of a Proxy is non-configurable and does not have a getter function"
ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID = "Prototype from revoked Proxy is invalid"
ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL = "Prototype is neither object nor null"
ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION = "Proxy handler is null for 'isArray' operation"
ECMA_ERR_PROXY_IS_NOT_SUPPORTED = "Proxy is not supported"
ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE = "Proxy target is non-extensible, but the trap did not return its actual prototype"
ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH = "Proxy trap returned falsish"
ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT = "Pushing element over 2**53-1 length is disallowed"
ECMA_ERR_MIN_GREATER_THAN_MAX = "Quantifier error: min > max"
ECMA_ERR_RADIX_IS_OUT_OF_RANGE = "Radix must be between 2 and 36"
ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS = "Range out of order in character class"
ECMA_ERR_REALM_IS_NOT_AVAILABLE = "Realm is not available"
ECMA_ERR_REALMS_ARE_DISABLED = "Realms are disabled"
ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE = "Reduce of empty Array with no initial value"
ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT = "Reflect.construct expects an object as second argument"
ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG = "RegExp argument should have global flag"
ECMA_ERR_REGEXP_IS_NOT_SUPPORTED = "RegExp is not supported"
ECMA_ERR_REJECT_MUST_BE_UNDEFINED = "Reject must be undefined"
ECMA_ERR_REQUEST_IS_NOT_AVAILABLE = "Request is not available"
ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE = "Resolve method must be callable"
ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED = "Resolve must be undefined"
ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID = "Result of [[DefaultValue]] is invalid"
ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT = "Return value is not an ArrayBuffer object"
ECMA_ERR_RETURN_VALUE_OF_EXEC_MUST_BE_AN_OBJECT_OR_NULL = "Return value of 'exec' must be an object or null"
ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT = "Right value of 'in' must be an object"
ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT = "Right value of 'instanceof' must be an object"
ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP = "Search string can't be of type: RegExp"
ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT = "Second argument must be an object"
ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR = "Species must be a constructor"
ECMA_ERR_STACK_LIMIT_EXCEEDED = "Stack limit exceeded"
ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER = "Start offset is outside the bounds of the buffer"
ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED = "Static snapshots are not enabled"
ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY = "Static snapshots cannot be copied into memory"
ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE = "String cannot be converted to BigInt value"
ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR = "Super binding must be a constructor"
ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE = "Super constructor may only be called once"
ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR = "Symbol is not a constructor"
ECMA_ERR_TARGET_IS_NOT_OBJECT = "Target is not Object"
ECMA_ERR_TARGET_IS_NOT_WEAKREF = "Target is not weakRef"
ECMA_ERR_TARGET_NOT_EXTENSIBLE = "Target not extensible"
ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED = "Target object is non-extensible and trap returned different prototype"
ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE = "The 'mapfn' argument is not callable"
ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL = "The given argument is not a Symbol"
ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER = "The property of a Proxy target is a non configurable accessor without a setter"
ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED = "The requested property update cannot be performed"
ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL = "The structure is cyclical"
ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE = "The two descriptors are incompatible"
ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY = "Too many arguments declared for Function.apply"
ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED = "Trap is neither an object nor undefined"
ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT = "Trap must return with an object"
ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS = "Trap result did not include all configurable keys"
ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS = "Trap result did not include all non-configurable keys"
ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY = "Trap result does not reflect extensibility of Proxy target"
ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY = "Trap result does not reflect inextensibility of Proxy target"
ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET = "Trap returned extra keys for a non-extensible Proxy target"
ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE = "Trap returned falsish for property but the proxy target is not extensible"
ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE = "Trap returned falsish for property which exists in the proxy target as non-configurable"
ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL = "Trap returned neither object nor null"
ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET = "Trap returned truish for adding property to the non-extensible target"
ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP = "Trap returned truish for adding property that is incompatible with the existing property in the target"
ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY = "Trap returned truish for defining non-configurable property which is non-existent in the target"
ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE = "Trap returned truish for property which is non-configurable in the proxy target"
ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE = "Trap returned truish for target is not extensible"
ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES = "Trap returned with duplicated entries"
ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION = "TypedArray intrinstic cannot be called by a 'new' expression"
ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED = "TypedArray intrinstic cannot be directly called"
ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE = "TypedArray returned by [[ContentType]] does not match source"
ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS = "Unary plus is not allowed for BigInts"
ECMA_ERR_UNDEFINED_REFERENCE = "Undefined reference"
ECMA_ERR_UNEXPECTED_END_OF_PATTERN = "Unexpected end of pattern"
ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING = "Unicode surrogate pair missing"
ECMA_ERR_UNMATCHED_CLOSE_BRACKET = "Unmatched close bracket"
ECMA_ERR_UNSHIFT_TOO_HIGH = "Unshift elements over 2**53-1 length is disallowed"
ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS = "Unsigned right shift is not allowed for BigInts"
ECMA_ERR_UNSUPPORTED_BINARY_OPERATION = "Unsupported binary operation"
ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION = "Unsupported container operation"
ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED = "Unsupported snapshot exec flags are specified"
ECMA_ERR_UNTERMINATED_CHARACTER_CLASS = "Unterminated character class"
ECMA_ERR_UNTERMINATED_GROUP = "Unterminated group"
ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT = "Value cannot be converted to BigInt"
ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR = "Value for class heritage is not a constructor"
ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT = "Value received by for-async-of is not object"
ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT = "Value received by yield* is not object"
ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT = "WeakRef target must be an object"
ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE = "method 'return' is not callable"
ECMA_ERR_VALUE_MSG = "Argument cannot be marked as error"
ECMA_ERR_WRONG_ARGS_MSG = "This type of argument is not allowed"
ECMA_ERR_PARSER_NOT_SUPPORTED = "Source code parsing is disabled"
ECMA_ERR_JSON_NOT_SUPPORTED = "JSON support is disabled"
ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED = "TypedArray support is disabled"
ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED = "SharedArrayBuffer support is disabled"
ECMA_ERR_DATA_VIEW_NOT_SUPPORTED = "DataView support is disabled"
ECMA_ERR_BIGINT_NOT_SUPPORTED = "BigInt support is disabled"
ECMA_ERR_CONTAINER_NOT_SUPPORTED = "Container support is disabled"
ECMA_ERR_NOT_MODULE = "Argument is not a module"
ECMA_ERR_UNKNOWN_EXPORT = "Native module export not found"
ECMA_ERR_MODULE_NOT_SUPPORTED = "Module support is disabled"
ECMA_ERR_CALLBACK_IS_NOT_CALLABLE = "Callback function is not callable"
ECMA_ERR_ARRAYBUFFER_IS_DETACHED = "ArrayBuffer has been detached"
ECMA_ERR_CANNOT_CONVERT_TO_OBJECT = "Cannot convert undefined or null to object"
ECMA_ERR_CLASS_IS_NON_CONFIGURABLE = "Prototype property of a class is non-configurable"
ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT = "Argument is not an object"
ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY = "Argument is not a Proxy object"
ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR = "Target is not a constructor"
ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP = "Argument 'this' is not a RegExp object"
ECMA_ERR_INVALID_ARRAY_LENGTH = "Invalid Array length"
ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED = "Local variable is redeclared"
ECMA_ERR_EXPECTED_A_FUNCTION = "Expected a function"
ECMA_ERR_CLASS_CONSTRUCTOR_NEW = "Class constructor cannot be invoked without 'new'"
ECMA_ERR_LET_CONST_NOT_INITIALIZED = "Variables declared by let/const must be initialized before reading their value"
ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE = "Maximum snapshot size reached"
ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED = "Regular expression literals are not supported"
ECMA_ERR_SNAPSHOT_BUFFER_SMALL = "Snapshot buffer too small"
ECMA_ERR_SNAPSHOT_UNSUPPORTED_COMPILED_CODE = "Unsupported compiled code"
ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED = "Unsupported generate snapshot flags specified"
ECMA_ERR_SNAPSHOT_SAVE_DISABLED = "Snapshot generation is disabled"
ECMA_ERR_SNAPSHOT_EXEC_DISABLED = "Snapshot execution is disabled"
ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS = "Cannot allocate memory for literals"
ECMA_ERR_TAGGED_TEMPLATE_LITERALS = "Unsupported feature: tagged template literals"
ECMA_ERR_CONTAINER_NEEDED = "Value is not a Container or Iterator"
ECMA_ERR_INCORRECT_TYPE_CALL = "Operator called on incorrect container type"
ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL = "Invalid type for constructor call"
ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW = "Script (global) functions cannot be invoked with 'new'"
ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW = "Generator functions cannot be invoked with 'new'"
ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW = "Async functions cannot be invoked with 'new'"
ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW = "Async generator functions cannot be invoked with 'new'"
ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW = "Accessor functions cannot be invoked with 'new'"
ECMA_ERR_METHODS_INVOKE_WITH_NEW = "Methods cannot be invoked with 'new'"
ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW = "Arrow functions cannot be invoked with 'new'"
ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW = "Async arrow functions cannot be invoked with 'new'"
ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR = "Proxy target is not a constructor"
ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED = "Maximum call stack size exceeded"
ECMA_ERR_INVALID_SNAPSHOT_FORMAT = "Invalid snapshot format"
ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES = "Invalid snapshot version or unsupported features present"
ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT = "Receiver must be an object"
ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE = "Cannot declare same private field twice"
ECMA_ERR_CANNOT_WRITE_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT = "Cannot write private member to an object whose class did not declare it"
ECMA_ERR_PRIVATE_METHOD_IS_NOT_WRITABLE = "Private method is not writable"
ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_SETTER = "Private field was defined without a setter"
ECMA_ERR_CANNOT_READ_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT = "Cannot read private member to an object whose class did not declare it"
ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_GETTER = "Private field was defined without a getter"
+71
View File
@@ -0,0 +1,71 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-errors.h"
#if JERRY_ERROR_MESSAGES
/**
* Struct to store ecma error message with its size.
*/
typedef struct
{
char *text; /* Text of ecma error message. */
uint8_t size; /* Size of ecma error message. */
} ecma_error_message_t;
/* Error message texts with size. */
static ecma_error_message_t ecma_error_messages[] JERRY_ATTR_CONST_DATA = {
{ "", 0 }, /* ECMA_ERR_EMPTY */
/** @cond doxygen_suppress */
#define ECMA_ERROR_DEF(id, string) { string, sizeof (string) - 1 },
#include "ecma-error-messages.inc.h"
#undef ECMA_ERROR_DEF
/** @endcond */
};
#endif /* JERRY_ERROR_MESSAGES */
/**
* Get specified ecma error as zero-terminated string
*
* @return pointer to zero-terminated ecma error
*/
const char *
ecma_get_error_msg (ecma_error_msg_t id) /**< ecma error id */
{
JERRY_ASSERT (id != ECMA_IS_VALID_CONSTRUCTOR);
#if JERRY_ERROR_MESSAGES
return ecma_error_messages[id].text;
#else /* !JERRY_ERROR_MESSAGES */
return NULL;
#endif /* JERRY_ERROR_MESSAGES */
} /* ecma_get_error_msg */
/**
* Get size of specified ecma error
*
* @return size in bytes
*/
lit_utf8_size_t
ecma_get_error_size (ecma_error_msg_t id) /**< ecma error id */
{
JERRY_ASSERT (id != ECMA_IS_VALID_CONSTRUCTOR);
#if JERRY_ERROR_MESSAGES
return ecma_error_messages[id].size;
#else /* !JERRY_ERROR_MESSAGES */
return 0;
#endif /* JERRY_ERROR_MESSAGES */
} /* ecma_get_error_size */
+39
View File
@@ -0,0 +1,39 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMA_ERRORS_H
#define ECMA_ERRORS_H
#include "lit-globals.h"
typedef enum
{
ECMA_ERR_EMPTY,
/** @cond doxygen_suppress */
#if JERRY_ERROR_MESSAGES
#define ECMA_ERROR_DEF(id, ascii_zt_string) id,
#else /* !JERRY_ERROR_MESSAGES */
#define ECMA_ERROR_DEF(id, ascii_zt_string) id = ECMA_ERR_EMPTY,
#endif /* JERRY_ERROR_MESSAGES */
#include "ecma-error-messages.inc.h"
#undef ECMA_ERROR_DEF
/** @endcond */
ECMA_IS_VALID_CONSTRUCTOR /* used as return value when checking constructor */
} ecma_error_msg_t;
const char* ecma_get_error_msg (ecma_error_msg_t id);
lit_utf8_size_t ecma_get_error_size (ecma_error_msg_t id);
#endif /* !ECMA_ERRORS_H */
+144
View File
@@ -0,0 +1,144 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-extended-info.h"
#include "ecma-helpers.h"
#include "byte-code.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmaextendedinfo Extended info
* @{
*/
/**
* Decodes an uint32_t number, and updates the buffer position.
*
* @return the decoded value
*/
uint32_t
ecma_extended_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
{
uint8_t *source_p = *buffer_p;
uint32_t value = 0;
do
{
source_p--;
value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK);
} while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
*buffer_p = source_p;
return value;
} /* ecma_extended_info_decode_vlq */
/**
* Encodes an uint32_t number into a buffer.
*/
void
ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
uint32_t value) /**< encoded value */
{
uint8_t *destination_p = *buffer_p - 1;
if (value <= ECMA_EXTENDED_INFO_VLQ_MASK)
{
*destination_p = (uint8_t) value;
*buffer_p = destination_p;
return;
}
uint32_t length = 0;
uint32_t current_value = value >> ECMA_EXTENDED_INFO_VLQ_SHIFT;
do
{
current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
length++;
} while (current_value > 0);
destination_p -= length;
*buffer_p = destination_p;
do
{
*destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE);
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
} while (value > 0);
**buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK;
} /* ecma_extended_info_encode_vlq */
/**
* Gets the encoded length of a number.
*
* @return encoded length
*/
uint32_t
ecma_extended_info_get_encoded_length (uint32_t value) /**< encoded value */
{
uint32_t length = 0;
do
{
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
length++;
} while (value > 0);
return length;
} /* ecma_extended_info_get_encoded_length */
/**
* Get the extended info from a byte code
*
* @return pointer to the extended info
*/
uint8_t *
ecma_compiled_code_resolve_extended_info (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
{
JERRY_ASSERT (bytecode_header_p != NULL);
JERRY_ASSERT (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_EXTENDED_INFO);
ecma_value_t *base_p = ecma_compiled_code_resolve_arguments_start (bytecode_header_p);
if (CBC_FUNCTION_GET_TYPE (bytecode_header_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
{
base_p--;
}
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
{
base_p--;
}
#if JERRY_LINE_INFO
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_LINE_INFO)
{
base_p--;
}
#endif /* JERRY_LINE_INFO */
JERRY_ASSERT (((uint8_t *) base_p)[-1] != 0);
return ((uint8_t *) base_p) - 1;
} /* ecma_compiled_code_resolve_extended_info */
/**
* @}
* @}
*/
+54
View File
@@ -0,0 +1,54 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMA_EXTENDED_INFO_H
#define ECMA_EXTENDED_INFO_H
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmaextendedinfo Extended info
* @{
*/
#include "ecma-globals.h"
/**
* Vlq encoding: flag which is set for all bytes except the last one.
*/
#define ECMA_EXTENDED_INFO_VLQ_CONTINUE 0x80
/**
* Vlq encoding: mask to decode the number fragment.
*/
#define ECMA_EXTENDED_INFO_VLQ_MASK 0x7f
/**
* Vlq encoding: number of bits stored in a byte.
*/
#define ECMA_EXTENDED_INFO_VLQ_SHIFT 7
uint32_t ecma_extended_info_decode_vlq (uint8_t **buffer_p);
void ecma_extended_info_encode_vlq (uint8_t **buffer_p, uint32_t value);
uint32_t ecma_extended_info_get_encoded_length (uint32_t value);
uint8_t *ecma_compiled_code_resolve_extended_info (const ecma_compiled_code_t *bytecode_header_p);
/**
* @}
* @}
*/
#endif /* !ECMA_EXTENDED_INFO_H */
File diff suppressed because it is too large Load Diff
+14 -1
View File
@@ -17,6 +17,7 @@
#define ECMA_GC_H #define ECMA_GC_H
#include "ecma-globals.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -26,10 +27,22 @@
* @{ * @{
*/ */
/**
* Free option flags
*/
typedef enum
{
ECMA_GC_FREE_NO_OPTIONS = 0, /**< no options */
ECMA_GC_FREE_SECOND_PROPERTY = (1 << 0), /**< free second property of a property pair */
ECMA_GC_FREE_REFERENCES = (1 << 1), /**< free references */
} ecma_gc_free_options_t;
void ecma_init_gc_info (ecma_object_t *object_p); void ecma_init_gc_info (ecma_object_t *object_p);
void ecma_ref_object (ecma_object_t *object_p); void ecma_ref_object (ecma_object_t *object_p);
void ecma_ref_object_inline (ecma_object_t *object_p);
void ecma_deref_object (ecma_object_t *object_p); void ecma_deref_object (ecma_object_t *object_p);
void ecma_gc_free_properties (ecma_object_t *object_p); void ecma_gc_free_property (ecma_object_t *object_p, ecma_property_pair_t *prop_pair_p, uint32_t options);
void ecma_gc_free_properties (ecma_object_t *object_p, uint32_t options);
void ecma_gc_run (void); void ecma_gc_run (void);
void ecma_free_unused_memory (jmem_pressure_t pressure); void ecma_free_unused_memory (jmem_pressure_t pressure);
File diff suppressed because it is too large Load Diff
+252 -1
View File
@@ -14,9 +14,11 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-conversion.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h" #include "jrt.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -48,7 +50,7 @@ ecma_new_collection (void)
/** /**
* Deallocate a collection of ecma values without freeing it's values * Deallocate a collection of ecma values without freeing it's values
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_collection_destroy (ecma_collection_t *collection_p) /**< value collection */ ecma_collection_destroy (ecma_collection_t *collection_p) /**< value collection */
{ {
JERRY_ASSERT (collection_p != NULL); JERRY_ASSERT (collection_p != NULL);
@@ -78,6 +80,42 @@ ecma_collection_free_objects (ecma_collection_t *collection_p) /**< value collec
ecma_collection_destroy (collection_p); ecma_collection_destroy (collection_p);
} /* ecma_collection_free_objects */ } /* ecma_collection_free_objects */
/**
* Free the template literal objects and deallocate the collection
*/
void
ecma_collection_free_template_literal (ecma_collection_t *collection_p) /**< value collection */
{
for (uint32_t i = 0; i < collection_p->item_count; i++)
{
ecma_object_t *object_p = ecma_get_object_from_value (collection_p->buffer_p[i]);
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_ARRAY);
ecma_extended_object_t *array_object_p = (ecma_extended_object_t *) object_p;
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_ARRAY_TEMPLATE_LITERAL;
ecma_property_value_t *property_value_p;
property_value_p = ecma_get_named_data_property (object_p, ecma_get_magic_string (LIT_MAGIC_STRING_RAW));
ecma_object_t *raw_object_p = ecma_get_object_from_value (property_value_p->value);
JERRY_ASSERT (ecma_get_object_type (raw_object_p) == ECMA_OBJECT_TYPE_ARRAY);
array_object_p = (ecma_extended_object_t *) raw_object_p;
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_ARRAY_TEMPLATE_LITERAL;
ecma_deref_object (raw_object_p);
ecma_deref_object (object_p);
}
ecma_collection_destroy (collection_p);
} /* ecma_collection_free_template_literal */
/** /**
* Free the non-object collection elements and deallocate the collection * Free the non-object collection elements and deallocate the collection
*/ */
@@ -187,6 +225,219 @@ ecma_collection_append (ecma_collection_t *collection_p, /**< value collection *
collection_p->item_count += count; collection_p->item_count += count;
} /* ecma_collection_append */ } /* ecma_collection_append */
/**
* Helper function to check if a given collection have duplicated properties or not
*
* @return true - if there are duplicated properties in the collection
* false - otherwise
*/
bool
ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p) /**< prop name collection */
{
if (collection_p->item_count == 0)
{
return false;
}
ecma_value_t *buffer_p = collection_p->buffer_p;
for (uint32_t i = 0; i < collection_p->item_count - 1; i++)
{
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[i]);
for (uint32_t j = i + 1; j < collection_p->item_count; j++)
{
if (ecma_compare_ecma_strings (current_name_p, ecma_get_prop_name_from_value (buffer_p[j])))
{
return true;
}
}
}
return false;
} /* ecma_collection_check_duplicated_entries */
/**
* Check the string value existance in the collection.
*
* Used by:
* - ecma_builtin_json_stringify step 4.b.ii.5
* - ecma_op_object_enumerate
*
* @return true, if the string is already in the collection.
*/
bool
ecma_collection_has_string_value (ecma_collection_t *collection_p, /**< collection */
ecma_string_t *string_p) /**< string */
{
ecma_value_t *buffer_p = collection_p->buffer_p;
for (uint32_t i = 0; i < collection_p->item_count; i++)
{
ecma_string_t *current_p = ecma_get_string_from_value (buffer_p[i]);
if (ecma_compare_ecma_strings (current_p, string_p))
{
return true;
}
}
return false;
} /* ecma_collection_has_string_value */
/**
* Initial capacity of an ecma-collection
*/
#define ECMA_COMPACT_COLLECTION_GROWTH 8
/**
* Set the size of the compact collection
*/
#define ECMA_COMPACT_COLLECTION_SET_SIZE(compact_collection_p, item_count, unused_items) \
((compact_collection_p)[0] = (((item_count) << ECMA_COMPACT_COLLECTION_SIZE_SHIFT) | (unused_items)))
/**
* Set the size of the compact collection
*/
#define ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT(compact_collection_p) \
((compact_collection_p)[0] & ((1 << ECMA_COMPACT_COLLECTION_SIZE_SHIFT) - 1))
/**
* Allocate a compact collection of ecma values
*
* @return pointer to the compact collection
*/
ecma_value_t *
ecma_new_compact_collection (void)
{
size_t size = (ECMA_COMPACT_COLLECTION_GROWTH / 2) * sizeof (ecma_value_t);
ecma_value_t *compact_collection_p = (ecma_value_t *) jmem_heap_alloc_block (size);
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
ECMA_COMPACT_COLLECTION_GROWTH / 2,
(ECMA_COMPACT_COLLECTION_GROWTH / 2) - 1);
return compact_collection_p;
} /* ecma_new_compact_collection */
/**
* Append a value to the compact collection
*
* @return updated pointer to the compact collection
*/
ecma_value_t *
ecma_compact_collection_push_back (ecma_value_t *compact_collection_p, /**< compact collection */
ecma_value_t value) /**< ecma value to append */
{
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
if (unused_items > 0)
{
compact_collection_p[size - unused_items] = value;
(*compact_collection_p)--;
return compact_collection_p;
}
if (size == ECMA_COMPACT_COLLECTION_GROWTH / 2)
{
size_t old_size = (ECMA_COMPACT_COLLECTION_GROWTH / 2) * sizeof (ecma_value_t);
size_t new_size = ECMA_COMPACT_COLLECTION_GROWTH * sizeof (ecma_value_t);
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
compact_collection_p[ECMA_COMPACT_COLLECTION_GROWTH / 2] = value;
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
ECMA_COMPACT_COLLECTION_GROWTH,
(ECMA_COMPACT_COLLECTION_GROWTH / 2) - 1);
return compact_collection_p;
}
size_t old_size = size * sizeof (ecma_value_t);
size_t new_size = old_size + (ECMA_COMPACT_COLLECTION_GROWTH * sizeof (ecma_value_t));
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
compact_collection_p[size] = value;
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
size + ECMA_COMPACT_COLLECTION_GROWTH,
ECMA_COMPACT_COLLECTION_GROWTH - 1);
return compact_collection_p;
} /* ecma_compact_collection_push_back */
/**
* Discard the unused elements of a compact collection
*
* Note:
* further items should not be added after this call
*
* @return updated pointer to the compact collection
*/
ecma_value_t *
ecma_compact_collection_shrink (ecma_value_t *compact_collection_p) /**< compact collection */
{
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
if (unused_items == 0)
{
return compact_collection_p;
}
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
size_t old_size = size * sizeof (ecma_value_t);
size_t new_size = (size - unused_items) * sizeof (ecma_value_t);
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p, size - unused_items, 0);
return compact_collection_p;
} /* ecma_compact_collection_shrink */
/**
* Free a compact collection
*/
void
ecma_compact_collection_free (ecma_value_t *compact_collection_p) /**< compact collection */
{
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
ecma_value_t *end_p = compact_collection_p + size - unused_items;
ecma_value_t *current_p = compact_collection_p + 1;
while (current_p < end_p)
{
ecma_free_value (*current_p++);
}
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
} /* ecma_compact_collection_free */
/**
* Get the end of a compact collection
*
* @return pointer to the compact collection end
*/
ecma_value_t *
ecma_compact_collection_end (ecma_value_t *compact_collection_p) /**< compact collection */
{
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
return compact_collection_p + size - unused_items;
} /* ecma_compact_collection_end */
/**
* Destroy a compact collection
*/
void
ecma_compact_collection_destroy (ecma_value_t *compact_collection_p) /**< compact collection */
{
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
} /* ecma_compact_collection_destroy */
/** /**
* @} * @}
* @} * @}
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -133,13 +133,13 @@ ecma_divide_high_prec_by_10 (ecma_high_prec_t *hp_data_p) /**< [in, out] high-pr
* *
* @return number of generated digits * @return number of generated digits
*/ */
inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE extern inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
ecma_errol0_dtoa (double val, /**< ecma number */ ecma_errol0_dtoa (double val, /**< ecma number */
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */ lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
int32_t *exp_p) /**< [out] exponent */ int32_t *exp_p) /**< [out] exponent */
{ {
double power_of_10 = 1.0; double power_of_10 = 1.0;
int32_t exp = 1; int32_t exponent = 1;
/* normalize the midpoint */ /* normalize the midpoint */
ecma_high_prec_t mid; ecma_high_prec_t mid;
@@ -147,16 +147,16 @@ ecma_errol0_dtoa (double val, /**< ecma number */
mid.value = val; mid.value = val;
mid.offset = 0.0; mid.offset = 0.0;
while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exp < 308)) while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exponent < 308))
{ {
exp++; exponent++;
ecma_divide_high_prec_by_10 (&mid); ecma_divide_high_prec_by_10 (&mid);
power_of_10 /= 10.0; power_of_10 /= 10.0;
} }
while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exp > -307)) while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exponent > -307))
{ {
exp--; exponent--;
ecma_multiply_high_prec_by_10 (&mid); ecma_multiply_high_prec_by_10 (&mid);
power_of_10 *= 10.0; power_of_10 *= 10.0;
} }
@@ -181,14 +181,14 @@ ecma_errol0_dtoa (double val, /**< ecma number */
while (high_bound.value > 10.0 || (high_bound.value == 10.0 && (high_bound.offset >= 0.0))) while (high_bound.value > 10.0 || (high_bound.value == 10.0 && (high_bound.offset >= 0.0)))
{ {
exp++; exponent++;
ecma_divide_high_prec_by_10 (&high_bound); ecma_divide_high_prec_by_10 (&high_bound);
ecma_divide_high_prec_by_10 (&low_bound); ecma_divide_high_prec_by_10 (&low_bound);
} }
while (high_bound.value < 1.0 || (high_bound.value == 1.0 && (high_bound.offset < 0.0))) while (high_bound.value < 1.0 || (high_bound.value == 1.0 && (high_bound.offset < 0.0)))
{ {
exp--; exponent--;
ecma_multiply_high_prec_by_10 (&high_bound); ecma_multiply_high_prec_by_10 (&high_bound);
ecma_multiply_high_prec_by_10 (&low_bound); ecma_multiply_high_prec_by_10 (&low_bound);
} }
@@ -230,7 +230,7 @@ ecma_errol0_dtoa (double val, /**< ecma number */
double mdig = (high_bound.value + low_bound.value) / 2.0 + 0.5; double mdig = (high_bound.value + low_bound.value) / 2.0 + 0.5;
*dst_p++ = (lit_utf8_byte_t) ('0' + (uint8_t) mdig); *dst_p++ = (lit_utf8_byte_t) ('0' + (uint8_t) mdig);
*exp_p = exp; *exp_p = exponent;
return (lit_utf8_size_t) (dst_p - buffer_p); return (lit_utf8_size_t) (dst_p - buffer_p);
} /* ecma_errol0_dtoa */ } /* ecma_errol0_dtoa */
@@ -16,9 +16,9 @@
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects-general.h"
#include "ecma-objects.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -36,9 +36,14 @@
bool bool
ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create property in */ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
void *native_p, /**< native pointer */ void *native_p, /**< native pointer */
void *info_p) /**< native pointer's type info */ const jerry_object_native_info_t *native_info_p) /**< native type info */
{ {
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER); ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
if (native_info_p != NULL && native_info_p->number_of_references > 0)
{
name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER_WITH_REFERENCES);
}
if (ecma_op_object_is_fast_array (obj_p)) if (ecma_op_object_is_fast_array (obj_p))
{ {
@@ -53,50 +58,91 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
if (property_p == NULL) if (property_p == NULL)
{ {
native_pointer_p = (ecma_native_pointer_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
ecma_property_value_t *value_p; ecma_property_value_t *value_p;
value_p = ecma_create_named_data_property (obj_p, name_p, ECMA_PROPERTY_CONFIGURABLE_WRITABLE, &property_p); ECMA_CREATE_INTERNAL_PROPERTY (obj_p, name_p, property_p, value_p);
ECMA_CONVERT_DATA_PROPERTY_TO_INTERNAL_PROPERTY (property_p);
native_pointer_p = jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p); ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
*property_p |= ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
}
else if (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)
{
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
if (native_pointer_p->native_info_p == native_info_p)
{
native_pointer_p->native_p = native_p;
return false;
}
value_p->value = JMEM_CP_NULL;
(void) value_p->value; /* Make cppcheck happy. */
*property_p &= (ecma_property_t) ~ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
ecma_native_pointer_chain_t *item_p;
item_p = (ecma_native_pointer_chain_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_chain_t));
item_p->data = *native_pointer_p;
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
item_p->next_p = (ecma_native_pointer_chain_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_chain_t));
item_p->next_p->next_p = NULL;
native_pointer_p = &item_p->next_p->data;
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, item_p);
} }
else else
{ {
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p); ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
ecma_native_pointer_t *iter_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value); if (value_p->value == JMEM_CP_NULL)
/* There should be at least 1 native pointer in the chain */
JERRY_ASSERT (iter_p != NULL);
while (true)
{ {
if (iter_p->info_p == info_p) native_pointer_p = (ecma_native_pointer_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
{ ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
/* The native info already exists -> update the corresponding data */
iter_p->data_p = native_p;
return false;
}
if (iter_p->next_p == NULL) *property_p |= ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
{
/* The native info does not exist -> append a new element to the chain */
break;
}
iter_p = iter_p->next_p;
} }
else
{
ecma_native_pointer_chain_t *item_p;
item_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
native_pointer_p = jmem_heap_alloc_block (sizeof (ecma_native_pointer_t)); /* There should be at least 2 native pointers in the chain */
JERRY_ASSERT (item_p != NULL && item_p->next_p != NULL);
iter_p->next_p = native_pointer_p; while (true)
{
if (item_p->data.native_info_p == native_info_p)
{
/* The native info already exists -> update the corresponding data */
item_p->data.native_p = native_p;
return false;
}
if (item_p->next_p == NULL)
{
/* The native info does not exist -> append a new element to the chain */
break;
}
item_p = item_p->next_p;
}
ecma_native_pointer_chain_t *new_item_p;
new_item_p = (ecma_native_pointer_chain_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_chain_t));
item_p->next_p = new_item_p;
new_item_p->next_p = NULL;
native_pointer_p = &new_item_p->data;
}
} }
native_pointer_p->data_p = native_p; native_pointer_p->native_p = native_p;
native_pointer_p->info_p = info_p; native_pointer_p->native_info_p = (jerry_object_native_info_t *) native_info_p;
native_pointer_p->next_p = NULL;
return is_new; return is_new;
} /* ecma_create_native_pointer_property */ } /* ecma_create_native_pointer_property */
@@ -113,7 +159,7 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
*/ */
ecma_native_pointer_t * ecma_native_pointer_t *
ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
void *info_p) /**< native pointer's type info */ const jerry_object_native_info_t *native_info_p) /**< native type info */
{ {
if (ecma_op_object_is_fast_array (obj_p)) if (ecma_op_object_is_fast_array (obj_p))
{ {
@@ -121,7 +167,13 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
return NULL; return NULL;
} }
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER); ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
if (native_info_p != NULL && native_info_p->number_of_references > 0)
{
name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER_WITH_REFERENCES);
}
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p); ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
if (property_p == NULL) if (property_p == NULL)
@@ -131,21 +183,39 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p); ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
value_p->value);
JERRY_ASSERT (native_pointer_p != NULL);
while (native_pointer_p != NULL)
{ {
if (native_pointer_p->info_p == info_p) ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
if (native_pointer_p->native_info_p == native_info_p)
{ {
return native_pointer_p; return native_pointer_p;
} }
native_pointer_p = native_pointer_p->next_p; return NULL;
} }
if (value_p->value == JMEM_CP_NULL)
{
return NULL;
}
ecma_native_pointer_chain_t *item_p;
item_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
/* There should be at least 2 native pointers in the chain */
JERRY_ASSERT (item_p != NULL && item_p->next_p != NULL);
do
{
if (item_p->data.native_info_p == native_info_p)
{
return &item_p->data;
}
item_p = item_p->next_p;
} while (item_p != NULL);
return NULL; return NULL;
} /* ecma_get_native_pointer_value */ } /* ecma_get_native_pointer_value */
@@ -161,7 +231,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
*/ */
bool bool
ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete property from */ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete property from */
void *info_p) /**< native pointer's type info */ const jerry_object_native_info_t *native_info_p) /**< native type info */
{ {
if (ecma_op_object_is_fast_array (obj_p)) if (ecma_op_object_is_fast_array (obj_p))
{ {
@@ -169,7 +239,13 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
return false; return false;
} }
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER); ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
if (native_info_p != NULL && native_info_p->number_of_references > 0)
{
name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER_WITH_REFERENCES);
}
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p); ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
if (property_p == NULL) if (property_p == NULL)
@@ -179,49 +255,75 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p); ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
value_p->value);
ecma_native_pointer_t *prev_p = NULL;
JERRY_ASSERT (native_pointer_p != NULL);
while (native_pointer_p != NULL)
{ {
if (native_pointer_p->info_p == info_p) ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
if (native_pointer_p->native_info_p != native_info_p)
{
return false;
}
value_p->value = JMEM_CP_NULL;
*property_p &= (ecma_property_t) ~ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
return true;
}
if (value_p->value == JMEM_CP_NULL)
{
return false;
}
ecma_native_pointer_chain_t *first_p;
first_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
/* There should be at least 2 native pointers in the chain */
JERRY_ASSERT (first_p != NULL && first_p->next_p != NULL);
ecma_native_pointer_chain_t *item_p = first_p;
ecma_native_pointer_chain_t *prev_p = NULL;
do
{
if (item_p->data.native_info_p == native_info_p)
{ {
if (prev_p == NULL) if (prev_p == NULL)
{ {
if (native_pointer_p->next_p == NULL) /* The first element is deleted from the chain: change the property value. */
{ first_p = item_p->next_p;
/* Only one native pointer property exists, so the property can be deleted as well. */ ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, first_p);
ecma_op_general_object_delete (obj_p, name_p, false);
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
return true;
}
else
{
/* There are at least two native pointers and the first one should be deleted.
In this case the second element's data is copied to the head of the chain, and freed as well. */
ecma_native_pointer_t *next_p = native_pointer_p->next_p;
memcpy (native_pointer_p, next_p, sizeof (ecma_native_pointer_t));
jmem_heap_free_block (next_p, sizeof (ecma_native_pointer_t));
return true;
}
} }
else else
{ {
/* There are at least two native pointers and not the first element should be deleted. /* A non-first element is deleted from the chain: update the previous pointer. */
In this case the current element's next element reference is copied to the previous element. */ prev_p->next_p = item_p->next_p;
prev_p->next_p = native_pointer_p->next_p; }
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t));
if (first_p->next_p != NULL)
{
return true; return true;
} }
/* Only one item remained. The ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL flag is
* set early to avoid using the chain if the allocation below triggers a GC. */
*property_p |= ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
ecma_native_pointer_t *native_pointer_p;
native_pointer_p = (ecma_native_pointer_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
*native_pointer_p = first_p->data;
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
jmem_heap_free_block (first_p, sizeof (ecma_native_pointer_chain_t));
return true;
} }
prev_p = native_pointer_p; prev_p = item_p;
native_pointer_p = native_pointer_p->next_p; item_p = item_p->next_p;
} } while (item_p != NULL);
return false; return false;
} /* ecma_delete_native_pointer_property */ } /* ecma_delete_native_pointer_property */
File diff suppressed because it is too large Load Diff
+245
View File
@@ -0,0 +1,245 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMA_HELPERS_NUMBER_H
#define ECMA_HELPERS_NUMBER_H
#include "ecma-globals.h"
#include "config.h"
/**
* Binary representation of an ecma-number
*/
#if JERRY_NUMBER_TYPE_FLOAT64
typedef uint64_t ecma_binary_num_t;
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
typedef uint32_t ecma_binary_num_t;
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Makes it possible to read/write the binary representation of an ecma_number_t
* without strict aliasing rule violation.
*/
typedef union
{
ecma_number_t as_number; /**< ecma-number */
ecma_binary_num_t as_binary; /**< binary representation */
} ecma_number_accessor_t;
ecma_binary_num_t ecma_number_to_binary (ecma_number_t number);
ecma_number_t ecma_number_from_binary (ecma_binary_num_t binary);
bool ecma_number_sign (ecma_binary_num_t binary);
uint32_t ecma_number_biased_exp (ecma_binary_num_t binary);
uint64_t ecma_number_fraction (ecma_binary_num_t binary);
ecma_number_t ecma_number_create (bool sign, uint32_t biased_exp, uint64_t fraction);
/**
* Maximum number of significant decimal digits that an ecma-number can store
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MAX_DIGITS (19)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MAX_DIGITS (9)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Width of sign field
*
* See also:
* IEEE-754 2008, 3.6, Table 3.5
*/
#define ECMA_NUMBER_SIGN_WIDTH (1)
/**
* Width of biased exponent field
*
* See also:
* IEEE-754 2008, 3.6, Table 3.5
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_BIASED_EXP_WIDTH (8)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Exponent bias
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_EXPONENT_BIAS (1023)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_EXPONENT_BIAS (127)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Width of fraction field
*
* See also:
* IEEE-754 2008, 3.6, Table 3.5
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_FRACTION_WIDTH (52)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_FRACTION_WIDTH (23)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Sign bit in ecma-numbers
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_SIGN_BIT 0x8000000000000000ull
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_SIGN_BIT 0x7f800000u;
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Binary representation of an IEEE-754 QNaN value.
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_BINARY_QNAN 0x7ff8000000000000ull
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_BINARY_QNAN 0x7fc00000u
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Binary representation of an IEEE-754 Infinity value.
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_BINARY_INF 0x7ff0000000000000ull
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_BINARY_INF 0x7f800000u
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Binary representation of an IEEE-754 zero value.
*/
#define ECMA_NUMBER_BINARY_ZERO 0x0ull
/**
* Number.MIN_VALUE (i.e., the smallest positive value of ecma-number)
*
* See also: ECMA_262 v5, 15.7.3.3
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
*
* See also: ECMA_262 v5, 15.7.3.2
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Number.EPSILON
*
* See also: ECMA_262 v6, 20.1.2.1
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Number.MAX_SAFE_INTEGER
*
* See also: ECMA_262 v6, 20.1.2.6
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Number.MIN_SAFE_INTEGER
*
* See also: ECMA_262 v6, 20.1.2.8
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Number.MAX_VALUE exponent part
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define NUMBER_MAX_DECIMAL_EXPONENT 308
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define NUMBER_MAX_DECIMAL_EXPONENT 38
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Number.MIN_VALUE exponent part
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define NUMBER_MIN_DECIMAL_EXPONENT -324
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define NUMBER_MIN_DECIMAL_EXPONENT -45
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Euler number
*/
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
/**
* Natural logarithm of 10
*/
#define ECMA_NUMBER_LN10 ((ecma_number_t) 2.302585092994046)
/**
* Natural logarithm of 2
*/
#define ECMA_NUMBER_LN2 ((ecma_number_t) 0.6931471805599453)
/**
* Logarithm base 2 of the Euler number
*/
#define ECMA_NUMBER_LOG2E ((ecma_number_t) 1.4426950408889634)
/**
* Logarithm base 10 of the Euler number
*/
#define ECMA_NUMBER_LOG10E ((ecma_number_t) 0.4342944819032518)
/**
* Pi number
*/
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
/**
* Square root of 0.5
*/
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
/**
* Square root of 2
*/
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
#endif /* !ECMA_HELPERS_NUMBER_H */
File diff suppressed because it is too large Load Diff
+183 -129
View File
@@ -15,20 +15,19 @@
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers-number.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h"
#include "jrt-bit-fields.h" #include "jrt-bit-fields.h"
#include "jrt.h"
#include "vm-defines.h" #include "vm-defines.h"
#include "ecma-function-object.h" JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, ecma_types_must_be_less_than_mask);
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT), ecma_value_part_must_start_after_flags);
ecma_types_must_be_less_than_mask);
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
ecma_value_part_must_start_after_flags);
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG, JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log); ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
@@ -42,20 +41,25 @@ JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY #ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
/* cppcheck-suppress zerodiv */ /* cppcheck-suppress zerodiv */
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), uintptr_t_must_fit_in_ecma_value_t);
uintptr_t_must_fit_in_ecma_value_t);
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), uintptr_t_must_not_fit_in_ecma_value_t);
uintptr_t_must_not_fit_in_ecma_value_t);
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE_TRUE JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE_TRUE
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE, && ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false); only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
#if JERRY_BUILTIN_BIGINT
JERRY_STATIC_ASSERT (ECMA_NULL_POINTER == (ECMA_BIGINT_ZERO & ~(ecma_value_t) ECMA_VALUE_TYPE_MASK),
ecma_bigint_zero_must_be_encoded_as_null_pointer);
#endif /* JERRY_BUILTIN_BIGINT */
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
* *
@@ -103,7 +107,7 @@ ecma_pointer_to_ecma_value (const void *ptr) /**< pointer */
* *
* @return pointer * @return pointer
*/ */
static inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE static inline void *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */ ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
{ {
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY #ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
@@ -121,7 +125,7 @@ ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
* @return true - if the value is a direct value, * @return true - if the value is a direct value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_direct (ecma_value_t value) /**< ecma value */ ecma_is_value_direct (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT); return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT);
@@ -133,7 +137,7 @@ ecma_is_value_direct (ecma_value_t value) /**< ecma value */
* @return true - if the value is a simple value, * @return true - if the value is a simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_simple (ecma_value_t value) /**< ecma value */ ecma_is_value_simple (ecma_value_t value) /**< ecma value */
{ {
return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_SIMPLE_VALUE; return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_SIMPLE_VALUE;
@@ -158,7 +162,7 @@ ecma_is_value_equal_to_simple_value (ecma_value_t value, /**< ecma value */
* @return true - if the value contains implementation-defined empty simple value, * @return true - if the value contains implementation-defined empty simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_empty (ecma_value_t value) /**< ecma value */ ecma_is_value_empty (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_EMPTY); return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_EMPTY);
@@ -170,7 +174,7 @@ ecma_is_value_empty (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-undefined simple value, * @return true - if the value contains ecma-undefined simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_undefined (ecma_value_t value) /**< ecma value */ ecma_is_value_undefined (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED); return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED);
@@ -182,7 +186,7 @@ ecma_is_value_undefined (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-null simple value, * @return true - if the value contains ecma-null simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_null (ecma_value_t value) /**< ecma value */ ecma_is_value_null (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL); return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL);
@@ -194,7 +198,7 @@ ecma_is_value_null (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-true or ecma-false simple values, * @return true - if the value contains ecma-true or ecma-false simple values,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_boolean (ecma_value_t value) /**< ecma value */ ecma_is_value_boolean (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_true (value | (1 << ECMA_DIRECT_SHIFT)); return ecma_is_value_true (value | (1 << ECMA_DIRECT_SHIFT));
@@ -206,7 +210,7 @@ ecma_is_value_boolean (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-true simple value, * @return true - if the value contains ecma-true simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_true (ecma_value_t value) /**< ecma value */ ecma_is_value_true (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_TRUE); return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_TRUE);
@@ -218,7 +222,7 @@ ecma_is_value_true (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-false simple value, * @return true - if the value contains ecma-false simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_false (ecma_value_t value) /**< ecma value */ ecma_is_value_false (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_FALSE); return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_FALSE);
@@ -230,7 +234,7 @@ ecma_is_value_false (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-not-found simple value, * @return true - if the value contains ecma-not-found simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_found (ecma_value_t value) /**< ecma value */ ecma_is_value_found (ecma_value_t value) /**< ecma value */
{ {
return value != ECMA_VALUE_NOT_FOUND; return value != ECMA_VALUE_NOT_FOUND;
@@ -242,7 +246,7 @@ ecma_is_value_found (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-array-hole simple value, * @return true - if the value contains ecma-array-hole simple value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_array_hole (ecma_value_t value) /**< ecma value */ ecma_is_value_array_hole (ecma_value_t value) /**< ecma value */
{ {
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_ARRAY_HOLE); return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_ARRAY_HOLE);
@@ -254,7 +258,7 @@ ecma_is_value_array_hole (ecma_value_t value) /**< ecma value */
* @return true - if the value contains an integer ecma-number value, * @return true - if the value contains an integer ecma-number value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_integer_number (ecma_value_t value) /**< ecma value */ ecma_is_value_integer_number (ecma_value_t value) /**< ecma value */
{ {
return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE; return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
@@ -266,12 +270,11 @@ ecma_is_value_integer_number (ecma_value_t value) /**< ecma value */
* @return true - if both values contain integer ecma-number values, * @return true - if both values contain integer ecma-number values,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */ ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */
ecma_value_t second_value) /**< second ecma value */ ecma_value_t second_value) /**< second ecma value */
{ {
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, ecma_direct_type_integer_value_must_be_zero);
ecma_direct_type_integer_value_must_be_zero);
return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE; return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
} /* ecma_are_values_integer_numbers */ } /* ecma_are_values_integer_numbers */
@@ -282,7 +285,7 @@ ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value
* @return true - if the value contains a floating-point ecma-number value, * @return true - if the value contains a floating-point ecma-number value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_float_number (ecma_value_t value) /**< ecma value */ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT); return (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -297,8 +300,7 @@ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_number (ecma_value_t value) /**< ecma value */ ecma_is_value_number (ecma_value_t value) /**< ecma value */
{ {
return (ecma_is_value_integer_number (value) return (ecma_is_value_integer_number (value) || ecma_is_value_float_number (value));
|| ecma_is_value_float_number (value));
} /* ecma_is_value_number */ } /* ecma_is_value_number */
JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING, JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
@@ -316,19 +318,47 @@ ecma_is_value_string (ecma_value_t value) /**< ecma value */
return ((value & (ECMA_VALUE_TYPE_MASK - 0x4)) == ECMA_TYPE_STRING); return ((value & (ECMA_VALUE_TYPE_MASK - 0x4)) == ECMA_TYPE_STRING);
} /* ecma_is_value_string */ } /* ecma_is_value_string */
#if ENABLED (JERRY_ES2015)
/** /**
* Check if the value is symbol. * Check if the value is symbol.
* *
* @return true - if the value contains symbol value, * @return true - if the value contains symbol value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_symbol (ecma_value_t value) /**< ecma value */ ecma_is_value_symbol (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_SYMBOL); return (ecma_get_value_type_field (value) == ECMA_TYPE_SYMBOL);
} /* ecma_is_value_symbol */ } /* ecma_is_value_symbol */
#endif /* ENABLED (JERRY_ES2015) */
/**
* Check if the value is a specific magic string.
*
* @return true - if the value the magic string value,
* false - otherwise
*/
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
lit_magic_string_id_t id) /**< magic string id */
{
return value == ecma_make_magic_string_value (id);
} /* ecma_is_value_magic_string */
/**
* Check if the value is bigint.
*
* @return true - if the value contains bigint value,
* false - otherwise
*/
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
{
#if JERRY_BUILTIN_BIGINT
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
#else /* !JERRY_BUILTIN_BIGINT */
JERRY_UNUSED (value);
return false;
#endif /* JERRY_BUILTIN_BIGINT */
} /* ecma_is_value_bigint */
/** /**
* Check if the value can be property name. * Check if the value can be property name.
@@ -336,14 +366,10 @@ ecma_is_value_symbol (ecma_value_t value) /**< ecma value */
* @return true - if the value can be property name value, * @return true - if the value can be property name value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */ ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */
{ {
#if ENABLED (JERRY_ES2015)
return ecma_is_value_string (value) || ecma_is_value_symbol (value); return ecma_is_value_string (value) || ecma_is_value_symbol (value);
#else /* !ENABLED (JERRY_ES2015) */
return ecma_is_value_string (value);
#endif /* ENABLED (JERRY_ES2015) */
} /* ecma_is_value_prop_name */ } /* ecma_is_value_prop_name */
/** /**
@@ -352,7 +378,7 @@ ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */
* @return true - if the value contains direct ecma-string value, * @return true - if the value contains direct ecma-string value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */ ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT_STRING); return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT_STRING);
@@ -364,7 +390,7 @@ ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
* @return true - if the value contains non-direct ecma-string value, * @return true - if the value contains non-direct ecma-string value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_non_direct_string (ecma_value_t value) /**< ecma value */ ecma_is_value_non_direct_string (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING); return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
@@ -376,7 +402,7 @@ ecma_is_value_non_direct_string (ecma_value_t value) /**< ecma value */
* @return true - if the value contains object value, * @return true - if the value contains object value,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_object (ecma_value_t value) /**< ecma value */ ecma_is_value_object (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT); return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
@@ -388,11 +414,11 @@ ecma_is_value_object (ecma_value_t value) /**< ecma value */
* @return true - if the value contains an error reference, * @return true - if the value contains an error reference,
* false - otherwise * false - otherwise
*/ */
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */ ecma_is_value_exception (ecma_value_t value) /**< ecma value */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR); return (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
} /* ecma_is_value_error_reference */ } /* ecma_is_value_exception */
/** /**
* Debug assertion that specified value's type is one of ECMA-defined * Debug assertion that specified value's type is one of ECMA-defined
@@ -401,13 +427,9 @@ ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
void void
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */ ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_undefined (value) JERRY_ASSERT (ecma_is_value_undefined (value) || ecma_is_value_null (value) || ecma_is_value_boolean (value)
|| ecma_is_value_null (value) || ecma_is_value_number (value) || ecma_is_value_string (value) || ecma_is_value_bigint (value)
|| ecma_is_value_boolean (value) || ecma_is_value_symbol (value) || ecma_is_value_object (value));
|| ecma_is_value_number (value)
|| ecma_is_value_string (value)
|| ECMA_ASSERT_VALUE_IS_SYMBOL (value)
|| ecma_is_value_object (value));
} /* ecma_check_value_type_is_spec_defined */ } /* ecma_check_value_type_is_spec_defined */
/** /**
@@ -426,25 +448,24 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */
ecma_object_t *arg_obj_p = ecma_get_object_from_value (arg); ecma_object_t *arg_obj_p = ecma_get_object_from_value (arg);
if (ecma_get_object_type (arg_obj_p) == ECMA_OBJECT_TYPE_ARRAY) if (ecma_get_object_base_type (arg_obj_p) == ECMA_OBJECT_BASE_TYPE_ARRAY)
{ {
return ECMA_VALUE_TRUE; return ECMA_VALUE_TRUE;
} }
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY) #if JERRY_BUILTIN_PROXY
if (ECMA_OBJECT_IS_PROXY (arg_obj_p)) if (ECMA_OBJECT_IS_PROXY (arg_obj_p))
{ {
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) arg_obj_p; ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) arg_obj_p;
if (proxy_obj_p->handler == ECMA_VALUE_NULL) if (proxy_obj_p->handler == ECMA_VALUE_NULL)
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot perform 'IsArray' on the given proxy " return ecma_raise_type_error (ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION);
"because handler is null"));
} }
return ecma_is_value_array (proxy_obj_p->target); return ecma_is_value_array (proxy_obj_p->target);
} }
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */ #endif /* JERRY_BUILTIN_PROXY */
return ECMA_VALUE_FALSE; return ECMA_VALUE_FALSE;
} /* ecma_is_value_array */ } /* ecma_is_value_array */
@@ -454,7 +475,7 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */
* *
* @return boolean ecma_value * @return boolean ecma_value
*/ */
inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_make_boolean_value (bool boolean_value) /**< raw bool value from which the ecma value will be created */ ecma_make_boolean_value (bool boolean_value) /**< raw bool value from which the ecma value will be created */
{ {
return boolean_value ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE; return boolean_value ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
@@ -468,7 +489,7 @@ ecma_make_boolean_value (bool boolean_value) /**< raw bool value from which the
* *
* @return ecma-value * @return ecma-value
*/ */
inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_make_integer_value (ecma_integer_value_t integer_value) /**< integer number to be encoded */ ecma_make_integer_value (ecma_integer_value_t integer_value) /**< integer number to be encoded */
{ {
JERRY_ASSERT (ECMA_IS_INTEGER_NUMBER (integer_value)); JERRY_ASSERT (ECMA_IS_INTEGER_NUMBER (integer_value));
@@ -496,7 +517,7 @@ ecma_create_float_number (ecma_number_t ecma_number) /**< value of the float num
* *
* @return ecma-value * @return ecma-value
*/ */
ecma_value_t extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_make_float_value (ecma_number_t *ecma_num_p) /**< pointer to the float number */ ecma_make_float_value (ecma_number_t *ecma_num_p) /**< pointer to the float number */
{ {
return ecma_pointer_to_ecma_value (ecma_num_p) | ECMA_TYPE_FLOAT; return ecma_pointer_to_ecma_value (ecma_num_p) | ECMA_TYPE_FLOAT;
@@ -507,7 +528,7 @@ ecma_make_float_value (ecma_number_t *ecma_num_p) /**< pointer to the float numb
* *
* @return ecma-value * @return ecma-value
*/ */
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE JERRY_ATTR_CONST
ecma_make_nan_value (void) ecma_make_nan_value (void)
{ {
return ecma_create_float_number (ecma_number_make_nan ()); return ecma_create_float_number (ecma_number_make_nan ());
@@ -521,15 +542,25 @@ ecma_make_nan_value (void)
static inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE static inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_number_equal_to_positive_zero (ecma_number_t ecma_number) /**< number */ ecma_is_number_equal_to_positive_zero (ecma_number_t ecma_number) /**< number */
{ {
ecma_number_accessor_t u; return ecma_number_to_binary (ecma_number) == ECMA_NUMBER_BINARY_ZERO;
u.as_ecma_number_t = ecma_number;
#if !ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
return u.as_uint32_t == 0;
#else /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
return u.as_uint64_t == 0;
#endif /* !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
} /* ecma_is_number_equal_to_positive_zero */ } /* ecma_is_number_equal_to_positive_zero */
/**
* Encode a property length number into an ecma-value
*
* @return ecma-value
*/
ecma_value_t
ecma_make_length_value (ecma_length_t number) /**< number to be encoded */
{
if (number <= ECMA_INTEGER_NUMBER_MAX)
{
return ecma_make_integer_value ((ecma_integer_value_t) number);
}
return ecma_create_float_number ((ecma_number_t) number);
} /* ecma_make_length_value */
/** /**
* Encode a number into an ecma-value * Encode a number into an ecma-value
* *
@@ -587,13 +618,11 @@ ecma_make_uint32_value (uint32_t uint32_number) /**< uint32 number to be encoded
* *
* @return ecma-value representation of the string argument * @return ecma-value representation of the string argument
*/ */
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_make_string_value (const ecma_string_t *ecma_string_p) /**< string to reference in value */ ecma_make_string_value (const ecma_string_t *ecma_string_p) /**< string to reference in value */
{ {
JERRY_ASSERT (ecma_string_p != NULL); JERRY_ASSERT (ecma_string_p != NULL);
#if ENABLED (JERRY_ES2015)
JERRY_ASSERT (!ecma_prop_name_is_symbol ((ecma_string_t *) ecma_string_p)); JERRY_ASSERT (!ecma_prop_name_is_symbol ((ecma_string_t *) ecma_string_p));
#endif /* ENABLED (JERRY_ES2015) */
if ((((uintptr_t) ecma_string_p) & ECMA_VALUE_TYPE_MASK) != 0) if ((((uintptr_t) ecma_string_p) & ECMA_VALUE_TYPE_MASK) != 0)
{ {
@@ -603,13 +632,12 @@ ecma_make_string_value (const ecma_string_t *ecma_string_p) /**< string to refer
return ecma_pointer_to_ecma_value (ecma_string_p) | ECMA_TYPE_STRING; return ecma_pointer_to_ecma_value (ecma_string_p) | ECMA_TYPE_STRING;
} /* ecma_make_string_value */ } /* ecma_make_string_value */
#if ENABLED (JERRY_ES2015)
/** /**
* Symbol value constructor * Symbol value constructor
* *
* @return ecma-value representation of the string argument * @return ecma-value representation of the string argument
*/ */
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p) /**< symbol to reference in value */ ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p) /**< symbol to reference in value */
{ {
JERRY_ASSERT (ecma_symbol_p != NULL); JERRY_ASSERT (ecma_symbol_p != NULL);
@@ -617,24 +645,21 @@ ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p) /**< symbol to refer
return ecma_pointer_to_ecma_value (ecma_symbol_p) | ECMA_TYPE_SYMBOL; return ecma_pointer_to_ecma_value (ecma_symbol_p) | ECMA_TYPE_SYMBOL;
} /* ecma_make_symbol_value */ } /* ecma_make_symbol_value */
#endif /* ENABLED (JERRY_ES2015) */
/** /**
* Property-name value constructor * Property-name value constructor
* *
* @return ecma-value representation of a property name argument * @return ecma-value representation of a property name argument
*/ */
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property name to reference in value */ ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property name to reference in value */
{ {
JERRY_ASSERT (ecma_prop_name_p != NULL); JERRY_ASSERT (ecma_prop_name_p != NULL);
#if ENABLED (JERRY_ES2015)
if (ecma_prop_name_is_symbol ((ecma_string_t *) ecma_prop_name_p)) if (ecma_prop_name_is_symbol ((ecma_string_t *) ecma_prop_name_p))
{ {
return ecma_make_symbol_value (ecma_prop_name_p); return ecma_make_symbol_value (ecma_prop_name_p);
} }
#endif /* ENABLED (JERRY_ES2015) */
return ecma_make_string_value (ecma_prop_name_p); return ecma_make_string_value (ecma_prop_name_p);
} /* ecma_make_prop_name_value */ } /* ecma_make_prop_name_value */
@@ -644,7 +669,7 @@ ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property
* *
* @return ecma-value representation of the string argument * @return ecma-value representation of the string argument
*/ */
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */ ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */
{ {
return (ecma_value_t) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC, (uintptr_t) id); return (ecma_value_t) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC, (uintptr_t) id);
@@ -655,7 +680,7 @@ ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */
* *
* @return ecma-value representation of the object argument * @return ecma-value representation of the object argument
*/ */
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_make_object_value (const ecma_object_t *object_p) /**< object to reference in value */ ecma_make_object_value (const ecma_object_t *object_p) /**< object to reference in value */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@@ -668,20 +693,25 @@ ecma_make_object_value (const ecma_object_t *object_p) /**< object to reference
* *
* @return ecma-value representation of the Error reference * @return ecma-value representation of the Error reference
*/ */
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_make_error_reference_value (const ecma_error_reference_t *error_ref_p) /**< error reference */ ecma_make_extended_primitive_value (const ecma_extended_primitive_t *primitve_p, /**< extended primitve value */
uint32_t type) /**< ecma type of extended primitve value */
{ {
JERRY_ASSERT (error_ref_p != NULL); JERRY_ASSERT (primitve_p != NULL);
#if JERRY_BUILTIN_BIGINT
JERRY_ASSERT (primitve_p != ECMA_BIGINT_POINTER_TO_ZERO);
#endif /* JERRY_BUILTIN_BIGINT */
JERRY_ASSERT (type == ECMA_TYPE_BIGINT || type == ECMA_TYPE_ERROR);
return ecma_pointer_to_ecma_value (error_ref_p) | ECMA_TYPE_ERROR; return ecma_pointer_to_ecma_value (primitve_p) | type;
} /* ecma_make_error_reference_value */ } /* ecma_make_extended_primitive_value */
/** /**
* Get integer value from an integer ecma value * Get integer value from an integer ecma value
* *
* @return integer value * @return integer value
*/ */
inline ecma_integer_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline ecma_integer_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_get_integer_from_value (ecma_value_t value) /**< ecma value */ ecma_get_integer_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_integer_number (value)); JERRY_ASSERT (ecma_is_value_integer_number (value));
@@ -694,7 +724,7 @@ ecma_get_integer_from_value (ecma_value_t value) /**< ecma value */
* *
* @return floating point value * @return floating point value
*/ */
inline ecma_number_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_number_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_float_from_value (ecma_value_t value) /**< ecma value */ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT); JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -707,7 +737,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
* *
* @return floating point value * @return floating point value
*/ */
inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_number_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */ ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT); JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -736,7 +766,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the string pointer * @return the string pointer
*/ */
inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_string (value)); JERRY_ASSERT (ecma_is_value_string (value));
@@ -749,27 +779,25 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value); return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_string_from_value */ } /* ecma_get_string_from_value */
#if ENABLED (JERRY_ES2015)
/** /**
* Get pointer to ecma-string from ecma value * Get pointer to ecma-string from ecma value
* *
* @return the string pointer * @return the string pointer
*/ */
inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */ ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_symbol (value)); JERRY_ASSERT (ecma_is_value_symbol (value));
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value); return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_symbol_from_value */ } /* ecma_get_symbol_from_value */
#endif /* ENABLED (JERRY_ES2015) */
/** /**
* Get pointer to a property name from ecma value * Get pointer to a property name from ecma value
* *
* @return the string pointer * @return the string pointer
*/ */
inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_prop_name (value)); JERRY_ASSERT (ecma_is_value_prop_name (value));
@@ -787,7 +815,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the pointer * @return the pointer
*/ */
inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_object (value)); JERRY_ASSERT (ecma_is_value_object (value));
@@ -800,20 +828,24 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the pointer * @return the pointer
*/ */
inline ecma_error_reference_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_extended_primitive_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_error_reference_from_value (ecma_value_t value) /**< ecma value */ ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR); #if JERRY_BUILTIN_BIGINT
JERRY_ASSERT (value != ECMA_BIGINT_ZERO);
#endif /* JERRY_BUILTIN_BIGINT */
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT
|| ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
return (ecma_error_reference_t *) ecma_get_pointer_from_ecma_value (value); return (ecma_extended_primitive_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_error_reference_from_value */ } /* ecma_get_extended_primitive_from_value */
/** /**
* Invert a boolean value * Invert a boolean value
* *
* @return ecma value * @return ecma value
*/ */
inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */ ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_boolean (value)); JERRY_ASSERT (ecma_is_value_boolean (value));
@@ -827,31 +859,39 @@ ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
* @return copy of the given value * @return copy of the given value
*/ */
ecma_value_t ecma_value_t
ecma_copy_value (ecma_value_t value) /**< value description */ ecma_copy_value (ecma_value_t value) /**< value description */
{ {
switch (ecma_get_value_type_field (value)) switch (ecma_get_value_type_field (value))
{ {
case ECMA_TYPE_FLOAT: case ECMA_TYPE_FLOAT:
{ {
ecma_number_t *num_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (value); ecma_number_t *num_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (value);
ecma_number_t *new_num_p = ecma_alloc_number ();
return ecma_create_float_number (*num_p); *new_num_p = *num_p;
return ecma_make_float_value (new_num_p);
} }
case ECMA_TYPE_SYMBOL:
case ECMA_TYPE_STRING: case ECMA_TYPE_STRING:
{ {
ecma_ref_ecma_string (ecma_get_string_from_value (value)); ecma_string_t *string_p = (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
ecma_ref_ecma_string_non_direct (string_p);
return value; return value;
} }
#if ENABLED (JERRY_ES2015) #if JERRY_BUILTIN_BIGINT
case ECMA_TYPE_SYMBOL: case ECMA_TYPE_BIGINT:
{ {
ecma_ref_ecma_string (ecma_get_symbol_from_value (value)); if (value != ECMA_BIGINT_ZERO)
{
ecma_ref_extended_primitive (ecma_get_extended_primitive_from_value (value));
}
return value; return value;
} }
#endif /* ENABLED (JERRY_ES2015) */ #endif /* JERRY_BUILTIN_BIGINT */
case ECMA_TYPE_OBJECT: case ECMA_TYPE_OBJECT:
{ {
ecma_ref_object (ecma_get_object_from_value (value)); ecma_ref_object_inline (ecma_get_object_from_value (value));
return value; return value;
} }
default: default:
@@ -875,8 +915,8 @@ ecma_copy_value (ecma_value_t value) /**< value description */
* *
* @return copy of the given value * @return copy of the given value
*/ */
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_fast_copy_value (ecma_value_t value) /**< value description */ ecma_fast_copy_value (ecma_value_t value) /**< value description */
{ {
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value); return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value);
} /* ecma_fast_copy_value */ } /* ecma_fast_copy_value */
@@ -886,7 +926,7 @@ ecma_fast_copy_value (ecma_value_t value) /**< value description */
* *
* @return copy of the given value * @return copy of the given value
*/ */
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */ ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */
{ {
if (!ecma_is_value_object (value)) if (!ecma_is_value_object (value))
@@ -900,7 +940,7 @@ ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */
/** /**
* Increase reference counter of a value if it is an object. * Increase reference counter of a value if it is an object.
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_ref_if_object (ecma_value_t value) /**< value description */ ecma_ref_if_object (ecma_value_t value) /**< value description */
{ {
if (ecma_is_value_object (value)) if (ecma_is_value_object (value))
@@ -912,7 +952,7 @@ ecma_ref_if_object (ecma_value_t value) /**< value description */
/** /**
* Decrease reference counter of a value if it is an object. * Decrease reference counter of a value if it is an object.
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_deref_if_object (ecma_value_t value) /**< value description */ ecma_deref_if_object (ecma_value_t value) /**< value description */
{ {
if (ecma_is_value_object (value)) if (ecma_is_value_object (value))
@@ -931,8 +971,7 @@ void
ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
ecma_value_t ecma_value) /**< value to assign */ ecma_value_t ecma_value) /**< value to assign */
{ {
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, ecma_type_direct_must_be_zero_for_the_next_check);
ecma_type_direct_must_be_zero_for_the_next_check);
if (*value_p == ecma_value) if (*value_p == ecma_value)
{ {
@@ -943,8 +982,7 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
{ {
*value_p = ecma_value; *value_p = ecma_value;
} }
else if (ecma_is_value_float_number (ecma_value) else if (ecma_is_value_float_number (ecma_value) && ecma_is_value_float_number (*value_p))
&& ecma_is_value_float_number (*value_p))
{ {
const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value); const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value);
ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p); ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p);
@@ -1056,26 +1094,29 @@ ecma_free_value (ecma_value_t value) /**< value description */
ecma_dealloc_number (number_p); ecma_dealloc_number (number_p);
break; break;
} }
case ECMA_TYPE_SYMBOL:
case ECMA_TYPE_STRING: case ECMA_TYPE_STRING:
{ {
ecma_string_t *string_p = ecma_get_string_from_value (value); ecma_string_t *string_p = (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
ecma_deref_ecma_string (string_p); ecma_deref_ecma_string_non_direct (string_p);
break; break;
} }
#if ENABLED (JERRY_ES2015)
case ECMA_TYPE_SYMBOL:
{
ecma_deref_ecma_string (ecma_get_symbol_from_value (value));
break;
}
#endif /* ENABLED (JERRY_ES2015) */
case ECMA_TYPE_OBJECT: case ECMA_TYPE_OBJECT:
{ {
ecma_deref_object (ecma_get_object_from_value (value)); ecma_deref_object (ecma_get_object_from_value (value));
break; break;
} }
#if JERRY_BUILTIN_BIGINT
case ECMA_TYPE_BIGINT:
{
if (value != ECMA_BIGINT_ZERO)
{
ecma_deref_bigint (ecma_get_extended_primitive_from_value (value));
}
break;
}
#endif /* JERRY_BUILTIN_BIGINT */
default: default:
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT
@@ -1096,7 +1137,7 @@ ecma_free_value (ecma_value_t value) /**< value description */
* It also increases the binary size so it is recommended for * It also increases the binary size so it is recommended for
* critical code paths only. * critical code paths only.
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_fast_free_value (ecma_value_t value) /**< value description */ ecma_fast_free_value (ecma_value_t value) /**< value description */
{ {
if (ecma_get_value_type_field (value) != ECMA_TYPE_DIRECT) if (ecma_get_value_type_field (value) != ECMA_TYPE_DIRECT)
@@ -1117,10 +1158,19 @@ ecma_free_value_if_not_object (ecma_value_t value) /**< value description */
} }
} /* ecma_free_value_if_not_object */ } /* ecma_free_value_if_not_object */
/**
* Free an ecma-value object
*/
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_free_object (ecma_value_t value) /**< value description */
{
ecma_deref_object (ecma_get_object_from_value (value));
} /* ecma_free_object */
/** /**
* Free an ecma-value number * Free an ecma-value number
*/ */
inline void JERRY_ATTR_ALWAYS_INLINE extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_free_number (ecma_value_t value) /**< value description */ ecma_free_number (ecma_value_t value) /**< value description */
{ {
JERRY_ASSERT (ecma_is_value_number (value)); JERRY_ASSERT (ecma_is_value_number (value));
@@ -1169,12 +1219,16 @@ ecma_get_typeof_lit_id (ecma_value_t value) /**< input ecma value */
{ {
ret_value = LIT_MAGIC_STRING_STRING; ret_value = LIT_MAGIC_STRING_STRING;
} }
#if ENABLED (JERRY_ES2015)
else if (ecma_is_value_symbol (value)) else if (ecma_is_value_symbol (value))
{ {
ret_value = LIT_MAGIC_STRING_SYMBOL; ret_value = LIT_MAGIC_STRING_SYMBOL;
} }
#endif /* ENABLED (JERRY_ES2015) */ #if JERRY_BUILTIN_BIGINT
else if (ecma_is_value_bigint (value))
{
ret_value = LIT_MAGIC_STRING_BIGINT;
}
#endif /* JERRY_BUILTIN_BIGINT */
else else
{ {
JERRY_ASSERT (ecma_is_value_object (value)); JERRY_ASSERT (ecma_is_value_object (value));
File diff suppressed because it is too large Load Diff
+154 -150
View File
@@ -17,6 +17,7 @@
#define ECMA_HELPERS_H #define ECMA_HELPERS_H
#include "ecma-globals.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
#include "lit-strings.h" #include "lit-strings.h"
@@ -47,8 +48,8 @@
* Set value of non-null compressed pointer so that it will correspond * Set value of non-null compressed pointer so that it will correspond
* to specified non_compressed_pointer. * to specified non_compressed_pointer.
*/ */
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \ #define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, non_compressed_pointer)
/** /**
* Set value of pointer-tag value so that it will correspond * Set value of pointer-tag value so that it will correspond
@@ -88,37 +89,38 @@
*/ */
typedef enum typedef enum
{ {
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */ ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */ ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
ECMA_STRING_FLAG_REHASH_NEEDED = (1 << 1), /**< The hash of the string must be recalculated. ECMA_STRING_FLAG_REHASH_NEEDED = (1 << 1), /**< The hash of the string must be recalculated.
* For more details see ecma_append_chars_to_string */ * For more details see ecma_append_chars_to_string */
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */ ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */ ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
} ecma_string_flag_t; } ecma_string_flag_t;
/**
* Underscore is ignored when this option is passed.
*/
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
/** /**
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer. * Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
*/ */
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \ #define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
utf8_ptr, /**< [out] output buffer pointer */ \ utf8_ptr, /**< [out] output buffer pointer */ \
utf8_str_size) /**< [out] output buffer size */ \ utf8_str_size) /**< [out] output buffer size */ \
lit_utf8_size_t utf8_str_size; \ lit_utf8_size_t utf8_str_size; \
uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \ uint8_t utf8_ptr##flags = ECMA_STRING_FLAG_EMPTY; \
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, \ const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, NULL, NULL, &utf8_ptr##flags);
&utf8_str_size, \
NULL, \
NULL, \
&utf8_ptr ## flags);
/** /**
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING' * Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
*/ */
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \ #define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
utf8_str_size) /**< buffer size */ \ utf8_str_size) /**< buffer size */ \
if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \ if (utf8_ptr##flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
{ \ { \
JERRY_ASSERT (utf8_ptr != NULL); \ JERRY_ASSERT (utf8_ptr != NULL); \
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \ jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
} }
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY #ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
@@ -126,52 +128,54 @@ typedef enum
/** /**
* Set an internal property value from pointer. * Set an internal property value from pointer.
*/ */
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
(field) = ((ecma_value_t) pointer)
/** /**
* Set an internal property value from pointer. Pointer can be NULL. * Set an internal property value from pointer. Pointer can be NULL.
*/ */
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
(field) = ((ecma_value_t) pointer)
/** /**
* Convert an internal property value to pointer. * Convert an internal property value to pointer.
*/ */
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ((type *) field)
((type *) field)
/** /**
* Convert an internal property value to pointer. Result can be NULL. * Convert an internal property value to pointer. Result can be NULL.
*/ */
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ((type *) field)
((type *) field)
/**
* Checks whether an internal property is NULL.
*/
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) NULL))
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
/** /**
* Set an internal property value from pointer. * Set an internal property value from pointer.
*/ */
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
ECMA_SET_NON_NULL_POINTER (field, pointer)
/** /**
* Set an internal property value from pointer. Pointer can be NULL. * Set an internal property value from pointer. Pointer can be NULL.
*/ */
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ECMA_SET_POINTER (field, pointer)
ECMA_SET_POINTER (field, pointer)
/** /**
* Convert an internal property value to pointer. * Convert an internal property value to pointer.
*/ */
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ECMA_GET_NON_NULL_POINTER (type, field)
ECMA_GET_NON_NULL_POINTER (type, field)
/** /**
* Convert an internal property value to pointer. Result can be NULL. * Convert an internal property value to pointer. Result can be NULL.
*/ */
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ECMA_GET_POINTER (type, field)
ECMA_GET_POINTER (type, field)
/**
* Checks whether an internal property is NULL.
*/
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
@@ -180,18 +184,6 @@ typedef enum
*/ */
#define ECMA_BOOL_TO_BITFIELD(x) ((x) ? 1 : 0) #define ECMA_BOOL_TO_BITFIELD(x) ((x) ? 1 : 0)
#if ENABLED (JERRY_ES2015)
/**
* JERRY_ASSERT compatible macro for checking whether the given ecma-value is symbol
*/
#define ECMA_ASSERT_VALUE_IS_SYMBOL(value) (ecma_is_value_symbol ((value)))
#else /* !ENABLED (JERRY_ES2015) */
/**
* JERRY_ASSERT compatible macro for checking whether the given ecma-value is symbol
*/
#define ECMA_ASSERT_VALUE_IS_SYMBOL(value) (false)
#endif /* ENABLED (JERRY_ES2015) */
/** /**
* Check whether the given type is ECMA_OBJECT_TYPE_PROXY * Check whether the given type is ECMA_OBJECT_TYPE_PROXY
* *
@@ -204,11 +196,11 @@ typedef enum
* *
* @param obj_p ecma-object * @param obj_p ecma-object
*/ */
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY) #if JERRY_BUILTIN_PROXY
#define ECMA_OBJECT_IS_PROXY(obj_p) (ECMA_OBJECT_TYPE_IS_PROXY (ecma_get_object_type ((obj_p)))) #define ECMA_OBJECT_IS_PROXY(obj_p) (ECMA_OBJECT_TYPE_IS_PROXY (ecma_get_object_type ((obj_p))))
#else /* !ENABLED (JERRY_ES2015_BUILTIN_PROXY) */ #else /* !JERRY_BUILTIN_PROXY */
#define ECMA_OBJECT_IS_PROXY(obj_p) (false) #define ECMA_OBJECT_IS_PROXY(obj_p) (false)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */ #endif /* JERRY_BUILTIN_PROXY */
/* ecma-helpers-value.c */ /* ecma-helpers-value.c */
ecma_type_t JERRY_ATTR_CONST ecma_get_value_type_field (ecma_value_t value); ecma_type_t JERRY_ATTR_CONST ecma_get_value_type_field (ecma_value_t value);
@@ -228,14 +220,14 @@ bool JERRY_ATTR_CONST ecma_are_values_integer_numbers (ecma_value_t first_value,
bool JERRY_ATTR_CONST ecma_is_value_float_number (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_float_number (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_number (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_number (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_string (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_string (ecma_value_t value);
#if ENABLED (JERRY_ES2015)
bool JERRY_ATTR_CONST ecma_is_value_symbol (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_symbol (ecma_value_t value);
#endif /* ENABLED (JERRY_ES2015) */ bool JERRY_ATTR_CONST ecma_is_value_magic_string (ecma_value_t value, lit_magic_string_id_t id);
bool JERRY_ATTR_CONST ecma_is_value_bigint (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_prop_name (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_prop_name (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_direct_string (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_direct_string (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_non_direct_string (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_non_direct_string (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_object (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_object (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_error_reference (ecma_value_t value); bool JERRY_ATTR_CONST ecma_is_value_exception (ecma_value_t value);
ecma_value_t ecma_is_value_array (ecma_value_t arg); ecma_value_t ecma_is_value_array (ecma_value_t arg);
void ecma_check_value_type_is_spec_defined (ecma_value_t value); void ecma_check_value_type_is_spec_defined (ecma_value_t value);
@@ -244,28 +236,26 @@ ecma_value_t JERRY_ATTR_CONST ecma_make_boolean_value (bool boolean_value);
ecma_value_t JERRY_ATTR_CONST ecma_make_integer_value (ecma_integer_value_t integer_value); ecma_value_t JERRY_ATTR_CONST ecma_make_integer_value (ecma_integer_value_t integer_value);
ecma_value_t ecma_make_nan_value (void); ecma_value_t ecma_make_nan_value (void);
ecma_value_t ecma_make_float_value (ecma_number_t *ecma_num_p); ecma_value_t ecma_make_float_value (ecma_number_t *ecma_num_p);
ecma_value_t ecma_make_length_value (ecma_length_t length);
ecma_value_t ecma_make_number_value (ecma_number_t ecma_number); ecma_value_t ecma_make_number_value (ecma_number_t ecma_number);
ecma_value_t ecma_make_int32_value (int32_t int32_number); ecma_value_t ecma_make_int32_value (int32_t int32_number);
ecma_value_t ecma_make_uint32_value (uint32_t uint32_number); ecma_value_t ecma_make_uint32_value (uint32_t uint32_number);
ecma_value_t JERRY_ATTR_PURE ecma_make_string_value (const ecma_string_t *ecma_string_p); ecma_value_t JERRY_ATTR_PURE ecma_make_string_value (const ecma_string_t *ecma_string_p);
#if ENABLED (JERRY_ES2015)
ecma_value_t JERRY_ATTR_PURE ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p); ecma_value_t JERRY_ATTR_PURE ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p);
#endif /* ENABLED (JERRY_ES2015) */
ecma_value_t JERRY_ATTR_PURE ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p); ecma_value_t JERRY_ATTR_PURE ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p);
ecma_value_t JERRY_ATTR_PURE ecma_make_magic_string_value (lit_magic_string_id_t id); ecma_value_t JERRY_ATTR_PURE ecma_make_magic_string_value (lit_magic_string_id_t id);
ecma_value_t JERRY_ATTR_PURE ecma_make_object_value (const ecma_object_t *object_p); ecma_value_t JERRY_ATTR_PURE ecma_make_object_value (const ecma_object_t *object_p);
ecma_value_t JERRY_ATTR_PURE ecma_make_error_reference_value (const ecma_error_reference_t *error_ref_p); ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_extended_primitive_t *primitve_p,
uint32_t type);
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value); ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value); ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
ecma_number_t * ecma_get_pointer_from_float_value (ecma_value_t value); ecma_number_t *ecma_get_pointer_from_float_value (ecma_value_t value);
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value); ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value); ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
#if ENABLED (JERRY_ES2015)
ecma_string_t JERRY_ATTR_PURE *ecma_get_symbol_from_value (ecma_value_t value); ecma_string_t JERRY_ATTR_PURE *ecma_get_symbol_from_value (ecma_value_t value);
#endif /* ENABLED (JERRY_ES2015) */
ecma_string_t JERRY_ATTR_PURE *ecma_get_prop_name_from_value (ecma_value_t value); ecma_string_t JERRY_ATTR_PURE *ecma_get_prop_name_from_value (ecma_value_t value);
ecma_object_t JERRY_ATTR_PURE *ecma_get_object_from_value (ecma_value_t value); ecma_object_t JERRY_ATTR_PURE *ecma_get_object_from_value (ecma_value_t value);
ecma_error_reference_t JERRY_ATTR_PURE *ecma_get_error_reference_from_value (ecma_value_t value); ecma_extended_primitive_t JERRY_ATTR_PURE *ecma_get_extended_primitive_from_value (ecma_value_t value);
ecma_value_t JERRY_ATTR_CONST ecma_invert_boolean_value (ecma_value_t value); ecma_value_t JERRY_ATTR_CONST ecma_invert_boolean_value (ecma_value_t value);
ecma_value_t ecma_copy_value (ecma_value_t value); ecma_value_t ecma_copy_value (ecma_value_t value);
ecma_value_t ecma_fast_copy_value (ecma_value_t value); ecma_value_t ecma_fast_copy_value (ecma_value_t value);
@@ -278,64 +268,52 @@ void ecma_value_assign_number (ecma_value_t *value_p, ecma_number_t ecma_number)
void ecma_free_value (ecma_value_t value); void ecma_free_value (ecma_value_t value);
void ecma_fast_free_value (ecma_value_t value); void ecma_fast_free_value (ecma_value_t value);
void ecma_free_value_if_not_object (ecma_value_t value); void ecma_free_value_if_not_object (ecma_value_t value);
void ecma_free_object (ecma_value_t value);
void ecma_free_number (ecma_value_t value); void ecma_free_number (ecma_value_t value);
lit_magic_string_id_t ecma_get_typeof_lit_id (ecma_value_t value); lit_magic_string_id_t ecma_get_typeof_lit_id (ecma_value_t value);
/* ecma-helpers-string.c */ /* ecma-helpers-string.c */
#if ENABLED (JERRY_ES2015)
ecma_string_t *ecma_new_symbol_from_descriptor_string (ecma_value_t string_desc); ecma_string_t *ecma_new_symbol_from_descriptor_string (ecma_value_t string_desc);
bool ecma_prop_name_is_symbol (ecma_string_t *string_p); bool ecma_prop_name_is_symbol (ecma_string_t *string_p);
uint32_t ecma_op_advance_string_index (ecma_string_t *str_p, uint32_t index, bool is_unicode); ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t index_num, bool is_unicode);
#endif /* ENABLED (JERRY_ES2015) */ #if JERRY_BUILTIN_CONTAINER
#if ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET)
ecma_string_t *ecma_new_map_key_string (ecma_value_t value); ecma_string_t *ecma_new_map_key_string (ecma_value_t value);
bool ecma_prop_name_is_map_key (ecma_string_t *string_p); bool ecma_prop_name_is_map_key (ecma_string_t *string_p);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) */ #endif /* JERRY_BUILTIN_CONTAINER */
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size); ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p, ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p,
lit_utf8_size_t string_size); lit_utf8_size_t string_size);
ecma_string_t *
ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, void *user_p);
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit); ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
#if ENABLED (JERRY_ES2015)
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit); ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
#endif /* ENABLED (JERRY_ES2015) */ ecma_string_t *ecma_new_ecma_string_from_length (ecma_length_t index);
ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number); ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number);
ecma_string_t *ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number); ecma_string_t *ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number);
ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number); ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number);
ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num); ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num);
ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id); ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id);
ecma_string_t *ecma_get_internal_string (lit_magic_string_id_t id);
ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p, ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p,
const lit_utf8_byte_t *cesu8_string2_p, const lit_utf8_byte_t *cesu8_string2_p,
lit_utf8_size_t cesu8_string2_size, lit_utf8_size_t cesu8_string2_size,
lit_utf8_size_t cesu8_string2_length); lit_utf8_size_t cesu8_string2_length);
ecma_string_t *ecma_concat_ecma_strings (ecma_string_t *string1_p, ecma_string_t *string2_p); ecma_string_t *ecma_concat_ecma_strings (ecma_string_t *string1_p, ecma_string_t *string2_p);
void ecma_ref_ecma_string (ecma_string_t *string_p); void ecma_ref_ecma_string (ecma_string_t *string_p);
void ecma_ref_ecma_string_non_direct (ecma_string_t *string_p);
void ecma_deref_ecma_string (ecma_string_t *string_p); void ecma_deref_ecma_string (ecma_string_t *string_p);
void ecma_deref_ecma_string_non_direct (ecma_string_t *string_p);
void ecma_destroy_ecma_string (ecma_string_t *string_p); void ecma_destroy_ecma_string (ecma_string_t *string_p);
ecma_number_t ecma_string_to_number (const ecma_string_t *str_p); ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
uint32_t ecma_string_get_array_index (const ecma_string_t *str_p); uint32_t ecma_string_get_array_index (const ecma_string_t *str_p);
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_buffer (const ecma_string_t *string_desc_p,
ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size,
lit_utf8_size_t buffer_size); jerry_encoding_t encoding);
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT void
ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p, ecma_string_to_cesu8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
lit_utf8_size_t
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
ecma_length_t start_pos,
ecma_length_t end_pos,
lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
lit_utf8_size_t
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
ecma_length_t start_pos,
ecma_length_t end_pos,
lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p, const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p,
lit_utf8_size_t *size_p, lit_utf8_size_t *size_p,
lit_utf8_size_t *length_p, lit_utf8_size_t *length_p,
@@ -349,30 +327,33 @@ jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_p
ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp); ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp);
lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp); lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp);
uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp); uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp);
bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp, bool ecma_string_compare_to_property_name (ecma_property_t property,
jmem_cpointer_t prop_name_cp,
const ecma_string_t *string_p); const ecma_string_t *string_p);
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p); bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
bool ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p); bool ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p); bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
ecma_length_t ecma_string_get_length (const ecma_string_t *string_p); lit_utf8_size_t ecma_string_get_length (const ecma_string_t *string_p);
ecma_length_t ecma_string_get_utf8_length (const ecma_string_t *string_p); lit_utf8_size_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_size (const ecma_string_t *string_p); lit_utf8_size_t ecma_string_get_size (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_utf8_size (const ecma_string_t *string_p); lit_utf8_size_t ecma_string_get_utf8_size (const ecma_string_t *string_p);
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, ecma_length_t index); ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, lit_utf8_size_t index);
lit_magic_string_id_t ecma_get_string_magic (const ecma_string_t *string_p); lit_magic_string_id_t ecma_get_string_magic (const ecma_string_t *string_p);
lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p); lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, ecma_length_t start_pos, ecma_length_t end_pos); ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
lit_utf8_size_t *utf8_str_size); const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, lit_utf8_size_t *utf8_str_size);
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p); ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
ecma_value_t
ecma_string_pad (ecma_value_t original_string_p, ecma_value_t max_length, ecma_value_t fill_string, bool pad_on_start);
ecma_stringbuilder_t ecma_stringbuilder_create (void); ecma_stringbuilder_t ecma_stringbuilder_create (void);
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p); ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, const lit_utf8_size_t data_size);
const lit_utf8_size_t data_size);
lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p); lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p);
lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p); lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p);
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size); void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
@@ -381,6 +362,7 @@ void ecma_stringbuilder_append_magic (ecma_stringbuilder_t *builder_p, const lit
void ecma_stringbuilder_append_raw (ecma_stringbuilder_t *builder_p, void ecma_stringbuilder_append_raw (ecma_stringbuilder_t *builder_p,
const lit_utf8_byte_t *data_p, const lit_utf8_byte_t *data_p,
const lit_utf8_size_t data_size); const lit_utf8_size_t data_size);
void ecma_stringbuilder_append_codepoint (ecma_stringbuilder_t *builder_p, lit_code_point_t cp);
void ecma_stringbuilder_append_char (ecma_stringbuilder_t *builder_p, const ecma_char_t c); void ecma_stringbuilder_append_char (ecma_stringbuilder_t *builder_p, const ecma_char_t c);
void ecma_stringbuilder_append_byte (ecma_stringbuilder_t *builder_p, const lit_utf8_byte_t); void ecma_stringbuilder_append_byte (ecma_stringbuilder_t *builder_p, const lit_utf8_byte_t);
ecma_string_t *ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p); ecma_string_t *ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p);
@@ -394,23 +376,16 @@ bool ecma_number_is_negative (ecma_number_t num);
bool ecma_number_is_zero (ecma_number_t num); bool ecma_number_is_zero (ecma_number_t num);
bool ecma_number_is_infinity (ecma_number_t num); bool ecma_number_is_infinity (ecma_number_t num);
bool ecma_number_is_finite (ecma_number_t num); bool ecma_number_is_finite (ecma_number_t num);
ecma_number_t
ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
ecma_number_t ecma_number_get_prev (ecma_number_t num); ecma_number_t ecma_number_get_prev (ecma_number_t num);
ecma_number_t ecma_number_get_next (ecma_number_t num); ecma_number_t ecma_number_get_next (ecma_number_t num);
ecma_number_t ecma_number_trunc (ecma_number_t num); ecma_number_t ecma_number_trunc (ecma_number_t num);
ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num); ecma_number_t ecma_number_remainder (ecma_number_t left_num, ecma_number_t right_num);
ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y); ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y);
ecma_value_t ecma_number_parse_int (const lit_utf8_byte_t *string_buff, ecma_value_t
lit_utf8_size_t string_buff_size, ecma_number_parse_int (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size, ecma_value_t radix);
ecma_value_t radix); ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size);
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff,
lit_utf8_size_t string_buff_size);
ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer); ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer);
lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p); lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p);
lit_utf8_size_t ecma_number_to_binary_floating_point_number (ecma_number_t num,
lit_utf8_byte_t *out_digits_p,
int32_t *out_decimal_exp_p);
/* ecma-helpers-collection.c */ /* ecma-helpers-collection.c */
ecma_collection_t *ecma_new_collection (void); ecma_collection_t *ecma_new_collection (void);
@@ -421,46 +396,63 @@ void ecma_collection_destroy (ecma_collection_t *collection_p);
void ecma_collection_free (ecma_collection_t *collection_p); void ecma_collection_free (ecma_collection_t *collection_p);
void ecma_collection_free_if_not_object (ecma_collection_t *collection_p); void ecma_collection_free_if_not_object (ecma_collection_t *collection_p);
void ecma_collection_free_objects (ecma_collection_t *collection_p); void ecma_collection_free_objects (ecma_collection_t *collection_p);
void ecma_collection_free_template_literal (ecma_collection_t *collection_p);
bool ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p);
bool ecma_collection_has_string_value (ecma_collection_t *collection_p, ecma_string_t *string_p);
ecma_value_t *ecma_new_compact_collection (void);
ecma_value_t *ecma_compact_collection_push_back (ecma_value_t *compact_collection_p, ecma_value_t value);
ecma_value_t *ecma_compact_collection_shrink (ecma_value_t *compact_collection_p);
void ecma_compact_collection_free (ecma_value_t *compact_collection_p);
ecma_value_t *ecma_compact_collection_end (ecma_value_t *compact_collection_p);
void ecma_compact_collection_destroy (ecma_value_t *compact_collection_p);
/* ecma-helpers.c */ /* ecma-helpers.c */
ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type); ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type);
ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p); ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p);
ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p, ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p);
ecma_lexical_environment_type_t type); ecma_object_t *ecma_create_lex_env_class (ecma_object_t *outer_lexical_environment_p, size_t lexical_env_size);
bool JERRY_ATTR_PURE ecma_is_lexical_environment (const ecma_object_t *object_p); bool JERRY_ATTR_PURE ecma_is_lexical_environment (const ecma_object_t *object_p);
void ecma_op_ordinary_object_set_extensible (ecma_object_t *object_p); void ecma_op_ordinary_object_set_extensible (ecma_object_t *object_p);
ecma_object_type_t JERRY_ATTR_PURE ecma_get_object_type (const ecma_object_t *object_p); ecma_object_type_t JERRY_ATTR_PURE ecma_get_object_type (const ecma_object_t *object_p);
bool JERRY_ATTR_PURE ecma_get_object_is_builtin (const ecma_object_t *object_p); ecma_object_base_type_t JERRY_ATTR_PURE ecma_get_object_base_type (const ecma_object_t *object_p);
void ecma_set_object_is_builtin (ecma_object_t *object_p); bool JERRY_ATTR_PURE ecma_object_class_is (ecma_object_t *object_p, ecma_object_class_type_t class_id);
uint8_t ecma_get_object_builtin_id (ecma_object_t *object_p);
ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecma_object_t *object_p); ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecma_object_t *object_p);
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p); ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values); ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
ecma_property_value_t * ecma_property_value_t *ecma_create_named_data_property (ecma_object_t *object_p,
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes, ecma_string_t *name_p,
ecma_property_t **out_prop_p); uint8_t prop_attributes,
ecma_property_value_t * ecma_property_t **out_prop_p);
ecma_create_named_accessor_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_object_t *get_p, ecma_property_value_t *ecma_create_named_accessor_property (ecma_object_t *object_p,
ecma_object_t *set_p, uint8_t prop_attributes, ecma_property_t **out_prop_p); ecma_string_t *name_p,
ecma_property_t * ecma_object_t *get_p,
ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p); ecma_object_t *set_p,
ecma_property_value_t * uint8_t prop_attributes,
ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p); ecma_property_t **out_prop_p);
#if JERRY_MODULE_SYSTEM
void ecma_free_property (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p); void ecma_create_named_reference_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_value_t reference);
#endif /* JERRY_MODULE_SYSTEM */
ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
ecma_property_value_t *ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p); void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
void ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, void
ecma_value_t value); ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
ecma_getter_setter_pointers_t * ecma_getter_setter_pointers_t *ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p); void ecma_set_named_accessor_property_getter (ecma_object_t *object_p,
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p, ecma_property_value_t *prop_value_p,
ecma_object_t *getter_p); ecma_object_t *getter_p);
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p, void ecma_set_named_accessor_property_setter (ecma_object_t *object_p,
ecma_property_value_t *prop_value_p,
ecma_object_t *setter_p); ecma_object_t *setter_p);
#if JERRY_MODULE_SYSTEM
ecma_value_t ecma_property_to_reference (ecma_property_t *property_p);
ecma_property_value_t *ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p);
#endif /* JERRY_MODULE_SYSTEM */
bool ecma_is_property_writable (ecma_property_t property); bool ecma_is_property_writable (ecma_property_t property);
void ecma_set_property_writable_attr (ecma_property_t *property_p, bool is_writable); void ecma_set_property_writable_attr (ecma_property_t *property_p, bool is_writable);
bool ecma_is_property_enumerable (ecma_property_t property); bool ecma_is_property_enumerable (ecma_property_t property);
@@ -468,42 +460,54 @@ void ecma_set_property_enumerable_attr (ecma_property_t *property_p, bool is_enu
bool ecma_is_property_configurable (ecma_property_t property); bool ecma_is_property_configurable (ecma_property_t property);
void ecma_set_property_configurable_attr (ecma_property_t *property_p, bool is_configurable); void ecma_set_property_configurable_attr (ecma_property_t *property_p, bool is_configurable);
#if ENABLED (JERRY_LCACHE) #if JERRY_LCACHE
bool ecma_is_property_lcached (ecma_property_t *property_p); bool ecma_is_property_lcached (ecma_property_t *property_p);
void ecma_set_property_lcached (ecma_property_t *property_p, bool is_lcached); void ecma_set_property_lcached (ecma_property_t *property_p, bool is_lcached);
#endif /* ENABLED (JERRY_LCACHE) */ #endif /* JERRY_LCACHE */
ecma_property_descriptor_t ecma_make_empty_property_descriptor (void); ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p); void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p);
ecma_value_t ecma_create_error_reference (ecma_value_t value, bool is_exception); void ecma_ref_extended_primitive (ecma_extended_primitive_t *primitve_p);
ecma_value_t ecma_create_error_reference_from_context (void); void ecma_deref_exception (ecma_extended_primitive_t *exception_p);
ecma_value_t ecma_create_error_object_reference (ecma_object_t *object_p); #if JERRY_BUILTIN_BIGINT
void ecma_ref_error_reference (ecma_error_reference_t *error_ref_p); void ecma_deref_bigint (ecma_extended_primitive_t *bigint_p);
void ecma_deref_error_reference (ecma_error_reference_t *error_ref_p); #endif /* JERRY_BUILTIN_BIGINT */
void ecma_raise_error_from_error_reference (ecma_value_t value);
ecma_value_t ecma_create_exception (ecma_value_t value, uint32_t options);
ecma_value_t ecma_create_exception_from_context (void);
ecma_value_t ecma_create_exception_from_object (ecma_object_t *object_p);
void ecma_throw_exception (ecma_value_t value);
void ecma_script_deref (ecma_value_t script_value);
void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p); void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p);
void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p); void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
#if ENABLED (JERRY_ES2015) ecma_value_t ecma_script_get_from_value (ecma_value_t value);
ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
#endif /* ENABLED (JERRY_ES2015) */
#if ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ES2015)
ecma_length_t ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_p);
ecma_value_t *ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p); ecma_value_t *ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p);
ecma_value_t *ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p); ecma_value_t *ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p);
#endif /* ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ES2015) */ ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
#if JERRY_LINE_INFO
uint8_t *ecma_compiled_code_get_line_info (const ecma_compiled_code_t *bytecode_header_p);
#endif /* JERRY_LINE_INFO */
ecma_value_t ecma_get_source_name (const ecma_compiled_code_t *bytecode_p);
#if (JERRY_STACK_LIMIT != 0) #if (JERRY_STACK_LIMIT != 0)
uintptr_t ecma_get_current_stack_usage (void); uintptr_t ecma_get_current_stack_usage (void);
#endif /* (JERRY_STACK_LIMIT != 0) */ #endif /* (JERRY_STACK_LIMIT != 0) */
/* ecma-helpers-external-pointers.c */ /* ecma-helpers-external-pointers.c */
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p, void *info_p); bool ecma_create_native_pointer_property (ecma_object_t *obj_p,
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, void *info_p); void *native_p,
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, void *info_p); const jerry_object_native_info_t *native_info_p);
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p,
const jerry_object_native_info_t *native_info_p);
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_info_p);
/* ecma-helpers-conversion.c */ /* ecma-helpers-conversion.c */
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size); ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
ecma_number_t ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p,
lit_utf8_size_t str_size,
uint32_t radix,
uint32_t option);
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size); lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
uint32_t ecma_number_to_uint32 (ecma_number_t num); uint32_t ecma_number_to_uint32 (ecma_number_t num);
int32_t ecma_number_to_int32 (ecma_number_t num); int32_t ecma_number_to_int32 (ecma_number_t num);
+25 -17
View File
@@ -13,14 +13,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-init-finalize.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-init-finalize.h"
#include "ecma-lex-env.h" #include "ecma-lex-env.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "jmem.h"
#include "jcontext.h" #include "jcontext.h"
#include "jmem.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -46,24 +48,23 @@ ecma_init (void)
ecma_init_global_environment (); ecma_init_global_environment ();
#if ENABLED (JERRY_PROPRETY_HASHMAP) #if JERRY_PROPERTY_HASHMAP
JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_ON; JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_ON;
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_HIGH_PRESSURE_GC; JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_HIGH_PRESSURE_GC;
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */ #endif /* JERRY_PROPERTY_HASHMAP */
#if (JERRY_STACK_LIMIT != 0) #if (JERRY_STACK_LIMIT != 0)
volatile int sp; volatile int sp;
JERRY_CONTEXT (stack_base) = (uintptr_t) &sp; JERRY_CONTEXT (stack_base) = (uintptr_t) &sp;
#endif /* (JERRY_STACK_LIMIT != 0) */ #endif /* (JERRY_STACK_LIMIT != 0) */
#if ENABLED (JERRY_ES2015_BUILTIN_PROMISE)
ecma_job_queue_init (); ecma_job_queue_init ();
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
#if ENABLED (JERRY_ES2015) JERRY_CONTEXT (current_new_target_p) = NULL;
JERRY_CONTEXT (current_new_target) = NULL;
JERRY_CONTEXT (current_function_obj_p) = NULL; #if JERRY_BUILTIN_TYPEDARRAY
#endif /* ENABLED (JERRY_ES2015) */ JERRY_CONTEXT (arraybuffer_compact_allocation_limit) = 256;
#endif /* JERRY_BUILTIN_TYPEDARRAY */
} /* ecma_init */ } /* ecma_init */
/** /**
@@ -72,23 +73,30 @@ ecma_init (void)
void void
ecma_finalize (void) ecma_finalize (void)
{ {
#if ENABLED (JERRY_ES2015) JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) == NULL);
JERRY_ASSERT (JERRY_CONTEXT (current_new_target) == NULL);
JERRY_ASSERT (JERRY_CONTEXT (current_function_obj_p) == NULL);
#endif /* ENABLED (JERRY_ES2015) */
ecma_finalize_global_environment (); ecma_finalize_global_environment ();
uint8_t runs = 0; uint8_t runs = 0;
do do
{ {
ecma_finalize_builtins ();
ecma_gc_run (); ecma_gc_run ();
if (++runs >= JERRY_GC_LOOP_LIMIT) if (++runs >= JERRY_GC_LOOP_LIMIT)
{ {
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS); jerry_fatal (JERRY_FATAL_UNTERMINATED_GC_LOOPS);
}
} while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
for (uint32_t i = 0; i < ECMA_BUILTIN_GLOBAL_SYMBOL_COUNT; i++)
{
if (global_symbols_cp[i] != JMEM_CP_NULL)
{
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t, global_symbols_cp[i]));
} }
} }
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
ecma_finalize_lit_storage (); ecma_finalize_lit_storage ();
} /* ecma_finalize */ } /* ecma_finalize */
+17 -21
View File
@@ -13,10 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-lcache.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lcache.h"
#include "jcontext.h" #include "jcontext.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -26,16 +28,16 @@
* @{ * @{
*/ */
#if ENABLED (JERRY_LCACHE) #if JERRY_LCACHE
/** /**
* Bitshift index for calculating hash. * Bitshift index for calculating hash.
*/ */
#if ENABLED (JERRY_CPOINTER_32_BIT) #if JERRY_CPOINTER_32_BIT
#define ECMA_LCACHE_HASH_BITSHIFT_INDEX (2 * JMEM_ALIGNMENT_LOG) #define ECMA_LCACHE_HASH_BITSHIFT_INDEX (2 * JMEM_ALIGNMENT_LOG)
#else /* !ENABLED (JERRY_CPOINTER_32_BIT) */ #else /* !JERRY_CPOINTER_32_BIT */
#define ECMA_LCACHE_HASH_BITSHIFT_INDEX 0 #define ECMA_LCACHE_HASH_BITSHIFT_INDEX 0
#endif /* ENABLED (JERRY_CPOINTER_32_BIT) */ #endif /* JERRY_CPOINTER_32_BIT */
/** /**
* Mask for hash bits * Mask for hash bits
@@ -91,16 +93,14 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (prop_p != NULL && !ecma_is_property_lcached (prop_p)); JERRY_ASSERT (prop_p != NULL && !ecma_is_property_lcached (prop_p));
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
jmem_cpointer_t object_cp; jmem_cpointer_t object_cp;
ECMA_SET_NON_NULL_POINTER (object_cp, object_p); ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
size_t row_index = ecma_lcache_row_index (object_cp, name_cp); size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index]; ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH; ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
do do
@@ -111,8 +111,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
} }
entry_p++; entry_p++;
} } while (entry_p < entry_end_p);
while (entry_p < entry_end_p);
/* Invalidate the last entry. */ /* Invalidate the last entry. */
ecma_lcache_invalidate_entry (--entry_p); ecma_lcache_invalidate_entry (--entry_p);
@@ -138,7 +137,7 @@ insert:
* @return a pointer to an ecma_property_t if the lookup is successful * @return a pointer to an ecma_property_t if the lookup is successful
* NULL otherwise * NULL otherwise
*/ */
inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_property_t *JERRY_ATTR_ALWAYS_INLINE
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
const ecma_string_t *prop_name_p) /**< property's name */ const ecma_string_t *prop_name_p) /**< property's name */
{ {
@@ -163,7 +162,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp); size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp);
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index]; ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH; ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp); ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp);
@@ -175,8 +174,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
return entry_p->prop_p; return entry_p->prop_p;
} }
entry_p++; entry_p++;
} } while (entry_p < entry_end_p);
while (entry_p < entry_end_p);
return NULL; return NULL;
} /* ecma_lcache_lookup */ } /* ecma_lcache_lookup */
@@ -191,20 +189,18 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (prop_p != NULL && ecma_is_property_lcached (prop_p)); JERRY_ASSERT (prop_p != NULL && ecma_is_property_lcached (prop_p));
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
jmem_cpointer_t object_cp; jmem_cpointer_t object_cp;
ECMA_SET_NON_NULL_POINTER (object_cp, object_p); ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
size_t row_index = ecma_lcache_row_index (object_cp, name_cp); size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index]; ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
while (true) while (true)
{ {
/* The property must be present. */ /* The property must be present. */
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH); JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache)[row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
if (entry_p->id != 0 && entry_p->prop_p == prop_p) if (entry_p->id != 0 && entry_p->prop_p == prop_p)
{ {
@@ -217,7 +213,7 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
} }
} /* ecma_lcache_invalidate */ } /* ecma_lcache_invalidate */
#endif /* ENABLED (JERRY_LCACHE) */ #endif /* JERRY_LCACHE */
/** /**
* @} * @}
+4 -2
View File
@@ -23,12 +23,14 @@
* @{ * @{
*/ */
#if ENABLED (JERRY_LCACHE) #include "ecma-globals.h"
#if JERRY_LCACHE
void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p); void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p); ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p);
void ecma_lcache_invalidate (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p); void ecma_lcache_invalidate (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
#endif /* ENABLED (JERRY_LCACHE) */ #endif /* JERRY_LCACHE */
/** /**
* @} * @}
+271
View File
@@ -0,0 +1,271 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-line-info.h"
#include "ecma-helpers.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmalineinfo Line info
* @{
*/
#if JERRY_LINE_INFO
/* The layout of the structure is defined in js-parser-line-info-create.c */
JERRY_STATIC_ASSERT ((ECMA_LINE_INFO_COLUMN_DEFAULT - 1) == ((ECMA_LINE_INFO_ENCODE_TWO_BYTE >> 1) - 1),
ecma_line_info_column_1_must_be_accessible_with_the_highest_one_byte_negative_value);
/**
* Decodes an uint32_t number, and updates the buffer position.
* Numbers expected to be larger values.
*
* @return the decoded value
*/
uint32_t
ecma_line_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
{
uint8_t *source_p = *buffer_p;
uint32_t value = 0;
do
{
value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK);
} while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
*buffer_p = source_p;
return value;
} /* ecma_line_info_decode_vlq */
/**
* Decodes an uint32_t number, and updates the buffer position.
* Numbers expected to be smaller values.
*
* @return the decoded value
*/
static uint32_t
ecma_line_info_decode_small (uint8_t **buffer_p) /**< [in/out] target buffer */
{
uint8_t *source_p = *buffer_p;
uint32_t type = source_p[0];
*buffer_p = source_p + 1;
if (type < ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN)
{
return type;
}
if (type == ECMA_LINE_INFO_ENCODE_TWO_BYTE)
{
*buffer_p = source_p + 2;
return ((uint32_t) source_p[1]) + ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN;
}
JERRY_ASSERT (type == ECMA_LINE_INFO_ENCODE_VLQ);
return ecma_line_info_decode_vlq (buffer_p) + ECMA_LINE_INFO_ENCODE_VLQ_MIN;
} /* ecma_line_info_decode_small */
/**
* Updates a value using an encoded difference.
*
* @return updated value
*/
extern inline uint32_t JERRY_ATTR_ALWAYS_INLINE
ecma_line_info_difference_update (uint32_t current_value, /**< current value */
uint32_t difference_value) /**< encoded difference */
{
if ((difference_value & 0x1) == ECMA_LINE_INFO_INCREASE)
{
return current_value + (difference_value >> 1) + 1;
}
return current_value - (difference_value >> 1);
} /* ecma_line_info_difference_update */
/**
* Release line info data.
*/
void
ecma_line_info_free (uint8_t *line_info_p) /**< line info buffer */
{
uint8_t *source_p = line_info_p;
uint32_t total_length = ecma_line_info_decode_vlq (&source_p);
jmem_heap_free_block (line_info_p, total_length + (uint32_t) (source_p - line_info_p));
} /* ecma_line_info_free */
/**
* Returns the line/column information for a given byte code offset.
*/
void
ecma_line_info_get (uint8_t *line_info_p, /**< line info buffer */
uint32_t offset, /**< byte code offset */
jerry_frame_location_t *location_p) /**< [out] location */
{
uint32_t line = 1;
uint32_t column = ECMA_LINE_INFO_COLUMN_DEFAULT;
uint32_t end_offset = 0;
uint32_t end_offset_increase;
uint32_t value;
/* Skip total_length. */
ecma_line_info_decode_vlq (&line_info_p);
while (true)
{
value = ecma_line_info_decode_vlq (&line_info_p);
line = ecma_line_info_difference_update (line, value);
if (*line_info_p == 0)
{
break;
}
uint8_t *size_p = line_info_p + *line_info_p + (ECMA_LINE_INFO_STREAM_SIZE_MIN + 1);
uint32_t next_end_offset = end_offset + ecma_line_info_decode_vlq (&size_p);
if (offset < next_end_offset)
{
break;
}
end_offset = next_end_offset;
line_info_p = size_p;
}
line_info_p++;
do
{
end_offset_increase = ecma_line_info_decode_small (&line_info_p);
if (end_offset_increase & ECMA_LINE_INFO_HAS_LINE)
{
value = ecma_line_info_decode_small (&line_info_p);
line = ecma_line_info_difference_update (line, value);
column = ECMA_LINE_INFO_COLUMN_DEFAULT;
}
end_offset_increase >>= 1;
value = ecma_line_info_decode_small (&line_info_p);
column = ecma_line_info_difference_update (column, value);
end_offset += end_offset_increase;
} while (end_offset_increase != 0 && end_offset <= offset);
location_p->line = line;
location_p->column = column;
} /* ecma_line_info_get */
#if JERRY_PARSER_DUMP_BYTE_CODE
/**
* Dumps line info data.
*/
void
ecma_line_info_dump (uint8_t *line_info_p) /**< dumps line info data */
{
bool block_last = false;
uint32_t block_line = 1;
uint32_t block_byte_code_offset = 0;
uint32_t value;
value = ecma_line_info_decode_vlq (&line_info_p);
JERRY_DEBUG_MSG ("\nLine info size: %d bytes\n", (int) value);
while (true)
{
value = ecma_line_info_decode_vlq (&line_info_p);
block_line = ecma_line_info_difference_update (block_line, value);
JERRY_DEBUG_MSG ("\nNew block: line: %d", (int) block_line);
if (*line_info_p == 0)
{
JERRY_DEBUG_MSG (" StreamLength: [last]\n");
block_last = true;
}
else
{
uint8_t *size_p = line_info_p + *line_info_p + (ECMA_LINE_INFO_STREAM_SIZE_MIN + 1);
value = ecma_line_info_decode_vlq (&size_p);
JERRY_DEBUG_MSG (" StreamLength: %d ByteCodeSize: %d\n",
(int) (*line_info_p + ECMA_LINE_INFO_STREAM_SIZE_MIN),
(int) value);
}
line_info_p++;
uint32_t stream_line = block_line;
uint32_t stream_column = ECMA_LINE_INFO_COLUMN_DEFAULT;
uint32_t stream_end_offset = block_byte_code_offset;
while (true)
{
uint32_t stream_end_offset_increase = ecma_line_info_decode_small (&line_info_p);
if (stream_end_offset_increase & ECMA_LINE_INFO_HAS_LINE)
{
value = ecma_line_info_decode_small (&line_info_p);
stream_line = ecma_line_info_difference_update (stream_line, value);
stream_column = ECMA_LINE_INFO_COLUMN_DEFAULT;
}
stream_end_offset_increase >>= 1;
value = ecma_line_info_decode_small (&line_info_p);
stream_column = ecma_line_info_difference_update (stream_column, value);
if (stream_end_offset_increase == 0)
{
JERRY_DEBUG_MSG (" ByteCodeEndOffset: [unterminated] Line: %d Column: %d\n",
(int) stream_line,
(int) stream_column);
break;
}
stream_end_offset += stream_end_offset_increase;
JERRY_DEBUG_MSG (" ByteCodeEndOffset: %d Line: %d Column: %d\n",
(int) stream_end_offset,
(int) stream_line,
(int) stream_column);
}
if (block_last)
{
break;
}
block_byte_code_offset += ecma_line_info_decode_vlq (&line_info_p);
}
} /* ecma_line_info_dump */
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#endif /* JERRY_LINE_INFO */
/**
* @}
* @}
*/
+114
View File
@@ -0,0 +1,114 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ECMA_LINE_INFO_H
#define ECMA_LINE_INFO_H
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmalineinfo Line info
* @{
*/
#if JERRY_LINE_INFO
#include "ecma-globals.h"
/**
* Increase the current value of line or column.
*/
#define ECMA_LINE_INFO_INCREASE 0x0
/**
* Decrease the current value of line or column.
*/
#define ECMA_LINE_INFO_DECREASE 0x1
/**
* Line update is present.
*/
#define ECMA_LINE_INFO_HAS_LINE 0x1
/**
* A default value for columns after a line update.
*/
#define ECMA_LINE_INFO_COLUMN_DEFAULT 127
/**
* Vlq encoding: flag which is set for all bytes except the last one.
*/
#define ECMA_LINE_INFO_VLQ_CONTINUE 0x80
/**
* Vlq encoding: mask to decode the number fragment.
*/
#define ECMA_LINE_INFO_VLQ_MASK 0x7f
/**
* Vlq encoding: number of bits stored in a byte.
*/
#define ECMA_LINE_INFO_VLQ_SHIFT 7
/**
* Small encoding: a value which represents a two byte long number.
*/
#define ECMA_LINE_INFO_ENCODE_TWO_BYTE (UINT8_MAX - 1)
/**
* Small encoding: minimum value of an encoded two byte long number.
*/
#define ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN (UINT8_MAX - 1)
/**
* Small encoding: a value which represents a three byte long number.
*/
#define ECMA_LINE_INFO_ENCODE_VLQ UINT8_MAX
/**
* Small encoding: minimum value of an encoded three byte long number.
*/
#define ECMA_LINE_INFO_ENCODE_VLQ_MIN (ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN + UINT8_MAX + 1)
/**
* Maximum number of line/column entries stored in a stream.
*/
#define ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX 48
/**
* Minimum size of a stream (except the last one).
*/
#define ECMA_LINE_INFO_STREAM_SIZE_MIN ((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
/* Helper functions for parser/js/js-parser-line-info-create.c. */
uint32_t ecma_line_info_decode_vlq (uint8_t **buffer_p);
uint32_t ecma_line_info_difference_update (uint32_t current_value, uint32_t difference_value);
/* General functions. */
void ecma_line_info_free (uint8_t *line_info_p);
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, jerry_frame_location_t *location_p);
#if JERRY_PARSER_DUMP_BYTE_CODE
void ecma_line_info_dump (uint8_t *line_info_p);
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
#endif /* JERRY_LINE_INFO */
/**
* @}
* @}
*/
#endif /* !ECMA_LINE_INFO_H */
+207 -57
View File
@@ -13,9 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-alloc.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "ecma-alloc.h"
#include "ecma-big-uint.h"
#include "ecma-bigint.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jcontext.h" #include "jcontext.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -25,7 +29,6 @@
* @{ * @{
*/ */
#if ENABLED (JERRY_ES2015)
/** /**
* Free symbol list * Free symbol list
*/ */
@@ -40,8 +43,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
{ {
if (symbol_list_p->values[i] != JMEM_CP_NULL) if (symbol_list_p->values[i] != JMEM_CP_NULL)
{ {
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, symbol_list_p->values[i]);
symbol_list_p->values[i]);
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p)); JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
ecma_deref_ecma_string (string_p); ecma_deref_ecma_string (string_p);
@@ -53,7 +55,6 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
symbol_list_cp = next_item_cp; symbol_list_cp = next_item_cp;
} }
} /* ecma_free_symbol_list */ } /* ecma_free_symbol_list */
#endif /* ENABLED (JERRY_ES2015) */
/** /**
* Free string list * Free string list
@@ -69,8 +70,7 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
{ {
if (string_list_p->values[i] != JMEM_CP_NULL) if (string_list_p->values[i] != JMEM_CP_NULL)
{ {
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
string_list_p->values[i]);
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p)); JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
ecma_destroy_ecma_string (string_p); ecma_destroy_ecma_string (string_p);
@@ -87,39 +87,69 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
* Free number list * Free number list
*/ */
static void static void
ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< string list */ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
{ {
while (number_list_cp != JMEM_CP_NULL) while (number_list_cp != JMEM_CP_NULL)
{ {
ecma_number_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_storage_item_t, ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
number_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{ {
if (number_list_p->values[i] != JMEM_CP_NULL) if (number_list_p->values[i] != JMEM_CP_NULL)
{ {
ecma_number_t *num_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]); ecma_dealloc_number (JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]));
ecma_dealloc_number (num_p);
} }
} }
jmem_cpointer_t next_item_cp = number_list_p->next_cp; jmem_cpointer_t next_item_cp = number_list_p->next_cp;
jmem_pools_free (number_list_p, sizeof (ecma_number_storage_item_t)); jmem_pools_free (number_list_p, sizeof (ecma_lit_storage_item_t));
number_list_cp = next_item_cp; number_list_cp = next_item_cp;
} }
} /* ecma_free_number_list */ } /* ecma_free_number_list */
#if JERRY_BUILTIN_BIGINT
/**
* Free bigint list
*/
static void
ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
{
while (bigint_list_cp != JMEM_CP_NULL)
{
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{
if (bigint_list_p->values[i] != JMEM_CP_NULL)
{
ecma_extended_primitive_t *bigint_p =
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
ecma_deref_bigint (bigint_p);
}
}
jmem_cpointer_t next_item_cp = bigint_list_p->next_cp;
jmem_pools_free (bigint_list_p, sizeof (ecma_lit_storage_item_t));
bigint_list_cp = next_item_cp;
}
} /* ecma_free_bigint_list */
#endif /* JERRY_BUILTIN_BIGINT */
/** /**
* Finalize literal storage * Finalize literal storage
*/ */
void void
ecma_finalize_lit_storage (void) ecma_finalize_lit_storage (void)
{ {
#if ENABLED (JERRY_ES2015)
ecma_free_symbol_list (JERRY_CONTEXT (symbol_list_first_cp)); ecma_free_symbol_list (JERRY_CONTEXT (symbol_list_first_cp));
#endif /* ENABLED (JERRY_ES2015) */
ecma_free_string_list (JERRY_CONTEXT (string_list_first_cp)); ecma_free_string_list (JERRY_CONTEXT (string_list_first_cp));
ecma_free_number_list (JERRY_CONTEXT (number_list_first_cp)); ecma_free_number_list (JERRY_CONTEXT (number_list_first_cp));
#if JERRY_BUILTIN_BIGINT
ecma_free_bigint_list (JERRY_CONTEXT (bigint_list_first_cp));
#endif /* JERRY_BUILTIN_BIGINT */
} /* ecma_finalize_lit_storage */ } /* ecma_finalize_lit_storage */
/** /**
@@ -129,9 +159,11 @@ ecma_finalize_lit_storage (void)
*/ */
ecma_value_t ecma_value_t
ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string to be searched */ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string to be searched */
lit_utf8_size_t size) /**< size of the string */ lit_utf8_size_t size, /**< size of the string */
bool is_ascii) /**< encode of the string */
{ {
ecma_string_t *string_p = ecma_new_ecma_string_from_utf8 (chars_p, size); ecma_string_t *string_p =
(is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) : ecma_new_ecma_string_from_utf8 (chars_p, size));
if (ECMA_IS_DIRECT_STRING (string_p)) if (ECMA_IS_DIRECT_STRING (string_p))
{ {
@@ -156,8 +188,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
} }
else else
{ {
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
string_list_p->values[i]);
if (ecma_compare_ecma_strings (string_p, value_p)) if (ecma_compare_ecma_strings (string_p, value_p))
{ {
@@ -199,7 +230,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
/** /**
* Find or create a literal number. * Find or create a literal number.
* *
* @return ecma_string_t compressed pointer * @return ecma value
*/ */
ecma_value_t ecma_value_t
ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */
@@ -218,8 +249,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
while (number_list_cp != JMEM_CP_NULL) while (number_list_cp != JMEM_CP_NULL)
{ {
ecma_number_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_storage_item_t, ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
number_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{ {
@@ -232,8 +262,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
} }
else else
{ {
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
number_list_p->values[i]);
if (*number_p == number_arg) if (*number_p == number_arg)
{ {
@@ -246,10 +275,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
number_list_cp = number_list_p->next_cp; number_list_cp = number_list_p->next_cp;
} }
ecma_number_t *num_p = ecma_get_pointer_from_float_value (num);
jmem_cpointer_t result; jmem_cpointer_t result;
JMEM_CP_SET_NON_NULL_POINTER (result, num_p); JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_pointer_from_float_value (num));
if (empty_cpointer_p != NULL) if (empty_cpointer_p != NULL)
{ {
@@ -257,8 +284,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
return num; return num;
} }
ecma_number_storage_item_t *new_item_p; ecma_lit_storage_item_t *new_item_p;
new_item_p = (ecma_number_storage_item_t *) jmem_pools_alloc (sizeof (ecma_number_storage_item_t)); new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
new_item_p->values[0] = result; new_item_p->values[0] = result;
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
@@ -272,6 +299,82 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
return num; return num;
} /* ecma_find_or_create_literal_number */ } /* ecma_find_or_create_literal_number */
#if JERRY_BUILTIN_BIGINT
/**
* Find or create a literal BigInt.
*
* @return BigInt value
*/
ecma_value_t
ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searched */
{
JERRY_ASSERT (ecma_is_value_bigint (bigint));
if (bigint == ECMA_BIGINT_ZERO)
{
return bigint;
}
jmem_cpointer_t bigint_list_cp = JERRY_CONTEXT (bigint_list_first_cp);
jmem_cpointer_t *empty_cpointer_p = NULL;
while (bigint_list_cp != JMEM_CP_NULL)
{
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{
if (bigint_list_p->values[i] == JMEM_CP_NULL)
{
if (empty_cpointer_p == NULL)
{
empty_cpointer_p = bigint_list_p->values + i;
}
}
else
{
ecma_extended_primitive_t *other_bigint_p =
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
{
ecma_free_value (bigint);
return other_bigint;
}
}
}
bigint_list_cp = bigint_list_p->next_cp;
}
jmem_cpointer_t result;
JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_extended_primitive_from_value (bigint));
if (empty_cpointer_p != NULL)
{
*empty_cpointer_p = result;
return bigint;
}
ecma_lit_storage_item_t *new_item_p;
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
new_item_p->values[0] = result;
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{
new_item_p->values[i] = JMEM_CP_NULL;
}
new_item_p->next_cp = JERRY_CONTEXT (bigint_list_first_cp);
JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (bigint_list_first_cp), new_item_p);
return bigint;
} /* ecma_find_or_create_literal_bigint */
#endif /* JERRY_BUILTIN_BIGINT */
/** /**
* Log2 of snapshot literal alignment. * Log2 of snapshot literal alignment.
*/ */
@@ -285,23 +388,35 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
/** /**
* Literal offset shift. * Literal offset shift.
*/ */
#define JERRY_SNAPSHOT_LITERAL_SHIFT (ECMA_VALUE_SHIFT + 1) #define JERRY_SNAPSHOT_LITERAL_SHIFT (ECMA_VALUE_SHIFT + 2)
/** /**
* Literal value is number. * Literal value is number.
*/ */
#define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT) #define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT)
#if ENABLED (JERRY_SNAPSHOT_SAVE) #if JERRY_BUILTIN_BIGINT
/**
* Literal value is BigInt.
*/
#define JERRY_SNAPSHOT_LITERAL_IS_BIGINT (2u << ECMA_VALUE_SHIFT)
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_SNAPSHOT_SAVE
/** /**
* Append the value at the end of the appropriate list if it is not present there. * Append the value at the end of the appropriate list if it is not present there.
*/ */
void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */ void
ecma_collection_t *lit_pool_p) /**< list of known values */ ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
ecma_collection_t *lit_pool_p) /**< list of known values */
{ {
/* Unlike direct numbers, direct strings are converted to character literals. */ /* Unlike direct numbers, direct strings are converted to character literals. */
if (!ecma_is_value_string (value) && !ecma_is_value_float_number (value)) if (!ecma_is_value_string (value)
#if JERRY_BUILTIN_BIGINT
&& (!ecma_is_value_bigint (value) || value == ECMA_BIGINT_ZERO)
#endif /* JERRY_BUILTIN_BIGINT */
&& !ecma_is_value_float_number (value))
{ {
return; return;
} }
@@ -334,7 +449,7 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
uint32_t const_literal_end; uint32_t const_literal_end;
uint32_t literal_end; uint32_t literal_end;
JERRY_ASSERT (compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION); JERRY_ASSERT (CBC_IS_FUNCTION (compiled_code_p->status_flags));
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS) if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{ {
@@ -374,11 +489,9 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
for (uint32_t i = const_literal_end; i < literal_end; i++) for (uint32_t i = const_literal_end; i < literal_end; i++)
{ {
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_p[i]);
literal_p[i]);
if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION) if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
&& bytecode_p != compiled_code_p)
{ {
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p); ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
} }
@@ -436,6 +549,15 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
{ {
lit_table_size += (uint32_t) sizeof (ecma_number_t); lit_table_size += (uint32_t) sizeof (ecma_number_t);
} }
#if JERRY_BUILTIN_BIGINT
else if (ecma_is_value_bigint (lit_buffer_p[i]))
{
ecma_extended_primitive_t *bigint_p = ecma_get_extended_primitive_from_value (lit_buffer_p[i]);
lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint32_t) + ECMA_BIGINT_GET_SIZE (bigint_p),
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
}
#endif /* JERRY_BUILTIN_BIGINT */
else else
{ {
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]); ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
@@ -453,7 +575,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
} }
lit_mem_to_snapshot_id_map_entry_t *map_p; lit_mem_to_snapshot_id_map_entry_t *map_p;
ecma_length_t total_count = lit_pool_p->item_count; uint32_t total_count = lit_pool_p->item_count;
map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t)); map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
@@ -475,7 +597,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
map_p->literal_id = lit_buffer_p[i]; map_p->literal_id = lit_buffer_p[i];
map_p->literal_offset = (literal_offset << JERRY_SNAPSHOT_LITERAL_SHIFT) | ECMA_TYPE_SNAPSHOT_OFFSET; map_p->literal_offset = (literal_offset << JERRY_SNAPSHOT_LITERAL_SHIFT) | ECMA_TYPE_SNAPSHOT_OFFSET;
ecma_length_t length; lit_utf8_size_t length;
if (ecma_is_value_float_number (lit_buffer_p[i])) if (ecma_is_value_float_number (lit_buffer_p[i]))
{ {
@@ -486,6 +608,20 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
length = JERRY_ALIGNUP (sizeof (ecma_number_t), JERRY_SNAPSHOT_LITERAL_ALIGNMENT); length = JERRY_ALIGNUP (sizeof (ecma_number_t), JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
} }
#if JERRY_BUILTIN_BIGINT
else if (ecma_is_value_bigint (lit_buffer_p[i]))
{
map_p->literal_offset |= JERRY_SNAPSHOT_LITERAL_IS_BIGINT;
ecma_extended_primitive_t *bigint_p = ecma_get_extended_primitive_from_value (lit_buffer_p[i]);
uint32_t size = ECMA_BIGINT_GET_SIZE (bigint_p);
memcpy (destination_p, &bigint_p->u.bigint_sign_and_size, sizeof (uint32_t));
memcpy (destination_p + sizeof (uint32_t), ECMA_BIGINT_GET_DIGITS (bigint_p, 0), size);
length = JERRY_ALIGNUP (sizeof (uint32_t) + size, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
}
#endif /* JERRY_BUILTIN_BIGINT */
else else
{ {
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]); ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
@@ -493,7 +629,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
*(uint16_t *) destination_p = (uint16_t) length; *(uint16_t *) destination_p = (uint16_t) length;
ecma_string_to_utf8_bytes (string_p, destination_p + sizeof (uint16_t), length); ecma_string_to_cesu8_bytes (string_p, destination_p + sizeof (uint16_t), length);
length = JERRY_ALIGNUP (sizeof (uint16_t) + length, JERRY_SNAPSHOT_LITERAL_ALIGNMENT); length = JERRY_ALIGNUP (sizeof (uint16_t) + length, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
} }
@@ -509,9 +645,9 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
return true; return true;
} /* ecma_save_literals_for_snapshot */ } /* ecma_save_literals_for_snapshot */
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */ #endif /* JERRY_SNAPSHOT_SAVE */
#if ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) #if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
/** /**
* Get the compressed pointer of a given literal. * Get the compressed pointer of a given literal.
@@ -533,22 +669,43 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
return ecma_find_or_create_literal_number (num); return ecma_find_or_create_literal_number (num);
} }
#if JERRY_BUILTIN_BIGINT
if (literal_value & JERRY_SNAPSHOT_LITERAL_IS_BIGINT)
{
uint32_t bigint_sign_and_size = *(uint32_t *) literal_p;
uint32_t size = bigint_sign_and_size & ~(uint32_t) (sizeof (ecma_bigint_digit_t) - 1);
ecma_extended_primitive_t *bigint_p = ecma_bigint_create (size);
if (bigint_p == NULL)
{
jerry_fatal (JERRY_FATAL_OUT_OF_MEMORY);
}
/* Only the sign bit can differ. */
JERRY_ASSERT (bigint_p->u.bigint_sign_and_size == (bigint_sign_and_size & ~(uint32_t) ECMA_BIGINT_SIGN));
bigint_p->u.bigint_sign_and_size = bigint_sign_and_size;
memcpy (ECMA_BIGINT_GET_DIGITS (bigint_p, 0), literal_p + sizeof (uint32_t), size);
return ecma_find_or_create_literal_bigint (ecma_make_extended_primitive_value (bigint_p, ECMA_TYPE_BIGINT));
}
#endif /* JERRY_BUILTIN_BIGINT */
uint16_t length = *(const uint16_t *) literal_p; uint16_t length = *(const uint16_t *) literal_p;
return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length); return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length, false);
} /* ecma_snapshot_get_literal */ } /* ecma_snapshot_get_literal */
/** /**
* Compute the start of the serializable ecma-values of the bytecode * Compute the start of the serializable ecma-values of the bytecode
* Related values: * Related values:
* - function argument names, if CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED is present * - function argument names, if CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED is present
* - function name, if CBC_CODE_FLAGS_CLASS_CONSTRUCTOR is not present and ES2015 profile is enabled * - function name, if CBC_CODE_FLAGS_CLASS_CONSTRUCTOR is not present and es.next profile is enabled
* - resource name, if JERRY_RESOURCE_NAME is enabled
* *
* @return pointer to the beginning of the serializable ecma-values * @return pointer to the beginning of the serializable ecma-values
*/ */
ecma_value_t * ecma_value_t *
ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p, /**< compiled code */ ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, /**< compiled code */
uint8_t *bytecode_end_p) /**< end of the bytecode */ uint8_t *bytecode_end_p) /**< end of the bytecode */
{ {
ecma_value_t *base_p = (ecma_value_t *) bytecode_end_p; ecma_value_t *base_p = (ecma_value_t *) bytecode_end_p;
@@ -568,22 +725,15 @@ ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p
base_p -= argument_end; base_p -= argument_end;
} }
#if ENABLED (JERRY_ES2015)
/* function name */ /* function name */
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR)) if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
{ {
base_p--; base_p--;
} }
#endif /* ENABLED (JERRY_ES2015) */
#if ENABLED (JERRY_RESOURCE_NAME)
/* resource name */
base_p--;
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
return base_p; return base_p;
} /* ecma_snapshot_resolve_serializable_values */ } /* ecma_snapshot_resolve_serializable_values */
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */ #endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
/** /**
* @} * @}
+20 -15
View File
@@ -17,6 +17,7 @@
#define ECMA_LIT_STORAGE_H #define ECMA_LIT_STORAGE_H
#include "ecma-globals.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
#include "lit-globals.h" #include "lit-globals.h"
@@ -27,7 +28,7 @@
* @{ * @{
*/ */
#if ENABLED (JERRY_SNAPSHOT_SAVE) #if JERRY_SNAPSHOT_SAVE
/** /**
* Snapshot literal - offset map * Snapshot literal - offset map
*/ */
@@ -36,28 +37,32 @@ typedef struct
ecma_value_t literal_id; /**< literal id */ ecma_value_t literal_id; /**< literal id */
ecma_value_t literal_offset; /**< literal offset */ ecma_value_t literal_offset; /**< literal offset */
} lit_mem_to_snapshot_id_map_entry_t; } lit_mem_to_snapshot_id_map_entry_t;
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */ #endif /* JERRY_SNAPSHOT_SAVE */
void ecma_finalize_lit_storage (void); void ecma_finalize_lit_storage (void);
ecma_value_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size); ecma_value_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size, bool is_ascii);
ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg); ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg);
#if JERRY_BUILTIN_BIGINT
ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
#endif /* JERRY_BUILTIN_BIGINT */
#if ENABLED (JERRY_SNAPSHOT_SAVE) #if JERRY_SNAPSHOT_SAVE
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p); void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, ecma_collection_t *lit_pool_p);
ecma_collection_t *lit_pool_p); bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p,
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size, uint32_t *buffer_p,
size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p, size_t buffer_size,
size_t *in_out_buffer_offset_p,
lit_mem_to_snapshot_id_map_entry_t **out_map_p,
uint32_t *out_map_len_p); uint32_t *out_map_len_p);
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */ #endif /* JERRY_SNAPSHOT_SAVE */
#if ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) #if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
ecma_value_t ecma_value_t ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value); ecma_value_t *ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p,
ecma_value_t * uint8_t *byte_code_end_p);
ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p); #endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */
/** /**
* @} * @}
File diff suppressed because it is too large Load Diff
+69 -81
View File
@@ -16,13 +16,23 @@
#ifndef ECMA_MODULE_H #ifndef ECMA_MODULE_H
#define ECMA_MODULE_H #define ECMA_MODULE_H
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
#include "common.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "common.h"
#if JERRY_MODULE_SYSTEM
#define ECMA_MODULE_MAX_PATH 255u #define ECMA_MODULE_MAX_PATH 255u
/**
* Module status flags.
*/
typedef enum
{
ECMA_MODULE_IS_NATIVE = (1 << 0), /**< native module */
ECMA_MODULE_HAS_NAMESPACE = (1 << 1), /**< namespace object has been initialized */
} ecma_module_flags_t;
/** /**
* Imported or exported names, such as "a as b" * Imported or exported names, such as "a as b"
* Note: See https://www.ecma-international.org/ecma-262/6.0/#table-39 * Note: See https://www.ecma-international.org/ecma-262/6.0/#table-39
@@ -31,70 +41,57 @@
typedef struct ecma_module_names typedef struct ecma_module_names
{ {
struct ecma_module_names *next_p; /**< next linked list node */ struct ecma_module_names *next_p; /**< next linked list node */
ecma_string_t *imex_name_p; /**< Import/export name of the item */ ecma_string_t *imex_name_p; /**< Import/export name of the item */
ecma_string_t *local_name_p; /**< Local name of the item */ ecma_string_t *local_name_p; /**< Local name of the item */
} ecma_module_names_t; } ecma_module_names_t;
typedef struct ecma_module ecma_module_t;
/**
* Module node to store imports / exports.
*/
typedef struct ecma_module_node
{
struct ecma_module_node *next_p; /**< next linked list node */
ecma_module_names_t *module_names_p; /**< names of the requested import/export node */
ecma_module_t *module_request_p; /**< module structure of the requested module */
} ecma_module_node_t;
/**
* Module context containing all import and export nodes.
*/
typedef struct ecma_module_context
{
struct ecma_module_context *parent_p; /**< parent context */
ecma_module_node_t *imports_p; /**< import item of the current context */
ecma_module_node_t *local_exports_p; /**< export item of the current context */
ecma_module_node_t *indirect_exports_p; /**< export item of the current context */
ecma_module_node_t *star_exports_p; /**< export item of the current context */
ecma_module_t *module_p; /**< module request */
} ecma_module_context_t;
/**
* An enum identifing the current state of the module
*/
typedef enum
{
ECMA_MODULE_STATE_INIT = 0, /**< module is initialized */
ECMA_MODULE_STATE_PARSING = 1, /**< module is currently being parsed */
ECMA_MODULE_STATE_PARSED = 2, /**< module has been parsed */
ECMA_MODULE_STATE_EVALUATING = 3, /**< module is currently being evaluated */
ECMA_MODULE_STATE_EVALUATED = 4, /**< module has been evaluated */
ECMA_MODULE_STATE_NATIVE = 5, /**< module is native */
} ecma_module_state_t;
/** /**
* Module structure storing an instance of a module * Module structure storing an instance of a module
*
* Note:
* The imports_p list follows the order of import-from/export-from statements in the source
* code of a module, even if a given module specifier is only used by export-from statements.
*/ */
struct ecma_module typedef struct ecma_module
{ {
struct ecma_module *next_p; /**< next linked list node */ /* Note: state is stored in header.u.class_prop.extra_info */
ecma_module_state_t state; /**< state of the mode */ ecma_extended_object_t header; /**< header part */
ecma_string_t *path_p; /**< path of the module */ /* TODO(dbatyai): These could be compressed pointers */
ecma_module_context_t *context_p; /**< module context of the module */ ecma_object_t *scope_p; /**< lexical lenvironment of the module */
ecma_compiled_code_t *compiled_code_p; /**< compiled code of the module */ ecma_object_t *namespace_object_p; /**< namespace object of the module */
ecma_object_t *scope_p; /**< lexica lenvironment of the module */ struct ecma_module_node *imports_p; /**< import requests of the module */
ecma_object_t *namespace_object_p; /**< namespace import object of the module */ ecma_module_names_t *local_exports_p; /**< local exports of the module */
}; struct ecma_module_node *indirect_exports_p; /**< indirect exports of the module */
struct ecma_module_node *star_exports_p; /**< star exports of the module */
/* Code used for evaluating a module */
union
{
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
jerry_native_module_evaluate_cb_t callback; /**< callback for evaluating native modules */
} u;
} ecma_module_t;
/** /**
* A record that can be used to store {module, identifier} pairs * Module node to store imports / exports.
*
* Note:
* Only one module node is created for each module specifier: the names are
* concatenated if the same specifier is used multiple times in the source code.
* However, multiple nodes are created for modules with multiple alias
* (for example ./a.mjs and ././a.mjs can refer to the same module).
*/ */
typedef struct ecma_module_record typedef struct ecma_module_node
{ {
ecma_module_t *module_p; /**< module */ struct ecma_module_node *next_p; /**< next linked list node */
ecma_string_t *name_p; /**< identifier name */ ecma_module_names_t *module_names_p; /**< names of the requested import/export node */
} ecma_module_record_t;
union
{
ecma_value_t path_or_module; /**< imports: module specifier (if string) or module reference (if object) */
ecma_value_t *module_object_p; /**< non-imports: reference to a path_or_module field in the imports */
} u;
} ecma_module_node_t;
/** /**
* A list of module records that can be used to identify circular imports during resolution * A list of module records that can be used to identify circular imports during resolution
@@ -102,7 +99,8 @@ typedef struct ecma_module_record
typedef struct ecma_module_resolve_set typedef struct ecma_module_resolve_set
{ {
struct ecma_module_resolve_set *next_p; /**< next in linked list */ struct ecma_module_resolve_set *next_p; /**< next in linked list */
ecma_module_record_t record; /**< module record */ ecma_module_t *module_p; /**< module */
ecma_string_t *name_p; /**< identifier name */
} ecma_module_resolve_set_t; } ecma_module_resolve_set_t;
/** /**
@@ -111,34 +109,24 @@ typedef struct ecma_module_resolve_set
typedef struct ecma_module_resolve_stack typedef struct ecma_module_resolve_stack
{ {
struct ecma_module_resolve_stack *next_p; /**< next in linked list */ struct ecma_module_resolve_stack *next_p; /**< next in linked list */
ecma_module_t *module_p; /**< module request */ ecma_module_t *module_p; /**< module request */
ecma_string_t *export_name_p; /**< export identifier name */ ecma_string_t *export_name_p; /**< export identifier name */
bool resolving; /**< flag storing wether the current frame started resolving */ bool resolving; /**< flag storing wether the current frame started resolving */
} ecma_module_resolve_stack_t; } ecma_module_resolve_stack_t;
bool ecma_module_resolve_set_insert (ecma_module_resolve_set_t **set_p, ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
ecma_module_t *const module_p, ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val);
ecma_string_t *const export_name_p);
void ecma_module_resolve_set_cleanup (ecma_module_resolve_set_t *set_p);
void ecma_module_resolve_stack_push (ecma_module_resolve_stack_t **stack_p, ecma_value_t ecma_module_link (ecma_module_t *module_p, jerry_module_resolve_cb_t callback_p, void *user_p);
ecma_module_t *const module_p, ecma_value_t ecma_module_evaluate (ecma_module_t *module_p);
ecma_string_t *const export_name_p); ecma_value_t ecma_module_import (ecma_value_t specifier, ecma_value_t user_value);
void ecma_module_resolve_stack_pop (ecma_module_resolve_stack_t **stack_p);
ecma_string_t *ecma_module_create_normalized_path (const uint8_t *char_p, ecma_module_t *ecma_module_create (void);
prop_length_t size); void ecma_module_cleanup_context (void);
ecma_module_t *ecma_module_find_module (ecma_string_t *const path_p);
ecma_module_t *ecma_module_create_native_module (ecma_string_t *const path_p,
ecma_object_t *const namespace_p);
ecma_module_t *ecma_module_find_or_create_module (ecma_string_t *const path_p);
ecma_value_t ecma_module_initialize_current (void); void ecma_module_release_module_names (ecma_module_names_t *module_name_p);
ecma_value_t ecma_module_parse_modules (void); void ecma_module_release_module (ecma_module_t *module_p);
ecma_value_t ecma_module_check_indirect_exports (void);
void ecma_module_release_module_nodes (ecma_module_node_t *module_node_p); #endif /* JERRY_MODULE_SYSTEM */
void ecma_module_cleanup (void);
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
#endif /* !ECMA_MODULE_H */ #endif /* !ECMA_MODULE_H */
+30 -33
View File
@@ -13,11 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-property-hashmap.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-property-hashmap.h"
#include "jrt-libc-includes.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt-libc-includes.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -26,7 +28,7 @@
* @{ * @{
*/ */
#if ENABLED (JERRY_PROPRETY_HASHMAP) #if JERRY_PROPERTY_HASHMAP
/** /**
* Compute the total size of the property hashmap. * Compute the total size of the property hashmap.
@@ -42,28 +44,26 @@
/** /**
* Stepping values for searching items in the hashmap. * Stepping values for searching items in the hashmap.
*/ */
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = {
{
3, 5, 7, 11, 13, 17, 19, 23 3, 5, 7, 11, 13, 17, 19, 23
}; };
/** /**
* Get the value of a bit in a bitmap. * Get the value of a bit in a bitmap.
*/ */
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) \ #define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) ((byte_p)[(index) >> 3] & (1 << ((index) &0x7)))
((byte_p)[(index) >> 3] & (1 << ((index) & 0x7)))
/** /**
* Clear the value of a bit in a bitmap. * Clear the value of a bit in a bitmap.
*/ */
#define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \ #define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) & 0x7)))) ((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) &0x7))))
/** /**
* Set the value of a bit in a bitmap. * Set the value of a bit in a bitmap.
*/ */
#define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \ #define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) & 0x7)))) ((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) &0x7))))
/** /**
* Create a new property hashmap for the object. * Create a new property hashmap for the object.
@@ -93,10 +93,9 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++) for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
{ {
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (prop_iter_p->types[i]); if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
if (type != ECMA_PROPERTY_TYPE_SPECIAL)
{ {
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
named_property_count++; named_property_count++;
} }
} }
@@ -148,15 +147,16 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++) for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
{ {
if (!ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i])) if (prop_iter_p->types[i] == ECMA_PROPERTY_TYPE_DELETED)
{ {
continue; continue;
} }
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p; ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], property_pair_p->names_cp[i]);
property_pair_p->names_cp[i]);
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)]; uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
entry_index &= mask; entry_index &= mask;
@@ -201,8 +201,8 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
/* Property hash must be exists and must be the first property. */ /* Property hash must be exists and must be the first property. */
JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL); JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL);
ecma_property_header_t *property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *property_p =
object_p->u1.property_list_cp); ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, object_p->u1.property_list_cp);
JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP); JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
@@ -210,8 +210,7 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
object_p->u1.property_list_cp = property_p->next_property_cp; object_p->u1.property_list_cp = property_p->next_property_cp;
jmem_heap_free_block (hashmap_p, jmem_heap_free_block (hashmap_p, ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
} /* ecma_property_hashmap_free */ } /* ecma_property_hashmap_free */
/** /**
@@ -225,8 +224,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
{ {
JERRY_ASSERT (property_pair_p != NULL); JERRY_ASSERT (property_pair_p != NULL);
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, ecma_property_hashmap_t *hashmap_p =
object_p->u1.property_list_cp); ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP); JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
@@ -299,8 +298,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
jmem_cpointer_t name_cp, /**< property name */ jmem_cpointer_t name_cp, /**< property name */
ecma_property_t *property_p) /**< property */ ecma_property_t *property_p) /**< property */
{ {
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, ecma_property_hashmap_t *hashmap_p =
object_p->u1.property_list_cp); ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP); JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
@@ -336,8 +335,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
offset = 1; offset = 1;
} }
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, ecma_property_pair_t *property_pair_p =
pair_list_p[entry_index]); ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
if ((property_pair_p->header.types + offset) == property_p) if ((property_pair_p->header.types + offset) == property_p)
{ {
@@ -392,9 +391,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
{ {
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i])) if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
{ {
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
prop_pair_p->names_cp[i],
name_p))
{ {
/* Property is found */ /* Property is found */
property_found = true; property_found = true;
@@ -436,8 +433,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
offset = 1; offset = 1;
} }
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, ecma_property_pair_t *property_pair_p =
pair_list_p[entry_index]); ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
ecma_property_t *property_p = property_pair_p->header.types + offset; ecma_property_t *property_p = property_pair_p->header.types + offset;
@@ -485,8 +482,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
offset = 1; offset = 1;
} }
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, ecma_property_pair_t *property_pair_p =
pair_list_p[entry_index]); ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
ecma_property_t *property_p = property_pair_p->header.types + offset; ecma_property_t *property_p = property_pair_p->header.types + offset;
@@ -527,7 +524,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
} }
} /* ecma_property_hashmap_find */ } /* ecma_property_hashmap_find */
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */ #endif /* JERRY_PROPERTY_HASHMAP */
/** /**
* @} * @}
+13 -8
View File
@@ -16,6 +16,8 @@
#ifndef ECMA_PROPERTY_HASHMAP_H #ifndef ECMA_PROPERTY_HASHMAP_H
#define ECMA_PROPERTY_HASHMAP_H #define ECMA_PROPERTY_HASHMAP_H
#include "ecma-globals.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
* *
@@ -36,7 +38,7 @@ typedef struct
ecma_property_header_t header; /**< header of the property */ ecma_property_header_t header; /**< header of the property */
uint32_t max_property_count; /**< maximum property count (power of 2) */ uint32_t max_property_count; /**< maximum property count (power of 2) */
uint32_t null_count; /**< number of NULLs in the map */ uint32_t null_count; /**< number of NULLs in the map */
uint32_t unused_count; /**< number of unused entires in the map */ uint32_t unused_count; /**< number of unused entries in the map */
/* /*
* The hash is followed by max_property_count ecma_cpointer_t * The hash is followed by max_property_count ecma_cpointer_t
@@ -53,7 +55,7 @@ typedef struct
*/ */
} ecma_property_hashmap_t; } ecma_property_hashmap_t;
#if ENABLED (JERRY_PROPRETY_HASHMAP) #if JERRY_PROPERTY_HASHMAP
/** /**
* Simple ecma values * Simple ecma values
@@ -67,14 +69,17 @@ typedef enum
void ecma_property_hashmap_create (ecma_object_t *object_p); void ecma_property_hashmap_create (ecma_object_t *object_p);
void ecma_property_hashmap_free (ecma_object_t *object_p); void ecma_property_hashmap_free (ecma_object_t *object_p);
void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_p, void ecma_property_hashmap_insert (ecma_object_t *object_p,
ecma_property_pair_t *property_pair_p, int property_index); ecma_string_t *name_p,
ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_pair_t *property_pair_p,
ecma_property_t *property_p); int property_index);
ecma_property_hashmap_delete_status
ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p, ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p,
ecma_string_t *name_p,
jmem_cpointer_t *property_real_name_cp); jmem_cpointer_t *property_real_name_cp);
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */ #endif /* JERRY_PROPERTY_HASHMAP */
/** /**
* @} * @}
@@ -0,0 +1,33 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-alloc.h"
#include "ecma-builtins.h"
#include "ecma-conversion.h"
#include "ecma-exceptions.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-string-object.h"
#include "jrt.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
@@ -0,0 +1,34 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* AggregateError.prototype built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* Object properties:
* (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.7.8 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_AGGREGATE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.7.9 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.7.10 */
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,109 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-alloc.h"
#include "ecma-array-object.h"
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#include "ecma-conversion.h"
#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-iterator-object.h"
#include "ecma-objects.h"
#include "jcontext.h"
#include "jrt.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror.inc.h"
#define BUILTIN_UNDERSCORED_ID aggregate_error
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup aggregateerror ECMA AggregateError object built-in
* @{
*/
/**
* Handle calling [[Call]] of built-in AggregateError object
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_aggregate_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
ecma_value_t message_val = ECMA_VALUE_UNDEFINED;
ecma_value_t error_val = ECMA_VALUE_UNDEFINED;
if (arguments_list_len > 0)
{
error_val = arguments_list_p[0];
if (arguments_list_len > 1)
{
message_val = arguments_list_p[1];
}
}
return ecma_new_aggregate_error (error_val, message_val);
} /* ecma_builtin_aggregate_error_dispatch_call */
/**
* Handle calling [[Construct]] of built-in AggregateError object
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_aggregate_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE);
if (proto_p == NULL)
{
return ECMA_VALUE_ERROR;
}
ecma_value_t result = ecma_builtin_aggregate_error_dispatch_call (arguments_list_p, arguments_list_len);
if (!ECMA_IS_VALUE_ERROR (result))
{
ecma_object_t *object_p = ecma_get_object_from_value (result);
ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
}
ecma_deref_object (proto_p);
return result;
} /* ecma_builtin_aggregate_error_dispatch_construct */
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,35 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* AggregateError built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* Number properties:
* (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 2, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
/* Object properties:
* (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -13,18 +13,31 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-arraybuffer-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-typedarray-object.h" #include "ecma-typedarray-object.h"
#if ENABLED (JERRY_ES2015)
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ARRAY_ITERATOR_PROTOTYPE_ROUTINE_START = 0,
ECMA_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT,
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-iterator-prototype.inc.h" #define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-iterator-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype #define BUILTIN_UNDERSCORED_ID array_iterator_prototype
#include "ecma-builtin-internal-routines-template.inc.h" #include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -55,20 +68,19 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
/* 1 - 2. */ /* 1 - 2. */
if (!ecma_is_value_object (this_val)) if (!ecma_is_value_object (this_val))
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object.")); return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT);
} }
ecma_object_t *obj_p = ecma_get_object_from_value (this_val); ecma_object_t *obj_p = ecma_get_object_from_value (this_val);
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
/* 3. */ /* 3. */
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_ITERATOR))
|| ext_obj_p->u.pseudo_array.type != ECMA_PSEUDO_ARRAY_ITERATOR)
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator.")); return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR);
} }
ecma_value_t iterated_value = ext_obj_p->u.pseudo_array.u2.iterated_value; ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value;
/* 4 - 5 */ /* 4 - 5 */
if (ecma_is_value_empty (iterated_value)) if (ecma_is_value_empty (iterated_value))
@@ -78,16 +90,31 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
ecma_object_t *array_object_p = ecma_get_object_from_value (iterated_value); ecma_object_t *array_object_p = ecma_get_object_from_value (iterated_value);
/* 8 - 9. */ /* 8. */
uint32_t length; ecma_length_t length;
ecma_value_t len_value = ecma_op_object_get_length (array_object_p, &length); if (ecma_object_is_typedarray (array_object_p))
if (ECMA_IS_VALUE_ERROR (len_value))
{ {
return len_value; /* a. */
ecma_object_t *arraybuffer_p = ecma_typedarray_get_arraybuffer (array_object_p);
if (ecma_arraybuffer_is_detached (arraybuffer_p))
{
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
}
/* b. */
length = ecma_typedarray_get_length (array_object_p);
}
else
{
ecma_value_t len_value = ecma_op_object_get_length (array_object_p, &length);
if (ECMA_IS_VALUE_ERROR (len_value))
{
return len_value;
}
} }
uint32_t index = ext_obj_p->u.pseudo_array.u1.iterator_index; ecma_length_t index = ext_obj_p->u.cls.u2.iterator_index;
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT)) if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
{ {
@@ -98,13 +125,10 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
if (!ecma_is_value_undefined (index_value)) if (!ecma_is_value_undefined (index_value))
{ {
index = (uint32_t) (ecma_get_number_from_value (index_value) + 1); index = (ecma_length_t) (ecma_get_number_from_value (index_value) + 1);
} }
ecma_value_t put_result = ecma_op_object_put (obj_p, ecma_value_t put_result = ecma_op_object_put (obj_p, prop_name_p, ecma_make_length_value (index), true);
prop_name_p,
ecma_make_uint32_value (index),
true);
JERRY_ASSERT (ecma_is_value_true (put_result)); JERRY_ASSERT (ecma_is_value_true (put_result));
@@ -113,26 +137,26 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
else else
{ {
/* 11. */ /* 11. */
ext_obj_p->u.pseudo_array.u1.iterator_index++; ext_obj_p->u.cls.u2.iterator_index++;
} }
if (index >= length) if (index >= length)
{ {
ext_obj_p->u.pseudo_array.u2.iterated_value = ECMA_VALUE_EMPTY; ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY;
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE); return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
} }
/* 7. */ /* 7. */
uint8_t iterator_type = ext_obj_p->u.pseudo_array.extra_info; uint8_t iterator_kind = ext_obj_p->u.cls.u1.iterator_kind;
if (iterator_type == ECMA_ITERATOR_KEYS) if (iterator_kind == ECMA_ITERATOR_KEYS)
{ {
/* 12. */ /* 12. */
return ecma_create_iter_result_object (ecma_make_uint32_value (index), ECMA_VALUE_FALSE); return ecma_create_iter_result_object (ecma_make_length_value (index), ECMA_VALUE_FALSE);
} }
/* 14. */ /* 14. */
ecma_value_t get_value = ecma_op_object_get_by_uint32_index (array_object_p, index); ecma_value_t get_value = ecma_op_object_get_by_index (array_object_p, index);
/* 15. */ /* 15. */
if (ECMA_IS_VALUE_ERROR (get_value)) if (ECMA_IS_VALUE_ERROR (get_value))
@@ -143,19 +167,18 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
ecma_value_t result; ecma_value_t result;
/* 16. */ /* 16. */
if (iterator_type == ECMA_ITERATOR_VALUES) if (iterator_kind == ECMA_ITERATOR_VALUES)
{ {
result = ecma_create_iter_result_object (get_value, ECMA_VALUE_FALSE); result = ecma_create_iter_result_object (get_value, ECMA_VALUE_FALSE);
} }
else else
{ {
/* 17.a */ /* 17.a */
JERRY_ASSERT (iterator_type == ECMA_ITERATOR_KEYS_VALUES); JERRY_ASSERT (iterator_kind == ECMA_ITERATOR_ENTRIES);
/* 17.b */ /* 17.b */
ecma_value_t entry_array_value; ecma_value_t entry_array_value;
entry_array_value = ecma_create_array_from_iter_element (get_value, entry_array_value = ecma_create_array_from_iter_element (get_value, ecma_make_length_value (index));
ecma_make_uint32_value (index));
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE); result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
ecma_free_value (entry_array_value); ecma_free_value (entry_array_value);
@@ -166,10 +189,36 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
return result; return result;
} /* ecma_builtin_array_iterator_prototype_object_next */ } /* ecma_builtin_array_iterator_prototype_object_next */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_array_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in routine identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
JERRY_UNUSED_2 (arguments_list_p, arguments_number);
switch (builtin_routine_id)
{
case ECMA_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT:
{
return ecma_builtin_array_iterator_prototype_object_next (this_arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_array_iterator_prototype_dispatch_routine */
/** /**
* @} * @}
* @} * @}
* @} * @}
*/ */
#endif /* ENABLED (JERRY_ES2015) */
@@ -19,16 +19,10 @@
#include "ecma-builtin-helpers-macro-defines.inc.h" #include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015) STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_ITERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_NEXT, ecma_builtin_array_iterator_prototype_object_next, 0, 0) ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT, 0, 0)
#endif /* ENABLED (JERRY_ES2015) */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -16,13 +16,9 @@
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#if ENABLED (JERRY_ES2015)
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h" #define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h"
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables #define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
#include "ecma-builtin-internal-routines-template.inc.h" #include "ecma-builtin-internal-routines-template.inc.h"
#endif /* ENABLED (JERRY_ES2015) */
@@ -19,36 +19,26 @@
#include "ecma-builtin-helpers-macro-defines.inc.h" #include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015) SIMPLE_VALUE (LIT_MAGIC_STRING_AT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX, SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
#endif /* ENABLED (JERRY_ES2015) */ SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
File diff suppressed because it is too large Load Diff
@@ -19,34 +19,27 @@
#include "ecma-builtin-helpers-macro-defines.inc.h" #include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_BUILTIN_ARRAY) #if JERRY_BUILTIN_ARRAY
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.4.1 */ /* ECMA-262 v5, 15.4.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if ENABLED (JERRY_ES2015)
/* ECMA-262 v6, 22.1.3.31 */ /* ECMA-262 v6, 22.1.3.31 */
OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES, OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES,
ECMA_PROPERTY_FLAG_CONFIGURABLE) ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015) */
/* Number properties: /* Number properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.4 */ /* ECMA-262 v5, 15.4.4 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_WRITABLE)
0,
ECMA_PROPERTY_FLAG_WRITABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_STRING, 0, 0)
ROUTINE (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_LOCALE_STRING, 0, 0) ROUTINE (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_LOCALE_STRING, 0, 0)
ROUTINE (LIT_MAGIC_STRING_CONCAT, ECMA_ARRAY_PROTOTYPE_CONCAT, NON_FIXED, 1) ROUTINE (LIT_MAGIC_STRING_CONCAT, ECMA_ARRAY_PROTOTYPE_CONCAT, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_JOIN, ECMA_ARRAY_PROTOTYPE_JOIN, 1, 1) ROUTINE (LIT_MAGIC_STRING_JOIN, ECMA_ARRAY_PROTOTYPE_JOIN, 1, 1)
@@ -56,6 +49,7 @@ ROUTINE (LIT_MAGIC_STRING_REVERSE, ECMA_ARRAY_PROTOTYPE_REVERSE, 0, 0)
ROUTINE (LIT_MAGIC_STRING_SHIFT, ECMA_ARRAY_PROTOTYPE_SHIFT, 0, 0) ROUTINE (LIT_MAGIC_STRING_SHIFT, ECMA_ARRAY_PROTOTYPE_SHIFT, 0, 0)
ROUTINE (LIT_MAGIC_STRING_SLICE, ECMA_ARRAY_PROTOTYPE_SLICE, 2, 2) ROUTINE (LIT_MAGIC_STRING_SLICE, ECMA_ARRAY_PROTOTYPE_SLICE, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SORT, ECMA_ARRAY_PROTOTYPE_SORT, 1, 1) ROUTINE (LIT_MAGIC_STRING_SORT, ECMA_ARRAY_PROTOTYPE_SORT, 1, 1)
ROUTINE (LIT_MAGIC_STRING_AT, ECMA_ARRAY_PROTOTYPE_AT, 1, 1)
ROUTINE (LIT_MAGIC_STRING_SPLICE, ECMA_ARRAY_PROTOTYPE_SPLICE, NON_FIXED, 2) ROUTINE (LIT_MAGIC_STRING_SPLICE, ECMA_ARRAY_PROTOTYPE_SPLICE, NON_FIXED, 2)
ROUTINE (LIT_MAGIC_STRING_UNSHIFT, ECMA_ARRAY_PROTOTYPE_UNSHIFT, NON_FIXED, 1) ROUTINE (LIT_MAGIC_STRING_UNSHIFT, ECMA_ARRAY_PROTOTYPE_UNSHIFT, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_INDEX_OF_UL, ECMA_ARRAY_PROTOTYPE_INDEX_OF, 2, 1) ROUTINE (LIT_MAGIC_STRING_INDEX_OF_UL, ECMA_ARRAY_PROTOTYPE_INDEX_OF, 2, 1)
@@ -69,19 +63,23 @@ ROUTINE (LIT_MAGIC_STRING_FILTER, ECMA_ARRAY_PROTOTYPE_FILTER, 2, 1)
/* Note these 2 routines must be in this order */ /* Note these 2 routines must be in this order */
ROUTINE (LIT_MAGIC_STRING_REDUCE, ECMA_ARRAY_PROTOTYPE_REDUCE, 2, 1) ROUTINE (LIT_MAGIC_STRING_REDUCE, ECMA_ARRAY_PROTOTYPE_REDUCE, 2, 1)
ROUTINE (LIT_MAGIC_STRING_REDUCE_RIGHT_UL, ECMA_ARRAY_PROTOTYPE_REDUCE_RIGHT, 2, 1) ROUTINE (LIT_MAGIC_STRING_REDUCE_RIGHT_UL, ECMA_ARRAY_PROTOTYPE_REDUCE_RIGHT, 2, 1)
#if ENABLED (JERRY_ES2015)
ROUTINE (LIT_MAGIC_STRING_FIND, ECMA_ARRAY_PROTOTYPE_FIND, 2, 1) ROUTINE (LIT_MAGIC_STRING_FIND, ECMA_ARRAY_PROTOTYPE_FIND, 2, 1)
ROUTINE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_ARRAY_PROTOTYPE_FIND_INDEX, 2, 1) ROUTINE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_ARRAY_PROTOTYPE_FIND_INDEX, 2, 1)
ROUTINE (LIT_MAGIC_STRING_FILL, ECMA_ARRAY_PROTOTYPE_FILL, 3, 1) ROUTINE (LIT_MAGIC_STRING_FILL, ECMA_ARRAY_PROTOTYPE_FILL, 3, 1)
ROUTINE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_ARRAY_PROTOTYPE_COPY_WITHIN, NON_FIXED, 2) ROUTINE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_ARRAY_PROTOTYPE_COPY_WITHIN, NON_FIXED, 2)
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_ARRAY_PROTOTYPE_ENTRIES, 0, 0) ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_ARRAY_PROTOTYPE_ENTRIES, 0, 0)
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0) ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES, ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0)
ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES,
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES, INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR,
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* ENABLED (JERRY_ES2015) */
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */ #endif /* JERRY_BUILTIN_ARRAY */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -14,8 +14,9 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtins.h" #include "ecma-array-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
@@ -24,17 +25,34 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-array-object.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h" #include "jrt.h"
#if ENABLED (JERRY_BUILTIN_ARRAY) #if JERRY_BUILTIN_ARRAY
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ARRAY_ROUTINE_START = 0,
ECMA_ARRAY_ROUTINE_IS_ARRAY,
ECMA_ARRAY_ROUTINE_FROM,
ECMA_ARRAY_ROUTINE_OF,
ECMA_ARRAY_ROUTINE_SPECIES_GET
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array.inc.h" #define BUILTIN_INC_HEADER_NAME "ecma-builtin-array.inc.h"
#define BUILTIN_UNDERSCORED_ID array #define BUILTIN_UNDERSCORED_ID array
#include "ecma-builtin-internal-routines-template.inc.h" #include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -47,25 +65,6 @@
* @{ * @{
*/ */
/**
* The Array object's 'isArray' routine
*
* See also:
* ECMA-262 v5, 15.4.3.2
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_array_object_is_array (ecma_value_t this_arg, /**< 'this' argument */
ecma_value_t arg) /**< first argument */
{
JERRY_UNUSED (this_arg);
return ecma_is_value_array (arg);
} /* ecma_builtin_array_object_is_array */
#if ENABLED (JERRY_ES2015)
/** /**
* The Array object's 'from' routine * The Array object's 'from' routine
* *
@@ -78,7 +77,7 @@ ecma_builtin_array_object_is_array (ecma_value_t this_arg, /**< 'this' argument
static ecma_value_t static ecma_value_t
ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
const ecma_value_t *arguments_list_p, /**< arguments list */ const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
/* 1. */ /* 1. */
ecma_value_t constructor = this_arg; ecma_value_t constructor = this_arg;
@@ -95,7 +94,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
/* 3.a */ /* 3.a */
if (!ecma_op_is_callable (mapfn)) if (!ecma_op_is_callable (mapfn))
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable.")); return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE);
} }
/* 3.b */ /* 3.b */
@@ -122,44 +121,45 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
/* 6. */ /* 6. */
if (!ecma_is_value_undefined (using_iterator)) if (!ecma_is_value_undefined (using_iterator))
{ {
ecma_value_t array; ecma_object_t *array_obj_p;
/* 6.a */ /* 6.a */
if (ecma_is_constructor (constructor)) if (ecma_is_constructor (constructor))
{ {
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor); ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, NULL, 0); ecma_value_t array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, NULL, 0);
if (ecma_is_value_undefined (array) || ecma_is_value_null (array)) if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
{ {
ecma_free_value (using_iterator); ecma_free_value (using_iterator);
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null to object")); return ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT);
} }
/* 6.c */
if (ECMA_IS_VALUE_ERROR (array))
{
ecma_free_value (using_iterator);
return array;
}
array_obj_p = ecma_get_object_from_value (array);
} }
else else
{ {
/* 6.b */ /* 6.b */
array = ecma_op_create_array_object (NULL, 0, false); array_obj_p = ecma_op_new_array_object (0);
} }
/* 6.c */
if (ECMA_IS_VALUE_ERROR (array))
{
ecma_free_value (using_iterator);
return array;
}
ecma_object_t *array_obj_p = ecma_get_object_from_value (array);
/* 6.d */ /* 6.d */
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator); ecma_value_t next_method;
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator, &next_method);
ecma_free_value (using_iterator); ecma_free_value (using_iterator);
/* 6.e */ /* 6.e */
if (ECMA_IS_VALUE_ERROR (iterator)) if (ECMA_IS_VALUE_ERROR (iterator))
{ {
ecma_free_value (array); ecma_deref_object (array_obj_p);
return iterator; return iterator;
} }
@@ -170,7 +170,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
while (true) while (true)
{ {
/* 6.g.ii */ /* 6.g.ii */
ecma_value_t next = ecma_op_iterator_step (iterator); ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
/* 6.g.iii */ /* 6.g.iii */
if (ECMA_IS_VALUE_ERROR (next)) if (ECMA_IS_VALUE_ERROR (next))
@@ -183,10 +183,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
{ {
/* 6.g.iv.1 */ /* 6.g.iv.1 */
ecma_value_t len_value = ecma_make_uint32_value (k); ecma_value_t len_value = ecma_make_uint32_value (k);
ecma_value_t set_status = ecma_op_object_put (array_obj_p, ecma_value_t set_status =
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
len_value,
true);
ecma_free_value (len_value); ecma_free_value (len_value);
/* 6.g.iv.2 */ /* 6.g.iv.2 */
@@ -196,8 +194,9 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
} }
ecma_free_value (iterator); ecma_free_value (iterator);
ecma_free_value (next_method);
/* 6.g.iv.3 */ /* 6.g.iv.3 */
return array; return ecma_make_object_value (array_obj_p);
} }
/* 6.g.v */ /* 6.g.v */
@@ -236,7 +235,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
} }
/* 6.g.ix */ /* 6.g.ix */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags); ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
ecma_free_value (mapped_value); ecma_free_value (mapped_value);
@@ -254,7 +253,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
iterator_cleanup: iterator_cleanup:
ecma_free_value (iterator); ecma_free_value (iterator);
ecma_free_value (array); ecma_free_value (next_method);
ecma_deref_object (array_obj_p);
return ret_value; return ret_value;
} }
@@ -271,7 +271,7 @@ iterator_cleanup:
ecma_object_t *array_like_obj_p = ecma_get_object_from_value (array_like); ecma_object_t *array_like_obj_p = ecma_get_object_from_value (array_like);
/* 10. */ /* 10. */
uint32_t len; ecma_length_t len;
ecma_value_t len_value = ecma_op_object_get_length (array_like_obj_p, &len); ecma_value_t len_value = ecma_op_object_get_length (array_like_obj_p, &len);
/* 11. */ /* 11. */
@@ -280,49 +280,51 @@ iterator_cleanup:
goto cleanup; goto cleanup;
} }
len_value = ecma_make_uint32_value (len);
/* 12. */ /* 12. */
ecma_value_t array; ecma_object_t *array_obj_p;
/* 12.a */ /* 12.a */
if (ecma_is_constructor (constructor)) if (ecma_is_constructor (constructor))
{ {
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor); ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, &len_value, 1); len_value = ecma_make_length_value (len);
ecma_value_t array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, &len_value, 1);
ecma_free_value (len_value);
if (ecma_is_value_undefined (array) || ecma_is_value_null (array)) if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
{ {
ecma_free_value (len_value); ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT);
ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null to object"));
goto cleanup; goto cleanup;
} }
/* 14. */
if (ECMA_IS_VALUE_ERROR (array))
{
goto cleanup;
}
array_obj_p = ecma_get_object_from_value (array);
} }
else else
{ {
/* 13.a */ /* 13.a */
array = ecma_op_create_array_object (&len_value, 1, true); array_obj_p = ecma_op_new_array_object_from_length (len);
if (JERRY_UNLIKELY (array_obj_p == NULL))
{
goto cleanup;
}
} }
ecma_free_value (len_value);
/* 14. */
if (ECMA_IS_VALUE_ERROR (array))
{
goto cleanup;
}
ecma_object_t *array_obj_p = ecma_get_object_from_value (array);
/* 15. */ /* 15. */
uint32_t k = 0; ecma_length_t k = 0;
/* 16. */ /* 16. */
while (k < len) while (k < len)
{ {
/* 16.b */ /* 16.b */
ecma_value_t k_value = ecma_op_object_get_by_uint32_index (array_like_obj_p, k); ecma_value_t k_value = ecma_op_object_get_by_index (array_like_obj_p, k);
/* 16.c */ /* 16.c */
if (ECMA_IS_VALUE_ERROR (k_value)) if (ECMA_IS_VALUE_ERROR (k_value))
@@ -335,7 +337,7 @@ iterator_cleanup:
if (mapfn_obj_p != NULL) if (mapfn_obj_p != NULL)
{ {
/* 16.d.i */ /* 16.d.i */
ecma_value_t args_p[2] = { k_value, ecma_make_uint32_value (k) }; ecma_value_t args_p[2] = { k_value, ecma_make_length_value (k) };
mapped_value = ecma_op_function_call (mapfn_obj_p, call_this_arg, args_p, 2); mapped_value = ecma_op_function_call (mapfn_obj_p, call_this_arg, args_p, 2);
ecma_free_value (args_p[1]); ecma_free_value (args_p[1]);
ecma_free_value (k_value); ecma_free_value (k_value);
@@ -353,7 +355,7 @@ iterator_cleanup:
} }
/* 16.f */ /* 16.f */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags); ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
ecma_free_value (mapped_value); ecma_free_value (mapped_value);
@@ -369,11 +371,9 @@ iterator_cleanup:
} }
/* 17. */ /* 17. */
len_value = ecma_make_uint32_value (k); len_value = ecma_make_length_value (k);
ecma_value_t set_status = ecma_op_object_put (array_obj_p, ecma_value_t set_status =
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
len_value,
true);
ecma_free_value (len_value); ecma_free_value (len_value);
/* 18. */ /* 18. */
@@ -405,19 +405,17 @@ cleanup:
static ecma_value_t static ecma_value_t
ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
const ecma_value_t *arguments_list_p, /**< arguments list */ const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
if (!ecma_is_constructor (this_arg)) if (!ecma_is_constructor (this_arg))
{ {
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, false); return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
} }
ecma_value_t len = ecma_make_uint32_value (arguments_list_len); ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
ecma_value_t ret_val = ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_value_t ret_val =
ecma_get_object_from_value (this_arg), ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_get_object_from_value (this_arg), &len, 1);
&len,
1);
if (ECMA_IS_VALUE_ERROR (ret_val)) if (ECMA_IS_VALUE_ERROR (ret_val))
{ {
@@ -427,14 +425,12 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
uint32_t k = 0; uint32_t k = 0;
ecma_object_t *obj_p = ecma_get_object_from_value (ret_val); ecma_object_t *obj_p = ecma_get_object_from_value (ret_val);
const uint32_t prop_status_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW; const uint32_t prop_status_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
while (k < arguments_list_len) while (k < arguments_list_len)
{ {
ecma_value_t define_status = ecma_builtin_helper_def_prop_by_index (obj_p, ecma_value_t define_status =
k, ecma_builtin_helper_def_prop_by_index (obj_p, k, arguments_list_p[k], prop_status_flags);
arguments_list_p[k],
prop_status_flags);
if (ECMA_IS_VALUE_ERROR (define_status)) if (ECMA_IS_VALUE_ERROR (define_status))
{ {
@@ -446,10 +442,7 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
k++; k++;
} }
ret_val = ecma_op_object_put (obj_p, ret_val = ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len, true);
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
len,
true);
ecma_free_value (len); ecma_free_value (len);
@@ -462,74 +455,114 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
return ecma_make_object_value (obj_p); return ecma_make_object_value (obj_p);
} /* ecma_builtin_array_object_of */ } /* ecma_builtin_array_object_of */
/**
* 22.1.2.5 get Array [ @@species ] accessor
*
* @return ecma_value
* returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_builtin_array_species_get (ecma_value_t this_value) /**< This Value */
{
return ecma_copy_value (this_value);
} /* ecma_builtin_array_species_get */
#endif /* ENABLED (JERRY_ES2015) */
/** /**
* Handle calling [[Call]] of built-in Array object * Handle calling [[Call]] of built-in Array object
* *
* @return ecma value * @return ECMA_VALUE_ERROR - if the array construction fails
* constructed array object - otherwise
*/ */
ecma_value_t ecma_value_t
ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true); if (arguments_list_len != 1 || !ecma_is_value_number (arguments_list_p[0]))
{
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
}
ecma_number_t num = ecma_get_number_from_value (arguments_list_p[0]);
uint32_t num_uint32 = ecma_number_to_uint32 (num);
if (num != ((ecma_number_t) num_uint32))
{
return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH);
}
return ecma_make_object_value (ecma_op_new_array_object (num_uint32));
} /* ecma_builtin_array_dispatch_call */ } /* ecma_builtin_array_dispatch_call */
/** /**
* Handle calling [[Construct]] of built-in Array object * Handle calling [[Construct]] of built-in Array object
* *
* @return ecma value * @return ECMA_VALUE_ERROR - if the array construction fails
* constructed array object - otherwise
*/ */
ecma_value_t ecma_value_t
ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
#if !ENABLED (JERRY_ES2015) ecma_object_t *proto_p =
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true); ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
#else /* ENABLED (JERRY_ES2015) */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
if (proto_p == NULL) if (proto_p == NULL)
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
ecma_value_t result = ecma_op_create_array_object (arguments_list_p, arguments_list_len, true); ecma_value_t result = ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
if (ECMA_IS_VALUE_ERROR (result)) if (ECMA_IS_VALUE_ERROR (result))
{ {
ecma_deref_object (proto_p); ecma_deref_object (proto_p);
return ECMA_VALUE_ERROR; return result;
} }
ecma_object_t *object_p = ecma_get_object_from_value (result); ecma_object_t *object_p = ecma_get_object_from_value (result);
ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p); ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
ecma_deref_object (proto_p); ecma_deref_object (proto_p);
return result; return result;
#endif /* ENABLED (JERRY_ES2015) */
} /* ecma_builtin_array_dispatch_construct */ } /* ecma_builtin_array_dispatch_construct */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_array_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
JERRY_UNUSED (arguments_number);
switch (builtin_routine_id)
{
case ECMA_ARRAY_ROUTINE_IS_ARRAY:
{
JERRY_UNUSED (this_arg);
return ecma_is_value_array (arguments_list_p[0]);
}
case ECMA_ARRAY_ROUTINE_FROM:
{
return ecma_builtin_array_object_from (this_arg, arguments_list_p, arguments_number);
}
case ECMA_ARRAY_ROUTINE_OF:
{
return ecma_builtin_array_object_of (this_arg, arguments_list_p, arguments_number);
}
case ECMA_ARRAY_ROUTINE_SPECIES_GET:
{
return ecma_copy_value (this_arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_array_dispatch_routine */
/** /**
* @} * @}
* @} * @}
* @} * @}
*/ */
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */ #endif /* JERRY_BUILTIN_ARRAY */
@@ -19,42 +19,29 @@
#include "ecma-builtin-helpers-macro-defines.inc.h" #include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_BUILTIN_ARRAY) #if JERRY_BUILTIN_ARRAY
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.3.1 */ /* ECMA-262 v5, 15.4.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE,
ECMA_PROPERTY_FIXED)
/* Number properties: /* Number properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
1, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if ENABLED (JERRY_ES2015)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_ARRAY_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015) */
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_IS_ARRAY_UL, ecma_builtin_array_object_is_array, 1, 1) ROUTINE (LIT_MAGIC_STRING_IS_ARRAY_UL, ECMA_ARRAY_ROUTINE_IS_ARRAY, 1, 1)
#if ENABLED (JERRY_ES2015) ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_FROM, ecma_builtin_array_object_from, NON_FIXED, 1) ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
ROUTINE (LIT_MAGIC_STRING_OF, ecma_builtin_array_object_of, NON_FIXED, 0)
/* ECMA-262 v6, 22.1.2.5 */ /* ECMA-262 v6, 22.1.2.5 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAY_ROUTINE_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ecma_builtin_array_species_get,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015) */
#endif /* !(ENABLED (JERRY_BUILTIN_ARRAY)) */ #endif /* !(JERRY_BUILTIN_ARRAY) */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -13,24 +13,27 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-arraybuffer-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-arraybuffer-object.h"
#include "ecma-try-catch-macro.h"
#include "jrt.h"
#include "jrt-libc-includes.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) #include "jrt-libc-includes.h"
#include "jrt.h"
#if JERRY_BUILTIN_TYPEDARRAY
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h" #define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype #define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
#include "ecma-builtin-internal-routines-template.inc.h" #include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -59,89 +62,49 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
{ {
ecma_object_t *object_p = ecma_get_object_from_value (this_arg); ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL)) if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
{ {
if (ecma_arraybuffer_is_detached (object_p)) if (ecma_arraybuffer_is_detached (object_p))
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached.")); return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
} }
ecma_length_t len = ecma_arraybuffer_get_length (object_p); uint32_t len = ecma_arraybuffer_get_length (object_p);
return ecma_make_uint32_value (len); return ecma_make_uint32_value (len);
} }
} }
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a ArrayBuffer object.")); return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT);
} /* ecma_builtin_arraybuffer_prototype_bytelength_getter */ } /* ecma_builtin_arraybuffer_prototype_bytelength_getter */
/** /**
* The ArrayBuffer.prototype object's 'slice' routine * The ArrayBuffer.prototype object's 'slice' routine
* *
* See also: * See also:
* ES2015, 24.1.4.3 * ECMA-262 v11, 24.1.4.3
* *
* @return ecma value * @return ecma value
* Returned value must be freed with ecma_free_value. * Returned value must be freed with ecma_free_value.
*/ */
static ecma_value_t static ecma_value_t
ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< this argument */ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */ const ecma_value_t *argument_list_p, /**< arguments list */
ecma_value_t arg2) /**< routine's second argument */ uint32_t arguments_number) /**< number of arguments */
{ {
if (!ecma_is_value_object (this_arg)) if (!ecma_is_value_object (this_arg))
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not object.")); return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT);
} }
ecma_object_t *object_p = ecma_get_object_from_value (this_arg); ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
if (!ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL)) /* 2. */
if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
{ {
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object.")); return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT);
} }
if (ecma_arraybuffer_is_detached (object_p)) return ecma_builtin_arraybuffer_slice (this_arg, argument_list_p, arguments_number);
{
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
}
ecma_length_t len = ecma_arraybuffer_get_length (object_p);
ecma_length_t start = 0, end = len;
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1,
len,
&start)))
{
return ECMA_VALUE_ERROR;
}
if (!ecma_is_value_undefined (arg2))
{
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2,
len,
&end)))
{
return ECMA_VALUE_ERROR;
}
}
if (ret_value != ECMA_VALUE_EMPTY)
{
return ret_value;
}
JERRY_ASSERT (start <= len && end <= len);
ecma_length_t new_len = (end >= start) ? (end - start) : 0;
ecma_object_t *new_arraybuffer_p = ecma_arraybuffer_new_object (new_len);
lit_utf8_byte_t *old_buf = ecma_arraybuffer_get_buffer (object_p);
lit_utf8_byte_t *new_buf = ecma_arraybuffer_get_buffer (new_arraybuffer_p);
memcpy (new_buf, old_buf + start, new_len);
return ecma_make_object_value (new_arraybuffer_p);
} /* ecma_builtin_arraybuffer_prototype_object_slice */ } /* ecma_builtin_arraybuffer_prototype_object_slice */
/** /**
@@ -150,4 +113,4 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
* @} * @}
*/ */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
@@ -19,31 +19,25 @@
#include "ecma-builtin-helpers-macro-defines.inc.h" #include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) #if JERRY_BUILTIN_TYPEDARRAY
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ARRAYBUFFER,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* Readonly accessor properties */ /* Readonly accessor properties */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL, ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
ecma_builtin_arraybuffer_prototype_bytelength_getter, ecma_builtin_arraybuffer_prototype_bytelength_getter,
ECMA_PROPERTY_FLAG_CONFIGURABLE) ECMA_PROPERTY_FLAG_CONFIGURABLE)
#if ENABLED (JERRY_ES2015)
/* ECMA-262 v6, 24.1.4.4 */ /* ECMA-262 v6, 24.1.4.4 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015) */
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, 2, 2) ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, NON_FIXED, 2)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -13,24 +13,24 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-arraybuffer-object.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-dataview-object.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-arraybuffer-object.h"
#include "ecma-dataview-object.h"
#include "ecma-try-catch-macro.h"
#include "ecma-typedarray-object.h" #include "ecma-typedarray-object.h"
#include "jrt.h" #include "jrt.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) #if JERRY_BUILTIN_TYPEDARRAY
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h" #define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h"
#define BUILTIN_UNDERSCORED_ID arraybuffer #define BUILTIN_UNDERSCORED_ID arraybuffer
#include "ecma-builtin-internal-routines-template.inc.h" #include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -72,11 +72,11 @@ ecma_builtin_arraybuffer_object_is_view (ecma_value_t this_arg, /**< 'this' argu
*/ */
ecma_value_t ecma_value_t
ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor ArrayBuffer requires 'new'")); return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW);
} /* ecma_builtin_arraybuffer_dispatch_call */ } /* ecma_builtin_arraybuffer_dispatch_call */
/** /**
@@ -86,7 +86,7 @@ ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /*
*/ */
ecma_value_t ecma_value_t
ecma_builtin_arraybuffer_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_arraybuffer_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
@@ -111,4 +111,4 @@ ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) /**< This Value *
* @} * @}
*/ */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
@@ -19,25 +19,19 @@
#include "ecma-builtin-helpers-macro-defines.inc.h" #include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) #if JERRY_BUILTIN_TYPEDARRAY
/* Number properties: /* Number properties:
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
ECMA_PROPERTY_FIXED)
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -46,10 +40,8 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME,
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1) ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
/* ES2015 24.1.3.3 */ /* ES2015 24.1.3.3 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ecma_builtin_arraybuffer_species_get, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ecma_builtin_arraybuffer_species_get,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,355 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "jerryscript-types.h"
#include "ecma-builtin-handlers.h"
#include "ecma-builtins.h"
#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-iterator-object.h"
#include "ecma-objects.h"
#include "ecma-promise-object.h"
#include "jcontext.h"
#include "jrt.h"
#include "lit-magic-strings.h"
#include "lit-strings.h"
#include "opcodes.h"
#include "vm-defines.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_START = 0, /**< buitlin routine start id */
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_NEXT, /**< 'next' routine v11, 25.1.4.2.1 */
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_RETURN, /**< 'return' routine v11, 25.1.4.2.2 */
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_THROW /**< 'throw' routine v11, 25.1.4.2.3 */
} ecma_async_from_sync_iterator_operation_type_t;
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-from-sync-iterator-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID async_from_sync_iterator_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup asyncfromsynciteratorprototype ECMA %AsyncFromSyncIteratorPrototype% object built-in
* @{
*/
/**
* AsyncFromSyncIteratorContinuation operation
*
* See also:
* ECMAScript v11, 25.1.4.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_op_async_from_sync_iterator_prototype_continuation (ecma_value_t result, /**< routine's 'result' argument */
ecma_object_t *capability_obj_p) /**< promise capability */
{
/* 1. */
ecma_value_t done = ecma_op_iterator_complete (result);
/* 2. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&done, capability_obj_p)))
{
return done;
}
uint16_t done_flag = ecma_is_value_false (done) ? 0 : (1 << ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT);
ecma_free_value (done);
/* 3. */
ecma_value_t value = ecma_op_iterator_value (result);
/* 4. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&value, capability_obj_p)))
{
return value;
}
/* 5. */
ecma_value_t builtin_promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
ecma_value_t value_wrapper = ecma_promise_reject_or_resolve (builtin_promise, value, true);
ecma_free_value (value);
/* 6. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&value_wrapper, capability_obj_p)))
{
return value_wrapper;
}
/* 8 - 9. */
ecma_object_t *on_fullfilled = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_ASYNC_FROM_SYNC_ITERATOR_UNWRAP,
sizeof (ecma_extended_object_t));
((ecma_extended_object_t *) on_fullfilled)->u.built_in.u2.routine_flags = (uint8_t) done_flag;
/* 10. */
ecma_value_t then_result = ecma_promise_perform_then (value_wrapper,
ecma_make_object_value (on_fullfilled),
ECMA_VALUE_UNDEFINED,
capability_obj_p);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (then_result));
ecma_deref_object (on_fullfilled);
ecma_free_value (value_wrapper);
/* 11. */
return then_result;
} /* ecma_op_async_from_sync_iterator_prototype_continuation */
/**
* The %AsyncFromSyncIteratorPrototype% object's 'next' routine
*
* See also:
* ECMAScript v11, 25.1.4.2.1
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_async_from_sync_iterator_prototype_next (ecma_async_from_sync_iterator_object_t *iter_p, /**< iterator
* record*/
ecma_object_t *capability_p, /**< promise capability */
ecma_value_t value) /**< routine's 'value' argument */
{
/* 5. */
ecma_value_t next_result =
ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, iter_p->sync_next_method, value);
/* 6. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p)))
{
return next_result;
}
/* 7. */
ecma_value_t result = ecma_op_async_from_sync_iterator_prototype_continuation (next_result, capability_p);
ecma_free_value (next_result);
return result;
} /* ecma_builtin_async_from_sync_iterator_prototype_next */
/**
* The %AsyncFromSyncIteratorPrototype% object's 'return' and 'throw' routines
*
* See also:
* ECMAScript v11, 25.1.4.2.2
* ECMAScript v11, 25.1.4.2.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterator_object_t *iter_p, /**< iterator
* record*/
ecma_object_t *capability_obj_p, /**< promise capability */
ecma_value_t value, /**< routine's 'value' argument */
lit_magic_string_id_t method_id) /**< method id */
{
/* 5. */
ecma_value_t sync_iterator = iter_p->header.u.cls.u3.sync_iterator;
ecma_value_t method = ecma_op_get_method_by_magic_id (sync_iterator, method_id);
/* 6. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&method, capability_obj_p)))
{
return method;
}
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
ecma_value_t call_arg;
uint32_t arg_size;
if (ecma_is_value_empty (value))
{
arg_size = 0;
call_arg = ECMA_VALUE_UNDEFINED;
}
else
{
arg_size = 1;
call_arg = value;
}
/* 7. */
if (ecma_is_value_undefined (method))
{
ecma_value_t func_obj;
if (method_id == LIT_MAGIC_STRING_RETURN)
{
/* 7.a. */
call_arg = ecma_create_iter_result_object (call_arg, ECMA_VALUE_TRUE);
arg_size = 1;
func_obj = capability_p->resolve;
}
else
{
func_obj = capability_p->reject;
}
/* 7.b. */
ecma_value_t resolve =
ecma_op_function_call (ecma_get_object_from_value (func_obj), ECMA_VALUE_UNDEFINED, &call_arg, arg_size);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (resolve));
ecma_free_value (resolve);
if (method_id == LIT_MAGIC_STRING_RETURN)
{
ecma_free_value (call_arg);
}
/* 7.c. */
return ecma_copy_value (capability_p->header.u.cls.u3.promise);
}
/* 8. */
ecma_value_t call_result = ecma_op_function_validated_call (method, sync_iterator, &call_arg, arg_size);
ecma_free_value (method);
/* 9. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&call_result, capability_obj_p)))
{
return call_result;
}
/* 10. */
if (!ecma_is_value_object (call_result))
{
ecma_free_value (call_result);
#if JERRY_ERROR_MESSAGES
const lit_utf8_byte_t *msg_p = (lit_utf8_byte_t *) ecma_get_error_msg (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT);
lit_utf8_size_t msg_size = ecma_get_error_size (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT);
ecma_string_t *error_msg_p = ecma_new_ecma_string_from_ascii (msg_p, msg_size);
#else /* !JERRY_ERROR_MESSAGES */
ecma_string_t *error_msg_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
#endif /* JERRY_ERROR_MESSAGES */
ecma_object_t *type_error_obj_p = ecma_new_standard_error (JERRY_ERROR_TYPE, error_msg_p);
#if JERRY_ERROR_MESSAGES
ecma_deref_ecma_string (error_msg_p);
#endif /* JERRY_ERROR_MESSAGES */
ecma_value_t type_error = ecma_make_object_value (type_error_obj_p);
/* 10.a. */
ecma_value_t reject =
ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &type_error, 1);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (reject));
ecma_deref_object (type_error_obj_p);
ecma_free_value (reject);
/* 10.b. */
return ecma_copy_value (capability_p->header.u.cls.u3.promise);
}
ecma_value_t result = ecma_op_async_from_sync_iterator_prototype_continuation (call_result, capability_obj_p);
ecma_free_value (call_result);
return result;
} /* ecma_builtin_async_from_sync_iterator_prototype_do */
/**
* Dispatcher of the %AsyncFromSyncIteratorPrototype% built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_from_sync_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide
* routine
* identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of
* arguments
* passed to
* routine */
uint32_t arguments_number) /**< length of
* arguments' list */
{
JERRY_UNUSED (arguments_number);
JERRY_ASSERT (ecma_is_value_object (this_arg));
ecma_object_t *this_obj_p = ecma_get_object_from_value (this_arg);
JERRY_ASSERT (ecma_object_class_is (this_obj_p, ECMA_OBJECT_CLASS_ASYNC_FROM_SYNC_ITERATOR));
ecma_async_from_sync_iterator_object_t *iter_p = (ecma_async_from_sync_iterator_object_t *) this_obj_p;
ecma_value_t builtin_promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
ecma_object_t *capability_p = ecma_promise_new_capability (builtin_promise, ECMA_VALUE_UNDEFINED);
JERRY_ASSERT (capability_p != NULL);
ecma_value_t result;
ecma_value_t arg = (arguments_number == 0 ? ECMA_VALUE_EMPTY : arguments_list_p[0]);
switch (builtin_routine_id)
{
case ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_NEXT:
{
result = ecma_builtin_async_from_sync_iterator_prototype_next (iter_p, capability_p, arg);
break;
}
case ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_RETURN:
{
result = ecma_builtin_async_from_sync_iterator_prototype_do (iter_p, capability_p, arg, LIT_MAGIC_STRING_RETURN);
break;
}
case ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_THROW:
{
result = ecma_builtin_async_from_sync_iterator_prototype_do (iter_p, capability_p, arg, LIT_MAGIC_STRING_THROW);
break;
}
default:
{
JERRY_UNREACHABLE ();
break;
}
}
ecma_deref_object (capability_p);
return result;
} /* ecma_builtin_async_from_sync_iterator_prototype_dispatch_routine */
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,28 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* %AsyncFromSyncIteratorPrototype% built-in description (AsyncFunction.prototype)
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_NEXT, 1, 1)
ROUTINE (LIT_MAGIC_STRING_RETURN, ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_RETURN, 1, 1)
ROUTINE (LIT_MAGIC_STRING_THROW, ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_THROW, 1, 1)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -13,18 +13,27 @@
* limitations under the License. * limitations under the License.
*/ */
/** #include "ecma-globals.h"
* Allow project to override this partition scheme
* The following variables are allowed to be defined: #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID async_function_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
* *
* QUARK_START_PAGE the first page where the QUARK code is located * \addtogroup ecmabuiltins
* QUARK_NB_PAGE the number of pages reserved for the QUARK. The ARC gets the * @{
* remaining pages (out of 148). *
* \addtogroup asyncfunctionprototype ECMA AsyncFunction.prototype object built-in
* @{
*/ */
#ifndef PROJECT_MAPPING_H
#define PROJECT_MAPPING_H
#define QUARK_NB_PAGE 125 /**
#include "machine/soc/intel/quark_se/quark_se_mapping.h" * @}
* @}
#endif /* !PROJECT_MAPPING_H */ * @}
*/
@@ -0,0 +1,28 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* %AsyncFunctionPrototype% built-in description (AsyncFunction.prototype)
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* ECMA-262 v11, 25.7.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v11, 25.7.3.2 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,68 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-globals.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#include "ecma-function-object.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function.inc.h"
#define BUILTIN_UNDERSCORED_ID async_function
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup asyncfunction ECMA AsyncFunction object built-in
* @{
*/
/**
* Handle calling [[Call]] of built-in AsyncFunction object
*
* @return constructed async function object - if success
* raised error otherwise
*/
ecma_value_t
ecma_builtin_async_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_ASYNC_FUNCTION);
} /* ecma_builtin_async_function_dispatch_call */
/**
* Handle calling [[Construct]] of built-in AsyncFunction object
*
* @return constructed async function object - if success
* raised error otherwise
*/
ecma_value_t
ecma_builtin_async_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
return ecma_builtin_async_function_dispatch_call (arguments_list_p, arguments_list_len);
} /* ecma_builtin_async_function_dispatch_construct */
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,34 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* %AsyncFunction% built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* ECMA-262 v11, 25.7.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v11, 25.7.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v10, 25.7.2.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
/* ECMA-262 v11, 25.7.3.2 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,70 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-globals.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#include "ecma-function-object.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-function.inc.h"
#define BUILTIN_UNDERSCORED_ID async_generator_function
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup asyncgeneratorfunction ECMA AsyncGeneratorFunction object built-in
* @{
*/
/**
* Handle calling [[Call]] of built-in AsyncGeneratorFunction object
*
* @return constructed async generator function object - if success
* raised error otherwise
*/
ecma_value_t
ecma_builtin_async_generator_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
return ecma_op_create_dynamic_function (arguments_list_p,
arguments_list_len,
ECMA_PARSE_GENERATOR_FUNCTION | ECMA_PARSE_ASYNC_FUNCTION);
} /* ecma_builtin_async_generator_function_dispatch_call */
/**
* Handle calling [[Construct]] of built-in AsyncGeneratorFunction object
*
* @return constructed async generator function object - if success
* raised error otherwise
*/
ecma_value_t
ecma_builtin_async_generator_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
return ecma_builtin_async_generator_function_dispatch_call (arguments_list_p, arguments_list_len);
} /* ecma_builtin_async_generator_function_dispatch_construct */
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,31 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* %AsyncGeneratorFunction% built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* ECMA-262 v10, 25.3.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v10, 25.3.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FIXED)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,150 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-async-generator-object.h"
#include "ecma-builtins.h"
#include "ecma-exceptions.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-iterator-object.h"
#include "ecma-promise-object.h"
#include "jcontext.h"
#include "opcodes.h"
#include "vm-defines.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_START = 0,
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT,
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW,
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup asyncgeneratorprototype ECMA AsyncGenerator.prototype object built-in
* @{
*/
/**
* Convert routine type to operation type.
*/
#define ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION(type) \
((ecma_async_generator_operation_type_t) ((type) -ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
== ECMA_ASYNC_GENERATOR_DO_NEXT,
convert_ecma_async_generator_routine_next_to_ecma_async_generator_do_next_failed);
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW)
== ECMA_ASYNC_GENERATOR_DO_THROW,
convert_ecma_async_generator_routine_throw_to_ecma_async_generator_do_throw_failed);
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
== ECMA_ASYNC_GENERATOR_DO_RETURN,
convert_ecma_async_generator_routine_return_to_ecma_async_generator_do_return_failed);
/**
* Dispatcher of the Generator built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
* identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to
* routine */
uint32_t arguments_number) /**< length of arguments'
* list */
{
JERRY_UNUSED (arguments_number);
vm_executable_object_t *executable_object_p = NULL;
if (ecma_is_value_object (this_arg))
{
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ASYNC_GENERATOR))
{
executable_object_p = (vm_executable_object_t *) object_p;
}
}
if (executable_object_p == NULL)
{
const char *msg_p = ecma_get_error_msg (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
lit_utf8_size_t msg_size = ecma_get_error_size (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
ecma_string_t *error_msg_p = ecma_new_ecma_string_from_ascii ((const lit_utf8_byte_t *) msg_p, msg_size);
ecma_object_t *type_error_obj_p = ecma_new_standard_error (JERRY_ERROR_TYPE, error_msg_p);
ecma_deref_ecma_string (error_msg_p);
ecma_value_t promise = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
ecma_reject_promise (promise, ecma_make_object_value (type_error_obj_p));
ecma_deref_object (type_error_obj_p);
return promise;
}
if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED)
{
ecma_value_t promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW))
{
return ecma_promise_reject_or_resolve (promise, arguments_list_p[0], false);
}
ecma_value_t iter_result = ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
ecma_value_t result = ecma_promise_reject_or_resolve (promise, iter_result, true);
ecma_free_value (iter_result);
return result;
}
return ecma_async_generator_enqueue (executable_object_p,
ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (builtin_routine_id),
arguments_list_p[0]);
} /* ecma_builtin_async_generator_prototype_dispatch_routine */
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,37 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* AsyncGenerator.prototype built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* Object properties:
* (property name, object pointer getter) */
/* ECMA-262 v6, 25.3.1.5 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_GENERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT, 1, 1)
ROUTINE (LIT_MAGIC_STRING_RETURN, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN, 1, 1)
ROUTINE (LIT_MAGIC_STRING_THROW, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW, 1, 1)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,39 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-globals.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator.inc.h"
#define BUILTIN_UNDERSCORED_ID async_generator
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup asyncgenerator ECMA AsyncGenerator object built-in
* @{
*/
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,33 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* %AsyncGenerator% built-in description (AsyncGeneratorFunction.prototype)
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* ECMA-262 v6, 25.3.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.3.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.3.3 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,103 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#include "ecma-iterator-object.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_ROUTINE_START = 0,
ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_OBJECT_ASYNC_ITERATOR,
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-iterator-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup %asynciteratorprototype% ECMA %AsyncIteratorPrototype% object built-in
* @{
*/
/**
* The %AsyncIteratorPrototype% object's '@@asyncIterator' routine
*
* See also:
* ECMA-262 v10, 25.1.3.1
*
* Note:
* Returned value must be freed with ecma_free_value.
*
* @return the given this value
*/
static ecma_value_t
ecma_builtin_async_iterator_prototype_object_async_iterator (ecma_value_t this_val) /**< this argument */
{
/* 1. */
return ecma_copy_value (this_val);
} /* ecma_builtin_async_iterator_prototype_object_async_iterator */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_async_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide
* routine identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**<
* list of arguments
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
JERRY_UNUSED_2 (arguments_list_p, arguments_number);
switch (builtin_routine_id)
{
case ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_OBJECT_ASYNC_ITERATOR:
{
return ecma_builtin_async_iterator_prototype_object_async_iterator (this_arg);
}
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_async_iterator_prototype_dispatch_routine */
/**
* @}
* @}
* @}
*/
@@ -0,0 +1,26 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* %AsyncIteratorPrototype% built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_GLOBAL_SYMBOL_ASYNC_ITERATOR, ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_OBJECT_ASYNC_ITERATOR, 0, 0)
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,491 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-arraybuffer-object.h"
#include "ecma-atomics-object.h"
#include "ecma-bigint.h"
#include "ecma-builtins.h"
#include "ecma-errors.h"
#include "ecma-exceptions.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-shared-arraybuffer-object.h"
#include "ecma-typedarray-object.h"
#include "jrt.h"
#if JERRY_BUILTIN_ATOMICS
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_ATOMICS_ROUTINE_START = 0, /**< Special value, should be ignored */
ECMA_ATOMICS_ROUTINE_ADD, /**< Atomics add routine */
ECMA_ATOMICS_ROUTINE_AND, /**< Atomics and routine */
ECMA_ATOMICS_ROUTINE_COMPAREEXCHANGE, /**< Atomics compare exchange routine */
ECMA_ATOMICS_ROUTINE_EXCHANGE, /**< Atomics exchange routine */
ECMA_ATOMICS_ROUTINE_ISLOCKFREE, /**< Atomics is lock free routine */
ECMA_ATOMICS_ROUTINE_LOAD, /**< Atomics load routine */
ECMA_ATOMICS_ROUTINE_OR, /**< Atomics or routine */
ECMA_ATOMICS_ROUTINE_STORE, /**< Atomics store routine */
ECMA_ATOMICS_ROUTINE_SUB, /**< Atomics sub routine */
ECMA_ATOMICS_ROUTINE_WAIT, /**< Atomics wait routine */
ECMA_ATOMICS_ROUTINE_NOTIFY, /**< Atomics notify routine */
ECMA_ATOMICS_ROUTINE_XOR, /**< Atomics xor routine */
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-atomics.inc.h"
#define BUILTIN_UNDERSCORED_ID atomics
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup atomics ECMA Atomics object built-in
* @{
*/
/**
* Convert ecma_number to the appropriate type according to the element type of typedarray.
*/
static ecma_value_t
ecma_convert_number_to_typed_array_type (ecma_number_t num, /**< ecma_number argument */
ecma_typedarray_type_t element_type) /**< element type of typedarray */
{
uint32_t value = ecma_typedarray_setter_number_to_uint32 (num);
switch (element_type)
{
case ECMA_INT8_ARRAY:
{
return ecma_make_number_value ((int8_t) value);
}
case ECMA_UINT8_ARRAY:
{
return ecma_make_number_value ((uint8_t) value);
}
case ECMA_INT16_ARRAY:
{
return ecma_make_number_value ((int16_t) value);
}
case ECMA_UINT16_ARRAY:
{
return ecma_make_number_value ((uint16_t) value);
}
case ECMA_INT32_ARRAY:
{
return ecma_make_number_value ((int32_t) value);
}
default:
{
JERRY_ASSERT (element_type == ECMA_UINT32_ARRAY);
return ecma_make_number_value (value);
}
}
} /* ecma_convert_number_to_typed_array_type */
/**
* The Atomics object's 'compareExchange' routine
*
* See also: ES12 25.4.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_atomics_compare_exchange (ecma_value_t typedarray, /**< typedArray argument */
ecma_value_t index, /**< index argument */
ecma_value_t expected_value, /**< expectedValue argument */
ecma_value_t replacement_value) /**< replacementValue argument*/
{
ecma_value_t buffer = ecma_validate_integer_typedarray (typedarray, false);
if (ECMA_IS_VALUE_ERROR (buffer))
{
return buffer;
}
uint32_t idx = ecma_validate_atomic_access (typedarray, index);
if (idx == ECMA_STRING_NOT_ARRAY_INDEX)
{
return ECMA_VALUE_ERROR;
}
ecma_object_t *typedarray_p = ecma_get_object_from_value (typedarray);
ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p);
if (ECMA_ARRAYBUFFER_LAZY_ALLOC (target_info.array_buffer_p))
{
return ECMA_VALUE_ERROR;
}
ecma_typedarray_type_t element_type = target_info.id;
ecma_value_t expected;
ecma_value_t replacement;
#if JERRY_BUILTIN_BIGINT
if (ECMA_TYPEDARRAY_IS_BIGINT_TYPE (element_type))
{
expected = ecma_bigint_to_bigint (expected_value, false);
if (ECMA_IS_VALUE_ERROR (expected))
{
return expected;
}
if (element_type == ECMA_BIGUINT64_ARRAY)
{
uint64_t num;
bool sign;
ecma_bigint_get_digits_and_sign (expected, &num, 1, &sign);
if (sign)
{
num = (uint64_t) (-(int64_t) num);
}
if (expected != ECMA_BIGINT_ZERO)
{
ecma_deref_bigint (ecma_get_extended_primitive_from_value (expected));
}
expected = ecma_bigint_create_from_digits (&num, 1, false);
}
replacement = ecma_bigint_to_bigint (replacement_value, false);
if (ECMA_IS_VALUE_ERROR (replacement))
{
ecma_free_value (expected);
return replacement;
}
}
else
#endif /* JERRY_BUILTIN_BIGINT */
{
ecma_number_t tmp_exp;
ecma_number_t tmp_rep;
expected = ecma_op_to_integer (expected_value, &tmp_exp);
if (ECMA_IS_VALUE_ERROR (expected))
{
return expected;
}
expected = ecma_convert_number_to_typed_array_type (tmp_exp, element_type);
replacement = ecma_op_to_integer (replacement_value, &tmp_rep);
if (ECMA_IS_VALUE_ERROR (replacement))
{
ecma_free_value (expected);
return replacement;
}
replacement = ecma_make_number_value (tmp_rep);
}
uint8_t element_size = target_info.element_size;
uint32_t offset = target_info.offset;
uint32_t indexed_position = idx * element_size + offset;
if (ecma_arraybuffer_is_detached (ecma_get_object_from_value (buffer)))
{
ecma_free_value (expected);
ecma_free_value (replacement);
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
}
ecma_typedarray_getter_fn_t typedarray_getter_cb = ecma_get_typedarray_getter_fn (element_type);
ecma_object_t *buffer_obj_p = ecma_get_object_from_value (buffer);
lit_utf8_byte_t *pos = ecma_arraybuffer_get_buffer (buffer_obj_p) + indexed_position;
ecma_value_t stored_value = typedarray_getter_cb (pos);
// TODO: Handle shared array buffers differently.
if (ecma_op_same_value (stored_value, expected))
{
ecma_typedarray_setter_fn_t typedarray_setter_cb = ecma_get_typedarray_setter_fn (element_type);
typedarray_setter_cb (ecma_arraybuffer_get_buffer (buffer_obj_p) + indexed_position, replacement);
}
ecma_free_value (expected);
ecma_free_value (replacement);
return stored_value;
} /* ecma_builtin_atomics_compare_exchange */
/**
* The Atomics object's 'isLockFree' routine
*
* See also: ES11 24.4.6
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_atomics_is_lock_free (ecma_value_t size) /**< size argument */
{
JERRY_UNUSED (size);
return ECMA_VALUE_FALSE;
} /* ecma_builtin_atomics_is_lock_free */
/**
* The Atomics object's 'store' routine
*
* See also: ES11 24.4.9
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_atomics_store (ecma_value_t typedarray, /**< typedArray argument */
ecma_value_t index, /**< index argument */
ecma_value_t value) /**< value argument */
{
/* 1. */
ecma_value_t buffer = ecma_validate_integer_typedarray (typedarray, false);
if (ECMA_IS_VALUE_ERROR (buffer))
{
return buffer;
}
/* 2. */
uint32_t idx = ecma_validate_atomic_access (typedarray, index);
if (idx == ECMA_STRING_NOT_ARRAY_INDEX)
{
return ECMA_VALUE_ERROR;
}
ecma_object_t *typedarray_p = ecma_get_object_from_value (typedarray);
ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p);
if (ECMA_ARRAYBUFFER_LAZY_ALLOC (target_info.array_buffer_p))
{
return ECMA_VALUE_ERROR;
}
ecma_typedarray_type_t element_type = target_info.id;
ecma_typedarray_setter_fn_t typedarray_setter_cb = ecma_get_typedarray_setter_fn (element_type);
ecma_value_t value_to_store;
#if JERRY_BUILTIN_BIGINT
if (element_type == ECMA_BIGINT64_ARRAY || element_type == ECMA_BIGUINT64_ARRAY)
{
value_to_store = ecma_bigint_to_bigint (value, false);
if (ECMA_IS_VALUE_ERROR (value_to_store))
{
return value_to_store;
}
}
else
#endif /* JERRY_BUILTIN_BIGINT */
{
ecma_number_t num_int;
value_to_store = ecma_op_to_integer (value, &num_int);
if (ECMA_IS_VALUE_ERROR (value_to_store))
{
return value_to_store;
}
if (ecma_number_is_zero (num_int) && ecma_number_is_negative (num_int))
{
num_int = (ecma_number_t) 0;
}
value_to_store = ecma_make_number_value (num_int);
}
ecma_object_t *buffer_obj_p = ecma_get_object_from_value (buffer);
if (ecma_arraybuffer_is_detached (buffer_obj_p))
{
ecma_free_value (value_to_store);
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
}
uint8_t element_size = target_info.element_size;
uint32_t offset = target_info.offset;
uint32_t indexed_position = idx * element_size + offset;
// TODO: Handle shared array buffers differently.
typedarray_setter_cb (ecma_arraybuffer_get_buffer (buffer_obj_p) + indexed_position, value_to_store);
return value_to_store;
} /* ecma_builtin_atomics_store */
/**
* The Atomics object's 'wait' routine
*
* See also: ES11 24.4.11
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_atomics_wait (ecma_value_t typedarray, /**< typedArray argument */
ecma_value_t index, /**< index argument */
ecma_value_t value, /**< value argument */
ecma_value_t timeout) /**< timeout argument */
{
JERRY_UNUSED (typedarray);
JERRY_UNUSED (index);
JERRY_UNUSED (value);
JERRY_UNUSED (timeout);
return ecma_make_uint32_value (0);
} /* ecma_builtin_atomics_wait */
/**
* The Atomics object's 'notify' routine
*
* See also: ES11 24.4.12
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_atomics_notify (ecma_value_t typedarray, /**< typedArray argument */
ecma_value_t index, /**< index argument */
ecma_value_t count) /**< count argument */
{
JERRY_UNUSED (typedarray);
JERRY_UNUSED (index);
JERRY_UNUSED (count);
return ecma_make_uint32_value (0);
} /* ecma_builtin_atomics_notify */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_atomics_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
JERRY_UNUSED (this_arg);
ecma_value_t arg1 = arguments_list_p[0];
ecma_value_t arg2 = arguments_list_p[1];
ecma_value_t arg3 = arguments_list_p[2];
ecma_value_t arg4 = (arguments_number > 3) ? arguments_list_p[3] : ECMA_VALUE_UNDEFINED;
ecma_atomics_op_t type;
switch (builtin_routine_id)
{
case ECMA_ATOMICS_ROUTINE_ADD:
{
type = ECMA_ATOMICS_ADD;
break;
}
case ECMA_ATOMICS_ROUTINE_AND:
{
type = ECMA_ATOMICS_AND;
break;
}
case ECMA_ATOMICS_ROUTINE_COMPAREEXCHANGE:
{
return ecma_builtin_atomics_compare_exchange (arg1, arg2, arg3, arg4);
}
case ECMA_ATOMICS_ROUTINE_EXCHANGE:
{
type = ECMA_ATOMICS_EXCHANGE;
break;
}
case ECMA_ATOMICS_ROUTINE_ISLOCKFREE:
{
return ecma_builtin_atomics_is_lock_free (arg1);
}
case ECMA_ATOMICS_ROUTINE_LOAD:
{
return ecma_atomic_load (arg1, arg2);
}
case ECMA_ATOMICS_ROUTINE_OR:
{
type = ECMA_ATOMICS_OR;
break;
}
case ECMA_ATOMICS_ROUTINE_STORE:
{
return ecma_builtin_atomics_store (arg1, arg2, arg3);
}
case ECMA_ATOMICS_ROUTINE_SUB:
{
type = ECMA_ATOMICS_SUBTRACT;
break;
}
case ECMA_ATOMICS_ROUTINE_WAIT:
{
return ecma_builtin_atomics_wait (arg1, arg2, arg3, arg4);
}
case ECMA_ATOMICS_ROUTINE_NOTIFY:
{
return ecma_builtin_atomics_notify (arg1, arg2, arg3);
}
case ECMA_ATOMICS_ROUTINE_XOR:
{
type = ECMA_ATOMICS_XOR;
break;
}
default:
{
JERRY_UNREACHABLE ();
}
}
return ecma_atomic_read_modify_write (arg1, arg2, arg3, type);
} /* ecma_builtin_atomics_dispatch_routine */
/**
* @}
* @}
* @}
*/
#endif /* JERRY_BUILTIN_ATOMICS */
@@ -0,0 +1,44 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Atomics built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if JERRY_BUILTIN_ATOMICS
/* ECMA-262 v11, 24.4.14 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ATOMICS_U, ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
ROUTINE (LIT_MAGIC_STRING_ADD, ECMA_ATOMICS_ROUTINE_ADD, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_AND, ECMA_ATOMICS_ROUTINE_AND, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_COMPAREEXCHANGE, ECMA_ATOMICS_ROUTINE_COMPAREEXCHANGE, 4, 4)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_EXCHANGE, ECMA_ATOMICS_ROUTINE_EXCHANGE, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_ISLOCKFREE, ECMA_ATOMICS_ROUTINE_ISLOCKFREE, 1, 1)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_LOAD, ECMA_ATOMICS_ROUTINE_LOAD, 2, 2)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_OR, ECMA_ATOMICS_ROUTINE_OR, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_STORE, ECMA_ATOMICS_ROUTINE_STORE, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_SUB, ECMA_ATOMICS_ROUTINE_SUB, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_WAIT, ECMA_ATOMICS_ROUTINE_WAIT, 4, 4)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_NOTIFY, ECMA_ATOMICS_ROUTINE_NOTIFY, 3, 3)
ROUTINE (LIT_MAGIC_STRING_ATOMICS_XOR, ECMA_ATOMICS_ROUTINE_XOR, 3, 3)
#endif /* JERRY_BUILTIN_ATOMICS */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,186 @@
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ecma-bigint.h"
#include "ecma-exceptions.h"
#if JERRY_BUILTIN_BIGINT
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#define BUILTIN_CUSTOM_DISPATCH
/**
* List of built-in routine identifiers.
*/
enum
{
ECMA_BIGINT_PROTOTYPE_ROUTINE_START = 0,
ECMA_BIGINT_PROTOTYPE_VALUE_OF,
ECMA_BIGINT_PROTOTYPE_TO_STRING,
ECMA_BIGINT_PROTOTYPE_TO_LOCALE_STRING,
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID bigint_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup bigint ECMA BigInt object built-in
* @{
*/
/**
* The BigInt.prototype object's 'valueOf' routine
*
* See also:
* ECMA-262 v11, 20.2.3.4
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_bigint_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_bigint (this_arg))
{
return ecma_copy_value (this_arg);
}
if (ecma_is_value_object (this_arg))
{
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_BIGINT))
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.cls.u3.value));
return ecma_copy_value (ext_object_p->u.cls.u3.value);
}
}
return ecma_raise_type_error (ECMA_ERR_BIGINT_VALUE_EXCPECTED);
} /* ecma_builtin_bigint_prototype_object_value_of */
/**
* The BigInt.prototype object's 'toString' routine
*
* See also:
* ECMA-262 v11, 20.2.3.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_bigint_prototype_object_to_string (ecma_value_t this_arg, /**< this argument */
const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
uint32_t radix = 10;
if (arguments_list_len > 0 && !ecma_is_value_undefined (arguments_list_p[0]))
{
ecma_number_t arg_num;
if (ECMA_IS_VALUE_ERROR (ecma_op_to_integer (arguments_list_p[0], &arg_num)))
{
return ECMA_VALUE_ERROR;
}
if (arg_num < 2 || arg_num > 36)
{
return ecma_raise_range_error (ECMA_ERR_RADIX_IS_OUT_OF_RANGE);
}
radix = (uint32_t) arg_num;
}
ecma_string_t *string_p = ecma_bigint_to_string (this_arg, radix);
if (string_p == NULL)
{
return ECMA_VALUE_ERROR;
}
return ecma_make_string_value (string_p);
} /* ecma_builtin_bigint_prototype_object_to_string */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_bigint_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
* identifier */
ecma_value_t this_arg, /**< 'this' argument value */
const ecma_value_t arguments_list_p[], /**< list of arguments
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
ecma_value_t this_value = ecma_builtin_bigint_prototype_object_value_of (this_arg);
ecma_value_t ret_val;
if (ECMA_IS_VALUE_ERROR (this_value))
{
return this_value;
}
switch (builtin_routine_id)
{
case ECMA_BIGINT_PROTOTYPE_VALUE_OF:
{
ret_val = this_value;
break;
}
case ECMA_BIGINT_PROTOTYPE_TO_STRING:
{
ret_val = ecma_builtin_bigint_prototype_object_to_string (this_value, arguments_list_p, arguments_number);
ecma_free_value (this_value);
break;
}
case ECMA_BIGINT_PROTOTYPE_TO_LOCALE_STRING:
{
ret_val = ecma_builtin_bigint_prototype_object_to_string (this_value, 0, 0);
ecma_free_value (this_value);
break;
}
default:
{
JERRY_UNREACHABLE ();
}
}
return ret_val;
} /* ecma_builtin_bigint_prototype_dispatch_routine */
/**
* @}
* @}
* @}
*/
#endif /* JERRY_BUILTIN_BIGINT */

Some files were not shown because too many files have changed in this diff Show More