43 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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ó
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
Paul Sokolovsky
6b60e22e30 targets/zephyr: Update to new Jerry API and improve REPL interaction.
Various calls updated to use API from jerry-api.h (to-be JerryScript 1.0
API).

Use jerry_eval() instead of jerry_run_simple(), as it allow to store (and
then access) variables in a global environment. E.g. following now works
(entered and executed as two separate lines):

    a = 1
    print(a)

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2016-07-12 14:33:07 +03:00
Paul Sokolovsky
0898bf4835 targets/zephyr: Add support for NXP FRDM-K64F board.
Tested to boot and run "test" one-liner.

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2016-07-04 17:38:13 +03:00
Sergio Martinez
c8db27c4af Fix issue when you don't flash the ARC and the x86 waits
- Fixed problem when the x86 hangs waiting for the ARC to
be initialized. If you flash as arduino_101 instead of
arduino_101_factory this will happen and you will not get
a command line.

- Changed default build to arduino_101_factory which is
the current recommended method of flashing the arduino_101

- Updated documentation to explain a few bits on how to flash
the board and conform to the v1.4.0 way of flashing the device.

- Added a helper to run the dfu-util command directly on make.

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
2016-07-01 13:40:22 +01:00
Sakari Poussa
88db00ae4b [zephyr] rename SOURCE_DIR to ZEPHYR_TARGET_SRC_DIR in Makefile.zephyr
In Makefile.zephyr the SOURCE_DIR variable was introduced recently.

However, the SOURCE_DIR variable is heavily used in zephyr. If you try to build
the jerryscript zephyr port from a zephyr project using the makefiles, the
SOURCE_DIR gets set by the zephyr build system and points to wrong place here.

This patch creates unique name to avoid the name clash.

JerryScript-DCO-1.0-Signed-off-by: Sakari Poussa sakari.poussa@intel.com
2016-06-30 14:48:47 +03:00
Sakari Poussa
130be84ad1 [zephyr] Makefile tuning
Read the zephyr crosscompile settings earlier so correct values are used.

Currently, the crosscompilation does not work on OSX. With this fix it does.

JerryScript-DCO-1.0-Signed-off-by: Sakari Poussa sakari.poussa@intel.com
2016-06-28 14:28:20 +03:00
Paul Sokolovsky
4091444016 targets/zephyr: Rename from arduino_101, with more targets supported.
- Add preliminary support for ARC architecture.

Using "em_starterkit" board supported by Zephyr. Only build for this board
is tested, not booted on a real device due to lack of access. There's no
QEMU emulation support for ARC in Zephyr (yet) either.

- Update README to cover different Zephyr architectures/boards.

- Changed the arduino_101 paths to something more generic and adaptable
- Made sure it compiles and runs on Arduino 101

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2016-06-23 13:02:20 +03:00
Robert Sipka
c0665da299 Build fix for ALL_IN_ONE and COMPILER_DEFAULT_LIBC
The build fails with enabled ALL_ON_ONE and enabled COMPILER_DEFAULT_LIBC options,
because the _BSD_SOURCE doesn't defined before including the sys/time.h.

In case of glibc, the 'timezone' is not part of C99 but part of POSIX, so we need
to define the _BSD_SOURCE feature test macro before including sys/time.h to get
the prototype for this struct.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-06-19 07:39:48 +02:00
Paul Sokolovsky
78186445a4 targets/arduino_101: Refactor to better support other Zephyr targets.
This adds support for ARM/Thumb2 (Cortex-M) architecture, tested with
BOARD=qemu_cortex_m3 (i.e. QEMU with Cortex-M emulation). Should also
ease porting to other architectures supported by Zephyr.

This uses method of passing external libraries and link options into a
Zephyr application using ALL_LIBS and LDFLAGS_zephyr make variables, as
suggested by the Zephyr developers:
https://gerrit.zephyrproject.org/r/#/c/2476/ , and makes sure to append
to them, instead of assigning, to not overwrite important target-specific
options set by the Zephyr core.

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
2016-06-16 11:22:21 +03:00
Jimmy Huang
4afd76d932 Updated Zephyr command line shell after API changes
JerryScript-DCO-1.0-Signed-off-by: Jimmy Huang jimmy.huang@intel.com
2016-06-13 10:06:39 -07:00
Robert Sipka
3c83af9f23 Rename 'jerry_api_' prefix to 'jerry_' in the main-riotos.c file
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-06-09 17:03:01 +02:00
Robert Sipka
0dd1082d6f Added target to compile RIOT-OS against jerryscript
This patch contains an example in which you can run a small js on RIOT-OS with STM32F4-Discovery.
Check the README.md for a more detailed explanation of how to compile and run it.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-06-09 14:53:12 +02:00
Sergio Martinez
7583b63a6e Added target to compile zephyr against jerryscript.
This patch contains a project in which you can run
a small js test inside the Arduino101.

Follows the Nuttx implementation to replicate a command
line in the Quark SE Lakemont architecture.

Everything is self contained in the targets/arduino_101 folder.
It has only been tested with the arduino 101 at the moment.

Check the README.md for a more detailed explanation of
how to compile and run it.

- Command line javascript run test.

Use test to get a default test.

Write any valid javascript in the shell and get it resolved and executed

- Support for qemu
- Added extra verbose mode on the demo function
- Support to build factory images that can be flashed with dfu-util
- Added a few extra examples on the README about commands that work.

Small fixes to readme and libc_support.c (#1)

- Added a few more instructions to the README.md for arduino_101
- Added the stdint.h include in libc_support.c
- Added parameter to check-vera.sh to check a specific folder
- Cleared the libc function duplication

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
2016-06-06 17:47:43 +01:00
SaeHie Park
ed2a3602f4 Fix ESP8266 build
This change is to fix build for ESP8266 board with jerry_api_value_t changes.

JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2016-06-01 08:05:17 +09:00
Rob Moran
54d6e1f44f Updated readme.md to reflect new folder structure.
JerryScript-DCO-1.0-Signed-off-by: Rob Moran github@thegecko.org
2016-05-07 17:42:03 +01:00
Imre Kiss
5369fd4515 Merged target for mbed boards.
Merged the mbed releated targets into one source.
Available targets: FRDM-K64f, Discovery-STM32F4, Discovery-STM32F429ZI, NUCLEO-STM32F4

JerryScript-DCO-1.0-Signed-off-by: Imre Kiss kissi@inf.u-szeged.hu
2016-05-06 13:33:26 +02:00
Robert Sipka
94161d350a Check the return value of the gettimeofday() in 'jerry_port_get_time_zone' and 'jerry_port_get_current_time' functions.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-05-06 10:50:39 +02:00
Akos Kiss
33a1203d6b Drop jerry_port_putchar
Recent changes eliminate the need for `jerry_port_putchar`. As port
API discussions don't make it likely that it will ever be needed
again, this patch removes its declaration from jerry-port.h and its
implementations from the port(s).

The related code in jerry-libc is not needed either: whatever `putc`
(and `puts`) can do, `printf` can do as well.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-23 22:50:50 +02:00
Akos Kiss
68f3465eb5 Change current time from uint64_t to double in Date Port API
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-21 14:51:31 +02:00
Akos Kiss
b523cf3cd1 Introduce the Date Port API
Replaced `gettimeofday`-related code with `jerry_port_get_current_time`
and `jerry_port_get_time_zone` function calls. Moved old code to
default port implementation.

Removed `ENABLE_DATE_SYS_CALLS` as date syscalls should "just work".

Fix DST adjustments: even if `gettimeofday` returns meaningful data in
`tz_dsttime`, the value is just a flag (or, according to some sources,
a tri-state value: >0 if DST applies, ==0 if DST does not apply, <0 if
unknown). Hitherto, the field was simply added to/subtracted from a
time value in milliseconds. To use it approximately correctly, the
field's value should be multiplied by "millisecs/hour".

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-20 17:56:30 +02:00
Akos Kiss
02ba19f24d Introduce the Termination Port API
* Moved the error codes to jerry-port.h and declared port function
  `jerry_port_fatal`.

* Moved "exit or abort on fail" functionality to the newly added
  jerry-port-default-fatal.c.

* This implied that a default port-specific API had to be introduced:
  functions `jerry_port_default_set_abort_on_fail` and
  `jerry_port_default_is_abort_on_fail` declared in jerry-port-default.h
  control the fatal exit behaviour.

* For the sake of clarity, renamed jerry-port.c to
  jerry-port-default-io.c.

* Adapted CMakeLists to deal with port implementations consisting of
  more then one source file and exposing headers. This also required
  the renaming of `EXTERNAL_PORT_FILE` cmake option to
  `EXTERNAL_PORT_DIR`.

* Adapted main sources to use the default port header for the
  abort-on-fail functionality, as that is not part of the core jerry
  API anymore.

* Added default port implementation to the static source code checker
  tools.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-19 14:10:18 +02:00
Akos Kiss
bb665336d4 Fix layering violation in applications
Apps that use jerry should not (must not!) include and rely on its
internal headers. Typical issue is the use of "jrt/jrt.h". Fixing
`main-{unix,mcu}.c`, and speculatively the apps under the `targets`
directory as well.

(Note: a fix can be either including "jerry-port.h" and using
functions declared there, e.g., `jerry_port_errormsg`, or simply
using standard libc function like `printf`. Both approaches occur
in this patch.)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-15 17:16:28 +02:00
Akos Kiss
3ba286f3e1 Turn modified fdlibm into Jerry's own libm
* Rename modified fdlibm to jerry-libm
  * Move third-party/fdlibm to jerry-libm
  * Rename original fdlibm.h to jerry-libm-internal.h
    * And remove it from the public headers.
  * Rename jerry-libm's public header to math.h
    * This also makes jerry-core sources include `<math.h>`. Therefore,
      should anyone want to use a different libm implementation with
      jerry, it becomes possible. (The same way as we provide a minimal
      libc with standard headers, but should it be insufficient or
      conflicting for someone, it can be replaced.)
  * Drop `s_` prefix from jerry-libm sources
    * The original fdlibm implementation had various prefixes (e.g., `k_`
      for sources of kernel routines, and `w_` for wrapper routines), but
      after the specialization of fdlibm to jerry, only `s_` remained.
      Since it does not encode anything anymore, it can be dropped.
  * Stylistic edits to jerry-libm's CMakeLists
    * Align project name with other CMakeLists in the code base
  * Move Jerry-LibM under Apache License
    * Using the same approach as was used by linux-wireless when ath5k
      driver license needed clarification. Solution was proposed by SFLC.
      External mail for future reference: http://lwn.net/Articles/247806/

* Tests & checks
  * Remove FD from the name of libm unit test-related files
  * Make vera++ and cppcheck check jerry-libm

* Targets
  * Speculative update of targets to use jerry-libm

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-04-08 15:38:47 +02:00
Zsolt Borbély
21f8f06c51 Test the build options
Add new build target: test-buildoptions
Now every build option is tested on the proper targets. These are the native
and the MCU targets in release mode and unittests.
Therefore the USE_COMPILER_DEFAULT_LIBC build option is refactored.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-03-25 10:19:00 +01:00
François Baldassari
94f887919e Make target provide jerry-port.c
JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com
2016-03-21 13:08:11 -07:00
François Baldassari
05e7a837c4 Allow external builds to use non-gnu compilers
JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com
2016-03-11 10:13:26 -08:00
Akos Kiss
6e687fa6b7 Remove support for per-instruction memory statistics
The new CBC interpreter does not support it anymore, thus removing
related code.

(As a side-effect, `jerry_flag_t` has been refactored from
`uint32_t` and associated defines to an enum.)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-03-10 13:19:36 +01:00
Robert Sipka
977bfa5d2c Remove g++ support from the [C]Make files.
Move all '.cpp' files to '.c'.
Rename comments from 'cpp' to 'c'.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-02-15 12:49:12 +01:00
SaeHie Park
ef1252e29e targets: add nuttx interpreter build
JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2016-02-10 08:50:12 +01:00
Roland Takacs
efc994b112 Use C type casting instead of static_cast.
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.u-szeged@partner.samsung.com
2016-02-05 12:59:14 +01:00
SaeHie Park
25b8351774 targets: merge js2c.py into targets/tools folder
* also add .PHONY to target makefiles

JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2016-01-14 18:49:57 +09:00
SaeHie Park
feb27a5fc6 Add target build for ESP8266 board.
JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2016-01-14 07:27:18 +09:00
SaeHie Park
fe24452460 Add target build for mbed / FRDM-K64F board.
JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
2016-01-14 07:24:57 +09:00