aboutsummaryrefslogtreecommitdiff
path: root/jerry-core/jmem/jmem-heap.c
AgeCommit message (Collapse)Author
2023-11-15Update doxygen and fix documentation (#5106)Máté Tokodi
Update Doxyfile to version 1.9.1 Re-enable doxygen CI checker Fix some regular comments that should have been doc comments Document void return types for some inline functions explicitly Move start of some doxygen groups so they are included always, and not left out of certain ifdefs Ignore some doxygen warnings: Member (function) is not documented in headers Documented empty return type in headers Argument has multiple @param documentation sections JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
2022-01-21Fix logging related issues (#4971)Dániel Bátyai
PR #4907 moved the log level into the engine context, however this caused issues with logging without the engine being initialized. This commit reverts the log level to be a static variable. This commit also implements missing format specifiers for jerry_log. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2022-01-20Update jerry-port and jerry-ext (#4907)Dániel Bátyai
Notable changes: - Updated and the port API interface, new functions have been added and some have been changed. The port library is now cleaned up to not have any dependency on jerry-core, as it should be. The port library is now strictly a collection of functions that implement embedding/platform specific behavior. - The default port implementation has been split for windows and unix. Implemented port functions have been categorized and reorganized, and marked with attribute((weak)) for better reusability. - External context allocation has been moved to the port API instead of a core API callback. The iterface has also been extended with a function to free the allocated context. When external context is enabled, jerry_init now automatically calls the port implementation to allocate the context and jerry_cleanup automatically calls the port to free the context. - jerry_port_log has been changed to no longer require formatting to be implemented by the port. The reason beind this is that it was vague what format specifiers were used by the engine, and in what manner. The port function now takes a zero-terminated string, and should only implement how the string should be logged. - Logging and log message formatting is now handled by the core jerry library where it can be implemented as necessary. Logging can be done through a new core API function, which uses the port to output the final log message. - Log level has been moved into jerry-core, and an API function has been added to set the log level. It should be the library that filters log messages based on the requested log level, instead of logging everything and requiring the user to do so. - Module resolving logic has been moved into jerry-core. There's no reason to have it in the port library and requiring embedders to duplicate the code. It also added an unnecessary dependency on jerry-core to the port. Platform specific behavior is still used through the port API, like resolving module specifiers, and reading source file contents. If necessary, the resolving logic can still be overridden as previously. - The jerry-ext library has also been cleaned up, and many utility functions have been added that previously were implemented in jerry-main. This allows easier reusability for some common operations, like printing unhandled exceptions or providing a repl console. - Debugger interaction with logged/printed messages has been fixed, so that it's no longer the port implementations responsibility to send the output to the debugger, as the port should have no notion of what a debugger is. The printing and logging functions will now pass the result message to the debugger, if connected. - Cleaned up TZA handling in the date port implementation, and simplified the API function prototype. - Moved property access helper functions that use ASCII strings as keys from jerry-ext to the core API. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2021-11-05Replace vera++ with clang-format (#4518)Robert Fancsik
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
2021-02-04Remove the ENABLED/DISABLED macros (#4515)Robert Fancsik
The removal of these macros enabled cppcheck to reveal new errors. These errors are also fixed by the patch. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2021-01-16Fixes ENABLE_AMALGAM need FORCE set to ON when building with MSVC (#4392)Yonggang Luo
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2020-08-11Fix mem-stress-test to properly run gc before allocs (#4125)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
2020-05-22Fix vera++ rule to find expressions without space after parentheses (#3776)Rafal Walczyna
Regex didn't include some characters that may occur after ')' JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
2020-03-30Bump reference platform to Ubuntu 18.04 LTS (#3037)Csaba Osztrogonác
Ubuntu 14.04 reached its end of life on April 30m 2019. Let's bump the reference to the latest LTS, which is 18.04. Ubuntu 18.04 has newer Pylint and Cppcheck, the necessary fixes and suppresses are also included in this PR. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2020-02-03Add vera rules to check consecutive and trailing empty lines (#3540)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-11-06Add missing GC limit check to realloc with system allocator (#3279)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-10-01Cleanup Valgrind macros (#3180)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-09-26Fix undefined references build error on Windows (x64) (#3168)Csaba Osztrogonác
We should emit function symbols for these jerry-core functions: - ecma_compare_ecma_strings is used by test-stringbuilder.c - ecma_is_value_number is used by test-literal-storage.c - ecma_date_time_within_day is used by test-date-helpers.c - jmem_heap_alloc_block is used by test-jmem.c - jmem_heap_free_block is used by test-jmem.c - jmem_pools_alloc is used by test-poolman.c - jmem_pools_free is used by test-poolman.c JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
2019-09-05Refactor JSON builtin methods (#3031)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-08-28Add missing Valgrind macros to jmem (#3025)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-08-28Look up the previous block again after a GC in jmem_heap_realloc_block (#3021)Dániel Bátyai
Garbage collection can create new free blocks in the heap structure as it releases memory, so the previous block needs to be looked up again if a GC happens during a realloc. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-08-06Add realloc function to jmem (#2998)Dániel Bátyai
This patch extends jmem functionality by adding a realloc function. This opens up other paths of optimization which can result in smaller peak memory usage and faster execution times, due to not having to duplicate memory when we need to extend blocks. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-08-06Add build option for changing the heap limit (#3005)Dániel Bátyai
This change adds a build option that allows adjusting the garbage collection heap usage limit, which can be used to fine-tune how often garbage collection should be triggered. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-17Refactor memory management (#2954)Dániel Bátyai
This PR is a general cleanup for garbage collection and memory allocation code paths. Changes: * Removed an unnecesary local variable from 'ecma_gc_mark'. * Refactored 'ecma_gc_run' to have an implicit list head during iteration, which results in one less condition in the loops, and changed the loops to use compressed pointers to reduce the overall amount of compression/decompression. * Renamed 'jmem_free_unused_memory_severity_t' to 'jmem_pressure_t', and added additional values. * Removed 'jmem_free_unused_memory_callback', instead 'ecma_free_unused_memory' is now called directly. * Reworked 'ecma_free_unused_memory' to handle all code paths related to 'jmem_pressure_t', and moved all relevant code paths into this function. This simplifies the code paths in other places. * Reworked 'jmem_heap_gc_and_alloc_block' to be more streamlined. * Changed mem-stats to not report unused pool chunks as allocated memory. * Created an allocator internal API for allocating/freeing memory blocks that are not reported as used memory in mem-stats. * Removed iteration statistics for the jerry allocator from mem-stats, as they don't provide any actually useful information. Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu> JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-06-19Rework usages/naming of configuration macros [part 2] (#2903)Péter Gál
There are quite a few configuration macros in the project. As discussed in the #2520 issue there are a few awkward constructs. Main changes: * The following macros are now 0/1 switches: ** Renamed CONFIG_ECMA_LCACHE_DISABLE to JERRY_LCACHE. ** Renamed CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE to JERRY_PROPERTY_HASHMAP. ** Renamed CONFIG_DISABLE_UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION. ** Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE. ** Renamed JERRY_DISABLE_JS_PARSER to JERRY_PARSER. ** Renamed JERRY_ENABLE_ERROR_MESSAGES to JERRY_ERROR_MESSAGES. ** Renamed JERRY_ENABLE_EXTERNAL_CONTEXT to JERRY_EXTERNAL_CONTEXT. ** Renamed JERRY_ENABLE_LINE_INFO to JERRY_LINE_INFO. ** Renamed JERRY_ENABLE_LOGGING to JERRY_LOGGING. ** Renamed JERRY_ENABLE_SNAPSHOT_EXEC to JERRY_SNAPSHOT_EXEC. ** Renamed JERRY_ENABLE_SNAPSHOT_SAVE to JERRY_SNAPSHOT_SAVE. ** Renamed JERRY_SYSTEM_ALLOCATOR to JERRY_SYSTEM_ALLOCATOR. ** Renamed JERRY_VM_EXEC_STOP to JERRY_VM_EXEC_STOP. ** Renamed JMEM_GC_BEFORE_EACH_ALLOC to JERRY_MEM_GC_BEFORE_EACH_ALLOC. ** Renamed JMEM_STATS to JERRY_MEM_STATS. ** Renamed PARSER_DUMP_BYTE_CODE to JERRY_PARSER_DUMP_BYTE_CODE. ** Renamed REGEXP_DUMP_BYTE_CODE to JERRY_REGEXP_DUMP_BYTE_CODE. * Recursion check changes: ** Renamed REGEXP_RECURSION_LIMIT to JERRY_REGEXP_RECURSION_LIMIT. ** Renamed VM_RECURSION_LIMIT to JERRY_VM_RECURSION_LIMIT. * Attribute macro changes: ** Renamed JERRY_CONST_DATA to JERRY_ATTR_CONST_DATA. ** Renamed JERRY_HEAP_SECTION_ATTR to JERRY_ATTR_GLOBAL_HEAP. Now the macro can specify any attribute for the global heap object. * Other macro changes: ** Renamed CONFIG_MEM_HEAP_AREA_SIZE to JERRY_GLOBAL_HEAP_SIZE. Then new macro now specify the global heap size in kilobytes. * Updated documentations to reflect the new macro names. For more deatils please see jerry-core/config.h. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-05-17Fix heap limit calculation when using the system allocator. (#2872)Dániel Bátyai
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2018-09-04Fixup JMEM_HEAP_STAT_xxx definitions (#2509)Akos Kiss
- Get the macro definition indentations right. - Define some of the macros only if system allocator is not in use. - Ensure that macros with arguments don't cause unused variable warnings even if memory statistics is disabled. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-08-31Reorganize heap context related elements (#2500)Akos Kiss
- Moved global context's `JMEM_HEAP_SIZE` to jcontext.h as external context's heap size is declared there, too. - Moved the assert on `jmem_heap_t` vs `JMEM_HEAP_SIZE` to jcontext.c, as both entities are declared in the corresponding header. - Removed superfluous checks on `JMEM_HEAP_SIZE` as it is not a publicly configurable macro (opposed to `CONFIG_MEM_HEAP_AREA_SIZE`). - Ensured that all definitions of and references to `jmem_heap_t`, `JERRY_HEAP_CONTEXT`, `JERRY_HEAP_SIZE`, and `JERRY_HEAP_AREA_SIZE` are guarded by `#ifndef JERRY_SYSTEM_ALLOCATOR`, as they are meaningless if the system allocator is used. The commit also contains some stylistic changes in jcontext.h JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-05-29Maintenance and merging of Valgrind and Valgrind-Freya code paths (#2362)Akos Kiss
None of the code paths have been tested for long and especially the Freya code paths have been long abandoned. This patch: - Merges Valgrind-Freya into Valgrind code path (there should be no need to choose between them, Valgrind should work just fine). - Removes leftover code (`VALGRIND_FREYA_CHECK_MEMPOOL_REQUEST` and `valgrind_freya_mempool_request`). - Adds `JMEM_` prefix to Valgrind-related macros (to correctly leave the `VALGRIND_` prefix to Valgrind). - Moves the definition of the Valgrind-related macros to a common header to avoid duplication. Note: Adding a CI job to perform Valgrind Memchecks is left for follow-up as it turns out to be excessively slow (>50 mins for a `--jerry-tests --jerry-test-suite` run, and even a simple `--jerry-tests` may get terminated prematurely because of timeout issues). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-05-18Update Doxygen config file and fix Doxygen warnings (#2324)László Langó
A lot of warnings remained hibben because 'EXTRACT_ALL' was previously set to YES. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2018-05-14Add jerryscript-compiler.h public header to cover compiler incompatibilities ↵Akos Kiss
(#2313) In general, public headers should not have compiler-specific constructs but both the core and the port headers have attributes, which are non-standard. It's better to factor out such constructs to a common place (a new header) and hide them behind macros, which can then be defined on a per-compiler basis. This patch moves the existing definitions of function attributes and likely/unlikely builtins to the new header. At the same time, it unifies the names of these attribute defines and where they are used. Moreover, it touches on jerry-main and removes the uses of `__attribute__((unused))` entirely and replaces them with the elsewhere used `(void) ...` pattern. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-09-21Allow mem-stats when system allocator is enabledZsolt Borbély
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-08-28Remove unnecessary if statementTamas Keri
JerryScript-DCO-1.0-Signed-off-by: Tamas Keri tkeri@inf.u-szeged.hu
2017-05-20Support external context, heap and lcache (#1778)Zidong Jiang
JerryScript should support external context, heap and lcache, so that it can have multiple instances and runtime configurable heap size. Related issue: 1746 JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
2017-05-16Rework memory statistics to provide useful user information. (#1812)Zoltan Herczeg
Obsolote statistics is also removed. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-02-22Remove shadowed declarations, undefined identifiers, and specify argument ↵Robert Sipka
types where it is required. (#1601) JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-02-17Fix the missing inline specifier if compiling with -fPIC (#1590)Gabor Loki
JerryScript-DCO-1.0-Signed-off-by: Gabor Loki loki@inf.u-szeged.hu
2017-02-08Enable 32bit compressed pointers on 64bit systems. (#1567)László Langó
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-02-07Function `jmem_heap_get_region_end` is unused when the system-allocator is ↵Zsolt Borbély
enabled (#1565) JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2017-01-30Use default system allocator on 32bit systems, if JERRY_SYSTEM_ALLOCATOR is ↵László Langó
defined. (#1541) JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2017-01-24Organize public and internal parts of memory management (#1539)László Langó
* Introduced new 'jmem.h' for public part. * Removed obsolete headers JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-12-08Streamline copyright notices across the codebase. (#1473)Tilmann Scheller
Since the project is now hosted at the JS Foundation we can move to unified copyright notices for the project. Starting with this commit all future contributions to the project should only carry the following copyright notice (except for third-party code which requires copyright information to be preserved): "Copyright JS Foundation and other contributors, http://js.foundation" (without the quotes) This avoids cluttering the codebase with contributor-specific copyright notices which have a higher maintenance overhead and tend to get outdated quickly. Also dropping the year from the copyright notices helps to avoid yearly code changes just to update the copyright notices. Note that each contributor still retains full copyright ownership of his/her contributions and the respective authorship is tracked very accurately via Git. JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
2016-11-29Replace `//` double slash comments with `/* */`. (#1461)Robert Sipka
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-09-30Undef VALGRIND_*_SPACE macros at the end of sources (#1382)Akos Kiss
Defining the same macros in multiple source files can cause macro re-definition warnings or errors in all-in-one builds. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-09-19Define `__attr_hot___` for `__attribute__((hot))` (#1359)Akos Kiss
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-09-01Add 32 bit compressed pointer support.Zoltan Herczeg
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-08-29Fix JMEM_HEAP_END_OF_LIST for pointers larger than 32 bitsAkos Kiss
For 64 bit pointers, 0xffffffff as end-of-list marker pointer does not work, as the marker is expected to be greater than the start address of the heap area (and also max 0xffffffff away), but on 64 bit systems, the heap can start on higher addresses, i.e., above 0x100000000. This patch changes JMEM_HEAP_END_OF_LIST from pointer to offset. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-19Remove allocator functions which stores size.Zoltan Herczeg
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-08-11Follow-up refactoring of logging-related partsAkos Kiss
This patch: * Ensures that all calls to `jerry_port_log` in jerry-core happen via macros defined in jrt.h. Also, it unifies the names of those macros: as `JERRY_ERROR_MSG` and `JERRY_WARNING_MSG` gave a good pattern that was well aligned with the naming scheme of the log level enum, `JERRY_DLOG` and `JERRY_DDLOG` were rewritten to `JERRY_DEBUG_MSG` and `JERRY_TRACE_MSG`. * Ensures that all debug logging code parts of jerry-core (i.e., memory statistics, JS byte-code dumps, and RegExp byte-code dumps) are guarded by macros: `JMEM_STATS`, `PARSER_DUMP_BYTE_CODE`, and `REGEXP_DUMP_BYTE_CODE`, which in turn are controled by cmake build system feature flags `FEATURE_MEM_STATS`, `FEATURE_PARSER_DUMP`, and `FEATURE_REGEXP_DUMP`. * Ensures that all debug logging functionalities can be controled during run time (provided that they were enabled during build time): the engine has `JERRY_INIT_MEM_STATS[_SEPARATE]`, `JERRY_INIT_SHOW_OPCODES`, `JERRY_INIT_SHOW_REGEXP_OPCODES` init flags, and the default unix/linux command line app has corresponding command line switches.` * Drops `FEATURE_LOG`, `JERRY_ENABLE_LOG`, and `JERRY_INIT_ENABLE_LOG`, as their name was misleadingly general, even though they mostly controled the regexp engine only. The above-mentioned `*REGEXP*` things mostly act as their replacements. * Updates build, test, and measurement tool scripts, and documentation. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2016-08-01Move all remaining globals to the global context.Zoltan Herczeg
Zero out all globals (and remove unnecessary init() functions). Move snapshot globals to a temporary stack variable. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-07-20More gc-friendly property hashmap allocation.István Kádár
- New allocator is added that returns null on out of memory, property hasmap create uses this allocator for now. - Property hashmaps of objects are removed durring a high severity gc. Follow up patch is in progress. JerryScript-DCO-1.0-Signed-off-by: István Kádár ikadar@inf.u-szeged.hu
2016-07-20Remove printf calls from jerry coreLászló Langó
Related issue: #964 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2016-07-19Introducing global context.Zoltan Herczeg
Currently the static variables of the allocator are moved into a global structure. The future plan is supporting multiple context models with different advantages and disadvantages. Users can select the most appropriate context model for their own use case. This context model must be selected at compile time using compiler defines. Currently only one model is implemented, which will be the default context model: the context is stored in global variables, so only a single context is available which always exists. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2016-06-14Introduce JERRY_UNUSED() instead of __attr_unused___Zsolt Borbély
JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
2016-06-13Rename try_give_memory_back to a better free_unused_memory.Zoltan Herczeg
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com