Update the webpage (#4540)
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
This commit is contained in:
+22
-17
@@ -15,16 +15,19 @@ A configuration option's value can be changed either by providing specific C pre
|
|||||||
This document lists the available configuration options, shows the configuration name for C, CMake, and python, and provides a brief description that explains the effect of the options.
|
This document lists the available configuration options, shows the configuration name for C, CMake, and python, and provides a brief description that explains the effect of the options.
|
||||||
|
|
||||||
|
|
||||||
### All-in-one build
|
### Amalgamated build
|
||||||
|
|
||||||
Enables the All-in-one build process, which aggregates the contents of each source file, and uses this combined file to compile the JerryScript library.
|
Enables the amalgamated build process, which aggregates the contents of each source file per library
|
||||||
This process can provide comparable results to link time optimization, and can be useful when LTO is not available otherwise.
|
(i.e., JerryScript's core, port, and math libraries), and uses these combined files to compile the project.
|
||||||
|
This process can provide comparable results to link-time optimization, and can be useful when LTO is not available otherwise.
|
||||||
|
|
||||||
| Options | |
|
| Options | |
|
||||||
|---------|----------------------------------------------|
|
|---------|----------------------------------------------|
|
||||||
| C: | `<none>` |
|
| C: | `<none>` |
|
||||||
| CMake: | `-DENABLE_ALL_IN_ONE=ON/OFF` |
|
| CMake: | `-DENABLE_AMALGAM=ON/OFF` |
|
||||||
| Python: | `--all-in-one=ON/OFF` |
|
| Python: | `--amalgam=ON/OFF` |
|
||||||
|
|
||||||
|
See also: [Amalgamated sources](#amalgamated-sources)
|
||||||
|
|
||||||
### Jerry debugger
|
### Jerry debugger
|
||||||
|
|
||||||
@@ -288,25 +291,27 @@ This option is disabled by default.
|
|||||||
| Python: | `--mem-stress-test=ON/OFF` |
|
| Python: | `--mem-stress-test=ON/OFF` |
|
||||||
|
|
||||||
|
|
||||||
# Single source build mode
|
# Amalgamated sources
|
||||||
|
|
||||||
There is a special mode to use/"build" JerryScript. That is generating a single C file which can be
|
The sources of JerryScript can be combined into a handful of files to allow their easy integration
|
||||||
included into projects quickly. To achive this the following command can be executed to create
|
in other projects. To achieve this, the following command can be executed to create a set of files
|
||||||
a set of files into the `gen_src` directory (Note that the command is executed in the jerryscript root directory
|
into the `amalgam` directory:
|
||||||
but can be adapted to run outside of the project root dir):
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ python tools/srcgenerator.py --output-dir gen_src --jerry-core --jerry-port-default --jerry-libm
|
$ python tools/amalgam.py --output-dir amalgam --jerry-core --jerry-port-default --jerry-math
|
||||||
```
|
```
|
||||||
|
|
||||||
The command creates the following files in the `gen_src` dir:
|
(Note: In the example above, the command is executed from the project's root directory, but that is
|
||||||
|
not mandatory.)
|
||||||
|
|
||||||
|
The command creates the following files in the `amalgam` dir:
|
||||||
|
|
||||||
* `jerryscript.c`
|
* `jerryscript.c`
|
||||||
* `jerryscript.h`
|
* `jerryscript.h`
|
||||||
* `jerryscript-config.h`
|
* `jerryscript-config.h`
|
||||||
* `jerryscript-port-default.c`
|
* `jerryscript-port-default.c`
|
||||||
* `jerryscript-port-default.h`
|
* `jerryscript-port-default.h`
|
||||||
* `jerryscript-libm.c`
|
* `jerryscript-math.c`
|
||||||
* `math.h`
|
* `math.h`
|
||||||
|
|
||||||
**Important**: the `jerryscript-config.h` contains the configurations mentioned above and
|
**Important**: the `jerryscript-config.h` contains the configurations mentioned above and
|
||||||
@@ -314,15 +319,15 @@ should be adapted to the required use-case. See the file contents for more detai
|
|||||||
default configuration. (Note: This config file is created from the the `jerry-core/config.h` file.)
|
default configuration. (Note: This config file is created from the the `jerry-core/config.h` file.)
|
||||||
|
|
||||||
These files can be directly compiled with an application using the JerryScript API.
|
These files can be directly compiled with an application using the JerryScript API.
|
||||||
For example with the following command:
|
E.g., using a command similar to the one below:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc -Wall -o demo_app demo_app.c gen_src/jerryscript.c gen_src/jerryscript-port-default.c jerryscript-libm.c -Igen_src/
|
$ gcc -Wall -o demo_app demo_app.c amalgam/jerryscript.c amalgam/jerryscript-port-default.c amalgam/jerryscript-math.c -Iamalgam/
|
||||||
```
|
```
|
||||||
|
|
||||||
Please note that the headers must be available on the include path.
|
(Note: The headers must be available on the include path.)
|
||||||
|
|
||||||
In addition there is a `-DENABLE_ALL_IN_ONE_SOURCE=ON` CMake option to use this kind of sources during the build.
|
This approach is also under the hood of the [amalgamated build](#amalgamated-build) process.
|
||||||
|
|
||||||
# Target specific information
|
# Target specific information
|
||||||
|
|
||||||
|
|||||||
+775
-24
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -42,7 +42,7 @@ $ export PKG_CONFIG_PATH=$(pwd)/example_install/lib/pkgconfig/
|
|||||||
Test if the `pkg-config` works for JerryScript:
|
Test if the `pkg-config` works for JerryScript:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-libm
|
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-math
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example 1. Execute JavaScript from your application
|
## Example 1. Execute JavaScript from your application
|
||||||
@@ -68,7 +68,7 @@ main (void)
|
|||||||
To compile it one can use the following command:
|
To compile it one can use the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
$ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything is correct the application returns with a zero exit code:
|
If everything is correct the application returns with a zero exit code:
|
||||||
@@ -128,7 +128,7 @@ main (void)
|
|||||||
To compile it one can use the following command:
|
To compile it one can use the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
$ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything is correct the application returns with a zero exit code:
|
If everything is correct the application returns with a zero exit code:
|
||||||
@@ -191,7 +191,7 @@ main (void)
|
|||||||
To compile it one can use the following command:
|
To compile it one can use the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
$ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything is correct the application returns with a zero exit code:
|
If everything is correct the application returns with a zero exit code:
|
||||||
@@ -295,7 +295,7 @@ main (void)
|
|||||||
To compile it one can use the following command:
|
To compile it one can use the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
$ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything is correct the application should print out the message present in the `print_handler` method:
|
If everything is correct the application should print out the message present in the `print_handler` method:
|
||||||
@@ -415,7 +415,7 @@ main (void)
|
|||||||
To compile it one can use the following command:
|
To compile it one can use the following command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
$ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
||||||
@@ -483,7 +483,7 @@ To compile it one can use the following command:
|
|||||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
$ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
||||||
@@ -559,7 +559,7 @@ To compile it one can use the following command:
|
|||||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
$ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
The sample will output 'Hello from C!'. However, now it is not just a part of the source script, but the value, dynamically supplied to the engine:
|
The sample will output 'Hello from C!'. However, now it is not just a part of the source script, but the value, dynamically supplied to the engine:
|
||||||
@@ -832,7 +832,7 @@ To compile it one can use the following command:
|
|||||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
$ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
The application reads lines from standard input and evaluates them, one after another. To try out run:
|
The application reads lines from standard input and evaluates them, one after another. To try out run:
|
||||||
@@ -932,7 +932,7 @@ To compile it one can use the following command:
|
|||||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
$ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
Execute the example with:
|
Execute the example with:
|
||||||
@@ -1063,7 +1063,7 @@ To compile it one can use the following command:
|
|||||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
$ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||||
```
|
```
|
||||||
|
|
||||||
Execute the example with:
|
Execute the example with:
|
||||||
|
|||||||
+2
-1
@@ -290,7 +290,8 @@ The objects are represented as following structure:
|
|||||||
{: class="thumbnail center-block img-responsive" }
|
{: class="thumbnail center-block img-responsive" }
|
||||||
|
|
||||||
Objects have a linked list that contains their properties. This list actually contains property pairs, in order to save memory described in the followings:
|
Objects have a linked list that contains their properties. This list actually contains property pairs, in order to save memory described in the followings:
|
||||||
A property is 7 bit long and its type field is 2 bit long which consumes 9 bit which does not fit into 1 byte but consumes 2 bytes. Hence, placing together two properties (14 bit) with the 2 bit long type field fits into 2 bytes.
|
A property has a one byte long descriptor, a two byte long name and four byte long value. Hence 14 bytes consumed by a property pair. Another two bytes is
|
||||||
|
used to show the next property pair, so the total size (16 byte) is divisible by 8.
|
||||||
|
|
||||||
#### Property Hashmap
|
#### Property Hashmap
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,32 @@ jerry_port_get_native_module (jerry_value_t name) /**< module specifier */
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Promise
|
||||||
|
|
||||||
|
```c
|
||||||
|
/**
|
||||||
|
* HostPromiseRejectionTracker operations
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
JERRY_PROMISE_REJECTION_OPERATION_REJECT, /**< promise is rejected without any handlers */
|
||||||
|
JERRY_PROMISE_REJECTION_OPERATION_HANDLE, /**< handler is added to a rejected promise for the first time */
|
||||||
|
} jerry_promise_rejection_operation_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track unhandled promise rejections.
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* This port function is called by jerry-core when JERRY_BUILTIN_PROMISE
|
||||||
|
* is enabled.
|
||||||
|
*
|
||||||
|
* @param promise rejected promise
|
||||||
|
* @param operation HostPromiseRejectionTracker operation
|
||||||
|
*/
|
||||||
|
void jerry_port_track_promise_rejection (const jerry_value_t promise,
|
||||||
|
const jerry_promise_rejection_operation_t operation);
|
||||||
|
```
|
||||||
|
|
||||||
## Date
|
## Date
|
||||||
|
|
||||||
```c
|
```c
|
||||||
@@ -402,3 +428,32 @@ void jerry_port_sleep (uint32_t sleep_time)
|
|||||||
} /* jerry_port_sleep */
|
} /* jerry_port_sleep */
|
||||||
#endif /* defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1) */
|
#endif /* defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1) */
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Promise
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include "jerryscript-port.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default implementation of jerry_port_track_promise_rejection.
|
||||||
|
* Prints the reason of the unhandled rejections.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
jerry_port_track_promise_rejection (const jerry_value_t promise, /**< rejected promise */
|
||||||
|
const jerry_promise_rejection_operation_t operation) /**< operation */
|
||||||
|
{
|
||||||
|
(void) operation; /* unused */
|
||||||
|
|
||||||
|
jerry_value_t reason = jerry_get_promise_result (promise);
|
||||||
|
jerry_value_t reason_to_string = jerry_value_to_string (reason);
|
||||||
|
jerry_size_t req_sz = jerry_get_utf8_string_size (reason_to_string);
|
||||||
|
jerry_char_t str_buf_p[req_sz + 1];
|
||||||
|
jerry_string_to_utf8_char_buffer (reason_to_string, str_buf_p, req_sz);
|
||||||
|
str_buf_p[req_sz] = '\0';
|
||||||
|
|
||||||
|
jerry_release_value (reason_to_string);
|
||||||
|
jerry_release_value (reason);
|
||||||
|
|
||||||
|
printf ("Uncaught (in promise) %s\n", str_buf_p);
|
||||||
|
} /* jerry_port_track_promise_rejection */
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user