2382 Commits

Author SHA1 Message Date
Zoltan Herczeg
1726bba184 Create extended objects instead of internal properties.
Several internal properties are removed and directly stored as
part of the object. Faster built-in and JS function processing.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-21 06:12:17 -07:00
László Langó
7f153c799a Improve empty checks of ecma strings
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-21 13:40:12 +02:00
Zsolt Borbély
2324617928 Guard assert-related functions
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-06-21 12:58:24 +02:00
László Langó
87b6df21c6 Update API examples
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-21 11:21:39 +02:00
Tilmann Scheller
04ab949126 Enforce pure C99 build.
Building with -std=c99 is not sufficient to enforce a pure C99 build as it still allows GNU extensions which don't conflict with C99 to be used. Add -pedantic to the build options to ensure that the codebase is only using C99 constructs and the build will fail whenever any compiler extension is used. This helps to ensure that JerryScript remains portable and can be built with any C99-compatible C compiler.

Removing -Wpedantic, as any warnings of that type will already trigger an error when building with -pedantic.

JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-06-21 08:26:16 +02: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
Zoltan Herczeg
37ebd20a72 Remove LIST_LAZY_PROPERTY_NAMES_ROUTINE_NAME macro function.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-17 06:20:06 -07:00
Zsolt Borbély
bb07151a39 Pack assert-related code
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-06-17 14:00:21 +02:00
Tilmann Scheller
5caf00606c Remove GCC 4.7 build requirement.
The GCC 4.7 check is a leftover from the times when JerryScript was a C++11 codebase, it was there to ensure that JerryScript is compiled with a GCC version which has sufficient support for C++11.

Today JerryScript is a pure C99 codebase (enforced by building all the sources with -std=c99) and this check is no longer necessary. JerryScript should now build just fine even with rather old versions of GCC.

JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-06-17 13:29:20 +02:00
Akos Kiss
edc695e108 Remove const array and scalar variables from ecma_utf8_string_to_number
There is no need for putting `LIT_CHAR_*` constants in const
scalars or arrays, they can be used directly. (There is especially
no need for arrays of 10 elements if only 2 of them are used.)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-06-17 03:38:22 -07:00
Akos Kiss
30fd549e7f Optimize number-to-string conversion
* Make constants static in `ecma_number_to_utf8_string`.
* Make `ecma_number_to_utf8_string` use early returns, and rewrite
  its self-recursion in case of negative numbers.
* Make the stringification of decimal exponent in
  `ecma_number_to_utf8_string` use `ecma_uint32_to_utf8_string`.

* Changed ERROL0 dtoa implementation to use the `double` type
  instead of `ecma_number_t`. Thus, even is `ecma_number_t` is 32
  bit wide, the algorithm works the same.
* Changed `ecma_number_to_decimal` to use the ERROL0 dtoa algorithm
  for 32-bit floats as well.
* Changed `ecma_number_to_decimal` to generate the decimal string
  representation of the mantissa instead of an `uint64_t` number.

* Changed `ecma_number_to_utf8_string` to make use of the already
  available string representation of the mantissa, generated now by
  `ecma_number_to_decimal`.
* Changed `ecma_number_to_utf8_string` not to use static arrays and
  variables for digit, "e", etc. generation.

* Changed all `Number.prototype.toXXX` implementations and the
  `ecma_builtin_number_prototype_helper_round` helper to make use
  of the already available string representation of the mantissa,
  generated now by `ecma_number_to_decimal`.
* Factored out the common stringification parts of all
  `Number.prototype.toXXX` implementations into a new helper
  `ecma_builtin_number_prototype_helper_to_string`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-06-17 03:36:35 -07:00
László Langó
65542549af Add conversion API functions
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-16 14:13:06 +02:00
László Langó
8e8504244b Update jerry API
* Fix error handling (related issue: #1141)
 * Move output paramters to the end of the arguments lists

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-16 13:43:33 +02:00
László Langó
8453a9ade8 Change return value of 'ecma_ref_ecma_string' to void
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-16 12:44:27 +02:00
László Langó
0daeb2f942 Remove string copy
Changed 'ecma_copy_or_ref_ecma_string' to 'ecma_ref_ecma_string'. It does
not copy the string if the maximum number of reference counter is reached,
but bails out with an error like the 'ecma_ref_object' function does.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-16 12:44:27 +02:00
Hanjoung Lee
7a3ed2650d Fix errol0_dtoa for DBL_MAX
When `val` is DBL_MAX, we get +inf from `ECMA_NEXT_FLOAT (val)`.
It is necessary to handle this case specially.

Related issue: #1054

JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee hanjoung.lee@samsung.com
2016-06-16 18:40:06 +09:00
Zoltan Herczeg
378d7f78ca Improve builtin-property construction.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-16 01:42:55 -07: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
Hanjoung Lee
1c43e5b02b Fix Date construct helper
Correct behaviour of step 8, 15.9.3.1, ECMA-262 v5.1.
 - Change ToInt32(y) to ToInteger(y).
 - If ToInteger(y) is not between 0 and 99 then yr = y

Related issue: #1071

JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee hanjoung.lee@samsung.com

JerryScript-DCO-1.0-Signed-off-by: Hanjoung Lee hanjoung.lee@samsung.com
2016-06-16 11:05:57 +09:00
Tilmann Scheller
372a2bb40b Cleanup README and add official IRC channel and mailing list.
JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-06-15 12:15:20 +02:00
László Langó
a816ab8bb0 Use 'ecma_value_t' in API too
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-14 14:44:02 +02:00
Zoltan Herczeg
b828d4a463 Rename ecma_is_value_error to ECMA_IS_VALUE_ERROR.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-14 02:31:34 -07:00
Zoltan Herczeg
1eeed7e07e Improve get-value.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-14 01:58:52 -07:00
Zsolt Borbély
ce905487a0 Introduce JERRY_UNUSED() instead of __attr_unused___
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-06-14 08:45:14 +02: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
Zsolt Borbély
c557a0a047 Modify the usage of ecma_string_to_utf8_string()
Parts:
 * Rename ecma_string_to_utf8_string() to ecma_string_copy_to_utf8_buffer.

 * Introduce ecma_string_to_utf8_bytes(), which wraps the usual 'function call-assertion' pair,
   and check strict equality of size of the string and the buffer.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-06-13 15:21:30 +02:00
Zoltan Herczeg
eac736ffa4 Rename try_give_memory_back to a better free_unused_memory.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-13 05:35:53 -07:00
Zoltan Herczeg
495b24eebc Optimize put result phase in the interpreter.
Skip put result phase for opcodes which put their
result onto the stack or they don't have result at all.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-10 01:26:42 -07:00
Zoltan Herczeg
eed84a7dd9 Parser improvements.
The number of delete opcodes is reduced to two from six. The
range of numbers which can be included in the byte code is
doubled from (-127,127) to (-256,256).

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-10 01:18:17 -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
Zoltan Herczeg
d953fbb7be Branch opcodes have no result and either they have a stack argument
or no arguments at all. To improve the performance, the branch argument
flag is changed into a get argument type which eliminates a flag check
for all executed opcodes. Furthermore branch opcodes skip the put result
phase by changing the "break" to "continue" statements.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-09 01:20:36 -07:00
Zsolt Borbély
2834423fd2 Remove surplus attribute-defines from jrt.h
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-06-08 15:44:01 +02:00
László Langó
b5efa2ea03 Updated API examples, after API changes
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-08 12:48:47 +02:00
László Langó
824d39c2a2 Update API functions
* Rename 'jerry_api_' prefix to 'jerry_'
 * Fix minor style issues
 * Group the API functions and add comment to each group
 * Move engine behaviour related funtions to 'jerry.h'

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-08 12:48:47 +02:00
Zoltan Herczeg
3e0572e433 Optimize add operation.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-08 03:07:18 -07: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
Zoltan Herczeg
308bb3c8e1 Remove last_completion_value.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-03 04:12:10 -07:00
Zoltan Herczeg
98d2b66e40 Reduce the default LCache size by half. From 4Kbyte to 2Kbyte.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-03 02:17:43 -07:00
Zoltan Herczeg
6f33ab3e8f Improve equal operations.
The implementation is simplified and optimized
resulting the removal a large amount of code.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-03 02:10:44 -07:00
Zoltan Herczeg
5c852ab6fb Optimize LCache operation.
The cache stores only real properties now, because storing NULLs has
little benefit according to tests. Since only real properties are
stored now, there is no need to create real references to objects
and property names, which reduces the keeping of dead objects after
garbage collection.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-02 03:56:36 -07:00
Akos Kiss
d7f95434e2 Improve the output of test runner
* Improve the name of the temporary snapshot files in test runner:
  Until now, test runner used a completely random filename for the
  temporary snapshot file when testing (saving to and executing from)
  snapshots. This patch makes the temp file contain part of the name
  of the original test file in order to make reading the logs (and
  thus, identifying failing tests) easier.

* Add `--snapshot` to summary info of test runner if testing snapshot
  support:
  This helps reading the logs, especially when multiple tests run in
  parallel and get their output mixed. E.g., on the CI, all tests
  write the console at the same time and messages get interleaved.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-06-01 15:43:29 +02:00
Robert Sipka
331bdddea9 Insert parameters between the pair of parentheses in the JERRY_MIN and JERRY_MAX macro definitions
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-06-01 15:18:32 +02:00
Robert Sipka
8a911bb6cb Use 'ecma_get_float_from_value' instead of 'ecma_get_number_from_value' in the ToString operation.
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-06-01 15:03:06 +02:00
Zoltan Herczeg
a5d9701f60 Optimize uint32 hash computation.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-01 05:09:58 -07:00
István Kádár
71c32a1d96 API documentation update under docs.
Links to JerryScript API reference page (https://samsung.github.io/jerryscript/API/) are inserted.

JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu
2016-06-01 12:58:17 +02:00
László Langó
ed08518bd7 Code simplification
Move the enclosed condition forward and combine the two if statements.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-06-01 09:58:29 +02: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
Zsolt Borbély
36c7440c40 Restore the previous way to convert strings in ecma_builtin_json_parse()
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-05-31 15:52:28 +02:00
Zoltan Herczeg
f24be95f89 Optimize conditional jumps.
The ecma_op_to_boolean return value is changed to bool for faster
evaluation, and no need to swap operandos of relational compare.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-05-30 05:56:22 -07:00