Rework usages/naming of configuration macros [part 2] (#2903)

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
This commit is contained in:
Péter Gál
2019-06-19 12:28:21 +02:00
committed by Dániel Bátyai
parent 985de93d04
commit 01ecc7bb7b
77 changed files with 1154 additions and 795 deletions
+387 -40
View File
@@ -16,12 +16,19 @@
#ifndef CONFIG_H
#define CONFIG_H
/**
* Built-in configurations
*
* Allowed values for built-in defines:
* 0: Disable the given built-in.
* 1: Enable the given built-in.
*/
/*
* By default all built-ins are enabled if they are not defined.
*/
#ifndef JERRY_BUILTINS
# define JERRY_BUILTINS 1
#endif
#endif /* !defined (JERRY_BUILTINS) */
#ifndef JERRY_BUILTIN_ANNEXB
# define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
@@ -64,11 +71,11 @@
#endif /* !defined (JERRY_BUILTIN_STRING) */
/**
* ES2015 related features, by default all of them are enabled.
* ES2015 (a.k.a es6) related features, by default all of them are enabled.
*/
#ifndef JERRY_ES2015
# define JERRY_ES2015 1
#endif
#endif /* !defined (JERRY_ES2015) */
#ifndef JERRY_ES2015_BUILTIN
# define JERRY_ES2015_BUILTIN JERRY_ES2015
@@ -135,38 +142,124 @@
#endif /* !defined (JERRY_ES2015_TEMPLATE_STRINGS) */
/**
* Enables/disables the RegExp strict mode
* Engine internal and misc configurations.
*/
/**
* Specifies the compressed pointer representation
*
* Allowed values:
* 0: use 16 bit representation
* 1: use 32 bit representation
*
* Default value: 0
* For more details see: jmem/jmem.h
*/
#ifndef JERRY_CPOINTER_32_BIT
# define JERRY_CPOINTER_32_BIT 0
#endif /* !defined (JERRY_CPOINTER_32_BIT) */
/**
* Enable/Disable built-in error messages for error objects.
*
* Allowed values:
* 0: Disable error messages.
* 1: Enable error message.
*
* Default value: 0
*/
#ifndef JERRY_REGEXP_STRICT_MODE
# define JERRY_REGEXP_STRICT_MODE 0
#endif
#ifndef JERRY_ERROR_MESSAGES
# define JERRY_ERROR_MESSAGES 0
#endif /* !defined (JERRY_ERROR_MESSAGES) */
/**
* Enables/disables the unicode case conversion in the engine.
* By default Unicode case conversion is enabled.
* Enable/Disable external context.
*
* Allowed values:
* 0: Disable external context.
* 1: Enable external context support.
*
* Default value: 0
*/
#ifndef JERRY_UNICODE_CASE_CONVERSION
# define JERRY_UNICODE_CASE_CONVERSION 1
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
#ifndef JERRY_EXTERNAL_CONTEXT
# define JERRY_EXTERNAL_CONTEXT 0
#endif /* !defined (JERRY_EXTERNAL_CONTEXT) */
/**
* Size of heap
* Maximum size of heap in kilobytes
*
* Default value: 512 KiB
*/
#ifndef CONFIG_MEM_HEAP_AREA_SIZE
# define CONFIG_MEM_HEAP_AREA_SIZE (512 * 1024)
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */
#ifndef JERRY_GLOBAL_HEAP_SIZE
# define JERRY_GLOBAL_HEAP_SIZE (512)
#endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */
/**
* Max heap usage limit
* Enable/Disable property lookup cache.
*
* Allowed values:
* 0: Disable lookup cache.
* 1: Enable lookup cache.
*
* Default value: 1
*/
#define CONFIG_MEM_HEAP_MAX_LIMIT 8192
#ifndef JERRY_LCACHE
# define JERRY_LCACHE 1
#endif /* !defined (JERRY_LCACHE) */
/**
* Desired limit of heap usage
* Enable/Disable line-info management inside the engine.
*
* Allowed values:
* 0: Disable line-info in the engine.
* 1: Enable line-info management.
*
* Default value: 0
*/
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (JERRY_MIN (CONFIG_MEM_HEAP_AREA_SIZE / 32, CONFIG_MEM_HEAP_MAX_LIMIT))
#ifndef JERRY_LINE_INFO
# define JERRY_LINE_INFO 0
#endif /* !defined (JERRY_LINE_INFO) */
/**
* Enable/Disable logging inside the engine.
*
* Allowed values:
* 0: Disable internal logging.
* 1: Enable internal logging.
*
* Default value: 0
*/
#ifndef JERRY_LOGGING
# define JERRY_LOGGING 0
#endif /* !defined (JERRY_LOGGING) */
/**
* Enable/Disable gc call before every allocation.
*
* Allowed values:
* 0: Disable gc call before each allocation.
* 1: Enable and force gc call before each allocation.
*
* Default value: 0
* Warning!: This is an advanced option and will slow down the engine!
* Only enable it for debugging purposes.
*/
#ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC
# define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
#endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */
/**
* Enable/Disable the collection if run-time memory statistics.
*
* Allowed values:
* 0: Disable run-time memory information collection.
* 1: Enable run-time memory statistics collection.
*
* Default value: 0
*/
#ifndef JERRY_MEM_STATS
# define JERRY_MEM_STATS 0
#endif /* !defined (JERRY_MEM_STATS) */
/**
* Use 32-bit/64-bit float for ecma-numbers
@@ -180,26 +273,204 @@
*/
#ifndef JERRY_NUMBER_TYPE_FLOAT64
# define JERRY_NUMBER_TYPE_FLOAT64 1
#endif
#endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Disable ECMA lookup cache
*/
// #define CONFIG_ECMA_LCACHE_DISABLE
/**
* Disable ECMA property hashmap
*/
// #define CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
/**
* Share of newly allocated since last GC objects among all currently allocated objects,
* after achieving which, GC is started upon low severity try-give-memory-back requests.
* Enable/Disable the JavaScript parser.
*
* Share is calculated as the following:
* 1.0 / CONFIG_ECMA_GC_NEW_OBJECTS_SHARE_TO_START_GC
* Allowed values:
* 0: Disable the JavaScript parser and all related functionallity.
* 1: Enable the JavaScript parser.
*
* Default value: 1
*/
#define CONFIG_ECMA_GC_NEW_OBJECTS_SHARE_TO_START_GC (16)
#ifndef JERRY_PARSER
# define JERRY_PARSER 1
#endif /* !defined (JERRY_PARSER) */
/**
* Enable/Disable JerryScript byte code dump functions during parsing.
* To dump the JerryScript byte code the engine must be initialized with opcodes
* display flag. This option does not influence RegExp byte code dumps.
*
* Allowed values:
* 0: Disable all bytecode dump functions.
* 1: Enable bytecode dump functions.
*
* Default value: 0
*/
#ifndef JERRY_PARSER_DUMP_BYTE_CODE
# define JERRY_PARSER_DUMP_BYTE_CODE 0
#endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */
/**
* Enable/Disable ECMA property hashmap.
*
* Allowed values:
* 0: Disable property hasmap.
* 1: Enable property hashmap.
*
* Default value: 1
*/
#ifndef JERRY_PROPRETY_HASHMAP
# define JERRY_PROPRETY_HASHMAP 1
#endif /* !defined (JERRY_PROPRETY_HASHMAP) */
/**
* Enable/Disable byte code dump functions for RegExp objects.
* To dump the RegExp byte code the engine must be initialized with
* regexp opcodes display flag. This option does not influence the
* JerryScript byte code dumps.
*
* Allowed values:
* 0: Disable all bytecode dump functions.
* 1: Enable bytecode dump functions.
*
* Default value: 0
*/
#ifndef JERRY_REGEXP_DUMP_BYTE_CODE
# define JERRY_REGEXP_DUMP_BYTE_CODE 0
#endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */
/**
* Enables/disables the RegExp strict mode
*
* Default value: 0
*/
#ifndef JERRY_REGEXP_STRICT_MODE
# define JERRY_REGEXP_STRICT_MODE 0
#endif /* !defined (JERRY_REGEXP_STRICT_MODE) */
/**
* Set the RegExp parser and execution recursion limit.
*
* Allowed values:
* 0: Disable recursion limit check.
* 1 or greater: Set the recursion limit to the given number.
*
* Note:
* A negative value will cause a static assert compiler error.
*
* Default value: 0
*/
#ifndef JERRY_REGEXP_RECURSION_LIMIT
# define JERRY_REGEXP_RECURSION_LIMIT 0
#endif /* !defined (JERRY_REGEXP_RECURSION_LIMIT) */
/**
* Enable/Disable the snapshot execution functions.
*
* Allowed values:
* 0: Disable snapshot execution.
* 1: Enable snapshot execution.
*
* Default value: 0
*/
#ifndef JERRY_SNAPSHOT_EXEC
# define JERRY_SNAPSHOT_EXEC 0
#endif /* !defined (JERRY_SNAPSHOT_EXEC) */
/**
* Enable/Disable the snapshot save functions.
*
* Allowed values:
* 0: Disable snapshot save functions.
* 1: Enable snapshot save functions.
*/
#ifndef JERRY_SNAPSHOT_SAVE
# define JERRY_SNAPSHOT_SAVE 0
#endif /* !defined (JERRY_SNAPSHOT_SAVE) */
/**
* Enable/Disable usage of system allocator.
*
* Allowed values:
* 0: Disable usage of system allocator.
* 1: Enable usage of system allocator.
*
* Default value: 0
*/
#ifndef JERRY_SYSTEM_ALLOCATOR
# define JERRY_SYSTEM_ALLOCATOR 0
#endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */
/**
* Enables/disables the unicode case conversion in the engine.
* By default Unicode case conversion is enabled.
*/
#ifndef JERRY_UNICODE_CASE_CONVERSION
# define JERRY_UNICODE_CASE_CONVERSION 1
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
/**
* Configures if the internal memory allocations are exposed to Valgrind or not.
*
* Allowed values:
* 0: Disable the Valgrind specific memory allocation notifications.
* 1: Enable the Valgrind specific allocation notifications.
*/
#ifndef JERRY_VALGRIND
# define JERRY_VALGRIND 0
#endif /* !defined (JERRY_VALGRIND) */
/**
* Enable/Disable the vm execution stop callback function.
*
* Allowed values:
* 0: Disable vm exec stop callbacks.
* 1: Enable vm exec stop callback functionality.
*/
#ifndef JERRY_VM_EXEC_STOP
# define JERRY_VM_EXEC_STOP 0
#endif /* !defined (JERRY_VM_EXEC_STOP) */
/**
* Set the VM execution recursion limit.
*
* Allowed values:
* 0: Disable recursion limit check.
* 1 or greater: Set the recursion limit to the given number.
*
* Note:
* A negative value will cause a static assert compiler error.
*
* Default value: 0
*/
#ifndef JERRY_VM_RECURSION_LIMIT
# define JERRY_VM_RECURSION_LIMIT 0
#endif /* !defined (JERRY_VM_RECURSION_LIMIT) */
/**
* Advanced section configurations.
*/
/**
* Allow configuring attributes on a few constant data inside the engine.
*
* One of the main usages:
* Normally compilers store const(ant)s in ROM. Thus saving RAM.
* But if your compiler does not support it then the directive below can force it.
*
* For the moment it is mainly meant for the following targets:
* - ESP8266
*
* Example configuration for moving (some) constatns into a given section:
* # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const")))
*/
#ifndef JERRY_ATTR_CONST_DATA
# define JERRY_ATTR_CONST_DATA
#endif /* !defined (JERRY_ATTR_CONST_DATA) */
/**
* The JERRY_ATTR_GLOBAL_HEAP allows adding extra attributes for the Jerry global heap.
*
* Example on how to move the global heap into it's own section:
* #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap")))
*/
#ifndef JERRY_ATTR_GLOBAL_HEAP
# define JERRY_ATTR_GLOBAL_HEAP
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
/**
@@ -330,14 +601,90 @@
/**
* Internal options.
*/
#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."
#if !defined (JERRY_CPOINTER_32_BIT) \
|| ((JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1))
# error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro."
#endif
#if !defined (JERRY_ERROR_MESSAGES) \
|| ((JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1))
# error "Invalid value for 'JERRY_ERROR_MESSAGES' macro."
#endif
#if !defined (JERRY_EXTERNAL_CONTEXT) \
|| ((JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1))
# error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro."
#endif
#if !defined (JERRY_GLOBAL_HEAP_SIZE) || (JERRY_GLOBAL_HEAP_SIZE <= 0)
# error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro."
#endif
#if !defined (JERRY_LCACHE) \
|| ((JERRY_LCACHE != 0) && (JERRY_LCACHE != 1))
# error "Invalid value for 'JERRY_LCACHE' macro."
#endif
#if !defined (JERRY_LINE_INFO) \
|| ((JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1))
# error "Invalid value for 'JERRY_LINE_INFO' macro."
#endif
#if !defined (JERRY_LOGGING) \
|| ((JERRY_LOGGING != 0) && (JERRY_LOGGING != 1))
# error "Invalid value for 'JERRY_LOGGING' macro."
#endif
#if !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) \
|| ((JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1))
# error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro."
#endif
#if !defined (JERRY_MEM_STATS) \
|| ((JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1))
# error "Invalid value for 'JERRY_MEM_STATS' macro."
#endif
#if !defined (JERRY_NUMBER_TYPE_FLOAT64) \
|| ((JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1))
# error "Invalid value for JERRY_NUMBER_TYPE_FLOAT64 macro."
# error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro."
#endif
#if !defined (JERRY_PARSER) \
|| ((JERRY_PARSER != 0) && (JERRY_PARSER != 1))
# error "Invalid value for 'JERRY_PARSER' macro."
#endif
#if !defined (JERRY_PARSER_DUMP_BYTE_CODE) \
|| ((JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1))
# error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro."
#endif
#if !defined (JERRY_PROPRETY_HASHMAP) \
|| ((JERRY_PROPRETY_HASHMAP != 0) && (JERRY_PROPRETY_HASHMAP != 1))
# error "Invalid value for 'JERRY_PROPRETY_HASHMAP' macro."
#endif
#if !defined (JERRY_REGEXP_DUMP_BYTE_CODE) \
|| ((JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1))
# error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro."
#endif
#if !defined (JERRY_REGEXP_STRICT_MODE) \
|| ((JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1))
# error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro."
#endif
#if !defined (JERRY_SNAPSHOT_EXEC) \
|| ((JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1))
# error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro."
#endif
#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
#define ENABLED(FEATURE) ((FEATURE) == 1)
#define DISABLED(FEATURE) ((FEATURE) != 1)