853 Commits

Author SHA1 Message Date
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
Robert Fancsik 23bba1c6d9 Builtin objects finalization should handle function properties with tagged template literal collection (#3896)
This patch fixes #3893.

Co-authored-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-12 13:01:44 +02:00
Zoltan Herczeg 38111c0889 Fix redeclaration of existing var variables in functions with argument context. (#3891)
Fixes #3888

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-11 11:36:37 +02:00
Péter Gál 01e9670365 Update API version to 2.3 (#3889)
Update the API reference doc also.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-06-10 13:02:30 +02:00
Rafal Walczyna 049a0c43f6 Fix ReferenceError for let/const variables in of/in for loop (#3885)
ReferenceError should be thrown when variable is used before assignment

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-06-10 12:39:02 +02:00
Zoltan Herczeg 1bf52f5847 Fix initializer detection in for-in expressions. (#3884)
Also fix column update when comments are parsed.

Fixes #3882

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-10 12:37:52 +02:00
Dániel Bátyai 6d9d2328e9 Fix built-in RegExp allocation with default constructor (#3883)
Fixes #3880.
Fixes #3881.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-09 12:33:41 +02:00
Robert Fancsik dba9533af1 Compiled code should hold strong reference for the object in the tagged template literal collection (#3876)
This patch fixes #3866.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-09 08:20:30 +02:00
Dániel Bátyai 70383255fc Fix result of Date getters when called on invalid date (#3879)
Fixes #3878.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-09 07:27:31 +02:00
Roland Takacs 585332f072 Fix define_own_property_descriptor to set configurable flag correctly (#3877)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-06-08 18:12:39 +02:00
Zoltan Herczeg 36bf1ec09d Implement argument redefinition with var statement. (#3811)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-08 13:43:50 +02:00
Csaba Osztrogonác a885664220 Builtin objects accessor properties should be configurable (#3839)
http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-standard-built-in-objects

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-06-08 13:22:41 +02:00
Zoltan Herczeg 2058ea1286 Implement eval support for functions with arguments lexical env. (#3806)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-08 12:11:54 +02:00
Dániel Bátyai fed1b0c827 Add missing end-of-string checks to RegExp parser in unicode mode (#3875)
Fixes #3870.
Fixes #3871.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-08 11:09:08 +02:00
Robert Fancsik b7a641c124 Raw string length should be adjusted when UTF8 string is converted to CESU8 (#3853)
This patch fixes #3812.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-08 11:00:34 +02:00
Szilagyi Adam 4c53c94341 Fix value release in vm_loop for Proxy for-in cases (#3874)
Fixes #3868

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-08 10:29:06 +02:00
Szilagyi Adam 90fd881fda Fix TypedArray initialization with another TypedArray (#3850)
Fixes #3836

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-08 10:28:42 +02:00
Zoltan Herczeg 1230d4532c Asterisk should be ignored by object initializers. (#3872)
Fixes #3869

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-08 10:27:42 +02:00
Zoltan Herczeg ab2e821777 Fix three async function issues. (#3863)
- Invalid assert
- Add missing async prefix check when an identifier is enclosed in brackets
- Adding a new byte-code

Fixes #3855
Fixes #3856
Fixes #3857

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-08 10:25:34 +02:00
kisbg c2c623df79 Added missing generator prototype check (#3865)
Fixes #3861

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-06-08 10:25:04 +02:00
Szilagyi Adam 358101f27f Fix string dereference in ecma_op_create_dynamic_function (#3873)
Fixes #3862

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-08 10:23:26 +02:00
Péter Gál ba4e3a402f Correct release of spread arguments (#3867)
During the `opfunc_spread_arguments` argument release process
the stack pointer was incremented early resulting in a state where
one of the arguments was not freed causing a memory leak.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-06-06 18:39:40 +02:00
Dániel Bátyai cae6cd08fb Primitive this values of accessors should not be coerced in strict mode (#3854)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-05 15:58:10 +02:00
Zoltan Herczeg 10e78a4eef Context break should honor private contexts. (#3852)
Fixes #3830

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-05 14:39:13 +02:00
Robert Fancsik 1770ccaecd Object/Array initializers should be parsed as AssignmentExpression (#3851)
This patch fixes #3849.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-05 13:25:05 +02:00
Péter Gál 0d4116933f Fix property descriptor queries (#3840)
When the getOwnPropertyDescriptor method was invoked the input property
descriptor was not cleared in every case. This could lead to problems when
the property descriptor is not set/modified by the getOwnPropertyDescriptor
call, resulting in a failure at a later state.

Related to this the Proxy getOwnPropertyDescriptor method incorrectly returned
"undefined" value in a single case.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-06-05 12:28:34 +02:00
Szilagyi Adam 252cfb0876 Fix length check for Array.prototype indexOf, lastIndexOf and fill (#3798)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-06-05 12:20:26 +02:00
Robert Fancsik c09c2c5dd7 Fix several function name related issues (#3848)
- For non-computed name srcipt functions only identifier/string literal should be set as name
- Implicit class constructor names with non string function name should be ToString-ed

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-04 13:44:22 +02:00
Zoltan Herczeg e6ebc2be78 Don't continue parsing expressions after ternary operators. (#3847)
Further benefits: new code requires less checks.

Fixes #3841
Fixes #3842

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-06-04 13:27:32 +02:00
Robert Fancsik 1414e9bb00 Fix invalid AssignmentExpression lookahead in parser_process_group_expression (#3846)
This patch fixes #3845.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-04 13:23:25 +02:00
Dániel Bátyai 1322e08ac2 Fix parsing function statements containing invalid tokens (#3838)
Fixes #3821.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-04 11:25:25 +02:00
Robert Fancsik fe09200d61 Fix assignment lookahead in parser_process_group_expression (#3828)
This patch fixes #3815 and fixes #3819.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-03 15:29:26 +02:00
Robert Fancsik 4660bab16b Fix PropertyDefinition parsing in ObjectInitializer (#3832)
This patch fixes #3822 and fixes #3823 and fixes #3824 and fixes #3825.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-03 15:28:13 +02:00
Rafal Walczyna a56e31f194 Update ES6 Set and Map "size" accessor descriptors (#3826)
In ES6 accessors of built in object are by default configurable.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-06-02 18:01:45 +02:00
Robert Fancsik dc837d232d Fix incorrect assertion on ecma_op_function_has_instance (#3827)
This patch fixes #3814.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-06-02 16:16:21 +02:00
Dániel Bátyai 9ceece8eb4 Fix string position calculation in @@replace (#3831)
Fixes #3817.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-06-02 16:15:23 +02:00
Dániel Bátyai d06c3a7f50 Fix error handling in SerializeJSONProperty (#3816)
Fixes #3813.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-30 19:46:52 +02:00
Robert Fancsik 3b4c259281 Add support for builtin/builtin routine 'name' property (#3810)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-29 14:28:52 +02:00
Robert Fancsik 5895b96bdb Class extends expression should be parsed is strict mode (#3801)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-28 16:23:56 +02:00
Csaba Osztrogonác e76a1381e6 Update test262-es6-excludelist.xml. (#3808)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-05-28 15:10:54 +02:00
Csaba Osztrogonác ab3461b63d Fix tools/run-tests.py --test262-es2015 (#3803)
The output of the test262 runner changed between ES5.1 and ES6,
our script should respect it to signal regressions in return code too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-05-28 14:30:49 +02:00
Robert Fancsik d4fe48fae4 Script classes should be skipped during 'name' property lazy instantiation (#3809)
This patch fixes the TC262 language/expressions/class/name.js testcase.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-28 14:15:33 +02:00
Robert Fancsik 104001df68 Implement function name support for script functions and classes (#3745)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-28 12:33:21 +02:00
Zoltan Herczeg 562dcc8630 Fix Promise thenable. (#3799)
A single promise can be resolved any number of times due to
thenable functions, but each resolver pair can only be called once.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-28 10:48:44 +02:00
Dániel Bátyai c2b6621702 Fix adding entries to the internal buffer of a Map object (#3805)
When appending the key/value pair separately, garbage collection could be
triggered before the value is added, which could cause problems during
marking. This patch changes insertion to add both values at the same
time, which prevents partial entries from being present in the internal
buffer.

Fixes #3804.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-28 07:55:16 +02:00
Szilagyi Adam 7a20150ae7 Fix error handling in Reflect.defineProperty (#3800)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-27 18:57:15 +02:00
Robert Fancsik 69f8e78c2f Fix error handling in scanner when in case of OOM (#3793)
This patch fixes #3786 and fixes #3788.

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

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-26 15:28:54 +02:00
Péter Gál 908240ba62 Improve property key query for Proxy objects (#3797)
Property key query for Proxy objects always returned all keys
even if no symbols were requested symbols were present in the
resulting array.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-26 15:22:49 +02:00
Robert Fancsik dd6d148c3b Fix incorrect assertion in parser_parse_for_statement_start (#3795)
This patch fixes #3751.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-26 11:49:31 +02:00
Dániel Bátyai 15629e8ba5 Add stack limit check to proxy operations (#3796)
Fixes #3785.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-26 09:44:38 +02:00
Robert Fancsik 3060656562 Fix lazy property listing for [[Enumerate]] (#3794)
This patch fixes #3784.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-25 19:09:12 +02:00
Szilagyi Adam edaf4ef30f Rework the Reflect.preventExtensions method (#3771)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-25 18:25:09 +02:00
Szilagyi Adam 843c542053 Rework the Reflect.setPrototypeOf method (#3774)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-25 18:24:04 +02:00
Szilagyi Adam e50e2719df Get the typedArray's length property properly in Array.prototype.concat (#3791)
We should use the "length" property instead of the internal arraybuffer's length

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-25 18:10:38 +02:00
Szilagyi Adam ecf159795a Rework the Reflect.defineProperty method (#3770)
Also a minor update to the FromPropertyDescriptor operation since in ES6 we can use a property
descriptor whitout any keys

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-25 18:09:37 +02:00
Zoltan Herczeg 1105b43c22 Optimize Promise data structures. (#3768)
This patch reworks several structures:

- Fulfill and reject reactions are combined into one collection. The values in this collection
are compressed: a capability followed by an optional fulfill and reject functions.
- Fulfill and reject reactions are directly stored, no need to allocate an object for them.
- The job queue directly stores its items, this saves a pointer to the value, and the
callback is replaced by an uint8 type.
- Promise status and already resolved is stored in extra_info.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-25 18:00:43 +02:00
Péter Gál 1774cca47c Fix array length check in lastIndexOf (#3789)
When lastIndexOf is executed the array length can change and in
case of fast arrays the length should be re-checked.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-25 16:36:54 +02:00
Hyukwoo Park 589af6dc90 Handle properties of builtin routine separately from builtin objects (#3694)
separate builtin routine part to make code clear and to support 'name' property later

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-05-25 13:17:38 +02:00
Péter Gál 6fe6dab9cc Fix parseFloat input string length calculation (#3782)
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-25 13:05:18 +02:00
Robert Fancsik b2a2022d0a Fix property order in lazy property listing for builtin/external functions (#3780)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-25 13:00:21 +02:00
Szilagyi Adam f06c533a29 Change the Reflect.ownKeys method's length property (#3775)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-25 12:59:51 +02:00
Robert Fancsik b9258da7d0 Accessor functions should not have 'prototype' property (#3781)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-25 12:57:25 +02:00
Robert Fancsik 6cd309b525 Function.prototype[@@hasInstance] should not throw error for not callable this value (#3773)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-22 17:23:07 +02:00
Rafal Walczyna 876622a061 Fix vera++ rule to find expressions without space after parentheses (#3776)
Regex didn't include some characters that may occur after ')'

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-05-22 14:37:59 +02:00
Rafal Walczyna 5d6069176b Change raw string length calculation method (#3772)
New method uses length of source to calculate raw string length.

Also bug with template literal was fixed. Template object should have
indexed properties enumerable.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-05-22 10:11:47 +02:00
Péter Gál 87b1d1eeb0 Fix regexp flag handling in case of regexp like object (#3766)
The regexp flag should be correctly referenced and released
if an existing regexp like object is used for constructing a new one.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-21 14:51:50 +02:00
Péter Gál 08222992dc Fix parseFloat for non-infinity values (#3769)
The parseFloat method performed the "Infinity" string check
incorrectly.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-21 14:50:59 +02:00
Szilagyi Adam e1960621f3 Add new target support to RegExp object (#3723)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-20 17:10:55 +02:00
Rafal Walczyna a4659a888b Add support of escaping backslash and backtick to String.raw (#3736)
Template literals already supports escaping backslash and backtick,
this commit enables escaping this in String.raw.
It also fixes invalid behaviour of String.raw when using
new line character.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-05-20 13:26:01 +02:00
Péter Gál bbb5c9180e Fix releasing the pattern string in regexp (#3765)
The release of the regexp pattern string during creating
was incorrect as it was dereferenced a bit to early.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-20 12:10:05 +02:00
Dániel Bátyai 378244942f Fix iterator closing in Promise all/race (#3759)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-18 21:22:08 +02:00
Dániel Bátyai 7274fa4dd4 Fix rounding in Number.prototype.toFixed (#3747)
Fixes #3741.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-05-18 18:39:00 +02:00
Csaba Osztrogonác f0d443daec Add --test262-es2015 option to run-tests.py (#3667)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-05-18 16:43:17 +02:00
Zoltan Herczeg e01cfda0b8 Check next token before reparsing identifiers in object assignments. (#3756)
Fixes #3735.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-18 13:16:16 +02:00
Zoltan Herczeg c4d5c2c9e1 There is no block info after invalid if-function construct. (#3755)
Fixes #3713.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-18 13:15:16 +02:00
Zoltan Herczeg 2570f8e745 Move an assertion after post processing. (#3754)
Fixes #3752.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-18 13:14:17 +02:00
Zoltan Herczeg 09ac2ffa67 Update obsolote assert. (#3752)
Fixes #3713.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-18 13:13:43 +02:00
Mátyás Mustoha 0aad9cb431 Add native AArch64 testing to Travis (#3729)
Adds support for building and running the test suite on Travis CI
using native AArch64 containers.

JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2020-05-18 13:08:53 +02:00
Zoltan Herczeg bd1c4df9a6 Fix keyword parsing after use strict. (#3740)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-15 22:32:04 +02:00
Zoltan Herczeg 4aa27371b6 Array or object pattern must be assignment expression. (#3744)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-15 22:29:27 +02:00
Zoltan Herczeg 1f00d750b7 Implement parsing await. (#3738)
Several bugs fixed for parsing yield as well.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-15 22:26:05 +02:00
kisbg a6f6bce6f0 Added new target support for Date Object (#3739)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-05-15 22:21:40 +02:00
Mátyás Mustoha f13e8b602e Fix position calculations of String.startsWith (#3734)
Fixes two bugs in the index calculations that affect the result
of the `String.startsWith` function:

- Fixes the implementation of ECMA-262 v6, 21.1.3.18, step 14:
  "If searchLength+start is greater than len, return false".
- Fixes the return value of the helper function
  `ecma_builtin_helper_string_find_index`. If it is called with a
  starting search position, the returned index should be
  not less than that.

These changes fix the following test cases in the test262 suite:

- built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js
- built-ins/String/prototype/startsWith/searchstring-found-with-position.js

JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2020-05-15 22:18:42 +02:00
Daniella Barsony b51157d3c5 Add Array new target support (#3728)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-05-15 16:36:06 +02:00
Szilagyi Adam 95aa827635 Fix value release in ecma_builtin_regexp_dispatch_helper (#3702)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-14 17:10:27 +02:00
Mátyás Mustoha aaf0442611 Improve AArch64 support (#3712)
- Adds a CMake toolchain file for AArch64 to help with cross compilation
- Tests the AArch64 build on Travis and runs the test suite using QEMU

JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2020-05-13 14:56:30 +02:00
Robert Fancsik 9ad9d574fe Add proxy support for HasBinding operation for Object Environment records (#3731)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-13 14:27:31 +02:00
Zoltan Herczeg 4dc2cb3328 Implement proper creation of function arguments, let and const declarations. (#3725)
After the rework it is possible to detect use before init errors for function arguments.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-12 14:38:17 +02:00
Robert Fancsik df7e303145 Fix apply receiver operation for Proxy objects (#3730)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-11 16:56:41 +02:00
Szilagyi Adam 050fbfc130 Add Proxy support for JSON.stringify (#3685)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-11 15:18:18 +02:00
Szilagyi Adam 094ba2f30a Update the Array.prototype.reverse method to support ES6 version (#3676)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-11 13:42:46 +02:00
Szilagyi Adam 97a35b0f10 Add new target support to Function object (#3708)
Added steps 1, 2.c, 3.c, 21, 22 to ecma_op_create_dynamic_function

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-11 13:40:50 +02:00
Rafal Walczyna aa1777b1a0 Update ES6 Regexp accessors descriptors (#3726)
In ES6 accessors of built in object are by default configurable.
Also lastIndex property of RegExp object is created when only used.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-05-08 12:25:45 +02:00
Péter Gál 18fe546802 Fix appending elements for ecma collection (#3719)
During ecma_collection_append the underlying collection
was not increased in the required case. This triggered
a buffer overflow when processing the bound function's arguments
during call or during the Proxy ownKeys method.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-07 16:11:14 +02:00
Péter Gál 90c7eccb42 Fix fast array handling when doing put with receiver (#3720)
During "put" with receiver the fast arrays were not converted to normal
objects to correctly set properties on it.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
2020-05-07 09:00:50 +02:00
Rafal Walczyna 99859fb221 Fix prototype of NativeError objects (#3716)
Internal property [[Prototype]] of EvalError, RangeError, ReferenceError,
SyntaxError, TypeError and URIError should be Error.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-05-07 08:58:42 +02:00
Mátyás Mustoha 5af751263b Remove the unused ecma_op_check_object_type_is_class declaration (#3718)
Removes the unused `ecma_op_check_object_type_is_class` function
declaration from `ecma-helpers.h`. This also makes the file pass
the Doxygen check.

JerryScript-DCO-1.0-Signed-off-by: Mátyás Mustoha mmatyas@inf.u-szeged.hu
2020-05-07 08:56:31 +02:00
Daniella Barsony 8d08cec349 Update Travis build for OSx (#3721)
So far Travis doesn't support 10.15 (Catalina), but it does support a newer version (10.14, Mojave) than what we've been using (10.13, High Sierra).
This updates clang version too from 9.1.0 to 11.0.3.

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-05-06 14:01:03 +02:00
Szilagyi Adam 409e1fec5f Add missing index incrementation to ecma_builtin_string_object_raw (#3709)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-04 15:08:14 +02:00
kisbg 8ccb95c31c Added new target support to Promise (#3707)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-05-04 15:03:12 +02:00
Zoltan Herczeg 132a2008c9 Fix function argument handling issues caused by the parser. (#3705)
1) Nested function declarations should not overwrite arguments.
2) Functions should be created in the correct scope.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-05-04 14:55:46 +02:00
Robert Fancsik 40a9f27314 Fix __proto__ parsing in object literals (#3704)
Co-authored-by: Rafal Walczyna r.walczyna@samsung.com
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-05-04 14:49:15 +02:00
kisbg 14cea9c1ec Added new target support in Map, WeakMap, Set and WeakSet (#3701)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2020-05-04 14:24:39 +02:00
Szilagyi Adam b5d9699788 Update the RegExp.prototype.test function to support ES6 version (#3693)
The algorithm is based on ECMA-262 v6, 21.2.5.13

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-04 14:10:56 +02:00
Szilagyi Adam 1a72e070c8 Add value/key sign swap for Set.add and Map.set methods (#3681)
See also: ECMA-262 v6, 23.2.3.1 step 6 and 23.1.3.9 step 6

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-05-04 14:00:36 +02:00
Daniella Barsony 48e7b01fe9 Fix for OSx build (#3706)
Had an error on OSx when trying to build jerry, stating: "implicit conversion loses integer precision: 'cbc_opcopde_t' to 'uint16_t'"
Clang version: 11.0.3
OSx version: 10.15.4 (Catalina)

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-05-04 13:56:27 +02:00
Daniella Barsony 6ff299c831 Add [[GetOwnProperty]] internal Proxy method (#3672)
Depends on #3662

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-04-30 15:51:23 +02:00
Zoltan Herczeg 4b780507e1 Implement throwing const re-assignment error. (#3697)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-29 15:50:22 +02:00
Zoltan Herczeg 9e6c44be4f Fix function declaration issues inside catch blocks. (#3700)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-29 13:53:14 +02:00
Zoltan Herczeg 85401db547 Support function statements after 'if' or 'else'. (#3699)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-29 13:50:01 +02:00
Szilagyi Adam 2bdd0f5008 Accessor functions do not have [[Construct]] internal method (#3698)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-04-29 13:04:57 +02:00
Szilagyi Adam 62730f2ae1 Implement Proxy object [[DefineOwnProperty]] internal method (#3662)
The algorithm is based on ECMA-262 v6, 9.5.6

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-04-28 09:51:01 +02:00
Zoltan Herczeg f254b1a8b7 Fix invalid / unhandled this_literal cases. (#3696)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-27 14:54:21 +02:00
Zoltan Herczeg 4e8dac8ce1 Implement exponentiation operation. (#3692)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-27 11:43:35 +02:00
Zoltan Herczeg daeee77d63 Fix invalid assignment code generation. (#3695)
This patch prevents assigning a value to a string literal after a this token.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-27 10:14:29 +02:00
Zoltan Herczeg e2807c28fa Implement separate context for arguments. (#3686)
Fixes #3396.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-24 16:55:12 +02:00
Zoltan Herczeg dcf8ccfd03 Function declaration outside of blocks in direct eval must be ES5.1 compatible. (#3690)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-24 10:45:14 +02:00
Hyukwoo Park 1b1460e61f Fix attributes of length property for builtin functions (#3689)
fix length property of builtin functions to be configurable (ECMA-262 v6, 19.2.4.1)

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-04-22 08:36:23 +02:00
Rafal Walczyna bcd5ff3f40 Implement missing hyperbolic Math functions from ES6 (#3670)
Math.cosh, Math.sinh, Math.tanh

C implementation ported from fdlibm.

Part of Issue #3568

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-04-21 12:34:38 +02:00
Robert Fancsik d1bf9635c7 Fix incorrect assertion in parser_parse_for_statement_start (#3679)
This patch fixes #3655.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-04-21 12:00:39 +02:00
Zoltan Herczeg 3900152631 Fix delayed variable creation for function declarations. (#3687)
Fixes #3658.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-21 11:59:30 +02:00
Rafal Walczyna 0269b6c25d Fix is_constructor of bound function (#3684)
Bound function created from built-in function does not have a constructor

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-04-21 11:58:29 +02:00
Zoltan Herczeg 52f1476061 Fix assignment expression pre-scanning for arrow functions. (#3688)
Fixes #3656.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-21 11:25:36 +02:00
Robert Fancsik b209e95daa Fix iterator step calculation for bracketed property expressions (#3678)
This patch fixes #3665.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-04-20 19:32:59 +02:00
Rafal Walczyna 9c7a699d10 Implement missing Math Inverse Hyperbolic functions (#3675)
Math.acosh, Math.asinh, Math.acosh

C implementation ported from fdlibm

Part of Issue #3568

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-04-20 15:41:06 +02:00
Rafal Walczyna 453da11398 Implement missing Math.cbrt function from ES6 (#3680)
C implementation ported from fdlibm

Part of Issue #3568

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-04-20 15:40:03 +02:00
Zoltan Herczeg 1b01171a60 Update forcing of lexical environment creation for functions. (#3683)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-20 09:30:17 +02:00
Zoltan Herczeg 4be9ffda84 Use symbolic constants for code size checks. (#3682)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-17 13:05:07 +02:00
Daniella Barsony 895973ca82 Update device list in ReadMe (#3677)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-04-16 10:06:11 +02:00
Robert Fancsik 58257040dc Fix lexical binding set in VM_OC_COPY_TO_GLOBAL (#3653)
This patch fixes #3647.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-04-15 18:08:58 +02:00
Daniella Barsony e5702edab4 Update Babel ReadMe (#3673)
Remove Array.prototype.fill and Array.from from missing features that requires polyfill

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-04-15 16:53:14 +02:00
Robert Fancsik b5977de99c Fix lazy property name listing for ArrayIndices. (#3651)
This patch fixes #3648.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-04-15 15:21:06 +02:00
Szilagyi Adam d82bbb1c77 Update the isArray operation to handle proxy objects (#3666)
Added step 3. from ECMA-262 v6, 7.2.2

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-04-15 12:00:15 +02:00
Szilagyi Adam 4342c9ea6f Implement Proxy object [[OwnPropertyKeys]] internal method (#3639)
The algorithm is based on ECMA-262 v6, 9.5.12

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-04-14 16:57:47 +02:00
Robert Fancsik 60db840cf4 Fix super property assignment for namedaccessor properties (#3654)
Tha patch also updates the [[Put]] internal method with the new steps from the ES6 standard.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-04-09 17:08:08 +02:00
Szilagyi Adam 901e57c7d0 Implement Proxy object [[Construct]] internal method (#3657)
The algorithm is based on ECMA-262 v6, 9.5.14

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-04-06 12:17:23 +02:00
Dániel Bátyai 48fa2ec01b Fix the types of builtin prototype objects (#3663)
In ES2015 many builtin prototypes are no longer valid instances of their
respective classes. This change updates affected prototypes to be
regular objects as required.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-04-06 12:00:58 +02:00
Hyukwoo Park 73a78bd223 Fix attributes of length property for bound function (#3659)
fix length property of bound function objects to be configurable (ECMA-262 v6, 19.2.4.1)

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-04-04 02:04:02 +02:00
Rafal Walczyna e470b13096 Implement missing Math logarithm functions from ES6 (#3617)
Math.log2, Math.log10, Math.log1p, Math.expm1

C implementation ported from fdlibm

Part of Issue #3568

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-04-04 02:00:41 +02:00
Péter Gál c74256ccba Fix objects foreach unittest (#3660)
The `jerry_objects_foreach` unittest incorrectly
tried to create Map objects. Added extra checks
and improved the Map object creation.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-04-04 01:43:52 +02:00
Zoltan Herczeg 28f2772d9c Python debugger cleanup (#3635)
- Rename scopes to scope
- Make functions private
- Reorder some functions

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-04-02 17:57:23 +02:00
Csaba Osztrogonác 1bd1a36a81 Bump reference platform to Ubuntu 18.04 LTS (#3037)
Ubuntu 14.04 reached its end of life on April 30m 2019.
Let's bump the reference to the latest LTS, which is 18.04.

Ubuntu 18.04 has newer Pylint and Cppcheck, the necessary
fixes and suppresses are also included in this PR.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-03-30 12:26:56 +02:00
Péter Gál c237ba6097 Fix Array.slice when using fast arrays (#3649)
When a fast array was used during the Array.slice call and
the input array's properties were removed the property
list was used incorrectly.

Fixes: #3637

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-03-27 21:24:08 +01:00
Robert Fancsik d63936f371 CBC_PUSH_THIS should not be mutated in array literal parsing. (#3652)
This patch fixes #3650 and slightly reverts the changes of #3594.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-27 21:20:37 +01:00
Szilagyi Adam 4240b740aa Implement Object.prototype.__proto__ accessor property (#3546)
We are using the already existing Object.getPrototypeOf and
Object.setProtoypeOf methods

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-27 14:46:51 +01:00
Szilagyi Adam 94b8b4bb7b Implement Proxy object [[HasProperty]] internal method (#3642)
The algorithm is based on ECMA-262 v6, 9.5.7

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-27 14:33:56 +01:00
Robert Fancsik 3c7a776cae Fix heap-buffer-overflow in ecma_collection_append (#3645)
This patch fixes #3628.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-27 11:28:36 +01:00
Robert Fancsik 2ed742a9e7 Fix invalid free in ecma_op_function_get_super_constructor (#3644)
This patch fixes #3636.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-27 11:28:23 +01:00
Robert Fancsik 76b8555210 Remove JERRY_CONTEXT_INVALID_NEW_TARGET (#3643)
Until now JERRY_CONTEXT_INVALID_NEW_TARGET was used to represent whether the eval called from the script directly.
This information can be retrieved from the parser, so it simplifies the runtime handling of the new.target.

This patch fixes #3630, fixes #3640 and fixes #3641.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-27 11:21:50 +01:00
Virag Orkenyi 14bcc98089 Change the arguments list in ecma_builtin_array_reduce_from . (#3638)
This change deletes two routine arguments and creates an argument list in their place.

JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-03-27 11:20:25 +01:00
Péter Gál 43a36c9673 Fix VLA error in strings unittest (#3632)
In the test-api-string.c there was an error if the unittests are built in release.
Full error message:
```
tests/unit-core/test-api-strings.c:89:20: error: variable-length array bound is unknown [-Werror=vla-larger-than=]
89 |   JERRY_VLA (char, string_from_cesu8_string, cesu8_sz);
```

The problem is that the compiler does not know if the buffer size is always greater than zero.
Added an extra check to the TEST_ASSERT a line above to resolve the error.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-03-27 11:11:30 +01:00
Szilagyi Adam 6a022eb265 Implement Proxy object [[setPrototypeOf]] internal method (#3631)
The algorithm is based on ECMA-262 v6, 9.5.2

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-27 11:10:55 +01:00
Akos Kiss f29e6f9020 Fix undefined overflow behavior when converting double to integer (#3629)
Overflows in conversions from floating-point to integer are
undefined behavior in the C99 standard. (Clause 6.3.1.4: "If the
value of the integral part cannot be represented by the integer
type, the behavior is undefined.")

When UBSAN is enabled, this gets reported at `srand()` calls. (The
random seed is usually initialized using the date port API, which
represents dates as `double`s. But `srand` takes an `unsigned int`.
A simple cast from `double` to `unsigned` becomes undefined
behavior if the value is too large. And "now" is too large
nowadays. So, effectively, all executions start with an undefined
behavior.)

This patch fixes this by casting the floating-point value of the
date to an integer through a union.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2020-03-27 11:03:28 +01:00
Virag Orkenyi 18a4cba062 Implement Number.parseFloat and Number.parseInt (#3576)
The Global object parseFloat and parseInt fuctions have been moved to the number helpers and intrinsic properties have been created the are used for both the Number and Global methods.

JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-03-27 10:50:49 +01:00
Szilagyi Adam d539d30bf9 Update the RegExp constructor to ECMA-262 v6 (#3538)
The following methods have been implemented:
- RegExpAlloc, based on ECMA-262 v6, 21.2.3.2.1
- RegExpInitialize, based on ECMA-262 v6, 22.2.3.2.2
- RegExpCreate, based on ECMA-262 v6, 21.2.3.2.3

Co-authored-by: Robert Fancsik frobert@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-27 10:37:06 +01:00
Szilagyi Adam 56832d772e Implement Proxy object [[getPrototypeOf]] internal method (#3623)
The algorithm is based on ECMA-262 v6, 9.5.1

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-26 14:22:12 +01:00
Péter Gál 655110ad7b Add a Proxy C unittest (#3633)
Previously only the Proxy api was tested.
Added a unittest to check the C callbacks via proxy.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-03-24 11:23:20 +01:00
Robert Fancsik 5b6d4f39b1 Add missing ecma_free_value to opfunc_init_class (#3626)
This patch fixes #3625.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-19 17:24:03 +01:00
Szilagyi Adam b2e54e915b Implement Proxy object [[Delete]] internal method (#3616)
The algorithm is based on ECMA-262 v6, 9.5.10

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-18 16:52:24 +01:00
Szilagyi Adam 85fced2632 Impelement Proxy object [[preventExtensions]] internal method (#3620)
The algorithm is based on ECMA-262 v6, 9.5.4

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-18 16:51:02 +01:00
Roland Takacs 51a9575fd0 Use array based storage in container objects (#3600)
Currently, collections use object based solutions for storing elements and
iterating on them. If an element is deleted and re-inserted, the storage
position is the same as before so the iteration order is wrong.
This patch replaces the object based storage with an array based solution
that helps to store and iterate elements as expected.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-03-17 19:30:55 +01:00
Zoltan Herczeg 1cfda262bd Catch paramter must not be scanned as function in ES5.1 (#3618)
Fixes #3554

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-03-17 13:06:59 +01:00
Szilagyi Adam 7ea93aff4c Fix assignment validation in parser_append_binary_token (#3594)
Fixes #3589

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-16 15:02:37 +01:00
Robert Fancsik c305aee80f Fix for-in/off block context initialization for empty destructuring patterns (#3614)
This patch fixes #3611.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-16 14:53:02 +01:00
Robert Fancsik 7f67795326 Spread operator should not update the scanner context's binding type (#3613)
This patch fixes #3595.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-16 14:52:05 +01:00
Szilagyi Adam bc7c39d893 Implement helper method for Proxy object internals (#3612)
This method generally does the steps 2-5 in the proxy internal methods

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-16 14:47:04 +01:00
Robert Fancsik 1a8276c493 Conditional expression should be parsed as AssignmentExpression (#3610)
This patch fixes #3553 and fixes #3608.

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

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-16 14:37:47 +01:00
Szilagyi Adam 56b9f098ab Impement Proxy object [[isExtensible]] internal method (#3599)
The algorithm is based on ECMA-262 v6, 9.5.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-15 13:26:23 +01:00
Szilagyi Adam ccca998f43 Implement Proxy object [[Set]] internal method (#3605)
The algorithm is based on ECMA-262 v6, 9.5.9

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-14 20:06:27 +01:00
Hyukwoo Park 47d85a12e2 Fix attributes of length property for function objects (#3570)
fix length property of function objects to be configurable (ECMA-262 v6, 19.2.4.1)

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-03-12 15:00:53 +01:00
Robert Fancsik 6ef0a0e07e Fix the lazy listing of builtin property names (#3607)
This patch fixes #3606.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-12 12:45:53 +01:00
Zoltan Herczeg 57b8599581 Fix some style issues in the python debugger client. (#3603)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-03-11 16:01:12 +01:00
Daniella Barsony 055f753d02 Implement Proxy object [[Call]] internal method (#3609)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-03-11 15:38:16 +01:00
Szilagyi Adam 64fd37d1db Implement Proxy object [[Get]] internal method (#3604)
The algorithm is based on ECMA-262 v6, 9.5.8

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-11 15:34:46 +01:00
Rafal Walczyna 38862c39a6 Fix setting integrity level, when object has Symbol properties (#3602)
Symbol type properties were not included in SetIntegrityLevel operation

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-03-10 18:14:54 +01:00
Daniel Balla 9509c3da85 Add Map, Set, WeakMap, WeakSet basic functionality to the API (#3502)
JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-03-10 18:10:56 +01:00
Csaba Osztrogonác 72f8ef344c Implement missing Math functions from ES6 standard (#3593)
First step to fix issue #3568.

Changes:
- Implemented Math.clz32(), Math.fround(), Math.imul(), Math.hypot().
- Implemented all remaining Math functions with calling the standard
libm functions, but they throw UNIMPLEMENTED exception with jerry-libm,
because the necessary fdlibm functions are missing and should be ported.

All Math related test262 tests pass (except function name and length tests)

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-03-10 11:15:00 +01:00
Hyukwoo Park 6c3a42ec48 Add es5.1 specific directory in jerry-test-suite (#3567)
since compatibility issues between es5.1 and es6 exist,
es5.1 specific directory is newly added which includes es5.1 specific test.

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-03-06 14:17:05 +01:00
Szilagyi Adam 651b62584a Use stringbuilder in jerry_debugger_exception_object_to_string (#3586)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-04 18:06:40 +01:00
Szilagyi Adam 23974e2389 Use stringbuilder in ecma_raise_standard_error_with_format (#3585)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-04 18:05:08 +01:00
Szilagyi Adam 76bbb088e9 Optimize Array.prototype.fill for fast-array cases (#3569)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-03 15:48:50 +01:00
Rafal Walczyna 3c8a6ca71d Fix error for duplicated names in ArrowFunction paremeter list (#3597)
Duplicated parameter names are not allowed for arrow functions
regardless of strict mode.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-03-03 09:18:27 +01:00
Hyukwoo Park 34edf53753 Add new type which represents pointer with tag value (#3591)
jmem_cpointer_tag_t is newly added to represent pointer along with tag value.
This new type is first applied to scope_cp to mark initailized function properties (length, name) later

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-03-02 15:59:55 +01:00
Roland Takacs 19c61e14c0 Fix float point number comparsion (#3596)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
2020-03-02 15:57:11 +01:00
Szilagyi Adam aa17a4fa5d Implement ecma_stringbuilder_create_raw method for stringbuilder (#3584)
With this new method, we can create a stringbuilder from a raw string

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-02 15:39:12 +01:00
Robert Fancsik ec39d08d67 Fix object destructuring for empty pattern (#3571)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-03-02 15:37:03 +01:00
Péter Gál f31931267a Fix argument flags when invoking native function via construct (#3590)
When calling a native function via construct it should not have any
flags in the argument list pointer.

Fixes: #3588

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-03-02 10:37:41 +01:00
Szilagyi Adam a6acf2d417 Fix value release in ecma_builtin_array_prototype_object_copy_within (#3583)
Fixes #3580

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-03-02 10:28:02 +01:00
Robert Fancsik 4e136c8973 Implement the core of Proxy object (#3562)
- Internal routines of the of the proxy object are unimplemented
 - For-in enumerate with proxy target is currently not supported

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-02-28 14:41:59 +01:00
Robert Fancsik 9b393ee2ea Remove ECMA_OBJECT_TYPE_ARROW (#3582)
Until now arrow functions had a separate type, but most of the time they can be handled similar to single functions.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-02-25 13:28:50 +01:00
Rafal Walczyna 20300189cb Fix Symbol properties descriptors. (#3581)
Symbol properites descriptors had invalid values

Fixes #3578

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-02-24 14:06:14 +01:00
Szilagyi Adam 6430d1a3a3 Use stringbuilder in static_snapshot_error_unsupported_literal (#3574)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-24 11:34:07 +01:00
Zoltan Herczeg bd2696f7c7 Add global status flags for the parser. (#3572)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-02-24 11:22:20 +01:00
Szilagyi Adam cdbabc8c30 Use stringbuilder in ecma_builtin_try_to_instantiate_property (#3575)
Also removed the ecma_append_magic_string_to_string method,
because it doesn't get used anymore.

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-24 11:19:04 +01:00
Szilagyi Adam acbdb4184f Use stringbuilder in ecma_builtin_typedarray_prototype_join (#3573)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-24 11:15:36 +01:00
Daniella Barsony 73daeb19c9 Implement new Reflect methods (#3549)
This patch implements the get, set, has, deleteProperty, ownKeys, and construct methods of the Reflect objects. The Reflect.construct method is missing the new_target support because ecma_op_function_construct doesn't support it yet.

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2020-02-24 11:02:06 +01:00
Dániel Bátyai 68909fc5de Fix lexical scoping between scripts (#3558)
This change fixes the handling of lexical blocks when executing multiple
scripts, and also fixes a few issues with module environments.

After this change, all script files will run in the same context and
will have access to lexically scoped global variables of previous
scripts, and module environments will no longer have a bound global
'this' value.

The REPL implementation in main-unix is also fixed to correctly handle
lexically scoped variables.

Fixes #3561.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-02-21 13:30:48 +01:00
Szilagyi Adam b0a575b049 Use stringbuilder in vm_get_backtrace (#3566)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-20 13:01:04 +01:00
Szilagyi Adam f8da3d5e9d Remove vm_init_loop (#3551)
For every bytecode in the above function, i created a new VM_OC group code
to be able to execute them in the vm_loop. With this update, the expectation
is a faster runtime.

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-19 16:49:35 +01:00
rwalczyna 98b90ba697 Fix third parameter of forEach callback function in Map and Set (#3565)
There was a problem with passing third parameter to callback.

This patch fixes #3564

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-02-18 19:22:08 +01:00
rwalczyna 0ff664cab6 Fix Array.find and Array.findIndex omitting empty values. (#3563)
Empty values in array were omitted. Predicate should be called
for every element from 0 to length.

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-02-18 15:19:53 +01:00
Szilagyi Adam 181570ff41 Implement EscapeRegExpPattern method (#3543)
the algorithm is based on ECMA-262 v6, 21.2.3.2.4

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-18 09:49:54 +01:00
Zoltan Herczeg fda02d4b2a Fix local scoping for functions. (#3559)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-02-18 09:49:03 +01:00
Szilagyi Adam 44e63e038d Use stringbuilder in ecma_get_symbol_descriptive_string (#3560)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-18 09:47:53 +01:00
Hyukwoo Park 54e4de39ab Fix attributes of length property for builtin objects (#3556)
* length property has the attributes {[[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true} based on ECMA-262 v6, 19.2.4.1

JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
2020-02-14 10:25:26 +01:00
Szilagyi Adam 4d67ac3225 Use stringbuilder in ecma_builtin_string_prototype_object_concat (#3557)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-13 17:42:07 +01:00
Zoltan Herczeg 4b325ea9e3 Rework map_to member of the scope chain that it can store flags. (#3552)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-02-13 17:39:56 +01:00
Szilagyi Adam 8cd5d06620 Update ecma_op_typedarray_from to use iterable objects (#3501)
Added steps 6-8 from ECMA-262 v6, 22.2.2.1.1

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-02-13 15:53:41 +01:00
Robert Fancsik 5fdeb7c1d6 [[Prototype]] object's reference count should be increased by jerry_get_prototype (#3550)
This patch ensures that the implementation satisfies the requirements of the public API documentation.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-02-07 18:20:39 +01:00
Dániel Bátyai d7404700ad Update API version to 2.2.0 (#3547)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-02-07 15:38:49 +01:00
Paul Sokolovsky b044d4ad76 jerry_init: Calculate structure part address more safely. (#3545)
GCC 9.2 issues a warning-as-error trying to perform a large memset into
what it thinks as a single field of a structure. So, instead of taking
an address of that field, perform explicit address calculaton using
structure address and offset of that field.

Fixes #3544.

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2020-02-06 14:18:19 +01:00
Péter Gál 0d7f26e2c4 Add a few missing api version documentation (#3542)
A few api method/struct documentation did not have the
entry describing in which version it was introduced.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-02-04 13:17:24 +01:00
Péter Gál fa81944743 Foreach API methods should not iterate over internal objects (#3537)
The `jerry_objects_foreach` and `jerry_objects_foreach_by_native_info` methods
iterates over all objects. However in ES 2015 there are a few special objects
which should only be used internally thus these objects should not be accessed
by the API user.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-02-03 19:07:24 +01:00
Dániel Bátyai a78c8d4f16 Add vera rules to check consecutive and trailing empty lines (#3540)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2020-02-03 16:39:04 +01:00
Robert Fancsik 563a5d93e9 Fix 'arguments' and 'caller' properties lazy listing in ES2015 profile (#3539)
This patch fixes #3536.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-02-03 15:12:59 +01:00
Robert Fancsik 7734f87fbb For in-of declaration should only throw error after initialization. (#3541)
This patch fixes the error introduced in #3513.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-02-03 15:12:12 +01:00
Szilagyi Adam 2fe06f82f1 Add strict mode check to for-in and for-of header in parser_parse_for_statement_start (#3513)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-28 13:24:30 +01:00
Robert Fancsik b73100d933 Add missing release value call to Array.prototype.pop fast path. (#3535)
This patch fixes #3534.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-24 10:54:55 +01:00
Robert Fancsik e693854dae Fix array-indexed property name calculation for fast access mode arrays in property name listing (#3533)
This patch fixes #3532.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-23 17:21:35 +01:00
Robert Fancsik 3c5fb342be Update "arguments" and "caller" properties of function object to conform ES6 changes (#3530)
This patch resolves #3393.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-23 15:53:37 +01:00
Csaba Osztrogonác b7a2a153aa Fix the build with enabled debugger on Windows (#3531)
Changes:
- Typo fixed in cmake build system and appveyor config
- Added a new buildoption test

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-01-23 15:30:09 +01:00
Péter Gál 608bc9e5ff Improve new.target handling in case of eval calls (#3517)
Only direct eval calls propagate the "new.target" information.
In any other eval cases the "new.target" invocation is a syntax error.

Added test cases also.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-01-21 18:01:35 +01:00
Robert Fancsik 05b4bda927 Colon must be expected after computed property name in object destructuring (#3529)
This patch fixes #3527.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-20 16:49:08 +01:00
Péter Gál 24af089643 Introduce new.target C api (#3522)
Added new "jerry_get_new_target" API function
and updated the unit test.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-01-18 10:58:33 +01:00
Daniel Balla f46d061d19 Allow API usage in native_free_callbacks (#3515)
This patch allows the use of API functions in native_free_callbacks for native pointers once again.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-01-18 10:05:32 +01:00
Robert Fancsik 71d4e12105 Fix assignment opcode transformation for CBC_PUSH_THIS_LITERAL (#3525)
This patch fixes #3477.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-17 11:37:10 +01:00
Robert Fancsik c4948936c2 Add missing release value to ecma_op_object_get_property_names (#3524)
This patch fixes #3523.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-17 11:36:40 +01:00
Zoltan Herczeg f3d49f65dd Always mark the identifers which are propagated to upper level after argument parsing. (#3516)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-16 17:01:56 +01:00
Zoltan Herczeg 22eabd0e0b Allow an extra comma before the end of a function call. (#3520)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-16 17:00:49 +01:00
Péter Gál daf3b36ea6 Fix new.target invalidity check (#3521)
Fixes #3519

Only check the assert if the new.target bytecode is detected.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-01-16 16:03:59 +01:00
Peter Marki 51244b6d08 Add option to list symbols in Object.getOwnPropertyNames() (#3507)
Also a little refactoring of Object.getOwnPropertyNames()

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-01-16 15:59:27 +01:00
Robert Fancsik 8b41bf306a Introduce builtin intrinsic object to share property values between builtin objects (#3490)
Fixed:
 - Global symbol access
 - Array.prototype.values and Array.prototype[Symbol.iterator] must be the same function object

To test the new functionality arguments object Symbol.iterator property is added.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-16 15:57:27 +01:00
Daniel Balla 332e216736 Add runtime option "--call-on-exit [FUNCNAME]" to main-unix.c (#3518)
With this option you can call a function after the user script and promises have ran, to be able to do assertions that are executed just before the process would exit.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-01-15 17:10:42 +01:00
Robert Fancsik 4a331b2edc Add builtin GeneratorFunction support (#3499)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-15 12:01:58 +01:00
Csaba Osztrogonác e3decffdd3 Make run-test-suite.py handle crashes properly (#3512)
Changes:
- Crashing jerry / jerry-snapshot is always "FAIL",
only the 1 return code is accepted as expected fail.
- "FAIL (XPASS)" string is only used if the test marked
as expected fail, but the return code is 0.
- Simple "FAIL" string is used if the test marked as expected
fail, but the return code is not 0 or 1. (crash)

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-01-15 09:14:51 +01:00
Robert Fancsik 210b631b21 Fix iterator position calculation for array patterns (#3494)
This patch fixes #3455.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-14 16:03:26 +01:00
Peter Marki c8ce7d8791 Construct non-fast array in ecma_op_array_species_create (#3514)
Fixes #3506

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-01-14 15:35:49 +01:00
Zoltan Herczeg 0d7b461185 Correctly handle celestial plane codepoints in ES5.1. (#3510)
Fixes #3498.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-14 15:11:59 +01:00
Zoltan Herczeg d6070a9fed Call filter arguments after the global arguments are parsed. (#3511)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-14 15:10:19 +01:00
Péter Gál 0fd1ed6f27 Add support for new.target (#3469)
Notable changes:
* Extracted the pure JS/builtin and external C method invocations
  into two new methods (`ecma_op_function_call_{simple, external}`).
* Updated parser/scanner to handle "new.target" correctly.
* Added JS test case.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2020-01-14 13:34:19 +01:00
Robert Fancsik be8ae3aae8 Add iterator close support for for-of statement (#3401)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-13 17:38:47 +01:00
Zoltan Herczeg f1dd59e4bd Property modifiers should not be checked before an equals. (#3509)
Fixes #3434.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-13 15:14:29 +01:00
Zoltan Herczeg 9a8160176c Nested destructuring binding patterns should inherit the PARSER_PATTERN_ARGUMENTS flag. (#3508)
Fixes #3398.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-13 15:13:57 +01:00
Robert Fancsik be83ff6b71 Update Function.prototype.bind to conform ES6 requirements (#3504)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-13 11:43:11 +01:00
Robert Fancsik d0e8629342 Support nested destructuring patterns in catch header (#3488)
This patch fixes #3433.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-13 11:39:07 +01:00
Daniel Balla 1725e014b8 Support iterable objects in Promise.all and Promise.race functions (#3496)
JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-01-10 15:44:52 +01:00
Szilagyi Adam c407e8a04c Refactor ecma_builtin_error_prototype_object_to_string to use stringbuilder (#3503)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-10 15:40:00 +01:00
Virag Orkenyi b6c2e6eb54 toNumber operation should handle binary and octal literals (#3471)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2020-01-10 15:31:54 +01:00
Robert Fancsik b3b1dfdabd Tagged template object references should be released only in post_processing (#3495)
This patch fixes #3483.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-10 15:25:40 +01:00
László Langó 2960dffb50 Support all literals in 'jerry_get_literals_from_snapshot' when C format is used. (#3472)
The literals must be saved in hex format to support cases with special
characters, like `var s = 'hello",\n"world';`

JerryScript-DCO-1.0-Signed-off-by: László Langó lango@inf.u-szeged.hu
2020-01-10 14:57:10 +01:00
Peter Marki 08da8bc7aa Add length check to ecma_builtin_array_prototype_object_slice (#3481)
Fixes #3479

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-01-10 12:16:53 +01:00
Robert Fancsik dc3de8d8ae Fix for-of block context creation for empty destructuring pattern (#3492)
This patch fixes #3421.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-08 14:55:02 +01:00
Szilagyi Adam aedd55b1f8 Add unscopables check to ecma_op_get_value_lex_env_base (#3476)
Also added a special test case for this to symbol-unscopables.js

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-07 15:13:28 +01:00
Robert Fancsik 003694d259 Throw error for generator function class constructor (#3489)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2020-01-07 14:52:01 +01:00
Szilagyi Adam 22e52e45af Fix value release in ecma_builtin_typedarray_prototype_map (#3491)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-07 14:25:59 +01:00
Roland Takacs 420643d645 Use Python 3.6 in case of Zephyr target (#3493)
PyYAML requires Python 2.7 or Python 3.4+.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs r.takacs2@partner.samsung.com
2020-01-07 12:53:53 +01:00
Csaba Osztrogonác 9e0709e401 Fix Array.prototype.reduce and reduceRight (#3487)
Don't throw TypeError when object length is 0 and initialValue is undefined.
Additionally the error message should be more precise and match other engines.

Fixes #3463

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-01-06 15:17:54 +01:00
Szilagyi Adam 40b38f70ef Refactor ecma_regexp_exec_helper arguments (#3484)
We use pointers instead of ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-06 14:38:09 +01:00
Szilagyi Adam 183600dff2 Refactor ecma_op_same_value (#3486)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2020-01-06 14:33:46 +01:00
Zoltan Herczeg fa2ddb2466 Create a new file for scanner operations. (#3475)
Compared to utils, the functions here scan the input (e.g. uses lexer_next_token).

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-06 11:05:39 +01:00
Peter Marki 300570381f Add fast-path check to ecma_builtin_array_prototype_slice (#3480)
Fixes #3459

JerryScript-DCO-1.0-Signed-off-by: Peter Marki marpeter@inf.u-szeged.hu
2020-01-06 10:30:10 +01:00
Zoltan Herczeg dc15944ebd Remove lexer_process_char_literal function. (#3474)
Add a test for using large literals.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2020-01-06 10:13:05 +01:00
Daniel Balla e21e4a18ba Fix freeing this_arg in ecma_builtin_promise_race_or_all (#3482)
Fixes #3478

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2020-01-03 14:18:40 +01:00
Csaba Osztrogonác 518fcf2c6a Optimize ecma_number_to_uint32 (#3470)
The ecma_number_to_uint32 function is called many times, we can merge
ecma_number_is_nan and ecma_number_is_infinity checks to !ecma_number_is_finite
to let the compiler generate more optimal code for it.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-12-20 12:37:02 +01:00
Zoltan Herczeg 8cb2be6001 Support parsing async modifiers for functions. (#3460)
Only parsing is implemented, so the async functions currently behave
like normal function except they return with a resolved Promise object
when the function is terminated correctly.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-20 09:55:41 +01:00
Dániel Bátyai 2a29b72a83 Implement and add support for Symbol.split (#3453)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-12-20 09:10:58 +01:00
Csaba Osztrogonác 85bb2113fe Make Math.min() and Math.max() ECMA262 conform (#3465)
Math.min() and Math.max() functions should apply ToNumber on each arguments
always, even if a NaN argument occured previously and the result will be NaN.

ECMA262 v5.1 15.8.2:
"Each of the following Math object functions applies the ToNumber abstract
operator to each of its arguments (in left-to-right order if there is more
than one) and then performs a computation on the resulting Number value(s).

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-12-20 08:57:17 +01:00
Robert Fancsik ea5ad2a06f Fix the parsing/scanning of empty return statement (#3468)
This patch fixes #3467.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-19 19:31:59 +01:00
Robert Fancsik 9596a7e1d6 Implement tagged template literals (#3456)
Missing features: snapshot support

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-19 19:10:45 +01:00
Szilagyi Adam 7bfbc701d8 Implement Symbol.unscopables (#3405)
Added a new property for Array.prototype based on ECMA-262 v6, 22.1.3.31
Also upgraded the HasBinding operation with ECMA-262 v6, 8.1.1.2.1 steps 7-9

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-19 16:34:23 +01:00
Daniel Balla 52616f7d8c Early return when the scanner throws an error while parsing an invalid function identifier (#3464)
Fixes #3454

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2019-12-19 15:50:09 +01:00
Csaba Osztrogonác 456fb046ba Remove asserts from ecma_number_is_zero and is_inf (#3466)
There is no reason to force the developer to call ecma_number_is_nan
check before all ecma_number_is_zero and ecma_number_is_infinity.
These functions work fine and return false if NaN is passed.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-12-19 15:36:56 +01:00
Péter Gál d27a07edf4 Add missing assert entry in case of static super assignment (#3462)
In case of static super member assignments there was a missing
check to validate if the CBC opcode is of CBC_EXT_PUSH_STATIC_SUPER.

Fixes: #3458

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-12-19 12:38:38 +01:00
Szilagyi Adam e2893f26a1 Add iterator closing for ecma_op_container_create (#3457)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-19 11:40:29 +01:00
Zoltan Herczeg d0b4e7dd04 Free three parser status flag bits. (#3451)
The operations covered by these bits can be done in a different way.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-17 11:43:37 +01:00
László Langó 0428b51e35 Uncomment some fixed test cases (#3452)
After #3440 the Symbol related test cases runs fine for
Arrays, so the TODO had been resolved in that particular
test file.

JerryScript-DCO-1.0-Signed-off-by: László Langó lango@inf.u-szeged.hu
2019-12-17 11:42:56 +01:00
Szilagyi Adam b6f2ff1ba7 Implement binary literal parsing (#3439)
This patch will allow the user to use binary literals starting with 0b or 0B,
these literals will be evaluated in parsing time resulting an integer

Co-authored-by: Robert Fancsik frobert@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-17 11:42:29 +01:00
Zoltan Herczeg 3c0beaf87d Support strict mode detection in the pre-scanner. (#3450)
Furthermode an error is thrown when 'use strict' is used in a function with non-simple arguments
and function arguments are not moved to lexical environment when unmapped arguments are present.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-17 10:59:03 +01:00
Zoltan Herczeg b1237dbc5a Detect keyword type even if the keyword is identifier. (#3448)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-16 13:36:26 +01:00
Daniel Balla e0d8c4ca10 Add @@species accessor to Array and Promise builtin objects (#3440)
Fully support @@species and SpeciesConstructor in Array and Promise builtins.
Also added partial support to TypedArrays, but a rework is needed in %TypedArray%.prototype functions' typedarray constructor, which is out of this patch's scope.

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2019-12-16 11:44:15 +01:00
Zoltan Herczeg 40d930d62c Implement \u{hex} support. (#3447)
A large rework because surrogate pairs must be combined.

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

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-16 11:26:02 +01:00
Csaba Osztrogonác 1db16c3a1c Fix Math.round(x) for big integer numbers (#3449)
Math.round(x) should be x it x is already integer. (ES5 15.8.2.15)
The current implementation calculates with x +/- 0.5, which isn't
representable numbers if x >= 2^52.

A correct bug fix can be to follow the spec and simply
return the number itself if it is already integer.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-12-16 10:57:22 +01:00
Dániel Bátyai d3b8bed2c1 Implement and add support for RegExp.prototype[@@search] (#3436)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-12-12 15:59:28 +01:00
László Langó c525b1f10a Fixed segmentation fault in scanner. (#3444)
The register end index was not correctly calculated when
only holes presented in the arguments list of a function.

Fixes #3419, fixes #3431

JerryScript-DCO-1.0-Signed-off-by: László Langó lango@inf.u-szeged.hu
2019-12-12 12:17:45 +01:00
Csaba Osztrogonác fb4b18a515 Fix Math.trunc(x) if -1 < x < 0 (#3445)
Math.trunc(x) should be -0.0 if -1 < x < 0 (ES2015 20.2.2.35). The problem
was that -0 isn't -0.0, but +0.0 in C. There were a test case for it, but
it was incorrect, because +0.0 === -0.0 in JS.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-12-12 10:57:44 +01:00
László Langó df6995d0f6 Fixed typos in filenames of regression tests. (#3443)
JerryScript-DCO-1.0-Signed-off-by: László Langó lango@inf.u-szeged.hu
2019-12-11 16:19:05 +01:00
László Langó 4b5fad748f Fixed memory leak in rest initializer. (#3438)
Fixes #3437

JerryScript-DCO-1.0-Signed-off-by: László Langó lango@inf.u-szeged.hu
2019-12-11 10:24:49 +01:00
Robert Sipka f7382ce8c4 Updated the supported Unicode version from 9.0.0 to 13.0.0 (#3435)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2019-12-10 20:31:04 +01:00
Robert Fancsik 9b33fc8cbd Revise the usage of the global error value/exception flag (#3426)
This patch also fixes #3422.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-10 14:42:10 +01:00
Szilagyi Adam 7c0b1ca88a Update String.prototype.match to ECMA-262 v6 (#3375)
The algorithm is based on ECMA-262 v6, 21.1.3.11

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-10 14:40:41 +01:00
Zoltan Herczeg 531f1e9687 Support let identifier in non-strict mode. (#3427)
This code adds a lot of checks and complexity to the code.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-10 14:32:08 +01:00
Szilagyi Adam 6cc9848afc Implement Array.of method (#3418)
The algorithm is based on ECMA-262 v6, 22.1.2.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-10 14:30:59 +01:00
Zoltan Herczeg b8bc013fc0 Keywords must not contain escape sequences. (#3429)
The ES5.1 standard is unclear about this rule.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-09 14:37:41 +01:00
Szilagyi Adam dc458d29fb Implement TypedArray.of method (#3428)
The algorithm is based on ECMA-262 v6, 22.2.2.2

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

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2019-12-09 12:07:25 +01:00
Zoltan Herczeg 5ceffd209e Fix post increase / decrease in the pre-scanner. (#3430)
Fixes #3397.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-06 13:53:34 +01:00
Szilagyi Adam e70cfed57a Add bounds check for copyWithin (#3425)
When inputs are out of bounds, we don't need to do anything in the operation.

Fixes #3408

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-06 13:33:41 +01:00
Robert Fancsik 99fa823bab Fix cleanup on error in Array.from (#3423)
This patch fixes #3420.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-05 20:24:37 +01:00
Zoltan Herczeg 1a4972fc3f Implement yield* operation in generator functions. (#3407)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-05 13:50:53 +01:00
Robert Fancsik 1829d2df55 Fix scanner_create_variables for empty destructuring patterns (#3417)
This patch fixes #3383.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-04 15:38:50 +01:00
Roland Takacs 67d677a1bc Implement ArrayBuffer.isView function (#3403)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs r.takacs2@partner.samsung.com
2019-12-04 15:36:42 +01:00
Robert Fancsik 59eb0787ba Fix global error management in ecma_builtin_string_prototype_object_split (#3414)
This patch fixes #3395.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-04 14:13:43 +01:00
Robert Fancsik e188407d3a Support spreaded argument list in super property reference. (#3415)
This patch fixes #3394.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-04 14:13:00 +01:00
Robert Fancsik 99ae94b7c0 ecma_create_error_reference should clear the context's exception flag. (#3413)
This patch fixes #3410.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-04 14:12:06 +01:00
Robert Fancsik 041df1ec3c Fix the global error management on promise operations (#3412)
This patch fixes #3409 and fixes #3411.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-04 12:51:52 +01:00
Szilagyi Adam 4443c88bf4 Fix index handling in ecma_op_advance_string_index (#3406)
Fixes #3389

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-04 11:14:25 +01:00
Robert Fancsik bfc495f0cb Implement Array.from routine (#3402)
The patch also revealed a minor issue about Map[Symbol.iterator] which have been fixed as well.

Co-authored-by: Daniella Barsony bella@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-03 15:39:11 +01:00
Csaba Osztrogonác d31871d7c9 heap-buffer-overflow in ecma_date_parse_year (#3404)
If ecma_date_parse_year got an invalid date string, it could overread the input string.
The problem was that we compared the original str_p to str_end_p instead of str_start_p.
Additionally I simplified the parser loop.

Fixes #3388.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-12-03 13:42:39 +01:00
Zoltan Herczeg 31988877b2 Support destructuring bindings as catch variables. (#3399)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-03 12:52:20 +01:00
Dániel Bátyai 9634ca556e Fix leaking char buffer in RegExp.prototype[@@replace] (#3400)
Fixes #3392.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-12-03 09:34:53 +01:00
Robert Fancsik cc03c08c3d Fix error handling in abrupt promise rejection (#3391)
This patch fixes #3390.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-12-03 09:34:38 +01:00
Szilagyi Adam bdc608f2fb Optimize array copyWithin for fast-array cases (#3295)
Performance results:
Intel: 0m9,7s -> 0m0,07s
ARM: over 10m -> 1m38s

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-12-02 16:12:17 +01:00
Zoltan Herczeg 132de45c0b Remove CBC_EXT_CONTINUE_EXEC opcode. (#3378)
There is no need for a specific opcode after yield because
the return and throw commands can be redirected to fake byte code sequences.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-12-02 12:37:13 +01:00
Csaba Osztrogonác 51efba40b4 Remove dead code from ecma_date_parse_year() (#3387)
Code cleanup after #3314. Reverting already parsed '-' sign
after parse fail is unnecessary, because in this case the whole
date parse is failed.

Additionally this dead code was incorrect too, because it didn't
modify the original pointer to the string, but a local variable.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-29 20:54:57 +01:00
Robert Fancsik 0bc42a3fd5 Allow lexical function declaration in labeled statements. (#3386)
This patch fixes #3381.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-29 16:41:21 +01:00
Zoltan Herczeg fee3a600af Support assignment expressions in the pre-scanner. (#3382)
Fixes #3355.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-29 15:47:47 +01:00
Robert Fancsik 42b4af5921 Fix exception handling in ecma_op_create_promise_object (#3385)
This patch fixes #3376.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-29 15:45:41 +01:00
Csaba Osztrogonác 336fa45fa7 Make REPL option parser handle "-" option properly (#3384)
REPL could read JS file from standard input when we passed "-" option,
but after #1896 "-" became invalid option mistakenly.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-29 14:52:54 +01:00
Roland Takacs c5ed46f5ac Allow to create ArrayBuffer with empty external user data (#3373)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs r.takacs2@partner.samsung.com
2019-11-29 14:22:44 +01:00
Dániel Bátyai 35c0a6e299 Implement RegExp unicode and sticky flags (#3379)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-29 14:08:30 +01:00
Zoltan Herczeg 8956eff2bd Implement generator support for object initializers and classes. (#3372)
Large part of the code is also reworked.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-29 12:28:51 +01:00
Zoltan Herczeg 1b01bb034f Change JERRY_ES2015_BUILTIN to JERRY_ES2015. (#3377)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-29 11:17:15 +01:00
Zoltan Herczeg f41afeb89f Change JERRY_ES2015_BUILTIN_ITERATOR macro to JERRY_ES2015. (#3374)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-28 14:44:55 +01:00
Zoltan Herczeg 110f75c99d Implement the core of the generator functions. (#3368)
Some things are missing:
 - yield* support
 - generator definition in object literal
 - the hidden GeneratorFunction

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-28 11:54:27 +01:00
Robert Fancsik 14e95a4775 Fix the handling of unresolvable reference in VM_OC_TYPEOF_IDENT (#3371)
This patch fixes #3363.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-27 22:27:34 +01:00
Szilagyi Adam b7508c636c Fix value release in ecma_op_is_concat_spreadable (#3346)
Fixes #3356
Fixes #3361

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-27 11:06:51 +01:00
Szilagyi Adam 0c6b306429 Implement Regexp.prototype[@@match] method (#3345)
The algorithm is based on ECMA-262 v6, 21.2.5.6

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

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-26 16:05:48 +01:00
Zoltan Herczeg 9725936848 Rework register reference in the vm. (#3370)
The aim is storing only ecma values on the vm stack.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-26 16:03:20 +01:00
Robert Fancsik cbeecdb703 Fix this property reference on assignment patterns (#3365)
This patch fixes #3348.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-26 15:49:55 +01:00
Robert Fancsik 12211d8aaa Fix the order of the function arguments for spread operation (#3369)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-26 15:47:36 +01:00
Robert Fancsik aeb8431aff Fix the scanning of default array/object literals. (#3367)
Scanning should continue with `SCAN_MODE_POST_PRIMARY_EXPRESSION` in all cases.

Fixes #3360.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-26 13:07:28 +01:00
Robert Fancsik f63e4c363b Fix the assertion for VM_OC_EVAL. (#3366)
Eval flag can be set for spreaded argument function calls as well.

This patch fixes #3364.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-26 13:05:56 +01:00
Csaba Osztrogonác 4d422e17df Make Date.parse() ECMA-262 conform (#3314)
Changes:
- Parse output of Date.prototype.toString() and Date.prototype.toUTCString()
- Date.prototype.toString() is ECMA-262 v9 conform now, only TZ part changed
  (Before ECMA-262 v9 it was implementation-dependent.)
- Reused day_names_p and month_names_p arrays (and made them more efficient)
- Tests updated and new tests added

Fixes #2946.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-26 13:04:11 +01:00
Dániel Bátyai 16d0e83b64 Fix adding fast arrays as keys to a weak container (#3362)
Fixes #3359.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-26 08:21:33 +01:00
Csaba Osztrogonác 2e8a8f5caa Fix the es2015-subset profile build on Windows (#3347)
JERRY_ATTR_NOINLINE define is __declspec(noinline) which should be placed
at the beginning of the declaration and caused build fail because it was
placed after the * character. Details can be found here:
https://docs.microsoft.com/en-us/cpp/cpp/declspec?view=vs-2019

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-25 11:49:54 +01:00
Dániel Bátyai 37850bbfef Fix refcount when returning with the argument in Object built-ins (#3353)
Fixes #3350.
Fixes #3351.
Fixes #3352.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-25 11:49:24 +01:00
Dániel Bátyai b2d34724d4 Fix Reflect.getPrototypeOf for primitive arguments (#3354)
Fixes #3349.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-25 11:49:04 +01:00
Dániel Bátyai 1c6f334f62 Fix class name check for WeakMap and WeakSet prototype (#3358)
Fixes #3357.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-25 11:48:33 +01:00
Robert Fancsik 62356796fc Support get/set as property name in object literal (#3340)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-22 16:05:38 +01:00
Dániel Bátyai 279d4d4119 Add handling for RegExp unicode and sticky flags (#3341)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-22 14:04:03 +01:00
Dániel Bátyai fc2218e828 Fix weakrefs when adding a key to the same container multiple times (#3343)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-22 13:55:36 +01:00
Dániel Bátyai 3bf2bc50bc Properly handle primitive arguments in Object methods (#3342)
ES2015 allows primitive arguments for most of the Object built-ins.
This change implements handling for these arguments in affected methods.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-22 12:48:10 +01:00
Zoltan Herczeg d006f068f4 Improve the performance of the interpreter. (#3344)
Registers are stored immediately after the frame pointer and an argument is dropped from vm_run.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-22 12:47:11 +01:00
Roland Takacs 996bf76f59 Support ES6 based octal literals (#3338)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs r.takacs2@partner.samsung.com
2019-11-21 15:13:11 +01:00
Robert Fancsik 2ddf134cef Add iterator close support for array destructuring (#3337)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-21 12:55:52 +01:00
Zoltan Herczeg 6b43ef8605 Arrow functions should be parsed as assignment expressions. (#3336)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-21 11:32:33 +01:00
Péter Gál aadfa13c38 Improve RegExp compatibility with web browsers (#3339)
The modification adds support to parse /A{/ like RegExps.
That is: if the iterator is invalid it should be treated as normal
character.

This behaviour is defined in the ES2015 standard Annex B 1.4 point

This only works if the `JERRY_REGEXP_STRICT_MODE` is disabled
(set to zero).

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-11-21 10:59:21 +01:00
Robert Fancsik 7f6f562adb Throw error for using rest parameter in property setter (#3335)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-20 12:21:05 +01:00
Szilagyi Adam a0a71da025 Implement toPrimitive method and Date.prototype.toPrimitve (#3287)
The algorithms are based on ECMA-262 v6 7.1.1 and 20.3.4.45

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-20 11:51:02 +01:00
Szilagyi Adam c31452c138 Implement IsRegExp operation (#3321)
Algorithm is based on ECMA-262 v6, 22.1.3.1.1

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-20 11:50:26 +01:00
Dániel Bátyai bd0cb33172 Implement WeakMap and WeakSet (#3328)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-19 19:27:31 +01:00
Robert Fancsik 830011c033 Eliminate the allocation of spread object (#3333)
ECMA_VALUE_SPREAD_ELEMENT can be used to represent that the next argument needs to be spreaded, therefore no allocation is needed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-19 18:16:43 +01:00
Zoltan Herczeg 70566a52fb Improve eval call parsing. (#3330)
Eval calls are recognised when the eval identifier is encapsulated in brackets.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-19 15:55:53 +01:00
Robert Fancsik a1189cfb62 Add validation for single statement lexical declarations (#3326)
This patch fixes #3275 and fixes #3276.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-19 15:44:12 +01:00
Robert Fancsik 134f0c0d0f Fix fast array array hole initialization (#3332)
This patch eliminates the valgrind error: "Conditional jump or move depends on uninitialised value(s)".

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-19 14:10:55 +01:00
Robert Fancsik 7295c48638 Add missing macro guard for jerry_generate_snapshot_with_args (#3331)
JERRY_CONTEXT(resource_name) must be initialized with undefined when module system is enabled.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-19 14:07:17 +01:00
Robert Fancsik 22766a855e Implement spread operator for function call arguments (#3329)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-19 14:06:12 +01:00
Zoltan Herczeg bf630c0c54 Implement binding pattern support for rest argument and for statement. (#3327)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-19 14:02:17 +01:00
Szilagyi Adam a7d129c8b2 Implement Symbol.isConcatSpreadable (#3307)
Algorithm is based on ECMA-262 v6, 22.1.3.1.1

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-19 13:55:49 +01:00
Zoltan Herczeg 8bdb32cc88 Implement function destructuring argument support. (#3322)
Furthermore create unmapped arguments objects if a function has a non-simple argument.
A few destructuring pattern issues were fixed as well.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-18 14:15:36 +01:00
Dániel Bátyai 359643b5b2 Reorganize ecma_gc_free_object (#3323)
This change cleans up object deallocation, and reorganizes the code so
that we are able to do object type specific operations before the
properties are freed.

Previously this would require extra conditions that would slow things
down regardless of object type. With this change however, object type
conditions are checked only once for each possible type.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-15 18:19:52 +01:00
Csaba Osztrogonác 8d24c70513 Make run-test-suite.py work with python3 too (#3324)
Changes:
- Use list comprehension instead of filter in get_tests
to ensure returning list instead of iterable object
- Fix unicode decoding issues with Popen call

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-15 18:12:13 +01:00
Robert Fancsik 8cf5f96c15 Introduce parser statement flags (#3318)
These flags makes the code more readable also makes the process of introducing a new statement type easier.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-15 15:57:42 +01:00
Robert Fancsik fca0c94002 Fix the initialization of let/const patterns when block context is needed. (#3320)
Also some code cuplication is removed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-15 14:38:14 +01:00
Robert Fancsik 8eda9bc1c3 Fix the usage of escaped identifiers in scanner_scope_find_let_declaration (#3317)
This patch fixes #3313.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-14 14:46:01 +01:00
Csaba Osztrogonác 12184d7922 Don't upload artifacts to AppVeyor (#3316)
Uploaded JerryScript binaries aren't useful in practice
but this step regularly fails with an error message:
"Error uploading artifact the storage: Unable to connect to the remote server"

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-14 13:58:37 +01:00
Robert Fancsik be95aa33b4 Improve delete property with undefined base (#3312)
This patch finally resolves #2891 also the removes the related bytecode since it has become unnecessary.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-14 13:53:52 +01:00
Robert Fancsik 204de302aa Fix ecma_op_get_value_lex_env_base for let/const declarations (#3311)
This patch fixes #3306.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-14 13:52:12 +01:00
Robert Fancsik 213544ae47 Implement array/object destructuring (#3305)
This patch implements the core functionality of destructuring patterns.
Function argument/for in-of pattern are currently unsupported.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-14 13:49:49 +01:00
Zoltan Herczeg b4b55a67a2 Fix for propagating arguments reference from nested blocks. (#3309)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-14 13:48:58 +01:00
Zoltan Herczeg 55c7590767 Remove PARSER_ARGUMENTS_NOT_NEEDED parser flag. (#3308)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-14 13:47:11 +01:00
Csaba Osztrogonác 84f60c19ce Fixing sudo usage for dependency installation (#3315)
Fixes #3288, the fix is same as the bug reporter suggested.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-14 10:20:30 +01:00
Csaba Osztrogonác 3b5224b98d Fix timezone in Date.prototype.toString() (#3310)
Timezone minutes part was always 0 instead of the proper value.
Additionally fixed minor typos in comments.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-14 10:13:15 +01:00
Zoltan Herczeg c0cc5a1b08 Allow extending statements with block context. (#3296)
The block contexts bound to different statements are handled in the same way.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-13 12:37:23 +01:00
Zoltan Herczeg 419ccff611 Fix local variable declaration issues after function argument initialization. (#3304)
Fixes #3298
Fixes #3299
Fixes #3300
Fixes #3302

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-13 12:35:28 +01:00
Dániel Bátyai b16b400d5b Fix cleanup upon error in String.prototype.replace (#3301)
Fixes #3297

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-12 10:54:26 +01:00
Szilagyi Adam 452c78182d Implement String.prototype.codePointAt method (#3291)
The algorithm is based on ECMA-262 v6, 21.1.3.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-11 15:54:49 +01:00
Zoltan Herczeg da69589f05 Implement for[in/of]-let construct. (#3294)
This patch implements let/const support for all "for" statements.
It includes an algorithm for cloning declarative lexical environments.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-11 13:53:32 +01:00
Zoltan Herczeg 58f71e6ffa Implement left-hand-side expression parsing. (#3292)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-08 16:20:24 +01:00
kisbg 4996542f02 Added missing logical operator in js-parser-expr (#3293)
This fix is needed to build JerryScript 2.1 on a STM board.

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
2019-11-08 16:10:51 +01:00
Szilagyi Adam 798655a871 Implement Array.prototype's copyWithin method (#3269)
The algorithm is based on ECMA-262 v6, 22.1.3.3

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-08 15:41:20 +01:00
Zoltan Herczeg dc458111ba Local functions should not be created globally. (#3290)
Fixes #3286.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-08 14:03:19 +01:00
Szilagyi Adam 35d9b1ab17 Implement String.fromCodePoint method (#3281)
The algorithm is based on ECMA-262 v6, 21.1.2.2

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-11-08 13:48:05 +01:00
Zoltan Herczeg e1fc90db0e Delay the variable construction in the function body. (#3289)
Local variables inside the function body should be constructed after the
parameters are initialized. Furthermore arguments should be available
during parameter initialization.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-08 12:18:23 +01:00
Dániel Bátyai 923fd128b5 Refactor String.prototype.replace (#3284)
This change brings the replace operation up to date with ES6 by
implementing support for the @@replace well-known symbol, while
also improving performance and memory usage.

Also fixes #3070.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-08 12:15:28 +01:00
Robert Fancsik f48f926a39 [[HasOwnProperty]] should update the lex-env binding of argument objects (#3283)
This patch fixes #3271.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-07 11:24:07 +01:00
Robert Fancsik 859954b330 Add missing parameter description for jerry_get_resource_name (#3285)
Also some typos are fixed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-06 18:19:25 +01:00
Csaba Osztrogonác 44b1b9855d Make run-tests --jerry-tests --jerry-test-suite work on Windows too (#3260)
Changes:
* Bash based runners/run-test-suite.sh runner replaced with a python runner
* Common util functions moved to util.py
* Fixed EOL issues in tests directory

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-06 15:12:50 +01:00
Robert Fancsik 525c35f148 Introduce jerry_get_resource_name API function (#3236)
This new API function adds possibility to query the resource name of the currently executed script (including modules) or a function object.
This patch closes #2170.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-06 15:05:49 +01:00
Csaba Osztrogonác 55423ab82a Simplify ecma_builtin_date_parse function (#3280)
This PR is the preparation of the #2946 issue.
(Date.parse() should handle UTC date string format)

Changes:
- Handle min/max values in ecma_date_parse_date_chars function instead of code duplication
- Parse special characters in the new ecma_date_parse_special_char function
- Additionally fixed two parsing issue: invalid formats should be refused

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-11-06 14:51:17 +01:00
Robert Fancsik 3a505bda6b Increase the size of VM group opcodes to 256 (#3282)
Currently there is almost 115 group opcodes so increasing the number of bits which reprent a group opcode has become actual.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-06 14:49:57 +01:00
Dániel Bátyai 3b7d254e6a Add missing GC limit check to realloc with system allocator (#3279)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-06 11:02:28 +01:00
Ádám Kallai a8b627a80c Implement Object.is routine from ES2015 specification (#3272)
Related part of the standard: ECMA-262 v6, 19.1.2.10

JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2019-11-05 19:38:13 +01:00
Robert Fancsik 06135da642 Do not create temporary object during [[Get]] operation with primitive base (#3278)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-05 19:37:20 +01:00
Ádám Kallai f2a67876eb Fix the same Symbol value detection in SameValue function (#3273)
'is_types_equal' checks was missing for Symbol values.

JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2019-11-04 16:53:38 +01:00
Zoltan Herczeg ab8fa74b86 Correctly handle variables imported or exported by modules. (#3270)
Remove var declaration workarounds and correctly create / use variables for modules.

Still missing: create lexical environment for automatic module conversion.
(Or remove this feature overall.)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-04 16:51:26 +01:00
Robert Fancsik 6f83da4c0b Implement the spread operator for array initialization (#3265)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-04 16:36:58 +01:00
Robert Fancsik fc3cfc4fdc Arrow functions "prototype" property should not be lazy listed (#3268)
This patch fixes #3267.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-04 12:12:01 +01:00
Ádám Kallai cbae33a689 Add '-flto' flag to pkg-config if the libraries built with lto (#3274)
If we build Jerry libraries with lto, this information should be
passed to pkg-config as well.

JerryScript-DCO-1.0-Signed-off-by: Adam Kallai kadam@inf.u-szeged.hu
2019-11-01 20:29:17 +01:00
Robert Fancsik f93fa98a75 Add Number.{EPSILON, {MAX,MIN}_SAFE_INTEGER} to the builtin descriptor (#3258)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-31 15:06:19 +01:00
Robert Fancsik eee41ec734 Support \u200C \u200D unicode characters (#3266)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-31 11:14:13 +01:00
Zoltan Herczeg 6a342fcdd6 Implement throwing ReferenceErrors for let/const variables. (#3264)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-31 11:09:02 +01:00
Robert Fancsik d1faed7d03 Properly release callback result in ecma_builtin_typedarray_prototype_exec_routine (#3263)
This patch fixes #3262.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-31 11:08:16 +01:00
Szilagyi Adam cc9a657425 Optimize array shift/unshift for fast-array cases (#3235)
Performance results:
Intel: 13m11s -> 0m10s
ARM: over 20m -> 2m27s

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-30 16:59:20 +01:00
Szilagyi Adam 222e774cc2 Optimize array indexOf/lastIndexOf for fast-array cases (#3233)
Performance result:
Intel: 0m27s -> 0m23,5s
ARM: 5m13s -> 4m20s

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-30 16:49:13 +01:00
Szilagyi Adam 6639bbc580 Optimize array reverse for fast-array cases. (#3231)
Performace result:
Intel: 5m30s -> 0m3,9s
ARM: over 15m -> 1m14s

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-30 16:44:29 +01:00
Szilagyi Adam d801fc70bb Optimize array slice for fast-array cases (#3213)
Performance results:
Intel: 0m27s -> 0m7s
ARM: 5m42s -> 1m26s

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-30 16:43:17 +01:00
Zoltan Herczeg 1edfa81c76 Implement correct construction of let/const declarations and function statements. (#3259)
Various cbc opcodes are added to support the different instantiations.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-30 16:01:55 +01:00
Robert Fancsik 1c34539997 Rework array hole calculation for fast access mode arrays (#3248)
This patch gives possibility to Array.prototype builtin routine optimizations.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-29 10:10:25 +01:00
Robert Fancsik 42ab062441 Introduce ecma_op_object_get_length and ecma_op_object_get_by_index operations (#3245)
These two functions helps to reduce code duplication, also invokes the elimination of several ECMA_TRY_CATCH macros.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-29 10:07:20 +01:00
Daniella Barsony 11818f1cb0 Fix issue about Number.prototype.toString (#3232)
Fixes #3229

JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2019-10-29 08:35:55 +01:00
Robert Fancsik 87f60da14f Add arithmetic operations support for the API (#3249)
This patch extends the jerry_binary_operation_t list with arithmetic operations.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-28 15:46:35 +01:00
Robert Fancsik 448c239f08 Export statement parsing should construct new ident literal (#3256)
This patch fixes #3253.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-28 15:30:47 +01:00
Szilagyi Adam 072aedb4ef Fix wrong error handling in ecma_builtin_function_helper_get_function_arguments (#3257)
Fixes #3252

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-28 14:23:53 +01:00
Péter Gál eebbed143d Introduce new Promise API methods (#3186)
The new API methods make it possible to get a Promise object's
result and it's state.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-10-28 14:07:37 +01:00
Robert Fancsik 351b88184c Arrow functions prototype property should not be lazy instantiated (#3251)
This patch fixes #3250

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-28 10:33:28 +01:00
Zoltan Herczeg 3d797b8836 Implement the core of let/const statement. (#3239)
This patch implements the core part of let/const statements. Redeclarations are correctly
detected and separate contexts are correctly created for these statements. Register
optimizations are also emplyed whenever possible.

Lots of features are still missing:
 - checking the var statements in eval
 - const are treated as lets
 - single statement checks are missing
 - export declarations are exported as vars, let/const export is not supported

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-25 18:08:10 +02:00
Szilagyi Adam 4b352758c1 Refactor ecma_op_to_string (#3171)
Similar to the ecma_op_to_object rework, in this new method we
return directly with the pointer to the ecma string, and we don't
wrap the result into an ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-25 15:58:47 +02:00
Robert Fancsik b7aa21ebc7 Fix lazy instantiation of external functions 'prototype' property (#3246)
This patch resolves #2302.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-25 15:56:37 +02:00
Robert Fancsik 100a012931 Fix integer overflow during byteLength calculation for %TypedArray%s (#3244)
This patch fixes #3243.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-25 12:36:23 +02:00
Robert Fancsik 99ad34af4a Sort function breakpoints before enabling them (#3238)
Function breakpoints should be sorted before enabling then since the object enumeration order does not grant consistent result.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-24 15:08:03 +02:00
Daniel Vince 9e83032ada Fix error type when creating TypedArray with detached ArrayBuffer (#3230)
Based on the ES2015 standard TypeError should be returned
when a TypedArray is created for a detached ArrayBuffer.

JerryScript-DCO-1.0-Signed-off-by: Dániel Vince vinced@inf.u-szeged.hu
2019-10-24 15:04:38 +02:00
Robert Fancsik 48f34adea5 General GC optimizations (#3221)
- Enable recursive GC marking with a limited recursion count (this option is configurable)
- No need to decrease the reference count of the gray objects anymore
- Bound function object marking is seperated into a helper function

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-24 14:49:47 +02:00
Robert Fancsik 3b73562fa5 Revise ES2015 feature guards (#3240)
All the basic language element guards are merged into JERRY_ES2015 macro guard.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-24 14:44:51 +02:00
Csaba Osztrogonác 59e0d6e262 Make snapshot unittest easily updatable (#3242)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-10-22 18:46:56 +02:00
Daniella Barsony 7b589d1381 Refactor code to use ToLength (#3210)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2019-10-21 14:08:13 +02:00
Virag Orkenyi 3fb6f15730 Implement Reflect object (#3036)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
2019-10-21 13:46:29 +02:00
Robert Fancsik edf66f4e9b Extend the API documentation for jerry_create_string_* functions (#3234)
- The given string pointer cannot be NULL.
 - Fixed API prototype for jerry_create_string_sz_from_utf8
 - Assert is added for non-NULL pointer in lit_zt_utf8_string_size

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-21 13:42:31 +02:00
Daniel Vince 6a2767a09a Add documentation about x86 and floating-point operations (#3228)
If JerrScript is compiled for x86 then it is possible that the
floating-point operations are not correct for the JS standard.

To "fix" this the users should be advised to use at least SSE2
during build for this platform.

JerryScript-DCO-1.0-Signed-off-by: Dániel Vince vinced@inf.u-szeged.hu
2019-10-21 11:14:30 +02:00
Daniel Vince d85988af96 Implement ES2015 Function.prototype[@@hasInstance] (#3225)
Added hasInstance well known symbol implementation for Function.prototype.
This change however does not implement the ES2015 `instanceof` operator changes.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Dániel Vince vinced@inf.u-szeged.hu
2019-10-21 11:04:12 +02:00
Daniel Vince d60587f838 Add @@hasInstance Symbol support for instanceof operator (#3226)
Implemented ES2015 modifications for `instanceof` operator.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Dániel Vince vinced@inf.u-szeged.hu
2019-10-21 11:03:43 +02:00
Zoltan Herczeg 7df87b7778 Create function variables using the data produced by the pre-scanner. (#3199)
The pre-scanner now is able to track all variable declarations and produces a compressed
stream which store this data for each function and catch block. When a function or
catch block is parsed, this information is decoded and the appropriate variables are
created. Furthermore a stack scope is created which contains the currently available
local variables and their register or literal index.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-17 15:20:04 +02:00
Robert Fancsik fd1f7eab9f Add public API functions for internal property management (#3128)
These 4 new API functions give possibility to perform [[Get]], [[Set]], [[Has]], [[Delete]] operations for properties
which are not accessible from the JavaScript context only from the public API.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-17 13:56:49 +02:00
Robert Fancsik a40eb9bab8 Remove duplicated error raising in ecma_op_typedarray_set_with_typedarray (#3223)
This patch fixes #3222.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-17 11:56:14 +02:00
Daniel Balla fd8203ce98 Add missing error checks to API functions (#3190)
JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
2019-10-16 16:51:03 +02:00
legendecas 2e86bdae6f Add ArrayBuffer detach operations (#3208)
JerryScript-DCO-1.0-Signed-off-by: legendecas legendecas@gmail.com
2019-10-16 16:41:27 +02:00
Szilagyi Adam 09c5d98e25 Optimize array push/pop for fast-array cases (#3187)
Performance results:
ARM: 1m19s -> 0m57s
Intel: 0m7,5s -> 0m5s

Binary size increase: 168 bytes

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-16 16:41:01 +02:00
Daniella Barsony 390916e989 Add Array.prototype.fill method (#3201)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
2019-10-16 16:37:56 +02:00
Szilagyi Adam 5320f5a396 Use stringbuilder in typedArry toLocaleString (#3207)
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
2019-10-16 16:37:19 +02:00
3034 changed files with 142484 additions and 63561 deletions
+222
View File
@@ -0,0 +1,222 @@
name: JerryScript CI
on: [push, pull_request]
env:
RUNNER: tools/run-tests.py
jobs:
Checks:
runs-on: ubuntu-18.04 # needed for checker version stability
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: sudo apt update
- run: sudo apt install doxygen vera++ cppcheck pylint python-serial
- run: $RUNNER --check-signed-off=gh-actions
- run: $RUNNER --check-doxygen
- run: $RUNNER --check-vera
- run: $RUNNER --check-license
- run: $RUNNER --check-magic-strings
- run: $RUNNER --check-pylint
- run: $RUNNER --check-cppcheck
Linux_x86-64_Build_Correctness_Debugger_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '2.7' # needed by jerry-debugger
- run: $RUNNER -q --jerry-tests
- run: $RUNNER -q --jerry-debugger
Linux_x86_cpointer-32bit_Build_Correctness_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: $RUNNER -q --jerry-tests --buildoptions=--compile-flag=-m32,--cpointer-32bit=on
OSX_x86-64_Build_Correctness_Unit_Tests:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- run: $RUNNER -q --jerry-tests
- run: $RUNNER -q --unittests
Linux_x86-64_Build_Option_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt update
- run: sudo apt install gcc-multilib
- run: $RUNNER --buildoption-test
Conformance_Tests_ES5_1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: $RUNNER --test262
Conformance_Tests_ES2015:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: $RUNNER --test262-es2015=update
- uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: Test262-ES2015-results
path: build/tests/test262_tests_es2015/local/bin/test262.report
Conformance_Tests_ESNext_A:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: $RUNNER --test262-esnext=update --test262-test-list=built-ins,annexB,harness,intl402
- uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: Test262-ESNext-results-A
path: build/tests/test262_tests_esnext/local/bin/test262.report
Conformance_Tests_ESNext_B:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: $RUNNER --test262-esnext=update --test262-test-list=language
- uses: actions/upload-artifact@v2
if: success() || failure()
with:
name: Test262-ESNext-results-B
path: build/tests/test262_tests_esnext/local/bin/test262.report
Unit_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: $RUNNER -q --unittests
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
- 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-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js
UBSAN_Tests:
runs-on: ubuntu-latest
env:
UBSAN_OPTIONS: print_stacktrace=1
steps:
- uses: actions/checkout@v2
- 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
Linux_ARMv7l_Tests:
runs-on: ubuntu-latest
env:
RUNTIME: qemu-arm-static
TIMEOUT: 300
steps:
- uses: actions/checkout@v2
- 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_AArch64_Tests:
runs-on: ubuntu-latest
env:
RUNTIME: qemu-aarch64-static
TIMEOUT: 300
steps:
- uses: actions/checkout@v2
- 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
MbedOS5_K64F_Build_Test:
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8' # needed due to 'intelhex' module
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
- run: sudo apt update
- run: sudo apt install gcc-arm-embedded python3-setuptools
- run: make -f ./targets/mbedos5/Makefile.travis install
- run: make -f ./targets/mbedos5/Makefile.travis script
Zephyr_Arduino_101_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: sudo apt update
- run: sudo apt install gperf dfu-util device-tree-compiler
- run: make -f ./targets/zephyr/Makefile.travis install
- run: make -f ./targets/zephyr/Makefile.travis script
NuttX_STM32F4_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt update
- run: sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi gperf
- run: make -f ./targets/nuttx-stm32f4/Makefile.travis install-noapt
- run: make -f ./targets/nuttx-stm32f4/Makefile.travis script
RIOT_STM32F4_Build_Test:
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
env:
CC: clang
steps:
- uses: actions/checkout@v2
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
- run: sudo apt update
- run: sudo apt install clang gcc-arm-embedded gcc-multilib
- run: make -f ./targets/riot-stm32f4/Makefile.travis install-noapt
- run: make -f ./targets/riot-stm32f4/Makefile.travis script
ESP8266_Build_Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '2.7' # needed due to ESP8266_RTOS_SDK/tools/gen_appbin.py
- run: make -f ./targets/esp8266/Makefile.travis install-noapt
- run: make -f ./targets/esp8266/Makefile.travis script
Notification:
runs-on: ubuntu-latest
if: 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 }}
-170
View File
@@ -1,170 +0,0 @@
language: c
# Default environment: Ubuntu Trusty 14.04.
os: linux
dist: trusty
# 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"
install: pip install --user pylint==1.6.5
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++]
- 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: "OSX/x86-64 Build, Correctness & Unit Tests"
env:
- OPTS="--quiet --jerry-tests --jerry-test-suite --unittests"
os: osx
addons:
homebrew:
packages: [cmake, cppcheck, vera++]
- name: "Build Tests"
env:
- OPTS="--buildoption-test"
addons:
apt:
packages: [gcc-multilib]
- name: "Conformance Tests"
env:
- OPTS="--test262"
- 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 --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
compiler: gcc-5
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: [gcc-5, gcc-5-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
compiler: gcc-5
addons:
apt:
sources: ubuntu-toolchain-r-test
packages: [gcc-5, gcc-5-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"
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, python3-ply, python3-pip]
- 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}"
+52 -34
View File
@@ -15,6 +15,11 @@
cmake_minimum_required (VERSION 2.8.12)
project (Jerry C)
# Determining version
execute_process(COMMAND python ${CMAKE_SOURCE_DIR}/tools/version.py
OUTPUT_VARIABLE JERRY_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Determining platform
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
string(TOUPPER "${PLATFORM}" PLATFORM)
@@ -48,14 +53,16 @@ set(JERRY_CMDLINE_SNAPSHOT OFF CACHE BOOL "Build jerry snapshot command line to
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_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(DOCTESTS OFF CACHE BOOL "Build doc tests?")
# Optional build settings
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?")
set(ENABLE_LTO ON CACHE BOOL "Enable LTO build?")
set(ENABLE_STRIP ON CACHE BOOL "Enable stripping all symbols from release binary?")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?")
set(ENABLE_AMALGAM OFF CACHE BOOL "Enable amalgamated build?")
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?")
# Option overrides
if(NOT USING_CLANG)
@@ -77,11 +84,17 @@ if(JERRY_CMDLINE OR DOCTESTS)
endif()
if("${PLATFORM}" STREQUAL "DARWIN")
set(JERRY_LIBM OFF)
set(ENABLE_LTO 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_STRIP_MESSAGE " (FORCED BY PLATFORM)")
endif()
@@ -93,36 +106,40 @@ if(USING_TI)
endif()
if(USING_MSVC)
set(JERRY_LIBM OFF)
set(ENABLE_STRIP OFF)
set(JERRY_LIBM_MESSAGE " (FORCED BY COMPILER)")
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
endif()
if(CYGWIN)
if(CYGWIN OR MINGW OR MSYS)
set(ENABLE_LTO OFF)
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
endif()
# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ${ENABLE_COMPILE_COMMANDS})
# Status messages
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
message(STATUS "ENABLE_LTO " ${ENABLE_LTO} ${ENABLE_LTO_MESSAGE})
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP} ${ENABLE_STRIP_MESSAGE})
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE} ${JERRY_CMDLINE_MESSAGE})
message(STATUS "JERRY_CMDLINE_TEST " ${JERRY_CMDLINE_TEST} ${JERRY_CMDLINE_TEST_MESSAGE})
message(STATUS "JERRY_CMDLINE_SNAPSHOT " ${JERRY_CMDLINE_SNAPSHOT} ${JERRY_CMDLINE_SNAPSHOT_MESSAGE})
message(STATUS "JERRY_LIBFUZZER " ${JERRY_LIBFUZZER} ${JERRY_LIBFUZZER_MESSAGE})
message(STATUS "JERRY_PORT_DEFAULT " ${JERRY_PORT_DEFAULT} ${JERRY_PORT_DEFAULT_MESSAGE})
message(STATUS "JERRY_EXT " ${JERRY_EXT} ${JERRY_EXT_MESSAGE})
message(STATUS "JERRY_LIBM " ${JERRY_LIBM} ${JERRY_LIBM_MESSAGE})
message(STATUS "UNITTESTS " ${UNITTESTS})
message(STATUS "DOCTESTS " ${DOCTESTS})
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
message(STATUS "ENABLE_AMALGAM " ${ENABLE_AMALGAM} ${ENABLE_AMALGAM_MESSAGE})
message(STATUS "ENABLE_LTO " ${ENABLE_LTO} ${ENABLE_LTO_MESSAGE})
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP} ${ENABLE_STRIP_MESSAGE})
message(STATUS "ENABLE_COMPILE_COMMANDS " ${ENABLE_COMPILE_COMMANDS})
message(STATUS "JERRY_VERSION " ${JERRY_VERSION})
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE} ${JERRY_CMDLINE_MESSAGE})
message(STATUS "JERRY_CMDLINE_TEST " ${JERRY_CMDLINE_TEST} ${JERRY_CMDLINE_TEST_MESSAGE})
message(STATUS "JERRY_CMDLINE_SNAPSHOT " ${JERRY_CMDLINE_SNAPSHOT} ${JERRY_CMDLINE_SNAPSHOT_MESSAGE})
message(STATUS "JERRY_LIBFUZZER " ${JERRY_LIBFUZZER} ${JERRY_LIBFUZZER_MESSAGE})
message(STATUS "JERRY_PORT_DEFAULT " ${JERRY_PORT_DEFAULT} ${JERRY_PORT_DEFAULT_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
# Note: This mimics a conventional file system layout in the build directory for
@@ -185,14 +202,15 @@ if("${PLATFORM}" STREQUAL "DARWIN")
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>")
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)
endif()
if(USING_GCC OR USING_CLANG)
jerry_add_compile_flags(-std=c99 -pedantic)
# Turn off stack protector
jerry_add_compile_flags(-fno-builtin -fno-stack-protector)
if(JERRY_MATH)
jerry_add_compile_flags(-fno-builtin)
endif()
jerry_add_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations shadow strict-prototypes undef old-style-definition)
jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes -Werror)
endif()
@@ -237,12 +255,12 @@ if(DEFINED EXTERNAL_LINKER_FLAGS)
jerry_add_link_flags(${EXTERNAL_LINKER_FLAGS})
endif()
# Used for placeholder to attach single source build targets
add_custom_target(generate-single-source)
# Used as placeholder to attach amalgamated build targets to
add_custom_target(amalgam)
# Jerry's libm
if(JERRY_LIBM)
add_subdirectory(jerry-libm)
if(JERRY_MATH)
add_subdirectory(jerry-math)
endif()
# Jerry's core
@@ -266,8 +284,8 @@ endif()
# Unittests
if(UNITTESTS)
add_subdirectory(tests/unit-core)
if(JERRY_LIBM)
add_subdirectory(tests/unit-libm)
if(JERRY_MATH)
add_subdirectory(tests/unit-math)
endif()
if(JERRY_EXT)
add_subdirectory(tests/unit-ext)
-1
View File
@@ -798,7 +798,6 @@ RECURSIVE = YES
# who are familiar with the undocumented parts.
EXCLUDE = \
jerry-core/ecma/base/ecma-globals.h \
jerry-core/ecma/base/ecma-helpers.h \
jerry-core/ecma/operations/ecma-exceptions.h \
jerry-core/include/jerryscript-debugger-transport.h \
jerry-core/jcontext/jcontext.h \
+4 -7
View File
@@ -1,11 +1,9 @@
![](https://github.com/jerryscript-project/jerryscript/blob/master/LOGO.png)
# JerryScript: JavaScript engine for the Internet of Things
[![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)
[![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)
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.
@@ -22,11 +20,10 @@ Additional information can be found on our [project page](http://jerryscript.net
Memory usage and Binary footprint are measured at [here](https://jerryscript-project.github.io/jerryscript-test-results) with real target daily.
The following table shows the latest results on the devices:
The latest results on **Raspberry Pi 2**:
| STM32F4-Discovery | [![Remote Testrunner](https://firebasestorage.googleapis.com/v0/b/jsremote-testrunner.appspot.com/o/status%2Fjerryscript%2Fstm32f4dis.svg?alt=media&token=1)](https://jerryscript-project.github.io/jerryscript-test-results/?view=stm32f4dis) |
| :---: | :---: |
| **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) |
[![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).
+3 -12
View File
@@ -15,22 +15,13 @@ platform:
- x64
- Win32
environment:
matrix:
- FEATURE_DEBUGGER: ON
- FEATURE_DEBUGGER: OFF
# Steps of a job.
init:
- cmake -version
before_build:
- if "%PLATFORM%"=="Win32" cmake -G"Visual Studio 15 2017" -Bbuild -H. -DFEATURE_DEBUGGER=%FEATURE_DEBUGGER%
- if "%PLATFORM%"=="x64" cmake -G"Visual Studio 15 2017 Win64" -Bbuild -H. -DFEATURE_DEBUGGER=%FEATURE_DEBUGGER%
- if "%PLATFORM%"=="Win32" cmake -G"Visual Studio 15 2017" -Bbuild -H. -DJERRY_DEBUGGER=ON
- if "%PLATFORM%"=="x64" cmake -G"Visual Studio 15 2017 Win64" -Bbuild -H. -DJERRY_DEBUGGER=ON
build:
project: build\Jerry.sln
parallel: true
parallel: false # FIXME: This should not be needed but right now it is: msbuild generates all amalgamated files twice, at the same time in parallel builds, leading to I/O errors.
verbosity: minimal
artifacts:
- path: build\bin\$(configuration)\
name: JerryScriptBinary
+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")
+18
View File
@@ -0,0 +1,18 @@
# 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 Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
+3 -9
View File
@@ -1,6 +1,6 @@
## Setting up prerequisites
Currently, only Ubuntu 14.04+ is officially supported as primary development environment.
Currently, only Ubuntu 18.04+ is officially supported as primary development environment.
There are several dependencies, that should be installed manually. The following list is the absolute minimum for building:
@@ -51,10 +51,10 @@ tools/build.py --debug --logging=on --error-messages=on --line-info=on
python tools/build.py --cmake-param=CMAKE_PARAM
```
**Set a profile mode (ES5.1, subset of ES2015, minimal)**
**Set a profile mode (ES.next, ES5.1, minimal)**
```bash
python tools/build.py --profile=es5.1|es2015-subset|minimal
python tools/build.py --profile=es.next|es5.1|minimal
```
See also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).
@@ -161,12 +161,6 @@ python tools/run-tests.py --unittests
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**
```bash
+53 -19
View File
@@ -5,16 +5,19 @@ A configuration option's value can be changed either by providing specific C pre
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.
This process can provide comparable results to link time optimization, and can be useful when LTO is not available otherwise.
Enables the amalgamated build process, which aggregates the contents of each source file per library
(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 | |
|---------|----------------------------------------------|
| C: | `<none>` |
| CMake: | `-DENABLE_ALL_IN_ONE=ON/OFF` |
| Python: | `--all-in-one=ON/OFF` |
| CMake: | `-DENABLE_AMALGAM=ON/OFF` |
| Python: | `--amalgam=ON/OFF` |
See also: [Amalgamated sources](#amalgamated-sources)
### Jerry debugger
@@ -41,7 +44,7 @@ that can be used by the debugger to identify the currently executed source conte
### 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.
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`, `es5.1`, 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).
| Options | |
@@ -152,7 +155,7 @@ This feature is disabled by default.
### 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.
This option is enabled by default.
@@ -211,6 +214,17 @@ A value of 0 will use the default value.
| CMake: | `-DJERRY_GC_LIMIT=(int)` |
| Python: | `--gc-limit=(int)` |
### GC mark recursion limit
This option can be used to adjust the maximum recursion depth during the GC mark phase. The provided value should be an integer, which represents the allowed number of recursive calls. Increasing the depth of the recursion reduces the time of GC cycles, however increases stack usage.
A value of 0 will prevent any recursive GC calls.
| Options | |
|---------|---------------------------------------------------|
| C: | `-DJERRY_GC_MARK_LIMIT=(int)` |
| CMake: | `-DJERRY_GC_MARK_LIMIT=(int)` |
| Python: | `--gc-mark-limit=(int)` |
### Stack limit
This option can be used to cap the stack usage of the engine, and prevent stack overflows due to recursion. The provided value should be an integer, which represents the allowed stack usage in kilobytes.
@@ -267,25 +281,27 @@ This option is disabled by default.
| Python: | `--mem-stress-test=ON/OFF` |
# Single source build mode
# Amalgamated sources
There is a special mode to use/"build" JerryScript. That is generating a single C file which can be
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
but can be adapted to run outside of the project root dir):
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
$ 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-default --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.h`
* `jerryscript-config.h`
* `jerryscript-port-default.c`
* `jerryscript-port-default.h`
* `jerryscript-libm.c`
* `jerryscript-math.c`
* `math.h`
**Important**: the `jerryscript-config.h` contains the configurations mentioned above and
@@ -293,12 +309,30 @@ 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.)
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
$ 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-default.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
## x86 with GCC
When building for Intel 32 bit architecture it is possible that GCC uses conservative options, thus assuming the most
basic floating-point support (that is it does not generate SSE or others instructions).
However this could lead to loss off precision and/or different results than what is required by the JavaScript standard
in regards of floating-point values and arithmetic.
To resolve this precision problem it is advised to use at least SSE2.
To do this with GCC please provide the `-mfpmath=sse -msse2` options during build.
These options can also be specified via the `build.py` script:
```sh
$ ./tools/build.py --compile-flag=-mfpmath=sse --compile-flag=-msse2 --compile-flag=-m32
```
+2589 -73
View File
File diff suppressed because it is too large Load Diff
+13 -12
View File
@@ -32,7 +32,7 @@ $ export PKG_CONFIG_PATH=$(pwd)/example_install/lib/pkgconfig/
Test if the `pkg-config` works for JerryScript:
```sh
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-libm
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-math
```
## Example 1. Execute JavaScript from your application
@@ -58,7 +58,7 @@ main (void)
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)
$ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
```
If everything is correct the application returns with a zero exit code:
@@ -118,7 +118,7 @@ main (void)
To compile it one can use the following command:
```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-default libjerry-math)
```
If everything is correct the application returns with a zero exit code:
@@ -181,7 +181,7 @@ main (void)
To compile it one can use the following command:
```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-default libjerry-math)
```
If everything is correct the application returns with a zero exit code:
@@ -285,7 +285,7 @@ main (void)
To compile it one can use the following command:
```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-default libjerry-math)
```
If everything is correct the application should print out the message present in the `print_handler` method:
@@ -405,7 +405,7 @@ main (void)
To compile it one can use the following command:
```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-default libjerry-math)
```
If everything is correct the application should print out the string passed for the `print` method in the JS code:
@@ -473,7 +473,7 @@ 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.
```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-default libjerry-math)
```
If everything is correct the application should print out the string passed for the `print` method in the JS code:
@@ -549,7 +549,7 @@ 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.
```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-default 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:
@@ -822,7 +822,7 @@ 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.
```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-default libjerry-math)
```
The application reads lines from standard input and evaluates them, one after another. To try out run:
@@ -922,7 +922,7 @@ 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.
```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-default libjerry-math)
```
Execute the example with:
@@ -1053,7 +1053,7 @@ 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.
```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-default libjerry-math)
```
Execute the example with:
@@ -1084,7 +1084,8 @@ int
main (void)
{
/* Initialize srand value */
srand ((unsigned) jerry_port_get_current_time ());
union { double d; unsigned u; } now = { .d = jerry_port_get_current_time () };
srand (now.u);
/* Generate a random number, and print it */
const jerry_char_t script[] = "var a = Math.random (); print(a)";
+2 -1
View File
@@ -284,7 +284,8 @@ The objects are represented as following structure:
![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:
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
+57 -2
View File
@@ -83,7 +83,7 @@ information.
void jerry_port_print_char (char c);
```
### ES2015 Module system
### Jerry 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.
@@ -135,7 +135,7 @@ jerry_port_normalize_path (const char *in_path_p, /**< input file path */
* Get the module object of a native module.
*
* Note:
* This port function is called by jerry-core when ES2015_MODULE_SYSTEM
* This port function is called by jerry-core when JERRY_MODULE_SYSTEM
* is enabled.
*
* @param name String value of the module specifier.
@@ -151,6 +151,32 @@ jerry_port_get_native_module (jerry_value_t name) /**< module specifier */
}
```
## Promise
```c
/**
* HostPromiseRejectionTracker operations
*/
typedef enum
{
JERRY_PROMISE_REJECTION_OPERATION_REJECT, /**< promise is rejected without any handlers */
JERRY_PROMISE_REJECTION_OPERATION_HANDLE, /**< handler is added to a rejected promise for the first time */
} jerry_promise_rejection_operation_t;
/**
* Track unhandled promise rejections.
*
* Note:
* This port function is called by jerry-core when JERRY_BUILTIN_PROMISE
* is enabled.
*
* @param promise rejected promise
* @param operation HostPromiseRejectionTracker operation
*/
void jerry_port_track_promise_rejection (const jerry_value_t promise,
const jerry_promise_rejection_operation_t operation);
```
## Date
```c
@@ -392,3 +418,32 @@ void jerry_port_sleep (uint32_t sleep_time)
} /* jerry_port_sleep */
#endif /* defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1) */
```
## Promise
```c
#include "jerryscript-port.h"
/**
* Default implementation of jerry_port_track_promise_rejection.
* Prints the reason of the unhandled rejections.
*/
void
jerry_port_track_promise_rejection (const jerry_value_t promise, /**< rejected promise */
const jerry_promise_rejection_operation_t operation) /**< operation */
{
(void) operation; /* unused */
jerry_value_t reason = jerry_get_promise_result (promise);
jerry_value_t reason_to_string = jerry_value_to_string (reason);
jerry_size_t req_sz = jerry_get_utf8_string_size (reason_to_string);
jerry_char_t str_buf_p[req_sz + 1];
jerry_string_to_utf8_char_buffer (reason_to_string, str_buf_p, req_sz);
str_buf_p[req_sz] = '\0';
jerry_release_value (reason_to_string);
jerry_release_value (reason);
printf ("Uncaught (in promise) %s\n", str_buf_p);
} /* jerry_port_track_promise_rejection */
```
+6
View File
@@ -739,6 +739,12 @@ typedef
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 in JerryScript are verbose but this format
+2 -2
View File
@@ -2,7 +2,7 @@
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).
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
@@ -76,7 +76,7 @@ export var version = "1.0 (e92ae0fb)";
```js
// module_2.js
var featureName = "EcmaScript 2015 modules";
var featureName = "EcmaScript modules";
var year = 2018;
export function getFeatureDetails() {
+403 -79
View File
@@ -16,39 +16,33 @@ cmake_minimum_required (VERSION 2.8.12)
set(JERRY_CORE_NAME jerry-core)
project (${JERRY_CORE_NAME} C)
# Optional build settings
set(ENABLE_ALL_IN_ONE OFF CACHE BOOL "Enable all-in-one build?")
include(CheckLibraryExists)
# Optional features
set(JERRY_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?")
set(JERRY_LINE_INFO OFF CACHE BOOL "Enable line info?")
set(JERRY_LOGGING OFF CACHE BOOL "Enable logging?")
set(JERRY_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
set(JERRY_MEM_GC_BEFORE_EACH_ALLOC OFF CACHE BOOL "Enable mem-stress test?")
set(JERRY_PARSER_DUMP_BYTE_CODE OFF CACHE BOOL "Enable parser byte-code dumps?")
set(JERRY_PROFILE "es5.1" CACHE STRING "Use default or other profile?")
set(JERRY_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?")
set(JERRY_REGEXP_DUMP_BYTE_CODE OFF CACHE BOOL "Enable regexp byte-code dumps?")
set(JERRY_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
set(JERRY_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
set(JERRY_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
set(JERRY_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
set(JERRY_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
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_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?")
set(JERRY_LINE_INFO OFF CACHE BOOL "Enable line info?")
set(JERRY_LOGGING OFF CACHE BOOL "Enable logging?")
set(JERRY_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
set(JERRY_MEM_GC_BEFORE_EACH_ALLOC OFF CACHE BOOL "Enable mem-stress test?")
set(JERRY_PARSER_DUMP_BYTE_CODE OFF CACHE BOOL "Enable parser byte-code dumps?")
set(JERRY_PROFILE "es.next" CACHE STRING "Use default or other profile?")
set(JERRY_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?")
set(JERRY_REGEXP_DUMP_BYTE_CODE OFF CACHE BOOL "Enable regexp byte-code dumps?")
set(JERRY_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
set(JERRY_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
set(JERRY_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
set(JERRY_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
set(JERRY_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
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
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)
set(JERRY_CPOINTER_32_BIT ON)
@@ -82,7 +76,6 @@ if(JERRY_MEM_STATS OR JERRY_PARSER_DUMP_BYTE_CODE OR JERRY_REGEXP_DUMP_BYTE_CODE
endif()
# 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_DEBUGGER " ${JERRY_DEBUGGER})
message(STATUS "JERRY_ERROR_MESSAGES " ${JERRY_ERROR_MESSAGES})
@@ -104,6 +97,7 @@ message(STATUS "JERRY_VM_EXEC_STOP " ${JERRY_VM_EXEC_STOP})
message(STATUS "JERRY_GLOBAL_HEAP_SIZE " ${JERRY_GLOBAL_HEAP_SIZE})
message(STATUS "JERRY_GC_LIMIT " ${JERRY_GC_LIMIT})
message(STATUS "JERRY_STACK_LIMIT " ${JERRY_STACK_LIMIT})
message(STATUS "JERRY_GC_MARK_LIMIT " ${JERRY_GC_MARK_LIMIT})
# Include directories
set(INCLUDE_CORE_PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
@@ -128,70 +122,379 @@ set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} PARENT_SCOPE) # for tests/unit-
# Sources
# Jerry core
file(GLOB SOURCE_CORE_FILES
api/*.c
debugger/*.c
ecma/base/*.c
ecma/builtin-objects/*.c
ecma/builtin-objects/typedarray/*.c
ecma/operations/*.c
jcontext/*.c
jmem/*.c
jrt/*.c
lit/*.c
parser/js/*.c
parser/regexp/*.c
vm/*.c)
set(SOURCE_CORE_FILES
api/jerry-debugger-transport.c
api/jerry-debugger.c
api/jerry-snapshot.c
api/jerry.c
debugger/debugger.c
ecma/base/ecma-alloc.c
ecma/base/ecma-gc.c
ecma/base/ecma-helpers-collection.c
ecma/base/ecma-helpers-conversion.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-literal-storage.c
ecma/base/ecma-module.c
ecma/base/ecma-property-hashmap.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-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-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-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-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-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-arithmetic.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-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
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-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/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
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.
# Amalgamated JerryScript source/header build.
# The process will create the following files:
# * jerryscript.c
# * jerryscript.h
# * jerryscript-config.h
if(ENABLE_ALL_IN_ONE_SOURCE)
if(ENABLE_AMALGAM)
# 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-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-literal-storage.h
ecma/base/ecma-module.h
ecma/base/ecma-property-hashmap.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-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-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-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-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-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-arithmetic.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-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
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/src/jerryscript.c")
set(ALL_IN_FILE_H "${CMAKE_BINARY_DIR}/src/jerryscript.h")
set(JERRYSCRIPT_CONFIG_H "${CMAKE_BINARY_DIR}/src/jerryscript-config.h")
set(AMALGAM_CORE_C "${CMAKE_BINARY_DIR}/amalgam/jerryscript.c")
set(AMALGAM_CORE_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript.h")
set(AMALGAM_CONFIG_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript-config.h")
add_custom_command(OUTPUT ${ALL_IN_FILE} ${ALL_IN_FILE_H}
COMMAND python ${CMAKE_SOURCE_DIR}/tools/srcgenerator.py
add_custom_command(OUTPUT ${AMALGAM_CORE_C} ${AMALGAM_CORE_H}
COMMAND python ${CMAKE_SOURCE_DIR}/tools/amalgam.py
--jerry-core
--output-dir ${CMAKE_BINARY_DIR}/src
--output-dir ${CMAKE_BINARY_DIR}/amalgam
DEPENDS ${SOURCE_CORE_FILES}
${HEADER_CORE_FILES}
${CMAKE_SOURCE_DIR}/tools/srcgenerator.py
${CMAKE_SOURCE_DIR}/tools/srcmerger.py
${CMAKE_SOURCE_DIR}/tools/amalgam.py
)
# 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.
# 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)
add_custom_command(OUTPUT ${JERRYSCRIPT_CONFIG_H}
COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${JERRYSCRIPT_CONFIG_H}
DEPENDS ${ALL_IN_FILE_C} ${ALL_IN_FILE_H})
add_custom_target(generate-single-source-jerry DEPENDS ${ALL_IN_FILE} ${ALL_IN_FILE_H})
add_dependencies(generate-single-source generate-single-source-jerry)
add_custom_command(OUTPUT ${AMALGAM_CONFIG_H}
COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${AMALGAM_CONFIG_H}
DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H})
add_custom_target(amalgam-jerry DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
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})
endif()
# Third-party
@@ -252,14 +555,18 @@ jerry_add_define01(JERRY_MEM_GC_BEFORE_EACH_ALLOC)
jerry_add_define01(JERRY_PARSER_DUMP_BYTE_CODE)
# 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})
set(JERRY_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/profiles/${JERRY_PROFILE}.profile")
endif()
if(EXISTS ${JERRY_PROFILE})
file(READ "${JERRY_PROFILE}" PROFILE_SETTINGS)
string(REGEX REPLACE "^#.*$" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
string(REGEX REPLACE "[\r|\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
string(REGEX REPLACE "[ \t]*#[^\n]*" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
string(REGEX REPLACE "[\r\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
# Process entries and save them as CMake variables.
# This is required to correctly generate the jerryscript-config.h file.
@@ -305,6 +612,9 @@ set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GLOBAL_HEAP_SIZE=${JERRY_GLOBAL_HEAP_SI
# Maximum size of stack memory usage
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_STACK_LIMIT=${JERRY_STACK_LIMIT})
# Maximum depth of recursion during GC mark phase
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GC_MARK_LIMIT=${JERRY_GC_MARK_LIMIT})
## This function is to read "config.h" for default values
function(read_set_defines FILE PREFIX OUTPUTVAR)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}" INPUT_FILE_CONTENTS)
@@ -395,10 +705,24 @@ target_include_directories(${JERRY_CORE_NAME} PRIVATE ${INCLUDE_CORE_PRIVATE})
set(JERRY_CORE_PKGCONFIG_REQUIRES)
set(JERRY_CORE_PKGCONFIG_LIBS)
set(JERRY_CORE_PKGCONFIG_CFLAGS)
if(JERRY_LIBM)
target_link_libraries(${JERRY_CORE_NAME} jerry-libm)
set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-libm)
if(ENABLE_LTO)
set(JERRY_CORE_PKGCONFIG_CFLAGS "${JERRY_CORE_PKGCONFIG_CFLAGS} -flto")
endif()
if(JERRY_MATH)
target_link_libraries(${JERRY_CORE_NAME} jerry-math)
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()
separate_arguments(EXTERNAL_LINK_LIBS)
+215 -198
View File
@@ -24,6 +24,7 @@
#include "jerry-snapshot.h"
#include "js-parser.h"
#include "lit-char-helpers.h"
#include "js-parser-internal.h"
#include "re-compiler.h"
#if ENABLED (JERRY_SNAPSHOT_SAVE) || ENABLED (JERRY_SNAPSHOT_EXEC)
@@ -45,9 +46,12 @@ snapshot_get_global_flags (bool has_regex, /**< regex literal is present */
#if ENABLED (JERRY_BUILTIN_REGEXP)
flags |= (has_regex ? JERRY_SNAPSHOT_HAS_REGEX_LITERAL : 0);
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
#if ENABLED (JERRY_ES2015_CLASS)
#if ENABLED (JERRY_ESNEXT)
flags |= (has_class ? JERRY_SNAPSHOT_HAS_CLASS_LITERAL : 0);
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_REALMS)
flags |= JERRY_SNAPSHOT_HAS_REALM_VALUE;
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
return flags;
} /* snapshot_get_global_flags */
@@ -63,9 +67,12 @@ snapshot_check_global_flags (uint32_t global_flags) /**< global flags */
#if ENABLED (JERRY_BUILTIN_REGEXP)
global_flags &= (uint32_t) ~JERRY_SNAPSHOT_HAS_REGEX_LITERAL;
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
#if ENABLED (JERRY_ES2015_CLASS)
#if ENABLED (JERRY_ESNEXT)
global_flags &= (uint32_t) ~JERRY_SNAPSHOT_HAS_CLASS_LITERAL;
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_REALMS)
global_flags |= JERRY_SNAPSHOT_HAS_REALM_VALUE;
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
return global_flags == snapshot_get_global_flags (false, false);
} /* snapshot_check_global_flags */
@@ -160,15 +167,22 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
#if ENABLED (JERRY_ES2015_CLASS)
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR)
#if ENABLED (JERRY_ESNEXT)
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
{
const char * const error_message_p = "Unsupported feature: tagged template literals.";
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
return 0;
}
if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) == CBC_FUNCTION_CONSTRUCTOR)
{
globals_p->class_found = true;
}
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_REGEXP)
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
if (!CBC_IS_FUNCTION (compiled_code_p->status_flags))
{
/* Regular expression. */
if (globals_p->snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t) > snapshot_buffer_size)
@@ -182,7 +196,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
ecma_value_t pattern = ((re_compiled_code_t *) compiled_code_p)->source;
ecma_string_t *pattern_string_p = ecma_get_string_from_value (pattern);
ecma_length_t pattern_size = 0;
lit_utf8_size_t pattern_size = 0;
ECMA_STRING_TO_UTF8_STRING (pattern_string_p, buffer_p, buffer_size);
@@ -212,7 +226,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
/* Regexp character size is stored in refs. */
copied_code_p->refs = (uint16_t) pattern_size;
pattern_size += (ecma_length_t) sizeof (ecma_compiled_code_t);
pattern_size += (lit_utf8_size_t) sizeof (ecma_compiled_code_t);
copied_code_p->size = (uint16_t) ((pattern_size + JMEM_ALIGNMENT - 1) >> JMEM_ALIGNMENT_LOG);
copied_code_p->status_flags = compiled_code_p->status_flags;
@@ -221,7 +235,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
}
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
JERRY_ASSERT (compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
JERRY_ASSERT (CBC_IS_FUNCTION (compiled_code_p->status_flags));
if (!snapshot_write_to_buffer_by_offset (snapshot_buffer_p,
snapshot_buffer_size,
@@ -288,19 +302,20 @@ static void
static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< snapshot globals */
ecma_value_t literal) /**< literal form the literal pool */
{
const lit_utf8_byte_t error_prefix[] = "Unsupported static snapshot literal: ";
lit_utf8_byte_t *str_p = (lit_utf8_byte_t *) "Unsupported static snapshot literal: ";
ecma_stringbuilder_t builder = ecma_stringbuilder_create_raw (str_p, 37);
ecma_string_t *error_message_p = ecma_new_ecma_string_from_utf8 (error_prefix, sizeof (error_prefix) - 1);
literal = ecma_op_to_string (literal);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (literal));
ecma_string_t *literal_string_p = ecma_get_string_from_value (literal);
error_message_p = ecma_concat_ecma_strings (error_message_p, literal_string_p);
ecma_string_t *literal_string_p = ecma_op_to_string (literal);
JERRY_ASSERT (literal_string_p != NULL);
ecma_stringbuilder_append (&builder, literal_string_p);
ecma_deref_ecma_string (literal_string_p);
ecma_object_t *error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE, error_message_p);
ecma_deref_ecma_string (error_message_p);
ecma_object_t *error_object_p = ecma_new_standard_error (ECMA_ERROR_RANGE,
ecma_stringbuilder_finalize (&builder));
globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p);
} /* static_snapshot_error_unsupported_literal */
@@ -337,7 +352,7 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
if (!CBC_IS_FUNCTION (compiled_code_p->status_flags))
{
/* Regular expression literals are not supported. */
const char * const error_message_p = "Regular expression literals are not supported.";
@@ -359,7 +374,6 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
/* Sub-functions and regular expressions are stored recursively. */
uint8_t *buffer_p = (uint8_t *) copied_code_p;
ecma_value_t *literal_start_p;
uint32_t argument_end;
uint32_t const_literal_end;
uint32_t literal_end;
@@ -370,18 +384,24 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
#if ENABLED (JERRY_BUILTIN_REALMS)
args_p->realm_value = JMEM_CP_NULL;
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
}
else
{
literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
#if ENABLED (JERRY_BUILTIN_REALMS)
args_p->realm_value = JMEM_CP_NULL;
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
}
for (uint32_t i = 0; i < const_literal_end; i++)
@@ -416,19 +436,19 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
}
}
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (compiled_code_p))
{
buffer_p += ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG;
literal_start_p = ((ecma_value_t *) buffer_p) - argument_end;
buffer_p += ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG;
literal_start_p = ecma_snapshot_resolve_serializable_values (compiled_code_p, buffer_p);
for (uint32_t i = 0; i < argument_end; i++)
while (literal_start_p < (ecma_value_t *) buffer_p)
{
if (!ecma_is_value_direct_string (*literal_start_p)
&& !ecma_is_value_empty (*literal_start_p))
{
if (!ecma_is_value_direct_string (literal_start_p[i]))
{
static_snapshot_error_unsupported_literal (globals_p, literal_start_p[i]);
return 0;
}
static_snapshot_error_unsupported_literal (globals_p, *literal_start_p);
return 0;
}
literal_start_p++;
}
return start_offset;
@@ -449,10 +469,9 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
if (CBC_IS_FUNCTION (bytecode_p->status_flags))
{
ecma_value_t *literal_start_p;
uint32_t argument_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
@@ -460,7 +479,6 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
literal_start_p = (ecma_value_t *) (((uint8_t *) buffer_p) + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
@@ -468,13 +486,15 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
literal_start_p = (ecma_value_t *) (((uint8_t *) buffer_p) + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
for (uint32_t i = 0; i < const_literal_end; i++)
{
if (ecma_is_value_string (literal_start_p[i])
#if ENABLED (JERRY_BUILTIN_BIGINT)
|| ecma_is_value_bigint (literal_start_p[i])
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|| ecma_is_value_float_number (literal_start_p[i]))
{
lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
@@ -488,28 +508,26 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
}
}
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p))
uint8_t *byte_p = (uint8_t *) bytecode_p + (((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
literal_start_p = ecma_snapshot_resolve_serializable_values (bytecode_p, byte_p);
while (literal_start_p < (ecma_value_t *) byte_p)
{
uint8_t *byte_p = (uint8_t *) bytecode_p;
byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
literal_start_p = ((ecma_value_t *) byte_p) - argument_end;
for (uint32_t i = 0; i < argument_end; i++)
if (*literal_start_p != ECMA_VALUE_EMPTY)
{
if (literal_start_p[i] != ECMA_VALUE_EMPTY)
JERRY_ASSERT (ecma_is_value_string (*literal_start_p));
lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
while (current_p->literal_id != *literal_start_p)
{
JERRY_ASSERT (ecma_is_value_string (literal_start_p[i]));
lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
while (current_p->literal_id != literal_start_p[i])
{
current_p++;
}
literal_start_p[i] = current_p->literal_offset;
current_p++;
}
*literal_start_p = current_p->literal_offset;
}
literal_start_p++;
}
/* Set reference counter to 1. */
@@ -549,30 +567,26 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
#if ENABLED (JERRY_BUILTIN_REGEXP)
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
if (!CBC_IS_FUNCTION (bytecode_p->status_flags))
{
const re_compiled_code_t *re_bytecode_p = NULL;
const uint8_t *regex_start_p = ((const uint8_t *) bytecode_p) + sizeof (ecma_compiled_code_t);
/* Real size is stored in refs. */
ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p,
bytecode_p->refs);
re_compile_bytecode (&re_bytecode_p,
pattern_str_p,
bytecode_p->status_flags);
const re_compiled_code_t *re_bytecode_p = re_compile_bytecode (pattern_str_p,
bytecode_p->status_flags);
ecma_deref_ecma_string (pattern_str_p);
return (ecma_compiled_code_t *) re_bytecode_p;
}
#else /* !ENABLED (JERRY_BUILTIN_REGEXP) */
JERRY_ASSERT (CBC_IS_FUNCTION (bytecode_p->status_flags));
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
JERRY_ASSERT (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
size_t header_size;
uint32_t argument_end = 0;
uint32_t argument_end;
uint32_t const_literal_end;
uint32_t literal_end;
@@ -581,28 +595,28 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
uint8_t *byte_p = (uint8_t *) bytecode_p;
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) byte_p;
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p))
{
argument_end = args_p->argument_end;
}
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
header_size = sizeof (cbc_uint16_arguments_t);
#if ENABLED (JERRY_BUILTIN_REALMS)
ECMA_SET_INTERNAL_VALUE_POINTER (args_p->realm_value, ecma_builtin_get_global ());
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
}
else
{
uint8_t *byte_p = (uint8_t *) bytecode_p;
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) byte_p;
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p))
{
argument_end = args_p->argument_end;
}
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
header_size = sizeof (cbc_uint8_arguments_t);
#if ENABLED (JERRY_BUILTIN_REALMS)
ECMA_SET_INTERNAL_VALUE_POINTER (args_p->realm_value, ecma_builtin_get_global ());
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
}
if (copy_bytecode
@@ -622,13 +636,33 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
uint8_t *real_bytecode_p = ((uint8_t *) bytecode_p) + start_offset;
uint32_t new_code_size = (uint32_t) (start_offset + 1 + sizeof (uint8_t *));
uint32_t extra_bytes = 0;
if (argument_end != 0)
if (bytecode_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
{
new_code_size += (uint32_t) (argument_end * sizeof (ecma_value_t));
extra_bytes += (uint32_t) (argument_end * sizeof (ecma_value_t));
}
new_code_size = JERRY_ALIGNUP (new_code_size, JMEM_ALIGNMENT);
#if ENABLED (JERRY_ESNEXT)
/* function name */
if (CBC_FUNCTION_GET_TYPE (bytecode_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
{
extra_bytes += (uint32_t) sizeof (ecma_value_t);
}
/* tagged template literals */
if (bytecode_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
{
extra_bytes += (uint32_t) sizeof (ecma_value_t);
}
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_RESOURCE_NAME)
/* resource name */
extra_bytes += (uint32_t) sizeof (ecma_value_t);
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
new_code_size = JERRY_ALIGNUP (new_code_size + extra_bytes, JMEM_ALIGNMENT);
bytecode_p = (ecma_compiled_code_t *) jmem_heap_alloc_block (new_code_size);
@@ -642,12 +676,12 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
uint8_t *byte_p = (uint8_t *) bytecode_p;
if (argument_end != 0)
uint8_t *new_base_p = byte_p + new_code_size - extra_bytes;
const uint8_t *base_p = base_addr_p + code_size - extra_bytes;
if (extra_bytes != 0)
{
uint32_t argument_size = (uint32_t) (argument_end * sizeof (ecma_value_t));
memcpy (byte_p + new_code_size - argument_size,
base_addr_p + code_size - argument_size,
argument_size);
memcpy (new_base_p, base_p, extra_bytes);
}
byte_p[start_offset] = CBC_SET_BYTECODE_PTR;
@@ -694,18 +728,17 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
}
}
if (argument_end != 0)
{
literal_start_p = (ecma_value_t *) (((uint8_t *) bytecode_p) + code_size);
literal_start_p -= argument_end;
uint8_t *byte_p = ((uint8_t *) bytecode_p) + code_size;
literal_start_p = ecma_snapshot_resolve_serializable_values (bytecode_p, byte_p);
for (uint32_t i = 0; i < argument_end; i++)
while (literal_start_p < (ecma_value_t *) byte_p)
{
if ((*literal_start_p & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
{
if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
{
literal_start_p[i] = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
}
*literal_start_p = ecma_snapshot_get_literal (literal_base_p, *literal_start_p);
}
literal_start_p++;
}
return bytecode_p;
@@ -738,13 +771,16 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
JERRY_UNUSED (resource_name_p);
JERRY_UNUSED (resource_name_length);
#if ENABLED (JERRY_LINE_INFO)
JERRY_CONTEXT (resource_name) = ECMA_VALUE_UNDEFINED;
#endif /* ENABLED (JERRY_LINE_INFO) */
ecma_value_t resource_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
#if ENABLED (JERRY_RESOURCE_NAME)
if (resource_name_length > 0)
{
resource_name = ecma_find_or_create_literal_string (resource_name_p, (lit_utf8_size_t) resource_name_length);
}
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
snapshot_globals_t globals;
ecma_value_t parse_status;
ecma_compiled_code_t *bytecode_data_p;
const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t),
JMEM_ALIGNMENT);
@@ -753,20 +789,21 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
globals.regex_found = false;
globals.class_found = false;
parse_status = parser_parse_script (args_p,
args_size,
source_p,
source_size,
(generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STRICT) != 0,
&bytecode_data_p);
uint32_t status_flags = ((generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STRICT) ? ECMA_PARSE_STRICT_MODE
: ECMA_PARSE_NO_OPTS);
if (ECMA_IS_VALUE_ERROR (parse_status))
ecma_compiled_code_t *bytecode_data_p = parser_parse_script (args_p,
args_size,
source_p,
source_size,
resource_name,
status_flags);
if (JERRY_UNLIKELY (bytecode_data_p == NULL))
{
return ecma_create_error_reference (JERRY_CONTEXT (error_value), true);
return ecma_create_error_reference_from_context ();
}
JERRY_ASSERT (bytecode_data_p != NULL);
if (generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STATIC)
{
static_snapshot_add_compiled_code (bytecode_data_p, (uint8_t *) buffer_p, buffer_size, &globals);
@@ -977,13 +1014,32 @@ jerry_snapshot_result (const uint32_t *snapshot_p, /**< snapshot */
}
}
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_SHOW_OPCODES)
{
util_print_cbc (bytecode_p);
}
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
ecma_value_t ret_val;
if (as_function)
{
ecma_object_t *lex_env_p = ecma_get_global_environment ();
ecma_object_t *func_obj_p = ecma_op_create_function_object (lex_env_p,
bytecode_p);
ecma_object_t *global_object_p = ecma_builtin_get_global ();
#if ENABLED (JERRY_BUILTIN_REALMS)
JERRY_ASSERT (global_object_p == (ecma_object_t *) ecma_op_function_get_realm (bytecode_p));
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
#if ENABLED (JERRY_ESNEXT)
if (bytecode_p->status_flags & CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED)
{
ecma_create_global_lexical_block (global_object_p);
}
#endif /* ENABLED (JERRY_ESNEXT) */
ecma_object_t *lex_env_p = ecma_get_global_scope (global_object_p);
ecma_object_t *func_obj_p = ecma_op_create_simple_function_object (lex_env_p, bytecode_p);
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{
@@ -1058,11 +1114,10 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{
const ecma_value_t *literal_start_p;
uint32_t argument_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
@@ -1070,7 +1125,6 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
@@ -1078,7 +1132,6 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
@@ -1091,20 +1144,18 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
}
}
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p))
{
uint8_t *byte_p = (uint8_t *) bytecode_p;
byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
literal_start_p = ((ecma_value_t *) byte_p) - argument_end;
uint8_t *byte_p = (uint8_t *) bytecode_p + (((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
literal_start_p = ecma_snapshot_resolve_serializable_values ((ecma_compiled_code_t *) bytecode_p, byte_p);
for (uint32_t i = 0; i < argument_end; i++)
while (literal_start_p < (ecma_value_t *) byte_p)
{
if ((*literal_start_p & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
{
if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
{
ecma_value_t lit_value = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
ecma_save_literals_append_value (lit_value, lit_pool_p);
}
ecma_value_t lit_value = ecma_snapshot_get_literal (literal_base_p, *literal_start_p);
ecma_save_literals_append_value (lit_value, lit_pool_p);
}
literal_start_p++;
}
}
@@ -1129,11 +1180,10 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{
ecma_value_t *literal_start_p;
uint32_t argument_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
@@ -1141,7 +1191,6 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
@@ -1149,7 +1198,6 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
@@ -1169,27 +1217,25 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
}
}
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_p))
uint8_t *byte_p = (uint8_t *) bytecode_p + (((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
literal_start_p = ecma_snapshot_resolve_serializable_values ((ecma_compiled_code_t *) bytecode_p, byte_p);
while (literal_start_p < (ecma_value_t *) byte_p)
{
uint8_t *byte_p = (uint8_t *) bytecode_p;
byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
literal_start_p = ((ecma_value_t *) byte_p) - argument_end;
for (uint32_t i = 0; i < argument_end; i++)
if ((*literal_start_p & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
{
if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
ecma_value_t lit_value = ecma_snapshot_get_literal (literal_base_p, *literal_start_p);
const lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
while (current_p->literal_id != lit_value)
{
ecma_value_t lit_value = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
const lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
while (current_p->literal_id != lit_value)
{
current_p++;
}
literal_start_p[i] = current_p->literal_offset;
current_p++;
}
*literal_start_p = current_p->literal_offset;
}
literal_start_p++;
}
}
@@ -1543,42 +1589,6 @@ jerry_append_number_to_buffer (uint8_t *buffer_p, /**< buffer */
utf8_str_size);
} /* jerry_append_number_to_buffer */
/**
* Check whether the passed ecma-string is a valid identifier.
*
* @return true - if the ecma-string is a valid identifier,
* false - otherwise
*/
static bool
ecma_string_is_valid_identifier (const ecma_string_t *string_p)
{
bool result = false;
ECMA_STRING_TO_UTF8_STRING (string_p, str_buffer_p, str_buffer_size);
if (lit_char_is_identifier_start (str_buffer_p))
{
const uint8_t *str_start_p = str_buffer_p;
const uint8_t *str_end_p = str_buffer_p + str_buffer_size;
result = true;
while (str_start_p < str_end_p)
{
if (!lit_char_is_identifier_part (str_start_p))
{
result = false;
break;
}
lit_utf8_incr (&str_start_p);
}
}
ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size);
return result;
} /* ecma_string_is_valid_identifier */
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */
/**
@@ -1631,14 +1641,7 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
{
ecma_string_t *literal_p = ecma_get_string_from_value (buffer_p[i]);
/* NOTE:
* We don't save a literal (in C format) which isn't a valid
* identifier or it's a magic string.
* TODO:
* Save all of the literals in C format as well.
*/
if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
&& (!is_c_format || ecma_string_is_valid_identifier (literal_p)))
if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT)
{
literal_count++;
}
@@ -1666,14 +1669,7 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
{
ecma_string_t *literal_p = ecma_get_string_from_value (buffer_p[i]);
/* NOTE:
* We don't save a literal (in C format) which isn't a valid
* identifier or it's a magic string.
* TODO:
* Save all of the literals in C format as well.
*/
if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
&& (!is_c_format || ecma_string_is_valid_identifier (literal_p)))
if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT)
{
literal_array[literal_idx++] = literal_p;
}
@@ -1707,7 +1703,29 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
for (lit_utf8_size_t i = 0; i < literal_count; i++)
{
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, " \"", 0);
lit_buf_p = jerry_append_ecma_string_to_buffer (lit_buf_p, buffer_end_p, literal_array[i]);
ECMA_STRING_TO_UTF8_STRING (literal_array[i], str_buffer_p, str_buffer_size);
for (lit_utf8_size_t j = 0; j < str_buffer_size; j++)
{
uint8_t byte = str_buffer_p[j];
if (byte < 32 || byte > 127)
{
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "\\x", 0);
ecma_char_t hex_digit = (ecma_char_t) (byte >> 4);
*lit_buf_p++ = (lit_utf8_byte_t) ((hex_digit > 9) ? (hex_digit + ('A' - 10)) : (hex_digit + '0'));
hex_digit = (lit_utf8_byte_t) (byte & 0xf);
*lit_buf_p++ = (lit_utf8_byte_t) ((hex_digit > 9) ? (hex_digit + ('A' - 10)) : (hex_digit + '0'));
}
else
{
if (byte == '\\' || byte == '"')
{
*lit_buf_p++ = '\\';
}
*lit_buf_p++ = byte;
}
}
ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size);
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "\"", 0);
if (i < literal_count - 1)
@@ -1779,7 +1797,6 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */
} /* jerry_get_literals_from_snapshot */
/**
* Generate snapshot function from specified source and arguments
*
+2 -1
View File
@@ -45,7 +45,8 @@ typedef enum
{
/* 8 bits are reserved for dynamic features */
JERRY_SNAPSHOT_HAS_REGEX_LITERAL = (1u << 0), /**< byte code has regex literal */
JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 1), /**< byte code has class literal */
JERRY_SNAPSHOT_HAS_REALM_VALUE = (1u << 1), /**< byte code has realm value */
JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 2), /**< byte code has class literal */
/* 24 bits are reserved for compile time features */
JERRY_SNAPSHOT_FOUR_BYTE_CPOINTER = (1u << 8) /**< deprecated, an unused placeholder now */
} jerry_snapshot_global_flags_t;
+2369 -326
View File
File diff suppressed because it is too large Load Diff
+128 -116
View File
@@ -40,6 +40,10 @@
# define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ARRAY) */
#ifndef JERRY_BUILTIN_BOOLEAN
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
#ifndef JERRY_BUILTIN_DATE
# define JERRY_BUILTIN_DATE JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_DATE) */
@@ -48,10 +52,6 @@
# define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ERRORS) */
#ifndef JERRY_BUILTIN_BOOLEAN
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
#ifndef JERRY_BUILTIN_JSON
# define JERRY_BUILTIN_JSON JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_JSON) */
@@ -73,75 +73,59 @@
#endif /* !defined (JERRY_BUILTIN_STRING) */
/**
* ES2015 (a.k.a es6) related features, by default all of them are enabled.
* ES2015+ related features, by default all of them are enabled.
*/
#ifndef JERRY_ES2015
# define JERRY_ES2015 1
#endif /* !defined (JERRY_ES2015) */
#ifndef JERRY_ESNEXT
# define JERRY_ESNEXT 1
#endif /* !defined (JERRY_ESNEXT) */
#ifndef JERRY_ES2015_BUILTIN
# define JERRY_ES2015_BUILTIN JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN) */
#ifndef JERRY_BUILTIN_BIGINT
# define JERRY_BUILTIN_BIGINT JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_BIGINT) */
#ifndef JERRY_ES2015_BUILTIN_DATAVIEW
# define JERRY_ES2015_BUILTIN_DATAVIEW JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_DATAVIEW) */
#ifndef JERRY_BUILTIN_DATAVIEW
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
#ifndef JERRY_ES2015_BUILTIN_ITERATOR
# define JERRY_ES2015_BUILTIN_ITERATOR JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_ITERATOR) */
#ifndef JERRY_BUILTIN_MAP
# define JERRY_BUILTIN_MAP JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_MAP) */
#ifndef JERRY_ES2015_BUILTIN_MAP
# define JERRY_ES2015_BUILTIN_MAP JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_MAP) */
#ifndef JERRY_BUILTIN_PROMISE
# define JERRY_BUILTIN_PROMISE JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_PROMISE) */
#ifndef JERRY_ES2015_BUILTIN_SET
# define JERRY_ES2015_BUILTIN_SET JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_SET) */
#ifndef JERRY_BUILTIN_PROXY
# define JERRY_BUILTIN_PROXY JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_PROXY) */
#ifndef JERRY_ES2015_BUILTIN_PROMISE
# define JERRY_ES2015_BUILTIN_PROMISE JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_PROMISE) */
#ifndef JERRY_BUILTIN_REALMS
# define JERRY_BUILTIN_REALMS JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_REALMS) */
#ifndef JERRY_ES2015_BUILTIN_SYMBOL
# define JERRY_ES2015_BUILTIN_SYMBOL JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_SYMBOL) */
#ifndef JERRY_BUILTIN_REFLECT
# define JERRY_BUILTIN_REFLECT JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_REFLECT) */
#ifndef JERRY_ES2015_BUILTIN_TYPEDARRAY
# define JERRY_ES2015_BUILTIN_TYPEDARRAY JERRY_ES2015
#endif /* !defined (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
#ifndef JERRY_BUILTIN_SET
# define JERRY_BUILTIN_SET JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_SET) */
#ifndef JERRY_ES2015_ARROW_FUNCTION
# define JERRY_ES2015_ARROW_FUNCTION JERRY_ES2015
#endif /* !defined (JERRY_ES2015_ARROW_FUNCTION) */
#ifndef JERRY_BUILTIN_TYPEDARRAY
# define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
#ifndef JERRY_ES2015_CLASS
# define JERRY_ES2015_CLASS JERRY_ES2015
#endif /* !defined (JERRY_ES2015_CLASS) */
#ifndef JERRY_BUILTIN_WEAKMAP
# define JERRY_BUILTIN_WEAKMAP JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_WEAKMAP) */
#ifndef JERRY_ES2015_FOR_OF
# define JERRY_ES2015_FOR_OF JERRY_ES2015
#endif /* !defined (JERRY_ES2015_FOR_OF) */
#ifndef JERRY_BUILTIN_WEAKSET
# define JERRY_BUILTIN_WEAKSET JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_WEAKSET) */
#ifndef JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER
# define JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER JERRY_ES2015
#endif /* !defined (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) */
#ifndef JERRY_ES2015_FUNCTION_REST_PARAMETER
# define JERRY_ES2015_FUNCTION_REST_PARAMETER JERRY_ES2015
#endif /* !defined (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
#ifndef JERRY_ES2015_OBJECT_INITIALIZER
# define JERRY_ES2015_OBJECT_INITIALIZER JERRY_ES2015
#endif /* !defined (JERRY_ES2015_OBJECT_INITIALIZER) */
#ifndef JERRY_ES2015_MODULE_SYSTEM
# define JERRY_ES2015_MODULE_SYSTEM JERRY_ES2015
#endif /* !defined (JERRY_ES2015_MODULE_SYSTEM) */
#ifndef JERRY_ES2015_TEMPLATE_STRINGS
# define JERRY_ES2015_TEMPLATE_STRINGS JERRY_ES2015
#endif /* !defined (JERRY_ES2015_TEMPLATE_STRINGS) */
#ifndef JERRY_MODULE_SYSTEM
# define JERRY_MODULE_SYSTEM JERRY_ESNEXT
#endif /* !defined (JERRY_MODULE_SYSTEM) */
/**
* Engine internal and misc configurations.
@@ -229,6 +213,15 @@
# define JERRY_STACK_LIMIT (0)
#endif /* !defined (JERRY_STACK_LIMIT) */
/**
* Maximum depth of recursion during GC mark phase
*
* Default value: 8
*/
#ifndef JERRY_GC_MARK_LIMIT
# define JERRY_GC_MARK_LIMIT (8)
#endif /* !defined (JERRY_GC_MARK_LIMIT) */
/**
* Enable/Disable property lookup cache.
*
@@ -474,7 +467,6 @@
# define JERRY_ATTR_GLOBAL_HEAP
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
/**
* Sanity check for macros to see if the values are 0 or 1
*
@@ -529,75 +521,74 @@
#endif
/**
* Check ES2015 features
* Check ES2015+ features
*/
#if !defined (JERRY_ES2015) \
|| ((JERRY_ES2015 != 0) && (JERRY_ES2015 != 1))
# error "Invalid value for JERRY_ES2015 macro."
#if !defined (JERRY_ESNEXT) \
|| ((JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1))
# error "Invalid value for JERRY_ESNEXT macro."
#endif
#if !defined (JERRY_ES2015_ARROW_FUNCTION) \
|| ((JERRY_ES2015_ARROW_FUNCTION != 0) && (JERRY_ES2015_ARROW_FUNCTION != 1))
# error "Invalid value for JERRY_ES2015_ARROW_FUNCTION macro."
#if !defined (JERRY_BUILTIN_REALMS) \
|| ((JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1))
# error "Invalid value for JERRY_BUILTIN_REALMS macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN) \
|| ((JERRY_ES2015_BUILTIN != 0) && (JERRY_ES2015_BUILTIN != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN macro."
#if !defined (JERRY_BUILTIN_DATAVIEW) \
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1))
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_ITERATOR) \
|| ((JERRY_ES2015_BUILTIN_ITERATOR != 0) && (JERRY_ES2015_BUILTIN_ITERATOR != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_ITERATOR macro."
#if !defined (JERRY_BUILTIN_MAP) \
|| ((JERRY_BUILTIN_MAP != 0) && (JERRY_BUILTIN_MAP != 1))
# error "Invalid value for JERRY_BUILTIN_MAP macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_DATAVIEW) \
|| ((JERRY_ES2015_BUILTIN_DATAVIEW != 0) && (JERRY_ES2015_BUILTIN_DATAVIEW != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_DATAVIEW macro."
#if !defined (JERRY_BUILTIN_REFLECT) \
|| ((JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1))
# error "Invalid value for JERRY_BUILTIN_REFLECT macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_MAP) \
|| ((JERRY_ES2015_BUILTIN_MAP != 0) && (JERRY_ES2015_BUILTIN_MAP != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_MAP macro."
#if !defined (JERRY_BUILTIN_SET) \
|| ((JERRY_BUILTIN_SET != 0) && (JERRY_BUILTIN_SET != 1))
# error "Invalid value for JERRY_BUILTIN_SET macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_SET) \
|| ((JERRY_ES2015_BUILTIN_SET != 0) && (JERRY_ES2015_BUILTIN_SET != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_SET macro."
#if !defined (JERRY_BUILTIN_WEAKMAP) \
|| ((JERRY_BUILTIN_WEAKMAP != 0) && (JERRY_BUILTIN_WEAKMAP != 1))
# error "Invalid value for JERRY_BUILTIN_WEAKMAP 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."
#if !defined (JERRY_BUILTIN_WEAKSET) \
|| ((JERRY_BUILTIN_WEAKSET != 0) && (JERRY_BUILTIN_WEAKSET != 1))
# error "Invalid value for JERRY_BUILTIN_WEAKSET macro."
#endif
#if !defined (JERRY_ES2015_BUILTIN_SYMBOL) \
|| ((JERRY_ES2015_BUILTIN_SYMBOL != 0) && (JERRY_ES2015_BUILTIN_SYMBOL != 1))
# error "Invalid value for JERRY_ES2015_BUILTIN_SYMBOL macro."
#if !defined (JERRY_BUILTIN_PROMISE) \
|| ((JERRY_BUILTIN_PROMISE != 0) && (JERRY_BUILTIN_PROMISE != 1))
# error "Invalid value for JERRY_BUILTIN_PROMISE 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."
#if !defined (JERRY_BUILTIN_PROXY) \
|| ((JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1))
# error "Invalid value for JERRY_BUILTIN_PROXY macro."
#endif
#if !defined (JERRY_ES2015_CLASS) \
|| ((JERRY_ES2015_CLASS != 0) && (JERRY_ES2015_CLASS != 1))
# error "Invalid value for JERRY_ES2015_CLASS macro."
#if !defined (JERRY_BUILTIN_TYPEDARRAY) \
|| ((JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1))
# error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro."
#endif
#if !defined (JERRY_ES2015_FOR_OF) \
|| ((JERRY_ES2015_FOR_OF != 0) && (JERRY_ES2015_FOR_OF != 1))
# error "Invalid value for JERRY_ES2015_FOR_OF macro."
#if !defined (JERRY_BUILTIN_BIGINT) \
|| ((JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1))
# error "Invalid value for JERRY_BUILTIN_BIGINT macro."
#endif
#if !defined (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER) \
|| ((JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER != 0) && (JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER != 1))
# error "Invalid value for JERRY_ES2015_FUNCTION_PARAMETER_INITIALIZER macro."
#if !defined (JERRY_MODULE_SYSTEM) \
|| ((JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1))
# error "Invalid value for JERRY_MODULE_SYSTEM macro."
#endif
#if !defined (JERRY_ES2015_FUNCTION_REST_PARAMETER) \
|| ((JERRY_ES2015_FUNCTION_REST_PARAMETER != 0) && (JERRY_ES2015_FUNCTION_REST_PARAMETER != 1))
# error "Invalid value for JERRY_ES2015_FUNCTION_REST_PARAMETER macro."
#if (JERRY_ESNEXT == 0) \
&& ((JERRY_BUILTIN_DATAVIEW == 1) \
|| (JERRY_BUILTIN_MAP == 1) \
|| (JERRY_BUILTIN_SET == 1) \
|| (JERRY_BUILTIN_WEAKMAP == 1) \
|| (JERRY_BUILTIN_WEAKSET == 1) \
|| (JERRY_BUILTIN_PROMISE == 1) \
|| (JERRY_BUILTIN_PROXY == 1) \
|| (JERRY_BUILTIN_REFLECT == 1) \
|| (JERRY_BUILTIN_TYPEDARRAY == 1))
# error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_xxxxx macro."
#endif
#if !defined (JERRY_ES2015_OBJECT_INITIALIZER) \
|| ((JERRY_ES2015_OBJECT_INITIALIZER != 0) && (JERRY_ES2015_OBJECT_INITIALIZER != 1))
# error "Invalid value for JERRY_ES2015_OBJECT_INITIALIZER 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
#if !defined (JERRY_ES2015_TEMPLATE_STRINGS) \
|| ((JERRY_ES2015_TEMPLATE_STRINGS != 0) && (JERRY_ES2015_TEMPLATE_STRINGS != 1))
# error "Invalid value for JERRY_ES2015_TEMPLATE_STRINGS macro."
#if (JERRY_ESNEXT == 0) && (JERRY_MODULE_SYSTEM == 1)
# error "JERRY_ESNEXT should be enabled too to enable JERRY_MODULE_SYSTEM macro."
#endif
/**
@@ -628,6 +619,9 @@
#if !defined (JERRY_STACK_LIMIT) || (JERRY_STACK_LIMIT < 0)
# error "Invalid value for 'JERRY_STACK_LIMIT' macro."
#endif
#if !defined (JERRY_GC_MARK_LIMIT) || (JERRY_GC_MARK_LIMIT < 0)
# error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro."
#endif
#if !defined (JERRY_LCACHE) \
|| ((JERRY_LCACHE != 0) && (JERRY_LCACHE != 1))
# error "Invalid value for 'JERRY_LCACHE' macro."
@@ -697,7 +691,6 @@
# error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
#endif
#define ENABLED(FEATURE) ((FEATURE) == 1)
#define DISABLED(FEATURE) ((FEATURE) != 1)
@@ -712,4 +705,23 @@
# error "Date does not support float32"
#endif
/**
* Wrap container types into a single guard
*/
#if ENABLED (JERRY_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET) \
|| ENABLED (JERRY_BUILTIN_WEAKMAP) || ENABLED (JERRY_BUILTIN_WEAKSET)
# define JERRY_BUILTIN_CONTAINER 1
#else
# define JERRY_BUILTIN_CONTAINER 0
#endif
/**
* Resource name related types into a single guard
*/
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_MODULE_SYSTEM)
# define JERRY_RESOURCE_NAME 1
#else
# define JERRY_RESOURCE_NAME 0
#endif
#endif /* !JERRYSCRIPT_CONFIG_H */
+36 -51
View File
@@ -131,7 +131,7 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
uint32_t frame_count = 0;
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++;
}
@@ -164,7 +164,7 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
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))
{
frame_ctx_p = frame_ctx_p->prev_context_p;
@@ -183,10 +183,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;
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));
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));
frame_ctx_p = frame_ctx_p->prev_context_p;
@@ -235,7 +235,7 @@ jerry_debugger_send_scope_chain (void)
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
{
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_NON_CLOSURE) != 0)
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_BLOCK) != 0)
{
message_type_p->string[buffer_pos++] = JERRY_DEBUGGER_SCOPE_NON_CLOSURE;
}
@@ -304,7 +304,7 @@ jerry_debugger_get_variable_type (ecma_value_t value) /**< input ecma value */
{
JERRY_ASSERT (ecma_is_value_object (value));
if (ecma_object_get_class_name (ecma_get_object_from_value (value)) == LIT_MAGIC_STRING_ARRAY_UL)
if (ecma_get_object_type (ecma_get_object_from_value (value)) == ECMA_OBJECT_TYPE_ARRAY)
{
ret_value = JERRY_DEBUGGER_VALUE_ARRAY;
}
@@ -458,14 +458,9 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
if (JERRY_UNLIKELY (ecma_get_object_type (binding_obj_p) == ECMA_OBJECT_TYPE_ARRAY))
if (JERRY_UNLIKELY (ecma_op_object_is_fast_array (binding_obj_p)))
{
ecma_extended_object_t *ext_binding_obj_p = (ecma_extended_object_t *) binding_obj_p;
if (ext_binding_obj_p->u.array.is_fast_mode)
{
ecma_fast_array_convert_to_normal (binding_obj_p);
}
ecma_fast_array_convert_to_normal (binding_obj_p);
}
prop_iter_cp = binding_obj_p->u1.property_list_cp;
@@ -508,22 +503,22 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
ecma_deref_ecma_string (prop_name);
ecma_property_value_t prop_value_p = prop_pair_p->values[i];
ecma_value_t property_value;
uint8_t variable_type = jerry_debugger_get_variable_type (prop_value_p.value);
property_value = 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);
if (!jerry_debugger_copy_variables_to_string_message (variable_type,
ecma_get_string_from_value (property_value),
str_p,
message_string_p,
&buffer_pos))
{
ecma_free_value (property_value);
ecma_deref_ecma_string (str_p);
return;
}
ecma_free_value (property_value);
ecma_deref_ecma_string (str_p);
}
}
@@ -560,28 +555,23 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
{
if (eval_string_p[4] != JERRY_DEBUGGER_EVAL_EVAL)
{
JERRY_ASSERT (eval_string_p[4] == JERRY_DEBUGGER_EVAL_THROW || eval_string_p[4] == JERRY_DEBUGGER_EVAL_ABORT);
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
JERRY_CONTEXT (error_value) = result;
/* Stop where the error is caught. */
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
if (eval_string_p[4] == JERRY_DEBUGGER_EVAL_THROW)
{
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
}
else
{
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
}
jcontext_raise_exception (result);
jcontext_set_abort_flag (eval_string_p[4] == JERRY_DEBUGGER_EVAL_ABORT);
return true;
}
if (!ecma_is_value_string (result))
{
ecma_value_t to_string_value = ecma_op_to_string (result);
ecma_string_t *str_p = ecma_op_to_string (result);
ecma_value_t to_string_value = ecma_make_string_value (str_p);
ecma_free_value (result);
result = to_string_value;
}
@@ -618,8 +608,10 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
else
{
/* Primitive type. */
message = ecma_op_to_string (result);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (message));
ecma_string_t *str_p = ecma_op_to_string (result);
JERRY_ASSERT (str_p != NULL);
message = ecma_make_string_value (str_p);
}
ecma_free_value (result);
@@ -1158,7 +1150,6 @@ jerry_debugger_receive (jerry_debugger_uint8_data_t **message_data_p) /**< [out]
}
} /* jerry_debugger_receive */
#undef JERRY_DEBUGGER_CHECK_PACKET_SIZE
/**
@@ -1176,10 +1167,10 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
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));
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));
if (!jerry_debugger_send (sizeof (jerry_debugger_send_breakpoint_hit_t)))
@@ -1222,7 +1213,6 @@ jerry_debugger_send_type (jerry_debugger_header_type_t type) /**< message type *
jerry_debugger_send (sizeof (jerry_debugger_send_type_t));
} /* jerry_debugger_send_type */
/**
* Send the type signal to the client.
*
@@ -1484,34 +1474,31 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
}
}
lit_utf8_size_t size = lit_get_magic_string_size (string_id);
JERRY_ASSERT (size <= 14);
ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
lit_utf8_byte_t data[16];
memcpy (data, lit_get_magic_string_utf8 (string_id), size);
ecma_stringbuilder_append_magic (&builder, string_id);
ecma_property_t *property_p;
property_p = ecma_find_named_property (ecma_get_object_from_value (exception_obj_value),
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
if (property_p == NULL
|| ECMA_PROPERTY_GET_TYPE (*property_p) != ECMA_PROPERTY_TYPE_NAMEDDATA)
if (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_DATA))
{
return ecma_new_ecma_string_from_utf8 (data, size);
return ecma_stringbuilder_finalize (&builder);
}
ecma_property_value_t *prop_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (!ecma_is_value_string (prop_value_p->value))
{
return ecma_new_ecma_string_from_utf8 (data, size);
return ecma_stringbuilder_finalize (&builder);
}
data[size] = LIT_CHAR_COLON;
data[size + 1] = LIT_CHAR_SP;
ecma_stringbuilder_append_byte (&builder, LIT_CHAR_COLON);
ecma_stringbuilder_append_byte (&builder, LIT_CHAR_SP);
ecma_stringbuilder_append (&builder, ecma_get_string_from_value (prop_value_p->value));
return ecma_concat_ecma_strings (ecma_new_ecma_string_from_utf8 (data, size + 2),
ecma_get_string_from_value (prop_value_p->value));
return ecma_stringbuilder_finalize (&builder);
} /* jerry_debugger_exception_object_to_string */
/**
@@ -1521,12 +1508,11 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
* false - otherwise
*/
bool
jerry_debugger_send_exception_string (void)
jerry_debugger_send_exception_string (ecma_value_t exception_value)
{
JERRY_ASSERT (jcontext_has_pending_exception ());
ecma_string_t *string_p = NULL;
ecma_value_t exception_value = JERRY_CONTEXT (error_value);
if (ecma_is_value_object (exception_value))
{
string_p = jerry_debugger_exception_object_to_string (exception_value);
@@ -1543,8 +1529,7 @@ jerry_debugger_send_exception_string (void)
}
else
{
exception_value = ecma_op_to_string (exception_value);
string_p = ecma_get_string_from_value (exception_value);
string_p = ecma_op_to_string (exception_value);
}
ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size);
+1 -1
View File
@@ -484,7 +484,7 @@ bool jerry_debugger_send_string (uint8_t message_type, uint8_t sub_type, const u
bool jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, ecma_compiled_code_t *compiled_code_p);
bool jerry_debugger_send_parse_function (uint32_t line, uint32_t column);
void jerry_debugger_send_memstats (void);
bool jerry_debugger_send_exception_string (void);
bool jerry_debugger_send_exception_string (ecma_value_t exception_value);
#endif /* ENABLED (JERRY_DEBUGGER) */
+40 -12
View File
@@ -71,7 +71,7 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
*
* @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)
{
#if ENABLED (JERRY_MEM_STATS)
@@ -84,7 +84,7 @@ ecma_alloc_object (void)
/**
* 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 */
{
#if ENABLED (JERRY_MEM_STATS)
@@ -99,7 +99,7 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
*
* @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 */
{
#if ENABLED (JERRY_MEM_STATS)
@@ -112,7 +112,7 @@ ecma_alloc_extended_object (size_t size) /**< size of 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 */
size_t size) /**< size of object */
{
@@ -128,7 +128,7 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
*
* @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)
{
#if ENABLED (JERRY_MEM_STATS)
@@ -141,7 +141,7 @@ ecma_alloc_string (void)
/**
* 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 */
{
#if ENABLED (JERRY_MEM_STATS)
@@ -156,7 +156,7 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
*
* @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)
{
#if ENABLED (JERRY_MEM_STATS)
@@ -169,7 +169,7 @@ ecma_alloc_extended_string (void)
/**
* 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 */
{
#if ENABLED (JERRY_MEM_STATS)
@@ -179,12 +179,40 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t));
} /* 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 ENABLED (JERRY_MEM_STATS)
jmem_stats_allocate_string_bytes (sizeof (ecma_external_string_t));
#endif /* ENABLED (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 ENABLED (JERRY_MEM_STATS)
jmem_stats_free_string_bytes (sizeof (ecma_external_string_t));
#endif /* ENABLED (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
*
* @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 */
{
#if ENABLED (JERRY_MEM_STATS)
@@ -197,7 +225,7 @@ ecma_alloc_string_buffer (size_t size) /**< size of string */
/**
* 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 */
size_t size) /**< size of string */
{
@@ -213,7 +241,7 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
*
* @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)
{
#if ENABLED (JERRY_MEM_STATS)
@@ -226,7 +254,7 @@ ecma_alloc_property_pair (void)
/**
* 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 */
{
#if ENABLED (JERRY_MEM_STATS)
+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);
/**
* 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
*
File diff suppressed because it is too large Load Diff
+1
View File
@@ -29,6 +29,7 @@
void ecma_init_gc_info (ecma_object_t *object_p);
void ecma_ref_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_run (void);
void ecma_free_unused_memory (jmem_pressure_t pressure);
File diff suppressed because it is too large Load Diff
+273 -1
View File
@@ -14,6 +14,7 @@
*/
#include "ecma-alloc.h"
#include "ecma-conversion.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
@@ -48,7 +49,7 @@ ecma_new_collection (void)
/**
* 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 */
{
JERRY_ASSERT (collection_p != NULL);
@@ -78,6 +79,46 @@ ecma_collection_free_objects (ecma_collection_t *collection_p) /**< value collec
ecma_collection_destroy (collection_p);
} /* ecma_collection_free_objects */
#if ENABLED (JERRY_ESNEXT)
/**
* 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 */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Free the non-object collection elements and deallocate the collection
*/
@@ -144,6 +185,237 @@ ecma_collection_push_back (ecma_collection_t *collection_p, /**< value collectio
collection_p->buffer_p = buffer_p;
} /* ecma_collection_push_back */
/**
* Reserve space for the given amount of ecma_values in the collection
*/
void
ecma_collection_reserve (ecma_collection_t *collection_p, /**< value collection */
uint32_t count) /**< number of ecma values to reserve */
{
JERRY_ASSERT (collection_p != NULL);
JERRY_ASSERT (UINT32_MAX - count > collection_p->capacity);
const uint32_t new_capacity = collection_p->capacity + count;
const uint32_t old_size = ECMA_COLLECTION_ALLOCATED_SIZE (collection_p->capacity);
const uint32_t new_size = ECMA_COLLECTION_ALLOCATED_SIZE (new_capacity);
ecma_value_t *buffer_p = collection_p->buffer_p;
buffer_p = jmem_heap_realloc_block (buffer_p, old_size, new_size);
collection_p->capacity = new_capacity;
collection_p->buffer_p = buffer_p;
} /* ecma_collection_reserve */
/**
* Append a list of values to the end of the collection
*/
void
ecma_collection_append (ecma_collection_t *collection_p, /**< value collection */
const ecma_value_t *buffer_p, /**< values to append */
uint32_t count) /**< number of ecma values to append */
{
JERRY_ASSERT (collection_p != NULL);
JERRY_ASSERT (collection_p->capacity >= collection_p->item_count);
uint32_t free_count = collection_p->capacity - collection_p->item_count;
if (free_count < count)
{
ecma_collection_reserve (collection_p, count - free_count);
}
memcpy (collection_p->buffer_p + collection_p->item_count, buffer_p, count * sizeof (ecma_value_t));
collection_p->item_count += count;
} /* 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 */
/**
* @}
* @}
+119 -170
View File
@@ -280,17 +280,103 @@ static const uint8_t ecma_uint4_clz[] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0,
*/
#define EPSILON 0.0000001
/**
* ECMA-defined conversion from string to number for different radixes (2, 8, 16).
*
* See also:
* ECMA-262 v5 9.3.1
* ECMA-262 v6 7.1.3.1
*
* @return NaN - if the conversion fails
* converted number - otherwise
*/
static ecma_number_t
ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 string */
const lit_utf8_byte_t *end_p, /**< end of utf-8 string */
uint32_t radix) /**< radix */
{
#if ENABLED (JERRY_ESNEXT)
bool allow_underscore = (radix & ECMA_CONVERSION_ALLOW_UNDERSCORE);
radix &= (uint32_t) ~ECMA_CONVERSION_ALLOW_UNDERSCORE;
#endif /* ENABLED (JERRY_ESNEXT) */
JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);
ecma_number_t num = ECMA_NUMBER_ZERO;
#if ENABLED (JERRY_ESNEXT)
if (radix <= 8)
{
lit_code_point_t upper_limit = LIT_CHAR_0 + radix;
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
{
int32_t digit_value;
if (*iter_p >= LIT_CHAR_0 && *iter_p < upper_limit)
{
digit_value = (*iter_p - LIT_CHAR_0);
}
else
{
return ecma_number_make_nan ();
}
num = num * radix + (ecma_number_t) digit_value;
}
return num;
}
#endif /* ENABLED (JERRY_ESNEXT) */
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
{
int32_t digit_value;
if (*iter_p >= LIT_CHAR_0
&& *iter_p <= LIT_CHAR_9)
{
digit_value = (*iter_p - LIT_CHAR_0);
}
else if (*iter_p >= LIT_CHAR_LOWERCASE_A
&& *iter_p <= LIT_CHAR_LOWERCASE_F)
{
digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A);
}
else if (*iter_p >= LIT_CHAR_UPPERCASE_A
&& *iter_p <= LIT_CHAR_UPPERCASE_F)
{
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
}
#if ENABLED (JERRY_ESNEXT)
else if (*iter_p == LIT_CHAR_UNDERSCORE && allow_underscore)
{
continue;
}
#endif /* ENABLED (JERRY_ESNEXT) */
else
{
return ecma_number_make_nan ();
}
num = num * (ecma_number_t) radix + (ecma_number_t) digit_value;
}
return num;
} /* ecma_utf8_string_to_number_by_radix */
/**
* ECMA-defined conversion of string to Number.
*
* See also:
* ECMA-262 v5, 9.3.1
*
* @return ecma-number
* @return NaN - if the conversion fails
* converted number - otherwise
*/
ecma_number_t
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
lit_utf8_size_t str_size) /**< string size */
lit_utf8_size_t str_size, /**< string size */
uint32_t options) /**< allowing underscore option bit */
{
/* TODO: Check license issues */
@@ -307,46 +393,28 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
return ECMA_NUMBER_ZERO;
}
if ((end_p >= str_p + 2)
&& str_p[0] == LIT_CHAR_0
&& (str_p[1] == LIT_CHAR_LOWERCASE_X
|| str_p[1] == LIT_CHAR_UPPERCASE_X))
if (end_p >= str_p + 2
&& str_p[0] == LIT_CHAR_0)
{
/* Hex literal handling */
str_p += 2;
ecma_number_t num = ECMA_NUMBER_ZERO;
for (const lit_utf8_byte_t * iter_p = str_p;
iter_p <= end_p;
iter_p++)
switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
{
int32_t digit_value;
if (*iter_p >= LIT_CHAR_0
&& *iter_p <= LIT_CHAR_9)
case LIT_CHAR_LOWERCASE_X :
{
digit_value = (*iter_p - LIT_CHAR_0);
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
}
else if (*iter_p >= LIT_CHAR_LOWERCASE_A
&& *iter_p <= LIT_CHAR_LOWERCASE_F)
case LIT_CHAR_LOWERCASE_O :
{
digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A);
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
}
else if (*iter_p >= LIT_CHAR_UPPERCASE_A
&& *iter_p <= LIT_CHAR_UPPERCASE_F)
case LIT_CHAR_LOWERCASE_B :
{
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
}
else
default:
{
return ecma_number_make_nan ();
break;
}
num = num * 16 + (ecma_number_t) digit_value;
}
return num;
}
bool sign = false; /* positive */
@@ -393,6 +461,13 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
digit_seen = true;
digit_value = (*str_p - LIT_CHAR_0);
}
#if ENABLED (JERRY_ESNEXT)
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
{
str_p++;
continue;
}
#endif /* ENABLED (JERRY_ESNEXT) */
else
{
break;
@@ -435,6 +510,11 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
digit_seen = true;
digit_value = (*str_p - LIT_CHAR_0);
}
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
{
str_p++;
continue;
}
else
{
break;
@@ -494,6 +574,13 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
{
digit_value = (*str_p - LIT_CHAR_0);
}
#if ENABLED (JERRY_ESNEXT)
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
{
str_p++;
continue;
}
#endif /* ENABLED (JERRY_ESNEXT) */
else
{
return ecma_number_make_nan ();
@@ -703,9 +790,7 @@ ecma_uint32_to_utf8_string (uint32_t value, /**< value to convert */
uint32_t
ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
{
if (ecma_number_is_nan (num)
|| ecma_number_is_zero (num)
|| ecma_number_is_infinity (num))
if (JERRY_UNLIKELY (ecma_number_is_zero (num) || !ecma_number_is_finite (num)))
{
return 0;
}
@@ -823,142 +908,6 @@ ecma_number_to_decimal (ecma_number_t num, /**< ecma-number */
return ecma_errol0_dtoa ((double) num, out_digits_p, out_decimal_exp_p);
} /* ecma_number_to_decimal */
/**
* Calculate the number of digits from the given double value whithout franction part
*
* @return number of digits
*/
inline static int32_t JERRY_ATTR_ALWAYS_INLINE
ecma_number_of_digits (double val) /**< ecma number */
{
JERRY_ASSERT (fabs (fmod (val, 1.0)) < EPSILON);
int32_t exponent = 0;
while (val >= 1.0)
{
val /= 10.0;
exponent++;
}
return exponent;
} /* ecma_number_of_digits */
/**
* Convert double value to ASCII
*/
inline static void JERRY_ATTR_ALWAYS_INLINE
ecma_double_to_ascii (double val, /**< ecma number */
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
int32_t num_of_digits, /**< number of digits */
int32_t *exp_p) /**< [out] exponent */
{
int32_t char_cnt = 0;
double divider = 10.0;
double prev_residual;
double mod_res = fmod (val, divider);
buffer_p[num_of_digits - 1 - char_cnt++] = (lit_utf8_byte_t) ((int) mod_res + '0');
divider *= 10.0;
prev_residual = mod_res;
while (char_cnt < num_of_digits)
{
mod_res = fmod (val, divider);
double residual = mod_res - prev_residual;
buffer_p[num_of_digits - 1 - char_cnt++] = (lit_utf8_byte_t) ((int) (residual / (divider / 10.0)) + '0');
divider *= 10.0;
prev_residual = mod_res;
}
*exp_p = char_cnt;
} /* ecma_double_to_ascii */
/**
* Double to binary floating-point number conversion
*
* @return number of generated digits
*/
static inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
ecma_double_to_binary_floating_point (double val, /**< ecma number */
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
int32_t *exp_p) /**< [out] exponent */
{
int32_t char_cnt = 0;
double integer_part, fraction_part;
fraction_part = fmod (val, 1.0);
integer_part = floor (val);
int32_t num_of_digits = ecma_number_of_digits (integer_part);
if (fabs (integer_part) < EPSILON)
{
buffer_p[0] = '0';
char_cnt++;
}
else if (num_of_digits <= 16) /* Ensure that integer_part is not rounded */
{
while (integer_part > 0.0)
{
buffer_p[num_of_digits - 1 - char_cnt++] = (lit_utf8_byte_t) ((int) fmod (integer_part, 10.0) + '0');
integer_part = floor (integer_part / 10.0);
}
}
else if (num_of_digits <= 21)
{
ecma_double_to_ascii (integer_part, buffer_p, num_of_digits, &char_cnt);
}
else
{
/* According to ECMA-262 v5, 15.7.4.5, step 7: if x >= 10^21, then execution will continue with
* ToString(x) so in this case no further conversions are required. Number 21 in the else if condition
* above must be kept in sync with the number 21 in ecma_builtin_number_prototype_object_to_fixed
* method, step 7. */
*exp_p = num_of_digits;
return 0;
}
*exp_p = char_cnt;
while (fraction_part > 0 && char_cnt < ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER - 1)
{
fraction_part *= 10;
double tmp = fraction_part;
fraction_part = fmod (fraction_part, 1.0);
integer_part = floor (tmp);
buffer_p[char_cnt++] = (lit_utf8_byte_t) ('0' + (int) integer_part);
}
buffer_p[char_cnt] = '\0';
return (lit_utf8_size_t) (char_cnt - *exp_p);
} /* ecma_double_to_binary_floating_point */
/**
* Perform conversion of ecma-number to equivalent binary floating-point number representation with decimal exponent.
*
* Note:
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
* - parameter out_digits_p corresponds to s, the digits of the number;
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
* - return value corresponds to k, the number of digits.
*
* @return the number of digits
*/
lit_utf8_size_t
ecma_number_to_binary_floating_point_number (ecma_number_t num, /**< ecma-number */
lit_utf8_byte_t *out_digits_p, /**< [out] buffer to fill with digits */
int32_t *out_decimal_exp_p) /**< [out] decimal exponent */
{
JERRY_ASSERT (!ecma_number_is_nan (num));
JERRY_ASSERT (!ecma_number_is_zero (num));
JERRY_ASSERT (!ecma_number_is_infinity (num));
JERRY_ASSERT (!ecma_number_is_negative (num));
return ecma_double_to_binary_floating_point ((double) num, out_digits_p, out_decimal_exp_p);
} /* ecma_number_to_binary_floating_point_number */
/**
* Convert ecma-number to zero-terminated string
*
+1 -1
View File
@@ -133,7 +133,7 @@ ecma_divide_high_prec_by_10 (ecma_high_prec_t *hp_data_p) /**< [in, out] high-pr
*
* @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 */
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
int32_t *exp_p) /**< [out] exponent */
@@ -17,6 +17,7 @@
#include "ecma-array-object.h"
#include "ecma-globals.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-helpers.h"
/** \addtogroup ecma ECMA
@@ -37,10 +38,9 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
void *native_p, /**< native pointer */
void *info_p) /**< native pointer's 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 (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY
&& ((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode)
if (ecma_op_object_is_fast_array (obj_p))
{
ecma_fast_array_convert_to_normal (obj_p);
}
@@ -54,12 +54,9 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
if (property_p == NULL)
{
ecma_property_value_t *value_p;
value_p = ecma_create_named_data_property (obj_p, name_p, ECMA_PROPERTY_CONFIGURABLE_WRITABLE, &property_p);
ECMA_CONVERT_DATA_PROPERTY_TO_INTERNAL_PROPERTY (property_p);
ECMA_CREATE_INTERNAL_PROPERTY (obj_p, name_p, property_p, value_p);
native_pointer_p = jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
}
else
@@ -115,14 +112,13 @@ ecma_native_pointer_t *
ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
void *info_p) /**< native pointer's type info */
{
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY
&& ((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode)
if (ecma_op_object_is_fast_array (obj_p))
{
/* Fast access mode array can not have native pointer properties */
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);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
if (property_p == NULL)
@@ -164,14 +160,13 @@ bool
ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete property from */
void *info_p) /**< native pointer's type info */
{
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_ARRAY
&& ((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode)
if (ecma_op_object_is_fast_array (obj_p))
{
/* Fast access mode array can not have native pointer properties */
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);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
if (property_p == NULL)
@@ -196,7 +191,8 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
if (native_pointer_p->next_p == NULL)
{
/* Only one native pointer property exists, so the property can be deleted as well. */
ecma_op_object_delete (obj_p, name_p, false);
ecma_op_general_object_delete (obj_p, name_p, false);
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
return true;
}
+414 -12
View File
@@ -13,8 +13,10 @@
* limitations under the License.
*/
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include <math.h>
#include "ecma-conversion.h"
#include "lit-char-helpers.h"
/** \addtogroup ecma ECMA
* @{
@@ -46,7 +48,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t),
*
* @return ecma-number with specified sign, biased_exponent and fraction
*/
static ecma_number_t
ecma_number_t
ecma_number_pack (bool sign, /**< sign */
uint32_t biased_exp, /**< biased exponent */
uint64_t fraction) /**< fraction */
@@ -66,7 +68,7 @@ ecma_number_pack (bool sign, /**< sign */
/**
* Unpacking sign, fraction and biased exponent from ecma-number
*/
static void
void
ecma_number_unpack (ecma_number_t num, /**< ecma-number */
bool *sign_p, /**< [out] sign (optional) */
uint32_t *biased_exp_p, /**< [out] biased exponent (optional) */
@@ -109,7 +111,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t),
*
* @return ecma-number with specified sign, biased_exponent and fraction
*/
static ecma_number_t
ecma_number_t
ecma_number_pack (bool sign, /**< sign */
uint32_t biased_exp, /**< biased exponent */
uint64_t fraction) /**< fraction */
@@ -129,7 +131,7 @@ ecma_number_pack (bool sign, /**< sign */
/**
* Unpacking sign, fraction and biased exponent from ecma-number
*/
static void
void
ecma_number_unpack (ecma_number_t num, /**< ecma-number */
bool *sign_p, /**< [out] sign (optional) */
uint32_t *biased_exp_p, /**< [out] biased exponent (optional) */
@@ -280,7 +282,7 @@ ecma_number_make_infinity (bool sign) /**< true - for negative Infinity,
* @return true - if sign bit of ecma-number is set
* false - otherwise
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_number_is_negative (ecma_number_t num) /**< ecma-number */
{
JERRY_ASSERT (!ecma_number_is_nan (num));
@@ -298,8 +300,6 @@ ecma_number_is_negative (ecma_number_t num) /**< ecma-number */
bool
ecma_number_is_zero (ecma_number_t num) /**< ecma-number */
{
JERRY_ASSERT (!ecma_number_is_nan (num));
bool is_zero = (num == ECMA_NUMBER_ZERO);
#ifndef JERRY_NDEBUG
@@ -323,8 +323,6 @@ ecma_number_is_zero (ecma_number_t num) /**< ecma-number */
bool
ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
{
JERRY_ASSERT (!ecma_number_is_nan (num));
uint32_t biased_exp = ecma_number_get_biased_exponent_field (num);
uint64_t fraction = ecma_number_get_fraction_field (num);
@@ -333,6 +331,24 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
&& (fraction == 0));
} /* ecma_number_is_infinity */
/**
* Check if number is finite
*
* @return true - if number is finite
* false - if number is NaN or infinity
*/
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_number_is_finite (ecma_number_t num) /**< ecma-number */
{
#if defined (__GNUC__) || defined (__clang__)
return __builtin_isfinite (num);
#elif defined (_WIN32)
return isfinite (num);
#else
return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num);
#endif /* defined (__GNUC__) || defined (__clang__) */
} /* ecma_number_is_finite */
/**
* Get fraction and exponent of the number
*
@@ -642,12 +658,37 @@ ecma_number_calc_remainder (ecma_number_t left_num, /**< left operand */
return r;
} /* ecma_number_calc_remainder */
/**
* Compute power operation according to the ES standard.
*
* @return x ** y
*/
ecma_number_t
ecma_number_pow (ecma_number_t x, /**< left operand */
ecma_number_t y) /**< right operand */
{
if (ecma_number_is_nan (y) ||
(ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
{
/* Handle differences between ES5.1 and ISO C standards for pow. */
return ecma_number_make_nan ();
}
if (ecma_number_is_zero (y))
{
/* Handle differences between ES5.1 and ISO C standards for pow. */
return (ecma_number_t) 1.0;
}
return DOUBLE_TO_ECMA_NUMBER_T (pow (x, y));
} /* ecma_number_pow */
/**
* ECMA-integer number multiplication.
*
* @return number - result of multiplication.
*/
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
ecma_integer_value_t right_integer) /**< right operand */
{
@@ -667,6 +708,367 @@ ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
return ecma_make_integer_value (left_integer * right_integer);
} /* ecma_integer_multiply */
/**
* The Number object's 'parseInt' routine
*
* See also:
* ECMA-262 v5, 15.1.2.2
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
* string buffer */
lit_utf8_size_t string_buff_size, /**< routine's first argument's
* string buffer's size */
ecma_value_t radix) /**< routine's second argument */
{
if (string_buff_size == 0)
{
return ecma_make_nan_value ();
}
/* 2. Remove leading whitespace. */
const lit_utf8_byte_t *string_end_p = string_buff + string_buff_size;
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, string_end_p);
const lit_utf8_byte_t *string_curr_p = start_p;
const lit_utf8_byte_t *end_p = string_end_p;
if (string_curr_p >= string_end_p)
{
return ecma_make_nan_value ();
}
/* 3. */
int sign = 1;
/* 4. */
ecma_char_t current = lit_cesu8_read_next (&string_curr_p);
if (current == LIT_CHAR_MINUS)
{
sign = -1;
}
/* 5. */
if (current == LIT_CHAR_MINUS || current == LIT_CHAR_PLUS)
{
start_p = string_curr_p;
if (string_curr_p < string_end_p)
{
current = lit_cesu8_read_next (&string_curr_p);
}
}
/* 6. */
ecma_number_t radix_num;
radix = ecma_op_to_number (radix, &radix_num);
if (ECMA_IS_VALUE_ERROR (radix))
{
return ECMA_VALUE_ERROR;
}
int32_t rad = ecma_number_to_int32 (radix_num);
/* 7.*/
bool strip_prefix = true;
/* 8. */
if (rad != 0)
{
/* 8.a */
if (rad < 2 || rad > 36)
{
return ecma_make_nan_value ();
}
/* 8.b */
else if (rad != 16)
{
strip_prefix = false;
}
}
/* 9. */
else
{
rad = 10;
}
/* 10. */
if (strip_prefix
&& ((end_p - start_p) >= 2)
&& (current == LIT_CHAR_0))
{
ecma_char_t next = *string_curr_p;
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
{
/* Skip the 'x' or 'X' characters. */
start_p = ++string_curr_p;
rad = 16;
}
}
/* 11. Check if characters are in [0, Radix - 1]. We also convert them to number values in the process. */
string_curr_p = start_p;
while (string_curr_p < string_end_p)
{
ecma_char_t current_char = *string_curr_p++;
int32_t current_number;
if ((current_char >= LIT_CHAR_LOWERCASE_A && current_char <= LIT_CHAR_LOWERCASE_Z))
{
current_number = current_char - LIT_CHAR_LOWERCASE_A + 10;
}
else if ((current_char >= LIT_CHAR_UPPERCASE_A && current_char <= LIT_CHAR_UPPERCASE_Z))
{
current_number = current_char - LIT_CHAR_UPPERCASE_A + 10;
}
else if (lit_char_is_decimal_digit (current_char))
{
current_number = current_char - LIT_CHAR_0;
}
else
{
/* Not a valid number char, set value to radix so it fails to pass as a valid character. */
current_number = rad;
}
if (!(current_number < rad))
{
end_p = --string_curr_p;
break;
}
}
/* 12. */
if (end_p == start_p)
{
return ecma_make_nan_value ();
}
ecma_number_t value = ECMA_NUMBER_ZERO;
ecma_number_t multiplier = 1.0f;
/* 13. and 14. */
string_curr_p = end_p;
while (string_curr_p > start_p)
{
ecma_char_t current_char = *(--string_curr_p);
ecma_number_t current_number = ECMA_NUMBER_MINUS_ONE;
if ((current_char >= LIT_CHAR_LOWERCASE_A && current_char <= LIT_CHAR_LOWERCASE_Z))
{
current_number = (ecma_number_t) current_char - LIT_CHAR_LOWERCASE_A + 10;
}
else if ((current_char >= LIT_CHAR_UPPERCASE_A && current_char <= LIT_CHAR_UPPERCASE_Z))
{
current_number = (ecma_number_t) current_char - LIT_CHAR_UPPERCASE_A + 10;
}
else
{
JERRY_ASSERT (lit_char_is_decimal_digit (current_char));
current_number = (ecma_number_t) current_char - LIT_CHAR_0;
}
value += current_number * multiplier;
multiplier *= (ecma_number_t) rad;
}
/* 15. */
if (sign < 0)
{
value *= (ecma_number_t) sign;
}
return ecma_make_number_value (value);
} /* ecma_number_parse_int */
/**
* The Number object's 'parseFloat' routine
*
* See also:
* ECMA-262 v5, 15.1.2.2
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
* string buffer */
lit_utf8_size_t string_buff_size) /**< routine's first argument's
* string buffer's size */
{
if (string_buff_size == 0)
{
return ecma_make_nan_value ();
}
/* 2. Remove leading whitespace. */
const lit_utf8_byte_t *str_end_p = string_buff + string_buff_size;
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, str_end_p);
const lit_utf8_byte_t *str_curr_p = start_p;
const lit_utf8_byte_t *end_p = str_end_p;
bool sign = false;
ecma_char_t current;
if (str_curr_p < str_end_p)
{
/* Check if sign is present. */
current = *str_curr_p;
if (current == LIT_CHAR_MINUS)
{
sign = true;
}
if (current == LIT_CHAR_MINUS || current == LIT_CHAR_PLUS)
{
/* Set starting position to be after the sign character. */
start_p = ++str_curr_p;
}
}
/* Check if string is equal to "Infinity". */
const lit_utf8_byte_t *infinity_str_p = lit_get_magic_string_utf8 (LIT_MAGIC_STRING_INFINITY_UL);
const lit_utf8_size_t infinity_length = lit_get_magic_string_size (LIT_MAGIC_STRING_INFINITY_UL);
/* The input string should be at least the length of "Infinity" to be correctly processed as
* the infinity value.
*/
if ((str_end_p - str_curr_p) >= (int) infinity_length
&& memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
{
/* String matched Infinity. */
return ecma_make_number_value (ecma_number_make_infinity (sign));
}
/* Reset to starting position. */
str_curr_p = start_p;
/* String ended after sign character, or was empty after removing leading whitespace. */
if (str_curr_p >= str_end_p)
{
return ecma_make_nan_value ();
}
/* Reset to starting position. */
str_curr_p = start_p;
current = *str_curr_p;
bool has_whole_part = false;
bool has_fraction_part = false;
/* Check digits of whole part. */
if (lit_char_is_decimal_digit (current))
{
has_whole_part = true;
str_curr_p++;
while (str_curr_p < str_end_p)
{
current = *str_curr_p++;
if (!lit_char_is_decimal_digit (current))
{
str_curr_p--;
break;
}
}
}
/* Set end position to the end of whole part. */
end_p = str_curr_p;
if (str_curr_p < str_end_p)
{
current = *str_curr_p;
/* Check decimal point. */
if (current == LIT_CHAR_DOT)
{
str_curr_p++;
if (str_curr_p < str_end_p)
{
current = *str_curr_p;
if (lit_char_is_decimal_digit (current))
{
has_fraction_part = true;
/* Check digits of fractional part. */
while (str_curr_p < str_end_p)
{
current = *str_curr_p++;
if (!lit_char_is_decimal_digit (current))
{
str_curr_p--;
break;
}
}
/* Set end position to end of fraction part. */
end_p = str_curr_p;
}
}
}
}
if (str_curr_p < str_end_p)
{
current = *str_curr_p++;
}
/* Check exponent. */
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E)
&& (has_whole_part || has_fraction_part)
&& str_curr_p < str_end_p)
{
current = *str_curr_p++;
/* Check sign of exponent. */
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS)
&& str_curr_p < str_end_p)
{
current = *str_curr_p++;
}
if (lit_char_is_decimal_digit (current))
{
/* Check digits of exponent part. */
while (str_curr_p < str_end_p)
{
current = *str_curr_p++;
if (!lit_char_is_decimal_digit (current))
{
str_curr_p--;
break;
}
}
/* Set end position to end of exponent part. */
end_p = str_curr_p;
}
}
/* String did not contain a valid number. */
if (start_p == end_p)
{
return ecma_make_nan_value ();
}
/* 5. */
ecma_number_t ret_num = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (end_p - start_p), 0);
if (sign)
{
ret_num *= ECMA_NUMBER_MINUS_ONE;
}
return ecma_make_number_value (ret_num);
} /* ecma_number_parse_float */
/**
* @}
* @}
File diff suppressed because it is too large Load Diff
+240 -70
View File
@@ -14,6 +14,7 @@
*/
#include "ecma-alloc.h"
#include "ecma-exceptions.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
@@ -35,8 +36,12 @@ JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (ecma_value_t),
size_of_jmem_cpointer_t_must_be_less_or_equal_to_the_size_of_ecma_value_t);
JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
size_of_jmem_cpointer_t_must_be_less_or_equal_to_the_size_of_jmem_cpointer_tag_t);
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
/* cppcheck-suppress zerodiv */
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t),
uintptr_t_must_fit_in_ecma_value_t);
@@ -51,6 +56,13 @@ JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
#if ENABLED (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 /* ENABLED (JERRY_BUILTIN_BIGINT) */
/** \addtogroup ecma ECMA
* @{
*
@@ -63,7 +75,7 @@ JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE
*
* @return type field
*/
static inline ecma_type_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
extern inline ecma_type_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_get_value_type_field (ecma_value_t value) /**< ecma value */
{
return value & ECMA_VALUE_TYPE_MASK;
@@ -116,7 +128,7 @@ ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
* @return true - if the value is a direct value,
* 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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT);
@@ -128,7 +140,7 @@ ecma_is_value_direct (ecma_value_t value) /**< ecma value */
* @return true - if the value is a simple value,
* 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 */
{
return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_SIMPLE_VALUE;
@@ -153,7 +165,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,
* 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 */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_EMPTY);
@@ -165,7 +177,7 @@ ecma_is_value_empty (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-undefined simple value,
* 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 */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED);
@@ -177,7 +189,7 @@ ecma_is_value_undefined (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-null simple value,
* 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 */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL);
@@ -189,7 +201,7 @@ ecma_is_value_null (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-true or ecma-false simple values,
* 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 */
{
return ecma_is_value_true (value | (1 << ECMA_DIRECT_SHIFT));
@@ -201,7 +213,7 @@ ecma_is_value_boolean (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-true simple value,
* 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 */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_TRUE);
@@ -213,7 +225,7 @@ ecma_is_value_true (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-false simple value,
* 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 */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_FALSE);
@@ -225,7 +237,7 @@ ecma_is_value_false (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-not-found simple value,
* 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 */
{
return value != ECMA_VALUE_NOT_FOUND;
@@ -237,7 +249,7 @@ ecma_is_value_found (ecma_value_t value) /**< ecma value */
* @return true - if the value contains ecma-array-hole simple value,
* 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 */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_ARRAY_HOLE);
@@ -249,7 +261,7 @@ ecma_is_value_array_hole (ecma_value_t value) /**< ecma value */
* @return true - if the value contains an integer ecma-number value,
* 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 */
{
return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
@@ -261,7 +273,7 @@ ecma_is_value_integer_number (ecma_value_t value) /**< ecma value */
* @return true - if both values contain integer ecma-number values,
* 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_value_t second_value) /**< second ecma value */
{
@@ -277,7 +289,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,
* 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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -311,19 +323,52 @@ ecma_is_value_string (ecma_value_t value) /**< ecma value */
return ((value & (ECMA_VALUE_TYPE_MASK - 0x4)) == ECMA_TYPE_STRING);
} /* ecma_is_value_string */
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
/**
* Check if the value is symbol.
*
* @return true - if the value contains symbol value,
* 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 */
{
#if ENABLED (JERRY_ESNEXT)
return (ecma_get_value_type_field (value) == ECMA_TYPE_SYMBOL);
#else /* ENABLED (JERRY_ESNEXT) */
JERRY_UNUSED (value);
return false;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_is_value_symbol */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
/**
* 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 ENABLED (JERRY_BUILTIN_BIGINT)
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
#else /* !ENABLED (JERRY_BUILTIN_BIGINT) */
JERRY_UNUSED (value);
return false;
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
} /* ecma_is_value_bigint */
/**
* Check if the value can be property name.
@@ -331,14 +376,14 @@ ecma_is_value_symbol (ecma_value_t value) /**< ecma value */
* @return true - if the value can be property name value,
* 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 */
{
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
return ecma_is_value_string (value) || ecma_is_value_symbol (value);
#else /* !ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#else /* !ENABLED (JERRY_ESNEXT) */
return ecma_is_value_string (value);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_is_value_prop_name */
/**
@@ -347,7 +392,7 @@ ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */
* @return true - if the value contains direct ecma-string value,
* 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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT_STRING);
@@ -359,7 +404,7 @@ ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
* @return true - if the value contains non-direct ecma-string value,
* 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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
@@ -371,7 +416,7 @@ ecma_is_value_non_direct_string (ecma_value_t value) /**< ecma value */
* @return true - if the value contains object value,
* 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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
@@ -383,7 +428,7 @@ ecma_is_value_object (ecma_value_t value) /**< ecma value */
* @return true - if the value contains an error reference,
* 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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
@@ -401,16 +446,56 @@ ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
|| ecma_is_value_boolean (value)
|| ecma_is_value_number (value)
|| ecma_is_value_string (value)
|| ECMA_ASSERT_VALUE_IS_SYMBOL (value)
|| ecma_is_value_bigint (value)
|| ecma_is_value_symbol (value)
|| ecma_is_value_object (value));
} /* ecma_check_value_type_is_spec_defined */
/**
* Checks if the given argument is an array or not.
*
* @return ECMA_VALUE_ERROR- if the operation fails
* ECMA_VALUE_{TRUE/FALSE} - depends on whether 'arg' is an array object
*/
ecma_value_t
ecma_is_value_array (ecma_value_t arg) /**< argument */
{
if (!ecma_is_value_object (arg))
{
return ECMA_VALUE_FALSE;
}
ecma_object_t *arg_obj_p = ecma_get_object_from_value (arg);
if (ecma_get_object_type (arg_obj_p) == ECMA_OBJECT_TYPE_ARRAY)
{
return ECMA_VALUE_TRUE;
}
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_OBJECT_IS_PROXY (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)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot perform 'IsArray' on the given proxy "
"because handler is null"));
}
return ecma_is_value_array (proxy_obj_p->target);
}
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
return ECMA_VALUE_FALSE;
} /* ecma_is_value_array */
/**
* Creates an ecma value from the given raw boolean.
*
* @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 */
{
return boolean_value ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
@@ -424,7 +509,7 @@ ecma_make_boolean_value (bool boolean_value) /**< raw bool value from which the
*
* @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 */
{
JERRY_ASSERT (ECMA_IS_INTEGER_NUMBER (integer_value));
@@ -486,6 +571,22 @@ ecma_is_number_equal_to_positive_zero (ecma_number_t ecma_number) /**< number */
#endif /* !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
} /* 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
*
@@ -543,13 +644,13 @@ ecma_make_uint32_value (uint32_t uint32_number) /**< uint32 number to be encoded
*
* @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 */
{
JERRY_ASSERT (ecma_string_p != NULL);
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
JERRY_ASSERT (!ecma_prop_name_is_symbol ((ecma_string_t *) ecma_string_p));
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
if ((((uintptr_t) ecma_string_p) & ECMA_VALUE_TYPE_MASK) != 0)
{
@@ -559,13 +660,13 @@ 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;
} /* ecma_make_string_value */
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
/**
* Symbol value constructor
*
* @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 */
{
JERRY_ASSERT (ecma_symbol_p != NULL);
@@ -573,24 +674,24 @@ 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;
} /* ecma_make_symbol_value */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Property-name value constructor
*
* @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 */
{
JERRY_ASSERT (ecma_prop_name_p != NULL);
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
if (ecma_prop_name_is_symbol ((ecma_string_t *) ecma_prop_name_p))
{
return ecma_make_symbol_value (ecma_prop_name_p);
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
return ecma_make_string_value (ecma_prop_name_p);
} /* ecma_make_prop_name_value */
@@ -600,7 +701,7 @@ ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property
*
* @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 */
{
return (ecma_value_t) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC, (uintptr_t) id);
@@ -611,7 +712,7 @@ ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */
*
* @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 */
{
JERRY_ASSERT (object_p != NULL);
@@ -624,20 +725,25 @@ ecma_make_object_value (const ecma_object_t *object_p) /**< object to reference
*
* @return ecma-value representation of the Error reference
*/
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 */
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
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 ENABLED (JERRY_BUILTIN_BIGINT)
JERRY_ASSERT (primitve_p != ECMA_BIGINT_POINTER_TO_ZERO);
#endif /* ENABLED (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;
} /* ecma_make_error_reference_value */
return ecma_pointer_to_ecma_value (primitve_p) | type;
} /* ecma_make_extended_primitive_value */
/**
* Get integer value from an integer ecma 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 */
{
JERRY_ASSERT (ecma_is_value_integer_number (value));
@@ -650,7 +756,7 @@ ecma_get_integer_from_value (ecma_value_t value) /**< ecma 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 */
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -663,7 +769,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma 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 */
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -692,7 +798,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
*
* @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 */
{
JERRY_ASSERT (ecma_is_value_string (value));
@@ -705,27 +811,27 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_string_from_value */
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
/**
* Get pointer to ecma-string from ecma value
*
* @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 */
{
JERRY_ASSERT (ecma_is_value_symbol (value));
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_symbol_from_value */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Get pointer to a property name from ecma value
*
* @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 */
{
JERRY_ASSERT (ecma_is_value_prop_name (value));
@@ -743,7 +849,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
*
* @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 */
{
JERRY_ASSERT (ecma_is_value_object (value));
@@ -756,20 +862,24 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
*
* @return the pointer
*/
inline ecma_error_reference_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_error_reference_from_value (ecma_value_t value) /**< ecma value */
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
#if ENABLED (JERRY_BUILTIN_BIGINT)
JERRY_ASSERT (value != ECMA_BIGINT_ZERO);
#endif /* ENABLED (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);
} /* ecma_get_error_reference_from_value */
return (ecma_extended_primitive_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_extended_primitive_from_value */
/**
* Invert a boolean 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 */
{
JERRY_ASSERT (ecma_is_value_boolean (value));
@@ -798,13 +908,23 @@ ecma_copy_value (ecma_value_t value) /**< value description */
ecma_ref_ecma_string (ecma_get_string_from_value (value));
return value;
}
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
case ECMA_TYPE_SYMBOL:
{
ecma_ref_ecma_string (ecma_get_symbol_from_value (value));
return value;
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_BIGINT)
case ECMA_TYPE_BIGINT:
{
if (value != ECMA_BIGINT_ZERO)
{
ecma_ref_extended_primitive (ecma_get_extended_primitive_from_value (value));
}
return value;
}
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
case ECMA_TYPE_OBJECT:
{
ecma_ref_object (ecma_get_object_from_value (value));
@@ -831,7 +951,7 @@ ecma_copy_value (ecma_value_t value) /**< value description */
*
* @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 */
{
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value);
@@ -842,10 +962,10 @@ ecma_fast_copy_value (ecma_value_t value) /**< value description */
*
* @return copy of the given value
*/
ecma_value_t
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */
{
if (ecma_get_value_type_field (value) != ECMA_TYPE_OBJECT)
if (!ecma_is_value_object (value))
{
return ecma_copy_value (value);
}
@@ -853,6 +973,30 @@ ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */
return value;
} /* ecma_copy_value_if_not_object */
/**
* Increase reference counter of a value if it is an object.
*/
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_ref_if_object (ecma_value_t value) /**< value description */
{
if (ecma_is_value_object (value))
{
ecma_ref_object (ecma_get_object_from_value (value));
}
} /* ecma_ref_if_object */
/**
* Decrease reference counter of a value if it is an object.
*/
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_deref_if_object (ecma_value_t value) /**< value description */
{
if (ecma_is_value_object (value))
{
ecma_deref_object (ecma_get_object_from_value (value));
}
} /* ecma_deref_if_object */
/**
* Assign a new value to an ecma-value
*
@@ -995,19 +1139,30 @@ ecma_free_value (ecma_value_t value) /**< value description */
ecma_deref_ecma_string (string_p);
break;
}
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
case ECMA_TYPE_SYMBOL:
{
ecma_deref_ecma_string (ecma_get_symbol_from_value (value));
break;
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
case ECMA_TYPE_OBJECT:
{
ecma_deref_object (ecma_get_object_from_value (value));
break;
}
#if ENABLED (JERRY_BUILTIN_BIGINT)
case ECMA_TYPE_BIGINT:
{
if (value != ECMA_BIGINT_ZERO)
{
ecma_deref_bigint (ecma_get_extended_primitive_from_value (value));
}
break;
}
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
default:
{
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT
@@ -1028,7 +1183,7 @@ ecma_free_value (ecma_value_t value) /**< value description */
* It also increases the binary size so it is recommended for
* 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 */
{
if (ecma_get_value_type_field (value) != ECMA_TYPE_DIRECT)
@@ -1049,10 +1204,19 @@ ecma_free_value_if_not_object (ecma_value_t value) /**< value description */
}
} /* 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
*/
inline void JERRY_ATTR_ALWAYS_INLINE
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_free_number (ecma_value_t value) /**< value description */
{
JERRY_ASSERT (ecma_is_value_number (value));
@@ -1101,12 +1265,18 @@ ecma_get_typeof_lit_id (ecma_value_t value) /**< input ecma value */
{
ret_value = LIT_MAGIC_STRING_STRING;
}
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
else if (ecma_is_value_symbol (value))
{
ret_value = LIT_MAGIC_STRING_SYMBOL;
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_BIGINT)
else if (ecma_is_value_bigint (value))
{
ret_value = LIT_MAGIC_STRING_BIGINT;
}
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
else
{
JERRY_ASSERT (ecma_is_value_object (value));
+354 -187
View File
@@ -14,6 +14,7 @@
*/
#include "ecma-alloc.h"
#include "ecma-array-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
@@ -36,9 +37,6 @@
* @{
*/
JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_MASK >= ECMA_PROPERTY_TYPE__MAX,
ecma_property_types_must_be_lower_than_the_container_mask);
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK >= ECMA_OBJECT_TYPE__MAX - 1,
ecma_object_types_must_be_lower_than_the_container_mask);
@@ -54,11 +52,11 @@ JERRY_STATIC_ASSERT (ECMA_OBJECT_FLAG_EXTENSIBLE == (ECMA_OBJECT_FLAG_BUILT_IN_O
JERRY_STATIC_ASSERT (ECMA_OBJECT_REF_ONE == (ECMA_OBJECT_FLAG_EXTENSIBLE << 1),
ecma_object_ref_one_must_follow_the_extensible_flag);
JERRY_STATIC_ASSERT ((ECMA_OBJECT_MAX_REF | (ECMA_OBJECT_REF_ONE - 1)) == UINT16_MAX,
ecma_object_max_ref_does_not_fill_the_remaining_bits);
JERRY_STATIC_ASSERT (((ECMA_OBJECT_MAX_REF + ECMA_OBJECT_REF_ONE) | (ECMA_OBJECT_REF_ONE - 1)) == UINT16_MAX,
ecma_object_max_ref_does_not_fill_the_remaining_bits);
JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_DELETED == (ECMA_DIRECT_STRING_MAGIC << ECMA_PROPERTY_NAME_TYPE_SHIFT),
ecma_property_type_deleted_must_have_magic_string_name_type);
JERRY_STATIC_ASSERT (ECMA_PROPERTY_FLAGS_MASK == ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
ecma_property_flags_mask_must_use_the_configurable_enumerable_writable_flags);
/**
* Create an object with specified prototype object
@@ -138,12 +136,12 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
ecma_object_t *binding_obj_p, /**< binding object */
ecma_lexical_environment_type_t type) /**< type of the new lexical environment */
{
#if ENABLED (JERRY_ES2015_CLASS)
#if ENABLED (JERRY_ESNEXT)
JERRY_ASSERT (type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND
|| type == ECMA_LEXICAL_ENVIRONMENT_SUPER_OBJECT_BOUND);
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|| type == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND);
#else /* !ENABLED (JERRY_ESNEXT) */
JERRY_ASSERT (type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#endif /* ENABLED (JERRY_ESNEXT) */
JERRY_ASSERT (binding_obj_p != NULL
&& !ecma_is_lexical_environment (binding_obj_p));
@@ -168,7 +166,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
* @return true - if object is a lexical environment
* false - otherwise
*/
inline bool JERRY_ATTR_PURE
extern inline bool JERRY_ATTR_PURE
ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */
{
JERRY_ASSERT (object_p != NULL);
@@ -178,47 +176,24 @@ ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexic
return full_type >= (ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_TYPE_START);
} /* ecma_is_lexical_environment */
/**
* Get value of [[Extensible]] object's internal property.
*
* @return true - if object is extensible
* false - otherwise
*/
inline bool JERRY_ATTR_PURE
ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
return (object_p->type_flags_refs & ECMA_OBJECT_FLAG_EXTENSIBLE) != 0;
} /* ecma_get_object_extensible */
/**
* Set value of [[Extensible]] object's internal property.
*/
inline void
ecma_set_object_extensible (ecma_object_t *object_p, /**< object */
bool is_extensible) /**< value of [[Extensible]] */
extern inline void
ecma_op_ordinary_object_set_extensible (ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
if (is_extensible)
{
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_FLAG_EXTENSIBLE);
}
else
{
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs & ~ECMA_OBJECT_FLAG_EXTENSIBLE);
}
} /* ecma_set_object_extensible */
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_FLAG_EXTENSIBLE);
} /* ecma_op_ordinary_object_set_extensible */
/**
* Get object's internal implementation-defined type.
*
* @return type of the object (ecma_object_type_t)
*/
inline ecma_object_type_t JERRY_ATTR_PURE
extern inline ecma_object_type_t JERRY_ATTR_PURE
ecma_get_object_type (const ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT (object_p != NULL);
@@ -233,7 +208,7 @@ ecma_get_object_type (const ecma_object_t *object_p) /**< object */
* @return true - if object is a built-in object
* false - otherwise
*/
inline bool JERRY_ATTR_PURE
extern inline bool JERRY_ATTR_PURE
ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT (object_p != NULL);
@@ -245,7 +220,7 @@ ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
/**
* Set flag indicating whether the object is a built-in object
*/
inline void
extern inline void
ecma_set_object_is_builtin (ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT (object_p != NULL);
@@ -261,7 +236,7 @@ ecma_set_object_is_builtin (ecma_object_t *object_p) /**< object */
*
* @return the ID of the built-in
*/
inline uint8_t
extern inline uint8_t
ecma_get_object_builtin_id (ecma_object_t *object_p) /**< object */
{
if (!ecma_get_object_is_builtin (object_p))
@@ -272,7 +247,7 @@ ecma_get_object_builtin_id (ecma_object_t *object_p) /**< object */
ecma_built_in_props_t *built_in_props_p;
ecma_object_type_t object_type = ecma_get_object_type (object_p);
if (object_type == ECMA_OBJECT_TYPE_CLASS || object_type == ECMA_OBJECT_TYPE_ARRAY)
if (ECMA_BUILTIN_IS_EXTENDED_BUILT_IN (object_type))
{
built_in_props_p = &((ecma_extended_built_in_object_t *) object_p)->built_in;
}
@@ -289,7 +264,7 @@ ecma_get_object_builtin_id (ecma_object_t *object_p) /**< object */
*
* @return type of the lexical environment (ecma_lexical_environment_type_t)
*/
inline ecma_lexical_environment_type_t JERRY_ATTR_PURE
extern inline ecma_lexical_environment_type_t JERRY_ATTR_PURE
ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */
{
JERRY_ASSERT (object_p != NULL);
@@ -303,21 +278,91 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
*
* @return pointer to ecma object
*/
inline ecma_object_t *JERRY_ATTR_PURE
extern inline ecma_object_t *JERRY_ATTR_PURE
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
#if ENABLED (JERRY_ES2015_CLASS)
#if ENABLED (JERRY_ESNEXT)
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_SUPER_OBJECT_BOUND);
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND);
#else /* !ENABLED (JERRY_ESNEXT) */
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
#endif /* ENABLED (JERRY_ES2015_CLASS) */
#endif /* ENABLED (JERRY_ESNEXT) */
return ECMA_GET_NON_NULL_POINTER (ecma_object_t, object_p->u1.bound_object_cp);
} /* ecma_get_lex_env_binding_object */
/**
* Create a new lexical environment with the same property list as the passed lexical environment
*
* @return pointer to the newly created lexical environment
*/
ecma_object_t *
ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, /**< declarative lexical environment */
bool copy_values) /**< copy property values as well */
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
ecma_object_t *outer_lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
ecma_object_t *new_lex_env_p = ecma_create_decl_lex_env (outer_lex_env_p);
jmem_cpointer_t prop_iter_cp = lex_env_p->u1.property_list_cp;
JERRY_ASSERT (prop_iter_cp != JMEM_CP_NULL);
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
prop_iter_cp);
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{
prop_iter_cp = prop_iter_p->next_property_cp;
}
JERRY_ASSERT (prop_iter_cp != JMEM_CP_NULL);
do
{
prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
{
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
{
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW_DATA (prop_iter_p->types[i]));
uint8_t prop_attributes = (uint8_t) (prop_iter_p->types[i] & ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
ecma_string_t *name_p = ecma_string_from_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i]);
ecma_property_value_t *property_value_p;
property_value_p = ecma_create_named_data_property (new_lex_env_p, name_p, prop_attributes, NULL);
ecma_deref_ecma_string (name_p);
JERRY_ASSERT (property_value_p->value == ECMA_VALUE_UNDEFINED);
if (copy_values)
{
property_value_p->value = ecma_copy_value_if_not_object (prop_pair_p->values[i].value);
}
else
{
property_value_p->value = ECMA_VALUE_UNINITIALIZED;
}
}
}
prop_iter_cp = prop_iter_p->next_property_cp;
}
while (prop_iter_cp != JMEM_CP_NULL);
ecma_deref_object (lex_env_p);
return new_lex_env_p;
} /* ecma_clone_decl_lexical_environment */
/**
* Create a property in an object and link it into
* the object's properties' linked-list (at start of the list).
@@ -473,12 +518,11 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
{
JERRY_ASSERT (object_p != NULL && name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|| ecma_get_object_type (object_p) != ECMA_OBJECT_TYPE_ARRAY
|| !((ecma_extended_object_t *) object_p)->u.array.is_fast_mode);
|| !ecma_op_object_is_fast_array (object_p));
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA | prop_attributes;
uint8_t type_and_flags = ECMA_PROPERTY_FLAG_DATA | prop_attributes;
ecma_property_value_t value;
value.value = ECMA_VALUE_UNDEFINED;
@@ -502,12 +546,11 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
{
JERRY_ASSERT (object_p != NULL && name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|| ecma_get_object_type (object_p) != ECMA_OBJECT_TYPE_ARRAY
|| !((ecma_extended_object_t *) object_p)->u.array.is_fast_mode);
|| !ecma_op_object_is_fast_array (object_p));
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE) == 0);
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR | prop_attributes;
uint8_t type_and_flags = prop_attributes;
ecma_property_value_t value;
#if ENABLED (JERRY_CPOINTER_32_BIT)
@@ -525,7 +568,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
} /* ecma_create_named_accessor_property */
/**
* Find named data property or named access property in specified object.
* Find named data property or named accessor property in a specified object.
*
* @return pointer to the property, if it is found,
* NULL - otherwise.
@@ -537,8 +580,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
JERRY_ASSERT (obj_p != NULL);
JERRY_ASSERT (name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|| ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_ARRAY
|| !((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode);
|| !ecma_op_object_is_fast_array (obj_p));
ecma_property_t *property_p = NULL;
@@ -696,19 +738,20 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
JERRY_ASSERT (obj_p != NULL);
JERRY_ASSERT (name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|| ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_ARRAY
|| !((ecma_extended_object_t *) obj_p)->u.array.is_fast_mode);
|| !ecma_op_object_is_fast_array (obj_p));
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
JERRY_ASSERT (property_p != NULL
&& ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_IS_RAW_DATA (*property_p));
return ECMA_PROPERTY_VALUE_PTR (property_p);
} /* ecma_get_named_data_property */
/**
* Free property values and change their type to deleted.
*
* Note:
* internal properties are not supported
*/
void
ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to */
@@ -716,33 +759,20 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
ecma_property_t *property_p) /**< property */
{
JERRY_ASSERT (object_p != NULL && property_p != NULL);
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
switch (ECMA_PROPERTY_GET_TYPE (*property_p))
if (*property_p & ECMA_PROPERTY_FLAG_DATA)
{
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
}
else
{
case ECMA_PROPERTY_TYPE_NAMEDDATA:
{
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
break;
}
case ECMA_PROPERTY_TYPE_NAMEDACCESSOR:
{
#if ENABLED (JERRY_CPOINTER_32_BIT)
ecma_getter_setter_pointers_t *getter_setter_pair_p;
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
ECMA_PROPERTY_VALUE_PTR (property_p)->getter_setter_pair_cp);
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
ecma_getter_setter_pointers_t *getter_setter_pair_p;
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
ECMA_PROPERTY_VALUE_PTR (property_p)->getter_setter_pair_cp);
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
#endif /* ENABLED (JERRY_CPOINTER_32_BIT) */
break;
}
default:
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
/* Must be a native pointer. */
JERRY_ASSERT (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC
&& name_cp >= LIT_FIRST_INTERNAL_MAGIC_STRING);
break;
}
}
#if ENABLED (JERRY_LCACHE)
@@ -802,7 +832,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
{
if ((prop_pair_p->values + i) == prop_value_p)
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (cur_prop_p->types[i]) != ECMA_PROPERTY_TYPE_SPECIAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (cur_prop_p->types[i]));
#if ENABLED (JERRY_PROPRETY_HASHMAP)
if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP)
@@ -867,7 +897,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
static void
ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ecma-object */
const ecma_property_value_t *prop_value_p, /**< property value */
ecma_property_types_t type) /**< expected property type */
bool is_data) /**< property should be data property */
{
#ifndef JERRY_NDEBUG
jmem_cpointer_t prop_iter_cp = object_p->u1.property_list_cp;
@@ -892,7 +922,7 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
{
if ((prop_pair_p->values + i) == prop_value_p)
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_pair_p->header.types[i]) == type);
JERRY_ASSERT (is_data == ((prop_pair_p->header.types[i] & ECMA_PROPERTY_FLAG_DATA) != 0));
return;
}
}
@@ -902,7 +932,7 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
#else /* JERRY_NDEBUG */
JERRY_UNUSED (object_p);
JERRY_UNUSED (prop_value_p);
JERRY_UNUSED (type);
JERRY_UNUSED (is_data);
#endif /* !JERRY_NDEBUG */
} /* ecma_assert_object_contains_the_property */
@@ -912,12 +942,12 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
* Note:
* value previously stored in the property is freed
*/
inline void JERRY_ATTR_ALWAYS_INLINE
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
ecma_property_value_t *prop_value_p, /**< property value reference */
ecma_value_t value) /**< value to assign */
{
ecma_assert_object_contains_the_property (obj_p, prop_value_p, ECMA_PROPERTY_TYPE_NAMEDDATA);
ecma_assert_object_contains_the_property (obj_p, prop_value_p, true);
ecma_value_assign_value (&prop_value_p->value, value);
} /* ecma_named_data_property_assign_value */
@@ -945,7 +975,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
ecma_property_value_t *prop_value_p, /**< property value reference */
ecma_object_t *getter_p) /**< getter object */
{
ecma_assert_object_contains_the_property (object_p, prop_value_p, ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
ecma_assert_object_contains_the_property (object_p, prop_value_p, false);
#if ENABLED (JERRY_CPOINTER_32_BIT)
ecma_getter_setter_pointers_t *getter_setter_pair_p;
@@ -965,7 +995,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
ecma_property_value_t *prop_value_p, /**< property value reference */
ecma_object_t *setter_p) /**< setter object */
{
ecma_assert_object_contains_the_property (object_p, prop_value_p, ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
ecma_assert_object_contains_the_property (object_p, prop_value_p, false);
#if ENABLED (JERRY_CPOINTER_32_BIT)
ecma_getter_setter_pointers_t *getter_setter_pair_p;
@@ -983,11 +1013,10 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
* @return true - property is writable,
* false - otherwise
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_property_writable (ecma_property_t property) /**< property */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL);
JERRY_ASSERT (property & ECMA_PROPERTY_FLAG_DATA);
return (property & ECMA_PROPERTY_FLAG_WRITABLE) != 0;
} /* ecma_is_property_writable */
@@ -999,7 +1028,7 @@ void
ecma_set_property_writable_attr (ecma_property_t *property_p, /**< [in,out] property */
bool is_writable) /**< new value for writable flag */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW_DATA (*property_p));
if (is_writable)
{
@@ -1017,12 +1046,10 @@ ecma_set_property_writable_attr (ecma_property_t *property_p, /**< [in,out] prop
* @return true - property is enumerable,
* false - otherwise
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_property_enumerable (ecma_property_t property) /**< property */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (property));
return (property & ECMA_PROPERTY_FLAG_ENUMERABLE) != 0;
} /* ecma_is_property_enumerable */
@@ -1034,8 +1061,7 @@ void
ecma_set_property_enumerable_attr (ecma_property_t *property_p, /**< [in,out] property */
bool is_enumerable) /**< new value for enumerable flag */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
if (is_enumerable)
{
@@ -1053,12 +1079,10 @@ ecma_set_property_enumerable_attr (ecma_property_t *property_p, /**< [in,out] pr
* @return true - property is configurable,
* false - otherwise
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_property_configurable (ecma_property_t property) /**< property */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (property));
return (property & ECMA_PROPERTY_FLAG_CONFIGURABLE) != 0;
} /* ecma_is_property_configurable */
@@ -1070,8 +1094,7 @@ void
ecma_set_property_configurable_attr (ecma_property_t *property_p, /**< [in,out] property */
bool is_configurable) /**< new value for configurable flag */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
if (is_configurable)
{
@@ -1090,12 +1113,10 @@ ecma_set_property_configurable_attr (ecma_property_t *property_p, /**< [in,out]
*
* @return true / false
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_property_lcached (ecma_property_t *property_p) /**< property */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
return (*property_p & ECMA_PROPERTY_FLAG_LCACHED) != 0;
} /* ecma_is_property_lcached */
@@ -1103,13 +1124,11 @@ ecma_is_property_lcached (ecma_property_t *property_p) /**< property */
/**
* Set value of flag indicating whether the property is registered in LCache
*/
inline void JERRY_ATTR_ALWAYS_INLINE
extern inline void JERRY_ATTR_ALWAYS_INLINE
ecma_set_property_lcached (ecma_property_t *property_p, /**< property */
bool is_lcached) /**< new value for lcached flag */
{
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
if (is_lcached)
{
@@ -1172,9 +1191,69 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
/**
* The size of error reference must be 8 bytes to use jmem_pools_alloc().
*/
JERRY_STATIC_ASSERT (sizeof (ecma_error_reference_t) == 8,
JERRY_STATIC_ASSERT (sizeof (ecma_extended_primitive_t) == 8,
ecma_error_reference_size_must_be_8_bytes);
/**
* Increase ref count of an extended primitve value.
*/
void
ecma_ref_extended_primitive (ecma_extended_primitive_t *primitve_p) /**< extended primitve value */
{
if (JERRY_LIKELY (primitve_p->refs_and_type < ECMA_EXTENDED_PRIMITIVE_MAX_REF))
{
primitve_p->refs_and_type += ECMA_EXTENDED_PRIMITIVE_REF_ONE;
}
else
{
jerry_fatal (ERR_REF_COUNT_LIMIT);
}
} /* ecma_ref_extended_primitive */
/**
* Decrease ref count of an error reference.
*/
void
ecma_deref_error_reference (ecma_extended_primitive_t *error_ref_p) /**< error reference */
{
JERRY_ASSERT (error_ref_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE);
error_ref_p->refs_and_type -= ECMA_EXTENDED_PRIMITIVE_REF_ONE;
if (error_ref_p->refs_and_type < ECMA_EXTENDED_PRIMITIVE_REF_ONE)
{
ecma_free_value (error_ref_p->u.value);
jmem_pools_free (error_ref_p, sizeof (ecma_extended_primitive_t));
}
} /* ecma_deref_error_reference */
#if ENABLED (JERRY_BUILTIN_BIGINT)
/**
* Decrease ref count of a bigint value.
*/
void
ecma_deref_bigint (ecma_extended_primitive_t *bigint_p) /**< bigint value */
{
JERRY_ASSERT (bigint_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE);
bigint_p->refs_and_type -= ECMA_EXTENDED_PRIMITIVE_REF_ONE;
if (bigint_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE)
{
return;
}
uint32_t size = ECMA_BIGINT_GET_SIZE (bigint_p);
JERRY_ASSERT (size > 0);
size_t mem_size = ECMA_BIGINT_GET_BYTE_SIZE (size) + sizeof (ecma_extended_primitive_t);
jmem_heap_free_block (bigint_p, mem_size);
} /* ecma_deref_bigint */
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
/**
* Create an error reference from a given value.
*
@@ -1187,11 +1266,13 @@ ecma_value_t
ecma_create_error_reference (ecma_value_t value, /**< referenced value */
bool is_exception) /**< error reference is an exception */
{
ecma_error_reference_t *error_ref_p = (ecma_error_reference_t *) jmem_pools_alloc (sizeof (ecma_error_reference_t));
ecma_extended_primitive_t *error_ref_p;
error_ref_p = (ecma_extended_primitive_t *) jmem_pools_alloc (sizeof (ecma_extended_primitive_t));
error_ref_p->refs_and_flags = ECMA_ERROR_REF_ONE | (is_exception ? 0 : ECMA_ERROR_REF_ABORT);
error_ref_p->value = value;
return ecma_make_error_reference_value (error_ref_p);
error_ref_p->refs_and_type = (ECMA_EXTENDED_PRIMITIVE_REF_ONE
| (is_exception ? ECMA_EXTENDED_PRIMITIVE_ERROR : ECMA_EXTENDED_PRIMITIVE_ABORT));
error_ref_p->u.value = value;
return ecma_make_extended_primitive_value (error_ref_p, ECMA_TYPE_ERROR);
} /* ecma_create_error_reference */
/**
@@ -1202,8 +1283,13 @@ ecma_create_error_reference (ecma_value_t value, /**< referenced value */
ecma_value_t
ecma_create_error_reference_from_context (void)
{
return ecma_create_error_reference (JERRY_CONTEXT (error_value),
(JERRY_CONTEXT (status_flags) & ECMA_STATUS_EXCEPTION) != 0);
bool is_abort = jcontext_has_pending_abort ();
if (is_abort)
{
jcontext_set_abort_flag (false);
}
return ecma_create_error_reference (jcontext_take_exception (), !is_abort);
} /* ecma_create_error_reference_from_context */
/**
@@ -1214,80 +1300,42 @@ ecma_create_error_reference_from_context (void)
*
* @return error reference value
*/
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_create_error_object_reference (ecma_object_t *object_p) /**< referenced object */
{
return ecma_create_error_reference (ecma_make_object_value (object_p), true);
} /* ecma_create_error_object_reference */
/**
* Increase ref count of an error reference.
* Raise error from the given error reference.
*
* Note: the error reference's ref count is also decreased
*/
void
ecma_ref_error_reference (ecma_error_reference_t *error_ref_p) /**< error reference */
ecma_raise_error_from_error_reference (ecma_value_t value) /**< error reference */
{
if (JERRY_LIKELY (error_ref_p->refs_and_flags < ECMA_ERROR_MAX_REF))
JERRY_ASSERT (!jcontext_has_pending_exception () && !jcontext_has_pending_abort ());
ecma_extended_primitive_t *error_ref_p = ecma_get_extended_primitive_from_value (value);
JERRY_ASSERT (error_ref_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE);
ecma_value_t referenced_value = error_ref_p->u.value;
jcontext_set_exception_flag (true);
jcontext_set_abort_flag (ECMA_EXTENDED_PRIMITIVE_GET_TYPE (error_ref_p) == ECMA_EXTENDED_PRIMITIVE_ABORT);
if (error_ref_p->refs_and_type >= 2 * ECMA_EXTENDED_PRIMITIVE_REF_ONE)
{
error_ref_p->refs_and_flags += ECMA_ERROR_REF_ONE;
error_ref_p->refs_and_type -= ECMA_EXTENDED_PRIMITIVE_REF_ONE;
referenced_value = ecma_copy_value (referenced_value);
}
else
{
jerry_fatal (ERR_REF_COUNT_LIMIT);
}
} /* ecma_ref_error_reference */
/**
* Decrease ref count of an error reference.
*/
void
ecma_deref_error_reference (ecma_error_reference_t *error_ref_p) /**< error reference */
{
JERRY_ASSERT (error_ref_p->refs_and_flags >= ECMA_ERROR_REF_ONE);
error_ref_p->refs_and_flags -= ECMA_ERROR_REF_ONE;
if (error_ref_p->refs_and_flags < ECMA_ERROR_REF_ONE)
{
ecma_free_value (error_ref_p->value);
jmem_pools_free (error_ref_p, sizeof (ecma_error_reference_t));
}
} /* ecma_deref_error_reference */
/**
* Clears error reference, and returns with the value.
*
* @return value referenced by the error
*/
ecma_value_t
ecma_clear_error_reference (ecma_value_t value, /**< error reference */
bool set_abort_flag) /**< set abort flag */
{
ecma_error_reference_t *error_ref_p = ecma_get_error_reference_from_value (value);
if (set_abort_flag)
{
if (error_ref_p->refs_and_flags & ECMA_ERROR_REF_ABORT)
{
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
}
else
{
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
}
jmem_pools_free (error_ref_p, sizeof (ecma_extended_primitive_t));
}
JERRY_ASSERT (error_ref_p->refs_and_flags >= ECMA_ERROR_REF_ONE);
if (error_ref_p->refs_and_flags >= 2 * ECMA_ERROR_REF_ONE)
{
error_ref_p->refs_and_flags -= ECMA_ERROR_REF_ONE;
return ecma_copy_value (error_ref_p->value);
}
ecma_value_t referenced_value = error_ref_p->value;
jmem_pools_free (error_ref_p, sizeof (ecma_error_reference_t));
return referenced_value;
} /* ecma_clear_error_reference */
JERRY_CONTEXT (error_value) = referenced_value;
} /* ecma_raise_error_from_error_reference */
/**
* Increase reference counter of Compact
@@ -1313,7 +1361,8 @@ void
ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
{
JERRY_ASSERT (bytecode_p->refs > 0);
JERRY_ASSERT (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
JERRY_ASSERT (!CBC_IS_FUNCTION (bytecode_p->status_flags)
|| !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
bytecode_p->refs--;
@@ -1323,7 +1372,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
return;
}
if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
if (CBC_IS_FUNCTION (bytecode_p->status_flags))
{
ecma_value_t *literal_start_p = NULL;
uint32_t literal_end;
@@ -1394,6 +1443,18 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
}
#endif /* ENABLED (JERRY_DEBUGGER) */
#if ENABLED (JERRY_ESNEXT)
if (bytecode_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
{
ecma_collection_t *collection_p = ecma_compiled_code_get_tagged_template_collection (bytecode_p);
/* Since the objects in the tagged template collection are not strong referenced anymore by the compiled code
we can treat them as 'new' objects. */
JERRY_CONTEXT (ecma_gc_new_objects) += collection_p->item_count * 2;
ecma_collection_free_template_literal (collection_p);
}
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_MEM_STATS)
jmem_stats_free_byte_code_bytes (((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
#endif /* ENABLED (JERRY_MEM_STATS) */
@@ -1411,6 +1472,112 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
} /* ecma_bytecode_deref */
/**
* Resolve the position of the arguments list start of the compiled code
*
* @return start position of the arguments list start of the compiled code
*/
ecma_value_t *
ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
{
JERRY_ASSERT (bytecode_header_p != NULL);
uint8_t *byte_p = (uint8_t *) bytecode_header_p;
byte_p += ((size_t) bytecode_header_p->size) << JMEM_ALIGNMENT_LOG;
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED))
{
return ((ecma_value_t *) byte_p);
}
if (JERRY_LIKELY (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)))
{
return ((ecma_value_t *) byte_p) - ((cbc_uint8_arguments_t *) bytecode_header_p)->argument_end;
}
return ((ecma_value_t *) byte_p) - ((cbc_uint16_arguments_t *) bytecode_header_p)->argument_end;
} /* ecma_compiled_code_resolve_arguments_start */
#if ENABLED (JERRY_ESNEXT)
/**
* Resolve the position of the function name of the compiled code
*
* @return position of the function name of the compiled code
*/
extern inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
{
JERRY_ASSERT (bytecode_header_p != NULL);
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--;
}
return base_p;
} /* ecma_compiled_code_resolve_function_name */
/**
* Get the extended info from a byte code
*
* @return extended info value
*/
uint32_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_function_name (bytecode_header_p);
return base_p[-1];
} /* ecma_compiled_code_resolve_extended_info */
/**
* Get the tagged template collection of the compiled code
*
* @return pointer to the tagged template collection
*/
ecma_collection_t *
ecma_compiled_code_get_tagged_template_collection (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_TAGGED_LITERALS);
ecma_value_t *base_p = ecma_compiled_code_resolve_function_name (bytecode_header_p);
int offset = (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_EXTENDED_INFO) ? -2 : -1;
return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, base_p[offset]);
} /* ecma_compiled_code_get_tagged_template_collection */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Get the resource name of a compiled code.
*
* @return resource name value
*/
ecma_value_t
ecma_get_resource_name (const ecma_compiled_code_t *bytecode_p) /**< compiled code */
{
#if ENABLED (JERRY_RESOURCE_NAME)
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_p;
ecma_value_t *lit_pool_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint16_arguments_t));
return lit_pool_p[args_p->const_literal_end - args_p->register_end - 1];
}
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_p;
ecma_value_t *lit_pool_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint8_arguments_t));
return lit_pool_p[args_p->const_literal_end - args_p->register_end - 1];
#else /* !ENABLED (JERRY_RESOURCE_NAME) */
JERRY_UNUSED (bytecode_p);
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
#endif /* !ENABLED (JERRY_RESOURCE_NAME) */
} /* ecma_get_resource_name */
#if (JERRY_STACK_LIMIT != 0)
/**
* Check the current stack usage by calculating the difference from the initial stack base.
@@ -1421,7 +1588,7 @@ uintptr_t JERRY_ATTR_NOINLINE
ecma_get_current_stack_usage (void)
{
volatile int __sp;
return (uintptr_t) (JERRY_CONTEXT (stack_base) - (uintptr_t)&__sp);
return (uintptr_t) (JERRY_CONTEXT (stack_base) - (uintptr_t) &__sp);
} /* ecma_get_current_stack_usage */
#endif /* (JERRY_STACK_LIMIT != 0) */
+149 -42
View File
@@ -32,6 +32,12 @@
*/
#define ECMA_GET_NON_NULL_POINTER(type, field) JMEM_CP_GET_NON_NULL_POINTER (type, field)
/**
* Extract value of pointer from specified pointer-tag value
*/
#define ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG(type, field) \
JMEM_CP_GET_NON_NULL_POINTER_FROM_POINTER_TAG (type, field)
/**
* Get value of pointer from specified compressed pointer.
*/
@@ -44,12 +50,39 @@
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \
non_compressed_pointer)
/**
* Set value of pointer-tag value so that it will correspond
* to specified non_compressed_pointer along with tag
*/
#define ECMA_SET_NON_NULL_POINTER_TAG(field, non_compressed_pointer, tag) \
JMEM_CP_SET_NON_NULL_POINTER_TAG (field, non_compressed_pointer, tag)
/**
* Set value of compressed pointer so that it will correspond
* to specified non_compressed_pointer.
*/
#define ECMA_SET_POINTER(field, non_compressed_pointer) JMEM_CP_SET_POINTER (field, non_compressed_pointer)
/**
* Get value of each tag bit from specified pointer-tag value
*/
#define ECMA_GET_FIRST_BIT_FROM_POINTER_TAG(field) \
JMEM_CP_GET_FIRST_BIT_FROM_POINTER_TAG (field) /**< get first tag bit from jmem_cpointer_tag_t **/
#define ECMA_GET_SECOND_BIT_FROM_POINTER_TAG(field) \
JMEM_CP_GET_SECOND_BIT_FROM_POINTER_TAG (field) /**< get second tag bit from jmem_cpointer_tag_t **/
#define ECMA_GET_THIRD_BIT_FROM_POINTER_TAG(field) \
JMEM_CP_GET_THIRD_BIT_FROM_POINTER_TAG (field) /**< get third tag bit from jmem_cpointer_tag_t **/
/**
* Set value of each tag bit to specified pointer-tag value
*/
#define ECMA_SET_FIRST_BIT_TO_POINTER_TAG(field) \
JMEM_CP_SET_FIRST_BIT_TO_POINTER_TAG (field) /**< set first tag bit to jmem_cpointer_tag_t **/
#define ECMA_SET_SECOND_BIT_TO_POINTER_TAG(field) \
JMEM_CP_SET_SECOND_BIT_TO_POINTER_TAG (field) /**< set second tag bit to jmem_cpointer_tag_t **/
#define ECMA_SET_THIRD_BIT_TO_POINTER_TAG(field) \
JMEM_CP_SET_THIRD_BIT_TO_POINTER_TAG (field) /**< set third tag bit to jmem_cpointer_tag_t **/
/**
* Status flags for ecma_string_get_chars function
*/
@@ -63,6 +96,11 @@ typedef enum
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
} 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.
*/
@@ -94,13 +132,13 @@ typedef enum
* Set an internal property value from 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.
*/
#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.
@@ -114,6 +152,12 @@ typedef enum
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(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 */
/**
@@ -140,6 +184,12 @@ typedef enum
#define ECMA_GET_INTERNAL_VALUE_ANY_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 */
/**
@@ -147,19 +197,26 @@ typedef enum
*/
#define ECMA_BOOL_TO_BITFIELD(x) ((x) ? 1 : 0)
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
/**
* JERRY_ASSERT compatible macro for checking whether the given ecma-value is symbol
* Check whether the given type is ECMA_OBJECT_TYPE_PROXY
*
* @param type object type
*/
#define ECMA_ASSERT_VALUE_IS_SYMBOL(value) (ecma_is_value_symbol ((value)))
#else /* !ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#define ECMA_OBJECT_TYPE_IS_PROXY(type) (JERRY_UNLIKELY ((type) == ECMA_OBJECT_TYPE_PROXY))
/**
* JERRY_ASSERT compatible macro for checking whether the given ecma-value is symbol
* Check whether the given object has [[ProxyHandler]] and [[ProxyTarger]] internal slots
*
* @param obj_p ecma-object
*/
#define ECMA_ASSERT_VALUE_IS_SYMBOL(value) (false)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#if ENABLED (JERRY_BUILTIN_PROXY)
#define ECMA_OBJECT_IS_PROXY(obj_p) (ECMA_OBJECT_TYPE_IS_PROXY (ecma_get_object_type ((obj_p))))
#else /* !ENABLED (JERRY_BUILTIN_PROXY) */
#define ECMA_OBJECT_IS_PROXY(obj_p) (false)
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
/* ecma-helpers-value.c */
ecma_type_t JERRY_ATTR_CONST ecma_get_value_type_field (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_direct (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_simple (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_empty (ecma_value_t value);
@@ -176,14 +233,15 @@ 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_number (ecma_value_t value);
bool JERRY_ATTR_CONST ecma_is_value_string (ecma_value_t value);
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
bool JERRY_ATTR_CONST ecma_is_value_symbol (ecma_value_t value);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
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_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_error_reference (ecma_value_t value);
ecma_value_t ecma_is_value_array (ecma_value_t arg);
void ecma_check_value_type_is_spec_defined (ecma_value_t value);
@@ -191,68 +249,77 @@ 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 ecma_make_nan_value (void);
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_int32_value (int32_t int32_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);
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
ecma_value_t JERRY_ATTR_PURE ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
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_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_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 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);
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
ecma_string_t JERRY_ATTR_PURE *ecma_get_symbol_from_value (ecma_value_t value);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
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_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 ecma_copy_value (ecma_value_t value);
ecma_value_t ecma_fast_copy_value (ecma_value_t value);
ecma_value_t ecma_copy_value_if_not_object (ecma_value_t value);
void ecma_ref_if_object (ecma_value_t value);
void ecma_deref_if_object (ecma_value_t value);
ecma_value_t ecma_update_float_number (ecma_value_t float_value, ecma_number_t new_number);
void ecma_value_assign_value (ecma_value_t *value_p, ecma_value_t ecma_value);
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_fast_free_value (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);
lit_magic_string_id_t ecma_get_typeof_lit_id (ecma_value_t value);
/* ecma-helpers-string.c */
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
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);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#if ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET)
ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t index_num, bool is_unicode);
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET)
ecma_string_t *ecma_new_map_key_string (ecma_value_t value);
bool ecma_prop_name_is_map_key (ecma_string_t *string_p);
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) */
#endif /* ENABLED (JERRY_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET) */
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,
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,
ecma_object_native_free_callback_t free_cb);
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
#if ENABLED (JERRY_ESNEXT)
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_BUILTIN_ITERATOR) */
#endif /* ENABLED (JERRY_ESNEXT) */
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_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_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_internal_string (lit_magic_string_id_t id);
ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p,
const lit_utf8_byte_t *cesu8_string2_p,
lit_utf8_size_t cesu8_string2_size,
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_append_magic_string_to_string (ecma_string_t *string1_p, lit_magic_string_id_t string2_id);
void ecma_ref_ecma_string (ecma_string_t *string_p);
void ecma_deref_ecma_string (ecma_string_t *string_p);
void ecma_destroy_ecma_string (ecma_string_t *string_p);
@@ -269,14 +336,14 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_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_size_t start_pos,
lit_utf8_size_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_size_t start_pos,
lit_utf8_size_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,
@@ -300,22 +367,32 @@ bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpoint
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_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);
ecma_length_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_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_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_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);
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
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);
#if ENABLED (JERRY_ESNEXT)
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);
#endif /* ENABLED (JERRY_ESNEXT) */
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_raw (const lit_utf8_byte_t *data_p,
const lit_utf8_size_t data_size);
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);
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
@@ -324,37 +401,56 @@ void ecma_stringbuilder_append_magic (ecma_stringbuilder_t *builder_p, const lit
void ecma_stringbuilder_append_raw (ecma_stringbuilder_t *builder_p,
const lit_utf8_byte_t *data_p,
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_byte (ecma_stringbuilder_t *builder_p, const lit_utf8_byte_t);
ecma_string_t *ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p);
void ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p);
/* ecma-helpers-number.c */
ecma_number_t ecma_number_pack (bool sign, uint32_t biased_exp, uint64_t fraction);
void ecma_number_unpack (ecma_number_t num, bool *sign_p, uint32_t *biased_exp_p, uint64_t *fraction_p);
ecma_number_t ecma_number_make_nan (void);
ecma_number_t ecma_number_make_infinity (bool sign);
bool ecma_number_is_nan (ecma_number_t num);
bool ecma_number_is_negative (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_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_next (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_pow (ecma_number_t x, ecma_number_t y);
ecma_value_t 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 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);
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_collection_t *ecma_new_collection (void);
void ecma_collection_push_back (ecma_collection_t *collection_p, ecma_value_t value);
void ecma_collection_reserve (ecma_collection_t *collection_p, uint32_t count);
void ecma_collection_append (ecma_collection_t *collection_p, const ecma_value_t *buffer_p, uint32_t count);
void ecma_collection_destroy (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_objects (ecma_collection_t *collection_p);
#if ENABLED (JERRY_ESNEXT)
void ecma_collection_free_template_literal (ecma_collection_t *collection_p);
#endif /* ENABLED (JERRY_ESNEXT) */
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-helpers.c */
ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type);
@@ -362,15 +458,14 @@ ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environmen
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);
bool JERRY_ATTR_PURE ecma_is_lexical_environment (const ecma_object_t *object_p);
bool JERRY_ATTR_PURE ecma_get_object_extensible (const ecma_object_t *object_p);
void ecma_set_object_extensible (ecma_object_t *object_p, bool is_extensible);
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);
bool JERRY_ATTR_PURE ecma_get_object_is_builtin (const ecma_object_t *object_p);
void ecma_set_object_is_builtin (ecma_object_t *object_p);
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_object_t JERRY_ATTR_PURE *ecma_get_lex_env_outer_reference (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_property_value_t *
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
@@ -411,15 +506,26 @@ void ecma_set_property_lcached (ecma_property_t *property_p, bool is_lcached);
ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p);
void ecma_ref_extended_primitive (ecma_extended_primitive_t *primitve_p);
void ecma_deref_error_reference (ecma_extended_primitive_t *error_ref_p);
#if ENABLED (JERRY_BUILTIN_BIGINT)
void ecma_deref_bigint (ecma_extended_primitive_t *bigint_p);
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
ecma_value_t ecma_create_error_reference (ecma_value_t value, bool is_exception);
ecma_value_t ecma_create_error_reference_from_context (void);
ecma_value_t ecma_create_error_object_reference (ecma_object_t *object_p);
void ecma_ref_error_reference (ecma_error_reference_t *error_ref_p);
void ecma_deref_error_reference (ecma_error_reference_t *error_ref_p);
ecma_value_t ecma_clear_error_reference (ecma_value_t value, bool set_abort_flag);
void ecma_raise_error_from_error_reference (ecma_value_t value);
void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p);
void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
ecma_value_t *ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p);
#if ENABLED (JERRY_ESNEXT)
ecma_value_t *ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p);
uint32_t ecma_compiled_code_resolve_extended_info (const ecma_compiled_code_t *bytecode_header_p);
ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
#endif /* ENABLED (JERRY_ESNEXT) */
ecma_value_t ecma_get_resource_name (const ecma_compiled_code_t *bytecode_p);
#if (JERRY_STACK_LIMIT != 0)
uintptr_t ecma_get_current_stack_usage (void);
#endif /* (JERRY_STACK_LIMIT != 0) */
@@ -430,7 +536,8 @@ ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, void
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, void *info_p);
/* 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);
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);
int32_t ecma_number_to_int32 (ecma_number_t num);
+46 -7
View File
@@ -29,13 +29,22 @@
* @{
*/
/**
* Maximum number of GC loops on cleanup.
*/
#define JERRY_GC_LOOP_LIMIT 100
/**
* Initialize ECMA components
*/
void
ecma_init (void)
{
ecma_init_global_lex_env ();
#if (JERRY_GC_MARK_LIMIT != 0)
JERRY_CONTEXT (ecma_gc_mark_recursion_limit) = JERRY_GC_MARK_LIMIT;
#endif /* (JERRY_GC_MARK_LIMIT != 0) */
ecma_init_global_environment ();
#if ENABLED (JERRY_PROPRETY_HASHMAP)
JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_ON;
@@ -44,12 +53,16 @@ ecma_init (void)
#if (JERRY_STACK_LIMIT != 0)
volatile int sp;
JERRY_CONTEXT (stack_base) = (uintptr_t)&sp;
JERRY_CONTEXT (stack_base) = (uintptr_t) &sp;
#endif /* (JERRY_STACK_LIMIT != 0) */
#if ENABLED (JERRY_ES2015_BUILTIN_PROMISE)
#if ENABLED (JERRY_BUILTIN_PROMISE)
ecma_job_queue_init ();
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
#endif /* ENABLED (JERRY_BUILTIN_PROMISE) */
#if ENABLED (JERRY_ESNEXT)
JERRY_CONTEXT (current_new_target_p) = NULL;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_init */
/**
@@ -58,9 +71,35 @@ ecma_init (void)
void
ecma_finalize (void)
{
ecma_finalize_global_lex_env ();
ecma_finalize_builtins ();
ecma_gc_run ();
#if ENABLED (JERRY_ESNEXT)
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) == NULL);
#endif /* ENABLED (JERRY_ESNEXT) */
ecma_finalize_global_environment ();
uint8_t runs = 0;
do
{
ecma_gc_run ();
if (++runs >= JERRY_GC_LOOP_LIMIT)
{
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
}
}
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
#if ENABLED (JERRY_ESNEXT)
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]));
}
}
#endif /* ENABLED (JERRY_ESNEXT) */
ecma_finalize_lit_storage ();
} /* ecma_finalize */
+3 -7
View File
@@ -91,9 +91,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (prop_p != NULL && !ecma_is_property_lcached (prop_p));
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
jmem_cpointer_t object_cp;
@@ -138,7 +136,7 @@ insert:
* @return a pointer to an ecma_property_t if the lookup is successful
* 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 */
const ecma_string_t *prop_name_p) /**< property's name */
{
@@ -191,9 +189,7 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (prop_p != NULL && ecma_is_property_lcached (prop_p));
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
jmem_cpointer_t object_cp;
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
+244 -46
View File
@@ -14,6 +14,8 @@
*/
#include "ecma-alloc.h"
#include "ecma-bigint.h"
#include "ecma-big-uint.h"
#include "ecma-literal-storage.h"
#include "ecma-helpers.h"
#include "jcontext.h"
@@ -25,7 +27,7 @@
* @{
*/
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
/**
* Free symbol list
*/
@@ -53,7 +55,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
symbol_list_cp = next_item_cp;
}
} /* ecma_free_symbol_list */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Free string list
@@ -87,39 +89,73 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
* Free number list
*/
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)
{
ecma_number_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_storage_item_t,
number_list_cp);
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
number_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{
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 (num_p);
ecma_dealloc_number (JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]));
}
}
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;
}
} /* ecma_free_number_list */
#if ENABLED (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 /* ENABLED (JERRY_BUILTIN_BIGINT) */
/**
* Finalize literal storage
*/
void
ecma_finalize_lit_storage (void)
{
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#if ENABLED (JERRY_ESNEXT)
ecma_free_symbol_list (JERRY_CONTEXT (symbol_list_first_cp));
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#endif /* ENABLED (JERRY_ESNEXT) */
ecma_free_string_list (JERRY_CONTEXT (string_list_first_cp));
ecma_free_number_list (JERRY_CONTEXT (number_list_first_cp));
#if ENABLED (JERRY_BUILTIN_BIGINT)
ecma_free_bigint_list (JERRY_CONTEXT (bigint_list_first_cp));
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
} /* ecma_finalize_lit_storage */
/**
@@ -199,7 +235,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
/**
* Find or create a literal number.
*
* @return ecma_string_t compressed pointer
* @return ecma value
*/
ecma_value_t
ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */
@@ -218,8 +254,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
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,
number_list_cp);
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
number_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{
@@ -246,10 +282,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
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_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)
{
@@ -257,8 +291,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
return num;
}
ecma_number_storage_item_t *new_item_p;
new_item_p = (ecma_number_storage_item_t *) jmem_pools_alloc (sizeof (ecma_number_storage_item_t));
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++)
@@ -272,6 +306,83 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
return num;
} /* ecma_find_or_create_literal_number */
#if ENABLED (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 /* ENABLED (JERRY_BUILTIN_BIGINT) */
/**
* Log2 of snapshot literal alignment.
*/
@@ -285,13 +396,20 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
/**
* 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.
*/
#define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT)
#if ENABLED (JERRY_BUILTIN_BIGINT)
/**
* Literal value is BigInt.
*/
#define JERRY_SNAPSHOT_LITERAL_IS_BIGINT (2u << ECMA_VALUE_SHIFT)
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
#if ENABLED (JERRY_SNAPSHOT_SAVE)
/**
@@ -301,7 +419,11 @@ void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appen
ecma_collection_t *lit_pool_p) /**< list of known values */
{
/* 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 ENABLED (JERRY_BUILTIN_BIGINT)
&& (!ecma_is_value_bigint (value) || value == ECMA_BIGINT_ZERO)
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
&& !ecma_is_value_float_number (value))
{
return;
}
@@ -329,12 +451,12 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
ecma_collection_t *lit_pool_p) /**< list of known values */
{
ecma_value_t *literal_p;
uint32_t argument_end = 0;
uint32_t argument_end;
uint32_t register_end;
uint32_t const_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)
{
@@ -345,11 +467,7 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
register_end = args_p->register_end;
const_literal_end = args_p->const_literal_end - register_end;
literal_end = args_p->literal_end - register_end;
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (compiled_code_p))
{
argument_end = args_p->argument_end;
}
argument_end = args_p->argument_end;
}
else
{
@@ -360,16 +478,15 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
register_end = args_p->register_end;
const_literal_end = args_p->const_literal_end - register_end;
literal_end = args_p->literal_end - register_end;
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (compiled_code_p))
{
argument_end = args_p->argument_end;
}
argument_end = args_p->argument_end;
}
for (uint32_t i = 0; i < argument_end; i++)
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
{
ecma_save_literals_append_value (literal_p[i], lit_pool_p);
for (uint32_t i = 0; i < argument_end; i++)
{
ecma_save_literals_append_value (literal_p[i], lit_pool_p);
}
}
for (uint32_t i = 0; i < const_literal_end; i++)
@@ -382,23 +499,20 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
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)
{
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
}
}
if (argument_end != 0)
{
uint8_t *byte_p = (uint8_t *) compiled_code_p;
byte_p += ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG;
literal_p = ((ecma_value_t *) byte_p) - argument_end;
uint8_t *byte_p = ((uint8_t *) compiled_code_p) + (((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG);
literal_p = ecma_snapshot_resolve_serializable_values ((ecma_compiled_code_t *) compiled_code_p, byte_p);
for (uint32_t i = 0; i < argument_end; i++)
{
ecma_save_literals_append_value (literal_p[i], lit_pool_p);
}
while (literal_p < (ecma_value_t *) byte_p)
{
ecma_save_literals_append_value (*literal_p, lit_pool_p);
literal_p++;
}
} /* ecma_save_literals_add_compiled_code */
@@ -444,6 +558,15 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
{
lit_table_size += (uint32_t) sizeof (ecma_number_t);
}
#if ENABLED (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 /* ENABLED (JERRY_BUILTIN_BIGINT) */
else
{
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
@@ -461,7 +584,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;
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));
@@ -483,7 +606,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_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]))
{
@@ -494,6 +617,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);
}
#if ENABLED (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 /* ENABLED (JERRY_BUILTIN_BIGINT) */
else
{
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
@@ -541,11 +678,72 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
return ecma_find_or_create_literal_number (num);
}
#if ENABLED (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 (ERR_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 /* ENABLED (JERRY_BUILTIN_BIGINT) */
uint16_t length = *(const uint16_t *) literal_p;
return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length);
} /* ecma_snapshot_get_literal */
/**
* Compute the start of the serializable ecma-values of the bytecode
* Related values:
* - function argument names, if CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED is present
* - function name, if CBC_CODE_FLAGS_CLASS_CONSTRUCTOR is not present and ES.next profile is enabled
*
* @return pointer to the beginning of the serializable ecma-values
*/
ecma_value_t *
ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p, /**< compiled code */
uint8_t *bytecode_end_p) /**< end of the bytecode */
{
ecma_value_t *base_p = (ecma_value_t *) bytecode_end_p;
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
{
uint32_t argument_end;
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
argument_end = ((cbc_uint16_arguments_t *) compiled_code_p)->argument_end;
}
else
{
argument_end = ((cbc_uint8_arguments_t *) compiled_code_p)->argument_end;
}
base_p -= argument_end;
}
#if ENABLED (JERRY_ESNEXT)
/* function name */
if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
{
base_p--;
}
#endif /* ENABLED (JERRY_ESNEXT) */
return base_p;
} /* ecma_snapshot_resolve_serializable_values */
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */
/**
@@ -42,6 +42,9 @@ 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_number (ecma_number_t number_arg);
#if ENABLED (JERRY_BUILTIN_BIGINT)
ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
#if ENABLED (JERRY_SNAPSHOT_SAVE)
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
@@ -55,6 +58,8 @@ bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *b
#if ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE)
ecma_value_t
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
ecma_value_t *
ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p);
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */
/**
+391 -248
View File
@@ -27,7 +27,7 @@
#include "lit-char-helpers.h"
#include "vm.h"
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
#if ENABLED (JERRY_MODULE_SYSTEM)
/**
* Takes a ModuleSpecifier and applies path normalization to it.
@@ -37,8 +37,9 @@
* @return pointer to ecma_string_t containing the normalized and zero terminated path
*/
ecma_string_t *
ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier */
prop_length_t size) /**< size of module specifier */
ecma_module_create_normalized_path (const lit_utf8_byte_t *char_p, /**< module path specifier */
lit_utf8_size_t size, /**< size of module specifier */
ecma_string_t *const base_path_p) /**< base path for the module specifier */
{
JERRY_ASSERT (size > 0);
ecma_string_t *ret_p = NULL;
@@ -57,16 +58,13 @@ ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier
lit_utf8_byte_t *module_path_p = NULL;
lit_utf8_size_t module_path_size = 0;
/* Check if we have a current module, and use its path as the base path. */
JERRY_ASSERT (JERRY_CONTEXT (module_top_context_p) != NULL);
if (JERRY_CONTEXT (module_top_context_p)->module_p != NULL)
if (base_path_p != NULL)
{
JERRY_ASSERT (JERRY_CONTEXT (module_top_context_p)->module_p->path_p != NULL);
module_path_size = ecma_string_get_size (JERRY_CONTEXT (module_top_context_p)->module_p->path_p);
module_path_size = ecma_string_get_size (base_path_p);
module_path_p = (lit_utf8_byte_t *) jmem_heap_alloc_block (module_path_size + 1);
lit_utf8_size_t module_utf8_size;
module_utf8_size = ecma_string_copy_to_utf8_buffer (JERRY_CONTEXT (module_top_context_p)->module_p->path_p,
module_utf8_size = ecma_string_copy_to_utf8_buffer (base_path_p,
module_path_p,
module_path_size);
@@ -79,7 +77,6 @@ ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier
ECMA_MODULE_MAX_PATH,
(char *) module_path_p);
if (normalized_size > 0)
{
/* Convert the normalized path to cesu8. */
@@ -97,26 +94,39 @@ ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier
} /* ecma_module_create_normalized_path */
/**
* Find a module with a specific identifier
* Push a new module into the module list. New modules are inserted after the head module, this way in the end the
* root module remains the first in the list.
*/
static void
ecma_module_list_push (ecma_module_t *module_p)
{
ecma_module_t *head_p = JERRY_CONTEXT (module_list_p);
module_p->next_p = head_p->next_p;
head_p->next_p = module_p;
} /* ecma_module_list_push */
/**
* Lookup a module with a specific identifier.
*
* @return pointer to ecma_module_t, if found
* NULL, otherwise
*/
ecma_module_t *
ecma_module_find_module (ecma_string_t *const path_p) /**< module identifier */
static ecma_module_t *
ecma_module_list_lookup (ecma_string_t *const path_p) /**< module identifier */
{
ecma_module_t *current_p = JERRY_CONTEXT (ecma_modules_p);
ecma_module_t *current_p = JERRY_CONTEXT (module_list_p);
while (current_p != NULL)
{
if (ecma_compare_ecma_strings (path_p, current_p->path_p))
{
return current_p;
}
current_p = current_p->next_p;
}
return current_p;
} /* ecma_module_find_module */
return NULL;
} /* ecma_module_list_lookup */
/**
* Create a new module
@@ -130,8 +140,7 @@ ecma_module_create_module (ecma_string_t *const path_p) /**< module identifier *
memset (module_p, 0, sizeof (ecma_module_t));
module_p->path_p = path_p;
module_p->next_p = JERRY_CONTEXT (ecma_modules_p);
JERRY_CONTEXT (ecma_modules_p) = module_p;
ecma_module_list_push (module_p);
return module_p;
} /* ecma_module_create_module */
@@ -141,9 +150,10 @@ ecma_module_create_module (ecma_string_t *const path_p) /**< module identifier *
* @return pointer to found or newly created module structure
*/
ecma_module_t *
ecma_module_find_or_create_module (ecma_string_t *const path_p) /**< module path */
ecma_module_find_module (ecma_string_t *const path_p) /**< module path */
{
ecma_module_t *module_p = ecma_module_find_module (path_p);
ecma_module_t *module_p = ecma_module_list_lookup (path_p);
if (module_p)
{
ecma_deref_ecma_string (path_p);
@@ -151,7 +161,7 @@ ecma_module_find_or_create_module (ecma_string_t *const path_p) /**< module path
}
return ecma_module_create_module (path_p);
} /* ecma_module_find_or_create_module */
} /* ecma_module_find_module */
/**
* Create a new native module
@@ -159,28 +169,83 @@ ecma_module_find_or_create_module (ecma_string_t *const path_p) /**< module path
* @return pointer to created module
*/
ecma_module_t *
ecma_module_create_native_module (ecma_string_t *const path_p, /**< module identifier */
ecma_object_t *const namespace_p) /**< module namespace */
ecma_module_find_native_module (ecma_string_t *const path_p)
{
ecma_module_t *module_p = ecma_module_create_module (path_p);
module_p->state = ECMA_MODULE_STATE_NATIVE;
module_p->namespace_object_p = namespace_p;
return module_p;
} /* ecma_module_create_native_module */
ecma_module_t *module_p = ecma_module_list_lookup (path_p);
if (module_p != NULL)
{
return module_p;
}
ecma_value_t native = jerry_port_get_native_module (ecma_make_string_value (path_p));
if (!ecma_is_value_undefined (native))
{
JERRY_ASSERT (ecma_is_value_object (native));
module_p = ecma_module_create_module (path_p);
module_p->state = ECMA_MODULE_STATE_NATIVE;
module_p->namespace_object_p = ecma_get_object_from_value (native);
return module_p;
}
return NULL;
} /* ecma_module_find_native_module */
/**
* Creates a module context.
*
* @return pointer to created module context
* Initialize context variables for the root module.
*/
static ecma_module_context_t *
ecma_module_create_module_context (void)
void
ecma_module_initialize_context (ecma_string_t *root_path_p) /**< root module */
{
ecma_module_context_t *context_p = (ecma_module_context_t *) jmem_heap_alloc_block (sizeof (ecma_module_context_t));
memset (context_p, 0, sizeof (ecma_module_context_t));
JERRY_ASSERT (JERRY_CONTEXT (module_current_p) == NULL);
JERRY_ASSERT (JERRY_CONTEXT (module_list_p) == NULL);
return context_p;
} /* ecma_module_create_module_context */
lit_utf8_size_t path_str_size;
uint8_t flags = ECMA_STRING_FLAG_EMPTY;
const lit_utf8_byte_t *path_str_chars_p = ecma_string_get_chars (root_path_p,
&path_str_size,
NULL,
NULL,
&flags);
ecma_string_t *path_p = ecma_module_create_normalized_path (path_str_chars_p,
path_str_size,
NULL);
if (path_p == NULL)
{
ecma_ref_ecma_string (root_path_p);
path_p = root_path_p;
}
ecma_module_t *module_p = (ecma_module_t *) jmem_heap_alloc_block (sizeof (ecma_module_t));
memset (module_p, 0, sizeof (ecma_module_t));
module_p->path_p = path_p;
/* Root modules are handled differently then the rest of the referenced modules, as the scope and compiled code
* are handled separately. */
module_p->state = ECMA_MODULE_STATE_ROOT;
JERRY_CONTEXT (module_current_p) = module_p;
JERRY_CONTEXT (module_list_p) = module_p;
} /* ecma_module_initialize_context */
/**
* cleanup context variables for the root module.
*/
void
ecma_module_cleanup_context (void)
{
ecma_module_cleanup (JERRY_CONTEXT (module_current_p));
#ifndef JERRY_NDEBUG
JERRY_CONTEXT (module_current_p) = NULL;
JERRY_CONTEXT (module_list_p) = NULL;
#endif /* JERRY_NDEBUG */
} /* ecma_module_cleanup_context */
/**
* Inserts a {module, export_name} record into a resolve set.
@@ -191,8 +256,8 @@ ecma_module_create_module_context (void)
*/
bool
ecma_module_resolve_set_insert (ecma_module_resolve_set_t **set_p, /**< [in, out] resolve set */
ecma_module_t * const module_p, /**< module */
ecma_string_t * const export_name_p) /**< export name */
ecma_module_t *const module_p, /**< module */
ecma_string_t *const export_name_p) /**< export name */
{
JERRY_ASSERT (set_p != NULL);
ecma_module_resolve_set_t *current_p = *set_p;
@@ -284,8 +349,8 @@ ecma_module_resolve_stack_pop (ecma_module_resolve_stack_t **stack_p) /**< [in,
* ECMA_VALUE_EMPTY - otherwise
*/
static ecma_value_t
ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
ecma_string_t * const export_name_p, /**< export name */
ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
ecma_string_t *const export_name_p, /**< export name */
ecma_module_record_t *out_record_p) /**< [out] found module record */
{
ecma_module_resolve_set_t *resolve_set_p = NULL;
@@ -303,7 +368,6 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
ecma_module_t *current_module_p = current_frame_p->module_p;
JERRY_ASSERT (current_module_p->state >= ECMA_MODULE_STATE_PARSED);
ecma_module_context_t *context_p = current_module_p->context_p;
ecma_string_t *current_export_name_p = current_frame_p->export_name_p;
if (!current_frame_p->resolving)
@@ -342,11 +406,11 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
continue;
}
if (context_p->local_exports_p != NULL)
if (current_module_p->local_exports_p != NULL)
{
/* 15.2.1.16.3 / 4 */
JERRY_ASSERT (context_p->local_exports_p->next_p == NULL);
ecma_module_names_t *export_names_p = context_p->local_exports_p->module_names_p;
JERRY_ASSERT (current_module_p->local_exports_p->next_p == NULL);
ecma_module_names_t *export_names_p = current_module_p->local_exports_p->module_names_p;
while (export_names_p != NULL)
{
if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p))
@@ -378,7 +442,7 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
}
/* 15.2.1.16.3 / 5 */
ecma_module_node_t *indirect_export_p = context_p->indirect_exports_p;
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
while (indirect_export_p != NULL)
{
ecma_module_names_t *export_names_p = indirect_export_p->module_names_p;
@@ -390,6 +454,7 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
ecma_module_resolve_stack_push (&stack_p,
indirect_export_p->module_request_p,
export_names_p->local_name_p);
break;
}
export_names_p = export_names_p->next_p;
@@ -433,7 +498,7 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
ecma_module_resolve_stack_pop (&stack_p);
/* 15.2.1.16.3 / 10 */
ecma_module_node_t *star_export_p = context_p->star_exports_p;
ecma_module_node_t *star_export_p = current_module_p->star_exports_p;
while (star_export_p != NULL)
{
JERRY_ASSERT (star_export_p->module_names_p == NULL);
@@ -470,6 +535,49 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
return ret_value;
} /* ecma_module_resolve_export */
/**
* Evaluates an EcmaScript module.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
static ecma_value_t
ecma_module_evaluate (ecma_module_t *module_p) /**< module */
{
JERRY_ASSERT (module_p->state >= ECMA_MODULE_STATE_PARSED);
if (module_p->state >= ECMA_MODULE_STATE_EVALUATING)
{
return ECMA_VALUE_EMPTY;
}
#if ENABLED (JERRY_BUILTIN_REALMS)
ecma_object_t *global_object_p = (ecma_object_t *) ecma_op_function_get_realm (module_p->compiled_code_p);
#else /* !ENABLED (JERRY_BUILTIN_REALMS) */
ecma_object_t *global_object_p = ecma_builtin_get_global ();
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
module_p->state = ECMA_MODULE_STATE_EVALUATING;
module_p->scope_p = ecma_create_decl_lex_env (ecma_get_global_environment (global_object_p));
ecma_value_t ret_value;
ret_value = vm_run_module (module_p);
if (!ECMA_IS_VALUE_ERROR (ret_value))
{
ecma_free_value (ret_value);
ret_value = ECMA_VALUE_EMPTY;
}
module_p->state = ECMA_MODULE_STATE_EVALUATED;
ecma_bytecode_deref (module_p->compiled_code_p);
#ifndef JERRY_NDEBUG
module_p->compiled_code_p = NULL;
#endif /* JERRY_NDEBUG */
return ret_value;
} /* ecma_module_evaluate */
/**
* Resolves an export and adds it to the modules namespace object, if the export name is not yet handled.
* Note: See 15.2.1.16.2 and 15.2.1.18
@@ -484,7 +592,9 @@ ecma_module_namespace_object_add_export_if_needed (ecma_module_t *module_p, /**<
JERRY_ASSERT (module_p->namespace_object_p != NULL);
ecma_value_t result = ECMA_VALUE_EMPTY;
if (ecma_find_named_property (module_p->namespace_object_p, export_name_p) != NULL)
/* Default exports should not be added to the namespace object. */
if (ecma_compare_ecma_string_to_magic_id (export_name_p, LIT_MAGIC_STRING_DEFAULT)
|| ecma_find_named_property (module_p->namespace_object_p, export_name_p) != NULL)
{
/* This export name has already been handled. */
return result;
@@ -551,7 +661,6 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
{
ecma_module_resolve_stack_t *current_frame_p = stack_p;
ecma_module_t *current_module_p = current_frame_p->module_p;
ecma_module_context_t *context_p = current_module_p->context_p;
ecma_module_resolve_stack_pop (&stack_p);
@@ -564,11 +673,18 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
continue;
}
if (context_p->local_exports_p != NULL)
result = ecma_module_evaluate (current_module_p);
if (ECMA_IS_VALUE_ERROR (result))
{
break;
}
if (current_module_p->local_exports_p != NULL)
{
/* 15.2.1.16.2 / 5 */
JERRY_ASSERT (context_p->local_exports_p->next_p == NULL);
ecma_module_names_t *export_names_p = context_p->local_exports_p->module_names_p;
JERRY_ASSERT (current_module_p->local_exports_p->next_p == NULL);
ecma_module_names_t *export_names_p = current_module_p->local_exports_p->module_names_p;
while (export_names_p != NULL && ecma_is_value_empty (result))
{
result = ecma_module_namespace_object_add_export_if_needed (module_p,
@@ -578,7 +694,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
}
/* 15.2.1.16.2 / 6 */
ecma_module_node_t *indirect_export_p = context_p->indirect_exports_p;
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
while (indirect_export_p != NULL && ecma_is_value_empty (result))
{
ecma_module_names_t *export_names_p = indirect_export_p->module_names_p;
@@ -592,7 +708,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
}
/* 15.2.1.16.2 / 7 */
ecma_module_node_t *star_export_p = context_p->star_exports_p;
ecma_module_node_t *star_export_p = current_module_p->star_exports_p;
while (star_export_p != NULL && ecma_is_value_empty (result))
{
JERRY_ASSERT (star_export_p->module_names_p == NULL);
@@ -617,59 +733,65 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
} /* ecma_module_create_namespace_object */
/**
* Evaluates an EcmaScript module.
* Connects imported values to the current module scope.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
static ecma_value_t
ecma_module_evaluate (ecma_module_t *module_p) /**< module */
ecma_module_connect_imports (ecma_module_t *module_p)
{
JERRY_ASSERT (module_p->state >= ECMA_MODULE_STATE_PARSED);
if (module_p->state >= ECMA_MODULE_STATE_EVALUATING)
{
return ECMA_VALUE_EMPTY;
}
module_p->state = ECMA_MODULE_STATE_EVALUATING;
module_p->scope_p = ecma_create_decl_lex_env (ecma_get_global_environment ());
module_p->context_p->parent_p = JERRY_CONTEXT (module_top_context_p);
JERRY_CONTEXT (module_top_context_p) = module_p->context_p;
ecma_value_t ret_value;
ret_value = vm_run_module (module_p->compiled_code_p,
module_p->scope_p);
if (!ECMA_IS_VALUE_ERROR (ret_value))
{
jerry_release_value (ret_value);
ret_value = ECMA_VALUE_EMPTY;
}
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
ecma_bytecode_deref (module_p->compiled_code_p);
module_p->state = ECMA_MODULE_STATE_EVALUATED;
return ret_value;
} /* ecma_module_evaluate */
/**
* Connects imported values to the current context.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
ecma_value_t
ecma_module_connect_imports (void)
{
ecma_module_context_t *current_context_p = JERRY_CONTEXT (module_top_context_p);
ecma_object_t *local_env_p = current_context_p->module_p->scope_p;
ecma_object_t *local_env_p = module_p->scope_p;
JERRY_ASSERT (ecma_is_lexical_environment (local_env_p));
ecma_module_node_t *import_node_p = current_context_p->imports_p;
ecma_module_node_t *import_node_p = module_p->imports_p;
/* Check that the imported bindings don't exist yet. */
while (import_node_p != NULL)
{
ecma_module_names_t *import_names_p = import_node_p->module_names_p;
while (import_names_p != NULL)
{
ecma_object_t *lex_env_p = local_env_p;
ecma_property_t *binding_p = NULL;
if (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_BLOCK)
{
binding_p = ecma_find_named_property (lex_env_p, import_names_p->local_name_p);
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
}
if (binding_p != NULL)
{
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Imported binding shadows local variable."));
}
ecma_value_t status = ecma_op_has_binding (lex_env_p, import_names_p->local_name_p);
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_IS_VALUE_ERROR (status))
{
return status;
}
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
if (ecma_is_value_true (status))
{
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Imported binding shadows local variable."));
}
import_names_p = import_names_p->next_p;
}
import_node_p = import_node_p->next_p;
}
import_node_p = module_p->imports_p;
/* Resolve imports and create local bindings. */
while (import_node_p != NULL)
{
ecma_value_t result = ecma_module_evaluate (import_node_p->module_request_p);
@@ -684,6 +806,8 @@ ecma_module_connect_imports (void)
const bool is_namespace_import = ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
LIT_MAGIC_STRING_ASTERIX_CHAR);
ecma_value_t prop_value;
if (is_namespace_import)
{
result = ecma_module_create_namespace_object (import_node_p->module_request_p);
@@ -692,11 +816,8 @@ ecma_module_connect_imports (void)
return result;
}
ecma_op_create_mutable_binding (local_env_p, import_names_p->local_name_p, true /* is_deletable */);
ecma_op_set_mutable_binding (local_env_p,
import_names_p->local_name_p,
ecma_make_object_value (import_node_p->module_request_p->namespace_object_p),
false /* is_strict */);
ecma_ref_object (import_node_p->module_request_p->namespace_object_p);
prop_value = ecma_make_object_value (import_node_p->module_request_p->namespace_object_p);
}
else /* !is_namespace_import */
{
@@ -716,18 +837,8 @@ ecma_module_connect_imports (void)
if (record.module_p->state == ECMA_MODULE_STATE_NATIVE)
{
ecma_object_t *object_p = record.module_p->namespace_object_p;
ecma_value_t prop_value = ecma_op_object_find_own (ecma_make_object_value (object_p),
object_p,
record.name_p);
prop_value = ecma_op_object_find_own (ecma_make_object_value (object_p), object_p, record.name_p);
JERRY_ASSERT (ecma_is_value_found (prop_value));
ecma_op_create_mutable_binding (local_env_p, import_names_p->local_name_p, true /* is_deletable */);
ecma_op_set_mutable_binding (local_env_p,
import_names_p->local_name_p,
prop_value,
false /* is_strict */);
ecma_free_value (prop_value);
}
else
{
@@ -739,20 +850,33 @@ ecma_module_connect_imports (void)
}
ecma_object_t *ref_base_lex_env_p;
ecma_value_t prop_value = ecma_op_get_value_lex_env_base (record.module_p->scope_p,
&ref_base_lex_env_p,
record.name_p);
prop_value = ecma_op_get_value_lex_env_base (record.module_p->scope_p,
&ref_base_lex_env_p,
record.name_p);
ecma_op_create_mutable_binding (local_env_p, import_names_p->local_name_p, true /* is_deletable */);
ecma_op_set_mutable_binding (local_env_p,
import_names_p->local_name_p,
prop_value,
false /* is_strict */);
ecma_free_value (prop_value);
}
}
ecma_property_t *prop_p = ecma_op_create_mutable_binding (local_env_p,
import_names_p->local_name_p,
true /* is_deletable */);
JERRY_ASSERT (prop_p != ECMA_PROPERTY_POINTER_ERROR);
if (prop_p != NULL)
{
JERRY_ASSERT (ecma_is_value_undefined (ECMA_PROPERTY_VALUE_PTR (prop_p)->value));
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = prop_value;
ecma_deref_if_object (prop_value);
}
else
{
ecma_op_set_mutable_binding (local_env_p,
import_names_p->local_name_p,
prop_value,
false /* is_strict */);
ecma_free_value (prop_value);
}
import_names_p = import_names_p->next_p;
}
@@ -762,13 +886,100 @@ ecma_module_connect_imports (void)
return ECMA_VALUE_EMPTY;
} /* ecma_module_connect_imports */
/**
* Checks if indirect exports in the current context are resolvable.
* Note: See 15.2.1.16.4 / 9.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
static ecma_value_t
ecma_module_check_indirect_exports (ecma_module_t *module_p)
{
ecma_module_node_t *indirect_export_p = module_p->indirect_exports_p;
while (indirect_export_p != NULL)
{
ecma_module_names_t *name_p = indirect_export_p->module_names_p;
while (name_p != NULL)
{
ecma_module_record_t record;
ecma_value_t result = ecma_module_resolve_export (indirect_export_p->module_request_p,
name_p->local_name_p,
&record);
if (ECMA_IS_VALUE_ERROR (result))
{
return result;
}
JERRY_ASSERT (ecma_is_value_empty (result));
if (record.module_p == NULL)
{
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Ambiguous indirect export request."));
}
name_p = name_p->next_p;
}
indirect_export_p = indirect_export_p->next_p;
}
return ECMA_VALUE_EMPTY;
} /* ecma_module_check_indirect_exports */
/**
* Initialize the current module by creating the local binding for the imported variables
* and verifying indirect exports.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
ecma_value_t
ecma_module_initialize (ecma_module_t *module_p) /**< module */
{
ecma_value_t ret_value = ecma_module_connect_imports (module_p);
if (ecma_is_value_empty (ret_value))
{
ret_value = ecma_module_check_indirect_exports (module_p);
}
return ret_value;
} /* ecma_module_initialize */
static ecma_value_t ecma_module_parse (ecma_module_t *module_p);
/**
* Parses all referenced modules.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
ecma_value_t
ecma_module_parse_referenced_modules (void)
{
ecma_module_t *current_p = JERRY_CONTEXT (module_list_p);
while (current_p != NULL)
{
if (ECMA_IS_VALUE_ERROR (ecma_module_parse (current_p)))
{
return ECMA_VALUE_ERROR;
}
current_p = current_p->next_p;
}
return ECMA_VALUE_EMPTY;
} /* ecma_module_parse_referenced_modules */
/**
* Parses an EcmaScript module.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
static jerry_value_t
static ecma_value_t
ecma_module_parse (ecma_module_t *module_p) /**< module */
{
if (module_p->state >= ECMA_MODULE_STATE_PARSING)
@@ -777,7 +988,6 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
}
module_p->state = ECMA_MODULE_STATE_PARSING;
module_p->context_p = ecma_module_create_module_context ();
lit_utf8_size_t module_path_size = ecma_string_get_size (module_p->path_p);
lit_utf8_byte_t *module_path_p = (lit_utf8_byte_t *) jmem_heap_alloc_block (module_path_size + 1);
@@ -797,9 +1007,8 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
return ecma_raise_syntax_error (ECMA_ERR_MSG ("File not found."));
}
module_p->context_p->module_p = module_p;
module_p->context_p->parent_p = JERRY_CONTEXT (module_top_context_p);
JERRY_CONTEXT (module_top_context_p) = module_p->context_p;
ecma_module_t *prev_module_p = JERRY_CONTEXT (module_current_p);
JERRY_CONTEXT (module_current_p) = module_p;
#if ENABLED (JERRY_DEBUGGER) && ENABLED (JERRY_PARSER)
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
@@ -811,99 +1020,33 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
}
#endif /* ENABLED (JERRY_DEBUGGER) && ENABLED (JERRY_PARSER) */
JERRY_CONTEXT (resource_name) = ecma_make_string_value (module_p->path_p);
ecma_compiled_code_t *bytecode_data_p;
ecma_value_t ret_value = parser_parse_script (NULL,
0,
(jerry_char_t *) source_p,
source_size,
JERRY_PARSE_STRICT_MODE,
&bytecode_data_p);
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
ecma_compiled_code_t *bytecode_p = parser_parse_script (NULL,
0,
(jerry_char_t *) source_p,
source_size,
ecma_make_string_value (module_p->path_p),
ECMA_PARSE_STRICT_MODE | ECMA_PARSE_MODULE);
JERRY_CONTEXT (module_current_p) = prev_module_p;
jerry_port_release_source (source_p);
if (ECMA_IS_VALUE_ERROR (ret_value))
if (JERRY_UNLIKELY (bytecode_p == NULL))
{
return ret_value;
return ECMA_VALUE_ERROR;
}
ecma_free_value (ret_value);
if (ECMA_IS_VALUE_ERROR (ecma_module_parse_referenced_modules ()))
{
ecma_bytecode_deref (bytecode_p);
return ECMA_VALUE_ERROR;
}
module_p->compiled_code_p = bytecode_data_p;
module_p->compiled_code_p = bytecode_p;
module_p->state = ECMA_MODULE_STATE_PARSED;
return ECMA_VALUE_EMPTY;
} /* ecma_module_parse */
/**
* Parses all referenced modules.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
ecma_value_t
ecma_module_parse_modules (void)
{
ecma_module_t *current_p = JERRY_CONTEXT (ecma_modules_p);
while (current_p != NULL)
{
ecma_value_t ret_value = ecma_module_parse (current_p);
if (ECMA_IS_VALUE_ERROR (ret_value))
{
return ret_value;
}
JERRY_ASSERT (ecma_is_value_empty (ret_value));
current_p = current_p->next_p;
}
return ECMA_VALUE_EMPTY;
} /* ecma_module_parse_modules */
/**
* Checks if indirect exports in the current context are resolvable.
* Note: See 15.2.1.16.4 / 9.
*
* @return ECMA_VALUE_ERROR - if an error occured
* ECMA_VALUE_EMPTY - otherwise
*/
ecma_value_t
ecma_module_check_indirect_exports (void)
{
ecma_module_node_t *indirect_export_p = JERRY_CONTEXT (module_top_context_p)->indirect_exports_p;
while (indirect_export_p != NULL)
{
ecma_module_names_t *name_p = indirect_export_p->module_names_p;
while (name_p != NULL)
{
ecma_module_record_t record;
ecma_value_t result = ecma_module_resolve_export (indirect_export_p->module_request_p,
name_p->local_name_p,
&record);
if (ECMA_IS_VALUE_ERROR (result))
{
return result;
}
if (record.module_p == NULL)
{
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Ambiguous indirect export request."));
}
name_p = name_p->next_p;
}
indirect_export_p = indirect_export_p->next_p;
}
return ECMA_VALUE_EMPTY;
} /* ecma_module_check_indirect_exports */
/**
* Cleans up a list of module names.
*/
@@ -940,51 +1083,60 @@ ecma_module_release_module_nodes (ecma_module_node_t *module_node_p) /**< first
} /* ecma_module_release_module_nodes */
/**
* Cleans up a module context.
*/
static void
ecma_module_release_module_context (ecma_module_context_t *module_context_p) /**< modle context */
{
ecma_module_release_module_nodes (module_context_p->imports_p);
ecma_module_release_module_nodes (module_context_p->local_exports_p);
ecma_module_release_module_nodes (module_context_p->indirect_exports_p);
ecma_module_release_module_nodes (module_context_p->star_exports_p);
jmem_heap_free_block (module_context_p, sizeof (ecma_module_context_t));
} /* ecma_module_release_module_context */
/**
* Cleans up a module structure.
* Cleans up and releases a module structure including all referenced modules.
*/
static void
ecma_module_release_module (ecma_module_t *module_p) /**< module */
{
ecma_module_state_t state = module_p->state;
ecma_deref_ecma_string (module_p->path_p);
#ifndef JERRY_NDEBUG
module_p->path_p = NULL;
#endif /* JERRY_NDEBUG */
if (module_p->namespace_object_p != NULL)
{
/* The module structure keeps a strong reference to the namespace object, which will require an extra GC call. */
JERRY_CONTEXT (ecma_gc_new_objects)++;
ecma_deref_object (module_p->namespace_object_p);
#ifndef JERRY_NDEBUG
module_p->namespace_object_p = NULL;
#endif /* JERRY_NDEBUG */
}
if (module_p->state == ECMA_MODULE_STATE_NATIVE)
if (state == ECMA_MODULE_STATE_NATIVE)
{
goto finished;
}
if (module_p->state >= ECMA_MODULE_STATE_PARSING)
if (state >= ECMA_MODULE_STATE_PARSING)
{
ecma_module_release_module_context (module_p->context_p);
ecma_module_release_module_nodes (module_p->imports_p);
ecma_module_release_module_nodes (module_p->local_exports_p);
ecma_module_release_module_nodes (module_p->indirect_exports_p);
ecma_module_release_module_nodes (module_p->star_exports_p);
}
if (module_p->state >= ECMA_MODULE_STATE_EVALUATING)
if (state == ECMA_MODULE_STATE_ROOT)
{
goto finished;
}
if (state >= ECMA_MODULE_STATE_EVALUATING)
{
/* The module structure keeps a strong reference to the module scope, which will require an extra GC call. */
JERRY_CONTEXT (ecma_gc_new_objects)++;
ecma_deref_object (module_p->scope_p);
}
if (module_p->state >= ECMA_MODULE_STATE_PARSED
&& module_p->state < ECMA_MODULE_STATE_EVALUATED)
if (state >= ECMA_MODULE_STATE_PARSED
&& state < ECMA_MODULE_STATE_EVALUATED)
{
ecma_bytecode_deref (module_p->compiled_code_p);
#ifndef JERRY_NDEBUG
module_p->compiled_code_p = NULL;
#endif /* JERRY_NDEBUG */
}
finished:
@@ -992,25 +1144,16 @@ finished:
} /* ecma_module_release_module */
/**
* Cleans up all modules if the current context is the root context.
* Cleans up and releases a module list.
*/
void
ecma_module_cleanup (void)
ecma_module_cleanup (ecma_module_t *head_p) /**< module */
{
if (JERRY_CONTEXT (module_top_context_p)->parent_p != NULL)
while (head_p != NULL)
{
return;
ecma_module_t *next_p = head_p->next_p;
ecma_module_release_module (head_p);
head_p = next_p;
}
ecma_module_t *current_p = JERRY_CONTEXT (ecma_modules_p);
while (current_p != NULL)
{
ecma_module_t *next_p = current_p->next_p;
ecma_module_release_module (current_p);
current_p = next_p;
}
JERRY_CONTEXT (module_top_context_p) = NULL;
} /* ecma_module_cleanup */
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
+39 -47
View File
@@ -16,11 +16,11 @@
#ifndef ECMA_MODULE_H
#define ECMA_MODULE_H
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
#include "common.h"
#include "ecma-globals.h"
#if ENABLED (JERRY_MODULE_SYSTEM)
#define ECMA_MODULE_MAX_PATH 255u
/**
@@ -35,31 +35,6 @@ typedef struct ecma_module_names
ecma_string_t *local_name_p; /**< Local name of the item */
} 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
*/
@@ -71,21 +46,36 @@ typedef enum
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_ROOT = 6, /**< module is a root module */
} ecma_module_state_t;
/**
* Module structure storing an instance of a module
*/
struct ecma_module
typedef struct ecma_module
{
struct ecma_module *next_p; /**< next linked list node */
ecma_module_state_t state; /**< state of the mode */
ecma_string_t *path_p; /**< path of the module */
ecma_module_context_t *context_p; /**< module context of the module */
ecma_compiled_code_t *compiled_code_p; /**< compiled code of the module */
ecma_object_t *scope_p; /**< lexica lenvironment of the module */
ecma_object_t *namespace_object_p; /**< namespace import object of the module */
};
/* TODO(dbatyai): These could be compressed pointers */
struct ecma_module *next_p; /**< next module in the list */
struct ecma_module_node *imports_p; /**< import requests of the module */
struct ecma_module_node *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*/
ecma_string_t *path_p; /**< path of the module */
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
ecma_object_t *scope_p; /**< lexical lenvironment of the module */
ecma_object_t *namespace_object_p; /**< namespace object of the module */
ecma_module_state_t state; /**< evaluation state of the 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;
/**
* A record that can be used to store {module, identifier} pairs
@@ -126,19 +116,21 @@ void ecma_module_resolve_stack_push (ecma_module_resolve_stack_t **stack_p,
ecma_string_t *const export_name_p);
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,
prop_length_t size);
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_string_t *ecma_module_create_normalized_path (const lit_utf8_byte_t *char_p,
lit_utf8_size_t size,
ecma_string_t *const base_path_p);
ecma_value_t ecma_module_connect_imports (void);
ecma_value_t ecma_module_parse_modules (void);
ecma_value_t ecma_module_check_indirect_exports (void);
ecma_module_t *ecma_module_find_module (ecma_string_t *const path_p);
ecma_module_t *ecma_module_find_native_module (ecma_string_t *const path_p);
ecma_value_t ecma_module_parse_referenced_modules (void);
ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
void ecma_module_initialize_context (ecma_string_t *root_path_p);
void ecma_module_cleanup_context (void);
void ecma_module_release_module_nodes (ecma_module_node_t *module_node_p);
void ecma_module_cleanup (void);
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
void ecma_module_cleanup (ecma_module_t *head_p);
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
#endif /* !ECMA_MODULE_H */
+5 -5
View File
@@ -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++)
{
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (prop_iter_p->types[i]);
if (type != ECMA_PROPERTY_TYPE_SPECIAL)
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
{
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
named_property_count++;
}
}
@@ -148,11 +147,13 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
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;
}
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;
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i],
@@ -245,7 +246,6 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
uint32_t mask = hashmap_p->max_property_count - 1;
entry_index &= mask;
#ifndef JERRY_NDEBUG
/* See the comment for this variable in ecma_property_hashmap_create. */
uint32_t start_entry_index = entry_index;
@@ -72,7 +72,6 @@ void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_
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,
jmem_cpointer_t *property_real_name_cp);
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */
@@ -17,12 +17,9 @@
#include "ecma-builtins.h"
#include "ecma-iterator-object.h"
#include "ecma-typedarray-object.h"
#include "ecma-arraybuffer-object.h"
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
#if !ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
#error "Iterator builtin requires ES2015 symbol builtin"
#endif /* !ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
#if ENABLED (JERRY_ESNEXT)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -82,42 +79,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);
uint32_t length;
/* 8 - 9. */
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
if (ecma_is_typedarray (ecma_make_object_value (array_object_p)))
/* 8. */
ecma_length_t length;
if (ecma_object_is_typedarray (array_object_p))
{
/* 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_MSG ("ArrayBuffer has been detached."));
}
/* b. */
length = ecma_typedarray_get_length (array_object_p);
}
else
{
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
ecma_value_t len_value = ecma_op_object_get (array_object_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH));
ecma_value_t len_value = ecma_op_object_get_length (array_object_p, &length);
if (ECMA_IS_VALUE_ERROR (len_value))
{
return len_value;
}
ecma_number_t length_number;
ecma_value_t length_value = ecma_get_number (len_value, &length_number);
if (ECMA_IS_VALUE_ERROR (length_value))
{
ecma_free_value (len_value);
return length_value;
}
length = ecma_number_to_uint32 (length_number);
ecma_free_value (len_value);
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
uint32_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
ecma_length_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
{
@@ -128,12 +114,12 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
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,
prop_name_p,
ecma_make_uint32_value (index),
ecma_make_length_value (index),
true);
JERRY_ASSERT (ecma_is_value_true (put_result));
@@ -153,20 +139,16 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
}
/* 7. */
uint8_t iterator_type = ext_obj_p->u.pseudo_array.extra_info;
uint8_t iterator_kind = ext_obj_p->u.pseudo_array.extra_info;
if (iterator_type == ECMA_ITERATOR_KEYS)
if (iterator_kind == ECMA_ITERATOR_KEYS)
{
/* 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);
}
/* 13. */
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
/* 14. */
ecma_value_t get_value = ecma_op_object_get (array_object_p, index_string_p);
ecma_deref_ecma_string (index_string_p);
ecma_value_t get_value = ecma_op_object_get_by_index (array_object_p, index);
/* 15. */
if (ECMA_IS_VALUE_ERROR (get_value))
@@ -177,19 +159,19 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
ecma_value_t result;
/* 16. */
if (iterator_type == ECMA_ITERATOR_VALUES)
if (iterator_kind == ECMA_ITERATOR_VALUES)
{
result = ecma_create_iter_result_object (get_value, ECMA_VALUE_FALSE);
}
else
{
/* 17.a */
JERRY_ASSERT (iterator_type == ECMA_ITERATOR_KEYS_VALUES);
JERRY_ASSERT (iterator_kind == ECMA_ITERATOR_ENTRIES);
/* 17.b */
ecma_value_t entry_array_value;
entry_array_value = ecma_create_array_from_iter_element (get_value,
ecma_make_uint32_value (index));
ecma_make_length_value (index));
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
ecma_free_value (entry_array_value);
@@ -206,4 +188,4 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
* @}
*/
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -19,7 +19,7 @@
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
@@ -29,6 +29,6 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
* (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)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.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.
*/
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#if ENABLED (JERRY_ESNEXT)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h"
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
#include "ecma-builtin-internal-routines-template.inc.h"
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,66 @@
/* 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.
*/
/*
* Array.prototype[@@unscopables] built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ESNEXT)
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
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)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
File diff suppressed because it is too large Load Diff
@@ -29,6 +29,13 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
ECMA_BUILTIN_ID_ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if ENABLED (JERRY_ESNEXT)
/* ECMA-262 v6, 22.1.3.31 */
OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
/* Number properties:
* (property name, object pointer getter) */
@@ -39,8 +46,10 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
/* Routine properties:
* (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)
#if !ENABLED (JERRY_ESNEXT)
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_STRING, 0, 0)
#endif /* !ENABLED (JERRY_ESNEXT) */
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_POP, ECMA_ARRAY_PROTOTYPE_POP, 0, 0)
@@ -60,18 +69,25 @@ ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ECMA_ARRAY_PROTOTYPE_FOR_EACH, 2, 1)
ROUTINE (LIT_MAGIC_STRING_MAP, ECMA_ARRAY_PROTOTYPE_MAP, 2, 1)
ROUTINE (LIT_MAGIC_STRING_FILTER, ECMA_ARRAY_PROTOTYPE_FILTER, 2, 1)
/* Note these 2 routines must be in this order */
ROUTINE (LIT_MAGIC_STRING_REDUCE, ECMA_ARRAY_PROTOTYPE_REDUCE, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_REDUCE_RIGHT_UL, ECMA_ARRAY_PROTOTYPE_REDUCE_RIGHT, NON_FIXED, 1)
#if ENABLED (JERRY_ES2015_BUILTIN)
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)
#if ENABLED (JERRY_ESNEXT)
ROUTINE (LIT_MAGIC_STRING_FIND, ECMA_ARRAY_PROTOTYPE_FIND, 2, 1)
ROUTINE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_ARRAY_PROTOTYPE_FIND_INDEX, 2, 1)
#endif /* ENABLED (JERRY_ES2015_BUILTIN) */
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
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_ENTRIES, ECMA_ARRAY_PROTOTYPE_ENTRIES, 0, 0)
ROUTINE (LIT_MAGIC_STRING_VALUES, ECMA_ARRAY_PROTOTYPE_VALUES, 0, 0)
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ECMA_ARRAY_PROTOTYPE_SYMBOL_ITERATOR, 0, 0)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
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)
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */
@@ -15,14 +15,17 @@
#include "ecma-alloc.h"
#include "ecma-builtins.h"
#include "ecma-builtin-helpers.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 "ecma-array-object.h"
#include "ecma-try-catch-macro.h"
#include "jcontext.h"
#include "jrt.h"
#if ENABLED (JERRY_BUILTIN_ARRAY)
@@ -30,6 +33,25 @@
#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_ARRAY_ROUTINE_START = 0,
ECMA_ARRAY_ROUTINE_IS_ARRAY,
#if ENABLED (JERRY_ESNEXT)
ECMA_ARRAY_ROUTINE_FROM,
ECMA_ARRAY_ROUTINE_OF,
ECMA_ARRAY_ROUTINE_SPECIES_GET
#endif /* ENABLED (JERRY_ESNEXT) */
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array.inc.h"
#define BUILTIN_UNDERSCORED_ID array
#include "ecma-builtin-internal-routines-template.inc.h"
@@ -44,63 +66,519 @@
* @{
*/
#if ENABLED (JERRY_ESNEXT)
/**
* The Array object's 'isArray' routine
* The Array object's 'from' routine
*
* See also:
* ECMA-262 v5, 15.4.3.2
* ECMA-262 v6, 22.1.2.1
*
* @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 */
ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
JERRY_UNUSED (this_arg);
ecma_value_t is_array = ECMA_VALUE_FALSE;
/* 1. */
ecma_value_t constructor = this_arg;
ecma_value_t call_this_arg = ECMA_VALUE_UNDEFINED;
ecma_value_t items = arguments_list_p[0];
ecma_value_t mapfn = (arguments_list_len > 1) ? arguments_list_p[1] : ECMA_VALUE_UNDEFINED;
if (ecma_is_value_object (arg))
/* 2. */
ecma_object_t *mapfn_obj_p = NULL;
/* 3. */
if (!ecma_is_value_undefined (mapfn))
{
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_ARRAY_UL)
/* 3.a */
if (!ecma_op_is_callable (mapfn))
{
is_array = ECMA_VALUE_TRUE;
return ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable."));
}
/* 3.b */
if (arguments_list_len > 2)
{
call_this_arg = arguments_list_p[2];
}
/* 3.c */
mapfn_obj_p = ecma_get_object_from_value (mapfn);
}
/* 4. */
ecma_value_t using_iterator = ecma_op_get_method_by_symbol_id (items, LIT_GLOBAL_SYMBOL_ITERATOR);
/* 5. */
if (ECMA_IS_VALUE_ERROR (using_iterator))
{
return using_iterator;
}
ecma_value_t ret_value = ECMA_VALUE_ERROR;
/* 6. */
if (!ecma_is_value_undefined (using_iterator))
{
ecma_object_t *array_obj_p;
/* 6.a */
if (ecma_is_constructor (constructor))
{
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
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))
{
ecma_free_value (using_iterator);
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null 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
{
/* 6.b */
array_obj_p = ecma_op_new_array_object (0);
}
/* 6.d */
ecma_value_t next_method;
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator, &next_method);
ecma_free_value (using_iterator);
/* 6.e */
if (ECMA_IS_VALUE_ERROR (iterator))
{
ecma_deref_object (array_obj_p);
return iterator;
}
/* 6.f */
uint32_t k = 0;
/* 6.g */
while (true)
{
/* 6.g.ii */
ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
/* 6.g.iii */
if (ECMA_IS_VALUE_ERROR (next))
{
goto iterator_cleanup;
}
/* 6.g.iii */
if (ecma_is_value_false (next))
{
/* 6.g.iv.1 */
ecma_value_t len_value = ecma_make_uint32_value (k);
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
len_value,
true);
ecma_free_value (len_value);
/* 6.g.iv.2 */
if (ECMA_IS_VALUE_ERROR (set_status))
{
goto iterator_cleanup;
}
ecma_free_value (iterator);
ecma_free_value (next_method);
/* 6.g.iv.3 */
return ecma_make_object_value (array_obj_p);
}
/* 6.g.v */
ecma_value_t next_value = ecma_op_iterator_value (next);
ecma_free_value (next);
/* 6.g.vi */
if (ECMA_IS_VALUE_ERROR (next_value))
{
goto iterator_cleanup;
}
ecma_value_t mapped_value;
/* 6.g.vii */
if (mapfn_obj_p != NULL)
{
/* 6.g.vii.1 */
ecma_value_t args_p[2] = { next_value, ecma_make_uint32_value (k) };
/* 6.g.vii.3 */
mapped_value = ecma_op_function_call (mapfn_obj_p, call_this_arg, args_p, 2);
ecma_free_value (args_p[1]);
ecma_free_value (next_value);
/* 6.g.vii.2 */
if (ECMA_IS_VALUE_ERROR (mapped_value))
{
ecma_op_iterator_close (iterator);
goto iterator_cleanup;
}
}
else
{
/* 6.g.viii */
mapped_value = next_value;
}
/* 6.g.ix */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
ecma_free_value (mapped_value);
/* 6.g.x */
if (ECMA_IS_VALUE_ERROR (set_status))
{
ecma_op_iterator_close (iterator);
goto iterator_cleanup;
}
/* 6.g.xi */
k++;
}
iterator_cleanup:
ecma_free_value (iterator);
ecma_free_value (next_method);
ecma_deref_object (array_obj_p);
return ret_value;
}
/* 8. */
ecma_value_t array_like = ecma_op_to_object (items);
/* 9. */
if (ECMA_IS_VALUE_ERROR (array_like))
{
return array_like;
}
ecma_object_t *array_like_obj_p = ecma_get_object_from_value (array_like);
/* 10. */
ecma_length_t len;
ecma_value_t len_value = ecma_op_object_get_length (array_like_obj_p, &len);
/* 11. */
if (ECMA_IS_VALUE_ERROR (len_value))
{
goto cleanup;
}
/* 12. */
ecma_object_t *array_obj_p;
/* 12.a */
if (ecma_is_constructor (constructor))
{
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
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))
{
ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null to object"));
goto cleanup;
}
/* 14. */
if (ECMA_IS_VALUE_ERROR (array))
{
goto cleanup;
}
array_obj_p = ecma_get_object_from_value (array);
}
else
{
/* 13.a */
array_obj_p = ecma_op_new_array_object_from_length (len);
if (JERRY_UNLIKELY (array_obj_p == NULL))
{
goto cleanup;
}
}
return is_array;
} /* ecma_builtin_array_object_is_array */
/* 15. */
ecma_length_t k = 0;
/* 16. */
while (k < len)
{
/* 16.b */
ecma_value_t k_value = ecma_op_object_get_by_index (array_like_obj_p, k);
/* 16.c */
if (ECMA_IS_VALUE_ERROR (k_value))
{
goto construct_cleanup;
}
ecma_value_t mapped_value;
/* 16.d */
if (mapfn_obj_p != NULL)
{
/* 16.d.i */
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);
ecma_free_value (args_p[1]);
ecma_free_value (k_value);
/* 16.d.ii */
if (ECMA_IS_VALUE_ERROR (mapped_value))
{
goto construct_cleanup;
}
}
else
{
/* 16.e */
mapped_value = k_value;
}
/* 16.f */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
ecma_free_value (mapped_value);
/* 16.g */
if (ECMA_IS_VALUE_ERROR (set_status))
{
goto construct_cleanup;
}
/* 16.h */
k++;
}
/* 17. */
len_value = ecma_make_length_value (k);
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
len_value,
true);
ecma_free_value (len_value);
/* 18. */
if (ECMA_IS_VALUE_ERROR (set_status))
{
goto construct_cleanup;
}
/* 19. */
ecma_deref_object (array_like_obj_p);
return ecma_make_object_value (array_obj_p);
construct_cleanup:
ecma_deref_object (array_obj_p);
cleanup:
ecma_deref_object (array_like_obj_p);
return ret_value;
} /* ecma_builtin_array_object_from */
/**
* The Array object's 'of' routine
*
* See also:
* ECMA-262 v6, 22.1.2.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
if (!ecma_is_constructor (this_arg))
{
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 ret_val = ecma_op_function_construct (ecma_get_object_from_value (this_arg),
ecma_get_object_from_value (this_arg),
&len,
1);
if (ECMA_IS_VALUE_ERROR (ret_val))
{
ecma_free_value (len);
return ret_val;
}
uint32_t k = 0;
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;
while (k < arguments_list_len)
{
ecma_value_t define_status = ecma_builtin_helper_def_prop_by_index (obj_p,
k,
arguments_list_p[k],
prop_status_flags);
if (ECMA_IS_VALUE_ERROR (define_status))
{
ecma_free_value (len);
ecma_deref_object (obj_p);
return define_status;
}
k++;
}
ret_val = ecma_op_object_put (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
len,
true);
ecma_free_value (len);
if (ECMA_IS_VALUE_ERROR (ret_val))
{
ecma_deref_object (obj_p);
return ret_val;
}
return ecma_make_object_value (obj_p);
} /* ecma_builtin_array_object_of */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* 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_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);
return ecma_builtin_array_dispatch_construct (arguments_list_p, arguments_list_len);
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_MSG ("Invalid array length."));
}
return ecma_make_object_value (ecma_op_new_array_object (num_uint32));
} /* ecma_builtin_array_dispatch_call */
/**
* 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_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);
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true);
#if !ENABLED (JERRY_ESNEXT)
return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
#else /* ENABLED (JERRY_ESNEXT) */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
if (proto_p == NULL)
{
return ECMA_VALUE_ERROR;
}
ecma_value_t result = ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
if (ECMA_IS_VALUE_ERROR (result))
{
ecma_deref_object (proto_p);
return 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;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* 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 */
{
switch (builtin_routine_id)
{
case ECMA_ARRAY_ROUTINE_IS_ARRAY:
{
JERRY_UNUSED (this_arg);
return arguments_number > 0 ? ecma_is_value_array (arguments_list_p[0]) : ECMA_VALUE_FALSE;
}
#if ENABLED (JERRY_ESNEXT)
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);
}
#endif /* ENABLED (JERRY_ESNEXT) */
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_array_dispatch_routine */
/**
* @}
* @}
@@ -32,14 +32,28 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
/* Number properties:
* (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.3 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_ARRAY_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
/* Routine properties:
* (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_ESNEXT)
ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
/* ECMA-262 v6, 22.1.2.5 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
ECMA_ARRAY_ROUTINE_SPECIES_GET,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#endif /* !(ENABLED (JERRY_BUILTIN_ARRAY)) */
@@ -15,16 +15,18 @@
#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-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)
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -61,7 +63,11 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
{
ecma_length_t len = ecma_arraybuffer_get_length (object_p);
if (ecma_arraybuffer_is_detached (object_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
}
uint32_t len = ecma_arraybuffer_get_length (object_p);
return ecma_make_uint32_value (len);
}
@@ -74,15 +80,15 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
* The ArrayBuffer.prototype object's 'slice' routine
*
* See also:
* ES2015, 24.1.4.3
* ECMA-262 v11, 24.1.4.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
const ecma_value_t *argument_list_p, /**< arguments list */
uint32_t arguments_number) /**< number of arguments */
{
if (!ecma_is_value_object (this_arg))
{
@@ -91,50 +97,134 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
/* 2. */
if (!ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object."));
}
ecma_length_t len = ecma_arraybuffer_get_length (object_p);
/* TODO: step 3. if SharedArrayBuffer will be implemented */
ecma_length_t start = 0, end = len;
/* 4. */
if (ecma_arraybuffer_is_detached (object_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
}
/* 5. */
uint32_t len = ecma_arraybuffer_get_length (object_p);
uint32_t start = 0;
uint32_t end = len;
if (arguments_number > 0)
{
/* 6-7. */
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[0],
len,
&start)))
{
return ECMA_VALUE_ERROR;
}
if (arguments_number > 1 && !ecma_is_value_undefined (argument_list_p[1]))
{
/* 8-9 .*/
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[1],
len,
&end)))
{
return ECMA_VALUE_ERROR;
}
}
}
/* 10. */
uint32_t new_len = (end >= start) ? (end - start) : 0;
/* 11. */
ecma_value_t ctor = ecma_op_species_constructor (object_p, ECMA_BUILTIN_ID_ARRAYBUFFER);
if (ECMA_IS_VALUE_ERROR (ctor))
{
return ctor;
}
/* 12. */
ecma_object_t *ctor_obj_p = ecma_get_object_from_value (ctor);
ecma_value_t new_len_value = ecma_make_uint32_value (new_len);
ecma_value_t new_arraybuffer = ecma_op_function_construct (ctor_obj_p, ctor_obj_p, &new_len_value, 1);
ecma_deref_object (ctor_obj_p);
ecma_free_value (new_len_value);
if (ECMA_IS_VALUE_ERROR (new_arraybuffer))
{
return new_arraybuffer;
}
ecma_object_t *new_arraybuffer_p = ecma_get_object_from_value (new_arraybuffer);
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
ECMA_OP_TO_NUMBER_TRY_CATCH (start_num,
arg1,
ret_value);
start = ecma_builtin_helper_array_index_normalize (start_num, len, false);
if (!ecma_is_value_undefined (arg2))
/* 13. */
if (!ecma_object_class_is (new_arraybuffer_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
{
ECMA_OP_TO_NUMBER_TRY_CATCH (end_num,
arg2,
ret_value);
end = ecma_builtin_helper_array_index_normalize (end_num, len, false);
ECMA_OP_TO_NUMBER_FINALIZE (end_num);
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Return value is not an ArrayBuffer object."));
goto free_new_arraybuffer;
}
ECMA_OP_TO_NUMBER_FINALIZE (start_num);
/* TODO: step 14. if SharedArrayBuffer will be implemented */
if (ret_value != ECMA_VALUE_EMPTY)
/* 15. */
if (ecma_arraybuffer_is_detached (new_arraybuffer_p))
{
return ret_value;
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Return ArrayBuffer has been detached."));
goto free_new_arraybuffer;
}
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);
/* 16. */
if (ecma_op_same_value (new_arraybuffer, this_arg))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer subclass returned this from species constructor"));
goto free_new_arraybuffer;
}
/* 17. */
if (ecma_arraybuffer_get_length (new_arraybuffer_p) < new_len)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Derived ArrayBuffer constructor created a too small buffer."));
goto free_new_arraybuffer;
}
/* 19. */
if (ecma_arraybuffer_is_detached (object_p))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Original ArrayBuffer has been detached."));
goto free_new_arraybuffer;
}
/* 20. */
lit_utf8_byte_t *old_buf = ecma_arraybuffer_get_buffer (object_p);
/* 21. */
lit_utf8_byte_t *new_buf = ecma_arraybuffer_get_buffer (new_arraybuffer_p);
/* 22. */
memcpy (new_buf, old_buf + start, new_len);
return ecma_make_object_value (new_arraybuffer_p);
free_new_arraybuffer:
if (ret_value != ECMA_VALUE_EMPTY)
{
ecma_deref_object (new_arraybuffer_p);
}
else
{
/* 23. */
ret_value = ecma_make_object_value (new_arraybuffer_p);
}
return ret_value;
} /* ecma_builtin_arraybuffer_prototype_object_slice */
/**
@@ -143,4 +233,4 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
* @}
*/
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
@@ -19,7 +19,7 @@
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
/* Object properties:
* (property name, object pointer getter) */
@@ -31,19 +31,17 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
/* Readonly accessor properties */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
ecma_builtin_arraybuffer_prototype_bytelength_getter,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
/* ECMA-262 v6, 24.1.4.4 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
/* Routine properties:
* (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 /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -19,10 +19,11 @@
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-arraybuffer-object.h"
#include "ecma-try-catch-macro.h"
#include "ecma-dataview-object.h"
#include "ecma-typedarray-object.h"
#include "jrt.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -55,11 +56,8 @@ ecma_builtin_arraybuffer_object_is_view (ecma_value_t this_arg, /**< 'this' argu
ecma_value_t arg) /**< argument 1 */
{
JERRY_UNUSED (this_arg);
JERRY_UNUSED (arg);
/* TODO: if arg has [[ViewArrayBuffer]], return true */
return ECMA_VALUE_FALSE;
return ecma_make_boolean_value (ecma_is_typedarray (arg) || ecma_is_dataview (arg));
} /* ecma_builtin_arraybuffer_object_is_view */
/**
@@ -73,7 +71,7 @@ ecma_builtin_arraybuffer_object_is_view (ecma_value_t this_arg, /**< 'this' argu
*/
ecma_value_t
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);
@@ -87,17 +85,29 @@ ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /*
*/
ecma_value_t
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);
return ecma_op_create_arraybuffer_object (arguments_list_p, arguments_list_len);
} /* ecma_builtin_arraybuffer_dispatch_construct */
/**
* 24.1.3.3 get ArrayBuffer [ @@species ] accessor
*
* @return ecma_value
* returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) /**< This Value */
{
return ecma_copy_value (this_value);
} /* ecma_builtin_arraybuffer_species_get */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
@@ -19,14 +19,14 @@
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
/* Number properties:
* (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Object properties:
* (property name, object pointer getter) */
@@ -35,12 +35,21 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
ECMA_PROPERTY_FIXED)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
/* ES2015 24.1.3.1 */
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
/* ES2015 24.1.3.3 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
ecma_builtin_arraybuffer_species_get,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,43 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#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
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup asyncfunctionprototype ECMA AsyncFunction.prototype object built-in
* @{
*/
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,36 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
/* 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)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,74 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#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 */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,41 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
/* 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,
ECMA_PROPERTY_FIXED)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,74 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#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 asyncgenerator 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 */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,41 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
/* 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)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,147 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#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 asyncgenerator 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_get_object_type (object_p) == ECMA_OBJECT_TYPE_CLASS)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_ASYNC_GENERATOR_UL)
{
executable_object_p = (vm_executable_object_t *) ext_object_p;
}
}
}
if (executable_object_p == NULL)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an async generator object."));
}
if (executable_object_p->extended_object.u.class_prop.extra_info & 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 */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,45 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
/* 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)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,43 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#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
* @{
*/
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,41 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
/* 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)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,63 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#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 */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,30 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
/* 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)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,134 @@
/* 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 ENABLED (JERRY_BUILTIN_BIGINT)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/**
* This object has a custom dispatch function.
*/
#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, LIT_MAGIC_STRING_BIGINT_UL))
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.class_prop.u.value));
return ecma_copy_value (ext_object_p->u.class_prop.u.value);
}
}
return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt value expected."));
} /* 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 */
{
ecma_value_t bigint = ecma_builtin_bigint_prototype_object_value_of (this_arg);
if (ECMA_IS_VALUE_ERROR (bigint))
{
return bigint;
}
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)))
{
ecma_free_value (bigint);
return ECMA_VALUE_ERROR;
}
if (arg_num < 2 || arg_num > 36)
{
ecma_free_value (bigint);
return ecma_raise_range_error (ECMA_ERR_MSG ("Radix must be between 2 and 36."));
}
radix = (uint32_t) arg_num;
}
ecma_string_t *string_p = ecma_bigint_to_string (bigint, radix);
ecma_free_value (bigint);
if (string_p == NULL)
{
return ECMA_VALUE_ERROR;
}
return ecma_make_string_value (string_p);
} /* ecma_builtin_bigint_prototype_object_to_string */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
@@ -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.
*/
/*
* BigInt.prototype built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_BUILTIN_BIGINT)
/* Object properties:
* (property name, object pointer getter) */
/* ECMA-262 v11, 20.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
ECMA_BUILTIN_ID_BIGINT,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v11, 20.2.3.5 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
LIT_MAGIC_STRING_BIGINT_UL,
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_VALUE_OF_UL, ecma_builtin_bigint_prototype_object_value_of, 0, 0)
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ecma_builtin_bigint_prototype_object_to_string, NON_FIXED, 0)
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,80 @@
/* 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-builtins.h"
#include "ecma-exceptions.h"
#if ENABLED (JERRY_BUILTIN_BIGINT)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint.inc.h"
#define BUILTIN_UNDERSCORED_ID bigint
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup bigint ECMA BigInt object built-in
* @{
*/
/**
* Handle calling [[Call]] of built-in BigInt object
*
* See also:
* ECMA-262 v11, 20.2.1.1
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_bigint_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 value = (arguments_list_len == 0) ? ECMA_VALUE_UNDEFINED : arguments_list_p[0];
return ecma_bigint_to_bigint (value, true);
} /* ecma_builtin_bigint_dispatch_call */
/**
* Handle calling [[Construct]] of built-in BigInt object
*
* See also:
* ECMA-262 v11, 20.2.1
*
* @return ecma value
*/
ecma_value_t
ecma_builtin_bigint_dispatch_construct (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_raise_type_error (ECMA_ERR_MSG ("BigInt function is not a constructor."));
} /* ecma_builtin_bigint_dispatch_construct */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
@@ -0,0 +1,47 @@
/* 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.
*/
/*
* BigInt built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_BUILTIN_BIGINT)
/* Number properties:
* (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v11, 20.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v11, 20.2.1 */
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_BIGINT_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Object properties:
* (property name, object pointer getter) */
/* ECMA-262 v11, 20.2.2.3 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
ECMA_BUILTIN_ID_BIGINT_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -22,7 +22,6 @@
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-string-object.h"
#include "ecma-try-catch-macro.h"
#include "jrt.h"
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
@@ -30,6 +29,21 @@
#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_BOOLEAN_PROTOTYPE_ROUTINE_START = 0,
ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING,
ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-boolean-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID boolean_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
@@ -44,40 +58,6 @@
* @{
*/
/**
* The Boolean.prototype object's 'toString' routine
*
* See also:
* ECMA-262 v5, 15.6.4.2
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
ECMA_TRY_CATCH (value_of_ret,
ecma_builtin_boolean_prototype_object_value_of (this_arg),
ret_value);
if (ecma_is_value_true (value_of_ret))
{
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (value_of_ret));
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
}
ECMA_FINALIZE (value_of_ret);
return ret_value;
} /* ecma_builtin_boolean_prototype_object_to_string */
/**
* The Boolean.prototype object's 'valueOf' routine
*
@@ -111,6 +91,46 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Boolean object."));
} /* ecma_builtin_boolean_prototype_object_value_of */
/**
* Dispatcher of the built-in's routines
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_boolean_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_UNUSED (arguments_list_p);
ecma_value_t value_of_ret = ecma_builtin_boolean_prototype_object_value_of (this_arg);
if (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF)
{
return value_of_ret;
}
JERRY_ASSERT (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING);
if (ECMA_IS_VALUE_ERROR (value_of_ret))
{
return value_of_ret;
}
if (ecma_is_value_true (value_of_ret))
{
return ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
}
JERRY_ASSERT (ecma_is_value_false (value_of_ret));
return ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
} /* ecma_builtin_boolean_prototype_dispatch_routine */
/**
* @}
* @}
@@ -31,8 +31,8 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
/* Routine properties:
* (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_builtin_boolean_prototype_object_to_string, 0, 0)
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ecma_builtin_boolean_prototype_object_value_of, 0, 0)
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING, 0, 0)
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF, 0, 0)
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
@@ -22,7 +22,6 @@
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#include "jrt.h"
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
@@ -51,7 +50,7 @@
*/
ecma_value_t
ecma_builtin_boolean_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);
@@ -76,7 +75,7 @@ ecma_builtin_boolean_dispatch_call (const ecma_value_t *arguments_list_p, /**< a
*/
ecma_value_t
ecma_builtin_boolean_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);
@@ -32,10 +32,15 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
/* Number properties:
* (property name, object pointer getter) */
/* ECMA-262 v5, 15.6.3 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_BOOLEAN_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
@@ -13,14 +13,16 @@
* limitations under the License.
*/
#include "ecma-arraybuffer-object.h"
#include "ecma-exceptions.h"
#include "ecma-dataview-object.h"
#include "ecma-gc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
#ifdef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
#if !ENABLED (JERRY_BUILTIN_TYPEDARRAY)
#error "DataView builtin requires ES2015 TypedArray builtin"
#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
#endif /* !ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -35,7 +37,7 @@
*/
enum
{
ECMA_DATAVIEW_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
ECMA_DATAVIEW_PROTOTYPE_ROUTINE_START = 0,
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
ECMA_DATAVIEW_PROTOTYPE_BYTE_LENGTH_GETTER,
ECMA_DATAVIEW_PROTOTYPE_BYTE_OFFSET_GETTER,
@@ -50,6 +52,10 @@ enum
#if ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
ECMA_DATAVIEW_PROTOTYPE_GET_FLOAT64,
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
#if ENABLED (JERRY_BUILTIN_BIGINT)
ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64,
ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64,
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
ECMA_DATAVIEW_PROTOTYPE_SET_INT8,
ECMA_DATAVIEW_PROTOTYPE_SET_UINT8,
ECMA_DATAVIEW_PROTOTYPE_SET_UINT8_CLAMPED, /* unused value */
@@ -61,6 +67,10 @@ enum
#if ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64,
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
#if ENABLED (JERRY_BUILTIN_BIGINT)
ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64,
ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64,
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-dataview-prototype.inc.h"
@@ -110,11 +120,20 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this
}
case ECMA_DATAVIEW_PROTOTYPE_BYTE_LENGTH_GETTER:
{
if (ecma_arraybuffer_is_detached (obj_p->buffer_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
}
return ecma_make_uint32_value (obj_p->header.u.class_prop.u.length);
}
default:
{
JERRY_ASSERT (builtin_routine_id == ECMA_DATAVIEW_PROTOTYPE_BYTE_OFFSET_GETTER);
if (ecma_arraybuffer_is_detached (obj_p->buffer_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
}
return ecma_make_uint32_value (obj_p->byte_offset);
}
}
@@ -127,11 +146,11 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine identifier */
ecma_builtin_dataview_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 */
ecma_length_t arguments_number) /**< length of arguments' list */
uint32_t arguments_number) /**< length of arguments' list */
{
ecma_value_t byte_offset = arguments_number > 0 ? arguments_list_p[0] : ECMA_VALUE_UNDEFINED;
@@ -151,6 +170,10 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /
case ECMA_DATAVIEW_PROTOTYPE_GET_INT32:
case ECMA_DATAVIEW_PROTOTYPE_GET_UINT16:
case ECMA_DATAVIEW_PROTOTYPE_GET_UINT32:
#if ENABLED (JERRY_BUILTIN_BIGINT)
case ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64:
case ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64:
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
{
ecma_value_t little_endian = arguments_number > 1 ? arguments_list_p[1] : ECMA_VALUE_FALSE;
ecma_typedarray_type_t id = (ecma_typedarray_type_t) (builtin_routine_id - ECMA_DATAVIEW_PROTOTYPE_GET_INT8);
@@ -165,6 +188,10 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /
case ECMA_DATAVIEW_PROTOTYPE_SET_INT32:
case ECMA_DATAVIEW_PROTOTYPE_SET_UINT16:
case ECMA_DATAVIEW_PROTOTYPE_SET_UINT32:
#if ENABLED (JERRY_BUILTIN_BIGINT)
case ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64:
case ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64:
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
{
ecma_value_t value_to_set = arguments_number > 1 ? arguments_list_p[1] : ECMA_VALUE_UNDEFINED;
ecma_value_t little_endian = arguments_number > 2 ? arguments_list_p[2] : ECMA_VALUE_FALSE;
@@ -197,4 +224,4 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /
* @}
*/
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
@@ -19,7 +19,7 @@
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
/* Object properties:
* (property name, object pointer getter) */
@@ -29,12 +29,10 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
ECMA_BUILTIN_ID_DATAVIEW,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
/* ECMA-262 v6, 23.2.4.21 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
LIT_MAGIC_STRING_DATAVIEW_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -48,32 +46,38 @@ ROUTINE (LIT_MAGIC_STRING_GET_INT32_UL, ECMA_DATAVIEW_PROTOTYPE_GET_INT32, 2, 1)
ROUTINE (LIT_MAGIC_STRING_GET_UINT8_UL, ECMA_DATAVIEW_PROTOTYPE_GET_UINT8, 2, 1)
ROUTINE (LIT_MAGIC_STRING_GET_UINT16_UL, ECMA_DATAVIEW_PROTOTYPE_GET_UINT16, 2, 1)
ROUTINE (LIT_MAGIC_STRING_GET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_GET_UINT32, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32, 2, 2)
#if ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_64_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_64_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64, 2, 2)
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
ROUTINE (LIT_MAGIC_STRING_SET_INT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT8, 1, 1)
ROUTINE (LIT_MAGIC_STRING_SET_INT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT16, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_INT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT32, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_UINT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT8, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_UINT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT16, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT32, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_INT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT8, 1, 2)
ROUTINE (LIT_MAGIC_STRING_SET_INT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT16, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_INT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT32, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_UINT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT8, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_UINT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT16, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT32, 2, 2)
#if ENABLED (JERRY_BUILTIN_BIGINT)
ROUTINE (LIT_MAGIC_STRING_GET_BIGINT64, ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64, 2, 1)
ROUTINE (LIT_MAGIC_STRING_GET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64, 2, 1)
ROUTINE (LIT_MAGIC_STRING_SET_BIGINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64, 2, 2)
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
/* ECMA-262 v6, 24.2.4.1 */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 24.2.4.2 */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
ECMA_DATAVIEW_PROTOTYPE_BYTE_LENGTH_GETTER,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 24.2.4.3 */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_OFFSET_UL,
ECMA_DATAVIEW_PROTOTYPE_BYTE_OFFSET_GETTER,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -17,7 +17,7 @@
#include "ecma-exceptions.h"
#include "ecma-dataview-object.h"
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -43,7 +43,7 @@
*/
ecma_value_t
ecma_builtin_dataview_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);
@@ -57,7 +57,7 @@ ecma_builtin_dataview_dispatch_call (const ecma_value_t *arguments_list_p, /**<
*/
ecma_value_t
ecma_builtin_dataview_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 */
{
return ecma_op_dataview_create (arguments_list_p, arguments_list_len);
} /* ecma_builtin_dataview_dispatch_construct */
@@ -68,4 +68,4 @@ ecma_builtin_dataview_dispatch_construct (const ecma_value_t *arguments_list_p,
* @}
*/
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
@@ -19,15 +19,15 @@
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
/* Number properties:
* (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v6, 23.1.2 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
3,
ECMA_PROPERTY_FIXED)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 23.1 */
STRING_VALUE (LIT_MAGIC_STRING_NAME,
@@ -42,6 +42,6 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -19,10 +19,11 @@
#include "ecma-builtin-helpers.h"
#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#include "ecma-objects-general.h"
#if ENABLED (JERRY_BUILTIN_DATE)
@@ -45,7 +46,7 @@
*/
enum
{
ECMA_DATE_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
ECMA_DATE_PROTOTYPE_ROUTINE_START = 0,
ECMA_DATE_PROTOTYPE_GET_FULL_YEAR, /* ECMA-262 v5 15.9.5.10 */
ECMA_DATE_PROTOTYPE_GET_UTC_FULL_YEAR, /* ECMA-262 v5 15.9.5.11 */
@@ -91,13 +92,19 @@ enum
ECMA_DATE_PROTOTYPE_TO_STRING, /* ECMA-262 v5, 15.9.5.2 */
ECMA_DATE_PROTOTYPE_TO_DATE_STRING, /* ECMA-262 v5, 15.9.5.3 */
ECMA_DATE_PROTOTYPE_TO_TIME_STRING, /* ECMA-262 v5, 15.9.5.4 */
#if !ENABLED (JERRY_ESNEXT)
ECMA_DATE_PROTOTYPE_TO_UTC_STRING, /* ECMA-262 v5, 15.9.5.42 */
#endif /* ENABLED (JERRY_ESNEXT) */
ECMA_DATE_PROTOTYPE_TO_TIME_STRING, /* ECMA-262 v5, 15.9.5.4 */
ECMA_DATE_PROTOTYPE_TO_ISO_STRING, /* ECMA-262 v5, 15.9.5.43 */
ECMA_DATE_PROTOTYPE_GET_TIME, /* ECMA-262 v5, 15.9.5.9 */
ECMA_DATE_PROTOTYPE_SET_TIME, /* ECMA-262 v5, 15.9.5.27 */
ECMA_DATE_PROTOTYPE_TO_JSON, /* ECMA-262 v5, 15.9.5.44 */
#if ENABLED (JERRY_ESNEXT)
ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, /* ECMA-262 v6 20.3.4.45 */
#endif /* ENABLED (JERRY_ESNEXT) */
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date-prototype.inc.h"
@@ -126,59 +133,91 @@ enum
static ecma_value_t
ecma_builtin_date_prototype_to_json (ecma_value_t this_arg) /**< this argument */
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
/* 1. */
ECMA_TRY_CATCH (obj,
ecma_op_to_object (this_arg),
ret_value);
ecma_value_t obj = ecma_op_to_object (this_arg);
if (ECMA_IS_VALUE_ERROR (obj))
{
return obj;
}
/* 2. */
ECMA_TRY_CATCH (tv,
ecma_op_to_primitive (obj, ECMA_PREFERRED_TYPE_NUMBER),
ret_value);
ecma_value_t tv = ecma_op_to_primitive (obj, ECMA_PREFERRED_TYPE_NUMBER);
if (ECMA_IS_VALUE_ERROR (tv))
{
ecma_free_value (obj);
return tv;
}
/* 3. */
if (ecma_is_value_number (tv))
{
ecma_number_t num_value = ecma_get_number_from_value (tv);
ecma_free_value (tv);
if (ecma_number_is_nan (num_value) || ecma_number_is_infinity (num_value))
{
ret_value = ECMA_VALUE_NULL;
ecma_free_value (obj);
return ECMA_VALUE_NULL;
}
}
if (ecma_is_value_empty (ret_value))
else
{
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
/* 4. */
ECMA_TRY_CATCH (to_iso,
ecma_op_object_get_by_magic_id (value_obj_p, LIT_MAGIC_STRING_TO_ISO_STRING_UL),
ret_value);
/* 5. */
if (!ecma_op_is_callable (to_iso))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("'toISOString' is missing or not a function."));
}
/* 6. */
else
{
ecma_object_t *to_iso_obj_p = ecma_get_object_from_value (to_iso);
ret_value = ecma_op_function_call (to_iso_obj_p, this_arg, NULL, 0);
}
ECMA_FINALIZE (to_iso);
ecma_free_value (tv);
}
ECMA_FINALIZE (tv);
ECMA_FINALIZE (obj);
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
/* 4. */
ecma_value_t ret_value = ecma_op_invoke_by_magic_id (obj, LIT_MAGIC_STRING_TO_ISO_STRING_UL, NULL, 0);
ecma_deref_object (value_obj_p);
return ret_value;
} /* ecma_builtin_date_prototype_to_json */
#if ENABLED (JERRY_ESNEXT)
/**
* The Date.prototype object's toPrimitive routine
*
* See also:
* ECMA-262 v6, 20.3.4.45
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_to_primitive (ecma_value_t this_arg, /**< this argument */
ecma_value_t hint_arg) /**< {"default", "number", "string"} */
{
if (ecma_is_value_object (this_arg) && ecma_is_value_string (hint_arg))
{
ecma_string_t *hint_str_p = ecma_get_string_from_value (hint_arg);
ecma_preferred_type_hint_t hint = ECMA_PREFERRED_TYPE_NO;
if (hint_str_p == ecma_get_magic_string (LIT_MAGIC_STRING_STRING)
|| hint_str_p == ecma_get_magic_string (LIT_MAGIC_STRING_DEFAULT))
{
hint = ECMA_PREFERRED_TYPE_STRING;
}
else if (hint_str_p == ecma_get_magic_string (LIT_MAGIC_STRING_NUMBER))
{
hint = ECMA_PREFERRED_TYPE_NUMBER;
}
if (hint != ECMA_PREFERRED_TYPE_NO)
{
return ecma_op_general_object_ordinary_value (ecma_get_object_from_value (this_arg), hint);
}
}
return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type in toPrimitive."));
} /* ecma_builtin_date_prototype_to_primitive */
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Dispatch get date functions
*
@@ -192,7 +231,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
{
if (ecma_number_is_nan (date_num))
{
return ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
return ecma_make_nan_value ();
}
switch (builtin_routine_id)
@@ -302,10 +341,10 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
ecma_number_t date_num, /**< date converted to number */
const ecma_value_t arguments_list[], /**< list of arguments
* passed to routine */
ecma_length_t arguments_number) /**< length of arguments' list */
uint32_t arguments_number) /**< length of arguments' list */
{
ecma_number_t converted_number[4];
ecma_length_t conversions = 0;
uint32_t conversions = 0;
/* If the first argument is not specified, it is always converted to NaN. */
converted_number[0] = ecma_number_make_nan ();
@@ -354,17 +393,14 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
conversions = arguments_number;
}
for (ecma_length_t i = 0; i < conversions; i++)
for (uint32_t i = 0; i < conversions; i++)
{
ecma_value_t value = ecma_op_to_number (arguments_list[i]);
ecma_value_t value = ecma_op_to_number (arguments_list[i], &converted_number[i]);
if (ECMA_IS_VALUE_ERROR (value))
{
return value;
}
converted_number[i] = ecma_get_number_from_value (value);
ecma_free_value (value);
}
ecma_number_t day_part;
@@ -548,27 +584,33 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
* identifier */
ecma_builtin_date_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[], /**< list of arguments
* passed to routine */
ecma_length_t arguments_number) /**< length of arguments' list */
uint32_t arguments_number) /**< length of arguments' list */
{
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_JSON))
{
return ecma_builtin_date_prototype_to_json (this_arg);
}
#if ENABLED (JERRY_ESNEXT)
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_PRIMITIVE))
{
ecma_value_t argument = arguments_number > 0 ? arguments_list[0] : ECMA_VALUE_UNDEFINED;
return ecma_builtin_date_prototype_to_primitive (this_arg, argument);
}
#endif /* ENABLED (JERRY_ESNEXT) */
if (!ecma_is_value_object (this_arg)
|| !ecma_object_class_is (ecma_get_object_from_value (this_arg), LIT_MAGIC_STRING_DATE_UL))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Date object expected"));
return ecma_raise_type_error (ECMA_ERR_MSG ("'this' is not a Date object"));
}
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) ecma_get_object_from_value (this_arg);
ecma_number_t *prim_value_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t,
ext_object_p->u.class_prop.u.value);
@@ -579,16 +621,16 @@ ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**<
if (builtin_routine_id == ECMA_DATE_PROTOTYPE_SET_TIME)
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
ecma_number_t time_num;
if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (arguments_list[0], &time_num)))
{
return ECMA_VALUE_ERROR;
}
/* 1. */
ECMA_OP_TO_NUMBER_TRY_CATCH (time_num, arguments_list[0], ret_value);
*prim_value_p = ecma_date_time_clip (time_num);
ret_value = ecma_make_number_value (time_num);
ECMA_OP_TO_NUMBER_FINALIZE (time_num);
return ret_value;
return ecma_make_number_value (time_num);
}
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS)
@@ -637,15 +679,17 @@ ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**<
{
return ecma_date_value_to_date_string (*prim_value_p);
}
case ECMA_DATE_PROTOTYPE_TO_TIME_STRING:
#if !ENABLED (JERRY_ESNEXT)
case ECMA_DATE_PROTOTYPE_TO_UTC_STRING:
{
return ecma_date_value_to_time_string (*prim_value_p);
return ecma_date_value_to_utc_string (*prim_value_p);
}
#endif /* ENABLED (JERRY_ESNEXT) */
default:
{
JERRY_ASSERT (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_UTC_STRING);
JERRY_ASSERT (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_TIME_STRING);
return ecma_date_value_to_utc_string (*prim_value_p);
return ecma_date_value_to_time_string (*prim_value_p);
}
}
} /* ecma_builtin_date_prototype_dispatch_routine */
@@ -65,15 +65,27 @@ ROUTINE (LIT_MAGIC_STRING_SET_MONTH_UL, ECMA_DATE_PROTOTYPE_SET_MONTH, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_UTC_MONTH_UL, ECMA_DATE_PROTOTYPE_SET_UTC_MONTH, 2, 2)
ROUTINE (LIT_MAGIC_STRING_SET_FULL_YEAR_UL, ECMA_DATE_PROTOTYPE_SET_FULL_YEAR, NON_FIXED, 3)
ROUTINE (LIT_MAGIC_STRING_SET_UTC_FULL_YEAR_UL, ECMA_DATE_PROTOTYPE_SET_UTC_FULL_YEAR, NON_FIXED, 3)
ROUTINE (LIT_MAGIC_STRING_TO_UTC_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
ROUTINE (LIT_MAGIC_STRING_TO_ISO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_ISO_STRING, 0, 0)
ROUTINE (LIT_MAGIC_STRING_TO_JSON_UL, ECMA_DATE_PROTOTYPE_TO_JSON, 1, 1)
#if ENABLED (JERRY_ESNEXT)
ROUTINE_CONFIGURABLE_ONLY (LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, 1, 1)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if ENABLED (JERRY_BUILTIN_ANNEXB)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
#else /* !ENABLED (JERRY_ESNEXT) */
ROUTINE (LIT_MAGIC_STRING_TO_UTC_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
#if ENABLED (JERRY_BUILTIN_ANNEXB)
ROUTINE (LIT_MAGIC_STRING_TO_GMT_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
#endif /* !ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_ANNEXB)
ROUTINE (LIT_MAGIC_STRING_GET_YEAR_UL, ECMA_DATE_PROTOTYPE_GET_YEAR, 0, 0)
ROUTINE (LIT_MAGIC_STRING_SET_YEAR_UL, ECMA_DATE_PROTOTYPE_SET_YEAR, 1, 1)
ROUTINE (LIT_MAGIC_STRING_TO_GMT_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
File diff suppressed because it is too large Load Diff
@@ -28,12 +28,18 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
7,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
ROUTINE (LIT_MAGIC_STRING_PARSE, ecma_builtin_date_parse, 1, 1)
ROUTINE (LIT_MAGIC_STRING_UTC_U, ecma_builtin_date_utc, NON_FIXED, 7)
ROUTINE (LIT_MAGIC_STRING_NOW, ecma_builtin_date_now, 0, 0)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_DATE_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#endif /* ENABLED (JERRY_BUILTIN_DATE) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -20,9 +20,9 @@
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "lit-char-helpers.h"
#include "ecma-objects.h"
#include "ecma-string-object.h"
#include "ecma-try-catch-macro.h"
#include "jrt.h"
#include "lit-magic-strings.h"
@@ -43,6 +43,34 @@
* @{
*/
/**
* Helper method to get a property value from an error object
*
* @return ecma_string_t
*/
static ecma_string_t *
ecma_builtin_error_prototype_object_to_string_helper (ecma_object_t *obj_p, /**< error object */
lit_magic_string_id_t property_id, /**< property id */
lit_magic_string_id_t default_value) /**< default prop value */
{
ecma_value_t prop_value = ecma_op_object_get_by_magic_id (obj_p, property_id);
if (ECMA_IS_VALUE_ERROR (prop_value))
{
return NULL;
}
if (ecma_is_value_undefined (prop_value))
{
return ecma_get_magic_string (default_value);
}
ecma_string_t *ret_str_p = ecma_op_to_string (prop_value);
ecma_free_value (prop_value);
return ret_str_p;
} /* ecma_builtin_error_prototype_object_to_string_helper */
/**
* The Error.prototype object's 'toString' routine
*
@@ -55,125 +83,52 @@
static ecma_value_t
ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
/* 2. */
if (!ecma_is_value_object (this_arg))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object."));
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object."));
}
else
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_string_t *name_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p,
LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_ERROR_UL);
if (JERRY_UNLIKELY (name_string_p == NULL))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ECMA_TRY_CATCH (name_get_ret_value,
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_NAME),
ret_value);
ecma_value_t name_to_str_completion;
if (ecma_is_value_undefined (name_get_ret_value))
{
name_to_str_completion = ecma_make_magic_string_value (LIT_MAGIC_STRING_ERROR_UL);
}
else
{
name_to_str_completion = ecma_op_to_string (name_get_ret_value);
}
if (JERRY_UNLIKELY (ECMA_IS_VALUE_ERROR (name_to_str_completion)))
{
ret_value = ecma_copy_value (name_to_str_completion);
}
else
{
ECMA_TRY_CATCH (msg_get_ret_value,
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_MESSAGE),
ret_value);
ecma_value_t msg_to_str_completion;
if (ecma_is_value_undefined (msg_get_ret_value))
{
msg_to_str_completion = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
msg_to_str_completion = ecma_op_to_string (msg_get_ret_value);
}
if (JERRY_UNLIKELY (ECMA_IS_VALUE_ERROR (msg_to_str_completion)))
{
ret_value = ecma_copy_value (msg_to_str_completion);
}
else
{
ecma_string_t *name_string_p = ecma_get_string_from_value (name_to_str_completion);
ecma_string_t *msg_string_p = ecma_get_string_from_value (msg_to_str_completion);
ecma_string_t *ret_str_p;
if (ecma_string_is_empty (name_string_p))
{
ret_str_p = msg_string_p;
ecma_ref_ecma_string (ret_str_p);
}
else if (ecma_string_is_empty (msg_string_p))
{
ret_str_p = name_string_p;
ecma_ref_ecma_string (ret_str_p);
}
else
{
const lit_utf8_size_t name_size = ecma_string_get_size (name_string_p);
const lit_utf8_size_t msg_size = ecma_string_get_size (msg_string_p);
const lit_utf8_size_t colon_size = lit_get_magic_string_size (LIT_MAGIC_STRING_COLON_CHAR);
const lit_utf8_size_t space_size = lit_get_magic_string_size (LIT_MAGIC_STRING_SPACE_CHAR);
const lit_utf8_size_t size = name_size + msg_size + colon_size + space_size;
JMEM_DEFINE_LOCAL_ARRAY (ret_str_buffer, size, lit_utf8_byte_t);
lit_utf8_byte_t *ret_str_buffer_p = ret_str_buffer;
lit_utf8_size_t bytes = ecma_string_copy_to_cesu8_buffer (name_string_p, ret_str_buffer_p, name_size);
JERRY_ASSERT (bytes == name_size);
ret_str_buffer_p = ret_str_buffer_p + bytes;
JERRY_ASSERT (ret_str_buffer_p <= ret_str_buffer + size);
ret_str_buffer_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_COLON_CHAR,
ret_str_buffer_p,
colon_size);
JERRY_ASSERT (ret_str_buffer_p <= ret_str_buffer + size);
ret_str_buffer_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_SPACE_CHAR,
ret_str_buffer_p,
space_size);
JERRY_ASSERT (ret_str_buffer_p <= ret_str_buffer + size);
bytes = ecma_string_copy_to_cesu8_buffer (msg_string_p, ret_str_buffer_p, msg_size);
JERRY_ASSERT (bytes == msg_size);
ret_str_buffer_p = ret_str_buffer_p + bytes;
JERRY_ASSERT (ret_str_buffer_p == ret_str_buffer + size);
ret_str_p = ecma_new_ecma_string_from_utf8 (ret_str_buffer,
size);
JMEM_FINALIZE_LOCAL_ARRAY (ret_str_buffer);
}
ret_value = ecma_make_string_value (ret_str_p);
}
ecma_free_value (msg_to_str_completion);
ECMA_FINALIZE (msg_get_ret_value);
}
ecma_free_value (name_to_str_completion);
ECMA_FINALIZE (name_get_ret_value);
return ECMA_VALUE_ERROR;
}
return ret_value;
ecma_string_t *msg_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p,
LIT_MAGIC_STRING_MESSAGE,
LIT_MAGIC_STRING__EMPTY);
if (JERRY_UNLIKELY (msg_string_p == NULL))
{
ecma_deref_ecma_string (name_string_p);
return ECMA_VALUE_ERROR;
}
if (ecma_string_is_empty (name_string_p))
{
return ecma_make_string_value (msg_string_p);
}
if (ecma_string_is_empty (msg_string_p))
{
return ecma_make_string_value (name_string_p);
}
ecma_stringbuilder_t builder = ecma_stringbuilder_create_from (name_string_p);
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *)": ", 2);
ecma_stringbuilder_append (&builder, msg_string_p);
ecma_deref_ecma_string (name_string_p);
ecma_deref_ecma_string (msg_string_p);
return ecma_make_string_value (ecma_stringbuilder_finalize (&builder));
} /* ecma_builtin_error_prototype_object_to_string */
/**
@@ -22,8 +22,9 @@
#include "ecma-helpers.h"
#include "ecma-builtin-helpers.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#include "ecma-function-object.h"
#include "jrt.h"
#include "jcontext.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -49,7 +50,7 @@
*/
ecma_value_t
ecma_builtin_error_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 */
{
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_COMMON, arguments_list_p, arguments_list_len);
} /* ecma_builtin_error_dispatch_call */
@@ -61,9 +62,31 @@ ecma_builtin_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
*/
ecma_value_t
ecma_builtin_error_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 */
{
#if !ENABLED (JERRY_ESNEXT)
return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
#else /* ENABLED (JERRY_ESNEXT) */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
if (proto_p == NULL)
{
return ECMA_VALUE_ERROR;
}
ecma_value_t result = ecma_builtin_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;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_builtin_error_dispatch_construct */
/**
@@ -22,10 +22,9 @@
/* Number properties:
* (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v5, 15.11.3 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
/* Object properties:
* (property name, object pointer getter) */
@@ -35,4 +34,10 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_ERROR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -22,7 +22,6 @@
#include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-string-object.h"
#include "ecma-try-catch-macro.h"
#include "jrt.h"
#if ENABLED (JERRY_BUILTIN_ERRORS)
@@ -22,8 +22,9 @@
#include "ecma-helpers.h"
#include "ecma-builtin-helpers.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#include "ecma-function-object.h"
#include "jrt.h"
#include "jcontext.h"
#if ENABLED (JERRY_BUILTIN_ERRORS)
@@ -51,7 +52,7 @@
*/
ecma_value_t
ecma_builtin_eval_error_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 */
{
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_EVAL, arguments_list_p, arguments_list_len);
} /* ecma_builtin_eval_error_dispatch_call */
@@ -63,9 +64,31 @@ ecma_builtin_eval_error_dispatch_call (const ecma_value_t *arguments_list_p, /**
*/
ecma_value_t
ecma_builtin_eval_error_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 */
{
#if !ENABLED (JERRY_ESNEXT)
return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
#else /* ENABLED (JERRY_ESNEXT) */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
if (proto_p == NULL)
{
return ECMA_VALUE_ERROR;
}
ecma_value_t result = ecma_builtin_eval_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;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_builtin_eval_error_dispatch_construct */
/**
@@ -24,10 +24,9 @@
/* Number properties:
* (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v5, 15.11.3 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
/* Object properties:
* (property name, object pointer getter) */
@@ -37,6 +36,12 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_EVAL_ERROR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#endif /* ENABLED (JERRY_BUILTIN_ERRORS) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -23,8 +23,9 @@
#include "ecma-helpers.h"
#include "ecma-function-object.h"
#include "ecma-objects.h"
#include "ecma-try-catch-macro.h"
#include "ecma-proxy-object.h"
#include "jrt.h"
#include "ecma-builtin-function-prototype.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -39,11 +40,14 @@
*/
enum
{
ECMA_FUNCTION_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
ECMA_FUNCTION_PROTOTYPE_ROUTINE_START = 0,
ECMA_FUNCTION_PROTOTYPE_TO_STRING,
ECMA_FUNCTION_PROTOTYPE_CALL,
ECMA_FUNCTION_PROTOTYPE_APPLY,
ECMA_FUNCTION_PROTOTYPE_BIND,
#if ENABLED (JERRY_ESNEXT)
ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE,
#endif /* ENABLED (JERRY_ESNEXT) */
};
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-function-prototype.inc.h"
@@ -89,7 +93,7 @@ ecma_builtin_function_prototype_object_to_string (void)
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_value_t
ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< this argument object */
ecma_value_t arg1, /**< first argument */
ecma_value_t arg2) /**< second argument */
@@ -108,27 +112,15 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
ecma_object_t *obj_p = ecma_get_object_from_value (arg2);
/* 4. */
ecma_value_t length_value = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH);
if (ECMA_IS_VALUE_ERROR (length_value))
/* 4-5. */
ecma_length_t length;
ecma_value_t len_value = ecma_op_object_get_length (obj_p, &length);
if (ECMA_IS_VALUE_ERROR (len_value))
{
return length_value;
return len_value;
}
ecma_number_t length_number;
ecma_value_t get_result = ecma_get_number (length_value, &length_number);
ecma_free_value (length_value);
if (ECMA_IS_VALUE_ERROR (get_result))
{
return get_result;
}
JERRY_ASSERT (ecma_is_value_empty (get_result));
/* 5. */
const uint32_t length = ecma_number_to_uint32 (length_number);
if (length >= ECMA_FUNCTION_APPLY_ARGUMENT_COUNT_LIMIT)
{
return ecma_raise_range_error (ECMA_ERR_MSG ("Too many arguments declared for Function.apply()."));
@@ -137,14 +129,12 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
/* 6. */
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
JMEM_DEFINE_LOCAL_ARRAY (arguments_list_p, length, ecma_value_t);
uint32_t index = 0;
ecma_length_t index = 0;
/* 7. */
for (index = 0; index < length; index++)
{
ecma_string_t *curr_idx_str_p = ecma_new_ecma_string_from_uint32 (index);
ecma_value_t get_value = ecma_op_object_get (obj_p, curr_idx_str_p);
ecma_deref_ecma_string (curr_idx_str_p);
ecma_value_t get_value = ecma_op_object_get_by_index (obj_p, index);
if (ECMA_IS_VALUE_ERROR (get_value))
{
@@ -161,7 +151,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
ret_value = ecma_op_function_call (func_obj_p,
arg1,
arguments_list_p,
length);
(uint32_t) length);
}
for (uint32_t remove_index = 0; remove_index < index; remove_index++)
@@ -186,7 +176,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
static ecma_value_t
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< this argument object */
const ecma_value_t *arguments_list_p, /**< list of arguments */
ecma_length_t arguments_number) /**< number of arguments */
uint32_t arguments_number) /**< number of arguments */
{
if (arguments_number == 0)
{
@@ -200,7 +190,7 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
return ecma_op_function_call (func_obj_p,
arguments_list_p[0],
arguments_list_p + 1,
(ecma_length_t) (arguments_number - 1u));
(uint32_t) (arguments_number - 1u));
} /* ecma_builtin_function_prototype_object_call */
/**
@@ -215,62 +205,172 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
static ecma_value_t
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**< this argument object */
const ecma_value_t *arguments_list_p, /**< list of arguments */
ecma_length_t arguments_number) /**< number of arguments */
uint32_t arguments_number) /**< number of arguments */
{
/* 4. 11. 18. */
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
ecma_object_t *prototype_obj_p;
#if !ENABLED (JERRY_ESNEXT)
prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
#else /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_OBJECT_IS_PROXY (this_arg_obj_p))
{
ecma_value_t proto = ecma_proxy_object_get_prototype_of (this_arg_obj_p);
if (ECMA_IS_VALUE_ERROR (proto))
{
return proto;
}
prototype_obj_p = ecma_is_value_null (proto) ? NULL : ecma_get_object_from_value (proto);
}
else
{
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
jmem_cpointer_t proto_cp = ecma_op_ordinary_object_get_prototype_of (this_arg_obj_p);
if (proto_cp != JMEM_CP_NULL)
{
prototype_obj_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, proto_cp);
ecma_ref_object (prototype_obj_p);
}
else
{
prototype_obj_p = NULL;
}
#if ENABLED (JERRY_BUILTIN_PROXY)
}
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
#endif /* !ENABLED (JERRY_ESNEXT) */
ecma_object_t *function_p;
ecma_extended_object_t *ext_function_p;
ecma_bound_function_t *bound_func_p;
if (arguments_number == 0
|| (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
{
function_p = ecma_create_object (prototype_obj_p,
sizeof (ecma_extended_object_t),
sizeof (ecma_bound_function_t),
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
/* 8. */
ext_function_p = (ecma_extended_object_t *) function_p;
ECMA_SET_INTERNAL_VALUE_POINTER (ext_function_p->u.bound_function.target_function,
this_arg_obj_p);
bound_func_p = (ecma_bound_function_t *) function_p;
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function,
this_arg_obj_p,
0);
ext_function_p->u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
if (arguments_number != 0)
{
ext_function_p->u.bound_function.args_len_or_this = ecma_copy_value_if_not_object (arguments_list_p[0]);
bound_func_p->header.u.bound_function.args_len_or_this = ecma_copy_value_if_not_object (arguments_list_p[0]);
}
}
else
{
JERRY_ASSERT (arguments_number > 0);
size_t obj_size = sizeof (ecma_extended_object_t) + (arguments_number * sizeof (ecma_value_t));
size_t obj_size = sizeof (ecma_bound_function_t) + (arguments_number * sizeof (ecma_value_t));
function_p = ecma_create_object (prototype_obj_p,
obj_size,
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
/* 8. */
ext_function_p = (ecma_extended_object_t *) function_p;
ECMA_SET_INTERNAL_VALUE_POINTER (ext_function_p->u.bound_function.target_function,
this_arg_obj_p);
bound_func_p = (ecma_bound_function_t *) function_p;
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function,
this_arg_obj_p,
0);
/* NOTE: This solution provides temporary false data about the object's size
but prevents GC from freeing it until it's not fully initialized. */
ext_function_p->u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
ecma_value_t *args_p = (ecma_value_t *) (ext_function_p + 1);
bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
ecma_value_t *args_p = (ecma_value_t *) (bound_func_p + 1);
for (ecma_length_t i = 0; i < arguments_number; i++)
for (uint32_t i = 0; i < arguments_number; i++)
{
*args_p++ = ecma_copy_value_if_not_object (arguments_list_p[i]);
}
ecma_value_t args_len_or_this = ecma_make_integer_value ((ecma_integer_value_t) arguments_number);
ext_function_p->u.bound_function.args_len_or_this = args_len_or_this;
bound_func_p->header.u.bound_function.args_len_or_this = args_len_or_this;
}
#if ENABLED (JERRY_ESNEXT)
if (prototype_obj_p != NULL)
{
ecma_deref_object (prototype_obj_p);
}
bound_func_p->target_length = ecma_make_integer_value (0);
ecma_string_t *len_string = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH);
ecma_property_descriptor_t prop_desc;
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p,
len_string,
&prop_desc);
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_IS_VALUE_ERROR (status))
{
ecma_deref_object (function_p);
return status;
}
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
if (ecma_is_value_true (status))
{
ecma_free_property_descriptor (&prop_desc);
ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p,
len_string);
if (ECMA_IS_VALUE_ERROR (len_value))
{
ecma_deref_object (function_p);
return len_value;
}
if (ecma_is_value_number (len_value))
{
ecma_number_t len_num;
ecma_op_to_integer (len_value, &len_num);
bound_func_p->target_length = ecma_make_number_value (len_num);
}
ecma_free_value (len_value);
}
/* 12. */
ecma_value_t name_value = ecma_op_object_get_by_magic_id (this_arg_obj_p, LIT_MAGIC_STRING_NAME);
if (ECMA_IS_VALUE_ERROR (name_value))
{
ecma_deref_object (function_p);
return name_value;
}
ecma_string_t *name_p;
if (ecma_is_value_string (name_value))
{
name_p = ecma_get_string_from_value (name_value);
}
else
{
ecma_free_value (name_value);
name_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
}
ecma_value_t bound_function_name = ecma_op_function_form_name (name_p, "bound ", 6);
ecma_deref_ecma_string (name_p);
ecma_property_value_t *name_prop_value_p;
name_prop_value_p = ecma_create_named_data_property (function_p,
ecma_get_magic_string (LIT_MAGIC_STRING_NAME),
ECMA_PROPERTY_FLAG_CONFIGURABLE,
NULL);
name_prop_value_p->value = bound_function_name;
#endif /* ENABLED (JERRY_ESNEXT) */
/*
* [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_FUNCTION type.
*
@@ -288,7 +388,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
*/
ecma_value_t
ecma_builtin_function_prototype_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);
@@ -302,7 +402,7 @@ ecma_builtin_function_prototype_dispatch_call (const ecma_value_t *arguments_lis
*/
ecma_value_t
ecma_builtin_function_prototype_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);
@@ -316,15 +416,21 @@ ecma_builtin_function_prototype_dispatch_construct (const ecma_value_t *argument
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_builtin_function_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
* identifier */
ecma_builtin_function_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 */
ecma_length_t arguments_number) /**< length of arguments' list */
* passed to routine */
uint32_t arguments_number) /**< length of arguments' list */
{
if (!ecma_op_is_callable (this_arg))
{
#if ENABLED (JERRY_ESNEXT)
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE))
{
return ECMA_VALUE_FALSE;
}
#endif /* ENABLED (JERRY_ESNEXT) */
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a function."));
}
@@ -350,6 +456,12 @@ ecma_builtin_function_prototype_dispatch_routine (uint16_t builtin_routine_id, /
{
return ecma_builtin_function_prototype_object_bind (func_obj_p, arguments_list_p, arguments_number);
}
#if ENABLED (JERRY_ESNEXT)
case ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE:
{
return ecma_op_object_has_instance (func_obj_p, arguments_list_p[0]);
}
#endif /* ENABLED (JERRY_ESNEXT) */
default:
{
JERRY_UNREACHABLE ();
@@ -0,0 +1,23 @@
/* 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_BUILTIN_FUNCTION_PROTOTYPE_H
#define ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
ecma_value_t ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p,
ecma_value_t arg1,
ecma_value_t arg2);
#endif /* !ECMA_BUILTIN_FUNCTION_PROTOTYPE_H */
@@ -30,10 +30,15 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
/* Number properties:
* (property name, object pointer getter) */
/* ECMA-262 v5, 15.3.4 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
0,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING__EMPTY,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
/* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -42,4 +47,20 @@ ROUTINE (LIT_MAGIC_STRING_APPLY, ECMA_FUNCTION_PROTOTYPE_APPLY, 2, 2)
ROUTINE (LIT_MAGIC_STRING_CALL, ECMA_FUNCTION_PROTOTYPE_CALL, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_BIND, ECMA_FUNCTION_PROTOTYPE_BIND, NON_FIXED, 1)
#if ENABLED (JERRY_ESNEXT)
/**
* ECMA-262 v6.0 19.2.3.6 @@hasInstance
* the property attributes are: { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
*/
ROUTINE_WITH_FLAGS (LIT_GLOBAL_SYMBOL_HAS_INSTANCE, ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE, 1, 1, 0 /* flags */)
ACCESSOR_BUILTIN_FUNCTION (LIT_MAGIC_STRING_ARGUMENTS,
ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
ACCESSOR_BUILTIN_FUNCTION (LIT_MAGIC_STRING_CALLER,
ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -20,14 +20,9 @@
#include "ecma-gc.h"
#include "ecma-function-object.h"
#include "ecma-lex-env.h"
#include "ecma-try-catch-macro.h"
#include "js-parser.h"
#include "lit-magic-strings.h"
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
#include "jcontext.h"
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
@@ -52,67 +47,13 @@
*/
ecma_value_t
ecma_builtin_function_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);
return ecma_builtin_function_dispatch_construct (arguments_list_p, arguments_list_len);
} /* ecma_builtin_function_dispatch_call */
/**
* Helper method to count and convert the arguments for the Function constructor call.
*
* Performs the operation described in ECMA 262 v5.1 15.3.2.1 steps 5.a-d
*
*
* @return ecma value - concatenated arguments as a string.
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_function_helper_get_function_arguments (const ecma_value_t *arguments_list_p, /**< arguments list */
ecma_length_t arguments_list_len) /**< number of arguments */
{
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
if (arguments_list_len <= 1)
{
return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
ecma_value_t final_str = ecma_op_to_string (arguments_list_p[0]);
if (arguments_list_len == 2 || ECMA_IS_VALUE_ERROR (final_str))
{
return final_str;
}
for (ecma_length_t idx = 1; idx < arguments_list_len - 1; idx++)
{
ecma_value_t new_str = ecma_op_to_string (arguments_list_p[idx]);
if (ECMA_IS_VALUE_ERROR (new_str))
{
ecma_free_value (final_str);
/* Return with the error. */
final_str = new_str;
break;
}
ecma_string_t *final_str_p = ecma_get_string_from_value (final_str);
final_str_p = ecma_append_magic_string_to_string (final_str_p,
LIT_MAGIC_STRING_COMMA_CHAR);
ecma_string_t *new_str_p = ecma_get_string_from_value (new_str);
final_str_p = ecma_concat_ecma_strings (final_str_p, new_str_p);
ecma_deref_ecma_string (new_str_p);
final_str = ecma_make_string_value (final_str_p);
}
return final_str;
} /* ecma_builtin_function_helper_get_function_arguments */
/**
* Handle calling [[Construct]] of built-in Function object
*
@@ -123,73 +64,9 @@ ecma_builtin_function_helper_get_function_arguments (const ecma_value_t *argumen
*/
ecma_value_t
ecma_builtin_function_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);
ecma_value_t arguments_value = ecma_builtin_function_helper_get_function_arguments (arguments_list_p,
arguments_list_len);
if (ECMA_IS_VALUE_ERROR (arguments_value))
{
return arguments_value;
}
ecma_value_t function_body_value;
if (arguments_list_len > 0)
{
function_body_value = ecma_op_to_string (arguments_list_p[arguments_list_len - 1]);
if (ECMA_IS_VALUE_ERROR (function_body_value))
{
ecma_free_value (arguments_value);
return function_body_value;
}
}
else
{
/* Very unlikely code path, not optimized. */
function_body_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
ecma_string_t *arguments_str_p = ecma_get_string_from_value (arguments_value);
ecma_string_t *function_body_str_p = ecma_get_string_from_value (function_body_value);
ECMA_STRING_TO_UTF8_STRING (arguments_str_p, arguments_buffer_p, arguments_buffer_size);
ECMA_STRING_TO_UTF8_STRING (function_body_str_p, function_body_buffer_p, function_body_buffer_size);
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
JERRY_CONTEXT (resource_name) = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
ecma_compiled_code_t *bytecode_data_p = NULL;
ecma_value_t ret_value = parser_parse_script (arguments_buffer_p,
arguments_buffer_size,
function_body_buffer_p,
function_body_buffer_size,
ECMA_PARSE_NO_OPTS,
&bytecode_data_p);
if (!ECMA_IS_VALUE_ERROR (ret_value))
{
JERRY_ASSERT (ecma_is_value_true (ret_value));
ecma_object_t *func_obj_p = ecma_op_create_function_object (ecma_get_global_environment (),
bytecode_data_p);
ecma_bytecode_deref (bytecode_data_p);
ret_value = ecma_make_object_value (func_obj_p);
}
ECMA_FINALIZE_UTF8_STRING (function_body_buffer_p, function_body_buffer_size);
ECMA_FINALIZE_UTF8_STRING (arguments_buffer_p, arguments_buffer_size);
ecma_deref_ecma_string (arguments_str_p);
ecma_deref_ecma_string (function_body_str_p);
return ret_value;
return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_NO_OPTS);
} /* ecma_builtin_function_dispatch_construct */
/**
@@ -30,9 +30,14 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
/* Number properties:
* (property name, object pointer getter) */
/* ECMA-262 v5, 15.3.3.2 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FIXED)
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if ENABLED (JERRY_ESNEXT)
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,72 @@
/* 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"
#if ENABLED (JERRY_ESNEXT)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#include "ecma-function-object.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-function.inc.h"
#define BUILTIN_UNDERSCORED_ID generator_function
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup generator ECMA GeneratorFunction object built-in
* @{
*/
/**
* Handle calling [[Call]] of built-in GeneratorFunction object
*
* @return constructed generator function object - if success
* raised error otherwise
*/
ecma_value_t
ecma_builtin_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_builtin_generator_function_dispatch_call */
/**
* Handle calling [[Construct]] of built-in GeneratorFunction object
*
* @return constructed generator function object - if success
* raised error otherwise
*/
ecma_value_t
ecma_builtin_generator_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */
{
return ecma_builtin_generator_function_dispatch_call (arguments_list_p, arguments_list_len);
} /* ecma_builtin_generator_function_dispatch_construct */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,41 @@
/* 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.
*/
/*
* %GeneratorFunction% built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ESNEXT)
/* ECMA-262 v6, 25.2.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME,
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.2.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
ECMA_BUILTIN_ID_GENERATOR,
ECMA_PROPERTY_FIXED)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -0,0 +1,261 @@
/* 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-builtins.h"
#include "ecma-exceptions.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-iterator-object.h"
#include "jcontext.h"
#include "opcodes.h"
#include "vm-defines.h"
#if ENABLED (JERRY_ESNEXT)
#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_GENERATOR_PROTOTYPE_ROUTINE_START = 0,
ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT,
ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW,
ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN
} ecma_generator_operation_type_t;
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-prototype.inc.h"
#define BUILTIN_UNDERSCORED_ID generator_prototype
#include "ecma-builtin-internal-routines-template.inc.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup generator ECMA Generator.prototype object built-in
* @{
*/
/**
* Convert routine type to operation type..
*/
#define ECMA_GENERATOR_ROUTINE_TO_OPERATION(type) \
((ecma_iterator_command_type_t) ((type) - ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
== ECMA_ITERATOR_NEXT,
convert_ecma_generator_routine_next_to_ecma_iterator_next_failed);
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
== ECMA_ITERATOR_THROW,
convert_ecma_generator_routine_throw_to_ecma_iterator_throw_failed);
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
== ECMA_ITERATOR_RETURN,
convert_ecma_generator_routine_return_to_ecma_iterator_return_failed);
/**
* Helper function for next / return / throw
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_object_p, /**< generator object */
ecma_value_t arg, /**< argument */
ecma_iterator_command_type_t resume_mode) /**< resume mode */
{
arg = ecma_copy_value (arg);
while (true)
{
if (generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
{
ecma_value_t iterator = generator_object_p->frame_ctx.block_result;
ecma_value_t next_method = generator_object_p->frame_ctx.stack_top_p[-1];
bool done = false;
ecma_value_t result = ecma_op_iterator_do (resume_mode, iterator, next_method, arg, &done);
ecma_free_value (arg);
if (ECMA_IS_VALUE_ERROR (result))
{
arg = result;
}
else if (done)
{
arg = ecma_op_iterator_value (result);
ecma_free_value (result);
if (resume_mode == ECMA_ITERATOR_THROW)
{
resume_mode = ECMA_ITERATOR_NEXT;
}
}
else
{
return result;
}
ECMA_EXECUTABLE_OBJECT_RESUME_EXEC (generator_object_p);
generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
JERRY_ASSERT (generator_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
|| ecma_is_value_object (generator_object_p->frame_ctx.stack_top_p[-1]));
generator_object_p->frame_ctx.stack_top_p--;
if (ECMA_IS_VALUE_ERROR (arg))
{
arg = jcontext_take_exception ();
resume_mode = ECMA_ITERATOR_THROW;
}
}
if (resume_mode == ECMA_ITERATOR_RETURN)
{
generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_return;
}
else if (resume_mode == ECMA_ITERATOR_THROW)
{
generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
}
ecma_value_t value = opfunc_resume_executable_object (generator_object_p, arg);
if (ECMA_IS_VALUE_ERROR (value))
{
return value;
}
bool done = (generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED);
if (!done)
{
const uint8_t *byte_code_p = generator_object_p->frame_ctx.byte_code_p;
JERRY_ASSERT (byte_code_p[-2] == CBC_EXT_OPCODE
&& (byte_code_p[-1] == CBC_EXT_YIELD || byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR));
if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR)
{
ecma_value_t iterator = ecma_op_get_iterator (value,
ECMA_VALUE_SYNC_ITERATOR,
generator_object_p->frame_ctx.stack_top_p);
ecma_free_value (value);
if (ECMA_IS_VALUE_ERROR (iterator))
{
resume_mode = ECMA_ITERATOR_THROW;
arg = jcontext_take_exception ();
continue;
}
ecma_deref_object (ecma_get_object_from_value (iterator));
generator_object_p->extended_object.u.class_prop.extra_info |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
generator_object_p->frame_ctx.block_result = iterator;
if (generator_object_p->frame_ctx.stack_top_p[0] != ECMA_VALUE_UNDEFINED)
{
ecma_deref_object (ecma_get_object_from_value (generator_object_p->frame_ctx.stack_top_p[0]));
}
generator_object_p->frame_ctx.stack_top_p++;
arg = ECMA_VALUE_UNDEFINED;
continue;
}
}
ecma_value_t result = ecma_create_iter_result_object (value, ecma_make_boolean_value (done));
ecma_fast_free_value (value);
return result;
}
} /* ecma_builtin_generator_prototype_object_do */
/**
* 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_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_get_object_type (object_p) == ECMA_OBJECT_TYPE_CLASS)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_GENERATOR_UL)
{
executable_object_p = (vm_executable_object_t *) ext_object_p;
}
}
}
if (executable_object_p == NULL)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a generator object."));
}
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_RUNNING)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Generator is currently under execution."));
}
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
{
if (builtin_routine_id != ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
{
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
}
jcontext_raise_exception (ecma_copy_value (arguments_list_p[0]));
return ECMA_VALUE_ERROR;
}
return ecma_builtin_generator_prototype_object_do (executable_object_p,
arguments_list_p[0],
ECMA_GENERATOR_ROUTINE_TO_OPERATION (builtin_routine_id));
} /* ecma_builtin_generator_prototype_dispatch_routine */
/**
* @}
* @}
* @}
*/
#endif /* ENABLED (JERRY_ESNEXT) */
@@ -0,0 +1,45 @@
/* 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.
*/
/*
* Generator.prototype built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ESNEXT)
/* 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_GENERATOR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
ECMA_BUILTIN_ID_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_GENERATOR_PROTOTYPE_ROUTINE_NEXT, 1, 1)
ROUTINE (LIT_MAGIC_STRING_RETURN, ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN, 1, 1)
ROUTINE (LIT_MAGIC_STRING_THROW, ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW, 1, 1)
#endif /* ENABLED (JERRY_ESNEXT) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"

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