2112 Commits

Author SHA1 Message Date
Akos Kiss
d39c4187fb Fix the OSX build
Apple does not support staticaly built applications on OSX, and all
dynamically built apps have to be linked against the System lib
(i.e., `-static` should not be used and `-lSystem` is a must).
As System contains all libc and libm functions, building (and
linking) the minimal jerry-libc and jerry-libm libs makes no sense.
Moreover, if JERRY_LIBC is ON, the compiler will use the jerry-libc
headers but will link the libc functions from System, which causes
heavy confusion and segfaults at run time.

Thus, this patch changes the build system to disable the building
of jerry-libc and jerry-libm, and enables the use of system
libraries when building on OSX.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-15 12:39:09 +03:00
Zoltan Herczeg
ae1118293f Add two new API functions: jerry_create_number_infinity and jerry_create_number_nan
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-08-14 23:20:50 -07:00
Zoltan Herczeg
b6f174cce7 Gracefully throw an error when parser runs out of memory.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-08-14 23:08:26 -07:00
Zsolt Borbély
405bccf4d6 Fix run-tests.py: should evaluate the conditions correctly
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-08-14 23:39:19 +02:00
Akos Kiss
b4ab97581b Cleanup jerry-libc CMakeLists
Remove "-I/home/.../jerryscript/jerry-libc/__TARGET_HOST" and
"-D__TARGET_HOST" from compiler command line, they don't add
anything useful.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-14 22:35:31 +02:00
Robert Sipka
2e28542e9c Remove unused 'ecma_string_get_heap_number_size' and 'ecma_set_property_list' functions.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-12 18:48:56 +02:00
Akos Kiss
9d4f7c917f Fixing Math.pow
The Math.pow implementation relies on libm's pow. However, the ISO C
and ES5.1 standards differ on pow:
  * `x ** NAN` is NAN in ES but `+1 ** y` is 1 in C
  * `+-1 ** +-INF` is NAN in ES but 1 in C

This patch:
  * Modifies the Math.pow implementation to handle the special cases
    instead calling pow.
  * Adds a test case to jerry-test-suite as it did not test
    `Math.pow(1,NaN)`.
  * Fixes jerry-libm's pow, as it was not standard conforming, which
    helped hiding the error in Math.pow.
  * Updates the unit test for libm.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-11 22:49:36 +02:00
Akos Kiss
8f76bab92e Fix the use of mktemp in tool scripts
The manual of `mktemp` states that "TEMPLATE must contain at least
3 consecutive 'X's in last component." Linux implementation seems
to be relaxed about this and accepts and rewrites X's even inside
the template, but mktemp of OSX is more strict and handles trailing
X's only. This patch makes sure that mktemp templates work on both
OS's.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-11 22:20:43 +02:00
Akos Kiss
a2d5acb43c Follow-up refactoring of logging-related parts
This patch:
* Ensures that all calls to `jerry_port_log` in jerry-core happen
  via macros defined in jrt.h. Also, it unifies the names of those
  macros: as `JERRY_ERROR_MSG` and `JERRY_WARNING_MSG` gave a good
  pattern that was well aligned with the naming scheme of the log
  level enum, `JERRY_DLOG` and `JERRY_DDLOG` were rewritten to
  `JERRY_DEBUG_MSG` and `JERRY_TRACE_MSG`.
* Ensures that all debug logging code parts of jerry-core (i.e.,
  memory statistics, JS byte-code dumps, and RegExp byte-code
  dumps) are guarded by macros: `JMEM_STATS`,
  `PARSER_DUMP_BYTE_CODE`, and `REGEXP_DUMP_BYTE_CODE`, which in
  turn are controled by cmake build system feature flags
  `FEATURE_MEM_STATS`, `FEATURE_PARSER_DUMP`, and
  `FEATURE_REGEXP_DUMP`.
* Ensures that all debug logging functionalities can be controled
  during run time (provided that they were enabled during build
  time): the engine has `JERRY_INIT_MEM_STATS[_SEPARATE]`,
  `JERRY_INIT_SHOW_OPCODES`, `JERRY_INIT_SHOW_REGEXP_OPCODES` init
  flags, and the default unix/linux command line app has
  corresponding command line switches.`
* Drops `FEATURE_LOG`, `JERRY_ENABLE_LOG`, and
  `JERRY_INIT_ENABLE_LOG`, as their name was misleadingly general,
  even though they mostly controled the regexp engine only. The
  above-mentioned `*REGEXP*` things mostly act as their
  replacements.
* Updates build, test, and measurement tool scripts, and
  documentation.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-11 22:00:12 +02:00
Robert Sipka
1b996a9a56 Remove needless toolchain files and variable settings.
Unnecessary to set CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR, these values
are set by default. It also allows to use any C99-compliant compiler by using
the default CC enviroment variable or by setting the CMAKE_C_COMPILER value
using the build script's --cmake-param argument.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-11 16:59:26 +02:00
Levente Orban
91e29120d2 Follow the API & build system update in mbed targets
- Update the API changes in mbed targets
- Build fix for mbed target after the build system patch.

JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
2016-08-11 14:32:49 +02:00
Akos Kiss
d5eb2f0be1 Let the build script use a default for toolchain
The `cmake` directory already contains several toolchain files for
various platforms (operating system + architecture). However,
`tools/build.py` does not define a toolchain file for cmake unless
explicitly specified. This patch changes the script to look into
the `cmake` directory for a file named
`toolchain_$(os)_$(arch).cmake` and, if found, pass that to cmake
by default.

OS and arch are determined by `os.uname()`. As Linux on Raspberry
Pi identifies itself as "armv7l", the legacy "armv7l-hf" arch name
is shortened to "armv7l". This way, building jerry on RPi
(natively, not cross) becomes possible by simply running
`tools/build.py` without any extra options.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-08 13:42:59 +02:00
Zsolt Borbély
2836f49eec Fix run-tests.py: don't override the return value of a testrun
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-08-08 12:56:48 +02:00
Akos Kiss
2eb2b22c49 Rewrite parser_boolean_t to bool
And `PARSER_{TRUE,FALSE}` to `{true,false}`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-08 10:53:20 +02:00
Akos Kiss
ff21777950 Integrate JS parser module better with JRT
The fact that the JS parser had been developed as a separate
component for a while is still visible from some macros that mirror
things from JRT. This patch removes those duplicates and makes the
JS parser rely on jrt.h. (The removed macros are: `PARSER_DEBUG`,
`PARSER_INLINE`, `PARSER_NOINLINE`.)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-08 10:38:22 +02:00
Zoltan Herczeg
48812b4a61 Reduce memory consumption of ecma_property_hashmap_steps.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-08-05 06:00:01 -07:00
Sergio Martinez
67b494dcff Adapted the makefiles to the new build system
- Zephyr now requires two passes to create the configuration for the cross compiling
- Added the missing bits required to build a valid new jerryscript minimal configuration

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
2016-08-05 13:11:57 +01:00
Akos Kiss
db36e942fb Avoid (void) and use JERRY_UNUSED
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-05 13:16:53 +02:00
Akos Kiss
cad9ba1f01 Refactor flag additions in CMakeLists
CMakeLists already contains macros to ease adding compilation and
warning flags. This patch:
* Ensures that they are used whereever possible.
* Adds more macros to help with other flags as well.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-05 11:49:29 +02:00
Akos Kiss
e9a23c4235 Refactor jrt buffer operations
`jrt_read_from_buffer_by_offset` is not used anywhere in the code
while `jrt_write_to_buffer_by_offset` is only used by snapshot
saving functions. Thus, this patch removes the read variant
completely and moves the write variant as a static function to
jerry.c. This empties out jrt.c, thus deleting.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-05 11:28:15 +02:00
Akos Kiss
697442434d Cleanup jerry's assert-like routines and macros
Until now, jerry had 3 different assert-like routines:
`jerry_assert_fail`, `jerry_unreachable`, and `jerry_unimplemented`,
and 3 corresponding macros (`JERRY_ASSERT`, `JERRY_UNREACHABLE`,
and `JERRY_UNIMPLEMENTED`). They had some irregularities, namely:

* All of them had a string parameter, although `jerry_unreachable`
  never got anything there but NULL.
* Both `jerry_unreachable` and `jerry_unimplemented` checked its
  string parameter for NULL, although it was always NULL for the
  first one and never NULL for the second.
* `jerry_unreachable` is just a regular assert with a fixed error
  message (i.e., control should not have got here), however, the
  expansion of its corresponding macro in debug and release modes
  differs from the behaviour of `JERRY_ASSERT`: `JERRY_ASSERT` is
  a no-op in release, however, `JERRY_UNREACHABLE` was triggering
  a crash even there.
* Moreover, `JERRY_UNIMPLEMENTED` was almost never used anymore but
  in a few places (where often an `#ifdef` selected between
  `JERRY_UNIMPLEMENTED` and `JERRY_UNREACHABLE`).

Because of the above, this patch makes the following changes:

* Drops `JERRY_UNIMPLEMENTED` completely and whereever it was still
  used, replaces it with `JERRY_UNREACHABLE`. As a consequence, the
  `jerry_unimplemented` function and the `ERR_UNIMPLEMENTED_CASE`
  fatal error code are also removed.
* Makes `JERRY_UNREACHABLE` expand to no-op in release builds.
  (Actually, to `__builtin_unreachable ()` to avoid warnings.) As
  a consequence, makes both `jerry_assert_fail` and
  `jerry_unreachable` be guarded by `#ifndef JERRY_NDEBUG`. Also,
  changes `jerry_unreachable` not to expect a string parameter.
* Rewrites `TEST_ASSERT` not to rely on `jerry_assert_fail` as
  `TEST_ASSERT` has to work in release builds as well. This also
  allows changing the error message not to mention "ICE", which
  would misleadingly suggest an assert within the engine, but
  "TEST" instead.

As a side-effect of the cleanup, some refactorings happened in
jrt.h:

* Removed the definition of the unnecessary `__extension__` macro.
* Re-used `JERRY_UNUSED` and `unlikely` where possible.
* Moved some parts of the file around.
* Fixed some comments (`/**` should only be used for the docstring
  of a single entity, for groups header comments, the regular `/*`
  should be used).

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-05 10:09:32 +02:00
Robert Sipka
f15e7beadc Remove compact profile.
The standard doesn't defines ECMAScript Compact Profile as a subset of Ecma-262 Edition 5.1.
Profile modes can be added easily like the minimal profile if required.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-05 09:11:33 +02:00
István Kádár
79bc5d0220 Bugfixes related to low memory conditions.
- Bugfix for removing property hashmap in ecma_gc_run.
 - Fixed bug in ecma_create_property() caused by the new property pair allocation.

JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu
2016-08-04 14:08:48 +02:00
Akos Kiss
7f14a280b2 Fix logging of error message in jerry_fatal
As the comment of syscall error mentions, we should not try to log
(or print) anything in that case.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-03 18:17:40 +02:00
Slavey Karadzhov
ce8abfb636 Initial RAM optimization for ESP8266
by putting big constants into ROM, instead of residing in RAM.
Related to https://github.com/Samsung/jerryscript/issues/1224.

JerryScript-DCO-1.0-Signed-off-by: Slavey Karadzhov slaff@attachix.com
2016-08-03 11:54:43 +02:00
Zoltan Herczeg
d1b0b58729 Move all remaining globals to the global context.
Zero out all globals (and remove unnecessary init() functions).
Move snapshot globals to a temporary stack variable.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-08-01 04:25:32 -07:00
Robert Sipka
b14ca4e248 Complete the getting-started documentation after the build-system update.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-01 13:01:22 +02:00
Robert Sipka
e70c89e39e Comment fixes which are left behind after the API update.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-01 12:57:00 +02:00
Robert Sipka
e6fefd42bd Build fix for RIOT target after the modifications of the build system (commit ddab1d8).
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-08-01 12:42:34 +02:00
László Langó
37f9b475c0 Fix API examples after the IO Port update
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-08-01 09:27:41 +02:00
Robert Sipka
15ba287b9e Change the CONFIG_ECMA_NUMBER_TYPE default value to FLOAT64 to ensure compliance with ECMAScript 5.1
which requires numbers to be represented in double precision floating-point format.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-07-29 09:51:18 +02:00
Robert Sipka
ddab1d8152 Re-thinking the build system to bring it more into line with the conventions.
We removed that implementation where the build directory isn't set up to build with exactly one
configuration of the project but potentially several variants: the same build directory
can/must be used for debug and release builds, for full or compact profile versions, etc.
So we reworked the CMakeLists, and now one build dir deal with exactly one configuration
of the project's libraries and tools.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-07-28 12:29:55 +02:00
Tilmann Scheller
778f3c001e Remove CNAME file from the master branch.
Turns out that you need to add the CNAME file to the gh-pages branch rather than the master branch, thus removing it with this commit.

Related to #1218.

JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-07-28 08:01:28 +02:00
Slavey Karadzhov
23db8b5544 Refactoring of the ESP8266 target code to match the latest API.
Fixes issue #1211.

JerryScript-DCO-1.0-Signed-off-by: Slavey Karadzhov slaff@attachix.com
2016-07-27 13:35:30 +02:00
Zoltan Herczeg
76d42b5e8e Move GC, lcache, literal storage, lexical env global variables to jerry context.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-07-21 01:36:58 -07:00
István Kádár
e7ec053362 More gc-friendly property hashmap allocation.
- New allocator is added that returns null on out of memory, property hasmap create uses this allocator for now.
- Property hashmaps of objects are removed durring a high severity gc.

Follow up patch is in progress.

JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu
2016-07-20 17:31:24 +02:00
Paul Sokolovsky
80dc523ad3 targets/zephyr: REPL: Print expression result, or exception value.
With this change, REPL works almost the same as a standard JS REPL does
(browser console, Node.js, etc.). A result of each expression is
printed, e.g. "2+2" will print "4". Result is printed even if its
value is "undefined", e.g. "print(1)" will print "1", and on the next
line "undefined" (which is again how "normal" JS console work, except
a normal JS way to print to console is console.log()).

If an exception occured, a message "Error executing statement:", followed
by external representation of exception object, is printed. Note that
distinctive exception objects are supported only in "cp" (compact profile),
not in "cp_minimal". In the latter case, there's only exception hierarchy
top-level prototype, so any error message will look like:

    Error executing statement: [object Function]

(That's the reason why there's error message prefix - so it weren't too
confusing even if used in cp_minimal config. Unfortunately, compile-time
JerryScript configuration isn't available to Zephyr's main.c, so there's
no easy way to implement cp vs cp_minimal distinction).

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2016-07-20 17:39:20 +03:00
László Langó
1cdc66060f Fix RIOT port after API update
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-07-20 13:00:47 +02:00
László Langó
a004375e1d Remove printf calls from jerry core
Related issue: #964

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-07-20 12:43:14 +02:00
Zoltan Herczeg
12916c6c55 Fix minor implementation issues found in the JerryScript API.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-07-20 01:54:00 -07:00
Tilmann Scheller
8d69e26e75 Enable custom domain.
This enables the jerryscript.net domain for the GitHub project. This configuration file is necessary to enable the redirection from http://jerryscript.net to http://samsung.github.io/jerryscript.

JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-07-19 17:16:37 +02:00
István Kádár
9fcf6597f6 Memory leak is fixed in ecma_builtin_regexp_prototype_exec.
Issue fixed: #1079

JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu
2016-07-19 15:07:38 +02:00
Zoltan Herczeg
3a78d30897 Introducing global context.
Currently the static variables of the allocator are moved into a
global structure.

The future plan is supporting multiple context models with different
advantages and disadvantages. Users can select the most appropriate
context model for their own use case. This context model must be
selected at compile time using compiler defines.

Currently only one model is implemented, which will be the default
context model: the context is stored in global variables, so only
a single context is available which always exists.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-07-19 05:25:34 -07:00
Zidong Jiang
ca39875690 fix bug of "deref bytecode twice" in jerry_exec_snapshot
Enable the snapshot related test code in test-api.c

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2016-07-19 18:56:06 +08:00
Zsolt Borbély
dd3f801ae0 Update a link in README.md
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-07-18 09:57:32 +02:00
Zoltan Herczeg
3828f08796 Remove arbitrary case conversion tests.
Since upper/lower case conversions are unspecified by the standard,
we convert ASCII characters only, and a few other characters for
testing purposes. Because these are just random cases, it is better
to remove them before the release. At some point we could add a
unicode compatible case conversion which can be enabled at compile
time.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-07-15 06:38:13 -07:00
Zidong Jiang
6084f0845c Fix bug in jerry_string_to_char_buffer.
str_len can smaller than buffer_size.

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2016-07-15 21:06:47 +08:00
Dániel Bátyai
3354da3021 Optimize ecma_string_get_array_index
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2016-07-15 10:53:20 +02:00
László Langó
f0fd939d87 Move log level to default port
Setting the log level should be specified by the actual port.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-07-15 09:13:16 +02:00
László Langó
fa94c67ee7 Implement IO port API
Related issue: #964

Implemented the IO API of Jerry ports. Removed log file from API level.
The port implementation should define the destination of log messages.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-07-14 13:15:30 +02:00