240 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Péter Gál
3e23a3b62f Improve documentation on native pointer API methods (#3191)
Added extra notes on the native pointer API usages to clarify
when the free callback function is invoked. Also added a note
for the free callback typedef to inform users to not call API methods
in the callback.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-10-04 16:57:16 +02:00
Dániel Bátyai
f1883b9e7d
Provide support for native modules with ES6 imports (#3090)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-10-02 12:20:43 +02:00
legendecas
07c7eb8a20 Fix python build --mem-heap document (#3185)
`--heap-size` has been renamed to `--mem-heap`
JerryScript-DCO-1.0-Signed-off-by: legendecas legendecas@gmail.com
2019-10-02 11:16:38 +02:00
Csaba Osztrogonác
1acbf83d1a Disable unsupported doctest tests on Windows (#3135)
Disable 02.API-REFERENCE-create-context.c, because
it is based on pthread, and there is no pthread on Windows.

Disable 11.EXT-REFERENCE-AUTORELEASE.c and test-ext-autorelease.c
if compiler is MSVC, because MSVC doesn't support cleanup attribute.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-09-20 11:07:06 +02:00
Csaba Osztrogonác
dc44b8b933 Disable INIT_FINI unittest on Windows (#3132)
MSVC doesn't support library constructor/destructor, let's disable
the related unittest and clarify the documentation and error messages.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-09-20 10:04:55 +02:00
Csaba Osztrogonác
c05686b668 Fix jerry_get_context_data() API function (#3127)
If manager_p->bytes_needed == 0, jerry_get_context_data() should return
NULL pointer. Additionally init_cb, deinit_cb and finalize_cb should be
called with NULL pointer in this case.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-09-17 17:31:46 +02:00
Péter Gál
57f389dcf4 Add backtrace print when the 'assert' js method fails (#3051)
In the jerry-ext there is a native 'assert' handler implemented.
This change adds extra backtrace information if an 'assert' call fails.

To print out the backtrace the library should be built with `JERRY_LINE_INFO` enabled.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-09-05 13:07:21 +02:00
Csaba Osztrogonác
ff2e75ed2e Fix buffer overflow in example for jerry_string_to_char_buffer() API function (#3010)
We need one more byte allocated for the trailing '\0'.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-08-08 21:31:59 +02:00
Dániel Bátyai
3b7475b01d Add build option for changing the heap limit (#3005)
This change adds a build option that allows adjusting the garbage
collection heap usage limit, which can be used to fine-tune how often
garbage collection should be triggered.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-08-06 13:35:26 +02:00
Csaba Osztrogonác
9c7511221f Don't use VLA's in unit tests and API examples (#3002)
MSVC doesn't support C99 VLA (variable-length array).
Use fixed size arrays in API examples and use JERRY_VLA macro
in unit tests to make these tests buildable on Windows too.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-08-06 13:01:01 +02:00
Csaba Osztrogonác
051febfed7 Fix unused parameter related build issues on Windows (#3003)
MSVC doen't support __attribute__((unused)),
we should use JERRY_UNUSED macro instead.

Additionally removed the internal jrt.h include from
tests/unit-core/test-common.h which was layering violation.
It made JERRY_ASSERT unavailable, we should use TEST_ASSERT.

JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-08-06 10:13:41 +02:00
Péter Gál
8ebd3230a1 Make sure that snapshot API return values are the same as in the docs (#2997)
The snapshot API docs describe that those functions returns error if
the related features are not enabled. Updated the return values to follow
the API documentation.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-31 19:23:55 +02:00
Péter Gál
c64ee882da Introduce new jerry-ext methods to ease property registration (#2715)
New methods
* jerryx_set_properties: Allows multiple property registration for via a single call
* jerryx_set_property_str: Allows property registration without the need to
    create the property name JS value. The property name can be directly passed
    as a `const char*` value and must be zero terminated.
* jerryx_get_property_str: Allows getting a property value on a given object.
    The property name can be directly passed as a `const char*` value.
* jerryx_has_property_str: Allows checking if a property exists on a given object.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-25 20:37:44 +02:00
Istvan Miklos
7575fa454a Migration Guide (#2419)
* Migration Guide

Migration guide from JerryScript 1.0 to 2.0.

Co-authored-by: László Langó llango.u-szeged@partner.samsung.com
Co-authored-by: Peter Gal pgal.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Istvan Miklos imiklos2@inf.u-szeged.hu

* Add version information for API methods

For each API method/type the documentation now includes
the version it was introduced or a change occured.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-25 20:33:03 +02:00
Péter Gál
50be3a5384 Document and improve the single-source generation (#2986)
Changes done:
* Added usage/configuration info for this mode.
* Created `tools/srcgenerator.py` to allow source/header generation
  without using CMake.
* Adapted CMake to use the `srcgenerator.py` script.
* Added jerry-libm single-source build.
* Improved the `srcmerger.py` script to correctly handle the line numbering.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-25 12:46:00 +02:00
Péter Gál
434994eb67 Add extra details for the api example page (#2956)
Add simple examples and details on how to execute them.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-24 15:47:55 +02:00
Dániel Bátyai
5d6eebac4c Add documentation for configuration options (#2977)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-23 15:32:41 +02:00
Péter Gál
f53dba1a3a Add dependency info for accessing memstats from API (#2979)
The documentation of `jerry_get_memory_stats` method was missing
the requirements on what build option or feature is required.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-22 11:15:19 +02:00
Dániel Bátyai
ec11a7b4e9
Resolve module paths relative to the current module (#2976)
The current module implementation resolves module paths relative to the
current working directory, but paths should be resolved relative to the
currently evaluated module/source.

This requires a change in the jerry_port_normalize_path port API
function, so that it also takes the current module path as an argument.
On the engine side, we now also create a module object for the main
script, so that we can properly identify the base path for other
modules.

Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-17 14:44:18 +02:00
Dániel Bátyai
ff22634e27
Refactor memory management (#2954)
This PR is a general cleanup for garbage collection and memory
allocation code paths.

Changes:
  * Removed an unnecesary local variable from 'ecma_gc_mark'.
  * Refactored 'ecma_gc_run' to have an implicit list head during
    iteration, which results in one less condition in the loops,
    and changed the loops to use compressed pointers to reduce the
    overall amount of compression/decompression.
  * Renamed 'jmem_free_unused_memory_severity_t' to 'jmem_pressure_t',
    and added additional values.
  * Removed 'jmem_free_unused_memory_callback', instead
    'ecma_free_unused_memory' is now called directly.
  * Reworked 'ecma_free_unused_memory' to handle all code paths related
    to 'jmem_pressure_t', and moved all relevant code paths into this
    function. This simplifies the code paths in other places.
  * Reworked 'jmem_heap_gc_and_alloc_block' to be more streamlined.
  * Changed mem-stats to not report unused pool chunks as allocated
    memory.
  * Created an allocator internal API for allocating/freeing memory blocks
    that are not reported as used memory in mem-stats.
  * Removed iteration statistics for the jerry allocator from mem-stats,
    as they don't provide any actually useful information.

Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-17 14:12:23 +02:00
Péter Gál
1374d5f562 Update and improve API documentation (#2952)
A few parts of the API documentation was not clear enough.
Added extra details and examples.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-10 22:43:33 +02:00
Dániel Bátyai
04d5d56a68 Fix URLs in the repository after organization switch (#2955)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-09 19:13:57 +02:00
Robert Fancsik
a72d14f575 Make API unavailable while processing native free callbacks (#2932)
This patch fixes #2889 and extends the API documentation of the native free callbacks.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-07-02 15:46:19 +02:00
Péter Gál
eef1efa394 Rework usages/naming of configuration macros [part 3] (#2927)
Reworked the JERRY_DEBUGGER macro to be a 0/1 switch.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-01 13:12:19 +02:00
Robert Fancsik
f6f52a2bf1
Update the internals documentation (#2923)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-06-27 12:56:06 +02:00