diff --git a/jerry-core/api/jerryscript_adapter.c b/jerry-core/api/jerryscript_adapter.c index 1b751f5a92e9485d87d0b6371938330e59296886..9b10273551014ab0d713d8f4583ff01f55f9c5e9 100644 --- a/jerry-core/api/jerryscript_adapter.c +++ b/jerry-core/api/jerryscript_adapter.c @@ -18,11 +18,16 @@ #include "jerryscript.h" #include "jmem.h" #include "config-jupiter.h" +#include "generate-bytecode.h" +#include "los_task.h" + +#define MAX_CONTEXT_NUM (g_taskMaxNum+1) uint8_t* input_buffer; uint8_t* snapshot_buffer; uint8_t* bms_context_and_heap; uint8_t* js_context_and_heap; +ContextRecord* g_contextRecords; void JerryPsRamMemInit() { @@ -42,4 +47,12 @@ void JerryBmsPsRamMemInit() bms_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_LSRAM, BMS_TASK_CONTEXT_AND_HEAP_SIZE * CONVERTION_RATIO); } +void JerryInitContextRecords() +{ + g_contextRecords = (ContextRecord*)OhosMalloc(MEM_TYPE_JERRY, (MAX_CONTEXT_NUM) * sizeof(ContextRecord)); + if (g_contextRecords == NULL) { + jerry_port_log (JERRY_LOG_LEVEL_ERROR, "[JERRYSCRIPT]Init g_contextRecords Error.\n"); + } +} + #endif // JERRY_IAR_JUPITER diff --git a/jerry-core/include/jerryscript_adapter.h b/jerry-core/include/jerryscript_adapter.h index dd8d63bf44bfd30ccc5f66bd8740347c477b99b1..5af4e82fa28b7ebc79f4cced5ecd751794fe9102 100755 --- a/jerry-core/include/jerryscript_adapter.h +++ b/jerry-core/include/jerryscript_adapter.h @@ -14,6 +14,7 @@ extern "C" void JerryPsRamMemInit(); void JerryBmsPsRamMemInit(); +void JerryInitContextRecords(); #ifdef __cplusplus } diff --git a/jerry-port/default/default-external-context.c b/jerry-port/default/default-external-context.c index c08363eeb522a6d4a9a7d16bcb07e87c3e6445e2..46ac88dc450724a5bdac34d3abe66ba11e9e4a9c 100755 --- a/jerry-port/default/default-external-context.c +++ b/jerry-port/default/default-external-context.c @@ -24,13 +24,11 @@ extern jerry_context_t *jerry_dynamic_global_context_p; #include "generate-bytecode.h" #include "los_task.h" -#include "target_config.h" /** - * use array to record the correspondence between task id and jerry-heap/context + * use dynamic size array to record the correspondence between task id and jerry-heap/context */ -#define MAX_CONTEXT_NUM (LOSCFG_BASE_CORE_TSK_LIMIT+1) -ContextRecord g_contextRecords[MAX_CONTEXT_NUM] = {0}; +extern ContextRecord* g_contextRecords; void jerry_switch_context();