You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/04.INTERNALS.md
+18-17
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Expression parser is responsible for parsing JavaScript expressions. It is imple
23
23
24
24
JavaScript statements are parsed by this component. It uses the [Expression parser](#expression-parser) to parse the constituent expressions. The implementation of Statement parser is located in `./jerry-core/parser/js/js-parser-statm.c`.
25
25
26
-
Function `parser_parse_source` carries out the parsing and compiling of the input EcmaScript source code. When a function appears in the source `parser_parse_source` calls `parser_parse_function` which is responsible for processing the source code of functions recursively including argument parsing and context handling. After the parsing, function `parser_post_processing` dumps the created opcodes and returns an `ecma_compiled_code_t*` that points to the compiled bytecode sequence.
26
+
Function `parser_parse_source` carries out the parsing and compiling of the input ECMAScript source code. When a function appears in the source `parser_parse_source` calls `parser_parse_function` which is responsible for processing the source code of functions recursively including argument parsing and context handling. After the parsing, function `parser_post_processing` dumps the created opcodes and returns an `ecma_compiled_code_t*` that points to the compiled bytecode sequence.
27
27
28
28
The interactions between the major components shown on the following figure.
29
29
@@ -33,19 +33,19 @@ The interactions between the major components shown on the following figure.
33
33
34
34
This section describes the compact byte-code (CBC) representation. The key focus is reducing memory consumption of the byte-code representation without sacrificing considerable performance. Other byte-code representations often focus on performance only so inventing this representation is an original research.
35
35
36
-
CBC is a CISC like instruction set which assigns shorter instructions for frequent operations. Many instructions represent multiple atomic tasks which reduces the byte code size. This technique is basically a data compression method.
36
+
CBC is a CISC like instruction set which assigns shorter instructions for frequent operations. Many instructions represent multiple atomic tasks which reduces the bytecode size. This technique is basically a data compression method.
37
37
38
38
## Compiled Code Format
39
39
40
-
The memory layout of the compiled byte code is the following.
40
+
The memory layout of the compiled bytecode is the following.
41
41
42
42

43
43
44
44
The header is a `cbc_compiled_code` structure with several fields. These fields contain the key properties of the compiled code.
45
45
46
-
The literals part is an array of ecma values. These values can contain any EcmaScript value types, e.g. strings, numbers, function and regexp templates. The number of literals is stored in the `literal_end` field of the header.
46
+
The literals part is an array of ecma values. These values can contain any ECMAScript value types, e.g. strings, numbers, functions and regexp templates. The number of literals is stored in the `literal_end` field of the header.
47
47
48
-
CBC instruction list is a sequence of byte code instructions which represents the compiled code.
48
+
CBC instruction list is a sequence of bytecode instructions which represents the compiled code.
49
49
50
50
## Byte-code Format
51
51
@@ -55,15 +55,15 @@ The memory layout of a byte-code is the following:
55
55
56
56
Each byte-code starts with an opcode. The opcode is one byte long for frequent and two byte long for rare instructions. The first byte of the rare instructions is always zero (`CBC_EXT_OPCODE`), and the second byte represents the extended opcode. The name of common and rare instructions start with `CBC_` and `CBC_EXT_` prefix respectively.
57
57
58
-
The maximum number of opcodes is 511, since 255 common (zero value excluded) and 256 rare instructions can be defined. Currently around 230 frequent and 120 rare instructions are available.
58
+
The maximum number of opcodes is 511, since 255 common (zero value excluded) and 256 rare instructions can be defined. Currently around 215 frequent and 70 rare instructions are available.
59
59
60
60
There are three types of bytecode arguments in CBC:
61
61
62
62
*__byte argument__: A value between 0 and 255, which often represents the argument count of call like opcodes (function call, new, eval, etc.).
63
63
64
64
*__literal argument__: An integer index which is greater or equal than zero and less than the `literal_end` field of the header. For further information see next section Literals (next).
65
65
66
-
*__relative branch__: An 1-3 byte long offset. The branch argument might also represent the end of an instruction range. For example the branch argument of `CBC_EXT_WITH_CREATE_CONTEXT` shows the end of a `with` statement. More precisely the position after the last instruction.
66
+
*__relative branch__: An 1-3 byte long offset. The branch argument might also represent the end of an instruction range. For example the branch argument of `CBC_EXT_WITH_CREATE_CONTEXT` shows the end of a `with` statement. More precisely the position after the last instruction in the with clause.
67
67
68
68
Argument combinations are limited to the following seven forms:
69
69
@@ -137,12 +137,12 @@ Byte-codes of this category serve for placing objects onto the stack. As there a
| CBC_PUSH_LITERAL | Pushes the value of the given literal argument. |
143
+
| CBC_PUSH_TWO_LITERALS | Pushes the values of the given two literal arguments. |
144
+
| CBC_PUSH_UNDEFINED | Pushes an undefined value. |
145
+
| CBC_PUSH_TRUE | Pushes a logical true. |
146
146
| CBC_PUSH_PROP_LITERAL | Pushes a property whose base object is popped from the stack, and the property name is passed as a literal argument. |
147
147
148
148
</span>
@@ -196,7 +196,7 @@ Branch byte-codes are used to perform conditional and unconditional jumps in the
196
196
| CBC_JUMP_BACKWARD | Jumps backward by the 1 byte long relative offset argument. |
197
197
| CBC_JUMP_BACKWARD_2 | Jumps backward by the 2 byte long relative offset argument. |
198
198
| CBC_JUMP_BACKWARD_3 | Jumps backward by the 3 byte long relative offset argument. |
199
-
| CBC_BRANCH_IF_TRUE_FORWARD | Jumps if the value on the top of the stack is true by the 1 byte long relative offset argument. |
199
+
| CBC_BRANCH_IF_TRUE_FORWARD | Jumps forward if the value on the top of the stack is true by the 1 byte long relative offset argument. |
200
200
201
201
</span>
202
202
@@ -219,12 +219,14 @@ ECMA component of the engine is responsible for the following notions:
219
219
220
220
## Data Representation
221
221
222
-
The major structure for data representation is `ECMA_value`. The lower two bits of this structure encode value tag, which determines the type of the value:
222
+
The major structure for data representation is `ECMA_value`. The lower three bits of this structure encode value tag, which determines the type of the value:
223
223
224
224
* simple
225
225
* number
226
226
* string
227
227
* object
228
+
* symbol
229
+
* error
228
230
229
231

230
232
@@ -275,7 +277,6 @@ The objects are represented as following structure:
275
277
276
278
* Reference counter - number of hard (non-property) references
277
279
* Next object pointer for the garbage collector
278
-
* GC's visited flag
279
280
* type (function object, lexical environment, etc.)
280
281
281
282
### Properties of Objects
@@ -323,7 +324,7 @@ Collections are array-like data structures, which are optimized to save memory.
323
324
324
325
### Exception Handling
325
326
326
-
In order to implement a sense of exception handling, the return values of JerryScript functions are able to indicate their faulty or "exceptional" operation. The return values are actually ECMA values (see section [Data Representation](#data-representation)) in which the error bit is set if an erroneous operation is occurred.
327
+
In order to implement a sense of exception handling, the return values of JerryScript functions are able to indicate their faulty or "exceptional" operation. The return values are ECMA values (see section [Data Representation](#data-representation)) and if an erroneous operation occurred the ECMA_VALUE_ERROR simple value is returned.
0 commit comments