Replace vera++ with clang-format (#4518)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
Robert Fancsik
2021-11-05 14:15:47 +01:00
committed by GitHub
parent bc091e1742
commit badfdf4dba
564 changed files with 10195 additions and 15090 deletions
+87
View File
@@ -0,0 +1,87 @@
---
Language: Cpp
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: AllDefinitions
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '<windows.h>'
Priority: 0
- Regex: '<[-.a-z]*>'
Priority: 1
- Regex: '"jerryscript[-.a-z]*"'
Priority: 2
- Regex: '"ecma[-.a-z]*"'
Priority: 3
- Regex: '.*'
Priority: 4
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Always
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Auto
StatementMacros:
- JERRY_ASSERT
- JERRY_STATIC_ASSERT
- JERRY_UNREACHABLE
TabWidth: 0
UseCRLF: false
UseTab: Never
...
+5 -2
View File
@@ -12,13 +12,16 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- run: sudo apt update - run: sudo apt update
- run: sudo apt install doxygen vera++ cppcheck pylint python-serial - run: sudo apt install doxygen clang-format-10 cppcheck pylint python-serial
- run: $RUNNER --check-signed-off=gh-actions - run: $RUNNER --check-signed-off=gh-actions
if: ${{ always() }} if: ${{ always() }}
- run: $RUNNER --check-doxygen - run: $RUNNER --check-doxygen
if: ${{ always() }} if: ${{ always() }}
- run: $RUNNER --check-vera - run: $RUNNER --check-format
if: ${{ always() }} if: ${{ always() }}
- run: $RUNNER --check-license - run: $RUNNER --check-license
if: ${{ always() }} if: ${{ always() }}
+4 -4
View File
@@ -11,11 +11,11 @@ Several scripts and tools help the building and development process, thus it is
- `bash` >= `4.3.11` - `bash` >= `4.3.11`
- `cppcheck` >= `1.61` - `cppcheck` >= `1.61`
- `vera++` >= `1.2.1` - `clang-format-10` >= `10.0.0`
- `python` >= `2.7.6` - `python` >= `2.7.6`
```bash ```bash
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck vera++ python sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck clang-format-10 python
``` ```
To make our scripts run correctly, several shell utilities should be available on the system: To make our scripts run correctly, several shell utilities should be available on the system:
@@ -173,10 +173,10 @@ python tools/run-tests.py --check-signed-off
python tools/run-tests.py --check-cppcheck python tools/run-tests.py --check-cppcheck
``` ```
**To run vera check** **To run format check**
```bash ```bash
python tools/run-tests.py --check-vera python tools/run-tests.py --check-format
``` ```
**To get a list of all the available test options** **To get a list of all the available test options**
+1 -1
View File
@@ -12,7 +12,7 @@ review.
* Tab characters are not allowed. * Tab characters are not allowed.
* Maximum line length is 120 characters (excluding newline). * Maximum line length is 120 characters (excluding newline).
* No trailing white space is allowed. * No trailing white space is allowed.
* Run `tools/run-tests.py --check-vera` to check several * Run `tools/run-tests.py --check-format` to check several
of the coding conventions automatically. of the coding conventions automatically.
## Comments ## Comments
+1 -1
View File
@@ -132,7 +132,7 @@ set(SOURCE_CORE_FILES
api/jerry-debugger-transport.c api/jerry-debugger-transport.c
api/jerry-debugger.c api/jerry-debugger.c
api/jerry-snapshot.c api/jerry-snapshot.c
api/jerry.c api/jerryscript.c
debugger/debugger.c debugger/debugger.c
ecma/base/ecma-alloc.c ecma/base/ecma-alloc.c
ecma/base/ecma-gc.c ecma/base/ecma-gc.c
+5 -7
View File
@@ -13,9 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerryscript.h"
#include "debugger.h" #include "debugger.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript.h"
#if JERRY_DEBUGGER #if JERRY_DEBUGGER
@@ -137,8 +138,7 @@ jerry_debugger_transport_close (void)
current_p->close (current_p); current_p->close (current_p);
current_p = next_p; current_p = next_p;
} } while (current_p != NULL);
while (current_p != NULL);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n"); jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n");
@@ -164,8 +164,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
do do
{ {
size_t fragment_length = (message_length <= max_send_size ? message_length size_t fragment_length = (message_length <= max_send_size ? message_length : max_send_size);
: max_send_size);
memcpy (payload_p, message_p, fragment_length); memcpy (payload_p, message_p, fragment_length);
@@ -176,8 +175,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
message_p += fragment_length; message_p += fragment_length;
message_length -= fragment_length; message_length -= fragment_length;
} } while (message_length > 0);
while (message_length > 0);
return true; return true;
} /* jerry_debugger_transport_send */ } /* jerry_debugger_transport_send */
+2 -1
View File
@@ -13,9 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerryscript.h"
#include "debugger.h" #include "debugger.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript.h"
/** /**
* Checks whether the debugger is connected. * Checks whether the debugger is connected.
+68 -127
View File
@@ -13,6 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerry-snapshot.h"
#include "jerryscript.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-errors.h" #include "ecma-errors.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
@@ -20,12 +24,11 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lex-env.h" #include "ecma-lex-env.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript.h" #include "js-parser-internal.h"
#include "jerry-snapshot.h"
#include "js-parser.h" #include "js-parser.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#include "js-parser-internal.h"
#include "re-compiler.h" #include "re-compiler.h"
#if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC #if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC
@@ -150,8 +153,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
if (globals_p->snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET) if (globals_p->snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
{ {
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) ecma_error_maximum_snapshot_size); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_maximum_snapshot_size);
return 0; return 0;
} }
@@ -165,8 +168,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
#if JERRY_ESNEXT #if JERRY_ESNEXT
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS) if (compiled_code_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
{ {
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) ecma_error_tagged_template_literals); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_tagged_template_literals);
return 0; return 0;
} }
@@ -182,8 +185,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
/* Regular expression. */ /* Regular expression. */
if (globals_p->snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t) > snapshot_buffer_size) if (globals_p->snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t) > snapshot_buffer_size)
{ {
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) error_buffer_too_small_p); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_buffer_too_small_p);
return 0; return 0;
} }
@@ -204,8 +207,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
buffer_p, buffer_p,
buffer_size)) buffer_size))
{ {
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) error_buffer_too_small_p); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_buffer_too_small_p);
/* cannot return inside ECMA_FINALIZE_UTF8_STRING */ /* cannot return inside ECMA_FINALIZE_UTF8_STRING */
} }
@@ -217,8 +220,7 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
} }
globals_p->regex_found = true; globals_p->regex_found = true;
globals_p->snapshot_buffer_write_offset = JERRY_ALIGNUP (globals_p->snapshot_buffer_write_offset, globals_p->snapshot_buffer_write_offset = JERRY_ALIGNUP (globals_p->snapshot_buffer_write_offset, JMEM_ALIGNMENT);
JMEM_ALIGNMENT);
/* Regexp character size is stored in refs. */ /* Regexp character size is stored in refs. */
copied_code_p->refs = (uint16_t) pattern_size; copied_code_p->refs = (uint16_t) pattern_size;
@@ -274,8 +276,7 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
for (uint32_t i = const_literal_end; i < literal_end; i++) for (uint32_t i = const_literal_end; i < literal_end; i++)
{ {
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
literal_start_p[i]);
if (bytecode_p == compiled_code_p) if (bytecode_p == compiled_code_p)
{ {
@@ -283,10 +284,7 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
} }
else else
{ {
uint32_t offset = snapshot_add_compiled_code (bytecode_p, uint32_t offset = snapshot_add_compiled_code (bytecode_p, snapshot_buffer_p, snapshot_buffer_size, globals_p);
snapshot_buffer_p,
snapshot_buffer_size,
globals_p);
JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset); JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset);
@@ -316,8 +314,7 @@ static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< s
ecma_deref_ecma_string (literal_string_p); ecma_deref_ecma_string (literal_string_p);
ecma_object_t *error_object_p = ecma_new_standard_error (JERRY_ERROR_RANGE, ecma_object_t *error_object_p = ecma_new_standard_error (JERRY_ERROR_RANGE, ecma_stringbuilder_finalize (&builder));
ecma_stringbuilder_finalize (&builder));
globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p); globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p);
} /* static_snapshot_error_unsupported_literal */ } /* static_snapshot_error_unsupported_literal */
@@ -342,8 +339,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
if (globals_p->snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET) if (globals_p->snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
{ {
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) ecma_error_maximum_snapshot_size); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_maximum_snapshot_size);
return 0; return 0;
} }
@@ -357,8 +354,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
if (!CBC_IS_FUNCTION (compiled_code_p->status_flags)) if (!CBC_IS_FUNCTION (compiled_code_p->status_flags))
{ {
/* Regular expression literals are not supported. */ /* Regular expression literals are not supported. */
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) ecma_error_regular_expression_not_supported); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_regular_expression_not_supported);
return 0; return 0;
} }
@@ -368,8 +365,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
compiled_code_p, compiled_code_p,
((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG)) ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG))
{ {
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, globals_p->snapshot_error =
(const jerry_char_t *) ecma_error_snapshot_buffer_small); jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_snapshot_buffer_small);
return 0; return 0;
} }
@@ -404,8 +401,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
for (uint32_t i = 0; i < const_literal_end; i++) for (uint32_t i = 0; i < const_literal_end; i++)
{ {
if (!ecma_is_value_direct (literal_start_p[i]) if (!ecma_is_value_direct (literal_start_p[i]) && !ecma_is_value_direct_string (literal_start_p[i]))
&& !ecma_is_value_direct_string (literal_start_p[i]))
{ {
static_snapshot_error_unsupported_literal (globals_p, literal_start_p[i]); static_snapshot_error_unsupported_literal (globals_p, literal_start_p[i]);
return 0; return 0;
@@ -414,8 +410,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
for (uint32_t i = const_literal_end; i < literal_end; i++) for (uint32_t i = const_literal_end; i < literal_end; i++)
{ {
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
literal_start_p[i]);
if (bytecode_p == compiled_code_p) if (bytecode_p == compiled_code_p)
{ {
@@ -423,10 +418,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
} }
else else
{ {
uint32_t offset = static_snapshot_add_compiled_code (bytecode_p, uint32_t offset =
snapshot_buffer_p, static_snapshot_add_compiled_code (bytecode_p, snapshot_buffer_p, snapshot_buffer_size, globals_p);
snapshot_buffer_size,
globals_p);
JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset); JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset);
@@ -439,8 +432,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
while (literal_start_p < (ecma_value_t *) buffer_p) while (literal_start_p < (ecma_value_t *) buffer_p)
{ {
if (!ecma_is_value_direct_string (*literal_start_p) if (!ecma_is_value_direct_string (*literal_start_p) && !ecma_is_value_empty (*literal_start_p))
&& !ecma_is_value_empty (*literal_start_p))
{ {
static_snapshot_error_unsupported_literal (globals_p, *literal_start_p); static_snapshot_error_unsupported_literal (globals_p, *literal_start_p);
return 0; return 0;
@@ -535,8 +527,7 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
JERRY_ASSERT ((code_size % sizeof (uint32_t)) == 0); JERRY_ASSERT ((code_size % sizeof (uint32_t)) == 0);
buffer_p += code_size / sizeof (uint32_t); buffer_p += code_size / sizeof (uint32_t);
size -= code_size; size -= code_size;
} } while (size > 0);
while (size > 0);
} /* jerry_snapshot_set_offsets */ } /* jerry_snapshot_set_offsets */
#endif /* JERRY_SNAPSHOT_SAVE */ #endif /* JERRY_SNAPSHOT_SAVE */
@@ -571,11 +562,9 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
const uint8_t *regex_start_p = ((const uint8_t *) bytecode_p) + sizeof (ecma_compiled_code_t); const uint8_t *regex_start_p = ((const uint8_t *) bytecode_p) + sizeof (ecma_compiled_code_t);
/* Real size is stored in refs. */ /* Real size is stored in refs. */
ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p, ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p, bytecode_p->refs);
bytecode_p->refs);
const re_compiled_code_t *re_bytecode_p = re_compile_bytecode (pattern_str_p, const re_compiled_code_t *re_bytecode_p = re_compile_bytecode (pattern_str_p, bytecode_p->status_flags);
bytecode_p->status_flags);
ecma_deref_ecma_string (pattern_str_p); ecma_deref_ecma_string (pattern_str_p);
return (ecma_compiled_code_t *) re_bytecode_p; return (ecma_compiled_code_t *) re_bytecode_p;
@@ -622,8 +611,7 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
ECMA_SET_INTERNAL_VALUE_POINTER (args_p->script_value, script_p); ECMA_SET_INTERNAL_VALUE_POINTER (args_p->script_value, script_p);
} }
if (copy_bytecode if (copy_bytecode || (header_size + (literal_end * sizeof (uint16_t)) + BYTECODE_NO_COPY_THRESHOLD > code_size))
|| (header_size + (literal_end * sizeof (uint16_t)) + BYTECODE_NO_COPY_THRESHOLD > code_size))
{ {
bytecode_p = (ecma_compiled_code_t *) jmem_heap_alloc_block (code_size); bytecode_p = (ecma_compiled_code_t *) jmem_heap_alloc_block (code_size);
@@ -716,19 +704,15 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
if (literal_offset == 0) if (literal_offset == 0)
{ {
/* Self reference */ /* Self reference */
ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i], ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i], bytecode_p);
bytecode_p);
} }
else else
{ {
ecma_compiled_code_t *literal_bytecode_p; ecma_compiled_code_t *literal_bytecode_p;
literal_bytecode_p = snapshot_load_compiled_code (base_addr_p + literal_offset, literal_bytecode_p =
literal_base_p, snapshot_load_compiled_code (base_addr_p + literal_offset, literal_base_p, script_p, copy_bytecode);
script_p,
copy_bytecode);
ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i], ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i], literal_bytecode_p);
literal_bytecode_p);
} }
} }
@@ -805,8 +789,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func
} }
snapshot_globals_t globals; snapshot_globals_t globals;
const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t), const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t), JMEM_ALIGNMENT);
JMEM_ALIGNMENT);
globals.snapshot_buffer_write_offset = aligned_header_size; globals.snapshot_buffer_write_offset = aligned_header_size;
globals.snapshot_error = ECMA_VALUE_EMPTY; globals.snapshot_error = ECMA_VALUE_EMPTY;
@@ -862,11 +845,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func
size_t header_offset = 0; size_t header_offset = 0;
snapshot_write_to_buffer_by_offset ((uint8_t *) buffer_p, snapshot_write_to_buffer_by_offset ((uint8_t *) buffer_p, buffer_size, &header_offset, &header, sizeof (header));
buffer_size,
&header_offset,
&header,
sizeof (header));
if (lit_map_p != NULL) if (lit_map_p != NULL)
{ {
@@ -904,11 +883,9 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
#if JERRY_SNAPSHOT_EXEC #if JERRY_SNAPSHOT_EXEC
JERRY_ASSERT (snapshot_p != NULL); JERRY_ASSERT (snapshot_p != NULL);
uint32_t allowed_opts = (JERRY_SNAPSHOT_EXEC_COPY_DATA uint32_t allowed_opts =
| JERRY_SNAPSHOT_EXEC_ALLOW_STATIC (JERRY_SNAPSHOT_EXEC_COPY_DATA | JERRY_SNAPSHOT_EXEC_ALLOW_STATIC | JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION
| JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION | JERRY_SNAPSHOT_EXEC_HAS_RESOURCE | JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE);
| JERRY_SNAPSHOT_EXEC_HAS_RESOURCE
| JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE);
if ((exec_snapshot_opts & ~(allowed_opts)) != 0) if ((exec_snapshot_opts & ~(allowed_opts)) != 0)
{ {
@@ -916,8 +893,8 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
return ecma_create_error_reference_from_context (); return ecma_create_error_reference_from_context ();
} }
const char * const invalid_version_error_p = "Invalid snapshot version or unsupported features present"; const char *const invalid_version_error_p = "Invalid snapshot version or unsupported features present";
const char * const invalid_format_error_p = "Invalid snapshot format"; const char *const invalid_format_error_p = "Invalid snapshot format";
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p; const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
if (snapshot_size <= sizeof (jerry_snapshot_header_t)) if (snapshot_size <= sizeof (jerry_snapshot_header_t))
@@ -928,8 +905,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p; const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p;
if (header_p->magic != JERRY_SNAPSHOT_MAGIC if (header_p->magic != JERRY_SNAPSHOT_MAGIC || header_p->version != JERRY_SNAPSHOT_VERSION
|| header_p->version != JERRY_SNAPSHOT_VERSION
|| !snapshot_check_global_flags (header_p->global_flags)) || !snapshot_check_global_flags (header_p->global_flags))
{ {
ecma_raise_type_error (invalid_version_error_p); ecma_raise_type_error (invalid_version_error_p);
@@ -971,8 +947,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
{ {
ecma_value_t user_value = ECMA_VALUE_EMPTY; ecma_value_t user_value = ECMA_VALUE_EMPTY;
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE) if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE) && option_values_p != NULL)
&& option_values_p != NULL)
{ {
user_value = option_values_p->user_value; user_value = option_values_p->user_value;
} }
@@ -995,8 +970,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
#if JERRY_RESOURCE_NAME #if JERRY_RESOURCE_NAME
ecma_value_t resource_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); ecma_value_t resource_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_RESOURCE) if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_RESOURCE) && option_values_p != NULL
&& option_values_p != NULL
&& ecma_is_value_string (option_values_p->resource_name) > 0) && ecma_is_value_string (option_values_p->resource_name) > 0)
{ {
ecma_ref_ecma_string (ecma_get_string_from_value (option_values_p->resource_name)); ecma_ref_ecma_string (ecma_get_string_from_value (option_values_p->resource_name));
@@ -1113,8 +1087,7 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p; const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG; uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
if (CBC_IS_FUNCTION (bytecode_p->status_flags) if (CBC_IS_FUNCTION (bytecode_p->status_flags) && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{ {
const ecma_value_t *literal_start_p; const ecma_value_t *literal_start_p;
uint32_t const_literal_end; uint32_t const_literal_end;
@@ -1159,8 +1132,7 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
} }
buffer_p += code_size; buffer_p += code_size;
} } while (buffer_p < buffer_end_p);
while (buffer_p < buffer_end_p);
} /* scan_snapshot_functions */ } /* scan_snapshot_functions */
/** /**
@@ -1179,8 +1151,7 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p; const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG; uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
if (CBC_IS_FUNCTION (bytecode_p->status_flags) if (CBC_IS_FUNCTION (bytecode_p->status_flags) && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{ {
ecma_value_t *literal_start_p; ecma_value_t *literal_start_p;
uint32_t const_literal_end; uint32_t const_literal_end;
@@ -1239,8 +1210,7 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
} }
buffer_p += code_size; buffer_p += code_size;
} } while (buffer_p < buffer_end_p);
while (buffer_p < buffer_end_p);
} /* update_literal_offsets */ } /* update_literal_offsets */
#endif /* JERRY_SNAPSHOT_SAVE */ #endif /* JERRY_SNAPSHOT_SAVE */
@@ -1283,8 +1253,7 @@ jerry_merge_snapshots (const uint32_t **inp_buffers_p, /**< array of (pointers t
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) inp_buffers_p[i]; const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) inp_buffers_p[i];
if (header_p->magic != JERRY_SNAPSHOT_MAGIC if (header_p->magic != JERRY_SNAPSHOT_MAGIC || header_p->version != JERRY_SNAPSHOT_VERSION
|| header_p->version != JERRY_SNAPSHOT_VERSION
|| !snapshot_check_global_flags (header_p->global_flags)) || !snapshot_check_global_flags (header_p->global_flags))
{ {
*error_p = "invalid snapshot version or unsupported features present"; *error_p = "invalid snapshot version or unsupported features present";
@@ -1303,10 +1272,7 @@ jerry_merge_snapshots (const uint32_t **inp_buffers_p, /**< array of (pointers t
number_of_funcs += header_p->number_of_funcs; number_of_funcs += header_p->number_of_funcs;
functions_size += header_p->lit_table_offset - start_offset; functions_size += header_p->lit_table_offset - start_offset;
scan_snapshot_functions (data_p + start_offset, scan_snapshot_functions (data_p + start_offset, literal_base_p, lit_pool_p, literal_base_p);
literal_base_p,
lit_pool_p,
literal_base_p);
} }
JERRY_ASSERT (number_of_funcs > 0); JERRY_ASSERT (number_of_funcs > 0);
@@ -1436,14 +1402,12 @@ jerry_save_literals_heap_max (ecma_string_t *literals[], /**< array of literals
{ {
lit_utf8_size_t max_idx = node_idx; lit_utf8_size_t max_idx = node_idx;
if (child_idx1 < num_of_nodes if (child_idx1 < num_of_nodes && jerry_save_literals_compare (literals[max_idx], literals[child_idx1]))
&& jerry_save_literals_compare (literals[max_idx], literals[child_idx1]))
{ {
max_idx = child_idx1; max_idx = child_idx1;
} }
if (child_idx2 < num_of_nodes if (child_idx2 < num_of_nodes && jerry_save_literals_compare (literals[max_idx], literals[child_idx2]))
&& jerry_save_literals_compare (literals[max_idx], literals[child_idx2]))
{ {
max_idx = child_idx2; max_idx = child_idx2;
} }
@@ -1461,11 +1425,8 @@ jerry_save_literals_down_heap (ecma_string_t *literals[], /**< array of literals
{ {
while (true) while (true)
{ {
lit_utf8_size_t max_idx = jerry_save_literals_heap_max (literals, lit_utf8_size_t max_idx =
num_of_nodes, jerry_save_literals_heap_max (literals, num_of_nodes, node_idx, 2 * node_idx + 1, 2 * node_idx + 2);
node_idx,
2 * node_idx + 1,
2 * node_idx + 2);
if (max_idx == node_idx) if (max_idx == node_idx)
{ {
break; break;
@@ -1555,10 +1516,8 @@ jerry_append_ecma_string_to_buffer (uint8_t *buffer_p, /**< buffer */
ECMA_STRING_TO_UTF8_STRING (string_p, str_buffer_p, str_buffer_size); ECMA_STRING_TO_UTF8_STRING (string_p, str_buffer_p, str_buffer_size);
/* Append the string to the buffer. */ /* Append the string to the buffer. */
uint8_t *new_buffer_p = jerry_append_chars_to_buffer (buffer_p, uint8_t *new_buffer_p =
buffer_end_p, jerry_append_chars_to_buffer (buffer_p, buffer_end_p, (const char *) str_buffer_p, str_buffer_size);
(const char *) str_buffer_p,
str_buffer_size);
ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size); ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size);
@@ -1576,16 +1535,12 @@ jerry_append_number_to_buffer (uint8_t *buffer_p, /**< buffer */
lit_utf8_size_t number) /**< number */ lit_utf8_size_t number) /**< number */
{ {
lit_utf8_byte_t uint32_to_str_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32]; lit_utf8_byte_t uint32_to_str_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
lit_utf8_size_t utf8_str_size = ecma_uint32_to_utf8_string (number, lit_utf8_size_t utf8_str_size =
uint32_to_str_buffer, ecma_uint32_to_utf8_string (number, uint32_to_str_buffer, ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
JERRY_ASSERT (utf8_str_size <= ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32); JERRY_ASSERT (utf8_str_size <= ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
return jerry_append_chars_to_buffer (buffer_p, return jerry_append_chars_to_buffer (buffer_p, buffer_end_p, (const char *) uint32_to_str_buffer, utf8_str_size);
buffer_end_p,
(const char *) uint32_to_str_buffer,
utf8_str_size);
} /* jerry_append_number_to_buffer */ } /* jerry_append_number_to_buffer */
#endif /* JERRY_SNAPSHOT_SAVE */ #endif /* JERRY_SNAPSHOT_SAVE */
@@ -1612,10 +1567,8 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p; const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p; const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p;
if (snapshot_size <= sizeof (jerry_snapshot_header_t) if (snapshot_size <= sizeof (jerry_snapshot_header_t) || header_p->magic != JERRY_SNAPSHOT_MAGIC
|| header_p->magic != JERRY_SNAPSHOT_MAGIC || header_p->version != JERRY_SNAPSHOT_VERSION || !snapshot_check_global_flags (header_p->global_flags))
|| header_p->version != JERRY_SNAPSHOT_VERSION
|| !snapshot_check_global_flags (header_p->global_flags))
{ {
/* Invalid snapshot format */ /* Invalid snapshot format */
return 0; return 0;
@@ -1625,10 +1578,7 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
const uint8_t *literal_base_p = snapshot_data_p + header_p->lit_table_offset; const uint8_t *literal_base_p = snapshot_data_p + header_p->lit_table_offset;
ecma_collection_t *lit_pool_p = ecma_new_collection (); ecma_collection_t *lit_pool_p = ecma_new_collection ();
scan_snapshot_functions (snapshot_data_p + header_p->func_offsets[0], scan_snapshot_functions (snapshot_data_p + header_p->func_offsets[0], literal_base_p, lit_pool_p, literal_base_p);
literal_base_p,
lit_pool_p,
literal_base_p);
lit_utf8_size_t literal_count = 0; lit_utf8_size_t literal_count = 0;
ecma_value_t *buffer_p = lit_pool_p->buffer_p; ecma_value_t *buffer_p = lit_pool_p->buffer_p;
@@ -1683,18 +1633,12 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
if (is_c_format) if (is_c_format)
{ {
/* Save literal count. */ /* Save literal count. */
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "jerry_length_t literal_count = ", 0);
buffer_end_p,
"jerry_length_t literal_count = ",
0);
lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count); lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count);
/* Save the array of literals. */ /* Save the array of literals. */
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, ";\n\njerry_char_t *literals[", 0);
buffer_end_p,
";\n\njerry_char_t *literals[",
0);
lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count); lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count);
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "] =\n{\n", 0); lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "] =\n{\n", 0);
@@ -1735,10 +1679,7 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "\n", 0); lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "\n", 0);
} }
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "};\n\njerry_length_t literal_sizes[", 0);
buffer_end_p,
"};\n\njerry_length_t literal_sizes[",
0);
lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count); lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count);
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "] =\n{\n", 0); lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "] =\n{\n", 0);
@@ -13,10 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include <stdio.h> #include "jerryscript.h"
#include <math.h>
#include <math.h>
#include <stdio.h>
#include "jerryscript-debugger-transport.h"
#include "debugger.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-arraybuffer-object.h" #include "ecma-arraybuffer-object.h"
@@ -37,17 +40,17 @@
#include "ecma-lex-env.h" #include "ecma-lex-env.h"
#include "ecma-line-info.h" #include "ecma-line-info.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h" #include "ecma-objects-general.h"
#include "ecma-regexp-object.h" #include "ecma-objects.h"
#include "ecma-promise-object.h" #include "ecma-promise-object.h"
#include "ecma-proxy-object.h" #include "ecma-proxy-object.h"
#include "ecma-regexp-object.h"
#include "ecma-shared-arraybuffer-object.h" #include "ecma-shared-arraybuffer-object.h"
#include "ecma-symbol-object.h" #include "ecma-symbol-object.h"
#include "ecma-typedarray-object.h" #include "ecma-typedarray-object.h"
#include "debugger.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript.h"
#include "jerryscript-debugger-transport.h"
#include "jmem.h" #include "jmem.h"
#include "js-parser.h" #include "js-parser.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
@@ -61,7 +64,7 @@ JERRY_STATIC_ASSERT (sizeof (jerry_value_t) == sizeof (ecma_value_t),
JERRY_STATIC_ASSERT ((int) RE_FLAG_GLOBAL == (int) JERRY_REGEXP_FLAG_GLOBAL JERRY_STATIC_ASSERT ((int) RE_FLAG_GLOBAL == (int) JERRY_REGEXP_FLAG_GLOBAL
&& (int) RE_FLAG_MULTILINE == (int) JERRY_REGEXP_FLAG_MULTILINE && (int) RE_FLAG_MULTILINE == (int) JERRY_REGEXP_FLAG_MULTILINE
&& (int) RE_FLAG_IGNORE_CASE == (int) JERRY_REGEXP_FLAG_IGNORE_CASE && (int) RE_FLAG_IGNORE_CASE == (int) JERRY_REGEXP_FLAG_IGNORE_CASE
&& (int) RE_FLAG_STICKY== (int) JERRY_REGEXP_FLAG_STICKY && (int) RE_FLAG_STICKY == (int) JERRY_REGEXP_FLAG_STICKY
&& (int) RE_FLAG_UNICODE == (int) JERRY_REGEXP_FLAG_UNICODE && (int) RE_FLAG_UNICODE == (int) JERRY_REGEXP_FLAG_UNICODE
&& (int) RE_FLAG_DOTALL == (int) JERRY_REGEXP_FLAG_DOTALL, && (int) RE_FLAG_DOTALL == (int) JERRY_REGEXP_FLAG_DOTALL,
re_flags_t_must_be_equal_to_jerry_regexp_flags_t); re_flags_t_must_be_equal_to_jerry_regexp_flags_t);
@@ -80,7 +83,8 @@ JERRY_STATIC_ASSERT ((int) ECMA_PROMISE_IS_PENDING == (int) JERRY_PROMISE_STATE_
#define ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET (JERRY_BIN_OP_SUB - NUMBER_ARITHMETIC_SUBTRACTION) #define ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET (JERRY_BIN_OP_SUB - NUMBER_ARITHMETIC_SUBTRACTION)
JERRY_STATIC_ASSERT (((NUMBER_ARITHMETIC_SUBTRACTION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_SUB) JERRY_STATIC_ASSERT (((NUMBER_ARITHMETIC_SUBTRACTION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_SUB)
&& ((NUMBER_ARITHMETIC_MULTIPLICATION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_MUL) && ((NUMBER_ARITHMETIC_MULTIPLICATION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET)
== JERRY_BIN_OP_MUL)
&& ((NUMBER_ARITHMETIC_DIVISION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_DIV) && ((NUMBER_ARITHMETIC_DIVISION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_DIV)
&& ((NUMBER_ARITHMETIC_REMAINDER + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_REM), && ((NUMBER_ARITHMETIC_REMAINDER + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_REM),
number_arithmetics_operation_type_matches_external); number_arithmetics_operation_type_matches_external);
@@ -172,7 +176,8 @@ jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
JERRY_ASSERT (!(JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE)); JERRY_ASSERT (!(JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE));
/* Zero out all non-external members. */ /* Zero out all non-external members. */
memset ((char *) &JERRY_CONTEXT_STRUCT + offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER), 0, memset ((char *) &JERRY_CONTEXT_STRUCT + offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER),
0,
sizeof (jerry_context_t) - offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER)); sizeof (jerry_context_t) - offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER));
JERRY_CONTEXT (jerry_init_flags) = flags; JERRY_CONTEXT (jerry_init_flags) = flags;
@@ -200,9 +205,7 @@ jerry_cleanup (void)
} }
#endif /* JERRY_DEBUGGER */ #endif /* JERRY_DEBUGGER */
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p); for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p); this_p != NULL; this_p = this_p->next_p)
this_p != NULL;
this_p = this_p->next_p)
{ {
if (this_p->manager_p->deinit_cb) if (this_p->manager_p->deinit_cb)
{ {
@@ -217,8 +220,7 @@ jerry_cleanup (void)
ecma_finalize (); ecma_finalize ();
jerry_make_api_unavailable (); jerry_make_api_unavailable ();
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p), *next_p = NULL; for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p), *next_p = NULL; this_p != NULL;
this_p != NULL;
this_p = next_p) this_p = next_p)
{ {
next_p = this_p->next_p; next_p = this_p->next_p;
@@ -278,14 +280,14 @@ jerry_get_context_data (const jerry_context_data_manager_t *manager_p)
* Register external magic string array * Register external magic string array
*/ */
void void
jerry_register_magic_strings (const jerry_char_t * const *ex_str_items_p, /**< character arrays, representing jerry_register_magic_strings (const jerry_char_t *const *ex_str_items_p, /**< character arrays, representing
* external magic strings' contents */ * external magic strings' contents */
uint32_t count, /**< number of the strings */ uint32_t count, /**< number of the strings */
const jerry_length_t *str_lengths_p) /**< lengths of all strings */ const jerry_length_t *str_lengths_p) /**< lengths of all strings */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
lit_magic_strings_ex_set ((const lit_utf8_byte_t * const *) ex_str_items_p, lit_magic_strings_ex_set ((const lit_utf8_byte_t *const *) ex_str_items_p,
count, count,
(const lit_utf8_size_t *) str_lengths_p); (const lit_utf8_size_t *) str_lengths_p);
} /* jerry_register_magic_strings */ } /* jerry_register_magic_strings */
@@ -327,13 +329,10 @@ jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p) /**< [out] heap memory
memset (&jmem_heap_stats, 0, sizeof (jmem_heap_stats)); memset (&jmem_heap_stats, 0, sizeof (jmem_heap_stats));
jmem_heap_get_stats (&jmem_heap_stats); jmem_heap_get_stats (&jmem_heap_stats);
*out_stats_p = (jerry_heap_stats_t) *out_stats_p = (jerry_heap_stats_t){ .version = 1,
{
.version = 1,
.size = jmem_heap_stats.size, .size = jmem_heap_stats.size,
.allocated_bytes = jmem_heap_stats.allocated_bytes, .allocated_bytes = jmem_heap_stats.allocated_bytes,
.peak_allocated_bytes = jmem_heap_stats.peak_allocated_bytes .peak_allocated_bytes = jmem_heap_stats.peak_allocated_bytes };
};
return true; return true;
#else /* !JERRY_MEM_STATS */ #else /* !JERRY_MEM_STATS */
@@ -394,30 +393,22 @@ jerry_parse_common (void *source_p, /**< script source */
if (options_p != NULL) if (options_p != NULL)
{ {
const uint32_t allowed_options = (JERRY_PARSE_STRICT_MODE const uint32_t allowed_options = (JERRY_PARSE_STRICT_MODE | JERRY_PARSE_MODULE | JERRY_PARSE_HAS_ARGUMENT_LIST
| JERRY_PARSE_MODULE | JERRY_PARSE_HAS_RESOURCE | JERRY_PARSE_HAS_START | JERRY_PARSE_HAS_USER_VALUE);
| JERRY_PARSE_HAS_ARGUMENT_LIST
| JERRY_PARSE_HAS_RESOURCE
| JERRY_PARSE_HAS_START
| JERRY_PARSE_HAS_USER_VALUE);
uint32_t options = options_p->options; uint32_t options = options_p->options;
if ((options & ~allowed_options) != 0 if ((options & ~allowed_options) != 0
|| ((options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST) || ((options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)
&& ((options_p->options & JERRY_PARSE_MODULE) && ((options_p->options & JERRY_PARSE_MODULE) || !ecma_is_value_string (options_p->argument_list)))
|| !ecma_is_value_string (options_p->argument_list))) || ((options_p->options & JERRY_PARSE_HAS_RESOURCE) && !ecma_is_value_string (options_p->resource_name)))
|| ((options_p->options & JERRY_PARSE_HAS_RESOURCE)
&& !ecma_is_value_string (options_p->resource_name)))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
} }
#if JERRY_DEBUGGER #if JERRY_DEBUGGER
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) && options_p != NULL
&& options_p != NULL && (options_p->options & JERRY_PARSE_HAS_RESOURCE) && ecma_is_value_string (options_p->resource_name))
&& (options_p->options & JERRY_PARSE_HAS_RESOURCE)
&& ecma_is_value_string (options_p->resource_name))
{ {
ECMA_STRING_TO_UTF8_STRING (ecma_get_string_from_value (options_p->resource_name), ECMA_STRING_TO_UTF8_STRING (ecma_get_string_from_value (options_p->resource_name),
resource_name_start_p, resource_name_start_p,
@@ -471,8 +462,7 @@ jerry_parse_common (void *source_p, /**< script source */
} }
#endif /* JERRY_MODULE_SYSTEM */ #endif /* JERRY_MODULE_SYSTEM */
if (JERRY_UNLIKELY (options_p != NULL if (JERRY_UNLIKELY (options_p != NULL && (options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)))
&& (options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)))
{ {
ecma_object_t *global_object_p = ecma_builtin_get_global (); ecma_object_t *global_object_p = ecma_builtin_get_global ();
@@ -906,7 +896,7 @@ jerry_module_set_import_callback (jerry_module_import_callback_t callback_p, /**
jerry_value_t jerry_value_t
jerry_native_module_create (jerry_native_module_evaluate_callback_t callback, /**< evaluation callback for jerry_native_module_create (jerry_native_module_evaluate_callback_t callback, /**< evaluation callback for
* native modules */ * native modules */
const jerry_value_t * const exports_p, /**< list of the exported bindings of the module, const jerry_value_t *const exports_p, /**< list of the exported bindings of the module,
* must be valid string identifiers */ * must be valid string identifiers */
size_t number_of_exports) /**< number of exports in the exports_p list */ size_t number_of_exports) /**< number of exports in the exports_p list */
{ {
@@ -1033,14 +1023,13 @@ jerry_native_module_get_export (const jerry_value_t native_module_val, /**< a na
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p)));
} }
if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name_val))
|| !ecma_is_value_string (export_name_val))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
ecma_property_t *property_p = ecma_find_named_property (module_p->scope_p, ecma_property_t *property_p =
ecma_get_string_from_value (export_name_val)); ecma_find_named_property (module_p->scope_p, ecma_get_string_from_value (export_name_val));
if (property_p == NULL) if (property_p == NULL)
{ {
@@ -1080,24 +1069,21 @@ jerry_native_module_set_export (const jerry_value_t native_module_val, /**< a na
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p)));
} }
if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name_val)
|| !ecma_is_value_string (export_name_val)
|| ecma_is_value_error_reference (value_to_set)) || ecma_is_value_error_reference (value_to_set))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
ecma_property_t *property_p = ecma_find_named_property (module_p->scope_p, ecma_property_t *property_p =
ecma_get_string_from_value (export_name_val)); ecma_find_named_property (module_p->scope_p, ecma_get_string_from_value (export_name_val));
if (property_p == NULL) if (property_p == NULL)
{ {
return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_unknown_export_p))); return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_unknown_export_p)));
} }
ecma_named_data_property_assign_value (module_p->scope_p, ecma_named_data_property_assign_value (module_p->scope_p, ECMA_PROPERTY_VALUE_PTR (property_p), value_to_set);
ECMA_PROPERTY_VALUE_PTR (property_p),
value_to_set);
return ECMA_VALUE_TRUE; return ECMA_VALUE_TRUE;
#else /* !JERRY_MODULE_SYSTEM */ #else /* !JERRY_MODULE_SYSTEM */
JERRY_UNUSED (native_module_val); JERRY_UNUSED (native_module_val);
@@ -1287,9 +1273,7 @@ jerry_value_is_async_function (const jerry_value_t value) /**< api value */
bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) obj_p); bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) obj_p);
uint16_t type = CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags); uint16_t type = CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags);
return (type == CBC_FUNCTION_ASYNC return (type == CBC_FUNCTION_ASYNC || type == CBC_FUNCTION_ASYNC_ARROW || type == CBC_FUNCTION_ASYNC_GENERATOR);
|| type == CBC_FUNCTION_ASYNC_ARROW
|| type == CBC_FUNCTION_ASYNC_GENERATOR);
} }
} }
#else /* !JERRY_ESNEXT */ #else /* !JERRY_ESNEXT */
@@ -1352,8 +1336,7 @@ jerry_value_is_promise (const jerry_value_t value) /**< api value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
#if JERRY_ESNEXT #if JERRY_ESNEXT
return (ecma_is_value_object (value) return (ecma_is_value_object (value) && ecma_is_promise (ecma_get_object_from_value (value)));
&& ecma_is_promise (ecma_get_object_from_value (value)));
#else /* !JERRY_ESNEXT */ #else /* !JERRY_ESNEXT */
JERRY_UNUSED (value); JERRY_UNUSED (value);
return false; return false;
@@ -1371,8 +1354,7 @@ jerry_value_is_proxy (const jerry_value_t value) /**< api value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
#if JERRY_BUILTIN_PROXY #if JERRY_BUILTIN_PROXY
return (ecma_is_value_object (value) return (ecma_is_value_object (value) && ECMA_OBJECT_IS_PROXY (ecma_get_object_from_value (value)));
&& ECMA_OBJECT_IS_PROXY (ecma_get_object_from_value (value)));
#else /* !JERRY_BUILTIN_PROXY */ #else /* !JERRY_BUILTIN_PROXY */
JERRY_UNUSED (value); JERRY_UNUSED (value);
return false; return false;
@@ -1513,8 +1495,7 @@ jerry_value_get_type (const jerry_value_t value) /**< input value to check */
/** /**
* Used by jerry_object_get_type to get the type of class objects * Used by jerry_object_get_type to get the type of class objects
*/ */
static const uint8_t jerry_class_object_type[] = static const uint8_t jerry_class_object_type[] = {
{
/* These objects require custom property resolving. */ /* These objects require custom property resolving. */
JERRY_OBJECT_TYPE_STRING, /**< type of ECMA_OBJECT_CLASS_STRING */ JERRY_OBJECT_TYPE_STRING, /**< type of ECMA_OBJECT_CLASS_STRING */
JERRY_OBJECT_TYPE_ARGUMENTS, /**< type of ECMA_OBJECT_CLASS_ARGUMENTS */ JERRY_OBJECT_TYPE_ARGUMENTS, /**< type of ECMA_OBJECT_CLASS_ARGUMENTS */
@@ -1523,9 +1504,9 @@ static const uint8_t jerry_class_object_type[] =
#endif /* JERRY_BUILTIN_TYPEDARRAY */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
JERRY_OBJECT_TYPE_MODULE_NAMESPACE, /**< type of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */ JERRY_OBJECT_TYPE_MODULE_NAMESPACE, /**< type of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */
#endif #endif /* JERRY_MODULE_SYSTEM */
/* These objects are marked by Garbage Collector. */ /* These objects are marked by Garbage Collector. */
#if JERRY_ESNEXT #if JERRY_ESNEXT
JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_GENERATOR */ JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_GENERATOR */
JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_ASYNC_GENERATOR */ JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_ASYNC_GENERATOR */
@@ -1538,7 +1519,7 @@ static const uint8_t jerry_class_object_type[] =
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */ JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */
#endif #endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT #if JERRY_ESNEXT
JERRY_OBJECT_TYPE_PROMISE, /**< type of ECMA_OBJECT_CLASS_PROMISE */ JERRY_OBJECT_TYPE_PROMISE, /**< type of ECMA_OBJECT_CLASS_PROMISE */
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */ JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
@@ -1808,8 +1789,7 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|| feature == JERRY_FEATURE_JSON || feature == JERRY_FEATURE_JSON
#endif /* JERRY_BUILTIN_JSON */ #endif /* JERRY_BUILTIN_JSON */
#if JERRY_ESNEXT #if JERRY_ESNEXT
|| feature == JERRY_FEATURE_PROMISE || feature == JERRY_FEATURE_PROMISE || feature == JERRY_FEATURE_SYMBOL
|| feature == JERRY_FEATURE_SYMBOL
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#if JERRY_BUILTIN_TYPEDARRAY #if JERRY_BUILTIN_TYPEDARRAY
|| feature == JERRY_FEATURE_TYPEDARRAY || feature == JERRY_FEATURE_TYPEDARRAY
@@ -1836,9 +1816,7 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|| feature == JERRY_FEATURE_GLOBAL_THIS || feature == JERRY_FEATURE_GLOBAL_THIS
#endif /* JERRY_BUILTIN_GLOBAL_THIS */ #endif /* JERRY_BUILTIN_GLOBAL_THIS */
#if JERRY_BUILTIN_CONTAINER #if JERRY_BUILTIN_CONTAINER
|| feature == JERRY_FEATURE_MAP || feature == JERRY_FEATURE_MAP || feature == JERRY_FEATURE_SET || feature == JERRY_FEATURE_WEAKMAP
|| feature == JERRY_FEATURE_SET
|| feature == JERRY_FEATURE_WEAKMAP
|| feature == JERRY_FEATURE_WEAKSET || feature == JERRY_FEATURE_WEAKSET
#endif /* JERRY_BUILTIN_CONTAINER */ #endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_WEAKREF #if JERRY_BUILTIN_WEAKREF
@@ -1908,8 +1886,7 @@ jerry_binary_operation (jerry_binary_operation_t op, /**< operation */
} }
case JERRY_BIN_OP_INSTANCEOF: case JERRY_BIN_OP_INSTANCEOF:
{ {
if (!ecma_is_value_object (lhs) if (!ecma_is_value_object (lhs) || !ecma_op_is_callable (rhs))
|| !ecma_op_is_callable (rhs))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
@@ -2054,7 +2031,8 @@ jerry_set_error_object_created_callback (jerry_error_object_created_callback_t c
* When JERRY_VM_THROW is enabled, the callback passed to this * When JERRY_VM_THROW is enabled, the callback passed to this
* function is called when an error is thrown in ECMAScript code. * function is called when an error is thrown in ECMAScript code.
*/ */
void jerry_set_vm_throw_callback (jerry_vm_throw_callback_t throw_cb, /**< callback which is called on throws */ void
jerry_set_vm_throw_callback (jerry_vm_throw_callback_t throw_cb, /**< callback which is called on throws */
void *user_p) /**< pointer passed to the function */ void *user_p) /**< pointer passed to the function */
{ {
#if JERRY_VM_THROW #if JERRY_VM_THROW
@@ -2270,7 +2248,6 @@ jerry_value_to_primitive (const jerry_value_t value) /**< input value */
jerry_value_t jerry_value_t
jerry_value_to_string (const jerry_value_t value) /**< input value */ jerry_value_to_string (const jerry_value_t value) /**< input value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (ecma_is_value_error_reference (value)) if (ecma_is_value_error_reference (value))
@@ -2474,9 +2451,7 @@ jerry_create_error (jerry_error_t error_type, /**< type of error */
const jerry_char_t *message_p) /**< value of 'message' property const jerry_char_t *message_p) /**< value of 'message' property
* of constructed error object */ * of constructed error object */
{ {
return jerry_create_error_sz (error_type, return jerry_create_error_sz (error_type, (lit_utf8_byte_t *) message_p, lit_zt_utf8_string_size (message_p));
(lit_utf8_byte_t *) message_p,
lit_zt_utf8_string_size (message_p));
} /* jerry_create_error */ } /* jerry_create_error */
/** /**
@@ -2502,11 +2477,10 @@ jerry_create_error_sz (jerry_error_t error_type, /**< type of error */
} }
else else
{ {
ecma_string_t *message_string_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) message_p, ecma_string_t *message_string_p =
(lit_utf8_size_t) message_size); ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) message_p, (lit_utf8_size_t) message_size);
ecma_object_t *error_object_p = ecma_new_standard_error ((jerry_error_t) error_type, ecma_object_t *error_object_p = ecma_new_standard_error ((jerry_error_t) error_type, message_string_p);
message_string_p);
ecma_deref_ecma_string (message_string_p); ecma_deref_ecma_string (message_string_p);
@@ -2660,8 +2634,7 @@ jerry_create_proxy (const jerry_value_t target, /**< target argument */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (ecma_is_value_error_reference (target) if (ecma_is_value_error_reference (target) || ecma_is_value_error_reference (handler))
|| ecma_is_value_error_reference (handler))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
@@ -2696,8 +2669,7 @@ jerry_create_special_proxy (const jerry_value_t target, /**< target argument */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (ecma_is_value_error_reference (target) if (ecma_is_value_error_reference (target) || ecma_is_value_error_reference (handler))
|| ecma_is_value_error_reference (handler))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
@@ -2741,8 +2713,8 @@ jerry_create_string_sz_from_utf8 (const jerry_char_t *str_p, /**< pointer to str
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
ecma_string_t *ecma_str_p = ecma_new_ecma_string_from_utf8_converted_to_cesu8 ((lit_utf8_byte_t *) str_p, ecma_string_t *ecma_str_p =
(lit_utf8_size_t) str_size); ecma_new_ecma_string_from_utf8_converted_to_cesu8 ((lit_utf8_byte_t *) str_p, (lit_utf8_size_t) str_size);
return ecma_make_string_value (ecma_str_p); return ecma_make_string_value (ecma_str_p);
} /* jerry_create_string_sz_from_utf8 */ } /* jerry_create_string_sz_from_utf8 */
@@ -2775,8 +2747,7 @@ jerry_create_string_sz (const jerry_char_t *str_p, /**< pointer to string */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
ecma_string_t *ecma_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) str_p, ecma_string_t *ecma_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) str_p, (lit_utf8_size_t) str_size);
(lit_utf8_size_t) str_size);
return ecma_make_string_value (ecma_str_p); return ecma_make_string_value (ecma_str_p);
} /* jerry_create_string_sz */ } /* jerry_create_string_sz */
@@ -2810,9 +2781,8 @@ jerry_create_external_string_sz (const jerry_char_t *str_p, /**< pointer to stri
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
ecma_string_t *ecma_str_p = ecma_new_ecma_external_string_from_cesu8 ((lit_utf8_byte_t *) str_p, ecma_string_t *ecma_str_p =
(lit_utf8_size_t) str_size, ecma_new_ecma_external_string_from_cesu8 ((lit_utf8_byte_t *) str_p, (lit_utf8_size_t) str_size, user_p);
user_p);
return ecma_make_string_value (ecma_str_p); return ecma_make_string_value (ecma_str_p);
} /* jerry_create_external_string_sz */ } /* jerry_create_external_string_sz */
@@ -2905,9 +2875,7 @@ jerry_create_regexp_sz (const jerry_char_t *pattern_p, /**< zero-terminated UTF-
ecma_string_t *ecma_pattern = ecma_new_ecma_string_from_utf8 (pattern_p, pattern_size); ecma_string_t *ecma_pattern = ecma_new_ecma_string_from_utf8 (pattern_p, pattern_size);
jerry_value_t ret_val = ecma_op_create_regexp_with_flags (regexp_obj_p, jerry_value_t ret_val = ecma_op_create_regexp_with_flags (regexp_obj_p, ecma_make_string_value (ecma_pattern), flags);
ecma_make_string_value (ecma_pattern),
flags);
ecma_deref_ecma_string (ecma_pattern); ecma_deref_ecma_string (ecma_pattern);
return ret_val; return ret_val;
@@ -3085,9 +3053,7 @@ jerry_string_to_char_buffer (const jerry_value_t value, /**< input string value
return 0; return 0;
} }
return ecma_string_copy_to_cesu8_buffer (str_p, return ecma_string_copy_to_cesu8_buffer (str_p, (lit_utf8_byte_t *) buffer_p, buffer_size);
(lit_utf8_byte_t *) buffer_p,
buffer_size);
} /* jerry_string_to_char_buffer */ } /* jerry_string_to_char_buffer */
/** /**
@@ -3124,9 +3090,7 @@ jerry_string_to_utf8_char_buffer (const jerry_value_t value, /**< input string v
return 0; return 0;
} }
return ecma_string_copy_to_utf8_buffer (str_p, return ecma_string_copy_to_utf8_buffer (str_p, (lit_utf8_byte_t *) buffer_p, buffer_size);
(lit_utf8_byte_t *) buffer_p,
buffer_size);
} /* jerry_string_to_utf8_char_buffer */ } /* jerry_string_to_utf8_char_buffer */
/** /**
@@ -3156,11 +3120,7 @@ jerry_substring_to_char_buffer (const jerry_value_t value, /**< input string val
ecma_string_t *str_p = ecma_get_string_from_value (value); ecma_string_t *str_p = ecma_get_string_from_value (value);
return ecma_substring_copy_to_cesu8_buffer (str_p, return ecma_substring_copy_to_cesu8_buffer (str_p, start_pos, end_pos, (lit_utf8_byte_t *) buffer_p, buffer_size);
start_pos,
end_pos,
(lit_utf8_byte_t *) buffer_p,
buffer_size);
} /* jerry_substring_to_char_buffer */ } /* jerry_substring_to_char_buffer */
/** /**
@@ -3190,11 +3150,7 @@ jerry_substring_to_utf8_char_buffer (const jerry_value_t value, /**< input strin
ecma_string_t *str_p = ecma_get_string_from_value (value); ecma_string_t *str_p = ecma_get_string_from_value (value);
return ecma_substring_copy_to_utf8_buffer (str_p, return ecma_substring_copy_to_utf8_buffer (str_p, start_pos, end_pos, (lit_utf8_byte_t *) buffer_p, buffer_size);
start_pos,
end_pos,
(lit_utf8_byte_t *) buffer_p,
buffer_size);
} /* jerry_substring_to_utf8_char_buffer */ } /* jerry_substring_to_utf8_char_buffer */
/** /**
@@ -3262,14 +3218,15 @@ jerry_has_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return ECMA_VALUE_FALSE; return ECMA_VALUE_FALSE;
} }
return jerry_return (ecma_op_object_has_property (ecma_get_object_from_value (obj_val), ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
ecma_get_prop_name_from_value (prop_name_val))); ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (prop_name_val);
return jerry_return (ecma_op_object_has_property (obj_p, prop_name_p));
} /* jerry_has_property */ } /* jerry_has_property */
/** /**
@@ -3284,8 +3241,7 @@ jerry_has_own_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return ECMA_VALUE_FALSE; return ECMA_VALUE_FALSE;
} }
@@ -3328,8 +3284,7 @@ jerry_has_internal_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return false; return false;
} }
@@ -3368,15 +3323,13 @@ jerry_delete_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return false; return false;
} }
ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_val), ecma_value_t ret_value =
ecma_get_prop_name_from_value (prop_name_val), ecma_op_object_delete (ecma_get_object_from_value (obj_val), ecma_get_prop_name_from_value (prop_name_val), false);
false);
#if JERRY_BUILTIN_PROXY #if JERRY_BUILTIN_PROXY
if (ECMA_IS_VALUE_ERROR (ret_value)) if (ECMA_IS_VALUE_ERROR (ret_value))
@@ -3407,9 +3360,7 @@ jerry_delete_property_by_index (const jerry_value_t obj_val, /**< object value *
} }
ecma_string_t *str_idx_p = ecma_new_ecma_string_from_uint32 (index); ecma_string_t *str_idx_p = ecma_new_ecma_string_from_uint32 (index);
ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_val), ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_val), str_idx_p, false);
str_idx_p,
false);
ecma_deref_ecma_string (str_idx_p); ecma_deref_ecma_string (str_idx_p);
#if JERRY_BUILTIN_PROXY #if JERRY_BUILTIN_PROXY
@@ -3435,8 +3386,7 @@ jerry_delete_internal_property (const jerry_value_t obj_val, /**< object value *
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return false; return false;
} }
@@ -3485,14 +3435,13 @@ jerry_get_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
jerry_value_t ret_value = ecma_op_object_get (ecma_get_object_from_value (obj_val), jerry_value_t ret_value =
ecma_get_prop_name_from_value (prop_name_val)); ecma_op_object_get (ecma_get_object_from_value (obj_val), ecma_get_prop_name_from_value (prop_name_val));
return jerry_return (ret_value); return jerry_return (ret_value);
} /* jerry_get_property */ } /* jerry_get_property */
@@ -3544,8 +3493,7 @@ jerry_get_own_property (const jerry_value_t obj_val, /**< object value */
*found_p = false; *found_p = false;
} }
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val)
|| !ecma_is_value_prop_name (prop_name_val)
|| !ecma_is_value_object (receiver_val)) || !ecma_is_value_object (receiver_val))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
@@ -3597,8 +3545,7 @@ jerry_get_internal_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
@@ -3646,8 +3593,7 @@ jerry_set_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (ecma_is_value_error_reference (value_to_set) if (ecma_is_value_error_reference (value_to_set) || !ecma_is_value_object (obj_val)
|| !ecma_is_value_object (obj_val)
|| !ecma_is_value_prop_name (prop_name_val)) || !ecma_is_value_prop_name (prop_name_val))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
@@ -3675,16 +3621,13 @@ jerry_set_property_by_index (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (ecma_is_value_error_reference (value_to_set) if (ecma_is_value_error_reference (value_to_set) || !ecma_is_value_object (obj_val))
|| !ecma_is_value_object (obj_val))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
ecma_value_t ret_value = ecma_op_object_put_by_index (ecma_get_object_from_value (obj_val), ecma_value_t ret_value =
index, ecma_op_object_put_by_index (ecma_get_object_from_value (obj_val), index, value_to_set, true);
value_to_set,
true);
return jerry_return (ret_value); return jerry_return (ret_value);
} /* jerry_set_property_by_index */ } /* jerry_set_property_by_index */
@@ -3706,8 +3649,7 @@ jerry_set_internal_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (ecma_is_value_error_reference (value_to_set) if (ecma_is_value_error_reference (value_to_set) || !ecma_is_value_object (obj_val)
|| !ecma_is_value_object (obj_val)
|| !ecma_is_value_prop_name (prop_name_val)) || !ecma_is_value_prop_name (prop_name_val))
{ {
return false; return false;
@@ -3727,14 +3669,10 @@ jerry_set_internal_property (const jerry_value_t obj_val, /**< object value */
if (property_p == NULL) if (property_p == NULL)
{ {
ecma_property_value_t *value_p = ecma_create_named_data_property (obj_p, ecma_property_value_t *value_p =
internal_string_p, ecma_create_named_data_property (obj_p, internal_string_p, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, NULL);
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
NULL);
internal_object_p = ecma_create_object (NULL, internal_object_p = ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
sizeof (ecma_extended_object_t),
ECMA_OBJECT_TYPE_CLASS);
{ {
ecma_extended_object_t *container_p = (ecma_extended_object_t *) internal_object_p; ecma_extended_object_t *container_p = (ecma_extended_object_t *) internal_object_p;
container_p->u.cls.type = ECMA_OBJECT_CLASS_INTERNAL_OBJECT; container_p->u.cls.type = ECMA_OBJECT_CLASS_INTERNAL_OBJECT;
@@ -3954,8 +3892,7 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return jerry_type_error_or_false (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p), prop_desc_p->flags); return jerry_type_error_or_false (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p), prop_desc_p->flags);
} }
@@ -3991,8 +3928,7 @@ jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object val
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|| !ecma_is_value_prop_name (prop_name_val))
{ {
return ECMA_VALUE_FALSE; return ECMA_VALUE_FALSE;
} }
@@ -4016,10 +3952,9 @@ jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object val
} }
/* The flags are always filled in the returned descriptor. */ /* The flags are always filled in the returned descriptor. */
JERRY_ASSERT ((prop_desc.flags & JERRY_PROP_IS_CONFIGURABLE_DEFINED) JERRY_ASSERT (
&& (prop_desc.flags & JERRY_PROP_IS_ENUMERABLE_DEFINED) (prop_desc.flags & JERRY_PROP_IS_CONFIGURABLE_DEFINED) && (prop_desc.flags & JERRY_PROP_IS_ENUMERABLE_DEFINED)
&& ((prop_desc.flags & JERRY_PROP_IS_WRITABLE_DEFINED) && ((prop_desc.flags & JERRY_PROP_IS_WRITABLE_DEFINED) || !(prop_desc.flags & JERRY_PROP_IS_VALUE_DEFINED)));
|| !(prop_desc.flags & JERRY_PROP_IS_VALUE_DEFINED)));
prop_desc_p->flags = prop_desc.flags; prop_desc_p->flags = prop_desc.flags;
prop_desc_p->value = ECMA_VALUE_UNDEFINED; prop_desc_p->value = ECMA_VALUE_UNDEFINED;
@@ -4110,10 +4045,7 @@ jerry_call_function (const jerry_value_t func_obj_val, /**< function object to c
} }
} }
return jerry_return (ecma_op_function_validated_call (func_obj_val, return jerry_return (ecma_op_function_validated_call (func_obj_val, this_val, args_p, args_count));
this_val,
args_p,
args_count));
} /* jerry_call_function */ } /* jerry_call_function */
/** /**
@@ -4171,8 +4103,8 @@ jerry_get_object_keys (const jerry_value_t obj_val) /**< object value */
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
ecma_collection_t *prop_names = ecma_op_object_get_enumerable_property_names (ecma_get_object_from_value (obj_val), ecma_collection_t *prop_names =
ECMA_ENUMERABLE_PROPERTY_KEYS); ecma_op_object_get_enumerable_property_names (ecma_get_object_from_value (obj_val), ECMA_ENUMERABLE_PROPERTY_KEYS);
#if JERRY_BUILTIN_PROXY #if JERRY_BUILTIN_PROXY
if (JERRY_UNLIKELY (prop_names == NULL)) if (JERRY_UNLIKELY (prop_names == NULL))
@@ -4235,8 +4167,7 @@ jerry_set_prototype (const jerry_value_t obj_val, /**< object value */
{ {
jerry_assert_api_available (); jerry_assert_api_available ();
if (!ecma_is_value_object (obj_val) if (!ecma_is_value_object (obj_val) || ecma_is_value_error_reference (proto_obj_val)
|| ecma_is_value_error_reference (proto_obj_val)
|| (!ecma_is_value_object (proto_obj_val) && !ecma_is_value_null (proto_obj_val))) || (!ecma_is_value_object (proto_obj_val) && !ecma_is_value_null (proto_obj_val)))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
@@ -4262,8 +4193,8 @@ jerry_set_prototype (const jerry_value_t obj_val, /**< object value */
* @returns true - if the user can access the object in the callback. * @returns true - if the user can access the object in the callback.
* false - if the object is an internal object which should no be accessed by the user. * false - if the object is an internal object which should no be accessed by the user.
*/ */
static static bool
bool jerry_object_is_valid_foreach (ecma_object_t *object_p) /**< object to test */ jerry_object_is_valid_foreach (ecma_object_t *object_p) /**< object to test */
{ {
if (ecma_is_lexical_environment (object_p)) if (ecma_is_lexical_environment (object_p))
{ {
@@ -4308,8 +4239,7 @@ jerry_objects_foreach (jerry_objects_foreach_t foreach_p, /**< function pointer
{ {
ecma_object_t *iter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, iter_cp); ecma_object_t *iter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, iter_cp);
if (jerry_object_is_valid_foreach (iter_p) if (jerry_object_is_valid_foreach (iter_p) && !foreach_p (ecma_make_object_value (iter_p), user_data_p))
&& !foreach_p (ecma_make_object_value (iter_p), user_data_p))
{ {
return true; return true;
} }
@@ -4349,8 +4279,7 @@ jerry_objects_foreach_by_native_info (const jerry_object_native_info_t *native_i
if (jerry_object_is_valid_foreach (iter_p)) if (jerry_object_is_valid_foreach (iter_p))
{ {
native_pointer_p = ecma_get_native_pointer_value (iter_p, (void *) native_info_p); native_pointer_p = ecma_get_native_pointer_value (iter_p, (void *) native_info_p);
if (native_pointer_p if (native_pointer_p && !foreach_p (ecma_make_object_value (iter_p), native_pointer_p->native_p, user_data_p))
&& !foreach_p (ecma_make_object_value (iter_p), native_pointer_p->native_p, user_data_p))
{ {
return true; return true;
} }
@@ -4647,8 +4576,8 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
uint32_t index = ecma_string_get_array_index (key_p); uint32_t index = ecma_string_get_array_index (key_p);
/* Step 2. Filter by key type */ /* Step 2. Filter by key type */
if (filter & (JERRY_PROPERTY_FILTER_EXCLUDE_STRINGS if (filter
| JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS & (JERRY_PROPERTY_FILTER_EXCLUDE_STRINGS | JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS
| JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES)) | JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES))
{ {
if (ecma_is_value_symbol (key)) if (ecma_is_value_symbol (key))
@@ -4674,8 +4603,8 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
} }
/* Step 3. Filter property attributes */ /* Step 3. Filter property attributes */
if (filter & (JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE if (filter
| JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE & (JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE | JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE
| JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE)) | JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE))
{ {
ecma_property_descriptor_t prop_desc; ecma_property_descriptor_t prop_desc;
@@ -4695,19 +4624,15 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
uint16_t flags = prop_desc.flags; uint16_t flags = prop_desc.flags;
ecma_free_property_descriptor (&prop_desc); ecma_free_property_descriptor (&prop_desc);
if ((!(flags & JERRY_PROP_IS_CONFIGURABLE) if ((!(flags & JERRY_PROP_IS_CONFIGURABLE) && (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE))
&& (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE)) || (!(flags & JERRY_PROP_IS_ENUMERABLE) && (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE))
|| (!(flags & JERRY_PROP_IS_ENUMERABLE) || (!(flags & JERRY_PROP_IS_WRITABLE) && (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE)))
&& (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE))
|| (!(flags & JERRY_PROP_IS_WRITABLE)
&& (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE)))
{ {
continue; continue;
} }
} }
if (index != ECMA_STRING_NOT_ARRAY_INDEX if (index != ECMA_STRING_NOT_ARRAY_INDEX && (filter & JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER))
&& (filter & JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER))
{ {
ecma_deref_ecma_string (key_p); ecma_deref_ecma_string (key_p);
key = ecma_make_uint32_value (index); key = ecma_make_uint32_value (index);
@@ -4930,7 +4855,8 @@ jerry_get_promise_state (const jerry_value_t promise) /**< promise object to get
* Note: * Note:
* the previous callback is overwritten * the previous callback is overwritten
*/ */
void jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< combination of event filters */ void
jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< combination of event filters */
jerry_promise_callback_t callback, /**< notification callback */ jerry_promise_callback_t callback, /**< notification callback */
void *user_p) /**< user pointer passed to the callback */ void *user_p) /**< user pointer passed to the callback */
{ {
@@ -4981,7 +4907,7 @@ jerry_get_well_known_symbol (jerry_well_known_symbol_t symbol) /**< jerry_well_k
return ECMA_VALUE_UNDEFINED; return ECMA_VALUE_UNDEFINED;
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
} /** jerry_get_well_known_symbol */ } /* jerry_get_well_known_symbol */
/** /**
* Returns the description internal property of a symbol. * Returns the description internal property of a symbol.
@@ -5039,7 +4965,7 @@ jerry_get_symbol_descriptive_string (const jerry_value_t symbol) /**< symbol val
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_symbol_not_supported_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_symbol_not_supported_p)));
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
} /** jerry_get_symbol_descriptive_string */ } /* jerry_get_symbol_descriptive_string */
/** /**
* Get the number of uint64 digits of a BigInt value * Get the number of uint64 digits of a BigInt value
@@ -5173,9 +5099,7 @@ bool
jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, /**< UTF-8 string */ jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, /**< UTF-8 string */
jerry_size_t buf_size) /**< string size */ jerry_size_t buf_size) /**< string size */
{ {
return lit_is_valid_utf8_string ((lit_utf8_byte_t *) utf8_buf_p, return lit_is_valid_utf8_string ((lit_utf8_byte_t *) utf8_buf_p, (lit_utf8_size_t) buf_size, true);
(lit_utf8_size_t) buf_size,
true);
} /* jerry_is_valid_utf8_string */ } /* jerry_is_valid_utf8_string */
/** /**
@@ -5188,8 +5112,7 @@ bool
jerry_is_valid_cesu8_string (const jerry_char_t *cesu8_buf_p, /**< CESU-8 string */ jerry_is_valid_cesu8_string (const jerry_char_t *cesu8_buf_p, /**< CESU-8 string */
jerry_size_t buf_size) /**< string size */ jerry_size_t buf_size) /**< string size */
{ {
return lit_is_valid_cesu8_string ((lit_utf8_byte_t *) cesu8_buf_p, return lit_is_valid_cesu8_string ((lit_utf8_byte_t *) cesu8_buf_p, (lit_utf8_size_t) buf_size);
(lit_utf8_size_t) buf_size);
} /* jerry_is_valid_cesu8_string */ } /* jerry_is_valid_cesu8_string */
/** /**
@@ -5580,8 +5503,7 @@ jerry_get_source_info (const jerry_value_t value) /**< jerry api value */
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT) if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
{ {
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
ext_object_p->u.cls.u3.value);
} }
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
else if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE) else if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE)
@@ -5657,8 +5579,8 @@ jerry_get_source_info (const jerry_value_t value) /**< jerry api value */
{ {
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
object_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, object_p =
ext_object_p->u.bound_function.target_function); ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_object_p->u.bound_function.target_function);
continue; continue;
} }
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -6382,12 +6304,9 @@ jerry_create_dataview (const jerry_value_t array_buffer, /**< arraybuffer to cre
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
} }
ecma_value_t arguments_p[3] = ecma_value_t arguments_p[3] = { array_buffer,
{
array_buffer,
ecma_make_uint32_value (byte_offset), ecma_make_uint32_value (byte_offset),
ecma_make_uint32_value (byte_length) ecma_make_uint32_value (byte_length) };
};
ecma_object_t *old_new_target_p = JERRY_CONTEXT (current_new_target_p); ecma_object_t *old_new_target_p = JERRY_CONTEXT (current_new_target_p);
if (old_new_target_p == NULL) if (old_new_target_p == NULL)
{ {
@@ -6516,26 +6435,21 @@ typedef struct
/** /**
* List of TypedArray mappings * List of TypedArray mappings
*/ */
static jerry_typedarray_mapping_t jerry_typedarray_mappings[] = static jerry_typedarray_mapping_t jerry_typedarray_mappings[] = {
{
#define TYPEDARRAY_ENTRY(NAME, LIT_NAME, SIZE_SHIFT) \ #define TYPEDARRAY_ENTRY(NAME, LIT_NAME, SIZE_SHIFT) \
{ JERRY_TYPEDARRAY_ ## NAME, ECMA_BUILTIN_ID_ ## NAME ## ARRAY_PROTOTYPE, \ { \
ECMA_ ## LIT_NAME ## _ARRAY, SIZE_SHIFT } JERRY_TYPEDARRAY_##NAME, ECMA_BUILTIN_ID_##NAME##ARRAY_PROTOTYPE, ECMA_##LIT_NAME##_ARRAY, SIZE_SHIFT \
}
TYPEDARRAY_ENTRY (UINT8, UINT8, 0), TYPEDARRAY_ENTRY (UINT8, UINT8, 0), TYPEDARRAY_ENTRY (UINT8CLAMPED, UINT8_CLAMPED, 0),
TYPEDARRAY_ENTRY (UINT8CLAMPED, UINT8_CLAMPED, 0), TYPEDARRAY_ENTRY (INT8, INT8, 0), TYPEDARRAY_ENTRY (UINT16, UINT16, 1),
TYPEDARRAY_ENTRY (INT8, INT8, 0), TYPEDARRAY_ENTRY (INT16, INT16, 1), TYPEDARRAY_ENTRY (UINT32, UINT32, 2),
TYPEDARRAY_ENTRY (UINT16, UINT16, 1), TYPEDARRAY_ENTRY (INT32, INT32, 2), TYPEDARRAY_ENTRY (FLOAT32, FLOAT32, 2),
TYPEDARRAY_ENTRY (INT16, INT16, 1),
TYPEDARRAY_ENTRY (UINT32, UINT32, 2),
TYPEDARRAY_ENTRY (INT32, INT32, 2),
TYPEDARRAY_ENTRY (FLOAT32, FLOAT32, 2),
#if JERRY_NUMBER_TYPE_FLOAT64 #if JERRY_NUMBER_TYPE_FLOAT64
TYPEDARRAY_ENTRY (FLOAT64, FLOAT64, 3), TYPEDARRAY_ENTRY (FLOAT64, FLOAT64, 3),
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */ #endif /* JERRY_NUMBER_TYPE_FLOAT64 */
#if JERRY_BUILTIN_BIGINT #if JERRY_BUILTIN_BIGINT
TYPEDARRAY_ENTRY (BIGINT64, BIGINT64, 3), TYPEDARRAY_ENTRY (BIGINT64, BIGINT64, 3), TYPEDARRAY_ENTRY (BIGUINT64, BIGUINT64, 3),
TYPEDARRAY_ENTRY (BIGUINT64, BIGUINT64, 3),
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
#undef TYPEDARRAY_ENTRY #undef TYPEDARRAY_ENTRY
}; };
@@ -6601,11 +6515,8 @@ jerry_create_typedarray (jerry_typedarray_type_t type_name, /**< type of TypedAr
ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id); ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
ecma_value_t array_value = ecma_typedarray_create_object_with_length (length, ecma_value_t array_value =
NULL, ecma_typedarray_create_object_with_length (length, NULL, prototype_obj_p, element_size_shift, id);
prototype_obj_p,
element_size_shift,
id);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (array_value)); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (array_value));
@@ -6655,12 +6566,7 @@ jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, /
} }
ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id); ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
ecma_value_t arguments_p[3] = ecma_value_t arguments_p[3] = { arraybuffer, ecma_make_uint32_value (byte_offset), ecma_make_uint32_value (length) };
{
arraybuffer,
ecma_make_uint32_value (byte_offset),
ecma_make_uint32_value (length)
};
ecma_value_t array_value = ecma_op_create_typedarray (arguments_p, 3, prototype_obj_p, element_size_shift, id); ecma_value_t array_value = ecma_op_create_typedarray (arguments_p, 3, prototype_obj_p, element_size_shift, id);
ecma_free_value (arguments_p[1]); ecma_free_value (arguments_p[1]);
@@ -6946,17 +6852,14 @@ jerry_create_container (jerry_container_type_t container_type, /**< Type of the
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Invalid container type"))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Invalid container type")));
} }
} }
ecma_object_t * old_new_target_p = JERRY_CONTEXT (current_new_target_p); ecma_object_t *old_new_target_p = JERRY_CONTEXT (current_new_target_p);
if (old_new_target_p == NULL) if (old_new_target_p == NULL)
{ {
JERRY_CONTEXT (current_new_target_p) = ecma_builtin_get (ctor_id); JERRY_CONTEXT (current_new_target_p) = ecma_builtin_get (ctor_id);
} }
ecma_value_t container_value = ecma_op_container_create (arguments_list_p, ecma_value_t container_value = ecma_op_container_create (arguments_list_p, arguments_list_len, lit_id, proto_id);
arguments_list_len,
lit_id,
proto_id);
JERRY_CONTEXT (current_new_target_p) = old_new_target_p; JERRY_CONTEXT (current_new_target_p) = old_new_target_p;
return container_value; return container_value;
@@ -7123,11 +7026,11 @@ jerry_get_array_from_container (jerry_value_t value, /**< the container or itera
} }
} }
return ecma_op_new_array_object_from_collection (collection_buffer, false); return ecma_op_new_array_object_from_collection (collection_buffer, false);
#else /* JERRY_BUILTIN_CONTAINER */ #else /* !JERRY_BUILTIN_CONTAINER */
JERRY_UNUSED (value); JERRY_UNUSED (value);
JERRY_UNUSED (is_key_value_p); JERRY_UNUSED (is_key_value_p);
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_container_not_supported_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_container_not_supported_p)));
#endif #endif /* JERRY_BUILTIN_CONTAINER */
} /* jerry_get_array_from_container */ } /* jerry_get_array_from_container */
/** /**
@@ -7178,8 +7081,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container
} }
case JERRY_CONTAINER_OP_SET: case JERRY_CONTAINER_OP_SET:
{ {
if (arguments_number != 2 if (arguments_number != 2 || ecma_is_value_error_reference (arguments[0])
|| ecma_is_value_error_reference (arguments[0])
|| ecma_is_value_error_reference (arguments[1])) || ecma_is_value_error_reference (arguments[1]))
{ {
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
@@ -7269,7 +7171,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container
} }
} }
return jerry_return (result); return jerry_return (result);
#else /* JERRY_BUILTIN_CONTAINER */ #else /* !JERRY_BUILTIN_CONTAINER */
JERRY_UNUSED (operation); JERRY_UNUSED (operation);
JERRY_UNUSED (container); JERRY_UNUSED (container);
JERRY_UNUSED (arguments); JERRY_UNUSED (arguments);
+238 -276
View File
@@ -29,102 +29,102 @@
* By default all built-ins are enabled if they are not defined. * By default all built-ins are enabled if they are not defined.
*/ */
#ifndef JERRY_BUILTINS #ifndef JERRY_BUILTINS
# define JERRY_BUILTINS 1 #define JERRY_BUILTINS 1
#endif /* !defined (JERRY_BUILTINS) */ #endif /* !defined (JERRY_BUILTINS) */
#ifndef JERRY_BUILTIN_ANNEXB #ifndef JERRY_BUILTIN_ANNEXB
# define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS #define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ANNEXB) */ #endif /* !defined (JERRY_BUILTIN_ANNEXB) */
#ifndef JERRY_BUILTIN_ARRAY #ifndef JERRY_BUILTIN_ARRAY
# define JERRY_BUILTIN_ARRAY JERRY_BUILTINS #define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ARRAY) */ #endif /* !defined (JERRY_BUILTIN_ARRAY) */
#ifndef JERRY_BUILTIN_BOOLEAN #ifndef JERRY_BUILTIN_BOOLEAN
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS #define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */ #endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
#ifndef JERRY_BUILTIN_DATE #ifndef JERRY_BUILTIN_DATE
# define JERRY_BUILTIN_DATE JERRY_BUILTINS #define JERRY_BUILTIN_DATE JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_DATE) */ #endif /* !defined (JERRY_BUILTIN_DATE) */
#ifndef JERRY_BUILTIN_ERRORS #ifndef JERRY_BUILTIN_ERRORS
# define JERRY_BUILTIN_ERRORS JERRY_BUILTINS #define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_ERRORS) */ #endif /* !defined (JERRY_BUILTIN_ERRORS) */
#ifndef JERRY_BUILTIN_JSON #ifndef JERRY_BUILTIN_JSON
# define JERRY_BUILTIN_JSON JERRY_BUILTINS #define JERRY_BUILTIN_JSON JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_JSON) */ #endif /* !defined (JERRY_BUILTIN_JSON) */
#ifndef JERRY_BUILTIN_MATH #ifndef JERRY_BUILTIN_MATH
# define JERRY_BUILTIN_MATH JERRY_BUILTINS #define JERRY_BUILTIN_MATH JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_MATH) */ #endif /* !defined (JERRY_BUILTIN_MATH) */
#ifndef JERRY_BUILTIN_NUMBER #ifndef JERRY_BUILTIN_NUMBER
# define JERRY_BUILTIN_NUMBER JERRY_BUILTINS #define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_NUMBER) */ #endif /* !defined (JERRY_BUILTIN_NUMBER) */
#ifndef JERRY_BUILTIN_REGEXP #ifndef JERRY_BUILTIN_REGEXP
# define JERRY_BUILTIN_REGEXP JERRY_BUILTINS #define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_REGEXP) */ #endif /* !defined (JERRY_BUILTIN_REGEXP) */
#ifndef JERRY_BUILTIN_STRING #ifndef JERRY_BUILTIN_STRING
# define JERRY_BUILTIN_STRING JERRY_BUILTINS #define JERRY_BUILTIN_STRING JERRY_BUILTINS
#endif /* !defined (JERRY_BUILTIN_STRING) */ #endif /* !defined (JERRY_BUILTIN_STRING) */
/** /**
* ES2015+ related features, by default all of them are enabled. * ES2015+ related features, by default all of them are enabled.
*/ */
#ifndef JERRY_ESNEXT #ifndef JERRY_ESNEXT
# define JERRY_ESNEXT 1 #define JERRY_ESNEXT 1
#endif /* !defined (JERRY_ESNEXT) */ #endif /* !defined (JERRY_ESNEXT) */
#ifndef JERRY_BUILTIN_BIGINT #ifndef JERRY_BUILTIN_BIGINT
# define JERRY_BUILTIN_BIGINT JERRY_ESNEXT #define JERRY_BUILTIN_BIGINT JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_BIGINT) */ #endif /* !defined (JERRY_BUILTIN_BIGINT) */
#ifndef JERRY_BUILTIN_CONTAINER #ifndef JERRY_BUILTIN_CONTAINER
# define JERRY_BUILTIN_CONTAINER JERRY_ESNEXT #define JERRY_BUILTIN_CONTAINER JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_CONTAINER) */ #endif /* !defined (JERRY_BUILTIN_CONTAINER) */
#ifndef JERRY_BUILTIN_DATAVIEW #ifndef JERRY_BUILTIN_DATAVIEW
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT #define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */ #endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
#ifndef JERRY_BUILTIN_GLOBAL_THIS #ifndef JERRY_BUILTIN_GLOBAL_THIS
# define JERRY_BUILTIN_GLOBAL_THIS JERRY_ESNEXT #define JERRY_BUILTIN_GLOBAL_THIS JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */ #endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
#ifndef JERRY_BUILTIN_PROXY #ifndef JERRY_BUILTIN_PROXY
# define JERRY_BUILTIN_PROXY JERRY_ESNEXT #define JERRY_BUILTIN_PROXY JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_PROXY) */ #endif /* !defined (JERRY_BUILTIN_PROXY) */
#ifndef JERRY_BUILTIN_REALMS #ifndef JERRY_BUILTIN_REALMS
# define JERRY_BUILTIN_REALMS JERRY_ESNEXT #define JERRY_BUILTIN_REALMS JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_REALMS) */ #endif /* !defined (JERRY_BUILTIN_REALMS) */
#ifndef JERRY_BUILTIN_REFLECT #ifndef JERRY_BUILTIN_REFLECT
# define JERRY_BUILTIN_REFLECT JERRY_ESNEXT #define JERRY_BUILTIN_REFLECT JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_REFLECT) */ #endif /* !defined (JERRY_BUILTIN_REFLECT) */
#ifndef JERRY_BUILTIN_TYPEDARRAY #ifndef JERRY_BUILTIN_TYPEDARRAY
# define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT #define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */ #endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
#ifndef JERRY_BUILTIN_SHAREDARRAYBUFFER #ifndef JERRY_BUILTIN_SHAREDARRAYBUFFER
# define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_ESNEXT #define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) */ #endif /* !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) */
#ifndef JERRY_BUILTIN_ATOMICS #ifndef JERRY_BUILTIN_ATOMICS
# define JERRY_BUILTIN_ATOMICS JERRY_ESNEXT #define JERRY_BUILTIN_ATOMICS JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_ATOMICS) */ #endif /* !defined (JERRY_BUILTIN_ATOMICS) */
#ifndef JERRY_BUILTIN_WEAKREF #ifndef JERRY_BUILTIN_WEAKREF
# define JERRY_BUILTIN_WEAKREF JERRY_ESNEXT #define JERRY_BUILTIN_WEAKREF JERRY_ESNEXT
#endif /* !defined (JERRY_BUILTIN_WEAKREF) */ #endif /* !defined (JERRY_BUILTIN_WEAKREF) */
#ifndef JERRY_MODULE_SYSTEM #ifndef JERRY_MODULE_SYSTEM
# define JERRY_MODULE_SYSTEM JERRY_ESNEXT #define JERRY_MODULE_SYSTEM JERRY_ESNEXT
#endif /* !defined (JERRY_MODULE_SYSTEM) */ #endif /* !defined (JERRY_MODULE_SYSTEM) */
/** /**
@@ -142,7 +142,7 @@
* For more details see: jmem/jmem.h * For more details see: jmem/jmem.h
*/ */
#ifndef JERRY_CPOINTER_32_BIT #ifndef JERRY_CPOINTER_32_BIT
# define JERRY_CPOINTER_32_BIT 0 #define JERRY_CPOINTER_32_BIT 0
#endif /* !defined (JERRY_CPOINTER_32_BIT) */ #endif /* !defined (JERRY_CPOINTER_32_BIT) */
/** /**
@@ -153,7 +153,7 @@
* 1: Enable the debugger. * 1: Enable the debugger.
*/ */
#ifndef JERRY_DEBUGGER #ifndef JERRY_DEBUGGER
# define JERRY_DEBUGGER 0 #define JERRY_DEBUGGER 0
#endif /* !defined (JERRY_DEBUGGER) */ #endif /* !defined (JERRY_DEBUGGER) */
/** /**
@@ -166,7 +166,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_ERROR_MESSAGES #ifndef JERRY_ERROR_MESSAGES
# define JERRY_ERROR_MESSAGES 0 #define JERRY_ERROR_MESSAGES 0
#endif /* !defined (JERRY_ERROR_MESSAGES) */ #endif /* !defined (JERRY_ERROR_MESSAGES) */
/** /**
@@ -179,7 +179,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_EXTERNAL_CONTEXT #ifndef JERRY_EXTERNAL_CONTEXT
# define JERRY_EXTERNAL_CONTEXT 0 #define JERRY_EXTERNAL_CONTEXT 0
#endif /* !defined (JERRY_EXTERNAL_CONTEXT) */ #endif /* !defined (JERRY_EXTERNAL_CONTEXT) */
/** /**
@@ -188,7 +188,7 @@
* Default value: 512 KiB * Default value: 512 KiB
*/ */
#ifndef JERRY_GLOBAL_HEAP_SIZE #ifndef JERRY_GLOBAL_HEAP_SIZE
# define JERRY_GLOBAL_HEAP_SIZE (512) #define JERRY_GLOBAL_HEAP_SIZE (512)
#endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */ #endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */
/** /**
@@ -197,7 +197,7 @@
* If value is 0, the default is 1/32 of JERRY_HEAP_SIZE * If value is 0, the default is 1/32 of JERRY_HEAP_SIZE
*/ */
#ifndef JERRY_GC_LIMIT #ifndef JERRY_GC_LIMIT
# define JERRY_GC_LIMIT 0 #define JERRY_GC_LIMIT 0
#endif /* !defined (JERRY_GC_LIMIT) */ #endif /* !defined (JERRY_GC_LIMIT) */
/** /**
@@ -210,7 +210,7 @@
* Default value: 0, unlimited * Default value: 0, unlimited
*/ */
#ifndef JERRY_STACK_LIMIT #ifndef JERRY_STACK_LIMIT
# define JERRY_STACK_LIMIT (0) #define JERRY_STACK_LIMIT (0)
#endif /* !defined (JERRY_STACK_LIMIT) */ #endif /* !defined (JERRY_STACK_LIMIT) */
/** /**
@@ -219,7 +219,7 @@
* Default value: 8 * Default value: 8
*/ */
#ifndef JERRY_GC_MARK_LIMIT #ifndef JERRY_GC_MARK_LIMIT
# define JERRY_GC_MARK_LIMIT (8) #define JERRY_GC_MARK_LIMIT (8)
#endif /* !defined (JERRY_GC_MARK_LIMIT) */ #endif /* !defined (JERRY_GC_MARK_LIMIT) */
/** /**
@@ -232,7 +232,7 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_LCACHE #ifndef JERRY_LCACHE
# define JERRY_LCACHE 1 #define JERRY_LCACHE 1
#endif /* !defined (JERRY_LCACHE) */ #endif /* !defined (JERRY_LCACHE) */
/** /**
@@ -245,7 +245,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_FUNCTION_TO_STRING #ifndef JERRY_FUNCTION_TO_STRING
# define JERRY_FUNCTION_TO_STRING 0 #define JERRY_FUNCTION_TO_STRING 0
#endif /* !defined (JERRY_FUNCTION_TO_STRING) */ #endif /* !defined (JERRY_FUNCTION_TO_STRING) */
/** /**
@@ -258,7 +258,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_LINE_INFO #ifndef JERRY_LINE_INFO
# define JERRY_LINE_INFO 0 #define JERRY_LINE_INFO 0
#endif /* !defined (JERRY_LINE_INFO) */ #endif /* !defined (JERRY_LINE_INFO) */
/** /**
@@ -271,7 +271,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_LOGGING #ifndef JERRY_LOGGING
# define JERRY_LOGGING 0 #define JERRY_LOGGING 0
#endif /* !defined (JERRY_LOGGING) */ #endif /* !defined (JERRY_LOGGING) */
/** /**
@@ -286,7 +286,7 @@
* Only enable it for debugging purposes. * Only enable it for debugging purposes.
*/ */
#ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC #ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC
# define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0 #define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
#endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */ #endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */
/** /**
@@ -299,7 +299,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_MEM_STATS #ifndef JERRY_MEM_STATS
# define JERRY_MEM_STATS 0 #define JERRY_MEM_STATS 0
#endif /* !defined (JERRY_MEM_STATS) */ #endif /* !defined (JERRY_MEM_STATS) */
/** /**
@@ -313,7 +313,7 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_NUMBER_TYPE_FLOAT64 #ifndef JERRY_NUMBER_TYPE_FLOAT64
# define JERRY_NUMBER_TYPE_FLOAT64 1 #define JERRY_NUMBER_TYPE_FLOAT64 1
#endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */ #endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */
/** /**
@@ -326,7 +326,7 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_PARSER #ifndef JERRY_PARSER
# define JERRY_PARSER 1 #define JERRY_PARSER 1
#endif /* !defined (JERRY_PARSER) */ #endif /* !defined (JERRY_PARSER) */
/** /**
@@ -341,7 +341,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_PARSER_DUMP_BYTE_CODE #ifndef JERRY_PARSER_DUMP_BYTE_CODE
# define JERRY_PARSER_DUMP_BYTE_CODE 0 #define JERRY_PARSER_DUMP_BYTE_CODE 0
#endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */ #endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */
/** /**
@@ -354,7 +354,7 @@
* Default value: 1 * Default value: 1
*/ */
#ifndef JERRY_PROPERTY_HASHMAP #ifndef JERRY_PROPERTY_HASHMAP
# define JERRY_PROPERTY_HASHMAP 1 #define JERRY_PROPERTY_HASHMAP 1
#endif /* !defined (JERRY_PROPERTY_HASHMAP) */ #endif /* !defined (JERRY_PROPERTY_HASHMAP) */
/** /**
@@ -363,7 +363,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_PROMISE_CALLBACK #ifndef JERRY_PROMISE_CALLBACK
# define JERRY_PROMISE_CALLBACK 0 #define JERRY_PROMISE_CALLBACK 0
#endif /* !defined (JERRY_PROMISE_CALLBACK) */ #endif /* !defined (JERRY_PROMISE_CALLBACK) */
/** /**
@@ -379,7 +379,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_REGEXP_DUMP_BYTE_CODE #ifndef JERRY_REGEXP_DUMP_BYTE_CODE
# define JERRY_REGEXP_DUMP_BYTE_CODE 0 #define JERRY_REGEXP_DUMP_BYTE_CODE 0
#endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */ #endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */
/** /**
@@ -388,7 +388,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_REGEXP_STRICT_MODE #ifndef JERRY_REGEXP_STRICT_MODE
# define JERRY_REGEXP_STRICT_MODE 0 #define JERRY_REGEXP_STRICT_MODE 0
#endif /* !defined (JERRY_REGEXP_STRICT_MODE) */ #endif /* !defined (JERRY_REGEXP_STRICT_MODE) */
/** /**
@@ -401,7 +401,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_SNAPSHOT_EXEC #ifndef JERRY_SNAPSHOT_EXEC
# define JERRY_SNAPSHOT_EXEC 0 #define JERRY_SNAPSHOT_EXEC 0
#endif /* !defined (JERRY_SNAPSHOT_EXEC) */ #endif /* !defined (JERRY_SNAPSHOT_EXEC) */
/** /**
@@ -412,7 +412,7 @@
* 1: Enable snapshot save functions. * 1: Enable snapshot save functions.
*/ */
#ifndef JERRY_SNAPSHOT_SAVE #ifndef JERRY_SNAPSHOT_SAVE
# define JERRY_SNAPSHOT_SAVE 0 #define JERRY_SNAPSHOT_SAVE 0
#endif /* !defined (JERRY_SNAPSHOT_SAVE) */ #endif /* !defined (JERRY_SNAPSHOT_SAVE) */
/** /**
@@ -425,7 +425,7 @@
* Default value: 0 * Default value: 0
*/ */
#ifndef JERRY_SYSTEM_ALLOCATOR #ifndef JERRY_SYSTEM_ALLOCATOR
# define JERRY_SYSTEM_ALLOCATOR 0 #define JERRY_SYSTEM_ALLOCATOR 0
#endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */ #endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */
/** /**
@@ -433,7 +433,7 @@
* By default Unicode case conversion is enabled. * By default Unicode case conversion is enabled.
*/ */
#ifndef JERRY_UNICODE_CASE_CONVERSION #ifndef JERRY_UNICODE_CASE_CONVERSION
# define JERRY_UNICODE_CASE_CONVERSION 1 #define JERRY_UNICODE_CASE_CONVERSION 1
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */ #endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
/** /**
@@ -444,7 +444,7 @@
* 1: Enable the Valgrind specific allocation notifications. * 1: Enable the Valgrind specific allocation notifications.
*/ */
#ifndef JERRY_VALGRIND #ifndef JERRY_VALGRIND
# define JERRY_VALGRIND 0 #define JERRY_VALGRIND 0
#endif /* !defined (JERRY_VALGRIND) */ #endif /* !defined (JERRY_VALGRIND) */
/** /**
@@ -455,7 +455,7 @@
* 1: Enable vm exec stop callback support. * 1: Enable vm exec stop callback support.
*/ */
#ifndef JERRY_VM_EXEC_STOP #ifndef JERRY_VM_EXEC_STOP
# define JERRY_VM_EXEC_STOP 0 #define JERRY_VM_EXEC_STOP 0
#endif /* !defined (JERRY_VM_EXEC_STOP) */ #endif /* !defined (JERRY_VM_EXEC_STOP) */
/** /**
@@ -466,7 +466,7 @@
* 1: Enable vm throw callback support. * 1: Enable vm throw callback support.
*/ */
#ifndef JERRY_VM_THROW #ifndef JERRY_VM_THROW
# define JERRY_VM_THROW 0 #define JERRY_VM_THROW 0
#endif /* !defined (JERRY_VM_THROW) */ #endif /* !defined (JERRY_VM_THROW) */
/** /**
@@ -487,7 +487,7 @@
* # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const"))) * # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const")))
*/ */
#ifndef JERRY_ATTR_CONST_DATA #ifndef JERRY_ATTR_CONST_DATA
# define JERRY_ATTR_CONST_DATA #define JERRY_ATTR_CONST_DATA
#endif /* !defined (JERRY_ATTR_CONST_DATA) */ #endif /* !defined (JERRY_ATTR_CONST_DATA) */
/** /**
@@ -497,7 +497,7 @@
* #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap"))) * #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap")))
*/ */
#ifndef JERRY_ATTR_GLOBAL_HEAP #ifndef JERRY_ATTR_GLOBAL_HEAP
# define JERRY_ATTR_GLOBAL_HEAP #define JERRY_ATTR_GLOBAL_HEAP
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */ #endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
/** /**
@@ -508,232 +508,194 @@
/** /**
* Check base builtins. * Check base builtins.
*/ */
#if !defined (JERRY_BUILTIN_ANNEXB) \ #if (JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1)
|| ((JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1)) #error "Invalid value for JERRY_BUILTIN_ANNEXB macro."
# error "Invalid value for JERRY_BUILTIN_ANNEXB macro." #endif /* (JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1) */
#endif #if (JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1)
#if !defined (JERRY_BUILTIN_ARRAY) \ #error "Invalid value for JERRY_BUILTIN_ARRAY macro."
|| ((JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1)) #endif /* (JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1) */
# error "Invalid value for JERRY_BUILTIN_ARRAY macro." #if (JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1)
#endif #error "Invalid value for JERRY_BUILTIN_BOOLEAN macro."
#if !defined (JERRY_BUILTIN_BOOLEAN) \ #endif /* (JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1) */
|| ((JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1)) #if (JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1)
# error "Invalid value for JERRY_BUILTIN_BOOLEAN macro." #error "Invalid value for JERRY_BUILTIN_DATE macro."
#endif #endif /* (JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1) */
#if !defined (JERRY_BUILTIN_DATE) \ #if (JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1)
|| ((JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1)) #error "Invalid value for JERRY_BUILTIN_ERRORS macro."
# error "Invalid value for JERRY_BUILTIN_DATE macro." #endif /* (JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1) */
#endif #if (JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1)
#if !defined (JERRY_BUILTIN_ERRORS) \ #error "Invalid value for JERRY_BUILTIN_JSON macro."
|| ((JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1)) #endif /* (JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1) */
# error "Invalid value for JERRY_BUILTIN_ERRORS macro." #if (JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1)
#endif #error "Invalid value for JERRY_BUILTIN_MATH macro."
#if !defined (JERRY_BUILTIN_JSON) \ #endif /* (JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1) */
|| ((JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1)) #if (JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1)
# error "Invalid value for JERRY_BUILTIN_JSON macro." #error "Invalid value for JERRY_BUILTIN_NUMBER macro."
#endif #endif /* (JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1) */
#if !defined (JERRY_BUILTIN_MATH) \ #if (JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1)
|| ((JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1)) #error "Invalid value for JERRY_BUILTIN_REGEXP macro."
# error "Invalid value for JERRY_BUILTIN_MATH macro." #endif /* (JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1) */
#endif #if (JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1)
#if !defined (JERRY_BUILTIN_NUMBER) \ #error "Invalid value for JERRY_BUILTIN_STRING macro."
|| ((JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1)) #endif /* (JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1) */
# error "Invalid value for JERRY_BUILTIN_NUMBER macro." #if (JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1)
#endif #error "Invalid value for JERRY_BUILTINS macro."
#if !defined (JERRY_BUILTIN_REGEXP) \ #endif /* (JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1) */
|| ((JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1))
# error "Invalid value for JERRY_BUILTIN_REGEXP macro."
#endif
#if !defined (JERRY_BUILTIN_STRING) \
|| ((JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1))
# error "Invalid value for JERRY_BUILTIN_STRING macro."
#endif
#if !defined (JERRY_BUILTINS) \
|| ((JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1))
# error "Invalid value for JERRY_BUILTINS macro."
#endif
/** /**
* Check ES2015+ features * Check ES2015+ features
*/ */
#if !defined (JERRY_ESNEXT) \ #if (JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1)
|| ((JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1)) #error "Invalid value for JERRY_ESNEXT macro."
# error "Invalid value for JERRY_ESNEXT macro." #endif /* (JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1) */
#endif #if (JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1)
#if !defined (JERRY_BUILTIN_REALMS) \ #error "Invalid value for JERRY_BUILTIN_REALMS macro."
|| ((JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1)) #endif /* (JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1) */
# error "Invalid value for JERRY_BUILTIN_REALMS macro." #if (JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1)
#endif #error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
#if !defined (JERRY_BUILTIN_DATAVIEW) \ #endif /* (JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1) */
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1)) #if (JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1)
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro." #error "Invalid value for JERRY_BUILTIN_GLOBAL_THIS macro."
#endif #endif /* (JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1) */
#if !defined (JERRY_BUILTIN_GLOBAL_THIS) \ #if (JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1)
|| ((JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1)) #error "Invalid value for JERRY_BUILTIN_REFLECT macro."
# error "Invalid value for JERRY_BUILTIN_GLOBAL_THIS macro." #endif /* (JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1) */
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */ #if (JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1)
#if !defined (JERRY_BUILTIN_REFLECT) \ #error "Invalid value for JERRY_BUILTIN_WEAKREF macro."
|| ((JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1)) #endif /* (JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1) */
# error "Invalid value for JERRY_BUILTIN_REFLECT macro." #if (JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1)
#endif #error "Invalid value for JERRY_BUILTIN_PROXY macro."
#if !defined (JERRY_BUILTIN_WEAKREF) \ #endif /* (JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1) */
|| ((JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1)) #if (JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1)
# error "Invalid value for JERRY_BUILTIN_WEAKREF macro." #error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro."
#endif #endif /* (JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1) */
#if !defined (JERRY_BUILTIN_PROXY) \ #if (JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1)
|| ((JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1)) #error "Invalid value for JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
# error "Invalid value for JERRY_BUILTIN_PROXY macro." #endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1) */
#endif #if (JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1)
#if !defined (JERRY_BUILTIN_TYPEDARRAY) \ #error "Invalid value for JERRY_BUILTIN_ATOMICS macro."
|| ((JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1)) #endif /* (JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1) */
# error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro." #if (JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1)
#endif #error "Invalid value for JERRY_BUILTIN_BIGINT macro."
#if !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) \ #endif /* (JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1) */
|| ((JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1)) #if (JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1)
# error "Invalid value for JERRY_BUILTIN_SHAREDARRAYBUFFER macro." #error "Invalid value for JERRY_MODULE_SYSTEM macro."
#endif #endif /* (JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1) */
#if !defined (JERRY_BUILTIN_ATOMICS) \ #if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_DATAVIEW == 1)
|| ((JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1)) #error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_DATAVIEW macro."
# error "Invalid value for JERRY_BUILTIN_ATOMICS macro." #endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_DATAVIEW == 1) */
#endif #if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_CONTAINER == 1)
#if !defined (JERRY_BUILTIN_BIGINT) \ #error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_CONTAINER macro."
|| ((JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1)) #endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_CONTAINER == 1) */
# error "Invalid value for JERRY_BUILTIN_BIGINT macro." #if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_PROXY == 1)
#endif #error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_PROXY macro."
#if !defined (JERRY_MODULE_SYSTEM) \ #endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_PROXY == 1) */
|| ((JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1)) #if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_REFLECT == 1)
# error "Invalid value for JERRY_MODULE_SYSTEM macro." #error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_REFLECT macro."
#endif #endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_REFLECT == 1) */
#if (JERRY_ESNEXT == 0) \ #if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_TYPEDARRAY == 1)
&& ((JERRY_BUILTIN_DATAVIEW == 1) \ #error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_TYPEDARRAY macro."
|| (JERRY_BUILTIN_CONTAINER == 1) \ #endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_TYPEDARRAY == 1) */
|| (JERRY_BUILTIN_PROXY == 1) \ #if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_WEAKREF == 1)
|| (JERRY_BUILTIN_REFLECT == 1) \ #error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_WEAKREF macro."
|| (JERRY_BUILTIN_TYPEDARRAY == 1) \ #endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_WEAKREF == 1) */
|| (JERRY_BUILTIN_WEAKREF == 1))
# error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_xxxxx macro."
#endif
#if (JERRY_ESNEXT == 0) && (JERRY_MODULE_SYSTEM == 1) #if (JERRY_ESNEXT == 0) && (JERRY_MODULE_SYSTEM == 1)
# error "JERRY_ESNEXT should be enabled too to enable JERRY_MODULE_SYSTEM macro." #error "JERRY_ESNEXT should be enabled too to enable JERRY_MODULE_SYSTEM macro."
#endif #endif /* (JERRY_ESNEXT == 0) && (JERRY_MODULE_SYSTEM == 1) */
#if (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1) #if (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1)
# error "JERRY_BUILTIN_TYPEDARRAY should be enabled too to enable JERRY_BUILTIN_SHAREDARRAYBUFFER macro." #error "JERRY_BUILTIN_TYPEDARRAY should be enabled too to enable JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
#endif #endif /* (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1) */
#if (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1) #if (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1)
# error "JERRY_BUILTIN_SHAREDARRAYBUFFER should be enabled too to enable JERRY_BUILTIN_ATOMICS macro." #error "JERRY_BUILTIN_SHAREDARRAYBUFFER should be enabled too to enable JERRY_BUILTIN_ATOMICS macro."
#endif #endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1) */
/** /**
* Internal options. * Internal options.
*/ */
#if !defined (JERRY_CPOINTER_32_BIT) \ #if (JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1)
|| ((JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1)) #error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro."
# error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro." #endif /* (JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1) */
#endif #if (JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1)
#if !defined (JERRY_DEBUGGER) \ #error "Invalid value for 'JERRY_DEBUGGER' macro."
|| ((JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1)) #endif /* (JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1) */
# error "Invalid value for 'JERRY_DEBUGGER' macro." #if (JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1)
#endif #error "Invalid value for 'JERRY_ERROR_MESSAGES' macro."
#if !defined (JERRY_ERROR_MESSAGES) \ #endif /* (JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1) */
|| ((JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1)) #if (JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1)
# error "Invalid value for 'JERRY_ERROR_MESSAGES' macro." #error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro."
#endif #endif /* (JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1) */
#if !defined (JERRY_EXTERNAL_CONTEXT) \ #if JERRY_GLOBAL_HEAP_SIZE <= 0
|| ((JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1)) #error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro."
# error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro." #endif /* JERRY_GLOBAL_HEAP_SIZE <= 0 */
#endif #if JERRY_GC_LIMIT < 0
#if !defined (JERRY_GLOBAL_HEAP_SIZE) || (JERRY_GLOBAL_HEAP_SIZE <= 0) #error "Invalid value for 'JERRY_GC_LIMIT' macro."
# error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro." #endif /* JERRY_GC_LIMIT < 0 */
#endif #if JERRY_STACK_LIMIT < 0
#if !defined (JERRY_GC_LIMIT) || (JERRY_GC_LIMIT < 0) #error "Invalid value for 'JERRY_STACK_LIMIT' macro."
# error "Invalid value for 'JERRY_GC_LIMIT' macro." #endif /* JERRY_STACK_LIMIT < 0 */
#endif #if JERRY_GC_MARK_LIMIT < 0
#if !defined (JERRY_STACK_LIMIT) || (JERRY_STACK_LIMIT < 0) #error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro."
# error "Invalid value for 'JERRY_STACK_LIMIT' macro." #endif /* JERRY_GC_MARK_LIMIT < 0 */
#endif #if (JERRY_LCACHE != 0) && (JERRY_LCACHE != 1)
#if !defined (JERRY_GC_MARK_LIMIT) || (JERRY_GC_MARK_LIMIT < 0) #error "Invalid value for 'JERRY_LCACHE' macro."
# error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro." #endif /* (JERRY_LCACHE != 0) && (JERRY_LCACHE != 1) */
#endif #if (JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1)
#if !defined (JERRY_LCACHE) \ #error "Invalid value for 'JERRY_FUNCTION_TO_STRING' macro."
|| ((JERRY_LCACHE != 0) && (JERRY_LCACHE != 1)) #endif /* (JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1) */
# error "Invalid value for 'JERRY_LCACHE' macro." #if (JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1)
#endif #error "Invalid value for 'JERRY_LINE_INFO' macro."
#if !defined (JERRY_FUNCTION_TO_STRING) \ #endif /* (JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1) */
|| ((JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1)) #if (JERRY_LOGGING != 0) && (JERRY_LOGGING != 1)
# error "Invalid value for 'JERRY_FUNCTION_TO_STRING' macro." #error "Invalid value for 'JERRY_LOGGING' macro."
#endif #endif /* (JERRY_LOGGING != 0) && (JERRY_LOGGING != 1) */
#if !defined (JERRY_LINE_INFO) \ #if (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1)
|| ((JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1)) #error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro."
# error "Invalid value for 'JERRY_LINE_INFO' macro." #endif /* (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1) */
#endif #if (JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1)
#if !defined (JERRY_LOGGING) \ #error "Invalid value for 'JERRY_MEM_STATS' macro."
|| ((JERRY_LOGGING != 0) && (JERRY_LOGGING != 1)) #endif /* (JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1) */
# error "Invalid value for 'JERRY_LOGGING' macro." #if (JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1)
#endif #error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro."
#if !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) \ #endif /* (JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1) */
|| ((JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1)) #if (JERRY_PARSER != 0) && (JERRY_PARSER != 1)
# error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro." #error "Invalid value for 'JERRY_PARSER' macro."
#endif #endif /* (JERRY_PARSER != 0) && (JERRY_PARSER != 1) */
#if !defined (JERRY_MEM_STATS) \ #if (JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1)
|| ((JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1)) #error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro."
# error "Invalid value for 'JERRY_MEM_STATS' macro." #endif /* (JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1) */
#endif #if (JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1)
#if !defined (JERRY_NUMBER_TYPE_FLOAT64) \ #error "Invalid value for 'JERRY_PROPERTY_HASHMAP' macro."
|| ((JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1)) #endif /* (JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1) */
# error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro." #if (JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1)
#endif #error "Invalid value for 'JERRY_PROMISE_CALLBACK' macro."
#if !defined (JERRY_PARSER) \ #endif /* (JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1) */
|| ((JERRY_PARSER != 0) && (JERRY_PARSER != 1)) #if (JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1)
# error "Invalid value for 'JERRY_PARSER' macro." #error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro."
#endif #endif /* (JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1) */
#if !defined (JERRY_PARSER_DUMP_BYTE_CODE) \ #if (JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1)
|| ((JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1)) #error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro."
# error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro." #endif /* (JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1) */
#endif #if (JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1)
#if !defined (JERRY_PROPERTY_HASHMAP) \ #error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro."
|| ((JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1)) #endif /* (JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1) */
# error "Invalid value for 'JERRY_PROPERTY_HASHMAP' macro." #if (JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1)
#endif #error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro."
#if !defined (JERRY_PROMISE_CALLBACK) \ #endif /* (JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1) */
|| ((JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1)) #if (JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1)
# error "Invalid value for 'JERRY_PROMISE_CALLBACK' macro." #error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro."
#endif #endif /* (JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1) */
#if !defined (JERRY_REGEXP_DUMP_BYTE_CODE) \ #if (JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1)
|| ((JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1)) #error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
# error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro." #endif /* (JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1) */
#endif #if (JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1)
#if !defined (JERRY_REGEXP_STRICT_MODE) \ #error "Invalid value for 'JERRY_VALGRIND' macro."
|| ((JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1)) #endif /* (JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1) */
# error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro." #if (JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1)
#endif #error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
#if !defined (JERRY_SNAPSHOT_EXEC) \ #endif /* (JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1) */
|| ((JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1)) #if (JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1)
# error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro." #error "Invalid value for 'JERRY_VM_THROW' macro."
#endif #endif /* (JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1) */
#if !defined (JERRY_SNAPSHOT_SAVE) \
|| ((JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1))
# error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro."
#endif
#if !defined (JERRY_SYSTEM_ALLOCATOR) \
|| ((JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1))
# error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro."
#endif
#if !defined (JERRY_UNICODE_CASE_CONVERSION) \
|| ((JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1))
# error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
#endif
#if !defined (JERRY_VALGRIND) \
|| ((JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1))
# error "Invalid value for 'JERRY_VALGRIND' macro."
#endif
#if !defined (JERRY_VM_EXEC_STOP) \
|| ((JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1))
# error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
#endif
#if !defined (JERRY_VM_THROW) \
|| ((JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1))
# error "Invalid value for 'JERRY_VM_THROW' macro."
#endif
/** /**
* Cross component requirements check. * Cross component requirements check.
@@ -743,23 +705,23 @@
* The date module can only use the float 64 number types. * The date module can only use the float 64 number types.
*/ */
#if JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 #if JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64
# error "Date does not support float32" #error "Date does not support float32"
#endif #endif /* JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 */
/** /**
* Promise support must be enabled if Promise callback support is enabled. * Promise support must be enabled if Promise callback support is enabled.
*/ */
#if JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT #if JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT
# error "Promise callback support depends on ESNext support" #error "Promise callback support depends on ESNext support"
#endif /* JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT */ #endif /* JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT */
/** /**
* Resource name related types into a single guard * Resource name related types into a single guard
*/ */
#if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM #if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM
# define JERRY_RESOURCE_NAME 1 #define JERRY_RESOURCE_NAME 1
#else #else /* !(JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM) */
# define JERRY_RESOURCE_NAME 0 #define JERRY_RESOURCE_NAME 0
#endif #endif /* JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM */
#endif /* !JERRYSCRIPT_CONFIG_H */ #endif /* !JERRYSCRIPT_CONFIG_H */
+29 -47
View File
@@ -13,16 +13,19 @@
* limitations under the License. * limitations under the License.
*/ */
#include "byte-code.h"
#include "debugger.h" #include "debugger.h"
#include "jerryscript-debugger.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-eval.h" #include "ecma-eval.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "byte-code.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript-debugger.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#if JERRY_DEBUGGER #if JERRY_DEBUGGER
@@ -39,16 +42,14 @@ typedef struct
* The number of message types in the debugger should reflect the * The number of message types in the debugger should reflect the
* debugger versioning. * debugger versioning.
*/ */
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33 JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33 && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
&& JERRY_DEBUGGER_VERSION == 9, && JERRY_DEBUGGER_VERSION == 9,
debugger_version_correlates_to_message_type_count); debugger_version_correlates_to_message_type_count);
/** /**
* Waiting for data from the client. * Waiting for data from the client.
*/ */
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE \ #define JERRY_DEBUGGER_RECEIVE_DATA_MODE (JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
(JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
/** /**
* Type cast the debugger send buffer into a specific type. * Type cast the debugger send buffer into a specific type.
@@ -59,8 +60,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33
/** /**
* Type cast the debugger receive buffer into a specific type. * Type cast the debugger receive buffer into a specific type.
*/ */
#define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) \ #define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) type *name_p = ((type *) recv_buffer_p)
type *name_p = ((type *) recv_buffer_p)
/** /**
* Free all unreferenced byte code structures which * Free all unreferenced byte code structures which
@@ -71,17 +71,15 @@ jerry_debugger_free_unreferenced_byte_code (void)
{ {
jerry_debugger_byte_code_free_t *byte_code_free_p; jerry_debugger_byte_code_free_t *byte_code_free_p;
byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p =
JERRY_CONTEXT (debugger_byte_code_free_tail)); JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, JERRY_CONTEXT (debugger_byte_code_free_tail));
while (byte_code_free_p != NULL) while (byte_code_free_p != NULL)
{ {
jerry_debugger_byte_code_free_t *prev_byte_code_free_p; jerry_debugger_byte_code_free_t *prev_byte_code_free_p;
prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p->prev_cp);
byte_code_free_p->prev_cp);
jmem_heap_free_block (byte_code_free_p, jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
byte_code_free_p = prev_byte_code_free_p; byte_code_free_p = prev_byte_code_free_p;
} }
@@ -488,8 +486,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
continue; continue;
} }
ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i], ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i]);
prop_pair_p->names_cp[i]);
if (!jerry_debugger_copy_variables_to_string_message (JERRY_DEBUGGER_VALUE_NONE, if (!jerry_debugger_copy_variables_to_string_message (JERRY_DEBUGGER_VALUE_NONE,
prop_name, prop_name,
@@ -509,10 +506,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
ecma_string_t *str_p = ecma_op_to_string (prop_value_p.value); ecma_string_t *str_p = ecma_op_to_string (prop_value_p.value);
JERRY_ASSERT (str_p != NULL); JERRY_ASSERT (str_p != NULL);
if (!jerry_debugger_copy_variables_to_string_message (variable_type, if (!jerry_debugger_copy_variables_to_string_message (variable_type, str_p, message_string_p, &buffer_pos))
str_p,
message_string_p,
&buffer_pos))
{ {
ecma_deref_ecma_string (str_p); ecma_deref_ecma_string (str_p);
return; return;
@@ -591,21 +585,17 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
if (ecma_is_value_object (result)) if (ecma_is_value_object (result))
{ {
message = ecma_op_object_find (ecma_get_object_from_value (result), message =
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE)); ecma_op_object_find (ecma_get_object_from_value (result), ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
if (!ecma_is_value_string (message) if (!ecma_is_value_string (message) || ecma_string_is_empty (ecma_get_string_from_value (message)))
|| ecma_string_is_empty (ecma_get_string_from_value (message)))
{ {
ecma_free_value (message); ecma_free_value (message);
lit_magic_string_id_t id = ecma_object_get_class_name (ecma_get_object_from_value (result)); lit_magic_string_id_t id = ecma_object_get_class_name (ecma_get_object_from_value (result));
ecma_free_value (result); ecma_free_value (result);
const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id); const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id);
jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, string_p, strlen ((const char *) string_p));
type,
string_p,
strlen ((const char *) string_p));
return false; return false;
} }
} }
@@ -658,8 +648,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
{ {
/* Process the received message. */ /* Process the received message. */
if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{ {
JERRY_ERROR_MSG ("Message requires breakpoint mode\n"); JERRY_ERROR_MSG ("Message requires breakpoint mode\n");
jerry_debugger_transport_close (); jerry_debugger_transport_close ();
@@ -704,9 +693,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
} }
lit_utf8_byte_t *string_p = (lit_utf8_byte_t *) (uint8_data_p + 1); lit_utf8_byte_t *string_p = (lit_utf8_byte_t *) (uint8_data_p + 1);
memcpy (string_p + uint8_data_p->uint8_offset, memcpy (string_p + uint8_data_p->uint8_offset, (lit_utf8_byte_t *) (uint8_data_part_p + 1), message_size);
(lit_utf8_byte_t *) (uint8_data_part_p + 1),
message_size);
if (message_size < expected_data) if (message_size < expected_data)
{ {
@@ -754,8 +741,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
} }
jerry_debugger_byte_code_free_t *byte_code_free_p; jerry_debugger_byte_code_free_t *byte_code_free_p;
byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_cp);
byte_code_free_cp);
if (byte_code_free_p->prev_cp != ECMA_NULL_POINTER) if (byte_code_free_p->prev_cp != ECMA_NULL_POINTER)
{ {
@@ -771,8 +757,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
jmem_stats_free_byte_code_bytes (((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG); jmem_stats_free_byte_code_bytes (((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
#endif /* JERRY_MEM_STATS */ #endif /* JERRY_MEM_STATS */
jmem_heap_free_block (byte_code_free_p, jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
return true; return true;
} }
@@ -1023,8 +1008,8 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
client_source_data_p = (jerry_debugger_uint8_data_t *) jmem_heap_alloc_block (client_source_data_size); client_source_data_p = (jerry_debugger_uint8_data_t *) jmem_heap_alloc_block (client_source_data_size);
client_source_data_p->uint8_size = client_source_size; client_source_data_p->uint8_size = client_source_size;
client_source_data_p->uint8_offset = (uint32_t) (message_size client_source_data_p->uint8_offset =
- sizeof (jerry_debugger_receive_client_source_first_t)); (uint32_t) (message_size - sizeof (jerry_debugger_receive_client_source_first_t));
lit_utf8_byte_t *client_source_string_p = (lit_utf8_byte_t *) (client_source_data_p + 1); lit_utf8_byte_t *client_source_string_p = (lit_utf8_byte_t *) (client_source_data_p + 1);
memcpy (client_source_string_p, memcpy (client_source_string_p,
@@ -1193,8 +1178,7 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
if (uint8_data != NULL) if (uint8_data != NULL)
{ {
jmem_heap_free_block (uint8_data, jmem_heap_free_block (uint8_data, uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
} }
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE); JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE);
@@ -1460,13 +1444,13 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL; string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL;
break; break;
} }
#if JERRY_ESNEXT #if JERRY_ESNEXT
case ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE: case ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE:
{ {
string_id = LIT_MAGIC_STRING_AGGREGATE_ERROR_UL; string_id = LIT_MAGIC_STRING_AGGREGATE_ERROR_UL;
break; break;
} }
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE: case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE:
{ {
string_id = LIT_MAGIC_STRING_URI_ERROR_UL; string_id = LIT_MAGIC_STRING_URI_ERROR_UL;
@@ -1544,10 +1528,8 @@ jerry_debugger_send_exception_string (ecma_value_t exception_value)
ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size); ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size);
bool result = jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR, bool result =
JERRY_DEBUGGER_NO_SUBTYPE, jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR, JERRY_DEBUGGER_NO_SUBTYPE, string_data_p, string_size);
string_data_p,
string_size);
ECMA_FINALIZE_UTF8_STRING (string_data_p, string_size); ECMA_FINALIZE_UTF8_STRING (string_data_p, string_size);
+6 -6
View File
@@ -16,9 +16,10 @@
#ifndef DEBUGGER_H #ifndef DEBUGGER_H
#define DEBUGGER_H #define DEBUGGER_H
#include "ecma-globals.h"
#include "jerryscript-debugger-transport.h" #include "jerryscript-debugger-transport.h"
#include "ecma-globals.h"
#if JERRY_DEBUGGER #if JERRY_DEBUGGER
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */ /* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
@@ -51,8 +52,7 @@
/** /**
* Calculate the size of a message when a count number of items transmitted. * Calculate the size of a message when a count number of items transmitted.
*/ */
#define JERRY_DEBUGGER_SEND_SIZE(count, type) \ #define JERRY_DEBUGGER_SEND_SIZE(count, type) ((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
/** /**
* Debugger operation modes: * Debugger operation modes:
@@ -113,8 +113,8 @@ typedef enum
* Set and clear debugger flags. * Set and clear debugger flags.
*/ */
#define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \ #define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \
JERRY_CONTEXT (debugger_flags) = ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) \ JERRY_CONTEXT (debugger_flags) = \
& (uint32_t) ~(flags_to_clear)) ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) & (uint32_t) ~(flags_to_clear))
/** /**
* Types for the package. * Types for the package.
@@ -455,7 +455,7 @@ typedef struct
/** /**
* Incoming message: get scope variables * Incoming message: get scope variables
*/ */
typedef struct typedef struct
{ {
uint8_t type; /**< type of the message */ uint8_t type; /**< type of the message */
+12 -10
View File
@@ -14,10 +14,12 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-globals.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "jrt.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
#include "jrt.h"
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t); size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
@@ -51,7 +53,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_number_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_number (void) ecma_alloc_number (void)
{ {
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t)); return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
@@ -71,7 +73,7 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_object (void) ecma_alloc_object (void)
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
@@ -99,7 +101,7 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_extended_object_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_extended_object (size_t size) /**< size of object */ ecma_alloc_extended_object (size_t size) /**< size of object */
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
@@ -128,7 +130,7 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_string (void) ecma_alloc_string (void)
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
@@ -156,7 +158,7 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_extended_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_extended_string (void) ecma_alloc_extended_string (void)
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
@@ -184,7 +186,7 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_external_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_external_string (void) ecma_alloc_external_string (void)
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
@@ -212,7 +214,7 @@ ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< externa
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_string_buffer (size_t size) /**< size of string */ ecma_alloc_string_buffer (size_t size) /**< size of string */
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
@@ -241,7 +243,7 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
* *
* @return pointer to allocated memory * @return pointer to allocated memory
*/ */
extern inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_property_pair_t *JERRY_ATTR_ALWAYS_INLINE
ecma_alloc_property_pair (void) ecma_alloc_property_pair (void)
{ {
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
+33 -33
View File
@@ -20,114 +20,114 @@
/** /**
* Error message, if an argument is has an error flag * Error message, if an argument is has an error flag
*/ */
const char * const ecma_error_value_msg_p = "Argument cannot be marked as error"; const char* const ecma_error_value_msg_p = "Argument cannot be marked as error";
/** /**
* Error message, if an argument has a wrong type * Error message, if an argument has a wrong type
*/ */
const char * const ecma_error_wrong_args_msg_p = "This type of argument is not allowed"; const char* const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
#if !JERRY_PARSER #if !JERRY_PARSER
/** /**
* Error message, if parsing is disabled * Error message, if parsing is disabled
*/ */
const char * const ecma_error_parser_not_supported_p = "Source code parsing is disabled"; const char* const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
#endif /* !JERRY_PARSER */ #endif /* !JERRY_PARSER */
#if !JERRY_BUILTIN_JSON #if !JERRY_BUILTIN_JSON
/** /**
* Error message, if JSON support is disabled * Error message, if JSON support is disabled
*/ */
const char * const ecma_error_json_not_supported_p = "JSON support is disabled"; const char* const ecma_error_json_not_supported_p = "JSON support is disabled";
#endif /* !JERRY_BUILTIN_JSON */ #endif /* !JERRY_BUILTIN_JSON */
#if !JERRY_ESNEXT #if !JERRY_ESNEXT
/** /**
* Error message, if Symbol support is disabled * Error message, if Symbol support is disabled
*/ */
const char * const ecma_error_symbol_not_supported_p = "Symbol support is disabled"; const char* const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
/** /**
* Error message, if Promise support is disabled * Error message, if Promise support is disabled
*/ */
const char * const ecma_error_promise_not_supported_p = "Promise support is disabled"; const char* const ecma_error_promise_not_supported_p = "Promise support is disabled";
#endif /* !JERRY_ESNEXT */ #endif /* !JERRY_ESNEXT */
#if !JERRY_BUILTIN_TYPEDARRAY #if !JERRY_BUILTIN_TYPEDARRAY
/** /**
* Error message, if TypedArray support is disabled * Error message, if TypedArray support is disabled
*/ */
const char * const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled"; const char* const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
#endif /* !JERRY_BUILTIN_TYPEDARRAY */ #endif /* !JERRY_BUILTIN_TYPEDARRAY */
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER #if !JERRY_BUILTIN_SHAREDARRAYBUFFER
/** /**
* Error message, if SharedArrayBuffer support is disabled * Error message, if SharedArrayBuffer support is disabled
*/ */
const char * const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled"; const char* const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */ #endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
#if !JERRY_BUILTIN_DATAVIEW #if !JERRY_BUILTIN_DATAVIEW
/** /**
* Error message, if DataView support is disabled * Error message, if DataView support is disabled
*/ */
const char * const ecma_error_data_view_not_supported_p = "DataView support is disabled"; const char* const ecma_error_data_view_not_supported_p = "DataView support is disabled";
#endif /* !JERRY_BUILTIN_DATAVIEW */ #endif /* !JERRY_BUILTIN_DATAVIEW */
#if !JERRY_BUILTIN_BIGINT #if !JERRY_BUILTIN_BIGINT
/** /**
* Error message, if BigInt support is disabled * Error message, if BigInt support is disabled
*/ */
const char * const ecma_error_bigint_not_supported_p = "BigInt support is disabled"; const char* const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
#endif /* !JERRY_BUILTIN_BIGINT */ #endif /* !JERRY_BUILTIN_BIGINT */
#if !JERRY_BUILTIN_CONTAINER #if !JERRY_BUILTIN_CONTAINER
/** /**
* Error message, if Container support is disabled * Error message, if Container support is disabled
*/ */
const char * const ecma_error_container_not_supported_p = "Container support is disabled"; const char* const ecma_error_container_not_supported_p = "Container support is disabled";
#endif /* JERRY_BUILTIN_CONTAINER */ #endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
/** /**
* Error message, if argument is not a module * Error message, if argument is not a module
*/ */
const char * const ecma_error_not_module_p = "Argument is not a module"; const char* const ecma_error_not_module_p = "Argument is not a module";
/** /**
* Error message, if a native module export is not found * Error message, if a native module export is not found
*/ */
const char * const ecma_error_unknown_export_p = "Native module export not found"; const char* const ecma_error_unknown_export_p = "Native module export not found";
#else /* !JERRY_MODULE_SYSTEM */ #else /* !JERRY_MODULE_SYSTEM */
/** /**
* Error message, if Module support is disabled * Error message, if Module support is disabled
*/ */
const char * const ecma_error_module_not_supported_p = "Module support is disabled"; const char* const ecma_error_module_not_supported_p = "Module support is disabled";
#endif /* JERRY_MODULE_SYSTEM */ #endif /* JERRY_MODULE_SYSTEM */
/** /**
* Error message, if callback function is not callable * Error message, if callback function is not callable
*/ */
const char * const ecma_error_callback_is_not_callable = "Callback function is not callable"; const char* const ecma_error_callback_is_not_callable = "Callback function is not callable";
/** /**
* Error message, if arrayBuffer is detached * Error message, if arrayBuffer is detached
*/ */
const char * const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached"; const char* const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
/** /**
* Error message, cannot convert undefined or null to object * Error message, cannot convert undefined or null to object
*/ */
const char * const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object"; const char* const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
/** /**
* Error message, prototype property of a class is non-configurable * Error message, prototype property of a class is non-configurable
*/ */
const char * const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable"; const char* const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
/** /**
* Error message, argument is not an object * Error message, argument is not an object
*/ */
const char * const ecma_error_argument_is_not_an_object = "Argument is not an object"; const char* const ecma_error_argument_is_not_an_object = "Argument is not an object";
/** /**
* Error message length of 'ecma_error_argument_is_not_an_object' * Error message length of 'ecma_error_argument_is_not_an_object'
@@ -137,44 +137,44 @@ const int ecma_error_argument_is_not_an_object_length = 25;
/** /**
* Error message, argument is not a Proxy object * Error message, argument is not a Proxy object
*/ */
const char * const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object"; const char* const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
/** /**
* Error message, target is not a constructor * Error message, target is not a constructor
*/ */
const char * const ecma_error_target_is_not_a_constructor = "Target is not a constructor"; const char* const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
/** /**
* Error message, argument is not an regexp * Error message, argument is not an regexp
*/ */
const char * const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object"; const char* const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
/** /**
* Error message, invalid array length * Error message, invalid array length
*/ */
const char * const ecma_error_invalid_array_length = "Invalid Array length"; const char* const ecma_error_invalid_array_length = "Invalid Array length";
/** /**
* Error message, local variable is redeclared * Error message, local variable is redeclared
*/ */
const char * const ecma_error_local_variable_is_redeclared = "Local variable is redeclared"; const char* const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
/** /**
* Error message, expected a function * Error message, expected a function
*/ */
const char * const ecma_error_expected_a_function = "Expected a function"; const char* const ecma_error_expected_a_function = "Expected a function";
#if JERRY_ESNEXT #if JERRY_ESNEXT
/** /**
* Error message, class constructor invoked without new keyword * Error message, class constructor invoked without new keyword
*/ */
const char * const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'"; const char* const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
/** /**
* Error message, variables declared by let/const must be initialized before reading their value * Error message, variables declared by let/const must be initialized before reading their value
*/ */
const char * const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be" const char* const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
" initialized before reading their value"); " initialized before reading their value");
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -186,31 +186,31 @@ const char * const ecma_error_let_const_not_initialized = ("Variables declared b
/** /**
* Error message, maximum snapshot size reached * Error message, maximum snapshot size reached
*/ */
const char * const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached"; const char* const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
/** /**
* Error message, regular expressions literals are not supported * Error message, regular expressions literals are not supported
*/ */
const char * const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported"; const char* const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
/** /**
* Error message, snapshot buffer too small * Error message, snapshot buffer too small
*/ */
const char * const ecma_error_snapshot_buffer_small = "Snapshot buffer too small"; const char* const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
/** /**
* Error message, Unsupported generate snapshot flags specified * Error message, Unsupported generate snapshot flags specified
*/ */
const char * const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified"; const char* const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
/** /**
* Error message, Cannot allocate memory for literals * Error message, Cannot allocate memory for literals
*/ */
const char * const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals"; const char* const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
/** /**
* Error message, Unsupported feature: tagged template literals * Error message, Unsupported feature: tagged template literals
*/ */
const char * const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals"; const char* const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
#endif /* JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC */ #endif /* JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC */
+33 -33
View File
@@ -20,75 +20,75 @@
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
extern const char * const ecma_error_value_msg_p; extern const char* const ecma_error_value_msg_p;
extern const char * const ecma_error_wrong_args_msg_p; extern const char* const ecma_error_wrong_args_msg_p;
#if !JERRY_PARSER #if !JERRY_PARSER
extern const char * const ecma_error_parser_not_supported_p; extern const char* const ecma_error_parser_not_supported_p;
#endif /* !JERRY_PARSER */ #endif /* !JERRY_PARSER */
#if !JERRY_BUILTIN_JSON #if !JERRY_BUILTIN_JSON
extern const char * const ecma_error_json_not_supported_p; extern const char* const ecma_error_json_not_supported_p;
#endif /* !JERRY_BUILTIN_JSON */ #endif /* !JERRY_BUILTIN_JSON */
#if !JERRY_ESNEXT #if !JERRY_ESNEXT
extern const char * const ecma_error_symbol_not_supported_p; extern const char* const ecma_error_symbol_not_supported_p;
extern const char * const ecma_error_promise_not_supported_p; extern const char* const ecma_error_promise_not_supported_p;
#endif /* !JERRY_ESNEXT */ #endif /* !JERRY_ESNEXT */
#if !JERRY_BUILTIN_TYPEDARRAY #if !JERRY_BUILTIN_TYPEDARRAY
extern const char * const ecma_error_typed_array_not_supported_p; extern const char* const ecma_error_typed_array_not_supported_p;
#endif /* !JERRY_BUILTIN_TYPEDARRAY */ #endif /* !JERRY_BUILTIN_TYPEDARRAY */
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER #if !JERRY_BUILTIN_SHAREDARRAYBUFFER
extern const char * const ecma_error_shared_arraybuffer_not_supported_p; extern const char* const ecma_error_shared_arraybuffer_not_supported_p;
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */ #endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
#if !JERRY_BUILTIN_DATAVIEW #if !JERRY_BUILTIN_DATAVIEW
extern const char * const ecma_error_data_view_not_supported_p; extern const char* const ecma_error_data_view_not_supported_p;
#endif /* !JERRY_BUILTIN_DATAVIEW */ #endif /* !JERRY_BUILTIN_DATAVIEW */
#if !JERRY_BUILTIN_BIGINT #if !JERRY_BUILTIN_BIGINT
extern const char * const ecma_error_bigint_not_supported_p; extern const char* const ecma_error_bigint_not_supported_p;
#endif /* !JERRY_BUILTIN_BIGINT */ #endif /* !JERRY_BUILTIN_BIGINT */
#if !JERRY_BUILTIN_CONTAINER #if !JERRY_BUILTIN_CONTAINER
extern const char * const ecma_error_container_not_supported_p; extern const char* const ecma_error_container_not_supported_p;
#endif /* !JERRY_BUILTIN_CONTAINER */ #endif /* !JERRY_BUILTIN_CONTAINER */
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
extern const char * const ecma_error_not_module_p; extern const char* const ecma_error_not_module_p;
extern const char * const ecma_error_unknown_export_p; extern const char* const ecma_error_unknown_export_p;
#else /* !JERRY_MODULE_SYSTEM */ #else /* !JERRY_MODULE_SYSTEM */
extern const char * const ecma_error_module_not_supported_p; extern const char* const ecma_error_module_not_supported_p;
#endif /* JERRY_MODULE_SYSTEM */ #endif /* JERRY_MODULE_SYSTEM */
extern const char * const ecma_error_callback_is_not_callable; extern const char* const ecma_error_callback_is_not_callable;
extern const char * const ecma_error_arraybuffer_is_detached; extern const char* const ecma_error_arraybuffer_is_detached;
extern const char * const ecma_error_cannot_convert_to_object; extern const char* const ecma_error_cannot_convert_to_object;
extern const char * const ecma_error_class_is_non_configurable; extern const char* const ecma_error_class_is_non_configurable;
extern const char * const ecma_error_argument_is_not_an_object; extern const char* const ecma_error_argument_is_not_an_object;
extern const int ecma_error_argument_is_not_an_object_length; extern const int ecma_error_argument_is_not_an_object_length;
extern const char * const ecma_error_argument_is_not_a_proxy; extern const char* const ecma_error_argument_is_not_a_proxy;
extern const char * const ecma_error_target_is_not_a_constructor; extern const char* const ecma_error_target_is_not_a_constructor;
extern const char * const ecma_error_argument_is_not_an_regexp; extern const char* const ecma_error_argument_is_not_an_regexp;
extern const char * const ecma_error_invalid_array_length; extern const char* const ecma_error_invalid_array_length;
extern const char * const ecma_error_local_variable_is_redeclared; extern const char* const ecma_error_local_variable_is_redeclared;
extern const char * const ecma_error_expected_a_function; extern const char* const ecma_error_expected_a_function;
#if JERRY_ESNEXT #if JERRY_ESNEXT
extern const char * const ecma_error_class_constructor_new; extern const char* const ecma_error_class_constructor_new;
extern const char * const ecma_error_let_const_not_initialized; extern const char* const ecma_error_let_const_not_initialized;
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#endif /* JERRY_ERROR_MESSAGES */ #endif /* JERRY_ERROR_MESSAGES */
/* snapshot errors */ /* snapshot errors */
extern const char * const ecma_error_maximum_snapshot_size; extern const char* const ecma_error_maximum_snapshot_size;
extern const char * const ecma_error_regular_expression_not_supported; extern const char* const ecma_error_regular_expression_not_supported;
extern const char * const ecma_error_snapshot_buffer_small; extern const char* const ecma_error_snapshot_buffer_small;
extern const char * const ecma_error_snapshot_flag_not_supported; extern const char* const ecma_error_snapshot_flag_not_supported;
extern const char * const ecma_error_cannot_allocate_memory_literals; extern const char* const ecma_error_cannot_allocate_memory_literals;
extern const char * const ecma_error_tagged_template_literals; extern const char* const ecma_error_tagged_template_literals;
#endif /* !ECMA_ERRORS_H */ #endif /* !ECMA_ERRORS_H */
+8 -10
View File
@@ -13,10 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "byte-code.h"
#include "ecma-helpers.h"
#include "ecma-extended-info.h" #include "ecma-extended-info.h"
#include "ecma-helpers.h"
#include "byte-code.h"
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING #if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -41,8 +43,7 @@ ecma_extended_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer *
{ {
source_p--; source_p--;
value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK); value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK);
} } while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
*buffer_p = source_p; *buffer_p = source_p;
return value; return value;
@@ -71,8 +72,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
{ {
current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT; current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
length++; length++;
} } while (current_value > 0);
while (current_value > 0);
destination_p -= length; destination_p -= length;
*buffer_p = destination_p; *buffer_p = destination_p;
@@ -81,8 +81,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
{ {
*destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE); *destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE);
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT; value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
} } while (value > 0);
while (value > 0);
**buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK; **buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK;
} /* ecma_extended_info_encode_vlq */ } /* ecma_extended_info_encode_vlq */
@@ -101,8 +100,7 @@ ecma_extended_info_get_encoded_length (uint32_t value) /**< encoded value */
{ {
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT; value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
length++; length++;
} } while (value > 0);
while (value > 0);
return length; return length;
} /* ecma_extended_info_get_encoded_length */ } /* ecma_extended_info_get_encoded_length */
+2 -2
View File
@@ -23,10 +23,10 @@
* @{ * @{
*/ */
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
#include "ecma-globals.h" #include "ecma-globals.h"
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
/** /**
* Vlq encoding: flag which is set for all bytes except the last one. * Vlq encoding: flag which is set for all bytes except the last one.
*/ */
+45 -65
View File
@@ -17,6 +17,8 @@
* Garbage collector implementation * Garbage collector implementation
*/ */
#include "ecma-gc.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-arraybuffer-object.h" #include "ecma-arraybuffer-object.h"
@@ -24,16 +26,16 @@
#include "ecma-container-object.h" #include "ecma-container-object.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-gc.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lcache.h" #include "ecma-lcache.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-property-hashmap.h" #include "ecma-property-hashmap.h"
#include "ecma-proxy-object.h" #include "ecma-proxy-object.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h"
#include "jrt-libc-includes.h"
#include "jrt-bit-fields.h" #include "jrt-bit-fields.h"
#include "jrt-libc-includes.h"
#include "jrt.h"
#include "re-compiler.h" #include "re-compiler.h"
#include "vm-defines.h" #include "vm-defines.h"
#include "vm-stack.h" #include "vm-stack.h"
@@ -300,8 +302,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
if (!ECMA_PROPERTY_IS_INTERNAL (property)) if (!ECMA_PROPERTY_IS_INTERNAL (property))
{ {
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED || property == ECMA_PROPERTY_TYPE_HASHMAP);
|| property == ECMA_PROPERTY_TYPE_HASHMAP);
continue; continue;
} }
@@ -314,8 +315,8 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD: case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD:
{ {
ecma_environment_record_t *environment_record_p; ecma_environment_record_t *environment_record_p;
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t, environment_record_p =
property_pair_p->values[index].value); ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t, property_pair_p->values[index].value);
if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED) if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED)
{ {
@@ -397,8 +398,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
{ {
ecma_gc_set_object_visited (ecma_get_object_from_value (*value_p)); ecma_gc_set_object_visited (ecma_get_object_from_value (*value_p));
} }
} } while (++value_p < end_p);
while (++value_p < end_p);
if (property & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL) if (property & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)
{ {
@@ -406,8 +406,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
} }
item_p = &(((ecma_native_pointer_chain_t *) item_p)->next_p->data); item_p = &(((ecma_native_pointer_chain_t *) item_p)->next_p->data);
} } while (item_p != NULL);
while (item_p != NULL);
break; break;
} }
@@ -460,8 +459,8 @@ ecma_gc_mark_bound_function_object (ecma_object_t *object_p) /**< bound function
ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) object_p; ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) object_p;
ecma_object_t *target_func_p; ecma_object_t *target_func_p;
target_func_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, target_func_p =
bound_func_p->header.u.bound_function.target_function); ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function);
ecma_gc_set_object_visited (target_func_p); ecma_gc_set_object_visited (target_func_p);
@@ -547,12 +546,11 @@ ecma_gc_mark_map_object (ecma_object_t *object_p) /**< object */
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
map_object_p->u.cls.u3.value);
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE) for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
{ {
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i); ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
@@ -582,12 +580,11 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
map_object_p->u.cls.u3.value);
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE) for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
{ {
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i); ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
@@ -598,8 +595,7 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
JERRY_ASSERT (ecma_is_value_object (entry_p->key)); JERRY_ASSERT (ecma_is_value_object (entry_p->key));
if (ecma_is_value_object (entry_p->value) if (ecma_is_value_object (entry_p->value) && ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
&& ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
{ {
ecma_gc_set_object_visited (ecma_get_object_from_value (entry_p->value)); ecma_gc_set_object_visited (ecma_get_object_from_value (entry_p->value));
} }
@@ -615,12 +611,11 @@ ecma_gc_mark_set_object (ecma_object_t *object_p) /**< object */
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
map_object_p->u.cls.u3.value);
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p); ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_VALUE_SIZE) for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_VALUE_SIZE)
{ {
ecma_value_t *entry_p = start_p + i; ecma_value_t *entry_p = start_p + i;
@@ -728,8 +723,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
do do
{ {
ecma_gc_set_object_visited (ecma_get_object_from_value (*(--context_top_p))); ecma_gc_set_object_visited (ecma_get_object_from_value (*(--context_top_p)));
} } while (context_top_p > last_item_p);
while (context_top_p > last_item_p);
continue; continue;
} }
@@ -750,8 +744,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
JERRY_ASSERT (context_top_p >= context_end_p + offsets); JERRY_ASSERT (context_top_p >= context_end_p + offsets);
context_top_p -= offsets; context_top_p -= offsets;
} } while (context_top_p > context_end_p);
while (context_top_p > context_end_p);
} }
register_end_p = executable_object_p->frame_ctx.stack_top_p; register_end_p = executable_object_p->frame_ctx.stack_top_p;
@@ -891,8 +884,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
case ECMA_OBJECT_CLASS_SCRIPT: case ECMA_OBJECT_CLASS_SCRIPT:
{ {
const ecma_compiled_code_t *compiled_code_p; const ecma_compiled_code_t *compiled_code_p;
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
ext_object_p->u.cls.u3.value);
JERRY_ASSERT (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)); JERRY_ASSERT (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
ecma_gc_mark_compiled_code (((cbc_uint8_arguments_t *) compiled_code_p)->script_value); ecma_gc_mark_compiled_code (((cbc_uint8_arguments_t *) compiled_code_p)->script_value);
@@ -910,8 +902,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE: case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
{ {
JERRY_ASSERT (proto_cp == JMEM_CP_NULL); JERRY_ASSERT (proto_cp == JMEM_CP_NULL);
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ext_object_p->u.cls.u3.value));
ext_object_p->u.cls.u3.value));
ecma_gc_mark_properties (object_p, true); ecma_gc_mark_properties (object_p, true);
return; return;
} }
@@ -1114,8 +1105,8 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
case ECMA_OBJECT_TYPE_FUNCTION: case ECMA_OBJECT_TYPE_FUNCTION:
{ {
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ecma_gc_set_object_visited (
ext_func_p->u.function.scope_cp)); ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_func_p->u.function.scope_cp));
const ecma_compiled_code_t *compiled_code_p = ecma_op_function_get_compiled_code (ext_func_p); const ecma_compiled_code_t *compiled_code_p = ecma_op_function_get_compiled_code (ext_func_p);
@@ -1249,8 +1240,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION: case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
{ {
ecma_native_function_t *native_function_p = (ecma_native_function_t *) object_p; ecma_native_function_t *native_function_p = (ecma_native_function_t *) object_p;
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, native_function_p->realm_value));
native_function_p->realm_value));
break; break;
} }
#endif /* JERRY_BUILTIN_REALMS */ #endif /* JERRY_BUILTIN_REALMS */
@@ -1322,8 +1312,7 @@ ecma_gc_free_native_pointer (ecma_property_t property, /**< property descriptor
jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t)); jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t));
item_p = next_p; item_p = next_p;
} } while (item_p != NULL);
while (item_p != NULL);
} /* ecma_gc_free_native_pointer */ } /* ecma_gc_free_native_pointer */
/** /**
@@ -1347,8 +1336,8 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE)) if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE))
#endif /* JERRY_SNAPSHOT_EXEC */ #endif /* JERRY_SNAPSHOT_EXEC */
{ {
ecma_compiled_code_t *byte_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *byte_code_p =
mapped_arguments_p->u.byte_code); ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, mapped_arguments_p->u.byte_code);
ecma_bytecode_deref (byte_code_p); ecma_bytecode_deref (byte_code_p);
} }
@@ -1363,8 +1352,7 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
ecma_free_value_if_not_object (argv_p[i]); ecma_free_value_if_not_object (argv_p[i]);
} }
uint32_t saved_argument_count = JERRY_MAX (arguments_number, uint32_t saved_argument_count = JERRY_MAX (arguments_number, arguments_p->header.u.cls.u2.formal_params_number);
arguments_p->header.u.cls.u2.formal_params_number);
return object_size + (saved_argument_count * sizeof (ecma_value_t)); return object_size + (saved_argument_count * sizeof (ecma_value_t));
} /* ecma_free_arguments_object */ } /* ecma_free_arguments_object */
@@ -1485,8 +1473,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
do do
{ {
ecma_free_value_if_not_object (*(--context_top_p)); ecma_free_value_if_not_object (*(--context_top_p));
} } while (context_top_p > last_item_p);
while (context_top_p > last_item_p);
continue; continue;
} }
@@ -1506,8 +1493,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
} }
context_top_p = vm_stack_context_abort (&executable_object_p->frame_ctx, context_top_p); context_top_p = vm_stack_context_abort (&executable_object_p->frame_ctx, context_top_p);
} } while (context_top_p > context_end_p);
while (context_top_p > context_end_p);
} }
register_end_p = executable_object_p->frame_ctx.stack_top_p; register_end_p = executable_object_p->frame_ctx.stack_top_p;
@@ -1526,8 +1512,7 @@ JERRY_STATIC_ASSERT (!ECMA_PROPERTY_IS_RAW (ECMA_PROPERTY_TYPE_DELETED),
ecma_property_type_deleted_must_not_be_raw_property); ecma_property_type_deleted_must_not_be_raw_property);
JERRY_STATIC_ASSERT ((ECMA_PROPERTY_TYPE_DELETED & ECMA_PROPERTY_FLAG_LCACHED) == 0, JERRY_STATIC_ASSERT ((ECMA_PROPERTY_TYPE_DELETED & ECMA_PROPERTY_FLAG_LCACHED) == 0,
ecma_property_type_deleted_must_not_have_lcached_flag); ecma_property_type_deleted_must_not_have_lcached_flag);
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1, JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1, ecma_gc_free_second_must_be_one);
ecma_gc_free_second_must_be_one);
/** /**
* Free property of an object * Free property of an object
@@ -1575,8 +1560,8 @@ ecma_gc_free_property (ecma_object_t *object_p, /**< object */
#if JERRY_CPOINTER_32_BIT #if JERRY_CPOINTER_32_BIT
ecma_getter_setter_pointers_t *getter_setter_pair_p; ecma_getter_setter_pointers_t *getter_setter_pair_p;
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, getter_setter_pair_p =
prop_pair_p->values[index].getter_setter_pair_cp); ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_pair_p->values[index].getter_setter_pair_cp);
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t)); jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
#endif /* JERRY_CPOINTER_32_BIT */ #endif /* JERRY_CPOINTER_32_BIT */
return; return;
@@ -1655,8 +1640,7 @@ ecma_gc_free_properties (ecma_object_t *object_p, /**< object */
#if JERRY_PROPERTY_HASHMAP #if JERRY_PROPERTY_HASHMAP
if (prop_iter_cp != JMEM_CP_NULL) if (prop_iter_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
prop_iter_cp);
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP) if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{ {
ecma_property_hashmap_free (object_p); ecma_property_hashmap_free (object_p);
@@ -1791,8 +1775,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
case ECMA_OBJECT_CLASS_SCRIPT: case ECMA_OBJECT_CLASS_SCRIPT:
{ {
ecma_compiled_code_t *compiled_code_p; ecma_compiled_code_t *compiled_code_p;
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
ext_object_p->u.cls.u3.value);
ecma_bytecode_deref (compiled_code_p); ecma_bytecode_deref (compiled_code_p);
break; break;
@@ -1813,8 +1796,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
#if JERRY_BUILTIN_REGEXP #if JERRY_BUILTIN_REGEXP
case ECMA_OBJECT_CLASS_REGEXP: case ECMA_OBJECT_CLASS_REGEXP:
{ {
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *bytecode_p =
ext_object_p->u.cls.u3.value); ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
ecma_bytecode_deref (bytecode_p); ecma_bytecode_deref (bytecode_p);
@@ -1886,8 +1869,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
case ECMA_OBJECT_CLASS_CONTAINER: case ECMA_OBJECT_CLASS_CONTAINER:
{ {
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ecma_collection_t *container_p =
map_object_p->u.cls.u3.value); ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
ecma_op_container_free_entries (object_p); ecma_op_container_free_entries (object_p);
ecma_collection_destroy (container_p); ecma_collection_destroy (container_p);
break; break;
@@ -1978,8 +1961,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER) if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
{ {
#endif /* JERRY_SNAPSHOT_EXEC */ #endif /* JERRY_SNAPSHOT_EXEC */
ecma_compiled_code_t *byte_code_p = (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *byte_code_p =
ext_func_p->u.function.bytecode_cp)); (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_func_p->u.function.bytecode_cp));
#if JERRY_ESNEXT #if JERRY_ESNEXT
if (CBC_FUNCTION_IS_ARROW (byte_code_p->status_flags)) if (CBC_FUNCTION_IS_ARROW (byte_code_p->status_flags))
@@ -2227,8 +2210,7 @@ ecma_gc_run (void)
obj_iter_cp = obj_next_cp; obj_iter_cp = obj_next_cp;
} }
} } while (marked_anything_during_current_iteration);
while (marked_anything_during_current_iteration);
black_end_p->gc_next_cp = JMEM_CP_NULL; black_end_p->gc_next_cp = JMEM_CP_NULL;
JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp; JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp;
@@ -2320,8 +2302,7 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
if (!ecma_is_lexical_environment (obj_iter_p) if (!ecma_is_lexical_environment (obj_iter_p)
|| ecma_get_lex_env_type (obj_iter_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE) || ecma_get_lex_env_type (obj_iter_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
{ {
if (!ecma_is_lexical_environment (obj_iter_p) if (!ecma_is_lexical_environment (obj_iter_p) && ecma_op_object_is_fast_array (obj_iter_p))
&& ecma_op_object_is_fast_array (obj_iter_p))
{ {
obj_iter_cp = obj_iter_p->gc_next_cp; obj_iter_cp = obj_iter_p->gc_next_cp;
continue; continue;
@@ -2338,7 +2319,6 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
ecma_property_hashmap_free (obj_iter_p); ecma_property_hashmap_free (obj_iter_p);
} }
} }
} }
obj_iter_cp = obj_iter_p->gc_next_cp; obj_iter_cp = obj_iter_p->gc_next_cp;
+1
View File
@@ -17,6 +17,7 @@
#define ECMA_GC_H #define ECMA_GC_H
#include "ecma-globals.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
+61 -95
View File
@@ -17,10 +17,11 @@
#define ECMA_GLOBALS_H #define ECMA_GLOBALS_H
#include "ecma-errors.h" #include "ecma-errors.h"
#include "config.h" #include "config.h"
#include "jmem.h"
#include "jrt.h" #include "jrt.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
#include "jmem.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -37,7 +38,7 @@
*/ */
#define ECMA_NULL_POINTER JMEM_CP_NULL #define ECMA_NULL_POINTER JMEM_CP_NULL
#if defined (JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY) #if defined(JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
/** /**
* JMEM_ALIGNMENT_LOG aligned pointers can be stored directly in ecma_value_t * JMEM_ALIGNMENT_LOG aligned pointers can be stored directly in ecma_value_t
@@ -190,8 +191,7 @@ typedef int32_t ecma_integer_value_t;
/** /**
* ECMA make simple value * ECMA make simple value
*/ */
#define ECMA_MAKE_VALUE(value) \ #define ECMA_MAKE_VALUE(value) ((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
/** /**
* Simple ecma values * Simple ecma values
@@ -275,13 +275,12 @@ enum
#if ECMA_DIRECT_SHIFT != 4 #if ECMA_DIRECT_SHIFT != 4
#error "Please update ECMA_INTEGER_NUMBER_MIN/MAX_SHIFTED according to the new value of ECMA_DIRECT_SHIFT." #error "Please update ECMA_INTEGER_NUMBER_MIN/MAX_SHIFTED according to the new value of ECMA_DIRECT_SHIFT."
#endif #endif /* ECMA_DIRECT_SHIFT != 4 */
/** /**
* Checks whether the integer number is in the integer number range. * Checks whether the integer number is in the integer number range.
*/ */
#define ECMA_IS_INTEGER_NUMBER(num) \ #define ECMA_IS_INTEGER_NUMBER(num) (ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
(ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
/** /**
* Maximum integer number, which if squared, still fits in ecma_integer_value_t * Maximum integer number, which if squared, still fits in ecma_integer_value_t
@@ -295,8 +294,7 @@ enum
/** /**
* Checks whether the error flag is set. * Checks whether the error flag is set.
*/ */
#define ECMA_IS_VALUE_ERROR(value) \ #define ECMA_IS_VALUE_ERROR(value) (JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
(JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
/** /**
* Callback which tells whether the ECMAScript execution should be stopped. * Callback which tells whether the ECMAScript execution should be stopped.
@@ -422,32 +420,27 @@ typedef enum
/** /**
* Property flags configurable, enumerable. * Property flags configurable, enumerable.
*/ */
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE \ #define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
/** /**
* Property flags configurable, enumerable. * Property flags configurable, enumerable.
*/ */
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE \ #define ECMA_PROPERTY_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
/** /**
* Property flag built-in. * Property flag built-in.
*/ */
#define ECMA_PROPERTY_BUILT_IN_FIXED \ #define ECMA_PROPERTY_BUILT_IN_FIXED (ECMA_PROPERTY_FLAG_BUILT_IN)
(ECMA_PROPERTY_FLAG_BUILT_IN)
/** /**
* Property flags enumerable, writable. * Property flags enumerable, writable.
*/ */
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE \ #define ECMA_PROPERTY_ENUMERABLE_WRITABLE (ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
(ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
/** /**
* Property flags built-in, configurable. * Property flags built-in, configurable.
*/ */
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE \ #define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
/** /**
* Property flags built-in, configurable, enumerable. * Property flags built-in, configurable, enumerable.
@@ -458,14 +451,12 @@ typedef enum
/** /**
* Property flags built-in, configurable, writable. * Property flags built-in, configurable, writable.
*/ */
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE \ #define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/** /**
* Property flags built-in, writable. * Property flags built-in, writable.
*/ */
#define ECMA_PROPERTY_BUILT_IN_WRITABLE \ #define ECMA_PROPERTY_BUILT_IN_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
/** /**
* Property flags built-in, configurable, enumerable, writable. * Property flags built-in, configurable, enumerable, writable.
@@ -495,8 +486,7 @@ typedef enum
/** /**
* Type of hash-map property. * Type of hash-map property.
*/ */
#define ECMA_PROPERTY_TYPE_HASHMAP \ #define ECMA_PROPERTY_TYPE_HASHMAP (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
(ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
/** /**
* Type of deleted property. * Type of deleted property.
@@ -606,20 +596,17 @@ typedef struct
/** /**
* Get property name type. * Get property name type.
*/ */
#define ECMA_PROPERTY_GET_NAME_TYPE(property) \ #define ECMA_PROPERTY_GET_NAME_TYPE(property) ((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
/** /**
* Returns true if the property pointer is a property pair. * Returns true if the property pointer is a property pair.
*/ */
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) \ #define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) ((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
/** /**
* Property value of all internal properties * Property value of all internal properties
*/ */
#define ECMA_PROPERTY_INTERNAL \ #define ECMA_PROPERTY_INTERNAL (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
(ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
/** /**
* Checks whether a property is internal property * Checks whether a property is internal property
@@ -629,14 +616,13 @@ typedef struct
/** /**
* Checks whether a property is raw data or accessor property * Checks whether a property is raw data or accessor property
*/ */
#define ECMA_PROPERTY_IS_RAW(property) \ #define ECMA_PROPERTY_IS_RAW(property) ((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
/** /**
* Checks whether a property is raw data property (should only be used in assertions) * Checks whether a property is raw data property (should only be used in assertions)
*/ */
#define ECMA_PROPERTY_IS_RAW_DATA(property) \ #define ECMA_PROPERTY_IS_RAW_DATA(property) \
(((property) & ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL) (((property) &ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
/** /**
* Create internal property. * Create internal property.
@@ -646,8 +632,7 @@ typedef struct
{ \ { \
(property_value_p) = ecma_create_named_data_property ((object_p), (name_p), 0, &(property_p)); \ (property_value_p) = ecma_create_named_data_property ((object_p), (name_p), 0, &(property_p)); \
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \ JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
} \ } while (0)
while (0)
/** /**
* Property type of all virtual properties * Property type of all virtual properties
@@ -657,7 +642,7 @@ typedef struct
/** /**
* Checks whether a property is virtual property * Checks whether a property is virtual property
*/ */
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL(property) #define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL (property)
/** /**
* Returns true if the property is named property. * Returns true if the property is named property.
@@ -681,8 +666,7 @@ typedef struct
* Compute the property data pointer of a property. * Compute the property data pointer of a property.
* The property must be part of a property pair. * The property must be part of a property pair.
*/ */
#define ECMA_PROPERTY_VALUE_PTR(property_p) \ #define ECMA_PROPERTY_VALUE_PTR(property_p) ((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
/** /**
* Property reference. It contains the value pointer * Property reference. It contains the value pointer
@@ -768,7 +752,7 @@ typedef enum
ECMA_OBJECT_CLASS_MODULE_NAMESPACE, /**< Module Namespace (ECMAScript v11, 9.4.6) */ ECMA_OBJECT_CLASS_MODULE_NAMESPACE, /**< Module Namespace (ECMAScript v11, 9.4.6) */
#endif /* JERRY_MODULE_SYSTEM */ #endif /* JERRY_MODULE_SYSTEM */
/* These objects are marked by Garbage Collector. */ /* These objects are marked by Garbage Collector. */
#if JERRY_ESNEXT #if JERRY_ESNEXT
ECMA_OBJECT_CLASS_GENERATOR, /**< Generator object (ECMAScript v6, 25.2) */ ECMA_OBJECT_CLASS_GENERATOR, /**< Generator object (ECMAScript v6, 25.2) */
ECMA_OBJECT_CLASS_ASYNC_GENERATOR, /**< Async generator object (ECMAScript v11, 25.3) */ ECMA_OBJECT_CLASS_ASYNC_GENERATOR, /**< Async generator object (ECMAScript v11, 25.3) */
@@ -781,7 +765,7 @@ typedef enum
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
ECMA_OBJECT_CLASS_MODULE, /**< Module (ECMAScript v6, 15.2) */ ECMA_OBJECT_CLASS_MODULE, /**< Module (ECMAScript v6, 15.2) */
#endif #endif /* JERRY_MODULE_SYSTEM */
#if JERRY_ESNEXT #if JERRY_ESNEXT
ECMA_OBJECT_CLASS_PROMISE, /**< Promise (ECMAScript v6, 25.4) */ ECMA_OBJECT_CLASS_PROMISE, /**< Promise (ECMAScript v6, 25.4) */
ECMA_OBJECT_CLASS_PROMISE_CAPABILITY, /**< Promise capability (ECMAScript v6, 25.4.1.1) */ ECMA_OBJECT_CLASS_PROMISE_CAPABILITY, /**< Promise capability (ECMAScript v6, 25.4.1.1) */
@@ -1331,26 +1315,22 @@ typedef struct
/** /**
* Size of the internal buffer. * Size of the internal buffer.
*/ */
#define ECMA_CONTAINER_GET_SIZE(container_p) \ #define ECMA_CONTAINER_GET_SIZE(container_p) (container_p->buffer_p[0])
(container_p->buffer_p[0])
/** /**
* Remove the size field of the internal buffer. * Remove the size field of the internal buffer.
*/ */
#define ECMA_CONTAINER_SET_SIZE(container_p, size) \ #define ECMA_CONTAINER_SET_SIZE(container_p, size) (container_p->buffer_p[0] = (ecma_value_t) (size))
(container_p->buffer_p[0] = (ecma_value_t) (size))
/** /**
* Number of entries of the internal buffer. * Number of entries of the internal buffer.
*/ */
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) \ #define ECMA_CONTAINER_ENTRY_COUNT(collection_p) (collection_p->item_count - 1)
(collection_p->item_count - 1)
/** /**
* Pointer to the first entry of the internal buffer. * Pointer to the first entry of the internal buffer.
*/ */
#define ECMA_CONTAINER_START(collection_p) \ #define ECMA_CONTAINER_START(collection_p) (collection_p->buffer_p + 1)
(collection_p->buffer_p + 1)
#endif /* JERRY_BUILTIN_CONTAINER */ #endif /* JERRY_BUILTIN_CONTAINER */
@@ -1380,17 +1360,15 @@ typedef struct
* - is_value_defined : true * - is_value_defined : true
* - is_configurable_defined, is_writable_defined, is_enumerable_defined : true * - is_configurable_defined, is_writable_defined, is_enumerable_defined : true
*/ */
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS ((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED \ #define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS \
| JERRY_PROP_IS_CONFIGURABLE_DEFINED \ ((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE_DEFINED \
| JERRY_PROP_IS_ENUMERABLE_DEFINED \
| JERRY_PROP_IS_WRITABLE_DEFINED)) | JERRY_PROP_IS_WRITABLE_DEFINED))
/** /**
* Bitmask to get a the physical property flags from an ecma_property_descriptor * Bitmask to get a the physical property flags from an ecma_property_descriptor
*/ */
#define ECMA_PROPERTY_FLAGS_MASK ((uint16_t) (JERRY_PROP_IS_CONFIGURABLE \ #define ECMA_PROPERTY_FLAGS_MASK \
| JERRY_PROP_IS_ENUMERABLE \ ((uint16_t) (JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_ENUMERABLE | JERRY_PROP_IS_WRITABLE))
| JERRY_PROP_IS_WRITABLE))
#if !JERRY_NUMBER_TYPE_FLOAT64 #if !JERRY_NUMBER_TYPE_FLOAT64
/** /**
@@ -1515,68 +1493,68 @@ typedef union
* *
* See also: ECMA_262 v5, 15.7.3.3 * See also: ECMA_262 v5, 15.7.3.3
*/ */
# define ECMA_NUMBER_MIN_VALUE (FLT_MIN) #define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
/** /**
* Number.MAX_VALUE (i.e., the maximum value of ecma-number) * Number.MAX_VALUE (i.e., the maximum value of ecma-number)
* *
* See also: ECMA_262 v5, 15.7.3.2 * See also: ECMA_262 v5, 15.7.3.2
*/ */
# define ECMA_NUMBER_MAX_VALUE (FLT_MAX) #define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
/** /**
* Number.EPSILON * Number.EPSILON
* *
* See also: ECMA_262 v6, 20.1.2.1 * See also: ECMA_262 v6, 20.1.2.1
*/ */
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7) #define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
/** /**
* Number.MAX_SAFE_INTEGER * Number.MAX_SAFE_INTEGER
* *
* See also: ECMA_262 v6, 20.1.2.6 * See also: ECMA_262 v6, 20.1.2.6
*/ */
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF) #define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
/** /**
* Number.MIN_SAFE_INTEGER * Number.MIN_SAFE_INTEGER
* *
* See also: ECMA_262 v6, 20.1.2.8 * See also: ECMA_262 v6, 20.1.2.8
*/ */
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF) #define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
#elif JERRY_NUMBER_TYPE_FLOAT64 #elif JERRY_NUMBER_TYPE_FLOAT64
/** /**
* Number.MAX_VALUE (i.e., the maximum value of ecma-number) * Number.MAX_VALUE (i.e., the maximum value of ecma-number)
* *
* See also: ECMA_262 v5, 15.7.3.2 * See also: ECMA_262 v5, 15.7.3.2
*/ */
# define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308) #define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
/** /**
* Number.MIN_VALUE (i.e., the smallest positive value of ecma-number) * Number.MIN_VALUE (i.e., the smallest positive value of ecma-number)
* *
* See also: ECMA_262 v5, 15.7.3.3 * See also: ECMA_262 v5, 15.7.3.3
*/ */
# define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324) #define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
/** /**
* Number.EPSILON * Number.EPSILON
* *
* See also: ECMA_262 v6, 20.1.2.1 * See also: ECMA_262 v6, 20.1.2.1
*/ */
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16) #define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
/** /**
* Number.MAX_SAFE_INTEGER * Number.MAX_SAFE_INTEGER
* *
* See also: ECMA_262 v6, 20.1.2.6 * See also: ECMA_262 v6, 20.1.2.6
*/ */
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF) #define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
/** /**
* Number.MIN_SAFE_INTEGER * Number.MIN_SAFE_INTEGER
* *
* See also: ECMA_262 v6, 20.1.2.8 * See also: ECMA_262 v6, 20.1.2.8
*/ */
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF) #define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */ #endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
/** /**
@@ -1657,8 +1635,7 @@ typedef struct
/** /**
* Compute the total allocated size of the collection based on it's capacity * Compute the total allocated size of the collection based on it's capacity
*/ */
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) \ #define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) (uint32_t) (capacity * sizeof (ecma_value_t))
(uint32_t) (capacity * sizeof (ecma_value_t))
/** /**
* Initial allocated size of an ecma-collection * Initial allocated size of an ecma-collection
@@ -1724,8 +1701,7 @@ typedef enum
/** /**
* Checks whether the string is direct. * Checks whether the string is direct.
*/ */
#define ECMA_IS_DIRECT_STRING(string_p) \ #define ECMA_IS_DIRECT_STRING(string_p) ((((uintptr_t) (string_p)) & 0x1) != 0)
((((uintptr_t) (string_p)) & 0x1) != 0)
/** /**
* Checks whether the string is direct. * Checks whether the string is direct.
@@ -1736,8 +1712,7 @@ typedef enum
/** /**
* Returns the type of a direct string. * Returns the type of a direct string.
*/ */
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) \ #define ECMA_GET_DIRECT_STRING_TYPE(string_p) ((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
/** /**
* Shift applied to type conversions. * Shift applied to type conversions.
@@ -1753,8 +1728,7 @@ typedef enum
/** /**
* Returns the value of a direct string. * Returns the value of a direct string.
*/ */
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) \ #define ECMA_GET_DIRECT_STRING_VALUE(string_p) (((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
(((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
/** /**
* Maximum number of bytes that a long-utf8-string is able to store * Maximum number of bytes that a long-utf8-string is able to store
@@ -1799,14 +1773,12 @@ typedef enum
/** /**
* Set an ecma-string as static string * Set an ecma-string as static string
*/ */
#define ECMA_SET_STRING_AS_STATIC(string_p) \ #define ECMA_SET_STRING_AS_STATIC(string_p) (string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
(string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
/** /**
* Checks whether the ecma-string is static string * Checks whether the ecma-string is static string
*/ */
#define ECMA_STRING_IS_STATIC(string_p) \ #define ECMA_STRING_IS_STATIC(string_p) ((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
/** /**
* Returns with the container type of a string. * Returns with the container type of a string.
@@ -1817,8 +1789,7 @@ typedef enum
/** /**
* Checks whether the reference counter is 1 of a string. * Checks whether the reference counter is 1 of a string.
*/ */
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) \ #define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) (((string_desc_p)->refs_and_container >> 4) == 1)
(((string_desc_p)->refs_and_container >> 4) == 1)
/** /**
* Checks whether the reference counter is 1 of an extended primitive. * Checks whether the reference counter is 1 of an extended primitive.
@@ -1878,38 +1849,34 @@ typedef struct
/** /**
* Header size of an ecma ASCII string * Header size of an ecma ASCII string
*/ */
#define ECMA_ASCII_STRING_HEADER_SIZE \ #define ECMA_ASCII_STRING_HEADER_SIZE ((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
/** /**
* Get the size of an ecma ASCII string * Get the size of an ecma ASCII string
*/ */
#define ECMA_ASCII_STRING_GET_SIZE(string_p) \ #define ECMA_ASCII_STRING_GET_SIZE(string_p) \
((lit_utf8_size_t) *((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1) ((lit_utf8_size_t) * ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
/** /**
* Set the size of an ecma ASCII string * Set the size of an ecma ASCII string
*/ */
#define ECMA_ASCII_STRING_SET_SIZE(string_p, size) \ #define ECMA_ASCII_STRING_SET_SIZE(string_p, size) \
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) - 1)) (*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) -1))
/** /**
* Get the start position of the string buffer of an ecma ASCII string * Get the start position of the string buffer of an ecma ASCII string
*/ */
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) \ #define ECMA_ASCII_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
/** /**
* Get the start position of the string buffer of an ecma UTF8 string * Get the start position of the string buffer of an ecma UTF8 string
*/ */
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) \ #define ECMA_SHORT_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
/** /**
* Get the start position of the string buffer of an ecma long CESU8 string * Get the start position of the string buffer of an ecma long CESU8 string
*/ */
#define ECMA_LONG_STRING_BUFFER_START(string_p) \ #define ECMA_LONG_STRING_BUFFER_START(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
/** /**
* ECMA extended string-value descriptor * ECMA extended string-value descriptor
@@ -2145,8 +2112,7 @@ typedef struct
/** /**
* Checks whether a given typedarray is BigInt type or not. * Checks whether a given typedarray is BigInt type or not.
**/ **/
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) \ #define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) ((id) >= ECMA_BIGINT64_ARRAY)
((id) >= ECMA_BIGINT64_ARRAY)
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
#endif /* JERRY_BUILTIN_TYPEDARRAY */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
@@ -2307,20 +2273,20 @@ typedef struct
* The macro argument specifies the return value which is usally ECMA_VALUE_ERROR or NULL. * The macro argument specifies the return value which is usally ECMA_VALUE_ERROR or NULL.
*/ */
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \ #define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
do \ do \
{ \ { \
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \ if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
{ \ { \
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \ ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
return RETURN_VALUE; \ return RETURN_VALUE; \
} \ } \
} while (0) } while (0)
/** /**
* Specialized version of ECMA_CHECK_STACK_USAGE_RETURN which returns ECMA_VALUE_ERROR. * Specialized version of ECMA_CHECK_STACK_USAGE_RETURN which returns ECMA_VALUE_ERROR.
* This version should be used in most cases. * This version should be used in most cases.
*/ */
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN(ECMA_VALUE_ERROR) #define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN (ECMA_VALUE_ERROR)
#else /* JERRY_STACK_LIMIT == 0) */ #else /* JERRY_STACK_LIMIT == 0) */
/** /**
* If the stack limit is unlimited, this check is an empty macro. * If the stack limit is unlimited, this check is an empty macro.
@@ -18,6 +18,7 @@
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h" #include "jrt.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
+41 -58
View File
@@ -17,6 +17,7 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
@@ -55,8 +56,7 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
uint64_t masked_lo = num_p->lo & ~(1ULL << 63u); uint64_t masked_lo = num_p->lo & ~(1ULL << 63u);
uint64_t masked_hi = num_p->hi & 0x1; uint64_t masked_hi = num_p->hi & 0x1;
if ((num_p->lo >> 63u != 0) if ((num_p->lo >> 63u != 0) && (masked_lo > 0 || masked_hi != 0))
&& (masked_lo > 0 || masked_hi != 0))
{ {
return (num_p->hi + 1); return (num_p->hi + 1);
} }
@@ -66,53 +66,52 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
/** /**
* Check if 128-bit integer is zero * Check if 128-bit integer is zero
*/ */
#define ECMA_UINT128_IS_ZERO(name) \ #define ECMA_UINT128_IS_ZERO(name) (name.hi == 0 && name.lo == 0)
(name.hi == 0 && name.lo == 0)
/** /**
* Left shift 128-bit integer by max 63 bits * Left shift 128-bit integer by max 63 bits
*/ */
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \ #define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
{ \ { \
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \ name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
name.lo <<= (shift); \ name.lo <<= (shift); \
} }
/** /**
* Right shift 128-bit integer by max 63 bits * Right shift 128-bit integer by max 63 bits
*/ */
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \ #define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
{ \ { \
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \ name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
name.hi >>= (shift); \ name.hi >>= (shift); \
} }
/** /**
* Add 128-bit integer * Add 128-bit integer
*/ */
#define ECMA_UINT128_ADD(name_add_to, name_to_add) \ #define ECMA_UINT128_ADD(name_add_to, name_to_add) \
{ \ { \
name_add_to.hi += name_to_add.hi; \ name_add_to.hi += name_to_add.hi; \
name_add_to.lo += name_to_add.lo; \ name_add_to.lo += name_to_add.lo; \
if (name_add_to.lo < name_to_add.lo) \ if (name_add_to.lo < name_to_add.lo) \
{ \ { \
name_add_to.hi++; \ name_add_to.hi++; \
} \ } \
} }
/** /**
* Multiply 128-bit integer by 10 * Multiply 128-bit integer by 10
*/ */
#define ECMA_UINT128_MUL10(name) \ #define ECMA_UINT128_MUL10(name) \
{ \ { \
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \ ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
\ \
ecma_uint128_t name ## _tmp = name; \ ecma_uint128_t name##_tmp = name; \
\ \
ECMA_UINT128_LEFT_SHIFT_MAX63 (name ## _tmp, 2u); \ ECMA_UINT128_LEFT_SHIFT_MAX63 (name##_tmp, 2u); \
\ \
ECMA_UINT128_ADD (name, name ## _tmp); \ ECMA_UINT128_ADD (name, name##_tmp); \
} }
/** /**
* Divide 128-bit integer by 10 * Divide 128-bit integer by 10
@@ -130,7 +129,7 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
* Q = Q3 *2^96 + Q2 *2^64 + Q1 *2^32 + Q0 *2^0 // 128-bit quotient * Q = Q3 *2^96 + Q2 *2^64 + Q1 *2^32 + Q0 *2^0 // 128-bit quotient
*/ */
#define ECMA_UINT128_DIV10(name) \ #define ECMA_UINT128_DIV10(name) \
{ \ { \
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \ /* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
const uint64_t tenth_l = 0x9999999aul; \ const uint64_t tenth_l = 0x9999999aul; \
const uint64_t tenth_m = 0x99999999ul; \ const uint64_t tenth_m = 0x99999999ul; \
@@ -169,7 +168,7 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
q0 += (uint32_t) m1; \ q0 += (uint32_t) m1; \
q0 += (uint32_t) h0; \ q0 += (uint32_t) h0; \
\ \
q0 >>=32u; \ q0 >>= 32u; \
q0 += l3 >> 32u; \ q0 += l3 >> 32u; \
q0 += m2 >> 32u; \ q0 += m2 >> 32u; \
q0 += m1 >> 32u; \ q0 += m1 >> 32u; \
@@ -192,21 +191,19 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
\ \
name.lo = (q1 << 32u) | ((uint32_t) q0); \ name.lo = (q1 << 32u) | ((uint32_t) q0); \
name.hi = q32; \ name.hi = q32; \
} }
#if defined (__GNUC__) || defined (__clang__) #if defined(__GNUC__) || defined(__clang__)
/** /**
* Count leading zeros in the topmost 64 bits of a 128-bit integer. * Count leading zeros in the topmost 64 bits of a 128-bit integer.
*/ */
#define ECMA_UINT128_CLZ_MAX63(name) \ #define ECMA_UINT128_CLZ_MAX63(name) __builtin_clzll (name.hi)
__builtin_clzll (name.hi)
/** /**
* Count leading zeros in the topmost 4 bits of a 128-bit integer. * Count leading zeros in the topmost 4 bits of a 128-bit integer.
*/ */
#define ECMA_UINT128_CLZ_MAX4(name) \ #define ECMA_UINT128_CLZ_MAX4(name) __builtin_clzll (name.hi)
__builtin_clzll (name.hi)
#else /* !__GNUC__ && !__clang__ */ #else /* !__GNUC__ && !__clang__ */
@@ -238,14 +235,12 @@ static const uint8_t ecma_uint4_clz[] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0,
/** /**
* Count leading zeros in the topmost 64 bits of a 128-bit integer. * Count leading zeros in the topmost 64 bits of a 128-bit integer.
*/ */
#define ECMA_UINT128_CLZ_MAX63(name) \ #define ECMA_UINT128_CLZ_MAX63(name) ecma_uint64_clz (name.hi)
ecma_uint64_clz (name.hi)
/** /**
* Count leading zeros in the topmost 4 bits of a 128-bit integer. * Count leading zeros in the topmost 4 bits of a 128-bit integer.
*/ */
#define ECMA_UINT128_CLZ_MAX4(name) \ #define ECMA_UINT128_CLZ_MAX4(name) ecma_uint4_clz[name.hi >> 60]
ecma_uint4_clz[name.hi >> 60]
#endif /* __GNUC__ || __clang__ */ #endif /* __GNUC__ || __clang__ */
@@ -308,7 +303,7 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
{ {
lit_code_point_t upper_limit = LIT_CHAR_0 + radix; lit_code_point_t upper_limit = LIT_CHAR_0 + radix;
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++) for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
{ {
int32_t digit_value; int32_t digit_value;
@@ -328,22 +323,19 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
} }
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++) for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
{ {
int32_t digit_value; int32_t digit_value;
if (*iter_p >= LIT_CHAR_0 if (*iter_p >= LIT_CHAR_0 && *iter_p <= LIT_CHAR_9)
&& *iter_p <= LIT_CHAR_9)
{ {
digit_value = (*iter_p - LIT_CHAR_0); digit_value = (*iter_p - LIT_CHAR_0);
} }
else if (*iter_p >= LIT_CHAR_LOWERCASE_A else if (*iter_p >= LIT_CHAR_LOWERCASE_A && *iter_p <= LIT_CHAR_LOWERCASE_F)
&& *iter_p <= LIT_CHAR_LOWERCASE_F)
{ {
digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A); digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A);
} }
else if (*iter_p >= LIT_CHAR_UPPERCASE_A else if (*iter_p >= LIT_CHAR_UPPERCASE_A && *iter_p <= LIT_CHAR_UPPERCASE_F)
&& *iter_p <= LIT_CHAR_UPPERCASE_F)
{ {
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A); digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
} }
@@ -393,20 +385,19 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
return ECMA_NUMBER_ZERO; return ECMA_NUMBER_ZERO;
} }
if (end_p >= str_p + 2 if (end_p >= str_p + 2 && str_p[0] == LIT_CHAR_0)
&& str_p[0] == LIT_CHAR_0)
{ {
switch (LEXER_TO_ASCII_LOWERCASE (str_p[1])) switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
{ {
case LIT_CHAR_LOWERCASE_X : case LIT_CHAR_LOWERCASE_X:
{ {
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options); return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
} }
case LIT_CHAR_LOWERCASE_O : case LIT_CHAR_LOWERCASE_O:
{ {
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options); return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
} }
case LIT_CHAR_LOWERCASE_B : case LIT_CHAR_LOWERCASE_B:
{ {
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options); return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
} }
@@ -455,8 +446,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
{ {
int32_t digit_value; int32_t digit_value;
if (*str_p >= LIT_CHAR_0 if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
&& *str_p <= LIT_CHAR_9)
{ {
digit_seen = true; digit_seen = true;
digit_value = (*str_p - LIT_CHAR_0); digit_value = (*str_p - LIT_CHAR_0);
@@ -489,8 +479,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
str_p++; str_p++;
} }
if (str_p <= end_p if (str_p <= end_p && *str_p == LIT_CHAR_DOT)
&& *str_p == LIT_CHAR_DOT)
{ {
str_p++; str_p++;
@@ -504,8 +493,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
{ {
int32_t digit_value; int32_t digit_value;
if (*str_p >= LIT_CHAR_0 if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
&& *str_p <= LIT_CHAR_9)
{ {
digit_seen = true; digit_seen = true;
digit_value = (*str_p - LIT_CHAR_0); digit_value = (*str_p - LIT_CHAR_0);
@@ -539,9 +527,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
int32_t e_in_lit = 0; int32_t e_in_lit = 0;
bool e_in_lit_sign = false; bool e_in_lit_sign = false;
if (str_p <= end_p if (str_p <= end_p && (*str_p == LIT_CHAR_LOWERCASE_E || *str_p == LIT_CHAR_UPPERCASE_E))
&& (*str_p == LIT_CHAR_LOWERCASE_E
|| *str_p == LIT_CHAR_UPPERCASE_E))
{ {
str_p++; str_p++;
@@ -569,8 +555,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
{ {
int32_t digit_value; int32_t digit_value;
if (*str_p >= LIT_CHAR_0 if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
&& *str_p <= LIT_CHAR_9)
{ {
digit_value = (*str_p - LIT_CHAR_0); digit_value = (*str_p - LIT_CHAR_0);
} }
@@ -764,8 +749,7 @@ ecma_uint32_to_utf8_string (uint32_t value, /**< value to convert */
buf_p--; buf_p--;
*buf_p = (lit_utf8_byte_t) ((value % 10) + LIT_CHAR_0); *buf_p = (lit_utf8_byte_t) ((value % 10) + LIT_CHAR_0);
value /= 10; value /= 10;
} } while (value != 0);
while (value != 0);
JERRY_ASSERT (buf_p >= out_buffer_p); JERRY_ASSERT (buf_p >= out_buffer_p);
@@ -807,8 +791,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
if (abs_num >= num_2_pow_32) if (abs_num >= num_2_pow_32)
{ {
num_in_uint32_range = ecma_number_calc_remainder (abs_num, num_in_uint32_range = ecma_number_calc_remainder (abs_num, num_2_pow_32);
num_2_pow_32);
} }
else else
{ {
@@ -822,8 +805,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
const uint32_t ret = sign ? -uint32_num : uint32_num; const uint32_t ret = sign ? -uint32_num : uint32_num;
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
if (sign if (sign && uint32_num != 0)
&& uint32_num != 0)
{ {
JERRY_ASSERT (ret == uint64_2_pow_32 - uint32_num); JERRY_ASSERT (ret == uint64_2_pow_32 - uint32_num);
} }
@@ -951,7 +933,8 @@ ecma_number_to_utf8_string (ecma_number_t num, /**< ecma-number */
if (ecma_number_is_infinity (num)) if (ecma_number_is_infinity (num))
{ {
/* 4. */ /* 4. */
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL, dst_p, dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL,
dst_p,
(lit_utf8_size_t) (buffer_p + buffer_size - dst_p)); (lit_utf8_size_t) (buffer_p + buffer_size - dst_p));
JERRY_ASSERT (dst_p <= buffer_p + buffer_size); JERRY_ASSERT (dst_p <= buffer_p + buffer_size);
return (lit_utf8_size_t) (dst_p - buffer_p); return (lit_utf8_size_t) (dst_p - buffer_p);
@@ -16,9 +16,9 @@
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects-general.h"
#include "ecma-objects.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -185,8 +185,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)) if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
{ {
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
value_p->value);
if (native_pointer_p->native_info_p == native_info_p) if (native_pointer_p->native_info_p == native_info_p)
{ {
@@ -215,8 +214,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
} }
item_p = item_p->next_p; item_p = item_p->next_p;
} } while (item_p != NULL);
while (item_p != NULL);
return NULL; return NULL;
} /* ecma_get_native_pointer_value */ } /* ecma_get_native_pointer_value */
@@ -259,8 +257,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)) if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
{ {
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
value_p->value);
if (native_pointer_p->native_info_p != native_info_p) if (native_pointer_p->native_info_p != native_info_p)
{ {
@@ -326,8 +323,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
prev_p = item_p; prev_p = item_p;
item_p = item_p->next_p; item_p = item_p->next_p;
} } while (item_p != NULL);
while (item_p != NULL);
return false; return false;
} /* ecma_delete_native_pointer_property */ } /* ecma_delete_native_pointer_property */
+31 -57
View File
@@ -16,6 +16,7 @@
#include <math.h> #include <math.h>
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -28,20 +29,17 @@
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_integer_value_t), JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_integer_value_t),
size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_integer_value_t); size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_integer_value_t);
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1, JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1, currently_directly_encoded_values_has_one_extra_flag);
currently_directly_encoded_values_has_one_extra_flag);
JERRY_STATIC_ASSERT (((1 << (ECMA_DIRECT_SHIFT - 1)) | ECMA_TYPE_DIRECT) == ECMA_DIRECT_TYPE_SIMPLE_VALUE, JERRY_STATIC_ASSERT (((1 << (ECMA_DIRECT_SHIFT - 1)) | ECMA_TYPE_DIRECT) == ECMA_DIRECT_TYPE_SIMPLE_VALUE,
currently_directly_encoded_values_start_after_direct_type_simple_value); currently_directly_encoded_values_start_after_direct_type_simple_value);
/** /**
* Position of the sign bit in ecma-numbers * Position of the sign bit in ecma-numbers
*/ */
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + \ #define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + ECMA_NUMBER_BIASED_EXP_WIDTH)
ECMA_NUMBER_BIASED_EXP_WIDTH)
#if !JERRY_NUMBER_TYPE_FLOAT64 #if !JERRY_NUMBER_TYPE_FLOAT64
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t), JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t), size_of_ecma_number_t_must_be_equal_to_4_bytes);
size_of_ecma_number_t_must_be_equal_to_4_bytes);
/** /**
* Packing sign, fraction and biased exponent to ecma-number * Packing sign, fraction and biased exponent to ecma-number
@@ -56,9 +54,8 @@ ecma_number_pack (bool sign, /**< sign */
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0); JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0); JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
uint32_t packed_value = (((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) | uint32_t packed_value =
(biased_exp << ECMA_NUMBER_FRACTION_WIDTH) | (((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) | (biased_exp << ECMA_NUMBER_FRACTION_WIDTH) | ((uint32_t) fraction));
((uint32_t) fraction));
ecma_number_accessor_t u; ecma_number_accessor_t u;
u.as_uint32_t = packed_value; u.as_uint32_t = packed_value;
@@ -103,8 +100,7 @@ ecma_number_unpack (ecma_number_t num, /**< ecma-number */
const int32_t ecma_number_exponent_bias = 127; const int32_t ecma_number_exponent_bias = 127;
#elif JERRY_NUMBER_TYPE_FLOAT64 #elif JERRY_NUMBER_TYPE_FLOAT64
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t), JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t), size_of_ecma_number_t_must_be_equal_to_8_bytes);
size_of_ecma_number_t_must_be_equal_to_8_bytes);
/** /**
* Packing sign, fraction and biased exponent to ecma-number * Packing sign, fraction and biased exponent to ecma-number
@@ -116,9 +112,8 @@ ecma_number_pack (bool sign, /**< sign */
uint32_t biased_exp, /**< biased exponent */ uint32_t biased_exp, /**< biased exponent */
uint64_t fraction) /**< fraction */ uint64_t fraction) /**< fraction */
{ {
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS) | uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS)
(((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) | | (((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) | fraction);
fraction);
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0); JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0); JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
@@ -229,8 +224,7 @@ ecma_number_is_nan (ecma_number_t num) /**< ecma-number */
uint64_t fraction = ecma_number_get_fraction_field (num); uint64_t fraction = ecma_number_get_fraction_field (num);
/* IEEE-754 2008, 3.4, a */ /* IEEE-754 2008, 3.4, a */
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction != 0));
&& (fraction != 0));
JERRY_ASSERT (is_nan == is_nan_ieee754); JERRY_ASSERT (is_nan == is_nan_ieee754);
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
@@ -304,8 +298,8 @@ ecma_number_is_zero (ecma_number_t num) /**< ecma-number */
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
/* IEEE-754 2008, 3.4, e */ /* IEEE-754 2008, 3.4, e */
bool is_zero_ieee754 = (ecma_number_get_fraction_field (num) == 0 bool is_zero_ieee754 =
&& ecma_number_get_biased_exponent_field (num) == 0); (ecma_number_get_fraction_field (num) == 0 && ecma_number_get_biased_exponent_field (num) == 0);
JERRY_ASSERT (is_zero == is_zero_ieee754); JERRY_ASSERT (is_zero == is_zero_ieee754);
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
@@ -327,8 +321,7 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
uint64_t fraction = ecma_number_get_fraction_field (num); uint64_t fraction = ecma_number_get_fraction_field (num);
/* IEEE-754 2008, 3.4, b */ /* IEEE-754 2008, 3.4, b */
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction == 0));
&& (fraction == 0));
} /* ecma_number_is_infinity */ } /* ecma_number_is_infinity */
/** /**
@@ -340,11 +333,11 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
extern inline bool JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_number_is_finite (ecma_number_t num) /**< ecma-number */ ecma_number_is_finite (ecma_number_t num) /**< ecma-number */
{ {
#if defined (__GNUC__) || defined (__clang__) #if defined(__GNUC__) || defined(__clang__)
return __builtin_isfinite (num); return __builtin_isfinite (num);
#elif defined (_WIN32) #elif defined(_WIN32)
return isfinite (num); return isfinite (num);
#else #else /* !(defined(__GNUC__) || defined(__clang__) || defined(_WIN32)) */
return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num); return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num);
#endif /* defined (__GNUC__) || defined (__clang__) */ #endif /* defined (__GNUC__) || defined (__clang__) */
} /* ecma_number_is_finite */ } /* ecma_number_is_finite */
@@ -422,9 +415,7 @@ ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t fraction,
JERRY_ASSERT ((fraction & ~((1ull << (ECMA_NUMBER_FRACTION_WIDTH + 1)) - 1)) == 0); JERRY_ASSERT ((fraction & ~((1ull << (ECMA_NUMBER_FRACTION_WIDTH + 1)) - 1)) == 0);
JERRY_ASSERT ((fraction & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) != 0); JERRY_ASSERT ((fraction & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) != 0);
return ecma_number_pack (false, return ecma_number_pack (false, biased_exp, fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
biased_exp,
fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
} /* ecma_number_make_normal_positive_from_fraction_and_exponent */ } /* ecma_number_make_normal_positive_from_fraction_and_exponent */
/** /**
@@ -463,8 +454,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
} }
/* Normalizing mantissa */ /* Normalizing mantissa */
while (mantissa != 0 while (mantissa != 0 && ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
&& ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
{ {
exponent--; exponent--;
mantissa <<= 1; mantissa <<= 1;
@@ -507,9 +497,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
JERRY_ASSERT (biased_exp < (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1); JERRY_ASSERT (biased_exp < (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1);
JERRY_ASSERT ((mantissa & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0); JERRY_ASSERT ((mantissa & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
return ecma_number_pack (sign, return ecma_number_pack (sign, biased_exp, mantissa);
biased_exp,
mantissa);
} /* ecma_number_make_from_sign_mantissa_and_exponent */ } /* ecma_number_make_from_sign_mantissa_and_exponent */
/** /**
@@ -542,9 +530,7 @@ ecma_number_get_prev (ecma_number_t num) /**< ecma-number */
fraction--; fraction--;
} }
return ecma_number_pack (false, return ecma_number_pack (false, biased_exp, fraction);
biased_exp,
fraction);
} /* ecma_number_get_prev */ } /* ecma_number_get_prev */
/** /**
@@ -581,9 +567,7 @@ ecma_number_get_next (ecma_number_t num) /**< ecma-number */
fraction &= ~(1ull << ECMA_NUMBER_FRACTION_WIDTH); fraction &= ~(1ull << ECMA_NUMBER_FRACTION_WIDTH);
return ecma_number_pack (false, return ecma_number_pack (false, biased_exp, fraction);
biased_exp,
fraction);
} /* ecma_number_get_next */ } /* ecma_number_get_next */
/** /**
@@ -609,8 +593,7 @@ ecma_number_trunc (ecma_number_t num) /**< ecma-number */
{ {
fraction &= ~((1ull << (dot_shift - exponent)) - 1); fraction &= ~((1ull << (dot_shift - exponent)) - 1);
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction, ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction, exponent);
exponent);
if (sign) if (sign)
{ {
return -tmp; return -tmp;
@@ -639,18 +622,15 @@ ecma_number_t
ecma_number_calc_remainder (ecma_number_t left_num, /**< left operand */ ecma_number_calc_remainder (ecma_number_t left_num, /**< left operand */
ecma_number_t right_num) /**< right operand */ ecma_number_t right_num) /**< right operand */
{ {
JERRY_ASSERT (!ecma_number_is_nan (left_num) JERRY_ASSERT (!ecma_number_is_nan (left_num) && !ecma_number_is_zero (left_num)
&& !ecma_number_is_zero (left_num)
&& !ecma_number_is_infinity (left_num)); && !ecma_number_is_infinity (left_num));
JERRY_ASSERT (!ecma_number_is_nan (right_num) JERRY_ASSERT (!ecma_number_is_nan (right_num) && !ecma_number_is_zero (right_num)
&& !ecma_number_is_zero (right_num)
&& !ecma_number_is_infinity (right_num)); && !ecma_number_is_infinity (right_num));
const ecma_number_t q = ecma_number_trunc (left_num / right_num); const ecma_number_t q = ecma_number_trunc (left_num / right_num);
ecma_number_t r = left_num - right_num * q; ecma_number_t r = left_num - right_num * q;
if (ecma_number_is_zero (r) if (ecma_number_is_zero (r) && ecma_number_is_negative (left_num))
&& ecma_number_is_negative (left_num))
{ {
r = -r; r = -r;
} }
@@ -667,8 +647,7 @@ ecma_number_t
ecma_number_pow (ecma_number_t x, /**< left operand */ ecma_number_pow (ecma_number_t x, /**< left operand */
ecma_number_t y) /**< right operand */ ecma_number_t y) /**< right operand */
{ {
if (ecma_number_is_nan (y) || if (ecma_number_is_nan (y) || (ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
(ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
{ {
/* Handle differences between ES5.1 and ISO C standards for pow. */ /* Handle differences between ES5.1 and ISO C standards for pow. */
return ecma_number_make_nan (); return ecma_number_make_nan ();
@@ -692,7 +671,7 @@ extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */ ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
ecma_integer_value_t right_integer) /**< right operand */ ecma_integer_value_t right_integer) /**< right operand */
{ {
#if defined (__GNUC__) || defined (__clang__) #if defined(__GNUC__) || defined(__clang__)
/* Check if left_integer is power of 2 */ /* Check if left_integer is power of 2 */
if (JERRY_UNLIKELY ((left_integer & (left_integer - 1)) == 0)) if (JERRY_UNLIKELY ((left_integer & (left_integer - 1)) == 0))
{ {
@@ -796,9 +775,7 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
} }
/* 10. */ /* 10. */
if (strip_prefix if (strip_prefix && ((end_p - start_p) >= 2) && (current == LIT_CHAR_0))
&& ((end_p - start_p) >= 2)
&& (current == LIT_CHAR_0))
{ {
ecma_char_t next = *string_curr_p; ecma_char_t next = *string_curr_p;
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X) if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
@@ -937,8 +914,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
/* The input string should be at least the length of "Infinity" to be correctly processed as /* The input string should be at least the length of "Infinity" to be correctly processed as
* the infinity value. * the infinity value.
*/ */
if ((str_end_p - str_curr_p) >= (int) infinity_length if ((str_end_p - str_curr_p) >= (int) infinity_length && memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
&& memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
{ {
/* String matched Infinity. */ /* String matched Infinity. */
return ecma_make_number_value (ecma_number_make_infinity (sign)); return ecma_make_number_value (ecma_number_make_infinity (sign));
@@ -1021,15 +997,13 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
} }
/* Check exponent. */ /* Check exponent. */
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E) if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E) && (has_whole_part || has_fraction_part)
&& (has_whole_part || has_fraction_part)
&& str_curr_p < str_end_p) && str_curr_p < str_end_p)
{ {
current = *str_curr_p++; current = *str_curr_p++;
/* Check sign of exponent. */ /* Check sign of exponent. */
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS) if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS) && str_curr_p < str_end_p)
&& str_curr_p < str_end_p)
{ {
current = *str_curr_p++; current = *str_curr_p++;
} }
+50 -92
View File
@@ -19,9 +19,10 @@
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "jrt.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
@@ -41,8 +42,7 @@ JERRY_STATIC_ASSERT ((ECMA_STRING_MAX_REF | ECMA_STRING_CONTAINER_MASK | ECMA_ST
JERRY_STATIC_ASSERT (ECMA_STRING_NOT_ARRAY_INDEX == UINT32_MAX, JERRY_STATIC_ASSERT (ECMA_STRING_NOT_ARRAY_INDEX == UINT32_MAX,
ecma_string_not_array_index_must_be_equal_to_uint32_max); ecma_string_not_array_index_must_be_equal_to_uint32_max);
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0, JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0, ecma_type_direct_string_must_be_odd_number);
ecma_type_direct_string_must_be_odd_number);
JERRY_STATIC_ASSERT (LIT_MAGIC_STRING__COUNT <= ECMA_DIRECT_STRING_MAX_IMM, JERRY_STATIC_ASSERT (LIT_MAGIC_STRING__COUNT <= ECMA_DIRECT_STRING_MAX_IMM,
all_magic_strings_must_be_encoded_as_direct_string); all_magic_strings_must_be_encoded_as_direct_string);
@@ -96,8 +96,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
} }
index = (index * 10) + (uint32_t) (*string_p++ - LIT_CHAR_0); index = (index * 10) + (uint32_t) (*string_p++ - LIT_CHAR_0);
} } while (string_p < string_end_p);
while (string_p < string_end_p);
if (string_size < ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32) if (string_size < ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32)
{ {
@@ -107,9 +106,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
/* Overflow must be checked as well when size is /* Overflow must be checked as well when size is
* equal to ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32. */ * equal to ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32. */
if (*string_p > LIT_CHAR_9 if (*string_p > LIT_CHAR_9 || *string_p < LIT_CHAR_0 || index > (UINT32_MAX / 10)
|| *string_p < LIT_CHAR_0
|| index > (UINT32_MAX / 10)
|| (index == (UINT32_MAX / 10) && *string_p > LIT_CHAR_5)) || (index == (UINT32_MAX / 10) && *string_p > LIT_CHAR_5))
{ {
return false; return false;
@@ -241,8 +238,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
{ {
JERRY_ASSERT (string_p != NULL); JERRY_ASSERT (string_p != NULL);
return (!ECMA_IS_DIRECT_STRING (string_p) return (!ECMA_IS_DIRECT_STRING (string_p) && ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
&& ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
} /* ecma_prop_name_is_symbol */ } /* ecma_prop_name_is_symbol */
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -251,7 +247,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
* *
* @return pointer to ecma-string descriptor * @return pointer to ecma-string descriptor
*/ */
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length, /**< length of the buffer */ ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length, /**< length of the buffer */
lit_utf8_size_t size, /**< size of the buffer */ lit_utf8_size_t size, /**< size of the buffer */
lit_utf8_byte_t **data_p) /**< [out] pointer to the start of the string buffer */ lit_utf8_byte_t **data_p) /**< [out] pointer to the start of the string buffer */
@@ -382,9 +378,8 @@ ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, /**< utf-8 stri
} }
lit_utf8_byte_t *data_p; lit_utf8_byte_t *data_p;
string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size), string_desc_p =
string_size, ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size), string_size, &data_p);
&data_p);
string_desc_p->u.hash = lit_utf8_string_calc_hash (string_p, string_size); string_desc_p->u.hash = lit_utf8_string_calc_hash (string_p, string_size);
memcpy (data_p, string_p, string_size); memcpy (data_p, string_p, string_size);
@@ -446,9 +441,8 @@ ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string
JERRY_ASSERT (lit_is_valid_utf8_string (string_p, string_size, false)); JERRY_ASSERT (lit_is_valid_utf8_string (string_p, string_size, false));
lit_utf8_byte_t *data_p; lit_utf8_byte_t *data_p;
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (converted_string_length, ecma_string_t *string_desc_p =
converted_string_size, ecma_new_ecma_string_from_utf8_buffer (converted_string_length, converted_string_size, &data_p);
&data_p);
const lit_utf8_byte_t *const begin_data_p = data_p; const lit_utf8_byte_t *const begin_data_p = data_p;
pos = 0; pos = 0;
@@ -661,8 +655,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
if (ecma_number_is_infinity (num)) if (ecma_number_is_infinity (num))
{ {
lit_magic_string_id_t id = (ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL lit_magic_string_id_t id =
: LIT_MAGIC_STRING_INFINITY_UL); (ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL : LIT_MAGIC_STRING_INFINITY_UL);
return ecma_get_magic_string (id); return ecma_get_magic_string (id);
} }
@@ -676,9 +670,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
lit_utf8_byte_t *data_p; lit_utf8_byte_t *data_p;
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size), ecma_string_t *string_desc_p =
str_size, ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size), str_size, &data_p);
&data_p);
string_desc_p->u.hash = lit_utf8_string_calc_hash (str_buf, str_size); string_desc_p->u.hash = lit_utf8_string_calc_hash (str_buf, str_size);
memcpy (data_p, str_buf, str_size); memcpy (data_p, str_buf, str_size);
@@ -694,7 +687,7 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
* *
* @return pointer to ecma-string descriptor * @return pointer to ecma-string descriptor
*/ */
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string */ ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string */
{ {
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT); JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
@@ -709,7 +702,7 @@ ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string
* *
* @return pointer to ecma-string descriptor * @return pointer to ecma-string descriptor
*/ */
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_get_internal_string (lit_magic_string_id_t id) /**< identifier of magic string */ ecma_get_internal_string (lit_magic_string_id_t id) /**< identifier of magic string */
{ {
JERRY_ASSERT (id >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT && id < LIT_MAGIC_STRING__COUNT); JERRY_ASSERT (id >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT && id < LIT_MAGIC_STRING__COUNT);
@@ -743,11 +736,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII; uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32]; lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
const lit_utf8_byte_t *cesu8_string1_p = ecma_string_get_chars (string1_p, const lit_utf8_byte_t *cesu8_string1_p =
&cesu8_string1_size, ecma_string_get_chars (string1_p, &cesu8_string1_size, &cesu8_string1_length, uint32_to_string_buffer, &flags);
&cesu8_string1_length,
uint32_to_string_buffer,
&flags);
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED)); JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
JERRY_ASSERT (cesu8_string1_length > 0); JERRY_ASSERT (cesu8_string1_length > 0);
@@ -762,10 +752,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
} }
lit_magic_string_id_t magic_string_id; lit_magic_string_id_t magic_string_id;
magic_string_id = lit_is_utf8_string_pair_magic (cesu8_string1_p, magic_string_id =
cesu8_string1_size, lit_is_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
cesu8_string2_p,
cesu8_string2_size);
if (magic_string_id != LIT_MAGIC_STRING__COUNT) if (magic_string_id != LIT_MAGIC_STRING__COUNT)
{ {
@@ -789,10 +777,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
if (lit_get_magic_string_ex_count () > 0) if (lit_get_magic_string_ex_count () > 0)
{ {
lit_magic_string_ex_id_t magic_string_ex_id; lit_magic_string_ex_id_t magic_string_ex_id;
magic_string_ex_id = lit_is_ex_utf8_string_pair_magic (cesu8_string1_p, magic_string_ex_id =
cesu8_string1_size, lit_is_ex_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
cesu8_string2_p,
cesu8_string2_size);
if (magic_string_ex_id < lit_get_magic_string_ex_count ()) if (magic_string_ex_id < lit_get_magic_string_ex_count ())
{ {
@@ -802,9 +788,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
} }
lit_utf8_byte_t *data_p; lit_utf8_byte_t *data_p;
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length, ecma_string_t *string_desc_p =
new_size, ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length, new_size, &data_p);
&data_p);
lit_string_hash_t hash_start; lit_string_hash_t hash_start;
@@ -857,18 +842,13 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32]; lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII; uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
const lit_utf8_byte_t *cesu8_string2_p = ecma_string_get_chars (string2_p, const lit_utf8_byte_t *cesu8_string2_p =
&cesu8_string2_size, ecma_string_get_chars (string2_p, &cesu8_string2_size, &cesu8_string2_length, uint32_to_string_buffer, &flags);
&cesu8_string2_length,
uint32_to_string_buffer,
&flags);
JERRY_ASSERT (cesu8_string2_p != NULL); JERRY_ASSERT (cesu8_string2_p != NULL);
ecma_string_t *result_p = ecma_append_chars_to_string (string1_p, ecma_string_t *result_p =
cesu8_string2_p, ecma_append_chars_to_string (string1_p, cesu8_string2_p, cesu8_string2_size, cesu8_string2_length);
cesu8_string2_size,
cesu8_string2_length);
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED)); JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
@@ -1200,10 +1180,7 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_p, /**< ecma-string
return size; return size;
} }
size = lit_convert_cesu8_string_to_utf8_string (chars_p, size = lit_convert_cesu8_string_to_utf8_string (chars_p, size, buffer_p, buffer_size);
size,
buffer_p,
buffer_size);
if (flags & ECMA_STRING_FLAG_MUST_BE_FREED) if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
{ {
@@ -1606,7 +1583,6 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
JERRY_ASSERT (length == size); JERRY_ASSERT (length == size);
*flags_p |= ECMA_STRING_FLAG_IS_UINT32 | ECMA_STRING_FLAG_REHASH_NEEDED; *flags_p |= ECMA_STRING_FLAG_IS_UINT32 | ECMA_STRING_FLAG_REHASH_NEEDED;
break; break;
} }
default: default:
{ {
@@ -1634,8 +1610,7 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
*length_p = length; *length_p = length;
} }
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII) if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII) && length != size)
&& length != size)
{ {
*flags_p = (uint8_t) (*flags_p & (uint8_t) ~ECMA_STRING_FLAG_IS_ASCII); *flags_p = (uint8_t) (*flags_p & (uint8_t) ~ECMA_STRING_FLAG_IS_ASCII);
} }
@@ -1685,7 +1660,7 @@ ecma_string_is_length (const ecma_string_t *string_p) /**< property name */
* *
* @return pointer to the converted ecma string * @return pointer to the converted ecma string
*/ */
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
ecma_property_to_string (ecma_property_t property, /**< property name type */ ecma_property_to_string (ecma_property_t property, /**< property name type */
jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */ jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */
{ {
@@ -1964,8 +1939,7 @@ bool
ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-string */ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-string */
const ecma_string_t *string2_p) /**< ecma-string */ const ecma_string_t *string2_p) /**< ecma-string */
{ {
if (ecma_compare_ecma_strings (string1_p, if (ecma_compare_ecma_strings (string1_p, string2_p))
string2_p))
{ {
return false; return false;
} }
@@ -2038,10 +2012,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
} }
} }
return lit_compare_utf8_strings_relational (utf8_string1_p, return lit_compare_utf8_strings_relational (utf8_string1_p, utf8_string1_size, utf8_string2_p, utf8_string2_size);
utf8_string1_size,
utf8_string2_p,
utf8_string2_size);
} /* ecma_compare_ecma_strings_relational */ } /* ecma_compare_ecma_strings_relational */
/** /**
@@ -2071,8 +2042,7 @@ ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
return ECMA_STRING_NO_ASCII_SIZE; return ECMA_STRING_NO_ASCII_SIZE;
} }
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id), JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id), lit_get_magic_string_size (id)));
lit_get_magic_string_size (id)));
return lit_get_magic_string_size (id); return lit_get_magic_string_size (id);
} }
@@ -2120,8 +2090,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT); JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT; uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
lit_get_magic_string_ex_size (id));
} }
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING) if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
@@ -2137,8 +2106,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX); JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id; lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
lit_get_magic_string_ex_size (id));
} /* ecma_string_get_length */ } /* ecma_string_get_length */
/** /**
@@ -2162,8 +2130,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT); JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT; uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
lit_get_magic_string_ex_size (id));
} }
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING) if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
@@ -2196,8 +2163,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id; lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
lit_get_magic_string_ex_size (id));
} /* ecma_string_get_utf8_length */ } /* ecma_string_get_utf8_length */
/** /**
@@ -2259,8 +2225,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT); JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT; uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
lit_get_magic_string_ex_size (id));
} }
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING) if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
@@ -2291,8 +2256,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX); JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id; lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
lit_get_magic_string_ex_size (id));
} /* ecma_string_get_utf8_size */ } /* ecma_string_get_utf8_size */
/** /**
@@ -2626,7 +2590,6 @@ ecma_string_pad (ecma_value_t original_string_p, /**< Input ecma string */
bool pad_on_start) /**< true - if we are padding to the start, calling with padStart bool pad_on_start) /**< true - if we are padding to the start, calling with padStart
false - if we are padding to the end, calling with padEnd */ false - if we are padding to the end, calling with padEnd */
{ {
/* 3 */ /* 3 */
ecma_length_t int_max_length; ecma_length_t int_max_length;
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length))) if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length)))
@@ -2723,7 +2686,7 @@ ecma_stringbuilder_create (void)
jmem_stats_allocate_string_bytes (initial_size); jmem_stats_allocate_string_bytes (initial_size);
#endif /* JERRY_MEM_STATS */ #endif /* JERRY_MEM_STATS */
ecma_stringbuilder_t ret = {.header_p = header_p}; ecma_stringbuilder_t ret = { .header_p = header_p };
return ret; return ret;
} /* ecma_stringbuilder_create */ } /* ecma_stringbuilder_create */
@@ -2744,12 +2707,11 @@ ecma_stringbuilder_create_from (ecma_string_t *string_p) /**< ecma string */
jmem_stats_allocate_string_bytes (initial_size); jmem_stats_allocate_string_bytes (initial_size);
#endif /* JERRY_MEM_STATS */ #endif /* JERRY_MEM_STATS */
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, size_t copied_size =
ECMA_STRINGBUILDER_STRING_PTR (header_p), ecma_string_copy_to_cesu8_buffer (string_p, ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
string_size);
JERRY_ASSERT (copied_size == string_size); JERRY_ASSERT (copied_size == string_size);
ecma_stringbuilder_t ret = {.header_p = header_p}; ecma_stringbuilder_t ret = { .header_p = header_p };
return ret; return ret;
} /* ecma_stringbuilder_create_from */ } /* ecma_stringbuilder_create_from */
@@ -2772,7 +2734,7 @@ ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, /**< pointer to da
memcpy (ECMA_STRINGBUILDER_STRING_PTR (header_p), data_p, data_size); memcpy (ECMA_STRINGBUILDER_STRING_PTR (header_p), data_p, data_size);
ecma_stringbuilder_t ret = {.header_p = header_p}; ecma_stringbuilder_t ret = { .header_p = header_p };
return ret; return ret;
} /* ecma_stringbuilder_create_raw */ } /* ecma_stringbuilder_create_raw */
@@ -2860,9 +2822,7 @@ ecma_stringbuilder_append (ecma_stringbuilder_t *builder_p, /**< string builder
const lit_utf8_size_t string_size = ecma_string_get_size (string_p); const lit_utf8_size_t string_size = ecma_string_get_size (string_p);
lit_utf8_byte_t *dest_p = ecma_stringbuilder_grow (builder_p, string_size); lit_utf8_byte_t *dest_p = ecma_stringbuilder_grow (builder_p, string_size);
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, dest_p, string_size);
dest_p,
string_size);
JERRY_ASSERT (copied_size == string_size); JERRY_ASSERT (copied_size == string_size);
} /* ecma_stringbuilder_append */ } /* ecma_stringbuilder_append */
@@ -2953,7 +2913,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
builder_p->header_p = NULL; builder_p->header_p = NULL;
#endif #endif /* !defined (JERRY_NDEBUG) */
size_t container_size = sizeof (ecma_short_string_t); size_t container_size = sizeof (ecma_short_string_t);
const lit_string_hash_t hash = lit_utf8_string_calc_hash (string_begin_p, string_size); const lit_string_hash_t hash = lit_utf8_string_calc_hash (string_begin_p, string_size);
@@ -2978,9 +2938,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
const size_t utf8_string_size = string_size + container_size; const size_t utf8_string_size = string_size + container_size;
header_p = jmem_heap_realloc_block (header_p, header_p->current_size, utf8_string_size); header_p = jmem_heap_realloc_block (header_p, header_p->current_size, utf8_string_size);
memmove (((lit_utf8_byte_t *) header_p + container_size), memmove (((lit_utf8_byte_t *) header_p + container_size), ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
ECMA_STRINGBUILDER_STRING_PTR (header_p),
string_size);
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
jmem_stats_allocate_string_bytes (container_size - ECMA_ASCII_STRING_HEADER_SIZE); jmem_stats_allocate_string_bytes (container_size - ECMA_ASCII_STRING_HEADER_SIZE);
@@ -3021,7 +2979,7 @@ ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p) /**< string builder
#ifndef JERRY_NDEBUG #ifndef JERRY_NDEBUG
builder_p->header_p = NULL; builder_p->header_p = NULL;
#endif #endif /* !defined (JERRY_NDEBUG) */
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
jmem_stats_free_string_bytes (size); jmem_stats_free_string_bytes (size);
+24 -37
View File
@@ -15,20 +15,18 @@
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h"
#include "jrt-bit-fields.h" #include "jrt-bit-fields.h"
#include "jrt.h"
#include "vm-defines.h" #include "vm-defines.h"
#include "ecma-function-object.h" JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, ecma_types_must_be_less_than_mask);
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT), ecma_value_part_must_start_after_flags);
ecma_types_must_be_less_than_mask);
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
ecma_value_part_must_start_after_flags);
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG, JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log); ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
@@ -42,13 +40,11 @@ JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY #ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
/* cppcheck-suppress zerodiv */ /* cppcheck-suppress zerodiv */
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), uintptr_t_must_fit_in_ecma_value_t);
uintptr_t_must_fit_in_ecma_value_t);
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), uintptr_t_must_not_fit_in_ecma_value_t);
uintptr_t_must_not_fit_in_ecma_value_t);
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
@@ -110,7 +106,7 @@ ecma_pointer_to_ecma_value (const void *ptr) /**< pointer */
* *
* @return pointer * @return pointer
*/ */
static inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE static inline void *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */ ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
{ {
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY #ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
@@ -277,8 +273,7 @@ extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */ ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */
ecma_value_t second_value) /**< second ecma value */ ecma_value_t second_value) /**< second ecma value */
{ {
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, ecma_direct_type_integer_value_must_be_zero);
ecma_direct_type_integer_value_must_be_zero);
return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE; return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
} /* ecma_are_values_integer_numbers */ } /* ecma_are_values_integer_numbers */
@@ -304,8 +299,7 @@ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_number (ecma_value_t value) /**< ecma value */ ecma_is_value_number (ecma_value_t value) /**< ecma value */
{ {
return (ecma_is_value_integer_number (value) return (ecma_is_value_integer_number (value) || ecma_is_value_float_number (value));
|| ecma_is_value_float_number (value));
} /* ecma_is_value_number */ } /* ecma_is_value_number */
JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING, JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
@@ -362,12 +356,12 @@ ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_bigint (ecma_value_t value) /**< ecma value */ ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
{ {
#if JERRY_BUILTIN_BIGINT #if JERRY_BUILTIN_BIGINT
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT); return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
#else /* !JERRY_BUILTIN_BIGINT */ #else /* !JERRY_BUILTIN_BIGINT */
JERRY_UNUSED (value); JERRY_UNUSED (value);
return false; return false;
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
} /* ecma_is_value_bigint */ } /* ecma_is_value_bigint */
/** /**
@@ -441,14 +435,9 @@ ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
void void
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */ ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_undefined (value) JERRY_ASSERT (ecma_is_value_undefined (value) || ecma_is_value_null (value) || ecma_is_value_boolean (value)
|| ecma_is_value_null (value) || ecma_is_value_number (value) || ecma_is_value_string (value) || ecma_is_value_bigint (value)
|| ecma_is_value_boolean (value) || ecma_is_value_symbol (value) || ecma_is_value_object (value));
|| ecma_is_value_number (value)
|| ecma_is_value_string (value)
|| ecma_is_value_bigint (value)
|| ecma_is_value_symbol (value)
|| ecma_is_value_object (value));
} /* ecma_check_value_type_is_spec_defined */ } /* ecma_check_value_type_is_spec_defined */
/** /**
@@ -768,7 +757,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
* *
* @return floating point value * @return floating point value
*/ */
extern inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_number_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */ ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT); JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
@@ -797,7 +786,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the string pointer * @return the string pointer
*/ */
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_string (value)); JERRY_ASSERT (ecma_is_value_string (value));
@@ -816,7 +805,7 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the string pointer * @return the string pointer
*/ */
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */ ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_symbol (value)); JERRY_ASSERT (ecma_is_value_symbol (value));
@@ -830,7 +819,7 @@ ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the string pointer * @return the string pointer
*/ */
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_prop_name (value)); JERRY_ASSERT (ecma_is_value_prop_name (value));
@@ -848,7 +837,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the pointer * @return the pointer
*/ */
extern inline ecma_object_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
{ {
JERRY_ASSERT (ecma_is_value_object (value)); JERRY_ASSERT (ecma_is_value_object (value));
@@ -861,7 +850,7 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
* *
* @return the pointer * @return the pointer
*/ */
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE extern inline ecma_extended_primitive_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */ ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
{ {
#if JERRY_BUILTIN_BIGINT #if JERRY_BUILTIN_BIGINT
@@ -1006,8 +995,7 @@ void
ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
ecma_value_t ecma_value) /**< value to assign */ ecma_value_t ecma_value) /**< value to assign */
{ {
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, ecma_type_direct_must_be_zero_for_the_next_check);
ecma_type_direct_must_be_zero_for_the_next_check);
if (*value_p == ecma_value) if (*value_p == ecma_value)
{ {
@@ -1018,8 +1006,7 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
{ {
*value_p = ecma_value; *value_p = ecma_value;
} }
else if (ecma_is_value_float_number (ecma_value) else if (ecma_is_value_float_number (ecma_value) && ecma_is_value_float_number (*value_p))
&& ecma_is_value_float_number (*value_p))
{ {
const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value); const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value);
ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p); ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p);
+44 -76
View File
@@ -13,20 +13,22 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-helpers.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-array-object.h" #include "ecma-array-object.h"
#include "ecma-builtins.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-lcache.h" #include "ecma-lcache.h"
#include "ecma-line-info.h" #include "ecma-line-info.h"
#include "ecma-property-hashmap.h" #include "ecma-property-hashmap.h"
#include "byte-code.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt-bit-fields.h" #include "jrt-bit-fields.h"
#include "byte-code.h"
#include "re-compiler.h" #include "re-compiler.h"
#include "ecma-builtins.h"
#if JERRY_DEBUGGER #if JERRY_DEBUGGER
#include "debugger.h" #include "debugger.h"
@@ -147,8 +149,7 @@ ecma_object_t *
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
ecma_object_t *binding_obj_p) /**< binding object */ ecma_object_t *binding_obj_p) /**< binding object */
{ {
JERRY_ASSERT (binding_obj_p != NULL JERRY_ASSERT (binding_obj_p != NULL && !ecma_is_lexical_environment (binding_obj_p));
&& !ecma_is_lexical_environment (binding_obj_p));
ecma_object_t *new_lexical_environment_p = ecma_alloc_object (); ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
@@ -156,8 +157,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
ecma_init_gc_info (new_lexical_environment_p); ecma_init_gc_info (new_lexical_environment_p);
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp, ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp, binding_obj_p);
binding_obj_p);
ECMA_SET_POINTER (new_lexical_environment_p->u2.outer_reference_cp, outer_lexical_environment_p); ECMA_SET_POINTER (new_lexical_environment_p->u2.outer_reference_cp, outer_lexical_environment_p);
@@ -298,7 +298,7 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
* *
* @return pointer to ecma object * @return pointer to ecma object
*/ */
extern inline ecma_object_t * JERRY_ATTR_PURE extern inline ecma_object_t *JERRY_ATTR_PURE
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
@@ -381,8 +381,7 @@ ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, /**< declarative
} }
prop_iter_cp = prop_iter_p->next_property_cp; prop_iter_cp = prop_iter_p->next_property_cp;
} } while (prop_iter_cp != JMEM_CP_NULL);
while (prop_iter_cp != JMEM_CP_NULL);
ecma_deref_object (lex_env_p); ecma_deref_object (lex_env_p);
return new_lex_env_p; return new_lex_env_p;
@@ -411,8 +410,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
if (*property_list_head_p != ECMA_NULL_POINTER) if (*property_list_head_p != ECMA_NULL_POINTER)
{ {
/* If the first entry is free (deleted), it is reused. */ /* If the first entry is free (deleted), it is reused. */
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *first_property_p =
*property_list_head_p); ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
#if JERRY_PROPERTY_HASHMAP #if JERRY_PROPERTY_HASHMAP
bool has_hashmap = false; bool has_hashmap = false;
@@ -420,8 +419,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP) if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{ {
property_list_head_p = &first_property_p->next_property_cp; property_list_head_p = &first_property_p->next_property_cp;
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
*property_list_head_p);
has_hashmap = true; has_hashmap = true;
} }
#endif /* JERRY_PROPERTY_HASHMAP */ #endif /* JERRY_PROPERTY_HASHMAP */
@@ -433,8 +431,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
ecma_property_pair_t *first_property_pair_p = (ecma_property_pair_t *) first_property_p; ecma_property_pair_t *first_property_pair_p = (ecma_property_pair_t *) first_property_p;
ecma_property_t name_type; ecma_property_t name_type;
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p, first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p, &name_type);
&name_type);
first_property_p->types[0] = (ecma_property_t) (type_and_flags | name_type); first_property_p->types[0] = (ecma_property_t) (type_and_flags | name_type);
ecma_property_t *property_p = first_property_p->types + 0; ecma_property_t *property_p = first_property_p->types + 0;
@@ -456,10 +453,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
if (has_hashmap) if (has_hashmap)
{ {
ecma_property_hashmap_insert (object_p, ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 0);
name_p,
first_property_pair_p,
0);
} }
#endif /* JERRY_PROPERTY_HASHMAP */ #endif /* JERRY_PROPERTY_HASHMAP */
@@ -478,8 +472,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
if (*property_list_head_p != ECMA_NULL_POINTER) if (*property_list_head_p != ECMA_NULL_POINTER)
{ {
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *first_property_p =
*property_list_head_p); ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP) if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{ {
@@ -495,8 +489,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
first_property_pair_p->names_cp[0] = LIT_INTERNAL_MAGIC_STRING_DELETED; first_property_pair_p->names_cp[0] = LIT_INTERNAL_MAGIC_STRING_DELETED;
ecma_property_t name_type; ecma_property_t name_type;
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p, first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p, &name_type);
&name_type);
first_property_pair_p->header.types[1] = (ecma_property_t) (type_and_flags | name_type); first_property_pair_p->header.types[1] = (ecma_property_t) (type_and_flags | name_type);
@@ -518,10 +511,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
if (has_hashmap) if (has_hashmap)
{ {
ecma_property_hashmap_insert (object_p, ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 1);
name_p,
first_property_pair_p,
1);
} }
#endif /* JERRY_PROPERTY_HASHMAP */ #endif /* JERRY_PROPERTY_HASHMAP */
@@ -542,8 +532,7 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
* if this field is non-NULL */ * if this field is non-NULL */
{ {
JERRY_ASSERT (object_p != NULL && name_p != NULL); JERRY_ASSERT (object_p != NULL && name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p) JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|| !ecma_op_object_is_fast_array (object_p));
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL); JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0); JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
@@ -570,8 +559,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
* if this field is non-NULL */ * if this field is non-NULL */
{ {
JERRY_ASSERT (object_p != NULL && name_p != NULL); JERRY_ASSERT (object_p != NULL && name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p) JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|| !ecma_op_object_is_fast_array (object_p));
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL); JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE) == 0); JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE) == 0);
@@ -630,8 +618,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
{ {
JERRY_ASSERT (obj_p != NULL); JERRY_ASSERT (obj_p != NULL);
JERRY_ASSERT (name_p != NULL); JERRY_ASSERT (name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|| !ecma_op_object_is_fast_array (obj_p));
#if JERRY_LCACHE #if JERRY_LCACHE
ecma_property_t *property_p = ecma_lcache_lookup (obj_p, name_p); ecma_property_t *property_p = ecma_lcache_lookup (obj_p, name_p);
@@ -648,17 +635,13 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
#if JERRY_PROPERTY_HASHMAP #if JERRY_PROPERTY_HASHMAP
if (prop_iter_cp != JMEM_CP_NULL) if (prop_iter_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
prop_iter_cp);
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP) if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{ {
jmem_cpointer_t property_real_name_cp; jmem_cpointer_t property_real_name_cp;
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p, property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p, name_p, &property_real_name_cp);
name_p,
&property_real_name_cp);
#if JERRY_LCACHE #if JERRY_LCACHE
if (property_p != NULL if (property_p != NULL && !ecma_is_property_lcached (property_p))
&& !ecma_is_property_lcached (property_p))
{ {
ecma_lcache_insert (obj_p, property_real_name_cp, property_p); ecma_lcache_insert (obj_p, property_real_name_cp, property_p);
} }
@@ -682,8 +665,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
while (prop_iter_cp != JMEM_CP_NULL) while (prop_iter_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
prop_iter_cp);
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p)); JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
@@ -717,8 +699,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
{ {
while (prop_iter_cp != JMEM_CP_NULL) while (prop_iter_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
prop_iter_cp);
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p)); JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
@@ -763,8 +744,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
#endif /* JERRY_PROPERTY_HASHMAP */ #endif /* JERRY_PROPERTY_HASHMAP */
#if JERRY_LCACHE #if JERRY_LCACHE
if (property_p != NULL if (property_p != NULL && !ecma_is_property_lcached (property_p))
&& !ecma_is_property_lcached (property_p))
{ {
ecma_lcache_insert (obj_p, property_name_cp, property_p); ecma_lcache_insert (obj_p, property_name_cp, property_p);
} }
@@ -788,8 +768,7 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
{ {
JERRY_ASSERT (obj_p != NULL); JERRY_ASSERT (obj_p != NULL);
JERRY_ASSERT (name_p != NULL); JERRY_ASSERT (name_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|| !ecma_op_object_is_fast_array (obj_p));
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p); ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
@@ -816,8 +795,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
if (cur_prop_cp != JMEM_CP_NULL) if (cur_prop_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
cur_prop_cp);
if (cur_prop_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP) if (cur_prop_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{ {
@@ -830,8 +808,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
while (cur_prop_cp != JMEM_CP_NULL) while (cur_prop_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
cur_prop_cp);
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (cur_prop_p)); JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (cur_prop_p));
@@ -846,9 +823,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
#if JERRY_PROPERTY_HASHMAP #if JERRY_PROPERTY_HASHMAP
if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP) if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP)
{ {
hashmap_status = ecma_property_hashmap_delete (object_p, hashmap_status = ecma_property_hashmap_delete (object_p, prop_pair_p->names_cp[i], cur_prop_p->types + i);
prop_pair_p->names_cp[i],
cur_prop_p->types + i);
} }
#endif /* JERRY_PROPERTY_HASHMAP */ #endif /* JERRY_PROPERTY_HASHMAP */
@@ -988,8 +963,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
#if JERRY_CPOINTER_32_BIT #if JERRY_CPOINTER_32_BIT
ecma_getter_setter_pointers_t *getter_setter_pair_p; ecma_getter_setter_pointers_t *getter_setter_pair_p;
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
prop_value_p->getter_setter_pair_cp);
ECMA_SET_POINTER (getter_setter_pair_p->getter_cp, getter_p); ECMA_SET_POINTER (getter_setter_pair_p->getter_cp, getter_p);
#else /* !JERRY_CPOINTER_32_BIT */ #else /* !JERRY_CPOINTER_32_BIT */
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.getter_cp, getter_p); ECMA_SET_POINTER (prop_value_p->getter_setter_pair.getter_cp, getter_p);
@@ -1008,8 +982,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
#if JERRY_CPOINTER_32_BIT #if JERRY_CPOINTER_32_BIT
ecma_getter_setter_pointers_t *getter_setter_pair_p; ecma_getter_setter_pointers_t *getter_setter_pair_p;
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
prop_value_p->getter_setter_pair_cp);
ECMA_SET_POINTER (getter_setter_pair_p->setter_cp, setter_p); ECMA_SET_POINTER (getter_setter_pair_p->setter_cp, setter_p);
#else /* !JERRY_CPOINTER_32_BIT */ #else /* !JERRY_CPOINTER_32_BIT */
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.setter_cp, setter_p); ECMA_SET_POINTER (prop_value_p->getter_setter_pair.setter_cp, setter_p);
@@ -1059,7 +1032,7 @@ ecma_property_to_reference (ecma_property_t *property_p) /**< data or reference
* *
* @return pointer to the value * @return pointer to the value
*/ */
extern inline ecma_property_value_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_property_value_t *JERRY_ATTR_ALWAYS_INLINE
ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p) /**< data property reference */ ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p) /**< data property reference */
{ {
ecma_value_t value = reference_p->value; ecma_value_t value = reference_p->value;
@@ -1248,14 +1221,12 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
ecma_free_value (prop_desc_p->value); ecma_free_value (prop_desc_p->value);
} }
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) && prop_desc_p->get_p != NULL)
&& prop_desc_p->get_p != NULL)
{ {
ecma_deref_object (prop_desc_p->get_p); ecma_deref_object (prop_desc_p->get_p);
} }
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) && prop_desc_p->set_p != NULL)
&& prop_desc_p->set_p != NULL)
{ {
ecma_deref_object (prop_desc_p->set_p); ecma_deref_object (prop_desc_p->set_p);
} }
@@ -1551,8 +1522,8 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
for (uint32_t i = const_literal_end; i < literal_end; i++) for (uint32_t i = const_literal_end; i < literal_end; i++)
{ {
ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *bytecode_literal_p =
literal_start_p[i]); ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
/* Self references are ignored. */ /* Self references are ignored. */
if (bytecode_literal_p != bytecode_p) if (bytecode_literal_p != bytecode_p)
@@ -1606,8 +1577,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
{ {
jerry_debugger_byte_code_free_t *first_byte_code_free_p; jerry_debugger_byte_code_free_t *first_byte_code_free_p;
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_head);
byte_code_free_head);
first_byte_code_free_p->prev_cp = byte_code_free_cp; first_byte_code_free_p->prev_cp = byte_code_free_cp;
} }
@@ -1629,8 +1599,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
#endif /* JERRY_BUILTIN_REGEXP */ #endif /* JERRY_BUILTIN_REGEXP */
} }
jmem_heap_free_block (bytecode_p, jmem_heap_free_block (bytecode_p, ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
} /* ecma_bytecode_deref */ } /* ecma_bytecode_deref */
/** /**
@@ -1659,8 +1628,7 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT) if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
{ {
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
ext_object_p->u.cls.u3.value);
break; break;
} }
@@ -1687,8 +1655,8 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
{ {
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
object_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, object_p =
ext_object_p->u.bound_function.target_function); ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_object_p->u.bound_function.target_function);
continue; continue;
} }
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -1741,7 +1709,7 @@ ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode
* *
* @return position of the function name of the compiled code * @return position of the function name of the compiled code
*/ */
extern inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_value_t *JERRY_ATTR_ALWAYS_INLINE
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */ ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
{ {
JERRY_ASSERT (bytecode_header_p != NULL); JERRY_ASSERT (bytecode_header_p != NULL);
+59 -81
View File
@@ -17,6 +17,7 @@
#define ECMA_HELPERS_H #define ECMA_HELPERS_H
#include "ecma-globals.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
#include "lit-strings.h" #include "lit-strings.h"
@@ -47,8 +48,8 @@
* Set value of non-null compressed pointer so that it will correspond * Set value of non-null compressed pointer so that it will correspond
* to specified non_compressed_pointer. * to specified non_compressed_pointer.
*/ */
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \ #define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, non_compressed_pointer)
/** /**
* Set value of pointer-tag value so that it will correspond * Set value of pointer-tag value so that it will correspond
@@ -99,7 +100,7 @@ typedef enum
/** /**
* Underscore is ignored when this option is passed. * Underscore is ignored when this option is passed.
*/ */
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1 #define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
/** /**
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer. * Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
@@ -108,19 +109,15 @@ typedef enum
utf8_ptr, /**< [out] output buffer pointer */ \ utf8_ptr, /**< [out] output buffer pointer */ \
utf8_str_size) /**< [out] output buffer size */ \ utf8_str_size) /**< [out] output buffer size */ \
lit_utf8_size_t utf8_str_size; \ lit_utf8_size_t utf8_str_size; \
uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \ uint8_t utf8_ptr##flags = ECMA_STRING_FLAG_EMPTY; \
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, \ const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, NULL, NULL, &utf8_ptr##flags);
&utf8_str_size, \
NULL, \
NULL, \
&utf8_ptr ## flags);
/** /**
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING' * Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
*/ */
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \ #define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
utf8_str_size) /**< buffer size */ \ utf8_str_size) /**< buffer size */ \
if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \ if (utf8_ptr##flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
{ \ { \
JERRY_ASSERT (utf8_ptr != NULL); \ JERRY_ASSERT (utf8_ptr != NULL); \
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \ jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
@@ -131,64 +128,54 @@ typedef enum
/** /**
* Set an internal property value from pointer. * Set an internal property value from pointer.
*/ */
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
((field) = ((ecma_value_t) pointer))
/** /**
* Set an internal property value from pointer. Pointer can be NULL. * Set an internal property value from pointer. Pointer can be NULL.
*/ */
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
((field) = ((ecma_value_t) pointer))
/** /**
* Convert an internal property value to pointer. * Convert an internal property value to pointer.
*/ */
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ((type *) field)
((type *) field)
/** /**
* Convert an internal property value to pointer. Result can be NULL. * Convert an internal property value to pointer. Result can be NULL.
*/ */
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ((type *) field)
((type *) field)
/** /**
* Checks whether an internal property is NULL. * Checks whether an internal property is NULL.
*/ */
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \ #define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) NULL))
((field) == ((ecma_value_t) NULL))
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
/** /**
* Set an internal property value from pointer. * Set an internal property value from pointer.
*/ */
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
ECMA_SET_NON_NULL_POINTER (field, pointer)
/** /**
* Set an internal property value from pointer. Pointer can be NULL. * Set an internal property value from pointer. Pointer can be NULL.
*/ */
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \ #define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ECMA_SET_POINTER (field, pointer)
ECMA_SET_POINTER (field, pointer)
/** /**
* Convert an internal property value to pointer. * Convert an internal property value to pointer.
*/ */
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ECMA_GET_NON_NULL_POINTER (type, field)
ECMA_GET_NON_NULL_POINTER (type, field)
/** /**
* Convert an internal property value to pointer. Result can be NULL. * Convert an internal property value to pointer. Result can be NULL.
*/ */
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \ #define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ECMA_GET_POINTER (type, field)
ECMA_GET_POINTER (type, field)
/** /**
* Checks whether an internal property is NULL. * Checks whether an internal property is NULL.
*/ */
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \ #define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
((field) == ((ecma_value_t) JMEM_CP_NULL))
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */ #endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
@@ -264,7 +251,7 @@ ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_exte
uint32_t type); uint32_t type);
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value); ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value); ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
ecma_number_t * ecma_get_pointer_from_float_value (ecma_value_t value); ecma_number_t *ecma_get_pointer_from_float_value (ecma_value_t value);
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value); ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value); ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -299,14 +286,12 @@ ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t
ecma_string_t *ecma_new_map_key_string (ecma_value_t value); ecma_string_t *ecma_new_map_key_string (ecma_value_t value);
bool ecma_prop_name_is_map_key (ecma_string_t *string_p); bool ecma_prop_name_is_map_key (ecma_string_t *string_p);
#endif /* JERRY_BUILTIN_CONTAINER */ #endif /* JERRY_BUILTIN_CONTAINER */
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p, ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
lit_utf8_size_t string_size); ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p,
lit_utf8_size_t string_size);
ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p, ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p,
lit_utf8_size_t string_size); lit_utf8_size_t string_size);
ecma_string_t *ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, ecma_string_t *
void *user_p); ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, void *user_p);
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit); ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
#if JERRY_ESNEXT #if JERRY_ESNEXT
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit); ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
@@ -331,28 +316,24 @@ void ecma_destroy_ecma_string (ecma_string_t *string_p);
ecma_number_t ecma_string_to_number (const ecma_string_t *str_p); ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
uint32_t ecma_string_get_array_index (const ecma_string_t *str_p); uint32_t ecma_string_get_array_index (const ecma_string_t *str_p);
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
lit_utf8_byte_t *buffer_p, lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size); lit_utf8_size_t buffer_size);
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
lit_utf8_byte_t *buffer_p, lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size); lit_utf8_size_t buffer_size);
lit_utf8_size_t lit_utf8_size_t ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
lit_utf8_size_t start_pos, lit_utf8_size_t start_pos,
lit_utf8_size_t end_pos, lit_utf8_size_t end_pos,
lit_utf8_byte_t *buffer_p, lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size); lit_utf8_size_t buffer_size);
lit_utf8_size_t lit_utf8_size_t ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
lit_utf8_size_t start_pos, lit_utf8_size_t start_pos,
lit_utf8_size_t end_pos, lit_utf8_size_t end_pos,
lit_utf8_byte_t *buffer_p, lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size); lit_utf8_size_t buffer_size);
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, void
lit_utf8_size_t buffer_size); ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p, const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p,
lit_utf8_size_t *size_p, lit_utf8_size_t *size_p,
lit_utf8_size_t *length_p, lit_utf8_size_t *length_p,
@@ -369,7 +350,8 @@ jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_p
ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp); ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp);
lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp); lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp);
uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp); uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp);
bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp, bool ecma_string_compare_to_property_name (ecma_property_t property,
jmem_cpointer_t prop_name_cp,
const ecma_string_t *string_p); const ecma_string_t *string_p);
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p); bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
@@ -387,20 +369,16 @@ lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos); ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p); const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p); const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, lit_utf8_size_t *utf8_str_size);
lit_utf8_size_t *utf8_str_size);
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p); ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
#if JERRY_ESNEXT #if JERRY_ESNEXT
ecma_value_t ecma_string_pad (ecma_value_t original_string_p, ecma_value_t
ecma_value_t max_length, ecma_string_pad (ecma_value_t original_string_p, ecma_value_t max_length, ecma_value_t fill_string, bool pad_on_start);
ecma_value_t fill_string,
bool pad_on_start);
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
ecma_stringbuilder_t ecma_stringbuilder_create (void); ecma_stringbuilder_t ecma_stringbuilder_create (void);
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p); ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, const lit_utf8_size_t data_size);
const lit_utf8_size_t data_size);
lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p); lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p);
lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p); lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p);
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size); void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
@@ -425,18 +403,15 @@ bool ecma_number_is_negative (ecma_number_t num);
bool ecma_number_is_zero (ecma_number_t num); bool ecma_number_is_zero (ecma_number_t num);
bool ecma_number_is_infinity (ecma_number_t num); bool ecma_number_is_infinity (ecma_number_t num);
bool ecma_number_is_finite (ecma_number_t num); bool ecma_number_is_finite (ecma_number_t num);
ecma_number_t ecma_number_t ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
ecma_number_t ecma_number_get_prev (ecma_number_t num); ecma_number_t ecma_number_get_prev (ecma_number_t num);
ecma_number_t ecma_number_get_next (ecma_number_t num); ecma_number_t ecma_number_get_next (ecma_number_t num);
ecma_number_t ecma_number_trunc (ecma_number_t num); ecma_number_t ecma_number_trunc (ecma_number_t num);
ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num); ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num);
ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y); ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y);
ecma_value_t ecma_number_parse_int (const lit_utf8_byte_t *string_buff, ecma_value_t
lit_utf8_size_t string_buff_size, ecma_number_parse_int (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size, ecma_value_t radix);
ecma_value_t radix); ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size);
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff,
lit_utf8_size_t string_buff_size);
ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer); ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer);
lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p); lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p);
@@ -476,30 +451,33 @@ ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecm
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p); ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values); ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
ecma_property_value_t * ecma_property_value_t *ecma_create_named_data_property (ecma_object_t *object_p,
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes, ecma_string_t *name_p,
uint8_t prop_attributes,
ecma_property_t **out_prop_p);
ecma_property_value_t *ecma_create_named_accessor_property (ecma_object_t *object_p,
ecma_string_t *name_p,
ecma_object_t *get_p,
ecma_object_t *set_p,
uint8_t prop_attributes,
ecma_property_t **out_prop_p); ecma_property_t **out_prop_p);
ecma_property_value_t *
ecma_create_named_accessor_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_object_t *get_p,
ecma_object_t *set_p, uint8_t prop_attributes, ecma_property_t **out_prop_p);
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
void ecma_create_named_reference_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_value_t reference); void ecma_create_named_reference_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_value_t reference);
#endif /* JERRY_MODULE_SYSTEM */ #endif /* JERRY_MODULE_SYSTEM */
ecma_property_t * ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p); ecma_property_value_t *ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
ecma_property_value_t *
ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p); void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
void ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, void
ecma_value_t value); ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
ecma_getter_setter_pointers_t * ecma_getter_setter_pointers_t *ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p); void ecma_set_named_accessor_property_getter (ecma_object_t *object_p,
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p, ecma_property_value_t *prop_value_p,
ecma_object_t *getter_p); ecma_object_t *getter_p);
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p, void ecma_set_named_accessor_property_setter (ecma_object_t *object_p,
ecma_property_value_t *prop_value_p,
ecma_object_t *setter_p); ecma_object_t *setter_p);
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
ecma_value_t ecma_property_to_reference (ecma_property_t *property_p); ecma_value_t ecma_property_to_reference (ecma_property_t *property_p);
@@ -549,15 +527,15 @@ uintptr_t ecma_get_current_stack_usage (void);
#endif /* (JERRY_STACK_LIMIT != 0) */ #endif /* (JERRY_STACK_LIMIT != 0) */
/* ecma-helpers-external-pointers.c */ /* ecma-helpers-external-pointers.c */
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p, bool ecma_create_native_pointer_property (ecma_object_t *obj_p,
void *native_p,
const jerry_object_native_info_t *native_info_p); const jerry_object_native_info_t *native_info_p);
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p,
const jerry_object_native_info_t *native_info_p); const jerry_object_native_info_t *native_info_p);
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_info_p); bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_info_p);
/* ecma-helpers-conversion.c */ /* ecma-helpers-conversion.c */
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
uint32_t option);
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size); lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
uint32_t ecma_number_to_uint32 (ecma_number_t num); uint32_t ecma_number_to_uint32 (ecma_number_t num);
int32_t ecma_number_to_int32 (ecma_number_t num); int32_t ecma_number_to_int32 (ecma_number_t num);
+5 -4
View File
@@ -13,14 +13,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-init-finalize.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-init-finalize.h"
#include "ecma-lex-env.h" #include "ecma-lex-env.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "jmem.h"
#include "jcontext.h" #include "jcontext.h"
#include "jmem.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -89,8 +91,7 @@ ecma_finalize (void)
{ {
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS); jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
} }
} } while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
#if JERRY_ESNEXT #if JERRY_ESNEXT
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp); jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
+10 -10
View File
@@ -13,10 +13,12 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-lcache.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lcache.h"
#include "jcontext.h" #include "jcontext.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -98,7 +100,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
ECMA_SET_NON_NULL_POINTER (object_cp, object_p); ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
size_t row_index = ecma_lcache_row_index (object_cp, name_cp); size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index]; ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH; ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
do do
@@ -109,8 +111,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
} }
entry_p++; entry_p++;
} } while (entry_p < entry_end_p);
while (entry_p < entry_end_p);
/* Invalidate the last entry. */ /* Invalidate the last entry. */
ecma_lcache_invalidate_entry (--entry_p); ecma_lcache_invalidate_entry (--entry_p);
@@ -136,7 +137,7 @@ insert:
* @return a pointer to an ecma_property_t if the lookup is successful * @return a pointer to an ecma_property_t if the lookup is successful
* NULL otherwise * NULL otherwise
*/ */
extern inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE extern inline ecma_property_t *JERRY_ATTR_ALWAYS_INLINE
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
const ecma_string_t *prop_name_p) /**< property's name */ const ecma_string_t *prop_name_p) /**< property's name */
{ {
@@ -161,7 +162,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp); size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp);
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index]; ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH; ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp); ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp);
@@ -173,8 +174,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
return entry_p->prop_p; return entry_p->prop_p;
} }
entry_p++; entry_p++;
} } while (entry_p < entry_end_p);
while (entry_p < entry_end_p);
return NULL; return NULL;
} /* ecma_lcache_lookup */ } /* ecma_lcache_lookup */
@@ -195,12 +195,12 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
ECMA_SET_NON_NULL_POINTER (object_cp, object_p); ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
size_t row_index = ecma_lcache_row_index (object_cp, name_cp); size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index]; ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
while (true) while (true)
{ {
/* The property must be present. */ /* The property must be present. */
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH); JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache)[row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
if (entry_p->id != 0 && entry_p->prop_p == prop_p) if (entry_p->id != 0 && entry_p->prop_p == prop_p)
{ {
+2
View File
@@ -23,6 +23,8 @@
* @{ * @{
*/ */
#include "ecma-globals.h"
#if JERRY_LCACHE #if JERRY_LCACHE
void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p); void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p); ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p);
+4 -5
View File
@@ -13,9 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-helpers.h"
#include "ecma-line-info.h" #include "ecma-line-info.h"
#include "ecma-helpers.h"
#if JERRY_LINE_INFO #if JERRY_LINE_INFO
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -45,8 +46,7 @@ ecma_line_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
do do
{ {
value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK); value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK);
} } while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
*buffer_p = source_p; *buffer_p = source_p;
return value; return value;
@@ -169,8 +169,7 @@ ecma_line_info_get (uint8_t *line_info_p, /**< line info buffer */
column = ecma_line_info_difference_update (column, value); column = ecma_line_info_difference_update (column, value);
end_offset += end_offset_increase; end_offset += end_offset_increase;
} } while (end_offset_increase != 0 && end_offset <= offset);
while (end_offset_increase != 0 && end_offset <= offset);
location_p->line = line; location_p->line = line;
location_p->column = column; location_p->column = column;
+2 -4
View File
@@ -90,8 +90,7 @@
/** /**
* Minimum size of a stream (except the last one). * Minimum size of a stream (except the last one).
*/ */
#define ECMA_LINE_INFO_STREAM_SIZE_MIN \ #define ECMA_LINE_INFO_STREAM_SIZE_MIN ((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
/* Helper functions for parser/js/js-parser-line-info-create.c. */ /* Helper functions for parser/js/js-parser-line-info-create.c. */
uint32_t ecma_line_info_decode_vlq (uint8_t **buffer_p); uint32_t ecma_line_info_decode_vlq (uint8_t **buffer_p);
@@ -99,8 +98,7 @@ uint32_t ecma_line_info_difference_update (uint32_t current_value, uint32_t diff
/* General functions. */ /* General functions. */
void ecma_line_info_free (uint8_t *line_info_p); void ecma_line_info_free (uint8_t *line_info_p);
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, jerry_backtrace_location_t *location_p);
jerry_backtrace_location_t *location_p);
#if JERRY_PARSER_DUMP_BYTE_CODE #if JERRY_PARSER_DUMP_BYTE_CODE
void ecma_line_info_dump (uint8_t *line_info_p); void ecma_line_info_dump (uint8_t *line_info_p);
+23 -30
View File
@@ -13,11 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-alloc.h"
#include "ecma-bigint.h"
#include "ecma-big-uint.h"
#include "ecma-literal-storage.h" #include "ecma-literal-storage.h"
#include "ecma-alloc.h"
#include "ecma-big-uint.h"
#include "ecma-bigint.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jcontext.h" #include "jcontext.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
@@ -42,8 +44,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
{ {
if (symbol_list_p->values[i] != JMEM_CP_NULL) if (symbol_list_p->values[i] != JMEM_CP_NULL)
{ {
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, symbol_list_p->values[i]);
symbol_list_p->values[i]);
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p)); JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
ecma_deref_ecma_string (string_p); ecma_deref_ecma_string (string_p);
@@ -71,8 +72,7 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
{ {
if (string_list_p->values[i] != JMEM_CP_NULL) if (string_list_p->values[i] != JMEM_CP_NULL)
{ {
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
string_list_p->values[i]);
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p)); JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
ecma_destroy_ecma_string (string_p); ecma_destroy_ecma_string (string_p);
@@ -93,8 +93,7 @@ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
{ {
while (number_list_cp != JMEM_CP_NULL) while (number_list_cp != JMEM_CP_NULL)
{ {
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
number_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{ {
@@ -120,15 +119,14 @@ ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
{ {
while (bigint_list_cp != JMEM_CP_NULL) while (bigint_list_cp != JMEM_CP_NULL)
{ {
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
bigint_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{ {
if (bigint_list_p->values[i] != JMEM_CP_NULL) if (bigint_list_p->values[i] != JMEM_CP_NULL)
{ {
ecma_extended_primitive_t *bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, ecma_extended_primitive_t *bigint_p =
bigint_list_p->values[i]); JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p)); JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
ecma_deref_bigint (bigint_p); ecma_deref_bigint (bigint_p);
} }
@@ -168,8 +166,8 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
lit_utf8_size_t size, /**< size of the string */ lit_utf8_size_t size, /**< size of the string */
bool is_ascii) /**< encode of the string */ bool is_ascii) /**< encode of the string */
{ {
ecma_string_t *string_p = (is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) ecma_string_t *string_p =
: ecma_new_ecma_string_from_utf8 (chars_p, size)); (is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) : ecma_new_ecma_string_from_utf8 (chars_p, size));
if (ECMA_IS_DIRECT_STRING (string_p)) if (ECMA_IS_DIRECT_STRING (string_p))
{ {
@@ -194,8 +192,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
} }
else else
{ {
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
string_list_p->values[i]);
if (ecma_compare_ecma_strings (string_p, value_p)) if (ecma_compare_ecma_strings (string_p, value_p))
{ {
@@ -256,8 +253,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
while (number_list_cp != JMEM_CP_NULL) while (number_list_cp != JMEM_CP_NULL)
{ {
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
number_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{ {
@@ -270,8 +266,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
} }
else else
{ {
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
number_list_p->values[i]);
if (*number_p == number_arg) if (*number_p == number_arg)
{ {
@@ -330,8 +325,7 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
while (bigint_list_cp != JMEM_CP_NULL) while (bigint_list_cp != JMEM_CP_NULL)
{ {
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
bigint_list_cp);
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
{ {
@@ -344,8 +338,8 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
} }
else else
{ {
ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, ecma_extended_primitive_t *other_bigint_p =
bigint_list_p->values[i]); JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT); ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint)) if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
@@ -417,7 +411,8 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
/** /**
* Append the value at the end of the appropriate list if it is not present there. * Append the value at the end of the appropriate list if it is not present there.
*/ */
void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */ void
ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
ecma_collection_t *lit_pool_p) /**< list of known values */ ecma_collection_t *lit_pool_p) /**< list of known values */
{ {
/* Unlike direct numbers, direct strings are converted to character literals. */ /* Unlike direct numbers, direct strings are converted to character literals. */
@@ -498,11 +493,9 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
for (uint32_t i = const_literal_end; i < literal_end; i++) for (uint32_t i = const_literal_end; i < literal_end; i++)
{ {
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_p[i]);
literal_p[i]);
if (CBC_IS_FUNCTION (bytecode_p->status_flags) if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
&& bytecode_p != compiled_code_p)
{ {
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p); ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
} }
+10 -8
View File
@@ -17,6 +17,7 @@
#define ECMA_LIT_STORAGE_H #define ECMA_LIT_STORAGE_H
#include "ecma-globals.h" #include "ecma-globals.h"
#include "jmem.h" #include "jmem.h"
#include "lit-globals.h" #include "lit-globals.h"
@@ -48,18 +49,19 @@ ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
#if JERRY_SNAPSHOT_SAVE #if JERRY_SNAPSHOT_SAVE
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p); void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, ecma_collection_t *lit_pool_p);
ecma_collection_t *lit_pool_p); bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p,
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size, uint32_t *buffer_p,
size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p, size_t buffer_size,
size_t *in_out_buffer_offset_p,
lit_mem_to_snapshot_id_map_entry_t **out_map_p,
uint32_t *out_map_len_p); uint32_t *out_map_len_p);
#endif /* JERRY_SNAPSHOT_SAVE */ #endif /* JERRY_SNAPSHOT_SAVE */
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE #if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
ecma_value_t ecma_value_t ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value); ecma_value_t *ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p,
ecma_value_t * uint8_t *byte_code_end_p);
ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p);
#endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */ #endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
/** /**
+40 -59
View File
@@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jcontext.h" #include "ecma-module.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
@@ -21,8 +21,9 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-lex-env.h" #include "ecma-lex-env.h"
#include "ecma-module.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "jcontext.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#include "vm.h" #include "vm.h"
@@ -104,12 +105,12 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
{ {
module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_ERROR; module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_ERROR;
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL && !jcontext_has_pending_abort ())
&& !jcontext_has_pending_abort ())
{ {
jerry_value_t exception = jcontext_take_exception (); jerry_value_t exception = jcontext_take_exception ();
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_ERROR, JERRY_CONTEXT (module_state_changed_callback_p)
(JERRY_MODULE_STATE_ERROR,
ecma_make_object_value (&module_p->header.object), ecma_make_object_value (&module_p->header.object),
exception, exception,
JERRY_CONTEXT (module_state_changed_callback_user_p)); JERRY_CONTEXT (module_state_changed_callback_user_p));
@@ -122,7 +123,7 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
* *
* @return module pointer * @return module pointer
*/ */
static inline ecma_module_t * JERRY_ATTR_ALWAYS_INLINE static inline ecma_module_t *JERRY_ATTR_ALWAYS_INLINE
ecma_module_get_from_object (ecma_value_t module_val) /**< module */ ecma_module_get_from_object (ecma_value_t module_val) /**< module */
{ {
JERRY_ASSERT (ecma_is_value_object (module_val)); JERRY_ASSERT (ecma_is_value_object (module_val));
@@ -210,8 +211,7 @@ ecma_module_resolve_set_append (ecma_module_resolve_set_t *set_p, /**< resolve s
while (true) while (true)
{ {
if (current_p->module_p == module_p if (current_p->module_p == module_p && ecma_compare_ecma_strings (current_p->name_p, export_name_p))
&& ecma_compare_ecma_strings (current_p->name_p, export_name_p))
{ {
return false; return false;
} }
@@ -339,16 +339,14 @@ ecma_module_resolve_import (ecma_module_resolve_result_t *resolve_result_p, /**<
{ {
JERRY_ASSERT (import_node_p != NULL); JERRY_ASSERT (import_node_p != NULL);
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p; for (ecma_module_names_t *import_names_p = import_node_p->module_names_p; import_names_p != NULL;
import_names_p != NULL;
import_names_p = import_names_p->next_p) import_names_p = import_names_p->next_p)
{ {
if (ecma_compare_ecma_strings (local_name_p, import_names_p->local_name_p)) if (ecma_compare_ecma_strings (local_name_p, import_names_p->local_name_p))
{ {
ecma_module_t *imported_module_p = ecma_module_get_from_object (import_node_p->u.path_or_module); ecma_module_t *imported_module_p = ecma_module_get_from_object (import_node_p->u.path_or_module);
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
LIT_MAGIC_STRING_ASTERIX_CHAR))
{ {
/* Namespace import. */ /* Namespace import. */
ecma_value_t namespace = ecma_make_object_value (imported_module_p->namespace_object_p); ecma_value_t namespace = ecma_make_object_value (imported_module_p->namespace_object_p);
@@ -401,17 +399,16 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE) if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE)
{ {
ecma_property_t *property_p = ecma_find_named_property (current_module_p->namespace_object_p, ecma_property_t *property_p =
current_export_name_p); ecma_find_named_property (current_module_p->namespace_object_p, current_export_name_p);
if (property_p != NULL) if (property_p != NULL)
{ {
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p); ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
JERRY_ASSERT ((!(*property_p & ECMA_PROPERTY_FLAG_DATA) JERRY_ASSERT (
&& !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG)) (!(*property_p & ECMA_PROPERTY_FLAG_DATA) && !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA) || ((*property_p & ECMA_PROPERTY_FLAG_DATA) && ecma_is_value_object (property_value_p->value)
&& ecma_is_value_object (property_value_p->value)
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value), && ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
ECMA_OBJECT_CLASS_MODULE_NAMESPACE))); ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
@@ -432,8 +429,8 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
{ {
if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p)) if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p))
{ {
ecma_property_t *property_p = ecma_find_named_property (current_module_p->scope_p, ecma_property_t *property_p =
export_names_p->local_name_p); ecma_find_named_property (current_module_p->scope_p, export_names_p->local_name_p);
if (property_p != NULL) if (property_p != NULL)
{ {
@@ -473,8 +470,7 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
{ {
ecma_module_t *target_module_p = ecma_module_get_from_object (*indirect_export_p->u.module_object_p); ecma_module_t *target_module_p = ecma_module_get_from_object (*indirect_export_p->u.module_object_p);
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p, if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
LIT_MAGIC_STRING_ASTERIX_CHAR))
{ {
/* Namespace export. */ /* Namespace export. */
ecma_value_t namespace = ecma_make_object_value (target_module_p->namespace_object_p); ecma_value_t namespace = ecma_make_object_value (target_module_p->namespace_object_p);
@@ -525,10 +521,9 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
star_export_p = star_export_p->next_p; star_export_p = star_export_p->next_p;
} }
next_iteration: next_iteration:
current_set_p = current_set_p->next_p; current_set_p = current_set_p->next_p;
} } while (current_set_p != NULL);
while (current_set_p != NULL);
exit: exit:
ecma_module_resolve_set_cleanup (resolve_set_p); ecma_module_resolve_set_cleanup (resolve_set_p);
@@ -586,7 +581,8 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL) if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
{ {
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_EVALUATED, JERRY_CONTEXT (module_state_changed_callback_p)
(JERRY_MODULE_STATE_EVALUATED,
ecma_make_object_value (&module_p->header.object), ecma_make_object_value (&module_p->header.object),
ret_value, ret_value,
JERRY_CONTEXT (module_state_changed_callback_user_p)); JERRY_CONTEXT (module_state_changed_callback_user_p));
@@ -746,8 +742,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
#if JERRY_PROPERTY_HASHMAP #if JERRY_PROPERTY_HASHMAP
if (prop_iter_cp != JMEM_CP_NULL) if (prop_iter_cp != JMEM_CP_NULL)
{ {
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
prop_iter_cp);
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP) if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
{ {
prop_iter_cp = prop_iter_p->next_property_cp; prop_iter_cp = prop_iter_p->next_property_cp;
@@ -802,8 +797,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
} }
export_names_p = export_names_p->next_p; export_names_p = export_names_p->next_p;
} } while (export_names_p != NULL);
while (export_names_p != NULL);
} }
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p; ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
@@ -848,8 +842,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
} }
current_set_p = current_set_p->next_p; current_set_p = current_set_p->next_p;
} } while (current_set_p != NULL);
while (current_set_p != NULL);
ecma_value_t *buffer_p = properties_p->buffer_p; ecma_value_t *buffer_p = properties_p->buffer_p;
uint32_t item_count = properties_p->item_count; uint32_t item_count = properties_p->item_count;
@@ -863,8 +856,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
{ {
end -= 2; end -= 2;
ecma_module_heap_sort_shift_down (buffer_p, item_count, end); ecma_module_heap_sort_shift_down (buffer_p, item_count, end);
} } while (end > 0);
while (end > 0);
end = item_count - 2; end = item_count - 2;
@@ -880,8 +872,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
ecma_module_heap_sort_shift_down (buffer_p, end, 0); ecma_module_heap_sort_shift_down (buffer_p, end, 0);
end -= 2; end -= 2;
} } while (end > 0);
while (end > 0);
} }
ecma_value_t *buffer_end_p = properties_p->buffer_p + item_count; ecma_value_t *buffer_end_p = properties_p->buffer_p + item_count;
@@ -989,15 +980,12 @@ ecma_module_connect_imports (ecma_module_t *module_p)
while (import_names_p != NULL) while (import_names_p != NULL)
{ {
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
LIT_MAGIC_STRING_ASTERIX_CHAR))
{ {
/* Namespace import. */ /* Namespace import. */
ecma_property_value_t *value_p; ecma_property_value_t *value_p;
value_p = ecma_create_named_data_property (module_p->scope_p, value_p =
import_names_p->local_name_p, ecma_create_named_data_property (module_p->scope_p, import_names_p->local_name_p, ECMA_PROPERTY_FIXED, NULL);
ECMA_PROPERTY_FIXED,
NULL);
value_p->value = ecma_make_object_value (imported_module_p->namespace_object_p); value_p->value = ecma_make_object_value (imported_module_p->namespace_object_p);
} }
else else
@@ -1021,9 +1009,7 @@ ecma_module_connect_imports (ecma_module_t *module_p)
} }
else else
{ {
ecma_create_named_reference_property (module_p->scope_p, ecma_create_named_reference_property (module_p->scope_p, import_names_p->local_name_p, resolve_result.result);
import_names_p->local_name_p,
resolve_result.result);
} }
} }
@@ -1253,9 +1239,8 @@ restart:
if (current_module_p->namespace_object_p == NULL) if (current_module_p->namespace_object_p == NULL)
{ {
ecma_object_t *namespace_object_p = ecma_create_object (NULL, ecma_object_t *namespace_object_p =
sizeof (ecma_extended_object_t), ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
ECMA_OBJECT_TYPE_CLASS);
namespace_object_p->type_flags_refs &= (ecma_object_descriptor_t) ~ECMA_OBJECT_FLAG_EXTENSIBLE; namespace_object_p->type_flags_refs &= (ecma_object_descriptor_t) ~ECMA_OBJECT_FLAG_EXTENSIBLE;
@@ -1297,8 +1282,7 @@ restart:
} }
iterator_p = iterator_p->prev_p; iterator_p = iterator_p->prev_p;
} } while (iterator_p != end_p);
while (iterator_p != end_p);
iterator_p = last_p; iterator_p = last_p;
@@ -1313,8 +1297,7 @@ restart:
} }
iterator_p = iterator_p->prev_p; iterator_p = iterator_p->prev_p;
} } while (iterator_p != end_p);
while (iterator_p != end_p);
do do
{ {
@@ -1325,7 +1308,8 @@ restart:
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL) if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
{ {
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_LINKED, JERRY_CONTEXT (module_state_changed_callback_p)
(JERRY_MODULE_STATE_LINKED,
ecma_make_object_value (&last_p->module_p->header.object), ecma_make_object_value (&last_p->module_p->header.object),
ECMA_VALUE_UNDEFINED, ECMA_VALUE_UNDEFINED,
JERRY_CONTEXT (module_state_changed_callback_user_p)); JERRY_CONTEXT (module_state_changed_callback_user_p));
@@ -1333,8 +1317,7 @@ restart:
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t)); jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
last_p = prev_p; last_p = prev_p;
} } while (last_p != end_p);
while (last_p != end_p);
if (current_p == NULL) if (current_p == NULL)
{ {
@@ -1357,8 +1340,7 @@ error:
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t)); jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
last_p = prev_p; last_p = prev_p;
} } while (last_p != NULL);
while (last_p != NULL);
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} /* ecma_module_link */ } /* ecma_module_link */
@@ -1397,8 +1379,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */
goto error; goto error;
} }
if (ecma_is_value_object (result) if (ecma_is_value_object (result) && ecma_is_promise (ecma_get_object_from_value (result)))
&& ecma_is_promise (ecma_get_object_from_value (result)))
{ {
return result; return result;
} }
+3 -4
View File
@@ -16,9 +16,10 @@
#ifndef ECMA_MODULE_H #ifndef ECMA_MODULE_H
#define ECMA_MODULE_H #define ECMA_MODULE_H
#include "common.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "common.h"
#if JERRY_MODULE_SYSTEM #if JERRY_MODULE_SYSTEM
#define ECMA_MODULE_MAX_PATH 255u #define ECMA_MODULE_MAX_PATH 255u
@@ -116,9 +117,7 @@ typedef struct ecma_module_resolve_stack
ecma_value_t ecma_module_initialize (ecma_module_t *module_p); ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val); ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val);
ecma_value_t ecma_module_link (ecma_module_t *module_p, ecma_value_t ecma_module_link (ecma_module_t *module_p, jerry_module_resolve_callback_t callback_p, void *user_p);
jerry_module_resolve_callback_t callback_p,
void *user_p);
ecma_value_t ecma_module_evaluate (ecma_module_t *module_p); ecma_value_t ecma_module_evaluate (ecma_module_t *module_p);
ecma_value_t ecma_module_import (ecma_value_t specifier, ecma_value_t user_value); ecma_value_t ecma_module_import (ecma_value_t specifier, ecma_value_t user_value);
+23 -27
View File
@@ -13,11 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-property-hashmap.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-property-hashmap.h"
#include "jrt-libc-includes.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt-libc-includes.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
@@ -42,28 +44,26 @@
/** /**
* Stepping values for searching items in the hashmap. * Stepping values for searching items in the hashmap.
*/ */
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = {
{
3, 5, 7, 11, 13, 17, 19, 23 3, 5, 7, 11, 13, 17, 19, 23
}; };
/** /**
* Get the value of a bit in a bitmap. * Get the value of a bit in a bitmap.
*/ */
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) \ #define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) ((byte_p)[(index) >> 3] & (1 << ((index) &0x7)))
((byte_p)[(index) >> 3] & (1 << ((index) & 0x7)))
/** /**
* Clear the value of a bit in a bitmap. * Clear the value of a bit in a bitmap.
*/ */
#define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \ #define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) & 0x7)))) ((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) &0x7))))
/** /**
* Set the value of a bit in a bitmap. * Set the value of a bit in a bitmap.
*/ */
#define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \ #define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) & 0x7)))) ((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) &0x7))))
/** /**
* Create a new property hashmap for the object. * Create a new property hashmap for the object.
@@ -156,8 +156,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p; ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], property_pair_p->names_cp[i]);
property_pair_p->names_cp[i]);
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)]; uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
entry_index &= mask; entry_index &= mask;
@@ -202,8 +201,8 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
/* Property hash must be exists and must be the first property. */ /* Property hash must be exists and must be the first property. */
JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL); JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL);
ecma_property_header_t *property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, ecma_property_header_t *property_p =
object_p->u1.property_list_cp); ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, object_p->u1.property_list_cp);
JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP); JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
@@ -211,8 +210,7 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
object_p->u1.property_list_cp = property_p->next_property_cp; object_p->u1.property_list_cp = property_p->next_property_cp;
jmem_heap_free_block (hashmap_p, jmem_heap_free_block (hashmap_p, ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
} /* ecma_property_hashmap_free */ } /* ecma_property_hashmap_free */
/** /**
@@ -226,8 +224,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
{ {
JERRY_ASSERT (property_pair_p != NULL); JERRY_ASSERT (property_pair_p != NULL);
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, ecma_property_hashmap_t *hashmap_p =
object_p->u1.property_list_cp); ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP); JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
@@ -300,8 +298,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
jmem_cpointer_t name_cp, /**< property name */ jmem_cpointer_t name_cp, /**< property name */
ecma_property_t *property_p) /**< property */ ecma_property_t *property_p) /**< property */
{ {
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, ecma_property_hashmap_t *hashmap_p =
object_p->u1.property_list_cp); ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP); JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
@@ -337,8 +335,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
offset = 1; offset = 1;
} }
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, ecma_property_pair_t *property_pair_p =
pair_list_p[entry_index]); ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
if ((property_pair_p->header.types + offset) == property_p) if ((property_pair_p->header.types + offset) == property_p)
{ {
@@ -393,9 +391,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
{ {
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i])) if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
{ {
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
prop_pair_p->names_cp[i],
name_p))
{ {
/* Property is found */ /* Property is found */
property_found = true; property_found = true;
@@ -437,8 +433,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
offset = 1; offset = 1;
} }
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, ecma_property_pair_t *property_pair_p =
pair_list_p[entry_index]); ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
ecma_property_t *property_p = property_pair_p->header.types + offset; ecma_property_t *property_p = property_pair_p->header.types + offset;
@@ -486,8 +482,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
offset = 1; offset = 1;
} }
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, ecma_property_pair_t *property_pair_p =
pair_list_p[entry_index]); ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
ecma_property_t *property_p = property_pair_p->header.types + offset; ecma_property_t *property_p = property_pair_p->header.types + offset;
+10 -5
View File
@@ -16,6 +16,8 @@
#ifndef ECMA_PROPERTY_HASHMAP_H #ifndef ECMA_PROPERTY_HASHMAP_H
#define ECMA_PROPERTY_HASHMAP_H #define ECMA_PROPERTY_HASHMAP_H
#include "ecma-globals.h"
/** \addtogroup ecma ECMA /** \addtogroup ecma ECMA
* @{ * @{
* *
@@ -67,12 +69,15 @@ typedef enum
void ecma_property_hashmap_create (ecma_object_t *object_p); void ecma_property_hashmap_create (ecma_object_t *object_p);
void ecma_property_hashmap_free (ecma_object_t *object_p); void ecma_property_hashmap_free (ecma_object_t *object_p);
void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_p, void ecma_property_hashmap_insert (ecma_object_t *object_p,
ecma_property_pair_t *property_pair_p, int property_index); ecma_string_t *name_p,
ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_pair_t *property_pair_p,
ecma_property_t *property_p); int property_index);
ecma_property_hashmap_delete_status
ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p, ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p,
ecma_string_t *name_p,
jmem_cpointer_t *property_real_name_cp); jmem_cpointer_t *property_real_name_cp);
#endif /* JERRY_PROPERTY_HASHMAP */ #endif /* JERRY_PROPERTY_HASHMAP */
@@ -22,6 +22,7 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-string-object.h" #include "ecma-string-object.h"
#include "jrt.h" #include "jrt.h"
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -25,19 +25,13 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.7.8 */ /* ECMA-262 v5, 15.11.7.8 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_AGGREGATE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_AGGREGATE_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.7.9 */ /* ECMA-262 v5, 15.11.7.9 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
LIT_MAGIC_STRING_AGGREGATE_ERROR_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.7.10 */ /* ECMA-262 v5, 15.11.7.10 */
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
LIT_MAGIC_STRING__EMPTY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -14,19 +14,20 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-array-object.h"
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-builtin-helpers.h"
#include "ecma-objects.h"
#include "ecma-function-object.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-array-object.h" #include "ecma-objects.h"
#include "jrt.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h"
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -24,21 +24,15 @@
/* Number properties: /* Number properties:
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 2, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
2,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.3.1 */ /* ECMA-262 v5, 15.11.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE,
ECMA_PROPERTY_FIXED)
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_AGGREGATE_ERROR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -13,11 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-arraybuffer-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-typedarray-object.h" #include "ecma-typedarray-object.h"
#include "ecma-arraybuffer-object.h"
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -130,10 +130,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
index = (ecma_length_t) (ecma_get_number_from_value (index_value) + 1); index = (ecma_length_t) (ecma_get_number_from_value (index_value) + 1);
} }
ecma_value_t put_result = ecma_op_object_put (obj_p, ecma_value_t put_result = ecma_op_object_put (obj_p, prop_name_p, ecma_make_length_value (index), true);
prop_name_p,
ecma_make_length_value (index),
true);
JERRY_ASSERT (ecma_is_value_true (put_result)); JERRY_ASSERT (ecma_is_value_true (put_result));
@@ -183,8 +180,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
/* 17.b */ /* 17.b */
ecma_value_t entry_array_value; ecma_value_t entry_array_value;
entry_array_value = ecma_create_array_from_iter_element (get_value, entry_array_value = ecma_create_array_from_iter_element (get_value, ecma_make_length_value (index));
ecma_make_length_value (index));
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE); result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
ecma_free_value (entry_array_value); ecma_free_value (entry_array_value);
@@ -21,9 +21,7 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_ITERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -21,49 +21,27 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
SIMPLE_VALUE (LIT_MAGIC_STRING_AT, SIMPLE_VALUE (LIT_MAGIC_STRING_AT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX, SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT, SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP, SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES, SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -26,8 +26,9 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-string-object.h" #include "ecma-string-object.h"
#include "lit-char-helpers.h"
#include "jrt.h" #include "jrt.h"
#include "lit-char-helpers.h"
#if JERRY_BUILTIN_ARRAY #if JERRY_BUILTIN_ARRAY
@@ -45,7 +46,7 @@
enum enum
{ {
ECMA_ARRAY_PROTOTYPE_ROUTINE_START = 0, ECMA_ARRAY_PROTOTYPE_ROUTINE_START = 0,
/* Note: these 2 routine ids must be in this order */ /* Note: these 2 routine ids must be in this order */
#if !JERRY_ESNEXT #if !JERRY_ESNEXT
ECMA_ARRAY_PROTOTYPE_TO_STRING, ECMA_ARRAY_PROTOTYPE_TO_STRING,
#endif /* !JERRY_ESNEXT */ #endif /* !JERRY_ESNEXT */
@@ -109,15 +110,12 @@ ecma_builtin_array_prototype_helper_set_length (ecma_object_t *object, /**< obje
ecma_number_t length) /**< new length */ ecma_number_t length) /**< new length */
{ {
ecma_value_t length_value = ecma_make_number_value (length); ecma_value_t length_value = ecma_make_number_value (length);
ecma_value_t ret_value = ecma_op_object_put (object, ecma_value_t ret_value =
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), ecma_op_object_put (object, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), length_value, true);
length_value,
true);
ecma_free_value (length_value); ecma_free_value (length_value);
JERRY_ASSERT (ecma_is_value_boolean (ret_value) JERRY_ASSERT (ecma_is_value_boolean (ret_value) || ecma_is_value_empty (ret_value)
|| ecma_is_value_empty (ret_value)
|| ECMA_IS_VALUE_ERROR (ret_value)); || ECMA_IS_VALUE_ERROR (ret_value));
return ret_value; return ret_value;
} /* ecma_builtin_array_prototype_helper_set_length */ } /* ecma_builtin_array_prototype_helper_set_length */
@@ -202,9 +200,8 @@ ecma_builtin_array_prototype_object_concat (const ecma_value_t args[], /**< argu
ecma_length_t new_length = 0; ecma_length_t new_length = 0;
/* 5.b - 5.c for this_arg */ /* 5.b - 5.c for this_arg */
ecma_value_t concat_this_value = ecma_builtin_helper_array_concat_value (new_array_p, ecma_value_t concat_this_value =
&new_length, ecma_builtin_helper_array_concat_value (new_array_p, &new_length, ecma_make_object_value (obj_p));
ecma_make_object_value (obj_p));
if (ECMA_IS_VALUE_ERROR (concat_this_value)) if (ECMA_IS_VALUE_ERROR (concat_this_value))
{ {
ecma_deref_object (new_array_p); ecma_deref_object (new_array_p);
@@ -227,8 +224,8 @@ ecma_builtin_array_prototype_object_concat (const ecma_value_t args[], /**< argu
JERRY_ASSERT (ecma_is_value_empty (concat_value)); JERRY_ASSERT (ecma_is_value_empty (concat_value));
} }
ecma_value_t set_length_value = ecma_builtin_array_prototype_helper_set_length (new_array_p, ecma_value_t set_length_value =
((ecma_number_t) new_length)); ecma_builtin_array_prototype_helper_set_length (new_array_p, ((ecma_number_t) new_length));
if (ECMA_IS_VALUE_ERROR (set_length_value)) if (ECMA_IS_VALUE_ERROR (set_length_value))
{ {
ecma_deref_object (new_array_p); ecma_deref_object (new_array_p);
@@ -279,8 +276,7 @@ ecma_op_array_get_to_string_at_index (ecma_object_t *obj_p, /**< this object */
return NULL; return NULL;
} }
if (ecma_is_value_undefined (index_value) if (ecma_is_value_undefined (index_value) || ecma_is_value_null (index_value))
|| ecma_is_value_null (index_value))
{ {
return ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY); return ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
} }
@@ -523,14 +519,12 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg, /**< this ar
ecma_object_t *obj_p, /**< object */ ecma_object_t *obj_p, /**< object */
ecma_length_t len) /**< object's length */ ecma_length_t len) /**< object's length */
{ {
if (ecma_op_object_is_fast_array (obj_p)) if (ecma_op_object_is_fast_array (obj_p))
{ {
uint32_t middle = (uint32_t) len / 2; uint32_t middle = (uint32_t) len / 2;
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
&& len != 0)
{ {
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp); ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);
@@ -674,7 +668,7 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg, /**< this ar
ret_value = ECMA_VALUE_EMPTY; ret_value = ECMA_VALUE_EMPTY;
clean_up: clean_up:
ecma_free_value (upper_value); ecma_free_value (upper_value);
ecma_free_value (lower_value); ecma_free_value (lower_value);
ecma_deref_ecma_string (lower_str_p); ecma_deref_ecma_string (lower_str_p);
@@ -714,8 +708,7 @@ ecma_builtin_array_prototype_object_shift (ecma_object_t *obj_p, /**< object */
{ {
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
&& len != 0)
{ {
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp); ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);
ecma_value_t ret_value = buffer_p[0]; ecma_value_t ret_value = buffer_p[0];
@@ -817,9 +810,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
ecma_length_t start = 0, end = len; ecma_length_t start = 0, end = len;
/* 5. 6.*/ /* 5. 6.*/
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1, if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1, len, &start)))
len,
&start)))
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
@@ -832,9 +823,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
else else
{ {
/* 7. part 2, 8.*/ /* 7. part 2, 8.*/
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2, if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2, len, &end)))
len,
&end)))
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
@@ -946,10 +935,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
#else /* !JERRY_ESNEXT */ #else /* !JERRY_ESNEXT */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, n, get_value, prop_flags);
n,
get_value,
prop_flags);
ecma_free_value (get_value); ecma_free_value (get_value);
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -1057,10 +1043,7 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t lhs, /**<
ecma_value_t compare_args[] = { lhs, rhs }; ecma_value_t compare_args[] = { lhs, rhs };
ecma_value_t call_value = ecma_op_function_call (comparefn_obj_p, ecma_value_t call_value = ecma_op_function_call (comparefn_obj_p, ECMA_VALUE_UNDEFINED, compare_args, 2);
ECMA_VALUE_UNDEFINED,
compare_args,
2);
if (ECMA_IS_VALUE_ERROR (call_value)) if (ECMA_IS_VALUE_ERROR (call_value))
{ {
return call_value; return call_value;
@@ -1178,11 +1161,8 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
if (copied_num > 1) if (copied_num > 1)
{ {
const ecma_builtin_helper_sort_compare_fn_t sort_cb = &ecma_builtin_array_prototype_object_sort_compare_helper; const ecma_builtin_helper_sort_compare_fn_t sort_cb = &ecma_builtin_array_prototype_object_sort_compare_helper;
ecma_value_t sort_value = ecma_builtin_helper_array_merge_sort_helper (values_buffer, ecma_value_t sort_value =
(uint32_t) (copied_num), ecma_builtin_helper_array_merge_sort_helper (values_buffer, (uint32_t) (copied_num), arg1, sort_cb, NULL);
arg1,
sort_cb,
NULL);
if (ECMA_IS_VALUE_ERROR (sort_value)) if (ECMA_IS_VALUE_ERROR (sort_value))
{ {
goto clean_up; goto clean_up;
@@ -1271,9 +1251,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
if (args_number > 0) if (args_number > 0)
{ {
/* ES5.1: 6, ES11: 4. */ /* ES5.1: 6, ES11: 4. */
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (args[0], if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (args[0], len, &actual_start)))
len,
&actual_start)))
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
@@ -1295,8 +1273,8 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
} }
/* ES5.1: 7 */ /* ES5.1: 7 */
actual_delete_count = (ecma_length_t) (JERRY_MIN (JERRY_MAX (delete_num, 0), actual_delete_count =
(ecma_number_t) (len - actual_start))); (ecma_length_t) (JERRY_MIN (JERRY_MAX (delete_num, 0), (ecma_number_t) (len - actual_start)));
} }
} }
@@ -1344,10 +1322,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, k, from_present, prop_flags);
k,
from_present,
prop_flags);
ecma_free_value (from_present); ecma_free_value (from_present);
#if JERRY_ESNEXT #if JERRY_ESNEXT
@@ -1364,8 +1339,8 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ES11: 12. */ /* ES11: 12. */
ecma_value_t set_length = ecma_builtin_array_prototype_helper_set_length (new_array_p, ecma_value_t set_length =
((ecma_number_t) actual_delete_count)); ecma_builtin_array_prototype_helper_set_length (new_array_p, ((ecma_number_t) actual_delete_count));
if (ECMA_IS_VALUE_ERROR (set_length)) if (ECMA_IS_VALUE_ERROR (set_length))
{ {
@@ -1465,10 +1440,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
uint32_t idx = 0; uint32_t idx = 0;
for (uint32_t arg_index = 2; arg_index < args_number; arg_index++, idx++) for (uint32_t arg_index = 2; arg_index < args_number; arg_index++, idx++)
{ {
ecma_value_t put_value = ecma_op_object_put_by_index (obj_p, ecma_value_t put_value = ecma_op_object_put_by_index (obj_p, actual_start + idx, args[arg_index], true);
actual_start + idx,
args[arg_index],
true);
if (ECMA_IS_VALUE_ERROR (put_value)) if (ECMA_IS_VALUE_ERROR (put_value))
{ {
@@ -1506,13 +1478,11 @@ ecma_builtin_array_prototype_object_unshift (const ecma_value_t args[], /**< arg
ecma_object_t *obj_p, /**< object */ ecma_object_t *obj_p, /**< object */
ecma_length_t len) /**< object's length */ ecma_length_t len) /**< object's length */
{ {
if (ecma_op_object_is_fast_array (obj_p)) if (ecma_op_object_is_fast_array (obj_p))
{ {
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
&& len != 0)
{ {
if (args_number > UINT32_MAX - len) if (args_number > UINT32_MAX - len)
{ {
@@ -1730,8 +1700,7 @@ ecma_builtin_array_prototype_object_index_of (const ecma_value_t args[], /**< ar
} }
/* 9.b.i, 9.b.ii */ /* 9.b.i, 9.b.ii */
if (ecma_is_value_found (get_value) if (ecma_is_value_found (get_value) && ecma_op_strict_equality_compare (args[0], get_value))
&& ecma_op_strict_equality_compare (args[0], get_value))
{ {
ecma_free_value (get_value); ecma_free_value (get_value);
return ecma_make_length_value (from_idx); return ecma_make_length_value (from_idx);
@@ -1834,8 +1803,7 @@ ecma_builtin_array_prototype_object_last_index_of (const ecma_value_t args[], /*
} }
/* 8.b.i, 8.b.ii */ /* 8.b.i, 8.b.ii */
if (ecma_is_value_found (get_value) if (ecma_is_value_found (get_value) && ecma_op_strict_equality_compare (search_element, get_value))
&& ecma_op_strict_equality_compare (search_element, get_value))
{ {
ecma_free_value (get_value); ecma_free_value (get_value);
return ecma_make_length_value (from_idx); return ecma_make_length_value (from_idx);
@@ -2023,10 +1991,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */
#else /* !JERRY_ESNEXT */ #else /* !JERRY_ESNEXT */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE; const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, index, mapped_value, prop_flags);
index,
mapped_value,
prop_flags);
ecma_free_value (mapped_value); ecma_free_value (mapped_value);
ecma_free_value (current_value); ecma_free_value (current_value);
@@ -2124,10 +2089,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn *
if (ecma_op_to_boolean (call_value)) if (ecma_op_to_boolean (call_value))
{ {
ecma_value_t put_comp; ecma_value_t put_comp;
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, new_array_index, get_value, prop_flags);
new_array_index,
get_value,
prop_flags);
#if JERRY_ESNEXT #if JERRY_ESNEXT
if (ECMA_IS_VALUE_ERROR (put_comp)) if (ECMA_IS_VALUE_ERROR (put_comp))
{ {
@@ -2206,8 +2168,7 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu
k_present = true; k_present = true;
/* 8.b.ii-iii */ /* 8.b.ii-iii */
ecma_value_t current_value = ecma_op_object_find_by_index (obj_p, start_from_left ? index ecma_value_t current_value = ecma_op_object_find_by_index (obj_p, start_from_left ? index : last_index - index);
: last_index - index);
if (ECMA_IS_VALUE_ERROR (current_value)) if (ECMA_IS_VALUE_ERROR (current_value))
{ {
@@ -2253,12 +2214,9 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu
{ {
/* 9.c.i, 9.c.ii */ /* 9.c.i, 9.c.ii */
current_index = ecma_make_length_value (corrected_index); current_index = ecma_make_length_value (corrected_index);
ecma_value_t call_args[] = {accumulator, current_value, current_index, ecma_make_object_value (obj_p)}; ecma_value_t call_args[] = { accumulator, current_value, current_index, ecma_make_object_value (obj_p) };
ecma_value_t call_value = ecma_op_function_call (func_object_p, ecma_value_t call_value = ecma_op_function_call (func_object_p, ECMA_VALUE_UNDEFINED, call_args, 4);
ECMA_VALUE_UNDEFINED,
call_args,
4);
ecma_free_value (current_index); ecma_free_value (current_index);
ecma_free_value (accumulator); ecma_free_value (accumulator);
ecma_free_value (current_value); ecma_free_value (current_value);
@@ -2298,9 +2256,7 @@ ecma_builtin_array_prototype_fill (ecma_value_t value, /**< value */
ecma_length_t k, final; ecma_length_t k, final;
/* 5. 6. 7. */ /* 5. 6. 7. */
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (start_val, if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (start_val, len, &k)))
len,
&k)))
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
@@ -2313,9 +2269,7 @@ ecma_builtin_array_prototype_fill (ecma_value_t value, /**< value */
else else
{ {
/* 8 part 2, 9, 10 */ /* 8 part 2, 9, 10 */
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (end_val, if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (end_val, len, &final)))
len,
&final)))
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
@@ -2728,7 +2682,7 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
{ {
/* i-ii. */ /* i-ii. */
ecma_value_t source_val = ecma_make_length_value (source_index); ecma_value_t source_val = ecma_make_length_value (source_index);
ecma_value_t args[] = {element, source_val, ecma_make_object_value (source)}; ecma_value_t args[] = { element, source_val, ecma_make_object_value (source) };
ecma_value_t temp_element = ecma_op_function_call (ecma_get_object_from_value (mapped_value), thisArg, args, 3); ecma_value_t temp_element = ecma_op_function_call (ecma_get_object_from_value (mapped_value), thisArg, args, 3);
ecma_free_value (element); ecma_free_value (element);
@@ -2787,10 +2741,8 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
/* vi. */ /* vi. */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW; const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
ecma_value_t element_temp = ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target), ecma_value_t element_temp =
target_index, ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target), target_index, element, flags);
element,
flags);
ecma_free_value (element); ecma_free_value (element);
@@ -2885,13 +2837,8 @@ ecma_builtin_array_prototype_object_flat_map (ecma_value_t callback, /**< callba
} }
/* 5. */ /* 5. */
ecma_value_t flatten_val = ecma_builtin_array_flatten_into_array (ecma_make_object_value (new_array_p), ecma_value_t flatten_val =
obj_p, ecma_builtin_array_flatten_into_array (ecma_make_object_value (new_array_p), obj_p, len, 0, 1, callback, this_arg);
len,
0,
1,
callback,
this_arg);
if (ECMA_IS_VALUE_ERROR (flatten_val)) if (ECMA_IS_VALUE_ERROR (flatten_val))
{ {
ecma_deref_object (new_array_p); ecma_deref_object (new_array_p);
@@ -2937,16 +2884,11 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
#endif /* !JERRY_ESNEXT */ #endif /* !JERRY_ESNEXT */
if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_SORT) if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_SORT)
{ {
ret_value = ecma_builtin_array_prototype_object_sort (this_arg, ret_value = ecma_builtin_array_prototype_object_sort (this_arg, arguments_list_p[0], obj_p);
arguments_list_p[0],
obj_p);
} }
else if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_CONCAT) else if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_CONCAT)
{ {
ret_value = ecma_builtin_array_prototype_object_concat (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_concat (arguments_list_p, arguments_number, obj_p);
arguments_number,
obj_p);
} }
ecma_deref_object (obj_p); ecma_deref_object (obj_p);
@@ -3004,10 +2946,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
} }
case ECMA_ARRAY_PROTOTYPE_PUSH: case ECMA_ARRAY_PROTOTYPE_PUSH:
{ {
ret_value = ecma_builtin_array_prototype_object_push (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_push (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_REVERSE: case ECMA_ARRAY_PROTOTYPE_REVERSE:
@@ -3022,49 +2961,32 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
} }
case ECMA_ARRAY_PROTOTYPE_SLICE: case ECMA_ARRAY_PROTOTYPE_SLICE:
{ {
ret_value = ecma_builtin_array_prototype_object_slice (arguments_list_p[0], ret_value = ecma_builtin_array_prototype_object_slice (arguments_list_p[0], arguments_list_p[1], obj_p, length);
arguments_list_p[1],
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_SPLICE: case ECMA_ARRAY_PROTOTYPE_SPLICE:
{ {
ret_value = ecma_builtin_array_prototype_object_splice (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_splice (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_UNSHIFT: case ECMA_ARRAY_PROTOTYPE_UNSHIFT:
{ {
ret_value = ecma_builtin_array_prototype_object_unshift (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_unshift (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_AT: case ECMA_ARRAY_PROTOTYPE_AT:
{ {
ret_value = ecma_builtin_array_prototype_object_at (arguments_list_p[0], ret_value = ecma_builtin_array_prototype_object_at (arguments_list_p[0], obj_p, length);
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_INDEX_OF: case ECMA_ARRAY_PROTOTYPE_INDEX_OF:
{ {
ret_value = ecma_builtin_array_prototype_object_index_of (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_index_of (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_LAST_INDEX_OF: case ECMA_ARRAY_PROTOTYPE_LAST_INDEX_OF:
{ {
ret_value = ecma_builtin_array_prototype_object_last_index_of (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_last_index_of (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_EVERY: case ECMA_ARRAY_PROTOTYPE_EVERY:
@@ -3080,10 +3002,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
} }
case ECMA_ARRAY_PROTOTYPE_MAP: case ECMA_ARRAY_PROTOTYPE_MAP:
{ {
ret_value = ecma_builtin_array_prototype_object_map (arguments_list_p[0], ret_value = ecma_builtin_array_prototype_object_map (arguments_list_p[0], arguments_list_p[1], obj_p, length);
arguments_list_p[1],
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_REDUCE: case ECMA_ARRAY_PROTOTYPE_REDUCE:
@@ -3099,10 +3018,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
#if JERRY_ESNEXT #if JERRY_ESNEXT
case ECMA_ARRAY_PROTOTYPE_COPY_WITHIN: case ECMA_ARRAY_PROTOTYPE_COPY_WITHIN:
{ {
ret_value = ecma_builtin_array_prototype_object_copy_within (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_copy_within (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_FIND: case ECMA_ARRAY_PROTOTYPE_FIND:
@@ -3126,26 +3042,18 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
} }
case ECMA_ARRAY_PROTOTYPE_INCLUDES: case ECMA_ARRAY_PROTOTYPE_INCLUDES:
{ {
ret_value = ecma_builtin_array_prototype_includes (arguments_list_p, ret_value = ecma_builtin_array_prototype_includes (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_FLAT: case ECMA_ARRAY_PROTOTYPE_FLAT:
{ {
ret_value = ecma_builtin_array_prototype_object_flat (arguments_list_p, ret_value = ecma_builtin_array_prototype_object_flat (arguments_list_p, arguments_number, obj_p, length);
arguments_number,
obj_p,
length);
break; break;
} }
case ECMA_ARRAY_PROTOTYPE_FLATMAP: case ECMA_ARRAY_PROTOTYPE_FLATMAP:
{ {
ret_value = ecma_builtin_array_prototype_object_flat_map (arguments_list_p[0], ret_value =
arguments_list_p[1], ecma_builtin_array_prototype_object_flat_map (arguments_list_p[0], arguments_list_p[1], obj_p, length);
obj_p,
length);
break; break;
} }
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -3153,10 +3061,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
{ {
JERRY_ASSERT (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_FILTER); JERRY_ASSERT (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_FILTER);
ret_value = ecma_builtin_array_prototype_object_filter (arguments_list_p[0], ret_value = ecma_builtin_array_prototype_object_filter (arguments_list_p[0], arguments_list_p[1], obj_p, length);
arguments_list_p[1],
obj_p,
length);
break; break;
} }
} }
@@ -25,9 +25,7 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.4.1 */ /* ECMA-262 v5, 15.4.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v6, 22.1.3.31 */ /* ECMA-262 v6, 22.1.3.31 */
@@ -40,9 +38,7 @@ OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.4 */ /* ECMA-262 v5, 15.4.4 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_WRITABLE)
0,
ECMA_PROPERTY_FLAG_WRITABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -82,11 +78,12 @@ ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1) ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0) ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0)
ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1) ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL, INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES,
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES, INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -14,8 +14,9 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtins.h" #include "ecma-array-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
@@ -24,7 +25,7 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-array-object.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h" #include "jrt.h"
@@ -185,10 +186,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
{ {
/* 6.g.iv.1 */ /* 6.g.iv.1 */
ecma_value_t len_value = ecma_make_uint32_value (k); ecma_value_t len_value = ecma_make_uint32_value (k);
ecma_value_t set_status = ecma_op_object_put (array_obj_p, ecma_value_t set_status =
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
len_value,
true);
ecma_free_value (len_value); ecma_free_value (len_value);
/* 6.g.iv.2 */ /* 6.g.iv.2 */
@@ -255,7 +254,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
k++; k++;
} }
iterator_cleanup: iterator_cleanup:
ecma_free_value (iterator); ecma_free_value (iterator);
ecma_free_value (next_method); ecma_free_value (next_method);
ecma_deref_object (array_obj_p); ecma_deref_object (array_obj_p);
@@ -376,10 +375,8 @@ iterator_cleanup:
/* 17. */ /* 17. */
len_value = ecma_make_length_value (k); len_value = ecma_make_length_value (k);
ecma_value_t set_status = ecma_op_object_put (array_obj_p, ecma_value_t set_status =
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
len_value,
true);
ecma_free_value (len_value); ecma_free_value (len_value);
/* 18. */ /* 18. */
@@ -420,10 +417,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
ecma_value_t len = ecma_make_uint32_value (arguments_list_len); ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
ecma_value_t ret_val = ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_value_t ret_val =
ecma_get_object_from_value (this_arg), ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_get_object_from_value (this_arg), &len, 1);
&len,
1);
if (ECMA_IS_VALUE_ERROR (ret_val)) if (ECMA_IS_VALUE_ERROR (ret_val))
{ {
@@ -437,10 +432,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
while (k < arguments_list_len) while (k < arguments_list_len)
{ {
ecma_value_t define_status = ecma_builtin_helper_def_prop_by_index (obj_p, ecma_value_t define_status =
k, ecma_builtin_helper_def_prop_by_index (obj_p, k, arguments_list_p[k], prop_status_flags);
arguments_list_p[k],
prop_status_flags);
if (ECMA_IS_VALUE_ERROR (define_status)) if (ECMA_IS_VALUE_ERROR (define_status))
{ {
@@ -452,10 +445,7 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
k++; k++;
} }
ret_val = ecma_op_object_put (obj_p, ret_val = ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len, true);
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
len,
true);
ecma_free_value (len); ecma_free_value (len);
@@ -482,8 +472,7 @@ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
{ {
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
if (arguments_list_len != 1 if (arguments_list_len != 1 || !ecma_is_value_number (arguments_list_p[0]))
|| !ecma_is_value_number (arguments_list_p[0]))
{ {
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len); return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
} }
@@ -514,8 +503,8 @@ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**
#if !JERRY_ESNEXT #if !JERRY_ESNEXT
return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len); return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
#else /* JERRY_ESNEXT */ #else /* JERRY_ESNEXT */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ecma_object_t *proto_p =
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE); ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
if (proto_p == NULL) if (proto_p == NULL)
{ {
@@ -25,21 +25,15 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.4.3.1 */ /* ECMA-262 v5, 15.4.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE,
ECMA_PROPERTY_FIXED)
/* Number properties: /* Number properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
1,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ARRAY_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
/* Routine properties: /* Routine properties:
@@ -50,9 +44,7 @@ ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0) ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
/* ECMA-262 v6, 22.1.2.5 */ /* ECMA-262 v6, 22.1.2.5 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAY_ROUTINE_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_ARRAY_ROUTINE_SPECIES_GET,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#endif /* !(JERRY_BUILTIN_ARRAY) */ #endif /* !(JERRY_BUILTIN_ARRAY) */
@@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-arraybuffer-object.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
@@ -22,9 +23,9 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-arraybuffer-object.h"
#include "jrt.h"
#include "jrt-libc-includes.h" #include "jrt-libc-includes.h"
#include "jrt.h"
#if JERRY_BUILTIN_TYPEDARRAY #if JERRY_BUILTIN_TYPEDARRAY
@@ -24,9 +24,7 @@
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ARRAYBUFFER,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* Readonly accessor properties */ /* Readonly accessor properties */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL, ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
@@ -34,9 +32,7 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE) ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 24.1.4.4 */ /* ECMA-262 v6, 24.1.4.4 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -13,14 +13,15 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-arraybuffer-object.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-dataview-object.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-arraybuffer-object.h"
#include "ecma-dataview-object.h"
#include "ecma-typedarray-object.h" #include "ecma-typedarray-object.h"
#include "jrt.h" #include "jrt.h"
#if JERRY_BUILTIN_TYPEDARRAY #if JERRY_BUILTIN_TYPEDARRAY
@@ -24,20 +24,14 @@
/* Number properties: /* Number properties:
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
ECMA_PROPERTY_FIXED)
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -46,9 +40,7 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME,
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1) ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
/* ES2015 24.1.3.3 */ /* ES2015 24.1.3.3 */
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ecma_builtin_arraybuffer_species_get, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ecma_builtin_arraybuffer_species_get,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_BUILTIN_TYPEDARRAY */ #endif /* JERRY_BUILTIN_TYPEDARRAY */
@@ -13,6 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
#include "jerryscript-types.h"
#include "ecma-builtin-handlers.h" #include "ecma-builtin-handlers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
@@ -23,8 +25,8 @@
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-promise-object.h" #include "ecma-promise-object.h"
#include "jcontext.h" #include "jcontext.h"
#include "jerryscript-types.h"
#include "jrt.h" #include "jrt.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
#include "lit-strings.h" #include "lit-strings.h"
@@ -146,9 +148,8 @@ ecma_builtin_async_from_sync_iterator_prototype_next (ecma_async_from_sync_itera
ecma_value_t value) /**< routine's 'value' argument */ ecma_value_t value) /**< routine's 'value' argument */
{ {
/* 5. */ /* 5. */
ecma_value_t next_result = ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, ecma_value_t next_result =
iter_p->sync_next_method, ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, iter_p->sync_next_method, value);
value);
/* 6. */ /* 6. */
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p))) if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p)))
@@ -224,10 +225,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
} }
/* 7.b. */ /* 7.b. */
ecma_value_t resolve = ecma_op_function_call (ecma_get_object_from_value (func_obj), ecma_value_t resolve =
ECMA_VALUE_UNDEFINED, ecma_op_function_call (ecma_get_object_from_value (func_obj), ECMA_VALUE_UNDEFINED, &call_arg, arg_size);
&call_arg,
arg_size);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (resolve)); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (resolve));
ecma_free_value (resolve); ecma_free_value (resolve);
@@ -273,10 +272,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
ecma_value_t type_error = ecma_make_object_value (type_error_obj_p); ecma_value_t type_error = ecma_make_object_value (type_error_obj_p);
/* 10.a. */ /* 10.a. */
ecma_value_t reject = ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ecma_value_t reject =
ECMA_VALUE_UNDEFINED, ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &type_error, 1);
&type_error,
1);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (reject)); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (reject));
ecma_deref_object (type_error_obj_p); ecma_deref_object (type_error_obj_p);
ecma_free_value (reject); ecma_free_value (reject);
@@ -22,14 +22,10 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v11, 25.7.3.1 */ /* ECMA-262 v11, 25.7.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_ASYNC_FUNCTION,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v11, 25.7.3.2 */ /* ECMA-262 v11, 25.7.3.2 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -47,9 +47,7 @@ ecma_builtin_async_function_dispatch_call (const ecma_value_t *arguments_list_p,
{ {
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
return ecma_op_create_dynamic_function (arguments_list_p, return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_ASYNC_FUNCTION);
arguments_list_len,
ECMA_PARSE_ASYNC_FUNCTION);
} /* ecma_builtin_async_function_dispatch_call */ } /* ecma_builtin_async_function_dispatch_call */
/** /**
@@ -22,24 +22,16 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v11, 25.7.2 */ /* ECMA-262 v11, 25.7.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v11, 25.7.2.1 */ /* ECMA-262 v11, 25.7.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v10, 25.7.2.2 */ /* ECMA-262 v10, 25.7.2.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE,
ECMA_PROPERTY_FIXED)
/* ECMA-262 v11, 25.7.3.2 */ /* ECMA-262 v11, 25.7.3.2 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -22,19 +22,13 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v10, 25.3.2 */ /* ECMA-262 v10, 25.3.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v10, 25.3.2.1 */ /* ECMA-262 v10, 25.3.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.2 */ /* ECMA-262 v6, 25.3.2.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
ECMA_PROPERTY_FIXED)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -21,6 +21,7 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-promise-object.h" #include "ecma-promise-object.h"
#include "jcontext.h" #include "jcontext.h"
#include "opcodes.h" #include "opcodes.h"
#include "vm-defines.h" #include "vm-defines.h"
@@ -64,7 +65,7 @@ enum
* Convert routine type to operation type.. * Convert routine type to operation type..
*/ */
#define ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION(type) \ #define ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION(type) \
((ecma_async_generator_operation_type_t) ((type) - ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT)) ((ecma_async_generator_operation_type_t) ((type) -ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT) JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
== ECMA_ASYNC_GENERATOR_DO_NEXT, == ECMA_ASYNC_GENERATOR_DO_NEXT,
@@ -25,14 +25,10 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v6, 25.3.1.5 */ /* ECMA-262 v6, 25.3.1.5 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_GENERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ASYNC_GENERATOR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.3.1 */ /* ECMA-262 v6, 25.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -22,14 +22,10 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v6, 25.3.2.3.1 */ /* ECMA-262 v6, 25.3.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.3.2 */ /* ECMA-262 v6, 25.3.2.3.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.3.3 */ /* ECMA-262 v6, 25.3.2.3.3 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
@@ -17,6 +17,7 @@
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jrt.h" #include "jrt.h"
#if JERRY_BUILTIN_ATOMICS #if JERRY_BUILTIN_ATOMICS
@@ -22,9 +22,7 @@
#if JERRY_BUILTIN_ATOMICS #if JERRY_BUILTIN_ATOMICS
/* ECMA-262 v11, 24.4.14 */ /* ECMA-262 v11, 24.4.14 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ATOMICS_U, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ATOMICS_U,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -25,14 +25,10 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v11, 20.2.3.1 */ /* ECMA-262 v11, 20.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_BIGINT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_BIGINT,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v11, 20.2.3.5 */ /* ECMA-262 v11, 20.2.3.5 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_BIGINT_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_BIGINT_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -25,22 +25,16 @@
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v11, 20.2.1 */ /* ECMA-262 v11, 20.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v11, 20.2.1 */ /* ECMA-262 v11, 20.2.1 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_BIGINT_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_BIGINT_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v11, 20.2.2.3 */ /* ECMA-262 v11, 20.2.2.3 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_BIGINT_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_BIGINT_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
@@ -22,6 +22,7 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-string-object.h" #include "ecma-string-object.h"
#include "jrt.h" #include "jrt.h"
#if JERRY_BUILTIN_BOOLEAN #if JERRY_BUILTIN_BOOLEAN
@@ -25,9 +25,7 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.6.4.1 */ /* ECMA-262 v5, 15.6.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_BOOLEAN, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_BOOLEAN,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -22,6 +22,7 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "jrt.h" #include "jrt.h"
#if JERRY_BUILTIN_BOOLEAN #if JERRY_BUILTIN_BOOLEAN
@@ -25,21 +25,15 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.6.3.1 */ /* ECMA-262 v5, 15.6.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
ECMA_PROPERTY_FIXED)
/* Number properties: /* Number properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
1,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_BOOLEAN_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_BOOLEAN_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#endif /* JERRY_BUILTIN_BOOLEAN */ #endif /* JERRY_BUILTIN_BOOLEAN */
@@ -14,8 +14,8 @@
*/ */
#include "ecma-arraybuffer-object.h" #include "ecma-arraybuffer-object.h"
#include "ecma-exceptions.h"
#include "ecma-dataview-object.h" #include "ecma-dataview-object.h"
#include "ecma-exceptions.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#if JERRY_BUILTIN_DATAVIEW #if JERRY_BUILTIN_DATAVIEW
@@ -179,7 +179,8 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
return ecma_op_dataview_get_set_view_value (this_arg, return ecma_op_dataview_get_set_view_value (this_arg,
arguments_list_p[0], arguments_list_p[0],
arguments_list_p[1], arguments_list_p[1],
ECMA_VALUE_EMPTY, id); ECMA_VALUE_EMPTY,
id);
} }
case ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32: case ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32:
#if JERRY_NUMBER_TYPE_FLOAT64 #if JERRY_NUMBER_TYPE_FLOAT64
@@ -25,14 +25,10 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v6, 24.2.3 */ /* ECMA-262 v6, 24.2.3 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_DATAVIEW, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_DATAVIEW,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v6, 23.2.4.21 */ /* ECMA-262 v6, 23.2.4.21 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_DATAVIEW_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -64,9 +60,7 @@ ROUTINE (LIT_MAGIC_STRING_SET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64,
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
/* ECMA-262 v6, 24.2.4.1 */ /* ECMA-262 v6, 24.2.4.1 */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER, ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER, ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 24.2.4.2 */ /* ECMA-262 v6, 24.2.4.2 */
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL, ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
@@ -14,8 +14,8 @@
*/ */
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-exceptions.h"
#include "ecma-dataview-object.h" #include "ecma-dataview-object.h"
#include "ecma-exceptions.h"
#if JERRY_BUILTIN_DATAVIEW #if JERRY_BUILTIN_DATAVIEW
@@ -25,22 +25,16 @@
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v6, 23.1.2 */ /* ECMA-262 v6, 23.1.2 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 23.1 */ /* ECMA-262 v6, 23.1 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_DATAVIEW_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v6, 23.1.2.1 */ /* ECMA-262 v6, 23.1.2.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#endif /* JERRY_BUILTIN_DATAVIEW */ #endif /* JERRY_BUILTIN_DATAVIEW */
@@ -22,8 +22,8 @@
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h" #include "ecma-objects-general.h"
#include "ecma-objects.h"
#if JERRY_BUILTIN_DATE #if JERRY_BUILTIN_DATE
@@ -39,7 +39,7 @@
* Checks whether the function uses UTC time zone. * Checks whether the function uses UTC time zone.
*/ */
#define BUILTIN_DATE_FUNCTION_IS_UTC(builtin_routine_id) \ #define BUILTIN_DATE_FUNCTION_IS_UTC(builtin_routine_id) \
(((builtin_routine_id) - ECMA_DATE_PROTOTYPE_GET_FULL_YEAR) & 0x1) (((builtin_routine_id) -ECMA_DATE_PROTOTYPE_GET_FULL_YEAR) & 0x1)
/** /**
* List of built-in routine identifiers. * List of built-in routine identifiers.
@@ -677,7 +677,6 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS) if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS)
{ {
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_GET_UTC_TIMEZONE_OFFSET) if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_GET_UTC_TIMEZONE_OFFSET)
{ {
if (!BUILTIN_DATE_FUNCTION_IS_UTC (builtin_routine_id)) if (!BUILTIN_DATE_FUNCTION_IS_UTC (builtin_routine_id))
@@ -706,10 +705,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
return ecma_builtin_date_prototype_dispatch_get (builtin_routine_id, date_value); return ecma_builtin_date_prototype_dispatch_get (builtin_routine_id, date_value);
} }
return ecma_builtin_date_prototype_dispatch_set (builtin_routine_id, return ecma_builtin_date_prototype_dispatch_set (builtin_routine_id, this_obj_p, arguments_list, arguments_number);
this_obj_p,
arguments_list,
arguments_number);
} }
if (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_ISO_STRING) if (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_ISO_STRING)
@@ -21,9 +21,7 @@
#if JERRY_BUILTIN_DATE #if JERRY_BUILTIN_DATE
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_DATE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_DATE,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_STRING, 0, 0) ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_STRING, 0, 0)
ROUTINE (LIT_MAGIC_STRING_TO_DATE_STRING_UL, ECMA_DATE_PROTOTYPE_TO_DATE_STRING, 0, 0) ROUTINE (LIT_MAGIC_STRING_TO_DATE_STRING_UL, ECMA_DATE_PROTOTYPE_TO_DATE_STRING, 0, 0)
@@ -69,10 +67,12 @@ ROUTINE (LIT_MAGIC_STRING_TO_ISO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_ISO_STRING, 0
ROUTINE (LIT_MAGIC_STRING_TO_JSON_UL, ECMA_DATE_PROTOTYPE_TO_JSON, 1, 1) ROUTINE (LIT_MAGIC_STRING_TO_JSON_UL, ECMA_DATE_PROTOTYPE_TO_JSON, 1, 1)
#if JERRY_ESNEXT #if JERRY_ESNEXT
ROUTINE_CONFIGURABLE_ONLY (LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, 1, 1) ROUTINE_CONFIGURABLE_ONLY (LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, 1, 1)
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL, INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL,
LIT_MAGIC_STRING_TO_UTC_STRING_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if JERRY_BUILTIN_ANNEXB #if JERRY_BUILTIN_ANNEXB
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL, INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL,
LIT_MAGIC_STRING_TO_UTC_STRING_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_ANNEXB */ #endif /* JERRY_BUILTIN_ANNEXB */
#else /* !JERRY_ESNEXT */ #else /* !JERRY_ESNEXT */
@@ -15,15 +15,16 @@
#include <math.h> #include <math.h>
#include "jcontext.h"
#include "ecma-function-object.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jcontext.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#if JERRY_BUILTIN_DATE #if JERRY_BUILTIN_DATE
@@ -148,8 +149,7 @@ ecma_date_check_two_chars (const lit_utf8_byte_t *str_p, /**< pointer to the ces
ecma_char_t expected_char1, /**< first expected character */ ecma_char_t expected_char1, /**< first expected character */
ecma_char_t expected_char2) /**< second expected character */ ecma_char_t expected_char2) /**< second expected character */
{ {
return (str_p < str_end_p return (str_p < str_end_p && (*str_p == expected_char1 || *str_p == expected_char2));
&& (*str_p == expected_char1 || *str_p == expected_char2));
} /* ecma_date_check_two_chars */ } /* ecma_date_check_two_chars */
/** /**
@@ -249,8 +249,7 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
uint32_t args_len, /**< number of arguments */ uint32_t args_len, /**< number of arguments */
ecma_number_t *tv_p) /**< [out] time value */ ecma_number_t *tv_p) /**< [out] time value */
{ {
ecma_number_t date_nums[7] = ecma_number_t date_nums[7] = {
{
ECMA_NUMBER_ZERO, /* year */ ECMA_NUMBER_ZERO, /* year */
ECMA_NUMBER_ZERO, /* month */ ECMA_NUMBER_ZERO, /* month */
ECMA_NUMBER_ONE, /* date */ ECMA_NUMBER_ONE, /* date */
@@ -287,13 +286,8 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
} }
/* 10. */ /* 10. */
*tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0], *tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0], date_nums[1], date_nums[2]),
date_nums[1], ecma_date_make_time (date_nums[3], date_nums[4], date_nums[5], date_nums[6]));
date_nums[2]),
ecma_date_make_time (date_nums[3],
date_nums[4],
date_nums[5],
date_nums[6]));
return true; return true;
} /* ecma_date_construct_helper */ } /* ecma_date_construct_helper */
@@ -324,10 +318,8 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date
year_limit = 999999; year_limit = 999999;
} }
ecma_number_t year = ecma_date_parse_date_chars (&date_str_curr_p, ecma_number_t year =
date_str_end_p, ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, year_digits, ECMA_DATE_LIMIT (0, year_limit));
year_digits,
ECMA_DATE_LIMIT (0, year_limit));
if (is_year_sign_negative) if (is_year_sign_negative)
{ {
year = -year; year = -year;
@@ -466,8 +458,7 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date
* @return the parsed date as ecma_number_t or NaN otherwise * @return the parsed date as ecma_number_t or NaN otherwise
*/ */
static ecma_number_t static ecma_number_t
ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p, ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p, const lit_utf8_byte_t *date_str_end_p)
const lit_utf8_byte_t *date_str_end_p)
{ {
const ecma_number_t nan = ecma_number_make_nan (); const ecma_number_t nan = ecma_number_make_nan ();
@@ -582,8 +573,7 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
} }
const char gmt_p[] = " GMT"; const char gmt_p[] = " GMT";
if (date_str_end_p - date_str_curr_p < 4 if (date_str_end_p - date_str_curr_p < 4 || memcmp (date_str_curr_p, gmt_p, 4) != 0)
|| memcmp (date_str_curr_p, gmt_p, 4) != 0)
{ {
return nan; return nan;
} }
@@ -725,8 +715,8 @@ ecma_builtin_date_create (ecma_number_t tv)
#if JERRY_ESNEXT #if JERRY_ESNEXT
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL); JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL);
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ecma_object_t *prototype_obj_p =
ECMA_BUILTIN_ID_DATE_PROTOTYPE); ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_DATE_PROTOTYPE);
if (JERRY_UNLIKELY (prototype_obj_p == NULL)) if (JERRY_UNLIKELY (prototype_obj_p == NULL))
{ {
@@ -787,7 +777,6 @@ ecma_value_t
ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
/* 20.4.2.3 */ /* 20.4.2.3 */
if (arguments_list_len == 0) if (arguments_list_len == 0)
{ {
@@ -804,7 +793,6 @@ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**<
if (ecma_is_value_object (argument) if (ecma_is_value_object (argument)
&& ecma_object_class_is (ecma_get_object_from_value (argument), ECMA_OBJECT_CLASS_DATE)) && ecma_object_class_is (ecma_get_object_from_value (argument), ECMA_OBJECT_CLASS_DATE))
{ {
#if JERRY_ESNEXT #if JERRY_ESNEXT
tv = ((ecma_date_object_t *) ecma_get_object_from_value (argument))->date_value; tv = ((ecma_date_object_t *) ecma_get_object_from_value (argument))->date_value;
#else /* !JERRY_ESNEXT */ #else /* !JERRY_ESNEXT */
@@ -22,22 +22,16 @@
#if JERRY_BUILTIN_DATE #if JERRY_BUILTIN_DATE
/* ECMA-262 v5, 15.9.4.1 */ /* ECMA-262 v5, 15.9.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_DATE_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_DATE_PROTOTYPE,
ECMA_PROPERTY_FIXED)
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 7, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
7,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
ROUTINE (LIT_MAGIC_STRING_PARSE, ECMA_DATE_ROUTINE_PARSE, 1, 1) ROUTINE (LIT_MAGIC_STRING_PARSE, ECMA_DATE_ROUTINE_PARSE, 1, 1)
ROUTINE (LIT_MAGIC_STRING_UTC_U, ECMA_DATE_ROUTINE_UTC, NON_FIXED, 7) ROUTINE (LIT_MAGIC_STRING_UTC_U, ECMA_DATE_ROUTINE_UTC, NON_FIXED, 7)
ROUTINE (LIT_MAGIC_STRING_NOW, ECMA_DATE_ROUTINE_NOW, 0, 0) ROUTINE (LIT_MAGIC_STRING_NOW, ECMA_DATE_ROUTINE_NOW, 0, 0)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_DATE_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_DATE_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#endif /* JERRY_BUILTIN_DATE */ #endif /* JERRY_BUILTIN_DATE */
@@ -20,10 +20,11 @@
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "lit-char-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-string-object.h" #include "ecma-string-object.h"
#include "jrt.h" #include "jrt.h"
#include "lit-char-helpers.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
@@ -105,18 +106,16 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg); ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_string_t *name_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p, ecma_string_t *name_string_p =
LIT_MAGIC_STRING_NAME, ecma_builtin_error_prototype_object_to_string_helper (obj_p, LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL);
LIT_MAGIC_STRING_ERROR_UL);
if (JERRY_UNLIKELY (name_string_p == NULL)) if (JERRY_UNLIKELY (name_string_p == NULL))
{ {
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
ecma_string_t *msg_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p, ecma_string_t *msg_string_p =
LIT_MAGIC_STRING_MESSAGE, ecma_builtin_error_prototype_object_to_string_helper (obj_p, LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY);
LIT_MAGIC_STRING__EMPTY);
if (JERRY_UNLIKELY (msg_string_p == NULL)) if (JERRY_UNLIKELY (msg_string_p == NULL))
{ {
@@ -136,7 +135,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
ecma_stringbuilder_t builder = ecma_stringbuilder_create_from (name_string_p); ecma_stringbuilder_t builder = ecma_stringbuilder_create_from (name_string_p);
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *)": ", 2); ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *) ": ", 2);
ecma_stringbuilder_append (&builder, msg_string_p); ecma_stringbuilder_append (&builder, msg_string_p);
ecma_deref_ecma_string (name_string_p); ecma_deref_ecma_string (name_string_p);
@@ -23,19 +23,13 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.4.1 */ /* ECMA-262 v5, 15.11.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.4.2 */ /* ECMA-262 v5, 15.11.4.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
LIT_MAGIC_STRING_ERROR_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.4.3 */ /* ECMA-262 v5, 15.11.4.3 */
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
LIT_MAGIC_STRING__EMPTY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -14,17 +14,18 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-builtin-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-function-object.h"
#include "jrt.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h"
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
@@ -67,8 +68,8 @@ ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**
#if !JERRY_ESNEXT #if !JERRY_ESNEXT
return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len); return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
#else /* JERRY_ESNEXT */ #else /* JERRY_ESNEXT */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ecma_object_t *proto_p =
ECMA_BUILTIN_ID_ERROR_PROTOTYPE); ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
if (proto_p == NULL) if (proto_p == NULL)
{ {
@@ -22,22 +22,16 @@
/* Number properties: /* Number properties:
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
1,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.7.3.1 */ /* ECMA-262 v5, 15.7.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_ERROR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -22,6 +22,7 @@
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-string-object.h" #include "ecma-string-object.h"
#include "jrt.h" #include "jrt.h"
#if JERRY_BUILTIN_ERRORS #if JERRY_BUILTIN_ERRORS
@@ -25,19 +25,13 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.7.8 */ /* ECMA-262 v5, 15.11.7.8 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_EVAL_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_EVAL_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.7.9 */ /* ECMA-262 v5, 15.11.7.9 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
LIT_MAGIC_STRING_EVAL_ERROR_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.11.7.10 */ /* ECMA-262 v5, 15.11.7.10 */
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
LIT_MAGIC_STRING__EMPTY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_ERRORS */ #endif /* JERRY_BUILTIN_ERRORS */
@@ -14,17 +14,18 @@
*/ */
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-builtin-helpers.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-function-object.h"
#include "jrt.h"
#include "jcontext.h" #include "jcontext.h"
#include "jrt.h"
#if JERRY_BUILTIN_ERRORS #if JERRY_BUILTIN_ERRORS
@@ -69,8 +70,8 @@ ecma_builtin_eval_error_dispatch_construct (const ecma_value_t *arguments_list_p
#if !JERRY_ESNEXT #if !JERRY_ESNEXT
return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len); return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
#else /* JERRY_ESNEXT */ #else /* JERRY_ESNEXT */
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ecma_object_t *proto_p =
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE); ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
if (proto_p == NULL) if (proto_p == NULL)
{ {
@@ -24,22 +24,16 @@
/* Number properties: /* Number properties:
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
1,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.11.3.1 */ /* ECMA-262 v5, 15.11.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
ECMA_PROPERTY_FIXED)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_EVAL_ERROR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#endif /* JERRY_BUILTIN_ERRORS */ #endif /* JERRY_BUILTIN_ERRORS */
@@ -13,20 +13,22 @@
* limitations under the License. * limitations under the License.
*/ */
#include "ecma-builtin-function-prototype.h"
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-builtin-helpers.h" #include "ecma-builtin-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h" #include "ecma-exceptions.h"
#include "ecma-extended-info.h" #include "ecma-extended-info.h"
#include "ecma-function-object.h"
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-function-object.h"
#include "ecma-objects.h" #include "ecma-objects.h"
#include "ecma-proxy-object.h" #include "ecma-proxy-object.h"
#include "jrt.h" #include "jrt.h"
#include "ecma-builtin-function-prototype.h"
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
@@ -256,10 +258,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
if (ecma_is_value_empty (ret_value)) if (ecma_is_value_empty (ret_value))
{ {
JERRY_ASSERT (index == length); JERRY_ASSERT (index == length);
ret_value = ecma_op_function_call (func_obj_p, ret_value = ecma_op_function_call (func_obj_p, arg1, arguments_list_p, (uint32_t) length);
arg1,
arguments_list_p,
(uint32_t) length);
} }
for (uint32_t remove_index = 0; remove_index < index; remove_index++) for (uint32_t remove_index = 0; remove_index < index; remove_index++)
@@ -282,17 +281,14 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
* Returned value must be freed with ecma_free_value. * Returned value must be freed with ecma_free_value.
*/ */
static ecma_value_t static ecma_value_t
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< this argument object */ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p, /**< this argument object */
const ecma_value_t *arguments_list_p, /**< list of arguments */ const ecma_value_t *arguments_list_p, /**< list of arguments */
uint32_t arguments_number) /**< number of arguments */ uint32_t arguments_number) /**< number of arguments */
{ {
if (arguments_number == 0) if (arguments_number == 0)
{ {
/* Even a 'this' argument is missing. */ /* Even a 'this' argument is missing. */
return ecma_op_function_call (func_obj_p, return ecma_op_function_call (func_obj_p, ECMA_VALUE_UNDEFINED, NULL, 0);
ECMA_VALUE_UNDEFINED,
NULL,
0);
} }
return ecma_op_function_call (func_obj_p, return ecma_op_function_call (func_obj_p,
@@ -311,7 +307,7 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
* Returned value must be freed with ecma_free_value. * Returned value must be freed with ecma_free_value.
*/ */
static ecma_value_t static ecma_value_t
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**< this argument object */ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p, /**< this argument object */
const ecma_value_t *arguments_list_p, /**< list of arguments */ const ecma_value_t *arguments_list_p, /**< list of arguments */
uint32_t arguments_number) /**< number of arguments */ uint32_t arguments_number) /**< number of arguments */
{ {
@@ -353,18 +349,13 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
ecma_object_t *function_p; ecma_object_t *function_p;
ecma_bound_function_t *bound_func_p; ecma_bound_function_t *bound_func_p;
if (arguments_number == 0 if (arguments_number == 0 || (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
|| (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
{ {
function_p = ecma_create_object (prototype_obj_p, function_p = ecma_create_object (prototype_obj_p, sizeof (ecma_bound_function_t), ECMA_OBJECT_TYPE_BOUND_FUNCTION);
sizeof (ecma_bound_function_t),
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
/* 8. */ /* 8. */
bound_func_p = (ecma_bound_function_t *) function_p; bound_func_p = (ecma_bound_function_t *) function_p;
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, this_arg_obj_p, 0);
this_arg_obj_p,
0);
bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED; bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
@@ -379,15 +370,11 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
size_t obj_size = sizeof (ecma_bound_function_t) + (arguments_number * sizeof (ecma_value_t)); size_t obj_size = sizeof (ecma_bound_function_t) + (arguments_number * sizeof (ecma_value_t));
function_p = ecma_create_object (prototype_obj_p, function_p = ecma_create_object (prototype_obj_p, obj_size, ECMA_OBJECT_TYPE_BOUND_FUNCTION);
obj_size,
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
/* 8. */ /* 8. */
bound_func_p = (ecma_bound_function_t *) function_p; bound_func_p = (ecma_bound_function_t *) function_p;
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, this_arg_obj_p, 0);
this_arg_obj_p,
0);
/* NOTE: This solution provides temporary false data about the object's size /* NOTE: This solution provides temporary false data about the object's size
but prevents GC from freeing it until it's not fully initialized. */ but prevents GC from freeing it until it's not fully initialized. */
@@ -413,9 +400,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
ecma_string_t *len_string = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH); ecma_string_t *len_string = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH);
ecma_property_descriptor_t prop_desc; ecma_property_descriptor_t prop_desc;
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p, ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p, len_string, &prop_desc);
len_string,
&prop_desc);
#if JERRY_BUILTIN_PROXY #if JERRY_BUILTIN_PROXY
if (ECMA_IS_VALUE_ERROR (status)) if (ECMA_IS_VALUE_ERROR (status))
@@ -428,8 +413,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
if (ecma_is_value_true (status)) if (ecma_is_value_true (status))
{ {
ecma_free_property_descriptor (&prop_desc); ecma_free_property_descriptor (&prop_desc);
ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p, ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p, len_string);
len_string);
if (ECMA_IS_VALUE_ERROR (len_value)) if (ECMA_IS_VALUE_ERROR (len_value))
{ {
@@ -552,9 +536,7 @@ ecma_builtin_function_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
} }
case ECMA_FUNCTION_PROTOTYPE_APPLY: case ECMA_FUNCTION_PROTOTYPE_APPLY:
{ {
return ecma_builtin_function_prototype_object_apply (func_obj_p, return ecma_builtin_function_prototype_object_apply (func_obj_p, arguments_list_p[0], arguments_list_p[1]);
arguments_list_p[0],
arguments_list_p[1]);
} }
case ECMA_FUNCTION_PROTOTYPE_CALL: case ECMA_FUNCTION_PROTOTYPE_CALL:
{ {
@@ -16,8 +16,9 @@
#ifndef ECMA_BUILTIN_FUNCTION_PROTOTYPE_H #ifndef ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
#define ECMA_BUILTIN_FUNCTION_PROTOTYPE_H #define ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
ecma_value_t ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, #include "ecma-globals.h"
ecma_value_t arg1,
ecma_value_t arg2); ecma_value_t
ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, ecma_value_t arg1, ecma_value_t arg2);
#endif /* !ECMA_BUILTIN_FUNCTION_PROTOTYPE_H */ #endif /* !ECMA_BUILTIN_FUNCTION_PROTOTYPE_H */
@@ -23,21 +23,15 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.3.4.1 */ /* ECMA-262 v5, 15.3.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_FUNCTION, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_FUNCTION,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* Number properties: /* Number properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
0,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING__EMPTY,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
/* Routine properties: /* Routine properties:
@@ -15,11 +15,12 @@
#include "ecma-alloc.h" #include "ecma-alloc.h"
#include "ecma-conversion.h" #include "ecma-conversion.h"
#include "ecma-exceptions.h"
#include "ecma-eval.h" #include "ecma-eval.h"
#include "ecma-gc.h" #include "ecma-exceptions.h"
#include "ecma-function-object.h" #include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-lex-env.h" #include "ecma-lex-env.h"
#include "js-parser.h" #include "js-parser.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
@@ -23,21 +23,15 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.3.3.1 */ /* ECMA-262 v5, 15.3.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
ECMA_PROPERTY_FIXED)
/* Number properties: /* Number properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
1,
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
#if JERRY_ESNEXT #if JERRY_ESNEXT
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#include "ecma-builtin-helpers-macro-undefs.inc.h" #include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -53,7 +53,7 @@ ecma_builtin_generator_function_dispatch_call (const ecma_value_t *arguments_lis
/** /**
* Handle calling [[Construct]] of built-in GeneratorFunction object * Handle calling [[Construct]] of built-in GeneratorFunction object
* *
* @return constructed generator function object - if success * @return constructed generator function object - if success
* raised error otherwise * raised error otherwise
*/ */
ecma_value_t ecma_value_t
@@ -22,19 +22,13 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v6, 25.2.2 */ /* ECMA-262 v6, 25.2.2 */
STRING_VALUE (LIT_MAGIC_STRING_NAME, STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.2.1 */ /* ECMA-262 v6, 25.2.2.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
1,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.2.2 */ /* ECMA-262 v6, 25.2.2.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_GENERATOR, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_ID_GENERATOR,
ECMA_PROPERTY_FIXED)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -19,6 +19,7 @@
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "jcontext.h" #include "jcontext.h"
#include "opcodes.h" #include "opcodes.h"
#include "vm-defines.h" #include "vm-defines.h"
@@ -62,10 +63,9 @@ enum
* Convert routine type to operation type.. * Convert routine type to operation type..
*/ */
#define ECMA_GENERATOR_ROUTINE_TO_OPERATION(type) \ #define ECMA_GENERATOR_ROUTINE_TO_OPERATION(type) \
((ecma_iterator_command_type_t) ((type) - ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT)) ((ecma_iterator_command_type_t) ((type) -ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT) JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT) == ECMA_ITERATOR_NEXT,
== ECMA_ITERATOR_NEXT,
convert_ecma_generator_routine_next_to_ecma_iterator_next_failed); convert_ecma_generator_routine_next_to_ecma_iterator_next_failed);
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW) JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
@@ -161,9 +161,8 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR) if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR)
{ {
ecma_value_t iterator = ecma_op_get_iterator (value, ecma_value_t iterator =
ECMA_VALUE_SYNC_ITERATOR, ecma_op_get_iterator (value, ECMA_VALUE_SYNC_ITERATOR, generator_object_p->frame_ctx.stack_top_p);
generator_object_p->frame_ctx.stack_top_p);
ecma_free_value (value); ecma_free_value (value);
if (ECMA_IS_VALUE_ERROR (iterator)) if (ECMA_IS_VALUE_ERROR (iterator))
@@ -25,14 +25,10 @@
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v6, 25.3.1.5 */ /* ECMA-262 v6, 25.3.1.5 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_GENERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_GENERATOR_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.2.3.1 */ /* ECMA-262 v6, 25.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_GENERATOR, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_GENERATOR,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* Routine properties: /* Routine properties:
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */ * (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
@@ -22,19 +22,13 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
/* ECMA-262 v6, 25.3.2.3.1 */ /* ECMA-262 v6, 25.3.2.3.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_GENERATOR_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_GENERATOR_FUNCTION,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.3.2 */ /* ECMA-262 v6, 25.3.2.3.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE, ECMA_PROPERTY_FLAG_CONFIGURABLE)
ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
/* ECMA-262 v6, 25.3.2.3.3 */ /* ECMA-262 v6, 25.3.2.3.3 */
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
@@ -21,14 +21,15 @@
#include "ecma-gc.h" #include "ecma-gc.h"
#include "ecma-globals.h" #include "ecma-globals.h"
#include "ecma-helpers.h" #include "ecma-helpers.h"
#include "jcontext.h"
#include "jrt-bit-fields.h"
#include "jrt-libc-includes.h"
#include "jrt.h" #include "jrt.h"
#include "lit-char-helpers.h" #include "lit-char-helpers.h"
#include "lit-magic-strings.h" #include "lit-magic-strings.h"
#include "lit-strings.h" #include "lit-strings.h"
#include "vm.h" #include "vm.h"
#include "jcontext.h"
#include "jrt-libc-includes.h"
#include "jrt-bit-fields.h"
#define ECMA_BUILTINS_INTERNAL #define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h" #include "ecma-builtins-internal.h"
@@ -137,8 +138,7 @@ ecma_builtin_global_object_is_nan (ecma_number_t arg_num) /**< routine's first a
static ecma_value_t static ecma_value_t
ecma_builtin_global_object_is_finite (ecma_number_t arg_num) /**< routine's first argument */ ecma_builtin_global_object_is_finite (ecma_number_t arg_num) /**< routine's first argument */
{ {
bool is_finite = !(ecma_number_is_nan (arg_num) bool is_finite = !(ecma_number_is_nan (arg_num) || ecma_number_is_infinity (arg_num));
|| ecma_number_is_infinity (arg_num));
return ecma_make_boolean_value (is_finite); return ecma_make_boolean_value (is_finite);
} /* ecma_builtin_global_object_is_finite */ } /* ecma_builtin_global_object_is_finite */
@@ -161,22 +161,16 @@ ecma_builtin_global_object_character_is_in (uint32_t character, /**< character *
* One bit for each character between 0 - 127. * One bit for each character between 0 - 127.
* Bit is set if the character is in the unescaped URI set. * Bit is set if the character is in the unescaped URI set.
*/ */
static const uint8_t unescaped_uri_set[16] = static const uint8_t unescaped_uri_set[16] = { 0x0, 0x0, 0x0, 0x0, 0xda, 0xff, 0xff, 0xaf,
{ 0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47 };
0x0, 0x0, 0x0, 0x0, 0xda, 0xff, 0xff, 0xaf,
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47
};
/** /**
* Unescaped URI component characters bitset: * Unescaped URI component characters bitset:
* One bit for each character between 0 - 127. * One bit for each character between 0 - 127.
* Bit is set if the character is in the unescaped component URI set. * Bit is set if the character is in the unescaped component URI set.
*/ */
static const uint8_t unescaped_uri_component_set[16] = static const uint8_t unescaped_uri_component_set[16] = { 0x0, 0x0, 0x0, 0x0, 0x82, 0x67, 0xff, 0x3,
{ 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47 };
0x0, 0x0, 0x0, 0x0, 0x82, 0x67, 0xff, 0x3,
0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47
};
/** /**
* Format is a percent sign followed by two hex digits. * Format is a percent sign followed by two hex digits.
@@ -283,8 +277,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
} }
} }
if (!is_valid if (!is_valid || !lit_is_valid_utf8_string (octets, bytes_count, true))
|| !lit_is_valid_utf8_string (octets, bytes_count, true))
{ {
ecma_stringbuilder_destroy (&builder); ecma_stringbuilder_destroy (&builder);
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 string")); return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 string"));
@@ -293,8 +286,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
lit_code_point_t cp; lit_code_point_t cp;
lit_read_code_point_from_utf8 (octets, bytes_count, &cp); lit_read_code_point_from_utf8 (octets, bytes_count, &cp);
if (lit_is_code_point_utf16_high_surrogate (cp) if (lit_is_code_point_utf16_high_surrogate (cp) || lit_is_code_point_utf16_low_surrogate (cp))
|| lit_is_code_point_utf16_low_surrogate (cp))
{ {
ecma_stringbuilder_destroy (&builder); ecma_stringbuilder_destroy (&builder);
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 codepoint")); return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 codepoint"));
@@ -431,11 +423,8 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /*
* Bit is set if the character does not need to be converted to %xx form. * Bit is set if the character does not need to be converted to %xx form.
* These characters are: a-z A-Z 0-9 @ * _ + - . / * These characters are: a-z A-Z 0-9 @ * _ + - . /
*/ */
static const uint8_t ecma_escape_set[16] = static const uint8_t ecma_escape_set[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0xec, 0xff, 0x3,
{ 0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x7 };
0x0, 0x0, 0x0, 0x0, 0x0, 0xec, 0xff, 0x3,
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x7
};
/** /**
* The Global object's 'escape' routine * The Global object's 'escape' routine
@@ -643,15 +632,12 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
if (builtin_routine_id == ECMA_GLOBAL_PARSE_INT) if (builtin_routine_id == ECMA_GLOBAL_PARSE_INT)
{ {
ret_value = ecma_number_parse_int (string_buff, ret_value = ecma_number_parse_int (string_buff, string_buff_size, arguments_list_p[1]);
string_buff_size,
arguments_list_p[1]);
} }
else else
{ {
JERRY_ASSERT (builtin_routine_id == ECMA_GLOBAL_PARSE_FLOAT); JERRY_ASSERT (builtin_routine_id == ECMA_GLOBAL_PARSE_FLOAT);
ret_value = ecma_number_parse_float (string_buff, ret_value = ecma_number_parse_float (string_buff, string_buff_size);
string_buff_size);
} }
ECMA_FINALIZE_UTF8_STRING (string_buff, string_buff_size); ECMA_FINALIZE_UTF8_STRING (string_buff, string_buff_size);
@@ -661,9 +647,7 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
lit_utf8_size_t input_size = ecma_string_get_size (str_p); lit_utf8_size_t input_size = ecma_string_get_size (str_p);
JMEM_DEFINE_LOCAL_ARRAY (input_start_p, JMEM_DEFINE_LOCAL_ARRAY (input_start_p, input_size + 1, lit_utf8_byte_t);
input_size + 1,
lit_utf8_byte_t);
ecma_string_to_utf8_bytes (str_p, input_start_p, input_size); ecma_string_to_utf8_bytes (str_p, input_start_p, input_size);
@@ -686,8 +670,8 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
case ECMA_GLOBAL_DECODE_URI: case ECMA_GLOBAL_DECODE_URI:
case ECMA_GLOBAL_DECODE_URI_COMPONENT: case ECMA_GLOBAL_DECODE_URI_COMPONENT:
{ {
const uint8_t *uri_set = (builtin_routine_id == ECMA_GLOBAL_DECODE_URI ? unescaped_uri_set const uint8_t *uri_set =
: unescaped_uri_component_set); (builtin_routine_id == ECMA_GLOBAL_DECODE_URI ? unescaped_uri_set : unescaped_uri_component_set);
ret_value = ecma_builtin_global_object_decode_uri_helper (input_start_p, input_size, uri_set); ret_value = ecma_builtin_global_object_decode_uri_helper (input_start_p, input_size, uri_set);
break; break;
@@ -697,8 +681,8 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
JERRY_ASSERT (builtin_routine_id == ECMA_GLOBAL_ENCODE_URI JERRY_ASSERT (builtin_routine_id == ECMA_GLOBAL_ENCODE_URI
|| builtin_routine_id == ECMA_GLOBAL_ENCODE_URI_COMPONENT); || builtin_routine_id == ECMA_GLOBAL_ENCODE_URI_COMPONENT);
const uint8_t *uri_set = (builtin_routine_id == ECMA_GLOBAL_ENCODE_URI ? unescaped_uri_set const uint8_t *uri_set =
: unescaped_uri_component_set); (builtin_routine_id == ECMA_GLOBAL_ENCODE_URI ? unescaped_uri_set : unescaped_uri_component_set);
ret_value = ecma_builtin_global_object_encode_uri_helper (input_start_p, input_size, uri_set); ret_value = ecma_builtin_global_object_encode_uri_helper (input_start_p, input_size, uri_set);
break; break;
@@ -23,147 +23,101 @@
* (property name, simple value, writable, enumerable, configurable) */ * (property name, simple value, writable, enumerable, configurable) */
/* ECMA-262 v5, 15.1.1.3 */ /* ECMA-262 v5, 15.1.1.3 */
SIMPLE_VALUE (LIT_MAGIC_STRING_UNDEFINED, SIMPLE_VALUE (LIT_MAGIC_STRING_UNDEFINED, ECMA_VALUE_UNDEFINED, ECMA_PROPERTY_FIXED)
ECMA_VALUE_UNDEFINED,
ECMA_PROPERTY_FIXED)
/* Number properties: /* Number properties:
* (property name, number value, writable, enumerable, configurable) */ * (property name, number value, writable, enumerable, configurable) */
/* ECMA-262 v5, 15.1.1.1 */ /* ECMA-262 v5, 15.1.1.1 */
NUMBER_VALUE (LIT_MAGIC_STRING_NAN, NUMBER_VALUE (LIT_MAGIC_STRING_NAN, ECMA_BUILTIN_NUMBER_NAN, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_NUMBER_NAN,
ECMA_PROPERTY_FIXED)
/* ECMA-262 v5, 15.1.1.2 */ /* ECMA-262 v5, 15.1.1.2 */
NUMBER_VALUE (LIT_MAGIC_STRING_INFINITY_UL, NUMBER_VALUE (LIT_MAGIC_STRING_INFINITY_UL, ECMA_BUILTIN_NUMBER_POSITIVE_INFINITY, ECMA_PROPERTY_FIXED)
ECMA_BUILTIN_NUMBER_POSITIVE_INFINITY,
ECMA_PROPERTY_FIXED)
/* Object properties: /* Object properties:
* (property name, object pointer getter) */ * (property name, object pointer getter) */
/* ECMA-262 v5, 15.1.4.1 */ /* ECMA-262 v5, 15.1.4.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_OBJECT_UL, OBJECT_VALUE (LIT_MAGIC_STRING_OBJECT_UL, ECMA_BUILTIN_ID_OBJECT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_OBJECT,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.2 */ /* ECMA-262 v5, 15.1.4.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_FUNCTION_UL, OBJECT_VALUE (LIT_MAGIC_STRING_FUNCTION_UL, ECMA_BUILTIN_ID_FUNCTION, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_FUNCTION,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.3 */ /* ECMA-262 v5, 15.1.4.3 */
#if JERRY_BUILTIN_ARRAY #if JERRY_BUILTIN_ARRAY
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_UL, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_ARRAY */ #endif /* JERRY_BUILTIN_ARRAY */
#if JERRY_BUILTIN_STRING #if JERRY_BUILTIN_STRING
/* ECMA-262 v5, 15.1.4.4 */ /* ECMA-262 v5, 15.1.4.4 */
OBJECT_VALUE (LIT_MAGIC_STRING_STRING_UL, OBJECT_VALUE (LIT_MAGIC_STRING_STRING_UL, ECMA_BUILTIN_ID_STRING, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_STRING,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_STRING */ #endif /* JERRY_BUILTIN_STRING */
#if JERRY_BUILTIN_BOOLEAN #if JERRY_BUILTIN_BOOLEAN
/* ECMA-262 v5, 15.1.4.5 */ /* ECMA-262 v5, 15.1.4.5 */
OBJECT_VALUE (LIT_MAGIC_STRING_BOOLEAN_UL, OBJECT_VALUE (LIT_MAGIC_STRING_BOOLEAN_UL, ECMA_BUILTIN_ID_BOOLEAN, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_BOOLEAN,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_BOOLEAN */ #endif /* JERRY_BUILTIN_BOOLEAN */
#if JERRY_BUILTIN_NUMBER #if JERRY_BUILTIN_NUMBER
/* ECMA-262 v5, 15.1.4.6 */ /* ECMA-262 v5, 15.1.4.6 */
OBJECT_VALUE (LIT_MAGIC_STRING_NUMBER_UL, OBJECT_VALUE (LIT_MAGIC_STRING_NUMBER_UL, ECMA_BUILTIN_ID_NUMBER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_NUMBER,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_NUMBER */ #endif /* JERRY_BUILTIN_NUMBER */
#if JERRY_BUILTIN_DATE #if JERRY_BUILTIN_DATE
/* ECMA-262 v5, 15.1.4.7 */ /* ECMA-262 v5, 15.1.4.7 */
OBJECT_VALUE (LIT_MAGIC_STRING_DATE_UL, OBJECT_VALUE (LIT_MAGIC_STRING_DATE_UL, ECMA_BUILTIN_ID_DATE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_DATE,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_DATE */ #endif /* JERRY_BUILTIN_DATE */
#if JERRY_BUILTIN_REGEXP #if JERRY_BUILTIN_REGEXP
/* ECMA-262 v5, 15.1.4.8 */ /* ECMA-262 v5, 15.1.4.8 */
OBJECT_VALUE (LIT_MAGIC_STRING_REGEXP_UL, OBJECT_VALUE (LIT_MAGIC_STRING_REGEXP_UL, ECMA_BUILTIN_ID_REGEXP, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_REGEXP,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_REGEXP */ #endif /* JERRY_BUILTIN_REGEXP */
/* ECMA-262 v5, 15.1.4.9 */ /* ECMA-262 v5, 15.1.4.9 */
OBJECT_VALUE (LIT_MAGIC_STRING_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_ERROR_UL, ECMA_BUILTIN_ID_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if JERRY_BUILTIN_ERRORS #if JERRY_BUILTIN_ERRORS
/* ECMA-262 v5, 15.1.4.10 */ /* ECMA-262 v5, 15.1.4.10 */
OBJECT_VALUE (LIT_MAGIC_STRING_EVAL_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_BUILTIN_ID_EVAL_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_EVAL_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.11 */ /* ECMA-262 v5, 15.1.4.11 */
OBJECT_VALUE (LIT_MAGIC_STRING_RANGE_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_RANGE_ERROR_UL, ECMA_BUILTIN_ID_RANGE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_RANGE_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.12 */ /* ECMA-262 v5, 15.1.4.12 */
OBJECT_VALUE (LIT_MAGIC_STRING_REFERENCE_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_REFERENCE_ERROR_UL, ECMA_BUILTIN_ID_REFERENCE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_REFERENCE_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.13 */ /* ECMA-262 v5, 15.1.4.13 */
OBJECT_VALUE (LIT_MAGIC_STRING_SYNTAX_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_SYNTAX_ERROR_UL, ECMA_BUILTIN_ID_SYNTAX_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_SYNTAX_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.14 */ /* ECMA-262 v5, 15.1.4.14 */
OBJECT_VALUE (LIT_MAGIC_STRING_TYPE_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_TYPE_ERROR_UL, ECMA_BUILTIN_ID_TYPE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_TYPE_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v5, 15.1.4.15 */ /* ECMA-262 v5, 15.1.4.15 */
OBJECT_VALUE (LIT_MAGIC_STRING_URI_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_URI_ERROR_UL, ECMA_BUILTIN_ID_URI_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_URI_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_ERRORS */ #endif /* JERRY_BUILTIN_ERRORS */
#if JERRY_BUILTIN_MATH #if JERRY_BUILTIN_MATH
/* ECMA-262 v5, 15.1.5.1 */ /* ECMA-262 v5, 15.1.5.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_MATH_UL, OBJECT_VALUE (LIT_MAGIC_STRING_MATH_UL, ECMA_BUILTIN_ID_MATH, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_MATH,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_MATH */ #endif /* JERRY_BUILTIN_MATH */
#if JERRY_BUILTIN_REFLECT #if JERRY_BUILTIN_REFLECT
/* ECMA-262 v6, 26.1 */ /* ECMA-262 v6, 26.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_REFLECT_UL, OBJECT_VALUE (LIT_MAGIC_STRING_REFLECT_UL, ECMA_BUILTIN_ID_REFLECT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_REFLECT,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_REFLECT */ #endif /* JERRY_BUILTIN_REFLECT */
#if JERRY_BUILTIN_JSON #if JERRY_BUILTIN_JSON
/* ECMA-262 v5, 15.1.5.2 */ /* ECMA-262 v5, 15.1.5.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_JSON_U, OBJECT_VALUE (LIT_MAGIC_STRING_JSON_U, ECMA_BUILTIN_ID_JSON, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_JSON,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_JSON */ #endif /* JERRY_BUILTIN_JSON */
#if JERRY_BUILTIN_ATOMICS #if JERRY_BUILTIN_ATOMICS
/* ECMA-262 v5, 15.1.5.2 */ /* ECMA-262 v5, 15.1.5.2 */
OBJECT_VALUE (LIT_MAGIC_STRING_ATOMICS_U, OBJECT_VALUE (LIT_MAGIC_STRING_ATOMICS_U, ECMA_BUILTIN_ID_ATOMICS, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ATOMICS,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_ATOMICS */ #endif /* JERRY_BUILTIN_ATOMICS */
#if JERRY_BUILTIN_TYPEDARRAY #if JERRY_BUILTIN_TYPEDARRAY
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_BUFFER_UL, OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_ARRAYBUFFER,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if JERRY_BUILTIN_SHAREDARRAYBUFFER #if JERRY_BUILTIN_SHAREDARRAYBUFFER
OBJECT_VALUE (LIT_MAGIC_STRING_SHARED_ARRAY_BUFFER_UL, OBJECT_VALUE (LIT_MAGIC_STRING_SHARED_ARRAY_BUFFER_UL,
@@ -171,48 +125,28 @@ OBJECT_VALUE (LIT_MAGIC_STRING_SHARED_ARRAY_BUFFER_UL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE) ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ #endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
OBJECT_VALUE (LIT_MAGIC_STRING_INT8_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_INT8_ARRAY_UL, ECMA_BUILTIN_ID_INT8ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_INT8ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_ARRAY_UL, ECMA_BUILTIN_ID_UINT8ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_UINT8ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_INT16_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_INT16_ARRAY_UL, ECMA_BUILTIN_ID_INT16ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_INT16ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_UINT16_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_UINT16_ARRAY_UL, ECMA_BUILTIN_ID_UINT16ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_UINT16ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_INT32_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_INT32_ARRAY_UL, ECMA_BUILTIN_ID_INT32ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_INT32ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_UINT32_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_UINT32_ARRAY_UL, ECMA_BUILTIN_ID_UINT32ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_UINT32ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT32_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT32_ARRAY_UL, ECMA_BUILTIN_ID_FLOAT32ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_FLOAT32ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if JERRY_NUMBER_TYPE_FLOAT64 #if JERRY_NUMBER_TYPE_FLOAT64
OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT64_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT64_ARRAY_UL, ECMA_BUILTIN_ID_FLOAT64ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_FLOAT64ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */ #endif /* JERRY_NUMBER_TYPE_FLOAT64 */
#if JERRY_BUILTIN_BIGINT #if JERRY_BUILTIN_BIGINT
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT64_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT64_ARRAY_UL, ECMA_BUILTIN_ID_BIGINT64ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_BIGINT64ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL, ECMA_BUILTIN_ID_BIGUINT64ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_BIGUINT64ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL,
@@ -223,73 +157,49 @@ OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL,
#if JERRY_BUILTIN_CONTAINER #if JERRY_BUILTIN_CONTAINER
/* ECMA-262 v6, 23.1.1.1 */ /* ECMA-262 v6, 23.1.1.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKSET_UL, OBJECT_VALUE (LIT_MAGIC_STRING_WEAKSET_UL, ECMA_BUILTIN_ID_WEAKSET, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_WEAKSET,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v6, 23.1.1.1 */ /* ECMA-262 v6, 23.1.1.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_MAP_UL, OBJECT_VALUE (LIT_MAGIC_STRING_MAP_UL, ECMA_BUILTIN_ID_MAP, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_MAP,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v6, 23.1.1.1 */ /* ECMA-262 v6, 23.1.1.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_SET_UL, OBJECT_VALUE (LIT_MAGIC_STRING_SET_UL, ECMA_BUILTIN_ID_SET, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_SET,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v6, 23.1.1.1 */ /* ECMA-262 v6, 23.1.1.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKMAP_UL, OBJECT_VALUE (LIT_MAGIC_STRING_WEAKMAP_UL, ECMA_BUILTIN_ID_WEAKMAP, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_WEAKMAP,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_CONTAINER */ #endif /* JERRY_BUILTIN_CONTAINER */
#if JERRY_BUILTIN_WEAKREF #if JERRY_BUILTIN_WEAKREF
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKREF_UL, OBJECT_VALUE (LIT_MAGIC_STRING_WEAKREF_UL, ECMA_BUILTIN_ID_WEAKREF, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_WEAKREF,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_WEAKREF */ #endif /* JERRY_BUILTIN_WEAKREF */
#if JERRY_ESNEXT #if JERRY_ESNEXT
OBJECT_VALUE (LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, OBJECT_VALUE (LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_BUILTIN_ID_AGGREGATE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_AGGREGATE_ERROR,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
OBJECT_VALUE (LIT_MAGIC_STRING_PROMISE_UL, OBJECT_VALUE (LIT_MAGIC_STRING_PROMISE_UL, ECMA_BUILTIN_ID_PROMISE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_PROMISE,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
/* ECMA-262 v6, 19.4.1.1 */ /* ECMA-262 v6, 19.4.1.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL, OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL, ECMA_BUILTIN_ID_SYMBOL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_SYMBOL,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */
#if JERRY_BUILTIN_GLOBAL_THIS #if JERRY_BUILTIN_GLOBAL_THIS
/* ECMA-262 v11, 18.1.1 */ /* ECMA-262 v11, 18.1.1 */
SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL, SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL, ECMA_VALUE_GLOBAL_THIS, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_VALUE_GLOBAL_THIS,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_GLOBAL_THIS */ #endif /* JERRY_BUILTIN_GLOBAL_THIS */
#if JERRY_BUILTIN_DATAVIEW #if JERRY_BUILTIN_DATAVIEW
/* ECMA-262 v6, 23.1.1.1 */ /* ECMA-262 v6, 23.1.1.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_DATAVIEW_UL, OBJECT_VALUE (LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_BUILTIN_ID_DATAVIEW, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_DATAVIEW,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_DATAVIEW */ #endif /* JERRY_BUILTIN_DATAVIEW */
#if JERRY_BUILTIN_PROXY #if JERRY_BUILTIN_PROXY
/* ECMA-262 v6, 26.2.1 */ /* ECMA-262 v6, 26.2.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_PROXY_UL, OBJECT_VALUE (LIT_MAGIC_STRING_PROXY_UL, ECMA_BUILTIN_ID_PROXY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_PROXY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_PROXY */ #endif /* JERRY_BUILTIN_PROXY */
#if JERRY_BUILTIN_BIGINT #if JERRY_BUILTIN_BIGINT
/* ECMA-262 v11, 20.2.1 */ /* ECMA-262 v11, 20.2.1 */
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT_UL, OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT_UL, ECMA_BUILTIN_ID_BIGINT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
ECMA_BUILTIN_ID_BIGINT,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#endif /* JERRY_BUILTIN_BIGINT */ #endif /* JERRY_BUILTIN_BIGINT */
/* Routine properties: /* Routine properties:
@@ -18,18 +18,16 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
#include "ecma-builtin-handlers.h" #include "ecma-builtin-handlers.h"
#include "ecma-promise-object.h"
#include "ecma-iterator-object.h" #include "ecma-iterator-object.h"
#include "ecma-promise-object.h"
static const ecma_builtin_handler_t ecma_native_handlers[] = static const ecma_builtin_handler_t ecma_native_handlers[] = {
{
#define ECMA_NATIVE_HANDLER(id, handler, length) handler, #define ECMA_NATIVE_HANDLER(id, handler, length) handler,
#include "ecma-builtin-handlers.inc.h" #include "ecma-builtin-handlers.inc.h"
#undef ECMA_NATIVE_HANDLER #undef ECMA_NATIVE_HANDLER
}; };
static const uint8_t ecma_native_handler_lengths[] = static const uint8_t ecma_native_handler_lengths[] = {
{
#define ECMA_NATIVE_HANDLER(id, handler, length) length, #define ECMA_NATIVE_HANDLER(id, handler, length) length,
#include "ecma-builtin-handlers.inc.h" #include "ecma-builtin-handlers.inc.h"
#undef ECMA_NATIVE_HANDLER #undef ECMA_NATIVE_HANDLER
@@ -20,8 +20,8 @@
#if JERRY_ESNEXT #if JERRY_ESNEXT
#include "ecma-helpers.h"
#include "ecma-builtins.h" #include "ecma-builtins.h"
#include "ecma-helpers.h"
#include "ecma-promise-object.h" #include "ecma-promise-object.h"
#include "ecma-proxy-object.h" #include "ecma-proxy-object.h"
@@ -46,10 +46,8 @@ typedef enum
*/ */
#define ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT 2 #define ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT 2
ecma_builtin_handler_t ecma_builtin_handler_t ecma_builtin_handler_get (ecma_native_handler_id_t id);
ecma_builtin_handler_get (ecma_native_handler_id_t id); uint8_t ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
uint8_t
ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
#endif /* JERRY_ESNEXT */ #endif /* JERRY_ESNEXT */

Some files were not shown because too many files have changed in this diff Show More