aboutsummaryrefslogtreecommitdiff
path: root/jerry-core
diff options
context:
space:
mode:
authorZoltan Herczeg <zherczeg.u-szeged@partner.samsung.com>2018-06-15 09:31:48 +0200
committeryichoi <duddlf.choi@samsung.com>2018-06-15 16:31:48 +0900
commit1044523af77fce01e55da9ec9765b8e617116a89 (patch)
tree32f9aba0b53930bedffd71dfbe4b02624dd648a9 /jerry-core
parentbc827cb49731b60e5ac60ec38afaab9e14bfa7e7 (diff)
Add operational mode for jerry_gc API call. (#2385)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
Diffstat (limited to 'jerry-core')
-rw-r--r--jerry-core/api/jerry.c5
-rw-r--r--jerry-core/include/jerryscript-core.h15
2 files changed, 16 insertions, 4 deletions
diff --git a/jerry-core/api/jerry.c b/jerry-core/api/jerry.c
index cca137f9..52aa341e 100644
--- a/jerry-core/api/jerry.c
+++ b/jerry-core/api/jerry.c
@@ -289,11 +289,12 @@ jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p, /**< chara
* Run garbage collection
*/
void
-jerry_gc (void)
+jerry_gc (jerry_gc_mode_t mode) /**< operational mode */
{
jerry_assert_api_available ();
- ecma_gc_run (JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW);
+ ecma_gc_run (mode == JERRY_GC_SEVERITY_LOW ? JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW
+ : JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH);
} /* jerry_gc */
/**
diff --git a/jerry-core/include/jerryscript-core.h b/jerry-core/include/jerryscript-core.h
index d720c708..6862b230 100644
--- a/jerry-core/include/jerryscript-core.h
+++ b/jerry-core/include/jerryscript-core.h
@@ -100,10 +100,21 @@ typedef enum
typedef enum
{
JERRY_PARSE_NO_OPTS = 0, /**< no options passed */
- JERRY_PARSE_STRICT_MODE = (1 << 0), /**< enable strict mode */
+ JERRY_PARSE_STRICT_MODE = (1 << 0) /**< enable strict mode */
} jerry_parse_opts_t;
/**
+ * GC operational modes.
+ */
+typedef enum
+{
+ JERRY_GC_SEVERITY_LOW, /**< free unused objects, but keep memory
+ * allocated for performance improvements
+ * such as property hash tables for large objects */
+ JERRY_GC_SEVERITY_HIGH /**< free as much memory as possible */
+} jerry_gc_mode_t;
+
+/**
* Character type of JerryScript.
*/
typedef uint8_t jerry_char_t;
@@ -303,7 +314,7 @@ void jerry_init (jerry_init_flag_t flags);
void jerry_cleanup (void);
void jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p, uint32_t count,
const jerry_length_t *str_lengths_p);
-void jerry_gc (void);
+void jerry_gc (jerry_gc_mode_t mode);
void *jerry_get_context_data (const jerry_context_data_manager_t *manager_p);
bool jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p);