244 Commits

Author SHA1 Message Date
Gabriel "_|Nix|_" Schulhof
66b2a7670f New extension: module (#1863)
This extension provides the following facilities:
  - registering modules,
  - module resolvers, and
  - an API for retrieving a module instance given its name.

A module is defined as a global static structure containing a pointer
to a string which is the name of the module, and a pointer to a function
which will be called when an instance of the module is needed.

A module resolver is a function that accepts a string holding the name
of the module and returns a `jerry_value_t` in an out-parameter and
`true` if the module was found, or `false` if it was not. If it returns
`true` and the out-parameter has the error flag set then the API will
pass it through without caching.

This extension provides a built-in module resolver which attempts to
load modules that follow the above module definition.

The API provided by this extension invokes all module resolvers it
receives in sequence to attempt to resolve the name of a single module.
After one resolver returns `true` and a `jerry_value_t` that represents
the module the API stops iterating over the remaining resolvers and
caches the value if its error flag is not set. It then returns the
`jerry_value_t`. The API will return a `jerry_value_t` containing an
error indicating that the module was not found if it reaches the end of
the list of resolvers. The error it returns has an extra property
`"moduleName"` the value of which is a string containing the name of the
module that the API was asked to resolve.

JerryScript-DCO-1.0-Signed-off-by: Gabriel Schulhof gabriel.schulhof@intel.com
2017-07-18 15:54:24 +02:00
Akos Kiss
1f7606fc05 Improve pylint runner script (#1915)
- On OSX, `find` is more picky about its arguments than on Linux
  and requires the start directory(-ies) to be explicitly mentioned
  before the expressions (a.k.a. "primaries"). However, until now,
  the `pylint` runner script called `find` without a start dir,
  which caused an error on OSX.

- Until now, `find` looked for python scripts in all subdirectories
  of the project, causing `pylint` to check scripts under `targets/`
  and `tests/test262` (if `test262` was checked out). However, the
  files under `targets/` are less strictly controlled while
  `test262` is completely beyond the control of the project. This
  caused a lot of superfluous lint warnings.

This patch makes the `pylint` runner script call `find` in the
cross-platform way, and also limits the scope of the lint checks to
the `tools/` and `jerry-debugger/` directories.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-07-14 19:53:59 +02:00
Akos Kiss
00f93bc287 Add support for doctests (#1909)
Markdown files in the docs/ directory can now be annotated to turn
fenced C code blocks into unit tests. The recognized syntax is:

    [doctest]: # (name="test.c", test="run")

    ```c
    // unit test code
    ```

The commit also fixes the issues revealed during the initial
annotation.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-07-14 16:18:20 +02:00
Akos Kiss
18283d22c0 Make debugger port runtime configurable
Convert debug server port from a compile-time constant to a context
variable. This enables each engine instance (either running in the
same process or in different processes) to listen for connections
at different ports, i.e., multiple engines can be debugged at the
same time on the same machine.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-07-06 07:08:00 +09:00
Martijn Thé
b947f56fd0 Add jerryscript-ext/autorelease.h with JERRYX_AR_VALUE_T (#1874)
JerryScript-DCO-1.0-Signed-off-by: Martijn The martijn.the@intel.com
2017-06-16 00:09:19 -05:00
Zidong Jiang
5e28bfc28a Support external context, heap and lcache (#1778)
JerryScript should support external context, heap and lcache,
so that it can have multiple instances and runtime configurable heap
size.

Related issue: 1746

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-05-20 11:00:19 +08:00
Akos Kiss
31cd3b8020 Rename internal lit identifiers (#1801)
We should keep the `jerry_` prefix for public API which is either
declared in jerry-core/include or implemented in jerry-core/api.
Moreover, we should also keep the convention to use short
identifiers for componentization within jerry-core, and use these
identifiers as directory names, file name prefixes, and identifier
prefixes.

Therefore, the tools/gen-unicode.py-generated arrays in
jerry-core/lit are renamed to use `lit_` prefix instead of `jerry_`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-05-16 10:34:41 +02:00
Akos Kiss
7837440cbb Add lightweight command line processor to jerry-main (#1809)
Eases command line option and sub-command definition, usage summary
and detailed help message printing, and argv processing.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-05-16 10:29:27 +02:00
Zsolt Borbély
ca6e7881e8 Add category property to each .md file for the webpage (#1818)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-05-12 15:34:46 +02:00
Zsolt Borbély
e76d44a2ee Add docs about extensions to webpage-generator script (#1811)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-05-12 09:51:00 +02:00
Zidong Jiang
90efdf9c8b A tool in jerry-ext: arg transformer for binding (#1740)
It provides some APIs for binding developers, so that
they can validate the type of the js argument and convert/assign them
to the native argument.

Related Issue: #1716

JerryScript-DCO-1.0-Signed-off-by: Martijn The martijn.the@intel.com
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-05-04 18:00:35 +08:00
Zidong Jiang
ede13835b2 Add promise C API (#1796)
Add API: jerry_create_promise, jerry_value_is_promise and jerry_resolve_or_reject_promise.

related issue: 1794

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-05-04 16:13:26 +08:00
Zoltan Herczeg
894aa6d036 Support ECMAScript stopping in JerryScript. (#1753)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-04-28 14:19:23 +02:00
Robert Sipka
56802c22a1 Remove unnecessary subfolder in tests/jerry/fail/ (#1783)
There is no need to create error code named subfolders since
every failing tests return with the same code.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-04-28 09:17:23 +02:00
Akos Kiss
6ecee7eef4 Ensure that jerry-port is license-checked (#1788)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-28 08:59:10 +09:00
Akos Kiss
fdbbd0e8af Turn port implementations into proper libraries (#1777)
This commit changes the concept of JerryScript port implementations
from a simple directory of C source files (which get injected among
the sources of `jerry-core`) into a proper static library (which
may be linked to an application together with `jerry-core`). As a
consequence, this commit introduces a new library to the
JerryScript component architecture: the sources of the default port
implementation form `jerry-port-default`.

Changes in more detail:

- The sources in `targets/default` are moved to `jerry-port/default`
  and are turned into a proper static library.
  - Actually, the default port implementation has two library
    variants, one that implements the bare minimum only
    (`jerry-port-default-minimal`) and one that has some extra
    functionalities specific to this implementation (the "full"
    `jerry-port-default`).
  - The new libraries have an interface header in
    `jerry-port/default/include`, which extends the common
    `jerryscript-port.h` API with functions specific to these
    libraries.
  - All non-standard port functions have now the
    `jerry_port_default_` prefix (this affects `jobqueue_init` and
    `jobqueue_run`).
  - The jobqueue implementation functions became config macro
    independent: it is now the responsibility of the linker to pick
    the needed objects from the library, and omit those (e.g.,
    jobqueue-related code) that are not referenced.
  - Build of the libraries can be controlled with the new
    `JERRY_PORT_DEFAULT` cmake option.

- The cmake option `PORT_DIR` is dropped, and `PORT_DIR/*.c` is not
  appended to `jerry-core` sources.
  - Instead, the `jerry` tool of `jerry-main` links to
    `jerry-port-default`, while `jerry-minimal` links to
    `jerry-port-default-minimal`.
  - `tests/unit-core` tests are also linked to
    `jerry-port-default-minimal`.

- Tools adapted.
  - `build.py` has `--jerry-port-default` instead of `--port-dir`.
  - `check-*.sh` have paths updated (`jerry-port/default` instead
    of `targets/default`).

- Miscellaneous.
  - Dropped `#ifndef`s from `jerryscript-port.h`. It is a public
    header of the `jerry-core` library, which means that it must
    not contain configuration-dependent parts (once the library is
    built with some config macros and the archive and the headers
    are installed, there is no way for the header to tell what
    those config macrose were).
  - Added documentation comments to the JobQueue Port API (in
    `jerryscript-port.h`) and to several default port
    implementation functions (in `jerry-port/default`).

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-25 19:33:10 +02:00
Akos Kiss
49ae946644 Merge lit-unicode-*.inc.h-related generator scripts (#1767)
The `conversions` and `ranges` files had separate generators, which
shared some functionality through a 3rd python module, and were
quite similar to each other -- but also had some differences.
Moreover, as they were separate scripts, nothing forced to keep the
outputs in sync (to re-generate them at the same time from the same
inputs).

To fix these maintainability issues, this patch
- merges the two python files and part of the 3rd utility module
  into a single script while keeping the existing functionality,
- names the new file `gen-unicode.py` to align better with other
  generator script in `tools`, and
- adds some extra documentation how to retrieve the input files
  (as they are not part of the repository).

The refactoring affected the utility module as well, so this patch
also
- renames `c_source_helper.py` to `gen_c_source.py` (again, for
  naming consistency),
- reorganizes some of its functions not to export module-local
  helper functions, and
- adapts `js2c.py`, as it also uses this utility module.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-25 07:22:05 +09:00
Akos Kiss
4f4f75e1a8 Update paths in check tools (#1772)
In #1761, not all unit test paths have been updated in check tools.
This triggers no errors as `check-vera` emits a warning only while
`check-cppcheck` signals nothing. Still, this means that some of
the code in the repository that has been quality-assured, is now
avoiding checks. This patch fixes this.

Moreover, `check-cppcheck` has had incorrect paths for a while: it
looked for source files in the root of the repository, but those
files have been in `jerry-main` for almost a year now. This patch
fixes this, too.

Fallout of the above: `main-unix-minimal.c` had to be improved to
make `check-cppcheck` pass.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-24 09:01:03 +09:00
Akos Kiss
6ca8319aea Split unit tests into separate directories (#1761)
The unit tests should follow the component structure, so this patch
moves all `jerry-core` unit tests under `tests/unit-core` and the
`jerry-libm` unit tests under `tests/unit-libm`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-22 10:57:45 +09:00
Akos Kiss
67c641e567 Generate lit-magic-strings.inc.h (#1690)
Currently, `lit-magic-strings.inc.h` is manually maintained. This
has several drawbacks:

- keeping the list of magic strings sorted first by length then
  alphabetically is error prone,
- it is easy to leave unused magic strings in the list by accident
  (e.g., `LIT_MAGIC_STRING_JERRY_UL` is defined as a magic string
  but not used anywhere in the code) and,
- it is very hard to add `CONFIG_DISABLE_*_BUILTIN` guards to the
  list, even though there are several magic strings, which are used
  in some of the configurations only (e.g, "setPrototypeOf" is used
  in ES2015 only).

To ease the maintenance of magic strings, this commit moves the
definition of magic strings to a config file
(`lit-magic-strings.ini`), and adds `tools/gen-magic-strings.py` to
generate the `.inc.h` file from this config file and from the use
cases of the strings in the code.

- The magic strings in the config file can appear in any order, the
  generator will ensure that they are correctly sorted.
- The generator skips those definitions that are not used anywhere
  (and emits a warning to signal that such definitions can be
  removed).
- The generator applies the same guards to the definitions in the
  `.inc.h` file as found in the code around the use of the strings
  to optimize for size.

The commit also changes some builtin-related `.inc.h` files by
adding guards that don't affect functionality but improve the
results of the generator.

To ensure that the invocation of the generator does not get
forgotten, the commit also adds `tools/check-magic-strings.sh` and
binds it into the testing infrastructure.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-21 11:42:36 +02:00
Akos Kiss
4cff7a3f2c Fix/rewrite/darwinize test runner of jerry-debugger (#1756)
First issue was that `diff -u0` was not supported on OSX, thus got
replaced by `-U0`. Then, it turned out that test outcome was
determined based on diff's stdout, which was empty even though the
exit code was non-0 - this got changed, too.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-21 09:51:31 +09:00
Zsolt Borbély
fda5924b06 Rename the doc of coding standard and add it to the update-webpage.sh (#1748)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-04-20 12:23:53 +02:00
Zsolt Borbély
2fa9ae8d64 Fix link-generation in tools/update-webpage.sh (#1747)
This change is required to fix invalid links in 'See also' sections.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-04-19 13:48:42 +02:00
Robert Sipka
9cbd5e78ad Refactor js2c.py and eliminate related pylint warnings (#1728)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-04-19 07:08:32 +09:00
Akos Kiss
4b9e458f44 Add support for init/fini arrays to libc (#1725)
The arrays contain the addresses of functions annotated with
constructor or destructor attributes. The support is optional,
requires FEATURE_INIT_FINI cmake option to be set. As of now, the
option is _not_ available in tools/build.py directly, only via
`--cmake-param="-DFEATURE_INIT_FINI=ON"`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-04-13 17:18:17 +02:00
Zsolt Borbély
574dff512e Remove duplicated profile-check from build.py (#1718)
This check is performed in cmake-side too.
The README.md about the profiles is also updated.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-04-07 18:47:22 +02:00
Robert Sipka
1886d54474 Update unicode ranges to the latest version of Unicode Standard (version 9.0.0) (#1714)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-04-06 10:07:17 +02:00
Akos Kiss
2d9484a968 Don't do duplicate builds during test runs (#1691)
The `run-tests.py` test execution harness validates the correctness
of JerryScript by building various configurations of jerry and
running various test suites and subsets against it. However, until
now, it always built jerry for each (build configuration, test suite)
pair. This commit improves `run-tests.py` by skipping duplicate
builds, sharing the same-built binaries across multiple test suite
runs.

The patch also improves on the style of how `Option`s are specified
and fixes the name of the `jerry_tests-debug-cpointer_32bit`
option.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-03-28 15:48:09 +02:00
László Langó
fa5d5febcc Fix several pylint warnings. (#1659)
Fixed all of the remaining warnings in 'build.py', 'run-tests.py' and 'check-license.py'.

Related issue: #1600

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-03-22 15:37:55 +01:00
Akos Kiss
20a21a1faf Unify timeout mechanism in test runners and ensure that they work on OSX (#1672)
On OSX, the traditional GNU `timeout` command is available as
`gtimeout`. So, this commit adds some logic to the test runners to
try and find the right command name on the host.

Moreover, the commit also unifies the timeout mechanism across all
test runners by rewriting occurrences of `ulimit`-based timeouting
to use the `[g]timeout` command.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-03-22 10:51:37 +01:00
Robert Sipka
d77d4ae1c6 Refactor the generator scripts for unicode tables (#1623)
Extract the source code generator methods into a separated `unicode_c_source.py` script.
Fix the generator scripts to make them compatible with both Python2 and Python3.
Remove pylint warnings.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-03-16 09:32:18 +01:00
László Langó
202a88bbeb Temporarily disable a few test262 tests in automatic testing. (#1662)
Those tests are related the actual daylight saving adjustment.
Related issue: #1661

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-03-14 15:26:56 +01:00
László Langó
57ea06782b Fix several pylint warnings. (#1644)
Fixed
 * 'unused-wildcard-import'
 * 'bad-whitespace'
 * 'bad-continuation'
 * 'wrong-import-order'
in 'build.py', 'run-tests.py' and 'check-license.py'.

Related issue: #1600

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-03-13 11:18:49 +01:00
Zoltan Herczeg
a20b9dfa19 Introducing debugger modes (run, breakpoint). (#1645)
This makes the code more robust and error prone, since certain
messages cannot be received in certain situations, e.g. an eval
command during garbage collection.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-03-07 11:58:46 +01:00
Zidong Jiang
b13f78f19e Check options in ecma_op_object_get_own_property for typedarray. (#1627)
And add regression-case subfolder for es2015

Fix issue #1622

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-03-06 19:07:02 +08:00
Zsolt Borbély
f780f2b8dc Allow to skip certain JS-tests under tests/jerry/ and tests/jerry-test-suite/ (#1632)
Add `--skip-list` option to tools/run-tests.py.

Additional modifications:
 - The test `parser-oom.js` doesn't work when system-allocator is enabled,
   hence we skip it in these jobs.
 - The sanitizer-tasks become mandatory.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-03-02 15:58:23 +01:00
László Langó
92f74f3cf5 Fix pylint install on Travis CI (#1608)
Followup fix after #1602

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-03-02 10:36:21 +01:00
László Langó
5ef305dfee Avoid using global statement (#1606)
Related issue: #1600

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-02-22 09:12:57 +01:00
Levente Orban
cc0f69613a Add debugger connection port setting to build script (#1599)
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
2017-02-21 15:39:22 +01:00
László Langó
92eaea2a8e Add pylint checker to the project (#1602)
* Added 'pylint' to dependencies
 * Added pylint config file
 * Added to travis CI as an allow failure job
   (until all of the warnings are fixed)
 * Added to 'run-test.py'

Related issue: #1600

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-02-21 12:40:33 +01:00
Robert Sipka
188dc46fe0 Rewrite the generator script of unicode ranges. (#1583)
The script generates the source file instead of copy the tables and paste these manually.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-02-16 18:31:30 +01:00
Zsolt Borbély
93eb35081f Add Debugger documentation to webpage-generator script (#1587)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-02-16 17:39:19 +01:00
Robert Sipka
1b5f839db9 Improve toLowerCase and toUpperCase functions. (#1575)
Language-sensitive mappings are not processed now.

Fixes #323

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-02-15 15:57:55 +01:00
Levente Orban
025a99ccbb Initial version of JerryScript debugger (#1557)
The debugger supports setting breakpoints, execution control (step, next, continue)
and getting backtrace. The communication is WebSocket-based, so a browser can
communicate with JerryScript without any intermediate application.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
2017-02-14 15:03:01 +01:00
László Langó
348894e41f Enable 32bit compressed pointers on 64bit systems. (#1567)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-02-08 14:58:37 +01:00
László Langó
107c058bb1 Add doxygen checker (#1540)
* Fixed Doxygen issues
 * Updated Doxygen config
 * Added new script to test whether doxygen generation was successful or not
 * Added to Travis CI

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-01-31 12:27:59 +01:00
László Langó
623975d19f Add testing of 'JERRY_CPOINTER_32BIT' option to Travis CI. (#1544)
Added a new 'buildoptions' option to tools/run-tests.py to add
a comma separated list of extra build options to each test.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-01-30 15:44:26 +01:00
László Langó
7b59c80e18 Use default system allocator on 32bit systems, if JERRY_SYSTEM_ALLOCATOR is defined. (#1541)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-01-30 11:04:25 +01:00
Zsolt Borbély
eef6e57a4c Skip out license-check in case of test262 tests (#1504)
Can break testruns, when the test262 folder already present.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-01-09 09:44:40 +01:00
Robert Sipka
ff8ff982de Change the default build type to MinSizeRel. (#1513)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-01-09 09:14:21 +01:00