375 Commits

Author SHA1 Message Date
Sanggyu Lee
af16a3ae1a Implement typedarary.set(array, offset)
JerryScript-DCO-1.0-Signed-off-by: Sanggyu Lee sg5.lee@samsung.com
2017-08-11 14:38:37 +09:00
Robert Fancsik
ad608e30dc Improve toFixed function
Fixes #1367.
From now numbers are represented as binary floating-point which guarantees the expected operation of toFixed function.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2017-08-10 08:27:27 +09:00
rerobika
d75710cf27 replace_str_curr_p must be inspected before dereferencing (#1926)
Fixes #1917.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2017-07-20 10:26:51 +02:00
Robert Fancsik
3d744c958f Shifting array element down in the tree must be finished even if an error occurs
Fixes #1671

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2017-07-13 17:54:14 +09:00
Robert Sipka
89015a6119 Improve split method to gain memory (#1893)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-07-10 10:49:16 +02:00
Zoltan Herczeg
838e74df0f Remove include jerryscript.h from jrt.h. (#1803)
Fixes #1791.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-05-11 12:42:47 +02: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
Akos Kiss
240411771a Remove the built-in print and the jerry_port_console port API functions (#1749)
The built-in `print` is removed from jerry-core, but an external
`print` implementation is added to jerry-main. From now on, all
embedders of the engine have to implement their own `print` if they
need such a functionality.

For printing results in REPL mode of jerry-main, the external
`print` handler is called directly instead of looking up the `print`
function registered into the global object. (The two are the same,
but the indirection is not needed anymore.)

Because jerry-core does not contain `print` anymore,
`jerry_port_console` is removed from the port API. The default port
is updated, i.e., the implementation of `jerry_port_console` is
removed. Additionally, all references to `jerry_port_console` in
jerry-main are replaced by `printf`.

Speculatively, `jerry_port_console` is also removed from all
non-default targets. Most targets implemented it for the sake of the
engine only; in those targets the removal was trivial. Where the
function was called from the embedder application as well, the
calls were replaced with equivalents (e.g., `printf`, `printk`).

NOTE 1: This is a breaking change!

NOTE 2: This patch still leaves several targets without a JS `print`
implementation.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-05-03 11:47:56 +02:00
Zidong Jiang
078f6e101d Implement other routines of Promise (#1729)
Add Promise.resolve, Promise.reject, Promise.race, Promise.all and
Promise.prototype.catch

Also it fixes the issue 1763

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-04-26 19:47:51 +08: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
Zidong Jiang
eb8dd4602b Implement the basic Promise (#1695)
Implement the Promise Constructor and routine: 'then'

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-04-12 22:10:08 +08:00
Robert Sipka
5f24620c8a Fix helper function for rounding numbers (#1702)
Fixes #1701

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-04-03 08:44:46 +02:00
Zoltan Herczeg
750e0ca9d5 Fix several style fixes for typed arrays and optimize filter a bit. (#1697)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-03-30 16:06:11 +02:00
Zidong Jiang
41c63e08b1 Combine ARRAYBUFFER and TYPEDARRAY macros together (#1699)
Change CONFIG_DISABLE_ES2015_ARRAYBUFFER_BUILTIN to
CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
Because typedarray depends on arraybuffer and it doesn't make sense to
enable arraybuffer only.

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-03-30 21:22:22 +08:00
Robert Sipka
3ff9a7de8a Fix the number of copied bytes in memmove (#1698)
Fixes #1634

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-03-30 10:40:05 +02:00
Levente Orban
c09ba8cdb3 Rename 'CONFIG_DISABLE_ARRAYBUFFER_BUILTIN' to 'CONFIG_DISABLE_ES2015_ARRAYBUFFER_BUILTIN' (#1687)
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
2017-03-24 11:30:23 +01:00
Zidong Jiang
8571ebfae5 Implement %TypedArray%.from and fix the issue #1670 (#1679)
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-03-24 10:37:22 +01:00
Levente Orban
f50193111b Rename 'CONFIG_DISABLE_TYPEDARRAY_BUILTIN' to 'CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN' (#1683)
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
2017-03-24 08:06:03 +01:00
Akos Kiss
4a5df52aa1 Factor out common macro un/definitions used for built-in descriptions (#1678)
The default definitions and undefinitions of macros used for built-in
descriptions (SIMPLE_VALUE, NUMBER_VALUE, STRING_VALUE, OBJECT_VALUE,
ROUTINE, ACCESSOR_READ_WRITE, ACCESSOR_READ_ONLY) are heavily cloned
all over the builtin-objects directory. This commit factors them out
into two header files, which are then included in the place of the
clones. This way, maintenance becomes a lot easier: e.g., if a new
macro gets introduced, default definition and undefinition don't have
to be added to all description files (of which there are 56 right now,
and their number will most probably just grow).

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-03-23 09:36:29 +01:00
Robert Sipka
78e4dcf6c2 Build fix for 32-bit float ecma-number storage (#1669)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-03-22 14:18:43 +01:00
Robert Sipka
7e1ade3406 Remove logically dead code (#1674)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-03-22 10:17:12 +01:00
Levente Orban
4420401cf5 Style fix: return value comments (#1668)
JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
2017-03-21 10:24:54 +01:00
Akos Kiss
e66bb5591d Implement Object.setPrototypeOf from ES2015 specification (#1666)
`Object.prototype.__proto__` has been implemented by most JS
engines to give R/W access to prototype chains, well before it made
it into the standard. JerryScript has decided not to implement it,
exactly because it was not part of ES 5.1. The only fully
ES5.1-compatible way of accessing the prototype chain is
`Object.getPrototypeOf` for reading.

However, ES2015 defines `Object.setPrototypeOf` for rewriting the
prototype chain, and JerryScript has now an ES2015 subset profile.
So, this commit adds its implementation to JerryScript.

Note, this commit does _not_ add `Object.prototype.__proto__`,
since that is in the Annex B of ES2015 specification, which is
optional for non-web-browser hosts.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-03-21 10:11:07 +01:00
Akos Kiss
edadc53def Fix Date objects' YearFromTime helper for out-of-range time values (#1658)
For negative out-of-range time values, ecma_date_year_from_time
fell into an infinite loop. (Moreover, for positive out-of-range
time values, it returned an incorrect year.) This patch fixes the
helper to return NaN in these cases (and ensures that its call
sites are prepared for NaN values).

Fixes #1657.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-03-16 17:03:42 +01:00
Robert Sipka
818c9cd0b0 Fix issue #742 (#1650)
It is a workaround fix. The problem comes from the inaccuracy of the double rounding.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-03-16 08:59:48 +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
Zoltan Herczeg
1b4426fd2a Check whether match result has error flag. (#1653)
Fixes #1641.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-03-14 10:01:22 +01:00
Zidong Jiang
c6f22a9683 Make sure the size arg of alloc will not overflow (#1618)
Also make sure the bytelength = arraylength << shift will not overflow

Fix issue #1616

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-03-07 08:37:19 +09:00
Zoltan Herczeg
3de72af712 NaN must not be passed to date getter functions. (#1620)
Fixes #1547

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-02-27 11:19:29 +01:00
Robert Sipka
39dc4a6273 Remove shadowed declarations, undefined identifiers, and specify argument types where it is required. (#1601)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-02-22 10:34:44 +01:00
Zidong Jiang
4727202c8e Add typedarray routine:reverse (#1585)
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-02-16 18:32:13 +01:00
László Langó
799726aa42 Add new input validator API functions (#1576)
Fixes #1549

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-02-16 18:31:04 +01:00
Zidong Jiang
64a340ffeb typedarray routine: filter (#1581)
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-02-15 19:20:15 +01:00
Zidong Jiang
24e6c3f062 Add typedarray routine: reduce and reduceRight (#1569)
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-02-10 13:36:00 +01:00
Zidong Jiang
7b01b29ec8 Add typedarray routine: every, some, foreach, and map (#1566)
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-02-09 08:49:00 +01:00
Zoltan Herczeg
589f2dec92 String.match should return on error. (#1560)
Fixes #1546.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-02-03 15:16:49 +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
Zidong Jiang
0547b31c16 [ES2015][TypedArray] add other 8 types (#1532)
Add Uint8Array, Int16Array Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array and Uint8ClampedArray. Support the conversion between any pairs of those types.

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-01-24 15:06:31 +01:00
t-harvey
94b6aae52c Added #if control around GCC built-in functions so that the code can be (#1483)
compiled using non-GCC compilers.

This included adding an initialization to a variable that looks(!)
like it can reach a use before being initialized (b/c we turned
JERRY_UNREACHABLE into a nop) -- an example:

int foo;
switch (value_can_only_be_one_or_two)
   case 1:
   case 2:
       foo = 5;
   default:
      JERRY_UNREACHABLE();
x = foo +1;

...the compiler assumes that the path can go through the default case,
which leaves the value of foo undefined.

JerryScript-DCO-1.0-Signed-off-by: Timothy Harvey t-harvey@ti.com
2017-01-23 12:19:35 +01:00
László Langó
471ad284f6 Remove 'OBJECT_ID' from builtin headers. (#1529)
After 378d7f7 it is not used in the codebase and can be eliminated.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-01-17 08:58:46 +01:00
Zidong Jiang
adfe61b4ed [ES2015 profile]add TypedArray intrinsic object (#1507)
* add %TypedArray% intrinsic object
* implement Int8Array
* will implement other types and prototype functions
in the following patches.

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-01-13 11:04:34 +01:00
Zoltan Herczeg
7d83293762 Improve date helpers. (#1499)
Rework date to string conversion, and remove nan checks from inline
functions. Furtermore some inline functions are changed to normal
functions.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-01-11 08:27:29 +01:00
Robert Sipka
445ca1d6de Add jerry_string_to_utf8_char_buffer API function. (#1501)
Copy the characters of a string into a specified utf-8 string buffer.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-01-05 09:35:31 +01:00
Akos Kiss
0026519040 Fix documentation errors (#1510)
Doxygen reported a few issues, which are fixed by this patch:
* ArrayBuffer-related documentation group names and titles were
  incorrect.
* Some Date-related helper functions used incorrect parameter
  documentation syntax.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-01-03 18:03:47 +01:00
Zoltan Herczeg
0c7d99e8e7 Reduce Math object binary size. (#1491)
Although many Math built-in functions have a similar structure
these code paths were implemented as separate C functions.
After this patch only one common dispatcher remains which shares
the common code paths of different built-in functions. This
reduces the binary size by 1 Kbyte.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-12-19 13:48:17 +01:00
Tilmann Scheller
65c32f6a3b Add parameter names to function declarations. (#1498)
It's generally considered a bad programming practice to have function declarations without parameter names.

This is another legacy from the early days of the project. Fix in one go to minimize history disruption.

Used a custom clang-tidy check to create the bulk of the change.

JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-12-16 15:40:46 +01:00
Tilmann Scheller
1e99be90c3 Remove redundant extern keywords from function declarations/definitions. (#1495)
Extern keywords on function declarations/definitions provide no additional value since function declarations/definitions default to external linkage in C99, e.g. removing them won't change the semantics of the program.

The extern keywords were essentially a legacy from the early days of the project. This commit cleans this up across the whole codebase in one go to minimize history disruption.

The bulk of the changes in this commit were produced by a custom clang-tidy checker.

Note that variables declarations carrying the extern keyword are untouched by this commit since there the presence of the keyword actually has an impact on the semantics of the program.

JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-12-16 10:18:37 +01:00
Zoltan Herczeg
7423226acc Reduce Date prototype binary size. (#1488)
Before this patch each built-in routine had a separate C
function. Although these functions shared a lot of common
operations compilers cannot eliminate these code duplications
in the final binary code. This patch introduces a single C
function which handles all date prototype routines. Each
shared code block has only one binary represenation.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-12-13 13:41:36 +01:00
Zoltan Herczeg
6904b9bd65 Do not copy source string by JSON parser. (#1481)
The JSON parser required a zero terminated writable copy of
the original string. The requirement is eliminated from the
project to reduce peak memory consumption.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-12-13 08:36:01 +01:00
Zoltan Herczeg
9d6ca800e1 Remove INSTANTIATED_MASK_32_63 internal property type. (#1474)
Furthermore the maximum number of properties is increased to 96.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-12-09 13:28:06 +01:00