Support external context, heap and lcache (#1778)
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
This commit is contained in:
@@ -205,6 +205,11 @@ typedef void *(*jerry_user_context_init_t) (void);
|
||||
*/
|
||||
typedef void (*jerry_user_context_deinit_t) (void *user_context_p);
|
||||
|
||||
/**
|
||||
* Function type for allocating buffer for JerryScript instance.
|
||||
*/
|
||||
typedef void *(*jerry_instance_alloc_t) (size_t size, void *cb_data_p);
|
||||
|
||||
/**
|
||||
* Type information of a native pointer.
|
||||
*/
|
||||
@@ -213,6 +218,11 @@ typedef struct
|
||||
jerry_object_native_free_callback_t free_cb; /**< the free callback of the native pointer */
|
||||
} jerry_object_native_info_t;
|
||||
|
||||
/**
|
||||
* A forward declaration of the JerryScript instance structure.
|
||||
*/
|
||||
typedef struct jerry_instance_t jerry_instance_t;
|
||||
|
||||
/**
|
||||
* General engine functions.
|
||||
*/
|
||||
@@ -403,6 +413,11 @@ jerry_value_t jerry_resolve_or_reject_promise (jerry_value_t promise, jerry_valu
|
||||
bool jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, jerry_size_t buf_size);
|
||||
bool jerry_is_valid_cesu8_string (const jerry_char_t *cesu8_buf_p, jerry_size_t buf_size);
|
||||
|
||||
/*
|
||||
* External context functions.
|
||||
*/
|
||||
jerry_instance_t *jerry_create_instance (uint32_t heap_size, jerry_instance_alloc_t alloc, void *cb_data_p);
|
||||
|
||||
/**
|
||||
* Miscellaneous functions.
|
||||
*/
|
||||
|
||||
@@ -126,6 +126,18 @@ bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
|
||||
*/
|
||||
double jerry_port_get_current_time (void);
|
||||
|
||||
/**
|
||||
* Get the current instance, which contains the current context, heap and other infomation.
|
||||
* Each port should provide its own implementation of this interface.
|
||||
*
|
||||
*Note:
|
||||
* This port function will be called automatically by jerry-core
|
||||
* wnen JERRY_ENABLE_EXTERNAL_CONTEXT is defined. If not, this function will never be called.
|
||||
*
|
||||
* @return the pointer to the jerry instance.
|
||||
*/
|
||||
struct jerry_instance_t *jerry_port_get_current_instance (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user