Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/NodeToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void initMem()
// printf("We satrt with: %ld free and stack:%ld \n", __startmem, __startStackMemory);
#endif
}
void displayStat(char *text)
void displayStat(const char *text)
{
pushToConsole(string_format(" %s :max used memory: %ld maxstack:%ld started %d free mem:%ld consumed %ld time:%dms", text, __maxMemUsage, __MaxStackMemory, __startmem, esp_get_free_heap_size(), __startmem - esp_get_free_heap_size(), (__endtime - __starttime) / 240000));
}
Expand Down Expand Up @@ -789,10 +789,14 @@ class NodeToken
int cur_size = 0;
if (_nodetype == extCallFunctionNode or _nodetype == callFunctionNode)
{
cur_size = getChildAtPos(1)->children_size();
for (int i = 0; i < getChildAtPos(2)->children_size(); i++)
NodeToken *child1 = getChildAtPos(1);
if (!child1) return cur_size; // nested extern call built without formal-param child — scalar, no spill needed
cur_size = child1->children_size();
NodeToken *child2 = getChildAtPos(2);
if (!child2) return cur_size;
for (int i = 0; i < child2->children_size(); i++)
{
int cmp = getChildAtPos(2)->getChildAtPos(i)->findMaxArgumentSize();
int cmp = child2->getChildAtPos(i)->findMaxArgumentSize();
if (cmp > cur_size)
cur_size = cmp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/asm_struct_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Text
// _texts.push_back(cc);
_it = _texts.begin();
}
int findText(char * str)
int findText(const char * str)
{
#ifdef __SPEED
return -1;
Expand Down
67 changes: 37 additions & 30 deletions src/execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
#ifndef __RUN_CORE
#define __RUN_CORE 0
#endif
#ifndef __LS_STACK_CAPS
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32P4)
#define __LS_STACK_CAPS (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)
#else
#define __LS_STACK_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#endif
#endif
using namespace std;
#ifndef _MAX_PROG_AT_ONCE
#define _MAX_PROG_AT_ONCE 10
Expand Down Expand Up @@ -507,7 +514,7 @@ class Executable

if (__run_handle_index != 9999)
{
vTaskDelete(*runningPrograms.getHandleByIndex(__run_handle_index));
vTaskDeleteWithCaps(*runningPrograms.getHandleByIndex(__run_handle_index));
}

_isRunning = false;
Expand All @@ -531,7 +538,7 @@ class Executable
#endif
}

int _run(vector<string> args, bool second_core, int core, Arguments arguments, string json)
int _run(vector<string> args, bool second_core, int core, Arguments arguments, string json, uint32_t stack_size = 4096 * 2)
{
__run_handle_index = 9999;
#ifndef __TEST_DEBUG
Expand Down Expand Up @@ -580,7 +587,7 @@ class Executable
taskname = string_format("_run_task_%d", __run_handle_index);
else
taskname = string_format("%s_%d", name.c_str(), __run_handle_index);
xTaskCreateUniversal(_run_task, taskname.c_str(), 4096 * 2, this, 3, (TaskHandle_t *)runningPrograms.getHandleByIndex(__run_handle_index), core);
xTaskCreatePinnedToCoreWithCaps(_run_task, taskname.c_str(), stack_size, this, 3, (TaskHandle_t *)runningPrograms.getHandleByIndex(__run_handle_index), core, __LS_STACK_CAPS);

pushToConsole("Execution on going CTRL + k to stop", true);
}
Expand Down Expand Up @@ -695,7 +702,7 @@ class Executable
}
return false;
}
void executeAsTask(string prog, int core, Arguments arguments, string json)
void executeAsTask(string prog, int core, Arguments arguments, string json, uint32_t stack_size = 8192)
{
// printf("herqsd sqdsq\n");
args.clear();
Expand All @@ -708,7 +715,7 @@ class Executable
{
vector<string> __args;
__args.push_back("@__" + prog);
_run(__args, true, core, arguments, json);
_run(__args, true, core, arguments, json, stack_size);
}
else
{
Expand All @@ -717,30 +724,30 @@ class Executable
#endif
}

void executeAsTask(string prog, int core, Arguments arguments)
void executeAsTask(string prog, int core, Arguments arguments, uint32_t stack_size = 8192)
{
executeAsTask(prog, core, arguments, "");
executeAsTask(prog, core, arguments, "", stack_size);
}
void executeAsTask(string prog, Arguments arguments)
void executeAsTask(string prog, Arguments arguments, uint32_t stack_size = 8192)
{
executeAsTask(prog, __RUN_CORE, arguments);
executeAsTask(prog, __RUN_CORE, arguments, stack_size);
}
void executeAsTask(string prog)
void executeAsTask(string prog, uint32_t stack_size = 8192)
{
args.clear();
executeAsTask(prog, __RUN_CORE, args);
executeAsTask(prog, __RUN_CORE, args, stack_size);
}

void executeAsTask(string prog, int core)
void executeAsTask(string prog, int core, uint32_t stack_size = 8192)
{
args.clear();
executeAsTask(prog, core, args);
executeAsTask(prog, core, args, stack_size);
}
void executeAsTask(string prog, string json)
void executeAsTask(string prog, string json, uint32_t stack_size = 8192)
{
// printf("her\n");
args.clear();
executeAsTask(prog, __RUN_CORE, args, json);
executeAsTask(prog, __RUN_CORE, args, json, stack_size);
}
#endif
bool isRunning()
Expand Down Expand Up @@ -802,7 +809,7 @@ static void _run_task(void *pvParameters)
exec->_isRunning = false;
runningPrograms.removeHandle(exec->__run_handle_index);
isSyncalled = false;
vTaskDelete(NULL);
vTaskDeleteWithCaps(xTaskGetCurrentTaskHandle());
#endif
}

Expand Down Expand Up @@ -952,81 +959,81 @@ class _ScriptRuntime
}
}

void executeAsTask(string name, Arguments arguments)
void executeAsTask(string name, Arguments arguments, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask("main", arguments);
exec->executeAsTask("main", arguments, stack_size);
#endif
}
}
void executeAsTask(string name)
void executeAsTask(string name, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask("main");
exec->executeAsTask("main", stack_size);
#endif
}
}
void executeAsTaskJ(string name, string json)
void executeAsTaskJ(string name, string json, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask("main", json);
exec->executeAsTask("main", json, stack_size);
#endif
}
}
void executeAsTask(string name, string function, Arguments arguments)
void executeAsTask(string name, string function, Arguments arguments, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask(function, arguments);
exec->executeAsTask(function, arguments, stack_size);
#endif
}
}

void executeAsTask(string name, string function)
void executeAsTask(string name, string function, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask(function);
exec->executeAsTask(function, stack_size);
#endif
}
}
void executeAsTask(string name, int core, Arguments args)
void executeAsTask(string name, int core, Arguments args, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask("main", core, args);
exec->executeAsTask("main", core, args, stack_size);
#endif
}
}
void executeAsTask(string name, int core)
void executeAsTask(string name, int core, uint32_t stack_size = 8192)
{
Executable *exec = findExecutable(name);
if (exec != NULL)
{
#ifndef __TEST_DEBUG

exec->executeAsTask("main", core);
exec->executeAsTask("main", core, stack_size);
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/execute_asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ void freeExecutable(executable *ex)
if (ex->start_program != NULL)
{

heap_caps_aligned_free(ex->start_program);
heap_caps_free(ex->start_program);
}

ex->start_program = NULL;
Expand Down
5 changes: 3 additions & 2 deletions src/functionlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ __ASM__ float __div(float a,float b)\n\
\"divn.s f0, f2, f6\"\n\
\"retw.n\"\n\
}@";
char * _div[]={
const char * _div[]={
"@___div(d|d):",
"entry a1,16",
"div0.s f3, f2",
Expand Down Expand Up @@ -109,7 +109,8 @@ __ASM__ uint32_t rand(uint32_t mod) \n\
\"retw.n\" \n\
}@";
#else
string _rand="\__ASM__ uint32_t rand(uint32_t mod) \n\
string _rand="\
__ASM__ uint32_t rand(uint32_t mod) \n\
{\n\
\"entry a1,56\" \n\
//\"l32r a4,@_stack_rand(d)\" \n\
Expand Down