mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add objCnt
ready to check where enable the mark_sweep auto gc with threshold failed, add some assert more assert about obj alive, dict mark not correct add pikaGC_try, but cannot run at any time markSweep crashed on keyword save gcRoot for obj to debug add debug point add kernal_debug config to keep more debug info use @res_<opt> to mark operation found self reference on __iter__() can not fix gc err around iter remove lock, only keep the self lock more obj info for debug only pikaui not pass only pikaui not pass
This commit is contained in:
parent
f0fecebc78
commit
7f5edaf090
@ -8,12 +8,14 @@
|
||||
#include "dataStrs.h"
|
||||
|
||||
Arg* PikaStdData_Dict_get(PikaObj* self, char* key) {
|
||||
pika_assert_obj_alive(self);
|
||||
PikaDict* dict = obj_getPtr(self, "dict");
|
||||
Arg* res = pikaDict_getArg(dict, key);
|
||||
if (NULL == res) {
|
||||
obj_setErrorCode(self, PIKA_RES_ERR_RUNTIME_ERROR);
|
||||
__platform_printf("KeyError: %s\n", key);
|
||||
}
|
||||
pika_assert_arg_alive(res);
|
||||
return arg_copy(res);
|
||||
}
|
||||
|
||||
@ -271,7 +273,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
|
||||
const uint8_t
|
||||
bytes[] =
|
||||
{
|
||||
0x40, 0x00, 0x00, 0x00,/* instruct array size */
|
||||
0x40, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x04,
|
||||
0x0d, 0x00, 0x00, 0x82, 0x11, 0x00, 0x00, 0x04, 0x1e, 0x00,
|
||||
0x00, 0x0d, 0x1e, 0x00, 0x00, 0x07, 0x24, 0x00, 0x11, 0x81,
|
||||
@ -279,7 +281,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
|
||||
0x21, 0x01, 0x1e, 0x00, 0x11, 0x1d, 0x00, 0x00, 0x01, 0x02,
|
||||
0x2c, 0x00, 0x01, 0x04, 0x26, 0x00, 0x00, 0x86, 0x38, 0x00,
|
||||
0x00, 0x8c, 0x0d, 0x00, /* instruct array */
|
||||
0x3b, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x3b, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x40, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x00, 0x69, 0x74,
|
||||
0x65, 0x72, 0x00, 0x24, 0x6c, 0x30, 0x00, 0x24, 0x6c, 0x30,
|
||||
0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00,
|
||||
|
@ -169,29 +169,31 @@ char* PikaStdLib_SysObj_str(PikaObj* self, Arg* arg) {
|
||||
|
||||
Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
|
||||
/* object */
|
||||
PIKA_BOOL is_temp = PIKA_FALSE;
|
||||
PikaObj* arg_obj = _arg_to_obj(arg, &is_temp);
|
||||
NewFun _clsptr = (NewFun)arg_obj->constructor;
|
||||
PIKA_BOOL bIsTemp = PIKA_FALSE;
|
||||
PikaObj* oArg = _arg_to_obj(arg, &bIsTemp);
|
||||
NewFun _clsptr = (NewFun)oArg->constructor;
|
||||
if (_clsptr == New_PikaStdLib_RangeObj) {
|
||||
/* found RangeObj, return directly */
|
||||
return arg_copy(arg);
|
||||
}
|
||||
// pikaVM_runAsm(arg_obj,
|
||||
// "B0\n"
|
||||
// "0 RUN __iter__\n"
|
||||
// "0 OUT __res\n");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
@res_iter = __iter__()
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0a, 0x00, /* instruct array */
|
||||
0x10, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x5f,
|
||||
0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
|
||||
0x14, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x5f, 0x5f, 0x00, 0x40,
|
||||
0x72, 0x65, 0x73, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(arg_obj, (uint8_t*)bytes);
|
||||
Arg* res = arg_copy(args_getArg(arg_obj->list, "__res"));
|
||||
obj_removeArg(arg_obj, "__res");
|
||||
if (is_temp) {
|
||||
obj_refcntDec(arg_obj);
|
||||
pikaVM_runByteCode(oArg, (uint8_t*)bytes);
|
||||
Arg* res = arg_copy(args_getArg(oArg->list, "@res_iter"));
|
||||
obj_setFlag(arg_getPtr(res), OBJ_FLAG_GC_ROOT);
|
||||
obj_removeArg(oArg, "@res_iter");
|
||||
if (bIsTemp) {
|
||||
obj_refcntDec(oArg);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -296,22 +298,22 @@ int PikaStdLib_SysObj_len(PikaObj* self, Arg* arg) {
|
||||
Arg* method_arg = obj_getMethodArg(arg_obj, "__len__");
|
||||
if (NULL != method_arg) {
|
||||
arg_deinit(method_arg);
|
||||
|
||||
obj_removeArg(arg_obj, "@res_len");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __len__()
|
||||
)
|
||||
PIKA_PYTHON(
|
||||
@res_len = __len__()
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct
|
||||
array */
|
||||
0x0f, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6c, 0x65, 0x6e, 0x5f, 0x5f, 0x00,
|
||||
0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
|
||||
0x12, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6c, 0x65, 0x6e, 0x5f, 0x5f, 0x00, 0x40,
|
||||
0x72, 0x65, 0x73, 0x5f, 0x6c, 0x65, 0x6e, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(arg_obj, (uint8_t*)bytes);
|
||||
return obj_getInt(arg_obj, "__res");
|
||||
return obj_getInt(arg_obj, "@res_len");
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,35 +327,37 @@ Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
|
||||
if (1 == pikaTuple_getSize(val)) {
|
||||
Arg* in = pikaTuple_getArg(val, 0);
|
||||
obj_setArg(self, "__list", in);
|
||||
obj_removeArg(self, "@res_list");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = []
|
||||
@res_list = []
|
||||
for __item in __list:
|
||||
__res.append(__item)
|
||||
@res_list.append(__item)
|
||||
del __item
|
||||
del __list
|
||||
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x3c, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x07,
|
||||
0x00, 0x00, 0x02, 0x0e, 0x00, 0x00, 0x04, 0x13, 0x00, 0x00, 0x82,
|
||||
0x17, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x0d, 0x24, 0x00, 0x00,
|
||||
0x07, 0x2b, 0x00, 0x11, 0x81, 0x24, 0x00, 0x01, 0x02, 0x2d, 0x00,
|
||||
0x00, 0x86, 0x3a, 0x00, 0x00, 0x8c, 0x13, 0x00, 0x00, 0x8c, 0x24,
|
||||
0x00, 0x00, 0x8c, 0x07, 0x00,
|
||||
0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x0b,
|
||||
0x00, 0x00, 0x02, 0x12, 0x00, 0x00, 0x04, 0x17, 0x00, 0x00, 0x82,
|
||||
0x1b, 0x00, 0x00, 0x04, 0x28, 0x00, 0x00, 0x0d, 0x28, 0x00, 0x00,
|
||||
0x07, 0x2f, 0x00, 0x11, 0x81, 0x28, 0x00, 0x01, 0x02, 0x31, 0x00,
|
||||
0x00, 0x86, 0x42, 0x00, 0x00, 0x8c, 0x17, 0x00, 0x00, 0x8c, 0x28,
|
||||
0x00, 0x00, 0x8c, 0x0b, 0x00,
|
||||
/* instruct array */
|
||||
0x3d, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, 0x5f, 0x5f, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30,
|
||||
0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74,
|
||||
0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x00, 0x32,
|
||||
0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65,
|
||||
0x6e, 0x64, 0x00, 0x2d, 0x31, 0x00,
|
||||
/* const pool */
|
||||
0x45, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x40, 0x72, 0x65, 0x73, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x00,
|
||||
0x5f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72,
|
||||
0x00, 0x24, 0x6c, 0x30, 0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f,
|
||||
0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x69, 0x74,
|
||||
0x65, 0x6d, 0x00, 0x32, 0x00, 0x40, 0x72, 0x65, 0x73, 0x5f, 0x6c,
|
||||
0x69, 0x73, 0x74, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x00,
|
||||
0x2d, 0x31, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(self, (uint8_t*)bytes);
|
||||
return arg_copy(obj_getArg(self, "__res"));
|
||||
return arg_copy(obj_getArg(self, "@res_list"));
|
||||
}
|
||||
PikaObj* New_PikaStdData_List(Args * args);
|
||||
return arg_newDirectObj(New_PikaStdData_List);
|
||||
|
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
"--gtest_filter=event.remove_regist"
|
||||
"--gtest_filter=pikaui.*"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
3
port/linux/.vscode/settings.json
vendored
3
port/linux/.vscode/settings.json
vendored
@ -122,6 +122,7 @@
|
||||
},
|
||||
"python.formatting.provider": "autopep8",
|
||||
"clangd.arguments": [
|
||||
"-compile-commands-dir=build"
|
||||
"-compile-commands-dir=build",
|
||||
"-header-insertion=never"
|
||||
]
|
||||
}
|
@ -28,7 +28,7 @@ void checker_memInfo(void)
|
||||
{
|
||||
printf("---------------------------\r\n");
|
||||
printf("Memory pool info:\r\n");
|
||||
checker_printMem(" mem state size = ", sizeof(pikaMemInfo));
|
||||
checker_printMem(" mem state size = ", sizeof(PikaMemInfo));
|
||||
printf("---------------------------\r\n");
|
||||
}
|
||||
void checker_assertMemFree()
|
||||
|
@ -6,4 +6,6 @@
|
||||
#define PIKA_INSTRUCT_HOOK_ENABLE 1
|
||||
#define PIKA_INSTRUCT_HOOK_PERIOD 1
|
||||
#define PIKA_SHELL_FILTER_ENABLE 1
|
||||
#define PIKA_GC_MARK_SWEEP_ENABLE 1
|
||||
#define PIKA_GC_MARK_SWEEP_ENABLE 1
|
||||
#define PIKA_GC_MARK_SWEEP_THRESHOLD 1
|
||||
#define PIKA_KERNAL_DEBUG_ENABLE 1
|
@ -337,9 +337,9 @@ stack_init(&bs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
TEST(parser, while_true_if_false_both_exit) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* bf = New_strBuff();
|
||||
Stack bs;
|
||||
stack_init(&bs);
|
||||
@ -377,7 +377,7 @@ stack_init(&bs);
|
||||
}
|
||||
|
||||
TEST(parser, multiLine) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines =(char *)
|
||||
"while true:\n"
|
||||
@ -414,7 +414,7 @@ TEST(parser, multiLine) {
|
||||
}
|
||||
|
||||
TEST(parser, pikaPi) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
const char lines[] =
|
||||
@ -533,7 +533,7 @@ TEST(parser, pikaPi) {
|
||||
}
|
||||
|
||||
TEST(parser, add) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = 1 + 1\n";
|
||||
printf("%s", lines);
|
||||
@ -550,7 +550,7 @@ TEST(parser, add) {
|
||||
}
|
||||
|
||||
TEST(parser, add_3) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = 1 + 2 + 3\n";
|
||||
printf("%s", lines);
|
||||
@ -569,7 +569,7 @@ TEST(parser, add_3) {
|
||||
}
|
||||
|
||||
TEST(parser, add_a_pp) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = a + 1\n";
|
||||
printf("%s", lines);
|
||||
@ -586,7 +586,7 @@ TEST(parser, add_a_pp) {
|
||||
}
|
||||
|
||||
TEST(parser, while_a_pp) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)
|
||||
"while a < 10:\n"
|
||||
@ -618,7 +618,7 @@ TEST(parser, while_a_pp) {
|
||||
}
|
||||
|
||||
TEST(parser, add_m2p3) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = 1 * 2 + 3\n";
|
||||
printf("%s", lines);
|
||||
@ -637,7 +637,7 @@ TEST(parser, add_m2p3) {
|
||||
}
|
||||
|
||||
TEST(parser, add_m2p3_) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = 1 * (2 + 3)\n";
|
||||
printf("%s", lines);
|
||||
@ -657,7 +657,7 @@ TEST(parser, add_m2p3_) {
|
||||
}
|
||||
|
||||
TEST(parser, add_m12p3_) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = (1 + 2) * 3\n";
|
||||
printf("%s", lines);
|
||||
@ -677,7 +677,7 @@ TEST(parser, add_m12p3_) {
|
||||
}
|
||||
|
||||
TEST(parser, method_equ) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"if right.read() == 1:\n";
|
||||
printf("%s", lines);
|
||||
@ -694,7 +694,7 @@ TEST(parser, method_equ) {
|
||||
}
|
||||
|
||||
TEST(parser, equ_method) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"if 1 == right.read() :\n";
|
||||
printf("%s", lines);
|
||||
@ -711,7 +711,7 @@ TEST(parser, equ_method) {
|
||||
}
|
||||
|
||||
TEST(parser, def_add) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)
|
||||
"def add(a, b):\n"
|
||||
@ -737,7 +737,7 @@ TEST(parser, def_add) {
|
||||
}
|
||||
|
||||
TEST(parser, def_add_return) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)
|
||||
"def add(a, b):\n"
|
||||
@ -764,7 +764,7 @@ TEST(parser, def_add_return) {
|
||||
}
|
||||
|
||||
TEST(parser, def_while_return) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)
|
||||
"def add(a, b):\n"
|
||||
@ -797,7 +797,7 @@ TEST(parser, def_while_return) {
|
||||
}
|
||||
|
||||
TEST(parser, def_while_return_void) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)
|
||||
"def add(a, b):\n"
|
||||
@ -827,7 +827,7 @@ TEST(parser, def_while_return_void) {
|
||||
}
|
||||
|
||||
TEST(parser, signed_num) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = -1\n";
|
||||
printf("%s", lines);
|
||||
@ -843,7 +843,7 @@ TEST(parser, signed_num) {
|
||||
}
|
||||
|
||||
TEST(parser, comp_signed_num) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"if a > -1:\n";
|
||||
printf("%s", lines);
|
||||
@ -862,7 +862,7 @@ TEST(parser, comp_signed_num) {
|
||||
|
||||
TEST(lexser, symbol_add) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -881,7 +881,7 @@ TEST(lexser, symbol_add) {
|
||||
|
||||
TEST(lexser, symbol_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -899,7 +899,7 @@ TEST(lexser, symbol_1) {
|
||||
|
||||
TEST(lexser, operator_not) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -917,7 +917,7 @@ TEST(lexser, operator_not) {
|
||||
|
||||
TEST(lexser, symbol_Nag) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -935,7 +935,7 @@ TEST(lexser, symbol_Nag) {
|
||||
|
||||
TEST(lexser, operator_all) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -967,7 +967,7 @@ TEST(lexser, operator_all) {
|
||||
|
||||
TEST(lexser, symbol_2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -987,7 +987,7 @@ TEST(lexser, symbol_2) {
|
||||
|
||||
TEST(lexser, symbol_and) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -1007,7 +1007,7 @@ TEST(lexser, symbol_and) {
|
||||
|
||||
TEST(lexser, sting) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -1025,7 +1025,7 @@ TEST(lexser, sting) {
|
||||
|
||||
TEST(lexser, num_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -1043,7 +1043,7 @@ TEST(lexser, num_1) {
|
||||
|
||||
TEST(lexser, jjcc) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
@ -1074,7 +1074,7 @@ TEST(parser, pop_by_str) {
|
||||
}
|
||||
|
||||
TEST(parser, mm) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = a ** -1\n";
|
||||
printf("%s", lines);
|
||||
@ -1092,7 +1092,7 @@ TEST(parser, mm) {
|
||||
}
|
||||
|
||||
TEST(parser, self_inc) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)
|
||||
"a += -1\n"
|
||||
@ -1156,7 +1156,7 @@ TEST(parser, self_inc) {
|
||||
}
|
||||
|
||||
TEST(parser, n_n1) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = ~-1\n";
|
||||
printf("%s", lines);
|
||||
@ -1173,7 +1173,7 @@ TEST(parser, n_n1) {
|
||||
}
|
||||
|
||||
TEST(parser, or_) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"( a>1) or (b<= 3)\n";
|
||||
printf("%s", lines);
|
||||
|
@ -8,12 +8,14 @@
|
||||
#include "dataStrs.h"
|
||||
|
||||
Arg* PikaStdData_Dict_get(PikaObj* self, char* key) {
|
||||
pika_assert_obj_alive(self);
|
||||
PikaDict* dict = obj_getPtr(self, "dict");
|
||||
Arg* res = pikaDict_getArg(dict, key);
|
||||
if (NULL == res) {
|
||||
obj_setErrorCode(self, PIKA_RES_ERR_RUNTIME_ERROR);
|
||||
__platform_printf("KeyError: %s\n", key);
|
||||
}
|
||||
pika_assert_arg_alive(res);
|
||||
return arg_copy(res);
|
||||
}
|
||||
|
||||
@ -271,7 +273,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
|
||||
const uint8_t
|
||||
bytes[] =
|
||||
{
|
||||
0x40, 0x00, 0x00, 0x00,/* instruct array size */
|
||||
0x40, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x04,
|
||||
0x0d, 0x00, 0x00, 0x82, 0x11, 0x00, 0x00, 0x04, 0x1e, 0x00,
|
||||
0x00, 0x0d, 0x1e, 0x00, 0x00, 0x07, 0x24, 0x00, 0x11, 0x81,
|
||||
@ -279,7 +281,7 @@ void PikaStdData_Dict_update(PikaObj* self, PikaObj* other) {
|
||||
0x21, 0x01, 0x1e, 0x00, 0x11, 0x1d, 0x00, 0x00, 0x01, 0x02,
|
||||
0x2c, 0x00, 0x01, 0x04, 0x26, 0x00, 0x00, 0x86, 0x38, 0x00,
|
||||
0x00, 0x8c, 0x0d, 0x00, /* instruct array */
|
||||
0x3b, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x3b, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x40, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x00, 0x69, 0x74,
|
||||
0x65, 0x72, 0x00, 0x24, 0x6c, 0x30, 0x00, 0x24, 0x6c, 0x30,
|
||||
0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00,
|
||||
|
@ -169,29 +169,31 @@ char* PikaStdLib_SysObj_str(PikaObj* self, Arg* arg) {
|
||||
|
||||
Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
|
||||
/* object */
|
||||
PIKA_BOOL is_temp = PIKA_FALSE;
|
||||
PikaObj* arg_obj = _arg_to_obj(arg, &is_temp);
|
||||
NewFun _clsptr = (NewFun)arg_obj->constructor;
|
||||
PIKA_BOOL bIsTemp = PIKA_FALSE;
|
||||
PikaObj* oArg = _arg_to_obj(arg, &bIsTemp);
|
||||
NewFun _clsptr = (NewFun)oArg->constructor;
|
||||
if (_clsptr == New_PikaStdLib_RangeObj) {
|
||||
/* found RangeObj, return directly */
|
||||
return arg_copy(arg);
|
||||
}
|
||||
// pikaVM_runAsm(arg_obj,
|
||||
// "B0\n"
|
||||
// "0 RUN __iter__\n"
|
||||
// "0 OUT __res\n");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
@res_iter = __iter__()
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0a, 0x00, /* instruct array */
|
||||
0x10, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x5f,
|
||||
0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
|
||||
0x14, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x5f, 0x5f, 0x00, 0x40,
|
||||
0x72, 0x65, 0x73, 0x5f, 0x69, 0x74, 0x65, 0x72, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(arg_obj, (uint8_t*)bytes);
|
||||
Arg* res = arg_copy(args_getArg(arg_obj->list, "__res"));
|
||||
obj_removeArg(arg_obj, "__res");
|
||||
if (is_temp) {
|
||||
obj_refcntDec(arg_obj);
|
||||
pikaVM_runByteCode(oArg, (uint8_t*)bytes);
|
||||
Arg* res = arg_copy(args_getArg(oArg->list, "@res_iter"));
|
||||
obj_setFlag(arg_getPtr(res), OBJ_FLAG_GC_ROOT);
|
||||
obj_removeArg(oArg, "@res_iter");
|
||||
if (bIsTemp) {
|
||||
obj_refcntDec(oArg);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -296,22 +298,22 @@ int PikaStdLib_SysObj_len(PikaObj* self, Arg* arg) {
|
||||
Arg* method_arg = obj_getMethodArg(arg_obj, "__len__");
|
||||
if (NULL != method_arg) {
|
||||
arg_deinit(method_arg);
|
||||
|
||||
obj_removeArg(arg_obj, "@res_len");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __len__()
|
||||
)
|
||||
PIKA_PYTHON(
|
||||
@res_len = __len__()
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct
|
||||
array */
|
||||
0x0f, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6c, 0x65, 0x6e, 0x5f, 0x5f, 0x00,
|
||||
0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
|
||||
0x12, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6c, 0x65, 0x6e, 0x5f, 0x5f, 0x00, 0x40,
|
||||
0x72, 0x65, 0x73, 0x5f, 0x6c, 0x65, 0x6e, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(arg_obj, (uint8_t*)bytes);
|
||||
return obj_getInt(arg_obj, "__res");
|
||||
return obj_getInt(arg_obj, "@res_len");
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,35 +327,37 @@ Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
|
||||
if (1 == pikaTuple_getSize(val)) {
|
||||
Arg* in = pikaTuple_getArg(val, 0);
|
||||
obj_setArg(self, "__list", in);
|
||||
obj_removeArg(self, "@res_list");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = []
|
||||
@res_list = []
|
||||
for __item in __list:
|
||||
__res.append(__item)
|
||||
@res_list.append(__item)
|
||||
del __item
|
||||
del __list
|
||||
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x3c, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x07,
|
||||
0x00, 0x00, 0x02, 0x0e, 0x00, 0x00, 0x04, 0x13, 0x00, 0x00, 0x82,
|
||||
0x17, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x0d, 0x24, 0x00, 0x00,
|
||||
0x07, 0x2b, 0x00, 0x11, 0x81, 0x24, 0x00, 0x01, 0x02, 0x2d, 0x00,
|
||||
0x00, 0x86, 0x3a, 0x00, 0x00, 0x8c, 0x13, 0x00, 0x00, 0x8c, 0x24,
|
||||
0x00, 0x00, 0x8c, 0x07, 0x00,
|
||||
0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x0b,
|
||||
0x00, 0x00, 0x02, 0x12, 0x00, 0x00, 0x04, 0x17, 0x00, 0x00, 0x82,
|
||||
0x1b, 0x00, 0x00, 0x04, 0x28, 0x00, 0x00, 0x0d, 0x28, 0x00, 0x00,
|
||||
0x07, 0x2f, 0x00, 0x11, 0x81, 0x28, 0x00, 0x01, 0x02, 0x31, 0x00,
|
||||
0x00, 0x86, 0x42, 0x00, 0x00, 0x8c, 0x17, 0x00, 0x00, 0x8c, 0x28,
|
||||
0x00, 0x00, 0x8c, 0x0b, 0x00,
|
||||
/* instruct array */
|
||||
0x3d, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, 0x5f, 0x5f, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30,
|
||||
0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74,
|
||||
0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x00, 0x32,
|
||||
0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65,
|
||||
0x6e, 0x64, 0x00, 0x2d, 0x31, 0x00,
|
||||
/* const pool */
|
||||
0x45, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x40, 0x72, 0x65, 0x73, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x00,
|
||||
0x5f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72,
|
||||
0x00, 0x24, 0x6c, 0x30, 0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f,
|
||||
0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x69, 0x74,
|
||||
0x65, 0x6d, 0x00, 0x32, 0x00, 0x40, 0x72, 0x65, 0x73, 0x5f, 0x6c,
|
||||
0x69, 0x73, 0x74, 0x2e, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x00,
|
||||
0x2d, 0x31, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(self, (uint8_t*)bytes);
|
||||
return arg_copy(obj_getArg(self, "__res"));
|
||||
return arg_copy(obj_getArg(self, "@res_list"));
|
||||
}
|
||||
PikaObj* New_PikaStdData_List(Args * args);
|
||||
return arg_newDirectObj(New_PikaStdData_List);
|
||||
|
@ -29,11 +29,11 @@ int main(void) {
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
#if PIKA_ARG_CACHE_ENABLE
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
printf("[ Info]: alloc times: %d, cached times: %d (%0.2f%%)\r\n",
|
||||
g_pikaMemInfo.alloc_times, g_pikaMemInfo.alloc_times_cache,
|
||||
((float)g_pikaMemInfo.alloc_times_cache /
|
||||
(float)g_pikaMemInfo.alloc_times) *
|
||||
g_PikaMemInfo.alloc_times, g_PikaMemInfo.alloc_times_cache,
|
||||
((float)g_PikaMemInfo.alloc_times_cache /
|
||||
(float)g_PikaMemInfo.alloc_times) *
|
||||
100.0);
|
||||
#endif
|
||||
printf("[ Info]: time elapsed: %lfs\r\n",
|
||||
|
286
src/PikaObj.c
286
src/PikaObj.c
@ -39,14 +39,25 @@
|
||||
#include "dataStrs.h"
|
||||
|
||||
extern volatile VMSignal g_PikaVMSignal;
|
||||
static volatile PikaObjState g_PikaObjState = {
|
||||
volatile PikaObjState g_PikaObjState = {
|
||||
.helpModulesCmodule = NULL,
|
||||
.inRootObj = PIKA_FALSE,
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
.gcRoot = NULL,
|
||||
.objCnt = 0,
|
||||
.objCntMax = 0,
|
||||
.objCntLastGC = 0,
|
||||
.gcChain = NULL,
|
||||
.markSweepBusy = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
PikaObj* New_PikaStdData_Dict(Args* args);
|
||||
PikaObj* New_PikaStdData_dict_keys(Args* args);
|
||||
PikaObj* New_PikaStdData_List(Args* args);
|
||||
PikaObj* New_PikaStdData_Tuple(Args* args);
|
||||
void _mem_cache_deinit(void);
|
||||
void _VMEvent_deinit(void);
|
||||
|
||||
static enum shellCTRL __obj_shellLineHandler_REPL(PikaObj* self,
|
||||
char* input_line,
|
||||
ShellConfig* shell);
|
||||
@ -116,6 +127,11 @@ char* fast_itoa(char* buf, uint32_t val) {
|
||||
static int32_t obj_deinit_no_del(PikaObj* self) {
|
||||
/* free the list */
|
||||
args_deinit(self->list);
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
if (NULL != self->aName) {
|
||||
arg_deinit(self->aName);
|
||||
}
|
||||
#endif
|
||||
extern volatile PikaObj* __pikaMain;
|
||||
/* remove self from gc chain */
|
||||
pikaGC_remove(self);
|
||||
@ -123,7 +139,6 @@ static int32_t obj_deinit_no_del(PikaObj* self) {
|
||||
pikaFree(self, sizeof(PikaObj));
|
||||
if (self == (PikaObj*)__pikaMain) {
|
||||
__pikaMain = NULL;
|
||||
pikaGC_markSweep();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -141,6 +156,11 @@ int obj_GC(PikaObj* self) {
|
||||
}
|
||||
|
||||
int32_t obj_deinit(PikaObj* self) {
|
||||
pikaGC_lock();
|
||||
PIKA_BOOL bisRoot = PIKA_FALSE;
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
self->isAlive = PIKA_FALSE;
|
||||
#endif
|
||||
Arg* del = obj_getMethodArg(self, "__del__");
|
||||
if (NULL != del) {
|
||||
const uint8_t bytes[] = {
|
||||
@ -155,8 +175,7 @@ int32_t obj_deinit(PikaObj* self) {
|
||||
}
|
||||
extern volatile PikaObj* __pikaMain;
|
||||
if (self == (PikaObj*)__pikaMain) {
|
||||
void _mem_cache_deinit(void);
|
||||
void _VMEvent_deinit(void);
|
||||
bisRoot = PIKA_TRUE;
|
||||
_mem_cache_deinit();
|
||||
#if PIKA_EVENT_ENABLE
|
||||
_VMEvent_deinit();
|
||||
@ -166,7 +185,12 @@ int32_t obj_deinit(PikaObj* self) {
|
||||
g_PikaObjState.helpModulesCmodule = NULL;
|
||||
}
|
||||
}
|
||||
return obj_deinit_no_del(self);
|
||||
int32_t ret = obj_deinit_no_del(self);
|
||||
pikaGC_unlock();
|
||||
if (bisRoot) {
|
||||
pikaGC_markSweep();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
PIKA_RES obj_setInt(PikaObj* self, char* argPath, int64_t val) {
|
||||
@ -263,6 +287,7 @@ PIKA_BOOL obj_getBool(PikaObj* self, char* argPath) {
|
||||
}
|
||||
|
||||
Arg* obj_getArg(PikaObj* self, char* argPath) {
|
||||
pika_assert(pikaGC_checkAlive(self));
|
||||
PIKA_BOOL is_temp = PIKA_FALSE;
|
||||
PikaObj* obj = obj_getHostObjWithIsTemp(self, argPath, &is_temp);
|
||||
if (NULL == obj) {
|
||||
@ -314,27 +339,45 @@ static PIKA_RES _obj_setArg(PikaObj* self,
|
||||
char* argPath,
|
||||
Arg* arg,
|
||||
uint8_t is_copy) {
|
||||
pika_assert(pikaGC_checkAlive(self));
|
||||
/* setArg would copy arg */
|
||||
PikaObj* obj = obj_getHostObj(self, argPath);
|
||||
if (NULL == obj) {
|
||||
PikaObj* host = obj_getHostObj(self, argPath);
|
||||
PikaObj* oNew = NULL;
|
||||
PIKA_BOOL bNew = PIKA_FALSE;
|
||||
if (NULL == host) {
|
||||
/* object no found */
|
||||
return PIKA_RES_ERR_ARG_NO_FOUND;
|
||||
}
|
||||
char* argName = strPointToLastToken(argPath, '.');
|
||||
Arg* newArg;
|
||||
char* sArgName = strPointToLastToken(argPath, '.');
|
||||
Arg* aNew;
|
||||
if (is_copy) {
|
||||
newArg = arg_copy(arg);
|
||||
aNew = arg_copy(arg);
|
||||
} else {
|
||||
newArg = arg;
|
||||
}
|
||||
newArg = arg_setName(newArg, argName);
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
if (arg_isObject(newArg)) {
|
||||
/* enable mark sweep to collect this object */
|
||||
obj_clearFlag(arg_getPtr(newArg), OBJ_FLAG_GC_ROOT);
|
||||
aNew = arg;
|
||||
}
|
||||
aNew = arg_setName(aNew, sArgName);
|
||||
if (arg_isObject(aNew)) {
|
||||
oNew = arg_getPtr(aNew);
|
||||
bNew = PIKA_TRUE;
|
||||
pika_assert(pikaGC_checkAlive(oNew));
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
if (host != oNew) {
|
||||
/* skip self ref */
|
||||
oNew->parent = host;
|
||||
}
|
||||
if (NULL != oNew->aName) {
|
||||
arg_deinit(oNew->aName);
|
||||
}
|
||||
oNew->aName = arg_newStr(sArgName);
|
||||
oNew->name = arg_getStr(oNew->aName);
|
||||
#endif
|
||||
args_setArg(obj->list, newArg);
|
||||
}
|
||||
args_setArg(host->list, aNew);
|
||||
/* enable mark sweep to collect this object */
|
||||
if (bNew) {
|
||||
/* only enable mark sweep after setArg */
|
||||
pikaGC_enable(oNew);
|
||||
}
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
|
||||
@ -592,9 +635,7 @@ static PikaObj* _obj_initMetaObj(PikaObj* obj, char* name) {
|
||||
obj_runNativeMethod(new_obj, "__init__", NULL);
|
||||
args_setPtrWithType(obj->list, name, ARG_TYPE_OBJECT, new_obj);
|
||||
res = obj_getPtr(obj, name);
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
obj_clearFlag(res, OBJ_FLAG_GC_ROOT);
|
||||
#endif
|
||||
// pikaGC_enable(res);
|
||||
goto exit;
|
||||
exit:
|
||||
strsDeinit(&buffs);
|
||||
@ -675,10 +716,10 @@ static PikaObj* _obj_getObjDirect(PikaObj* self,
|
||||
return _arg_to_obj(arg_obj, pIsTemp);
|
||||
}
|
||||
|
||||
static PikaObj* __obj_getObjWithKeepDeepth(PikaObj* self,
|
||||
char* objPath,
|
||||
PIKA_BOOL* pIsTemp,
|
||||
int32_t keepDeepth) {
|
||||
static PikaObj* _obj_getObjWithKeepDeepth(PikaObj* self,
|
||||
char* objPath,
|
||||
PIKA_BOOL* pIsTemp,
|
||||
int32_t keepDeepth) {
|
||||
char objPath_buff[PIKA_PATH_BUFF_SIZE];
|
||||
char* objPath_ptr = objPath_buff;
|
||||
strcpy(objPath_buff, objPath);
|
||||
@ -693,23 +734,26 @@ static PikaObj* __obj_getObjWithKeepDeepth(PikaObj* self,
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (NULL != obj) {
|
||||
pika_assert(pikaGC_checkAlive(obj));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
PikaObj* obj_getObj(PikaObj* self, char* objPath) {
|
||||
PIKA_BOOL is_temp = PIKA_FALSE;
|
||||
return __obj_getObjWithKeepDeepth(self, objPath, &is_temp, 0);
|
||||
return _obj_getObjWithKeepDeepth(self, objPath, &is_temp, 0);
|
||||
}
|
||||
|
||||
PikaObj* obj_getHostObj(PikaObj* self, char* objPath) {
|
||||
PIKA_BOOL is_temp = PIKA_FALSE;
|
||||
return __obj_getObjWithKeepDeepth(self, objPath, &is_temp, 1);
|
||||
return _obj_getObjWithKeepDeepth(self, objPath, &is_temp, 1);
|
||||
}
|
||||
|
||||
PikaObj* obj_getHostObjWithIsTemp(PikaObj* self,
|
||||
char* objPath,
|
||||
PIKA_BOOL* pIsTemp) {
|
||||
return __obj_getObjWithKeepDeepth(self, objPath, pIsTemp, 1);
|
||||
return _obj_getObjWithKeepDeepth(self, objPath, pIsTemp, 1);
|
||||
}
|
||||
|
||||
Method methodArg_getPtr(Arg* method_arg) {
|
||||
@ -1680,7 +1724,7 @@ char* method_getStr(Args* args, char* argName) {
|
||||
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
PikaObj* pikaGC_getLast(PikaObj* self) {
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
PikaObj* last = NULL;
|
||||
while (NULL != obj) {
|
||||
if (obj == self) {
|
||||
@ -1693,16 +1737,17 @@ PikaObj* pikaGC_getLast(PikaObj* self) {
|
||||
}
|
||||
|
||||
void pikaGC_cleanMark(void) {
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
while (NULL != obj) {
|
||||
obj_clearFlag(obj, OBJ_FLAG_GC_MARKED);
|
||||
// obj->gcRoot = NULL;
|
||||
obj = obj->gcNext;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t pikaGC_count(void) {
|
||||
uint32_t count = 0;
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
while (NULL != obj) {
|
||||
count++;
|
||||
obj = obj->gcNext;
|
||||
@ -1712,7 +1757,7 @@ uint32_t pikaGC_count(void) {
|
||||
|
||||
uint32_t pikaGC_countMarked(void) {
|
||||
uint32_t count = 0;
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
while (NULL != obj) {
|
||||
if (obj_getFlag(obj, OBJ_FLAG_GC_MARKED)) {
|
||||
count++;
|
||||
@ -1722,9 +1767,10 @@ uint32_t pikaGC_countMarked(void) {
|
||||
return count;
|
||||
}
|
||||
|
||||
uint32_t pikaGC_printCanFree(void) {
|
||||
uint32_t pikaGC_printFreeList(void) {
|
||||
uint32_t count = 0;
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
pika_platform_printf("-----\r\n");
|
||||
while (NULL != obj) {
|
||||
if (!obj_getFlag(obj, OBJ_FLAG_GC_MARKED)) {
|
||||
count++;
|
||||
@ -1732,6 +1778,7 @@ uint32_t pikaGC_printCanFree(void) {
|
||||
}
|
||||
obj = obj->gcNext;
|
||||
}
|
||||
pika_platform_printf("-----\r\n");
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -1740,21 +1787,30 @@ uint32_t pikaGC_FreeOnce(void) {
|
||||
// pika_platform_printf("-----\r\n");
|
||||
// pikaGC_printCanFree();
|
||||
uint32_t count = 0;
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* freeList[16] = {0};
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
while (NULL != obj) {
|
||||
if (!obj_getFlag(obj, OBJ_FLAG_GC_MARKED)) {
|
||||
freeList[count] = obj;
|
||||
count++;
|
||||
obj_GC(obj);
|
||||
return count;
|
||||
}
|
||||
obj = obj->gcNext;
|
||||
}
|
||||
if (count > 0) {
|
||||
pikaGC_printFreeList();
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
obj_GC(freeList[i]);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
int32_t pikaGC_markHandler(Arg* argEach, Args* context) {
|
||||
if (arg_isObject(argEach)) {
|
||||
PikaObj* obj = (PikaObj*)arg_getPtr(argEach);
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
obj->gcRoot = (void*)context;
|
||||
#endif
|
||||
pikaGC_mark(obj);
|
||||
}
|
||||
return 0;
|
||||
@ -1768,12 +1824,29 @@ void pikaGC_mark(PikaObj* self) {
|
||||
return;
|
||||
}
|
||||
obj_setFlag(self, OBJ_FLAG_GC_MARKED);
|
||||
args_foreach(self->list, pikaGC_markHandler, NULL);
|
||||
args_foreach(self->list, pikaGC_markHandler, (void*)self);
|
||||
if (self->constructor == New_PikaStdData_Dict) {
|
||||
PikaDict* dict = obj_getPtr(self, "dict");
|
||||
if (NULL == dict) {
|
||||
return;
|
||||
}
|
||||
args_foreach(&dict->super, pikaGC_markHandler, (void*)self);
|
||||
return;
|
||||
}
|
||||
if (self->constructor == New_PikaStdData_List ||
|
||||
self->constructor == New_PikaStdData_Tuple) {
|
||||
PikaList* list = obj_getPtr(self, "list");
|
||||
if (NULL == list) {
|
||||
return;
|
||||
}
|
||||
args_foreach(&list->super, pikaGC_markHandler, (void*)self);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void pikaGC_markRoot() {
|
||||
pikaGC_cleanMark();
|
||||
PikaObj* root = g_PikaObjState.gcRoot;
|
||||
PikaObj* root = g_PikaObjState.gcChain;
|
||||
while (NULL != root) {
|
||||
if (obj_getFlag(root, OBJ_FLAG_GC_ROOT)) {
|
||||
pikaGC_mark(root);
|
||||
@ -1788,17 +1861,26 @@ PIKA_BOOL pikaGC_checkAlive(PikaObj* self) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return PIKA_TRUE;
|
||||
#else
|
||||
if (NULL == g_PikaObjState.gcRoot) {
|
||||
return PIKA_TRUE;
|
||||
PIKA_BOOL ret = PIKA_FALSE;
|
||||
if (NULL == g_PikaObjState.gcChain) {
|
||||
ret = PIKA_FALSE;
|
||||
goto __exit;
|
||||
}
|
||||
PikaObj* obj = g_PikaObjState.gcRoot;
|
||||
PikaObj* obj = g_PikaObjState.gcChain;
|
||||
while (NULL != obj) {
|
||||
if (obj == self) {
|
||||
return PIKA_TRUE;
|
||||
ret = PIKA_TRUE;
|
||||
goto __exit;
|
||||
}
|
||||
obj = obj->gcNext;
|
||||
}
|
||||
return PIKA_FALSE;
|
||||
__exit:
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
if (ret == PIKA_TRUE) {
|
||||
self->isAlive = ret;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1807,25 +1889,47 @@ uint32_t pikaGC_markSweep(void) {
|
||||
return 0;
|
||||
#else
|
||||
uint32_t count = 0;
|
||||
if (pikaGC_islock()) {
|
||||
return 0;
|
||||
}
|
||||
pikaGC_lock();
|
||||
while (pikaGC_FreeOnce() != 0) {
|
||||
count++;
|
||||
};
|
||||
/* update gc state */
|
||||
g_PikaObjState.objCntLastGC = g_PikaObjState.objCnt;
|
||||
pikaGC_unlock();
|
||||
return count;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pikaGC_checkThreshold(void) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return;
|
||||
#else
|
||||
if (g_PikaObjState.objCnt >
|
||||
g_PikaObjState.objCntLastGC + PIKA_GC_MARK_SWEEP_THRESHOLD) {
|
||||
pikaGC_markSweep();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void pikaGC_append(PikaObj* self) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return;
|
||||
#else
|
||||
g_PikaObjState.objCnt++;
|
||||
if (g_PikaObjState.objCntMax < g_PikaObjState.objCnt) {
|
||||
g_PikaObjState.objCntMax = g_PikaObjState.objCnt;
|
||||
}
|
||||
/* gc single chain */
|
||||
if (NULL == g_PikaObjState.gcRoot) {
|
||||
g_PikaObjState.gcRoot = self;
|
||||
if (NULL == g_PikaObjState.gcChain) {
|
||||
g_PikaObjState.gcChain = self;
|
||||
return;
|
||||
}
|
||||
/* append to head of gc chain */
|
||||
self->gcNext = g_PikaObjState.gcRoot;
|
||||
g_PikaObjState.gcRoot = self;
|
||||
self->gcNext = g_PikaObjState.gcChain;
|
||||
g_PikaObjState.gcChain = self;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1833,16 +1937,49 @@ void pikaGC_remove(PikaObj* self) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return;
|
||||
#else
|
||||
g_PikaObjState.objCnt--;
|
||||
PikaObj* last = pikaGC_getLast(self);
|
||||
if (NULL == last) {
|
||||
/* remove head */
|
||||
g_PikaObjState.gcRoot = self->gcNext;
|
||||
g_PikaObjState.gcChain = self->gcNext;
|
||||
return;
|
||||
}
|
||||
last->gcNext = self->gcNext;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pikaGC_enable(PikaObj* self) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return;
|
||||
#else
|
||||
obj_clearFlag(self, OBJ_FLAG_GC_ROOT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void pikaGC_lock(void) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return;
|
||||
#else
|
||||
g_PikaObjState.markSweepBusy++;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pikaGC_unlock(void) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return;
|
||||
#else
|
||||
g_PikaObjState.markSweepBusy--;
|
||||
#endif
|
||||
}
|
||||
|
||||
PIKA_BOOL pikaGC_islock(void) {
|
||||
#if !PIKA_GC_MARK_SWEEP_ENABLE
|
||||
return PIKA_FALSE;
|
||||
#else
|
||||
return g_PikaObjState.markSweepBusy > 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
PikaObj* New_PikaObj(Args* args) {
|
||||
PikaObj* self = pikaMalloc(sizeof(PikaObj));
|
||||
/* List */
|
||||
@ -1853,9 +1990,19 @@ PikaObj* New_PikaObj(Args* args) {
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
self->gcNext = NULL;
|
||||
obj_setFlag(self, OBJ_FLAG_GC_ROOT);
|
||||
#endif
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
self->aName = NULL;
|
||||
self->name = NULL;
|
||||
self->parent = NULL;
|
||||
self->isAlive = PIKA_TRUE;
|
||||
#endif
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE && PIKA_KERNAL_DEBUG_ENABLE
|
||||
self->gcRoot = NULL;
|
||||
#endif
|
||||
/* append to gc chain */
|
||||
pikaGC_append(self);
|
||||
pikaGC_checkThreshold();
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -1873,9 +2020,7 @@ int32_t obj_newDirectObj(PikaObj* self, char* objName, NewFun newFunPtr) {
|
||||
Arg* aNewObj = arg_newDirectObj(newFunPtr);
|
||||
aNewObj = arg_setName(aNewObj, objName);
|
||||
arg_setType(aNewObj, ARG_TYPE_OBJECT);
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
obj_clearFlag(arg_getPtr(aNewObj), OBJ_FLAG_GC_ROOT);
|
||||
#endif
|
||||
// pikaGC_enable(arg_getPtr(aNewObj));
|
||||
args_setArg(self->list, aNewObj);
|
||||
return 0;
|
||||
}
|
||||
@ -2002,26 +2147,25 @@ int obj_importModule(PikaObj* self, char* module_name) {
|
||||
}
|
||||
|
||||
char* obj_toStr(PikaObj* self) {
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __str__()
|
||||
)
|
||||
/* clang-format on */
|
||||
|
||||
/* check method arg */
|
||||
Arg* method_arg = obj_getMethodArg(self, "__str__");
|
||||
if (NULL != method_arg) {
|
||||
arg_deinit(method_arg);
|
||||
Arg* aMethod = obj_getMethodArg(self, "__str__");
|
||||
if (NULL != aMethod) {
|
||||
arg_deinit(aMethod);
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
@res_str = __str__()
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct
|
||||
array */
|
||||
0x0f, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x73, 0x74, 0x72, 0x5f, 0x5f, 0x00,
|
||||
0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, /* const pool */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x09, 0x00, /* instruct array */
|
||||
0x12, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x73, 0x74, 0x72, 0x5f, 0x5f, 0x00, 0x40,
|
||||
0x72, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x72, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(self, (uint8_t*)bytes);
|
||||
char* str_res = obj_getStr(self, "__res");
|
||||
char* str_res = obj_cacheStr(self, obj_getStr(self, "@res_str"));
|
||||
obj_removeArg(self, "@res_str");
|
||||
return str_res;
|
||||
}
|
||||
|
||||
@ -2029,9 +2173,9 @@ char* obj_toStr(PikaObj* self) {
|
||||
Args buffs = {0};
|
||||
char* str_res =
|
||||
strsFormat(&buffs, PIKA_SPRINTF_BUFF_SIZE, "<object at %p>", self);
|
||||
obj_setStr(self, "__res", str_res);
|
||||
obj_setStr(self, "@res_str", str_res);
|
||||
strsDeinit(&buffs);
|
||||
return obj_getStr(self, "__res");
|
||||
return obj_getStr(self, "@res_str");
|
||||
}
|
||||
|
||||
void pks_eventListener_registEvent(PikaEventListener* self,
|
||||
@ -2046,7 +2190,7 @@ void pks_eventListener_registEvent(PikaEventListener* self,
|
||||
strsDeinit(&buffs);
|
||||
}
|
||||
|
||||
Args buffs = {0};
|
||||
Args buffs = {0};
|
||||
void pks_eventListener_removeEvent(PikaEventListener* self, uint32_t eventId) {
|
||||
char* event_name =
|
||||
strsFormat(&buffs, PIKA_SPRINTF_BUFF_SIZE, "%ld", eventId);
|
||||
|
@ -75,17 +75,30 @@ struct NativeProperty {
|
||||
uint32_t methodGroupCount;
|
||||
};
|
||||
|
||||
/* clang-format off */
|
||||
typedef struct PikaObj PikaObj;
|
||||
struct PikaObj {
|
||||
Args* list;
|
||||
void* constructor;
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
PikaObj* gcNext;
|
||||
#endif
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
PikaObj* gcNext;
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
PikaObj* gcRoot;
|
||||
#endif
|
||||
#endif
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
char* name;
|
||||
Arg* aName;
|
||||
PikaObj* parent;
|
||||
PIKA_BOOL isAlive;
|
||||
PIKA_BOOL isGCRoot;
|
||||
#endif
|
||||
uint8_t refcnt;
|
||||
uint8_t flag;
|
||||
};
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
typedef struct RangeData RangeData;
|
||||
struct RangeData {
|
||||
int64_t start;
|
||||
@ -99,18 +112,22 @@ struct PikaObjState {
|
||||
Arg* helpModulesCmodule;
|
||||
PIKA_BOOL inRootObj;
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
PikaObj* gcRoot;
|
||||
PikaObj* gcChain;
|
||||
uint32_t objCnt;
|
||||
uint32_t objCntMax;
|
||||
uint32_t objCntLastGC;
|
||||
uint32_t markSweepBusy;
|
||||
#endif
|
||||
};
|
||||
|
||||
#define OBJ_FLAG_PROXY_GETATTRIBUTE 1
|
||||
#define OBJ_FLAG_PROXY_GETATTR 2
|
||||
#define OBJ_FLAG_PROXY_SETATTR 4
|
||||
#define OBJ_FLAG_ALREADY_INIT 8
|
||||
#define OBJ_FLAG_RUN_AS 16
|
||||
#define OBJ_FLAG_GLOBALS 32
|
||||
#define OBJ_FLAG_GC_MARKED 64
|
||||
#define OBJ_FLAG_GC_ROOT 128
|
||||
#define OBJ_FLAG_PROXY_GETATTRIBUTE 1 << 0
|
||||
#define OBJ_FLAG_PROXY_GETATTR 1 << 1
|
||||
#define OBJ_FLAG_PROXY_SETATTR 1 << 2
|
||||
#define OBJ_FLAG_ALREADY_INIT 1 << 3
|
||||
#define OBJ_FLAG_RUN_AS 1 << 4
|
||||
#define OBJ_FLAG_GLOBALS 1 << 5
|
||||
#define OBJ_FLAG_GC_MARKED 1 << 6
|
||||
#define OBJ_FLAG_GC_ROOT 1 << 7
|
||||
|
||||
#define KEY_UP 0x41
|
||||
#define KEY_DOWN 0x42
|
||||
@ -125,10 +142,20 @@ static inline uint8_t obj_getFlag(PikaObj* self, uint8_t flag) {
|
||||
static inline void obj_setFlag(PikaObj* self, uint8_t flag) {
|
||||
pika_assert(self);
|
||||
self->flag |= flag;
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
if (flag == OBJ_FLAG_GC_ROOT) {
|
||||
self->isGCRoot = PIKA_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void obj_clearFlag(PikaObj* self, uint8_t flag) {
|
||||
self->flag &= ~flag;
|
||||
#if PIKA_KERNAL_DEBUG_ENABLE
|
||||
if (flag == OBJ_FLAG_GC_ROOT) {
|
||||
self->isGCRoot = PIKA_FALSE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef PikaObj* (*NewFun)(Args* args);
|
||||
@ -584,15 +611,34 @@ void obj_printModules(PikaObj* self);
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define pika_assert_arg_alive(__arg) \
|
||||
do { \
|
||||
if (NULL != (__arg)) { \
|
||||
if (arg_isObject((__arg))) { \
|
||||
pika_assert(pikaGC_checkAlive(arg_getPtr((__arg)))); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define pika_assert_obj_alive(__obj) \
|
||||
do { \
|
||||
pika_assert(pikaGC_checkAlive((__obj))); \
|
||||
} while (0)
|
||||
|
||||
void pikaGC_append(PikaObj* self);
|
||||
uint32_t pikaGC_count(void);
|
||||
void pikaGC_remove(PikaObj* self);
|
||||
void pikaGC_mark(PikaObj* self);
|
||||
void pikaGC_markRoot(void);
|
||||
uint32_t pikaGC_countMarked(void);
|
||||
uint32_t pikaGC_printCanFree(void);
|
||||
uint32_t pikaGC_printFreeList(void);
|
||||
uint32_t pikaGC_markSweep(void);
|
||||
PIKA_BOOL pikaGC_checkAlive(PikaObj* self);
|
||||
void pikaGC_enable(PikaObj* self);
|
||||
void pikaGC_try(void);
|
||||
void pikaGC_lock(void);
|
||||
void pikaGC_unlock(void);
|
||||
PIKA_BOOL pikaGC_islock(void);
|
||||
|
||||
int pika_GIL_EXIT(void);
|
||||
int pika_GIL_ENTER(void);
|
||||
|
76
src/PikaVM.c
76
src/PikaVM.c
@ -53,6 +53,7 @@ volatile VMSignal g_PikaVMSignal = {.signal_ctrl = VM_SIGNAL_CTRL_NONE,
|
||||
|
||||
#endif
|
||||
};
|
||||
extern volatile PikaObjState g_PikaObjState;
|
||||
|
||||
int pika_GIL_ENTER(void) {
|
||||
if (!g_pikaGIL.is_init) {
|
||||
@ -561,10 +562,10 @@ Arg* __vm_get(VMState* vm, PikaObj* self, Arg* key, Arg* obj) {
|
||||
arg_obj = arg_getPtr(obj);
|
||||
}
|
||||
obj_setArg(arg_obj, "__key", key);
|
||||
obj_removeArg(arg_obj, "__res");
|
||||
obj_removeArg(arg_obj, "@res_item");
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __getitem__(__key)
|
||||
@res_item = __getitem__(__key)
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
@ -572,11 +573,10 @@ Arg* __vm_get(VMState* vm, PikaObj* self, Arg* key, Arg* obj) {
|
||||
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x04, 0x13,
|
||||
0x00,
|
||||
/* instruct array */
|
||||
0x19, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x1d, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6b, 0x65, 0x79, 0x00, 0x5f, 0x5f, 0x67, 0x65,
|
||||
0x74, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72,
|
||||
0x65, 0x73, 0x00,
|
||||
/* const pool */
|
||||
0x74, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x5f, 0x00, 0x40, 0x72, 0x65,
|
||||
0x73, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x00, /* const pool */
|
||||
};
|
||||
if (NULL != vm) {
|
||||
_do_pikaVM_runByteCode(arg_obj, arg_obj, arg_obj, (uint8_t*)bytes,
|
||||
@ -584,7 +584,7 @@ Arg* __vm_get(VMState* vm, PikaObj* self, Arg* key, Arg* obj) {
|
||||
} else {
|
||||
pikaVM_runByteCode(arg_obj, (uint8_t*)bytes);
|
||||
}
|
||||
Arg* __res = args_getArg(arg_obj->list, "__res");
|
||||
Arg* __res = args_getArg(arg_obj->list, "@res_item");
|
||||
Arg* res = NULL;
|
||||
if (NULL != __res) {
|
||||
res = arg_copy(__res);
|
||||
@ -929,6 +929,7 @@ exit:
|
||||
} else {
|
||||
methodArg_setHostObj(aRes, oHost);
|
||||
aRes = arg_copy_noalloc(aRes, aRetReg);
|
||||
pika_assert_arg_alive(aRes);
|
||||
}
|
||||
if (is_temp) {
|
||||
obj_GC(oHost);
|
||||
@ -1008,6 +1009,7 @@ Arg* _obj_runMethodArgWithState(PikaObj* self,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
pika_assert_arg_alive(aReturn);
|
||||
return aReturn;
|
||||
}
|
||||
|
||||
@ -1781,6 +1783,8 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
pika_assert(pikaGC_checkAlive(oMethodHost));
|
||||
|
||||
#if !PIKA_NANO_ENABLE
|
||||
if (!bSkipInit && vm->in_super &&
|
||||
VMState_getInvokeDeepthNow(vm) == vm->super_invoke_deepth - 1) {
|
||||
@ -1831,7 +1835,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
||||
}
|
||||
|
||||
/* create sub local scope */
|
||||
oSublocals = New_TinyObj(NULL);
|
||||
oSublocals = New_Locals(NULL);
|
||||
|
||||
/* load args from vmState to sub_local->list */
|
||||
iNumUsed += VMState_loadArgsFromMethodArg(vm, oThis, oSublocals->list,
|
||||
@ -1864,7 +1868,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
||||
/* init object */
|
||||
PikaObj* oNew = arg_getPtr(aReturn);
|
||||
Arg* aMethod = obj_getMethodArg_noalloc(oNew, "__init__", &arg_reg1);
|
||||
oSublocalsInit = New_TinyObj(NULL);
|
||||
oSublocalsInit = New_Locals(NULL);
|
||||
Arg* aReturnInit = NULL;
|
||||
if (NULL == aMethod) {
|
||||
goto init_exit;
|
||||
@ -1881,6 +1885,9 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
||||
if (NULL != aReturnInit) {
|
||||
arg_deinit(aReturnInit);
|
||||
}
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
pika_assert(obj_getFlag(oSublocals, OBJ_FLAG_GC_ROOT));
|
||||
#endif
|
||||
obj_deinit(oSublocalsInit);
|
||||
if (NULL != aMethod) {
|
||||
arg_deinit(aMethod);
|
||||
@ -1905,6 +1912,9 @@ exit:
|
||||
arg_deinit(aMethod);
|
||||
}
|
||||
if (NULL != oSublocals) {
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
pika_assert(obj_getFlag(oSublocals, OBJ_FLAG_GC_ROOT));
|
||||
#endif
|
||||
obj_deinit(oSublocals);
|
||||
}
|
||||
if (NULL != aHost) {
|
||||
@ -1914,7 +1924,7 @@ exit:
|
||||
/* class method */
|
||||
obj_GC(oMethodHost);
|
||||
}
|
||||
|
||||
pika_assert_arg_alive(aReturn);
|
||||
return aReturn;
|
||||
}
|
||||
|
||||
@ -2317,7 +2327,7 @@ static void _OPT_ADD(OperatorInfo* op) {
|
||||
obj_setPtr(obj1, "__others", obj2);
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __add__(__others)
|
||||
@res_add = __add__(__others)
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
@ -2325,16 +2335,16 @@ static void _OPT_ADD(OperatorInfo* op) {
|
||||
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x04, 0x12,
|
||||
0x00,
|
||||
/* instruct array */
|
||||
0x18, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x1b, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x00, 0x5f,
|
||||
0x5f, 0x61, 0x64, 0x64, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x00, /* const pool */
|
||||
0x5f, 0x61, 0x64, 0x64, 0x5f, 0x5f, 0x00, 0x40, 0x72, 0x65, 0x73,
|
||||
0x5f, 0x61, 0x64, 0x64, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(obj1, (uint8_t*)bytes);
|
||||
Arg* __res = arg_copy(obj_getArg(obj1, "__res"));
|
||||
op->res = __res;
|
||||
Arg* __res = arg_copy(obj_getArg(obj1, "@res_add"));
|
||||
obj_removeArg(obj1, "__others");
|
||||
obj_removeArg(obj1, "__res");
|
||||
obj_removeArg(obj1, "@res_add");
|
||||
op->res = __res;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -2395,7 +2405,7 @@ static void _OPT_SUB(OperatorInfo* op) {
|
||||
obj_setPtr(obj1, "__others", obj2);
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __sub__(__others)
|
||||
@res_sub = __sub__(__others)
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
@ -2403,16 +2413,16 @@ static void _OPT_SUB(OperatorInfo* op) {
|
||||
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x04, 0x12,
|
||||
0x00,
|
||||
/* instruct array */
|
||||
0x18, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x1b, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x00, 0x5f,
|
||||
0x5f, 0x73, 0x75, 0x62, 0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x00, /* const pool */
|
||||
0x5f, 0x73, 0x75, 0x62, 0x5f, 0x5f, 0x00, 0x40, 0x72, 0x65, 0x73,
|
||||
0x5f, 0x73, 0x75, 0x62, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(obj1, (uint8_t*)bytes);
|
||||
Arg* __res = arg_copy(obj_getArg(obj1, "__res"));
|
||||
op->res = __res;
|
||||
Arg* __res = arg_copy(obj_getArg(obj1, "@res_sub"));
|
||||
obj_removeArg(obj1, "@res_sub");
|
||||
obj_removeArg(obj1, "__others");
|
||||
obj_removeArg(obj1, "__res");
|
||||
op->res = __res;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -2640,25 +2650,27 @@ static Arg* VM_instruction_handler_OPT(PikaObj* self,
|
||||
Arg* __contains__ = obj_getMethodArg(obj2, "__contains__");
|
||||
if (NULL != __contains__) {
|
||||
arg_deinit(__contains__);
|
||||
obj_setArg(obj2, "__others", op.a1);
|
||||
/* clang-format off */
|
||||
PIKA_PYTHON(
|
||||
__res = __contains__(__others)
|
||||
@res_contains = __contains__(__others)
|
||||
)
|
||||
obj_setArg(obj2, "__others", op.a1);
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x0c, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x04,
|
||||
0x17, 0x00,
|
||||
/* instruct array */
|
||||
0x1d, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x25, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x73, 0x00,
|
||||
0x5f, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73,
|
||||
0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73,
|
||||
0x00, /* const pool */
|
||||
0x5f, 0x5f, 0x00, 0x40, 0x72, 0x65, 0x73, 0x5f, 0x63, 0x6f,
|
||||
0x6e, 0x74, 0x61, 0x69, 0x6e, 0x73, 0x00,
|
||||
/* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(obj2, (uint8_t*)bytes);
|
||||
op.res = arg_setBool(op.res, "", obj_getInt(obj2, "__res"));
|
||||
op.res =
|
||||
arg_setBool(op.res, "", obj_getInt(obj2, "@res_contains"));
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
@ -3342,7 +3354,7 @@ static ByteCodeFrame* _cache_bcf_fn_bc(PikaObj* self, uint8_t* bytecode) {
|
||||
return _cache_bytecodeframe(self);
|
||||
}
|
||||
|
||||
static VMParameters* __pikaVM_runPyLines(PikaObj* self, char* py_lines) {
|
||||
static VMParameters* _pikaVM_runPyLines(PikaObj* self, char* py_lines) {
|
||||
VMParameters* globals = NULL;
|
||||
ByteCodeFrame bytecode_frame_stack = {0};
|
||||
ByteCodeFrame* bytecode_frame_p = NULL;
|
||||
@ -3447,7 +3459,7 @@ VMParameters* pikaVM_runSingleFile(PikaObj* self, char* filename) {
|
||||
}
|
||||
|
||||
VMParameters* pikaVM_run(PikaObj* self, char* py_lines) {
|
||||
return __pikaVM_runPyLines(self, py_lines);
|
||||
return _pikaVM_runPyLines(self, py_lines);
|
||||
}
|
||||
|
||||
VMParameters* pikaVM_runByteCode(PikaObj* self, const uint8_t* bytecode) {
|
||||
|
@ -36,3 +36,9 @@ PikaObj* New_TinyObj(Args* args) {
|
||||
self->constructor = New_TinyObj;
|
||||
return self;
|
||||
}
|
||||
|
||||
PikaObj* New_Locals(Args* args) {
|
||||
PikaObj* self = New_PikaObj(NULL);
|
||||
self->constructor = New_Locals;
|
||||
return self;
|
||||
}
|
||||
|
@ -29,4 +29,5 @@
|
||||
#define __TYNYOBJ__H
|
||||
#include "PikaObj.h"
|
||||
PikaObj* New_TinyObj(Args* args);
|
||||
PikaObj* New_Locals(Args* args);
|
||||
#endif
|
||||
|
@ -39,16 +39,16 @@ static PIKA_BOOL _arg_cache_push(Arg* self, uint32_t size) {
|
||||
if (PIKA_FALSE == pika_hook_arg_cache_filter(self)) {
|
||||
return PIKA_FALSE;
|
||||
}
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
if (self->heap_size < PIKA_ARG_CACHE_SIZE ||
|
||||
self->heap_size > 2 * PIKA_ARG_CACHE_SIZE) {
|
||||
return PIKA_FALSE;
|
||||
}
|
||||
if (PIKA_ARG_CACHE_POOL_SIZE <= g_pikaMemInfo.cache_pool_top) {
|
||||
if (PIKA_ARG_CACHE_POOL_SIZE <= g_PikaMemInfo.cache_pool_top) {
|
||||
return PIKA_FALSE;
|
||||
}
|
||||
g_pikaMemInfo.cache_pool[g_pikaMemInfo.cache_pool_top++] = (uint8_t*)self;
|
||||
g_pikaMemInfo.heapUsed -= mem_align(sizeof(Arg) + size);
|
||||
g_PikaMemInfo.cache_pool[g_PikaMemInfo.cache_pool_top++] = (uint8_t*)self;
|
||||
g_PikaMemInfo.heapUsed -= mem_align(sizeof(Arg) + size);
|
||||
return PIKA_TRUE;
|
||||
#endif
|
||||
}
|
||||
@ -58,16 +58,16 @@ static Arg* _arg_cache_pop(uint32_t size) {
|
||||
return NULL;
|
||||
#else
|
||||
uint32_t req_heap_size = mem_align(sizeof(Arg) + size);
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
if (req_heap_size > PIKA_ARG_CACHE_SIZE) {
|
||||
return NULL;
|
||||
}
|
||||
if (!(g_pikaMemInfo.cache_pool_top > 0)) {
|
||||
if (!(g_PikaMemInfo.cache_pool_top > 0)) {
|
||||
return NULL;
|
||||
}
|
||||
--g_pikaMemInfo.cache_pool_top;
|
||||
Arg* self = (Arg*)g_pikaMemInfo.cache_pool[g_pikaMemInfo.cache_pool_top];
|
||||
g_pikaMemInfo.heapUsed += mem_align(sizeof(Arg) + size);
|
||||
--g_PikaMemInfo.cache_pool_top;
|
||||
Arg* self = (Arg*)g_PikaMemInfo.cache_pool[g_PikaMemInfo.cache_pool_top];
|
||||
g_PikaMemInfo.heapUsed += mem_align(sizeof(Arg) + size);
|
||||
return self;
|
||||
#endif
|
||||
}
|
||||
@ -118,15 +118,15 @@ static Arg* _arg_set_hash(Arg* self,
|
||||
// if (heap_size < PIKA_ARG_CACHE_SIZE) {
|
||||
// heap_size = PIKA_ARG_CACHE_SIZE;
|
||||
// }
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
g_pikaMemInfo.alloc_times++;
|
||||
g_pikaMemInfo.alloc_times_cache++;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
g_PikaMemInfo.alloc_times++;
|
||||
g_PikaMemInfo.alloc_times_cache++;
|
||||
#endif
|
||||
if (NULL == self) {
|
||||
self = (Arg*)pikaMalloc(heap_size);
|
||||
#if PIKA_ARG_CACHE_ENABLE
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
g_pikaMemInfo.alloc_times_cache--;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
g_PikaMemInfo.alloc_times_cache--;
|
||||
self->heap_size = mem_align(heap_size);
|
||||
#endif
|
||||
}
|
||||
@ -550,8 +550,8 @@ Arg* arg_append(Arg* self, void* new_content, size_t new_size) {
|
||||
if (self->heap_size > mem_align(sizeof(Arg) + old_size + new_size)) {
|
||||
new_arg = self;
|
||||
new_arg->size = old_size + new_size;
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
g_pikaMemInfo.heapUsed += mem_align(sizeof(Arg) + old_size + new_size) -
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
g_PikaMemInfo.heapUsed += mem_align(sizeof(Arg) + old_size + new_size) -
|
||||
mem_align(sizeof(Arg) + old_size);
|
||||
}
|
||||
#endif
|
||||
|
@ -103,7 +103,7 @@ static inline void arg_setType(Arg* self, ArgType type) {
|
||||
}
|
||||
|
||||
static inline Hash arg_getNameHash(Arg* self) {
|
||||
pika_assert(self != 0);
|
||||
pika_assert(self != NULL);
|
||||
return self->name_hash;
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,7 @@ PIKA_RES args_setRef(Args* self, char* name, void* argPointer) {
|
||||
PIKA_RES errCode = PIKA_RES_OK;
|
||||
Arg* aNewRef = New_arg(NULL);
|
||||
aNewRef = arg_setRef(aNewRef, name, argPointer);
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
obj_clearFlag(arg_getPtr(aNewRef), OBJ_FLAG_GC_ROOT);
|
||||
#endif
|
||||
// pikaGC_enable(arg_getPtr(aNewRef));
|
||||
args_setArg(self, aNewRef);
|
||||
return errCode;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "dataLinkNode.h"
|
||||
#include "dataMemory.h"
|
||||
|
||||
void __link_deinit_pyload(Link* self) {
|
||||
void _link_deinit_pyload(Link* self) {
|
||||
LinkNode* nowNode = self->firstNode;
|
||||
while (NULL != nowNode) {
|
||||
LinkNode* nodeNext = (LinkNode*)arg_getNext((Arg*)nowNode);
|
||||
@ -42,12 +42,12 @@ void __link_deinit_pyload(Link* self) {
|
||||
|
||||
void link_deinit(Link* self) {
|
||||
pika_assert(self != NULL);
|
||||
__link_deinit_pyload(self);
|
||||
_link_deinit_pyload(self);
|
||||
pikaFree(self, sizeof(Link));
|
||||
}
|
||||
|
||||
void link_deinit_stack(Link* self) {
|
||||
__link_deinit_pyload(self);
|
||||
_link_deinit_pyload(self);
|
||||
}
|
||||
|
||||
void link_addNode(Link* self, void* content) {
|
||||
@ -59,7 +59,7 @@ void link_addNode(Link* self, void* content) {
|
||||
arg_setNext((Arg*)content, (Arg*)secondNode);
|
||||
}
|
||||
|
||||
static void __link_removeNode(Link* self,
|
||||
static void _link_removeNode(Link* self,
|
||||
void* content,
|
||||
uint8_t is_deinit_node) {
|
||||
LinkNode* nodeToDelete = NULL;
|
||||
@ -99,11 +99,11 @@ exit:
|
||||
}
|
||||
|
||||
void link_removeNode(Link* self, void* content) {
|
||||
__link_removeNode(self, content, 1);
|
||||
_link_removeNode(self, content, 1);
|
||||
}
|
||||
|
||||
void link_removeNode_notDeinitNode(Link* self, void* content) {
|
||||
__link_removeNode(self, content, 0);
|
||||
_link_removeNode(self, content, 0);
|
||||
}
|
||||
|
||||
int32_t link_getSize(Link* self) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "dataMemory.h"
|
||||
#include "PikaPlatform.h"
|
||||
|
||||
volatile pikaMemInfo g_pikaMemInfo = {0};
|
||||
volatile PikaMemInfo g_PikaMemInfo = {0};
|
||||
|
||||
void* pikaMalloc(uint32_t size) {
|
||||
/* pika memory lock */
|
||||
@ -43,9 +43,9 @@ void* pikaMalloc(uint32_t size) {
|
||||
size = mem_align(size);
|
||||
#endif
|
||||
|
||||
g_pikaMemInfo.heapUsed += size;
|
||||
if (g_pikaMemInfo.heapUsedMax < g_pikaMemInfo.heapUsed) {
|
||||
g_pikaMemInfo.heapUsedMax = g_pikaMemInfo.heapUsed;
|
||||
g_PikaMemInfo.heapUsed += size;
|
||||
if (g_PikaMemInfo.heapUsedMax < g_PikaMemInfo.heapUsed) {
|
||||
g_PikaMemInfo.heapUsedMax = g_PikaMemInfo.heapUsed;
|
||||
}
|
||||
pika_platform_disable_irq_handle();
|
||||
void* mem = pika_user_malloc(size);
|
||||
@ -73,20 +73,20 @@ void pikaFree(void* mem, uint32_t size) {
|
||||
pika_platform_disable_irq_handle();
|
||||
pika_user_free(mem, size);
|
||||
pika_platform_enable_irq_handle();
|
||||
g_pikaMemInfo.heapUsed -= size;
|
||||
g_PikaMemInfo.heapUsed -= size;
|
||||
}
|
||||
|
||||
uint32_t pikaMemNow(void) {
|
||||
return g_pikaMemInfo.heapUsed;
|
||||
return g_PikaMemInfo.heapUsed;
|
||||
// return 0;
|
||||
}
|
||||
|
||||
uint32_t pikaMemMax(void) {
|
||||
return g_pikaMemInfo.heapUsedMax;
|
||||
return g_PikaMemInfo.heapUsedMax;
|
||||
}
|
||||
|
||||
void pikaMemMaxReset(void) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
}
|
||||
|
||||
uint32_t pool_getBlockIndex_byMemSize(Pool* pool, uint32_t size) {
|
||||
@ -308,10 +308,10 @@ void mem_pool_init(void) {
|
||||
|
||||
void _mem_cache_deinit(void) {
|
||||
#if PIKA_ARG_CACHE_ENABLE
|
||||
while (g_pikaMemInfo.cache_pool_top) {
|
||||
while (g_PikaMemInfo.cache_pool_top) {
|
||||
pika_user_free(
|
||||
g_pikaMemInfo.cache_pool[g_pikaMemInfo.cache_pool_top - 1], 0);
|
||||
g_pikaMemInfo.cache_pool_top--;
|
||||
g_PikaMemInfo.cache_pool[g_PikaMemInfo.cache_pool_top - 1], 0);
|
||||
g_PikaMemInfo.cache_pool_top--;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ typedef struct {
|
||||
#endif
|
||||
uint32_t alloc_times;
|
||||
uint32_t alloc_times_cache;
|
||||
} pikaMemInfo;
|
||||
} PikaMemInfo;
|
||||
|
||||
typedef uint8_t* BitMap;
|
||||
|
||||
|
@ -167,6 +167,9 @@ static int32_t _stack_pushArg(Stack* stack, Arg* arg, PIKA_BOOL is_alloc) {
|
||||
|
||||
int32_t stack_pushArg(Stack* stack, Arg* arg) {
|
||||
pika_assert(arg != NULL);
|
||||
if (arg_isObject(arg)) {
|
||||
pika_assert(pikaGC_checkAlive(arg_getPtr(arg)));
|
||||
}
|
||||
if (arg_isSerialized(arg)) {
|
||||
return _stack_pushArg(stack, arg, PIKA_TRUE);
|
||||
}
|
||||
|
@ -443,6 +443,14 @@
|
||||
#define PIKA_GC_MARK_SWEEP_ENABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef PIKA_GC_MARK_SWEEP_THRESHOLD
|
||||
#define PIKA_GC_MARK_SWEEP_THRESHOLD 20
|
||||
#endif
|
||||
|
||||
#ifndef PIKA_KERNAL_DEBUG_ENABLE
|
||||
#define PIKA_KERNAL_DEBUG_ENABLE 0
|
||||
#endif
|
||||
|
||||
/* configuration validation */
|
||||
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && (!PIKA_POOL_ENABLE)
|
||||
TEST(PikaCV, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -19,7 +19,7 @@ TEST(PikaCV, test1) {
|
||||
|
||||
TEST(PikaCV, test2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -34,7 +34,7 @@ TEST(PikaCV, test2) {
|
||||
|
||||
TEST(PikaCV, test3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -49,7 +49,7 @@ TEST(PikaCV, test3) {
|
||||
|
||||
TEST(PikaCV, test4) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -64,7 +64,7 @@ TEST(PikaCV, test4) {
|
||||
|
||||
TEST(PikaCV, test5) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -79,7 +79,7 @@ TEST(PikaCV, test5) {
|
||||
|
||||
TEST(PikaCV, test6) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -94,7 +94,7 @@ TEST(PikaCV, test6) {
|
||||
|
||||
TEST(PikaCV, test7) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -109,7 +109,7 @@ TEST(PikaCV, test7) {
|
||||
|
||||
TEST(PikaCV, test8) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -124,7 +124,7 @@ TEST(PikaCV, test8) {
|
||||
|
||||
TEST(PikaCV, test9) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -139,7 +139,7 @@ TEST(PikaCV, test9) {
|
||||
|
||||
TEST(PikaCV, test10) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -154,7 +154,7 @@ TEST(PikaCV, test10) {
|
||||
|
||||
TEST(PikaCV, test11) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -3,7 +3,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(PikaMath, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -18,7 +18,7 @@ TEST(PikaMath, test1) {
|
||||
|
||||
TEST(PikaMath, quat_add) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -49,7 +49,7 @@ TEST(PikaMath, quat_add) {
|
||||
|
||||
TEST(PikaMath, quat_sub) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -80,7 +80,7 @@ TEST(PikaMath, quat_sub) {
|
||||
|
||||
TEST(PikaMath, quat_mul) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -111,7 +111,7 @@ TEST(PikaMath, quat_mul) {
|
||||
|
||||
TEST(PikaMath, quat_set) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -141,7 +141,7 @@ TEST(PikaMath, quat_set) {
|
||||
|
||||
TEST(PikaMath, quat_dot) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -166,7 +166,7 @@ TEST(PikaMath, quat_dot) {
|
||||
|
||||
TEST(PikaMath, quat_inv) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -196,7 +196,7 @@ TEST(PikaMath, quat_inv) {
|
||||
|
||||
TEST(PikaMath, quat_cross) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -230,7 +230,7 @@ TEST(PikaMath, quat_cross) {
|
||||
|
||||
TEST(PikaMath, quat_toEuler) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -259,7 +259,7 @@ TEST(PikaMath, quat_toEuler) {
|
||||
|
||||
TEST(PikaMath, quat_fromEuler) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
|
@ -5,7 +5,7 @@ TEST_START
|
||||
|
||||
TEST(PikaNN, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
132
test/VM-test.cpp
132
test/VM-test.cpp
@ -149,9 +149,9 @@ TEST(VM, Run_add_1_2_3) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
TEST(VM, WHILE) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines =(char *)
|
||||
"a = 1\n"
|
||||
@ -163,7 +163,7 @@ TEST(VM, WHILE) {
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
printf("%s", pikaAsm);
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* self = newRootObj("root", New_TinyObj);
|
||||
VMParameters* globals = pikaVM_runAsm(self, pikaAsm);
|
||||
EXPECT_EQ(args_getInt(globals->list, "a"), 0);
|
||||
@ -753,7 +753,7 @@ TEST(VM, bytecode_jjcc) {
|
||||
}
|
||||
|
||||
TEST(VM, WHILE_byte) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines =(char *)
|
||||
"a = 1\n"
|
||||
@ -765,7 +765,7 @@ TEST(VM, WHILE_byte) {
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
printf("%s", pikaAsm);
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* self = newRootObj("root", New_TinyObj);
|
||||
pikaVM_run(self, lines);
|
||||
EXPECT_EQ(obj_getInt(self, "a"), 0);
|
||||
@ -776,7 +776,7 @@ TEST(VM, WHILE_byte) {
|
||||
}
|
||||
|
||||
TEST(VM, for_break_byte) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines =(char *)
|
||||
"a = 0\n"
|
||||
@ -788,7 +788,7 @@ TEST(VM, for_break_byte) {
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
printf("%s", pikaAsm);
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
pikaVM_run(self, lines);
|
||||
/* assert */
|
||||
@ -891,13 +891,13 @@ TEST(VM, load_static_bytes) {
|
||||
}
|
||||
|
||||
TEST(VM, multi_jian) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "a = (3-4) - 4\n";
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
printf("%s", pikaAsm);
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
pikaVM_run(self, lines);
|
||||
/* assert */
|
||||
@ -1309,7 +1309,7 @@ TEST(vm, class_keyword_mqtt) {
|
||||
|
||||
TEST(vm, vars_keyward) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1327,7 +1327,7 @@ TEST(vm, vars_keyward) {
|
||||
|
||||
TEST(vm, cb_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1346,7 +1346,7 @@ TEST(vm, cb_1) {
|
||||
|
||||
TEST(vm, cb_2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1369,7 +1369,7 @@ TEST(vm, cb_2) {
|
||||
|
||||
TEST(vm, cb_3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1387,7 +1387,7 @@ TEST(vm, cb_3) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, default_no_input) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1407,7 +1407,7 @@ TEST(vm, default_no_input) {
|
||||
|
||||
TEST(vm, default_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1427,7 +1427,7 @@ TEST(vm, default_1) {
|
||||
|
||||
TEST(vm, default_2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1447,7 +1447,7 @@ TEST(vm, default_2) {
|
||||
|
||||
TEST(vm, default_3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1472,7 +1472,7 @@ TEST(vm, default_3) {
|
||||
|
||||
TEST(vm, default_4) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1500,7 +1500,7 @@ TEST(vm, default_4) {
|
||||
|
||||
TEST(vm, default_no_kw) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1526,7 +1526,7 @@ TEST(vm, default_no_kw) {
|
||||
|
||||
TEST(vm, none) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1544,7 +1544,7 @@ TEST(vm, none) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, super_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1571,7 +1571,7 @@ TEST(vm, super_) {
|
||||
|
||||
TEST(vm, super_val) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1600,7 +1600,7 @@ TEST(vm, super_val) {
|
||||
|
||||
TEST(vm, super_val_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1633,7 +1633,7 @@ TEST(vm, super_val_) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, multi_return) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1655,7 +1655,7 @@ TEST(vm, multi_return) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, multi_return_fn) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1679,7 +1679,7 @@ TEST(vm, multi_return_fn) {
|
||||
|
||||
TEST(vm, range_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1700,7 +1700,7 @@ TEST(vm, range_1) {
|
||||
|
||||
TEST(vm, rang_3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1721,7 +1721,7 @@ TEST(vm, rang_3) {
|
||||
|
||||
TEST(vm, test64) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1742,7 +1742,7 @@ TEST(vm, test64) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, exit) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1766,7 +1766,7 @@ TEST(vm, exit) {
|
||||
|
||||
TEST(vm, exit_fn) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1814,7 +1814,7 @@ void __gtest_hook_default_(void) {
|
||||
void _vm_exit_fn_issue_1_item(int hook_cnt) {
|
||||
g_hook_cnt_triggle = hook_cnt;
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1857,7 +1857,7 @@ TEST(vm, exit_fn_issue_1) {
|
||||
|
||||
TEST(vm, pass_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1881,7 +1881,7 @@ TEST(vm, pass_) {
|
||||
|
||||
TEST(vm, test64_hex) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1901,7 +1901,7 @@ TEST(vm, test64_hex) {
|
||||
|
||||
TEST(vm, test64_hex_print) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1922,7 +1922,7 @@ TEST(vm, test64_hex_print) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, call_dict_err) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1941,7 +1941,7 @@ TEST(vm, call_dict_err) {
|
||||
|
||||
TEST(vm, getattribute) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1963,7 +1963,7 @@ TEST(vm, getattribute) {
|
||||
|
||||
TEST(vm, getattr) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -1989,7 +1989,7 @@ TEST(vm, getattr) {
|
||||
|
||||
TEST(vm, setattr) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2015,7 +2015,7 @@ TEST(vm, setattr) {
|
||||
|
||||
TEST(vm, c_module_get_set_attr) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2040,7 +2040,7 @@ TEST(vm, c_module_get_set_attr) {
|
||||
|
||||
TEST(vm, class_attr_ref) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2060,7 +2060,7 @@ TEST(vm, class_attr_ref) {
|
||||
|
||||
TEST(vm, getattr_native) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2080,7 +2080,7 @@ TEST(vm, getattr_native) {
|
||||
|
||||
TEST(vm, issue_dict_update) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2097,7 +2097,7 @@ TEST(vm, issue_dict_update) {
|
||||
|
||||
TEST(vm, issue_big_dict_update) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2116,7 +2116,7 @@ TEST(vm, issue_big_dict_update) {
|
||||
|
||||
TEST(vm, i_pp) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2150,7 +2150,7 @@ TEST(vm, i_pp) {
|
||||
|
||||
TEST(vm, benchmark) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2288,7 +2288,7 @@ TEST(VM, bc_fn_file_cb2) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, slice_str_end) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2305,7 +2305,7 @@ TEST(vm, slice_str_end) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(vm, fn_pos_kw) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2323,7 +2323,7 @@ TEST(vm, fn_pos_kw) {
|
||||
|
||||
TEST(vm, fn_pos_kw2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2343,7 +2343,7 @@ TEST(vm, fn_pos_kw2) {
|
||||
|
||||
TEST(vm, fn_star) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2360,7 +2360,7 @@ TEST(vm, fn_star) {
|
||||
|
||||
TEST(vm, fn_star_pos) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2377,7 +2377,7 @@ TEST(vm, fn_star_pos) {
|
||||
|
||||
TEST(vm, fn_star_pos_2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2394,7 +2394,7 @@ TEST(vm, fn_star_pos_2) {
|
||||
|
||||
TEST(vm, fn_star_star) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2460,7 +2460,7 @@ TEST(vm, def_not_in) {
|
||||
|
||||
TEST(vm, fn_pos_kw_issue1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2478,7 +2478,7 @@ TEST(vm, fn_pos_kw_issue1) {
|
||||
|
||||
TEST(vm, fn_pos_kw_issue2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2496,7 +2496,7 @@ TEST(vm, fn_pos_kw_issue2) {
|
||||
|
||||
TEST(vm, num_issue_lakj) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2511,7 +2511,7 @@ TEST(vm, num_issue_lakj) {
|
||||
|
||||
TEST(vm, dir_issue) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -2528,7 +2528,7 @@ TEST(vm, dir_issue) {
|
||||
|
||||
TEST(vm, dir_issue1lk) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2546,7 +2546,7 @@ TEST(vm, dir_issue1lk) {
|
||||
|
||||
TEST(vm, type_int) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2565,7 +2565,7 @@ TEST(vm, type_int) {
|
||||
|
||||
TEST(vm, method_int) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2584,7 +2584,7 @@ TEST(vm, method_int) {
|
||||
|
||||
TEST(vm, fn_method_int) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2606,7 +2606,7 @@ TEST(vm, fn_method_int) {
|
||||
|
||||
TEST(vm, kw_no_empty) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2626,7 +2626,7 @@ TEST(vm, kw_no_empty) {
|
||||
|
||||
TEST(vm, tuple_void) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2678,7 +2678,7 @@ TEST(vm, method_cb) {
|
||||
|
||||
TEST(vm, class_getattr) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2696,7 +2696,7 @@ TEST(vm, class_getattr) {
|
||||
|
||||
TEST(vm, type_fullfealure) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2714,7 +2714,7 @@ TEST(vm, type_fullfealure) {
|
||||
|
||||
TEST(vm, dir_print_arg) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -2731,7 +2731,7 @@ TEST(vm, dir_print_arg) {
|
||||
|
||||
TEST(vm, fn_pos_vars) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_SLICE_ENABLE
|
||||
TEST(builtin, bytes) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -22,7 +22,7 @@ TEST(builtin, bytes) {
|
||||
#if PIKA_BUILTIN_STRUCT_ENABLE
|
||||
TEST(builtin, type1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -40,7 +40,7 @@ TEST(builtin, type1) {
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(builtin, seek) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -58,7 +58,7 @@ TEST(builtin, seek) {
|
||||
#if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL)
|
||||
TEST(builtin, file2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -76,7 +76,7 @@ TEST(builtin, file2) {
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(builtin, file3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -92,7 +92,7 @@ TEST(builtin, file3) {
|
||||
#if (PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL) && !PIKA_POOL_ENABLE
|
||||
TEST(builtin, bigfile) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -108,7 +108,7 @@ TEST(builtin, bigfile) {
|
||||
|
||||
TEST(builtin, nofound) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -123,7 +123,7 @@ TEST(builtin, nofound) {
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(builtin, callback_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -141,7 +141,7 @@ TEST(builtin, callback_1) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(builtin, utf8) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -3,7 +3,7 @@ TEST_START
|
||||
|
||||
TEST(cJSON, parse_print) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
char testjson[] =
|
||||
"{\n"
|
||||
@ -32,7 +32,7 @@ TEST(cJSON, parse_print) {
|
||||
|
||||
TEST(cJSON, getItem) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
char testjson[] =
|
||||
"{\n"
|
||||
@ -65,7 +65,7 @@ TEST(cJSON, getItem) {
|
||||
|
||||
TEST(cJSON, next) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
char testjson[] =
|
||||
"{\n"
|
||||
@ -103,7 +103,7 @@ TEST(cJSON, next) {
|
||||
|
||||
TEST(cJSON, next_get_value) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
char testjson[] =
|
||||
"{\n"
|
||||
@ -144,7 +144,7 @@ TEST(cJSON, next_get_value) {
|
||||
|
||||
TEST(cJSON, item) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -189,7 +189,7 @@ TEST(cJSON, item) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(cJSON, construct) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -228,7 +228,7 @@ TEST(cJSON, construct) {
|
||||
|
||||
TEST(cJSON, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -248,7 +248,7 @@ TEST(cJSON, test1) {
|
||||
|
||||
TEST(cJSON, test2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -269,7 +269,7 @@ TEST(cJSON, test2) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(cJSON, test3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -292,7 +292,7 @@ TEST(cJSON, test3) {
|
||||
|
||||
TEST(cJSON, test4) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -318,7 +318,7 @@ TEST(cJSON, test4) {
|
||||
|
||||
TEST(cJSON, test5) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -348,7 +348,7 @@ TEST(cJSON, test5) {
|
||||
|
||||
TEST(cJSON, test6) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -380,7 +380,7 @@ TEST(cJSON, test6) {
|
||||
|
||||
TEST(cJSON, parse_failed) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
char testjson[] =
|
||||
"{{\n"
|
||||
@ -419,7 +419,7 @@ TEST(cJSON, parse_failed) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(cJSON, test7) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -437,7 +437,7 @@ TEST(cJSON, test7) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(cJSON, module) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -3,7 +3,7 @@ TEST_START
|
||||
|
||||
TEST(chinese, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
pikaVM_runSingleFile(pikaMain, "../../examples/Chinese/test_operator.py");
|
||||
obj_run(pikaMain, "test()");
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(class, class_par) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -23,7 +23,7 @@ TEST(class, class_par) {
|
||||
|
||||
TEST(class, classpar1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -41,7 +41,7 @@ TEST(class, classpar1) {
|
||||
|
||||
TEST(class, static_method) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -60,7 +60,7 @@ TEST(class, static_method) {
|
||||
|
||||
TEST(class, dir_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -3,7 +3,7 @@ TEST_START
|
||||
|
||||
TEST(cmodule, print_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain, "print('test', 'test2')\n");
|
||||
|
@ -547,13 +547,13 @@ TEST(make, compile_depend_all) {
|
||||
// }
|
||||
|
||||
TEST(compiler, __str__) {
|
||||
char* lines = "__res = __str__()";
|
||||
char* lines = "@res_str = __str__()";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(compiler, __len__) {
|
||||
char* lines = "__res = __len__()";
|
||||
char* lines = "@res_len = __len__()";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
@ -583,25 +583,31 @@ TEST(compiler, __setitem__) {
|
||||
}
|
||||
|
||||
TEST(compiler, __getitem__) {
|
||||
char* lines = "__res = __getitem__(__key)";
|
||||
char* lines = "@res_item = __getitem__(__key)";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(compiler, __add__) {
|
||||
char* lines = "__res = __add__(__others)";
|
||||
char* lines = "@res_add = __add__(__others)";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(compiler, __iter__) {
|
||||
char* lines = "@res_iter = __iter__()";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(compiler, __sub__) {
|
||||
char* lines = "__res = __sub__(__others)";
|
||||
char* lines = "@res_sub = __sub__(__others)";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(compiler, __contains__) {
|
||||
char* lines = "__res = __contains__(__others)";
|
||||
char* lines = "@res_contains = __contains__(__others)";
|
||||
Parser_linesToArray(lines);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
@ -614,9 +620,9 @@ TEST(compiler, __callback) {
|
||||
|
||||
TEST(compiler, __list) {
|
||||
char* lines =
|
||||
"__res = []\n"
|
||||
"@res_list = []\n"
|
||||
"for __item in __list:\n"
|
||||
" __res.append(__item)\n"
|
||||
" @res_list.append(__item)\n"
|
||||
"del __item\n"
|
||||
"del __list\n";
|
||||
Parser_linesToArray(lines);
|
||||
|
@ -17,7 +17,7 @@ TEST(configparser, test1) {
|
||||
"ForwardX11 = no\n";
|
||||
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -39,7 +39,7 @@ TEST(configparser, test1) {
|
||||
#if PIKA_SYNTAX_SLICE_ENABLE
|
||||
TEST(configparser, test2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_SLICE_ENABLE
|
||||
TEST(ctypes, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
pikaVM_runSingleFile(pikaMain, "../../examples/BuiltIn/ctypes.py");
|
||||
@ -20,7 +20,7 @@ TEST(ctypes, test1) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(ctypes, test2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
|
@ -68,6 +68,7 @@ TEST(event, remove_regist) {
|
||||
EXPECT_EQ(testobj->refcnt, 1);
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
obj_GC(testobj);
|
||||
pks_eventListener_deinit(&g_pika_device_event_listener);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_EXCEPTION_ENABLE
|
||||
TEST(except, try1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -28,7 +28,7 @@ TEST(except, try1) {
|
||||
|
||||
TEST(except, def_none) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -48,7 +48,7 @@ TEST(except, def_none) {
|
||||
|
||||
TEST(except, trydef1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -65,7 +65,7 @@ TEST(except, trydef1) {
|
||||
|
||||
TEST(except, try1file) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -82,7 +82,7 @@ TEST(except, try1file) {
|
||||
|
||||
TEST(except, for_loop) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -108,7 +108,7 @@ TEST(except, for_loop) {
|
||||
|
||||
TEST(except, dict) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -124,7 +124,7 @@ TEST(except, dict) {
|
||||
|
||||
TEST(except, len) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -140,7 +140,7 @@ TEST(except, len) {
|
||||
|
||||
TEST(except, trycmodule1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -163,7 +163,7 @@ TEST(except, trycmodule1) {
|
||||
|
||||
TEST(except, except_break) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -189,7 +189,7 @@ TEST(except, except_break) {
|
||||
|
||||
TEST(except, while_try_while) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
|
@ -151,7 +151,6 @@ TEST(gc, circle) {
|
||||
pikaVM_runSingleFile(pikaMain, "test/python/gc/gc_circle.py");
|
||||
/* assert */
|
||||
/* deinit */
|
||||
pikaGC_markSweep();
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
TEST(hashlib, new_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -3,7 +3,7 @@ TEST_START
|
||||
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(json, loads) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -63,7 +63,7 @@ TEST(json, loads) {
|
||||
|
||||
#if PIKA_FLOAT_TYPE_DOUBLE
|
||||
TEST(json, dumps) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -6,7 +6,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void test_purec(void);
|
||||
void test_purec(void);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
@ -19,11 +19,16 @@ int main(int argc, char** argv) {
|
||||
#endif
|
||||
mem_pool_deinit();
|
||||
#if PIKA_ARG_CACHE_ENABLE
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
#if PIKA_GC_MARK_SWEEP_ENABLE
|
||||
extern PikaObjState g_PikaObjState;
|
||||
printf("[ GC]: object num max: %d, last GC: %d\r\n",
|
||||
g_PikaObjState.objCntMax, g_PikaObjState.objCntLastGC);
|
||||
#endif
|
||||
printf("[ Info]: alloc times: %d, cached times: %d (%0.2f%%)\r\n",
|
||||
g_pikaMemInfo.alloc_times, g_pikaMemInfo.alloc_times_cache,
|
||||
((float)g_pikaMemInfo.alloc_times_cache /
|
||||
(float)g_pikaMemInfo.alloc_times) *
|
||||
g_PikaMemInfo.alloc_times, g_PikaMemInfo.alloc_times_cache,
|
||||
((float)g_PikaMemInfo.alloc_times_cache /
|
||||
(float)g_PikaMemInfo.alloc_times) *
|
||||
100.0);
|
||||
#endif
|
||||
return res;
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(module, cmodule_import) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
__platform_printf("BEGIN\r\n");
|
||||
/* run */
|
||||
@ -23,7 +23,7 @@ TEST(module, cmodule_import) {
|
||||
|
||||
TEST(module, while_loop) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -42,7 +42,7 @@ TEST(module, while_loop) {
|
||||
|
||||
TEST(module, for_loop) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -61,7 +61,7 @@ TEST(module, for_loop) {
|
||||
|
||||
TEST(module, script) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -78,7 +78,7 @@ TEST(module, script) {
|
||||
|
||||
TEST(module, __init__) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -97,7 +97,7 @@ TEST(module, __init__) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(module, __init__2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -117,7 +117,7 @@ TEST(module, __init__2) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(module, import_as_issue1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -141,7 +141,7 @@ TEST(module, import_as_issue1) {
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(module, unittest_test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -163,7 +163,7 @@ TEST(module, unittest_test1) {
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(module, unittest_test2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -183,7 +183,7 @@ TEST(module, unittest_test2) {
|
||||
|
||||
TEST(module, unittest_test3) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -205,7 +205,7 @@ TEST(module, unittest_test3) {
|
||||
|
||||
TEST(socket, gethostname) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -223,7 +223,7 @@ TEST(socket, gethostname) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(socket, server_client) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -242,7 +242,7 @@ TEST(socket, server_client) {
|
||||
|
||||
TEST(socket, thread) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -264,7 +264,7 @@ TEST(socket, thread) {
|
||||
#if PIKA_FLOAT_TYPE_DOUBLE
|
||||
TEST(socket, json_issue) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -296,7 +296,7 @@ TEST(socket, json_issue) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(re, match) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -319,7 +319,7 @@ TEST(re, match) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(re, search) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -340,7 +340,7 @@ TEST(re, search) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(re, sub) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -361,7 +361,7 @@ TEST(re, sub) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(re, findall) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -387,7 +387,7 @@ TEST(re, findall) {
|
||||
|
||||
TEST(modbus, rtu_master) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -414,7 +414,7 @@ TEST(modbus, rtu_master) {
|
||||
|
||||
TEST(proxy, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -432,7 +432,7 @@ TEST(proxy, test1) {
|
||||
|
||||
TEST(issue, global) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -449,7 +449,7 @@ TEST(issue, global) {
|
||||
|
||||
TEST(module, mod1_mod2_mod1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -468,7 +468,7 @@ TEST(module, mod1_mod2_mod1) {
|
||||
|
||||
TEST(module, improt_as_cmodule) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -497,7 +497,7 @@ void pikaScriptShell_withGetchar(PikaObj* self, sh_getchar getchar_fn);
|
||||
|
||||
TEST(module, REPL_runbytecode) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -517,7 +517,7 @@ TEST(module, REPL_runbytecode) {
|
||||
|
||||
TEST(module, REPL_script) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -536,7 +536,7 @@ TEST(module, REPL_script) {
|
||||
|
||||
TEST(module, REPL_script_2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -555,7 +555,7 @@ TEST(module, REPL_script_2) {
|
||||
|
||||
TEST(module, REPL_big_script) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -576,7 +576,7 @@ TEST(module, REPL_big_script) {
|
||||
|
||||
TEST(module, REPL_stdtask) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -74,7 +74,7 @@ int pika_hal_platform_WIFI_ioctl_others(pika_dev* dev,
|
||||
}
|
||||
|
||||
TEST(network, scan) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -98,7 +98,7 @@ TEST(network, scan) {
|
||||
}
|
||||
|
||||
TEST(network, connect) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -127,7 +127,7 @@ TEST(network, connect) {
|
||||
}
|
||||
|
||||
TEST(network, config) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,4 @@
|
||||
#define LOG_BUFF_MAX 100
|
||||
#define LOG_SIZE 512
|
||||
#define LOG_SIZE 512
|
||||
void mem_pool_deinit(void);
|
||||
void mem_pool_init(void);
|
@ -4,7 +4,7 @@ TEST_START
|
||||
|
||||
TEST(pikaui, page) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -9,3 +9,5 @@ def test():
|
||||
b.parent = a
|
||||
|
||||
test()
|
||||
c = Tree()
|
||||
print('end')
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_SLICE_ENABLE
|
||||
TEST(stddata, test1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -31,7 +31,7 @@ TEST(stddata, test1) {
|
||||
/* test b2a_hex */
|
||||
TEST(stddata, test2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -49,7 +49,7 @@ TEST(stddata, test2) {
|
||||
/* test a2b_hex */
|
||||
TEST(stddata, a2b_hex) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -69,7 +69,7 @@ TEST(stddata, a2b_hex) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(stddata, encode_decode) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -91,7 +91,7 @@ TEST(stddata, encode_decode) {
|
||||
#if PIKA_FILEIO_ENABLE
|
||||
TEST(stddata, fileio) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -109,7 +109,7 @@ TEST(stddata, fileio) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(list, in) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -127,7 +127,7 @@ TEST(list, in) {
|
||||
|
||||
TEST(dict, in) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -144,7 +144,7 @@ TEST(dict, in) {
|
||||
|
||||
TEST(list, slice) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -165,7 +165,7 @@ TEST(list, slice) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(str, split) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -180,7 +180,7 @@ TEST(str, split) {
|
||||
|
||||
TEST(str, split2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -197,7 +197,7 @@ TEST(str, split2) {
|
||||
|
||||
TEST(dict, cmodule) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -214,7 +214,7 @@ TEST(dict, cmodule) {
|
||||
|
||||
TEST(dict, items) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -231,7 +231,7 @@ TEST(dict, items) {
|
||||
|
||||
TEST(dict, items2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -251,7 +251,7 @@ TEST(dict, items2) {
|
||||
|
||||
TEST(dict, items_kv) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -271,7 +271,7 @@ TEST(dict, items_kv) {
|
||||
|
||||
TEST(stddata, list_str) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -286,7 +286,7 @@ TEST(stddata, list_str) {
|
||||
|
||||
TEST(stddata, list_bytes) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -301,7 +301,7 @@ TEST(stddata, list_bytes) {
|
||||
|
||||
TEST(stddata, bytes_list) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -316,7 +316,7 @@ TEST(stddata, bytes_list) {
|
||||
|
||||
TEST(stddata, list_pop_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -338,7 +338,7 @@ TEST(stddata, list_pop_) {
|
||||
|
||||
TEST(stddata, list_remove_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -359,7 +359,7 @@ TEST(stddata, list_remove_) {
|
||||
|
||||
TEST(stddata, list_insert_) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -378,7 +378,7 @@ TEST(stddata, list_insert_) {
|
||||
|
||||
TEST(stddata, dict_update) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -399,7 +399,7 @@ TEST(stddata, dict_update) {
|
||||
|
||||
TEST(issue, id_test) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -415,7 +415,7 @@ TEST(issue, id_test) {
|
||||
|
||||
TEST(str, strip) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -431,7 +431,7 @@ TEST(str, strip) {
|
||||
|
||||
TEST(str, big_slice) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -445,7 +445,7 @@ TEST(str, big_slice) {
|
||||
|
||||
TEST(std, eval) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -460,7 +460,7 @@ TEST(std, eval) {
|
||||
|
||||
TEST(stddata, kw_fun) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -478,7 +478,7 @@ TEST(stddata, kw_fun) {
|
||||
|
||||
TEST(stddata, kw_fun_err_input) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -496,7 +496,7 @@ TEST(stddata, kw_fun_err_input) {
|
||||
|
||||
TEST(stddata, bytes_add) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -511,7 +511,7 @@ TEST(stddata, bytes_add) {
|
||||
|
||||
TEST(stddata, pikafs_open) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -531,7 +531,7 @@ TEST(stddata, pikafs_open) {
|
||||
|
||||
TEST(stddata, list_slice_issue) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -4,7 +4,7 @@ TEST_START
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, cformat) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain, "s = cformat('test:%d:%f', 33, 1.5)\n");
|
||||
@ -21,7 +21,7 @@ TEST(string, cformat) {
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, cformat1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain, "s = 'res:%d' % 23\n");
|
||||
@ -38,7 +38,7 @@ TEST(string, cformat1) {
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, format1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain, "print('tes:%d,%f'%(123,1.5))\n");
|
||||
@ -54,7 +54,7 @@ TEST(string, format1) {
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, format2) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain, "print('tes:%d,%f'%(123,1.5), 23)\n");
|
||||
@ -70,7 +70,7 @@ TEST(string, format2) {
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, print_file) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -90,7 +90,7 @@ TEST(string, print_file) {
|
||||
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, format_parse1) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "print('tes:%0.2f'% mem.getMax())";
|
||||
printf("%s\n", lines);
|
||||
@ -110,7 +110,7 @@ TEST(string, format_parse1) {
|
||||
|
||||
TEST(string, split) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -132,7 +132,7 @@ TEST(string, split) {
|
||||
|
||||
TEST(string, split_str) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -152,7 +152,7 @@ TEST(string, split_str) {
|
||||
|
||||
TEST(string, strip) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -170,7 +170,7 @@ TEST(string, strip) {
|
||||
|
||||
TEST(string, replace) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -189,7 +189,7 @@ TEST(string, replace) {
|
||||
#if PIKA_SYNTAX_IMPORT_EX_ENABLE
|
||||
TEST(string, replace_chain) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain,
|
||||
@ -212,7 +212,7 @@ TEST(string, replace_chain) {
|
||||
#if !PIKA_NANO_ENABLE
|
||||
TEST(string, split_chain) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -231,7 +231,7 @@ TEST(string, split_chain) {
|
||||
|
||||
TEST(string, str_chain) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -250,7 +250,7 @@ TEST(string, str_chain) {
|
||||
#if PIKA_SYNTAX_FORMAT_ENABLE
|
||||
TEST(string, str_issue1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -269,7 +269,7 @@ TEST(string, str_issue1) {
|
||||
#if PIKA_STRING_UTF8_ENABLE
|
||||
TEST(string, utf8_1) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "test_common.h"
|
||||
TEST_START
|
||||
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
/* the log_buff of printf */
|
||||
extern char log_buff[LOG_BUFF_MAX][LOG_SIZE];
|
||||
|
||||
@ -104,7 +104,7 @@ TEST(str, strPointToLastToken) {
|
||||
|
||||
TEST(str, transfer) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -122,7 +122,7 @@ TEST(str, transfer) {
|
||||
|
||||
TEST(str, transfer_issue_jfo4i) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -39,7 +39,7 @@ TEST(sysObj, getattr) {
|
||||
"test = Test()\n"
|
||||
"aa = getattr(test, 'a')\n";
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
@ -63,7 +63,7 @@ TEST(sysObj, setattr) {
|
||||
"setattr(test, 'a', 2)\n"
|
||||
"aa = test.a\n";
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
|
@ -18,7 +18,7 @@ extern "C" {
|
||||
#include "dataStrs.h"
|
||||
#include "pikaScript.h"
|
||||
#include "pika_config_gtest.h"
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
/* the log_buff of printf */
|
||||
extern char log_buff[LOG_BUFF_MAX][LOG_SIZE];
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ TEST_START
|
||||
#if !PIKA_NANO_ENABLE && 1
|
||||
|
||||
TEST(thread, test1) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
@ -18,7 +18,7 @@ TEST(thread, test1) {
|
||||
}
|
||||
|
||||
TEST(thread, self) {
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
@ -10,14 +10,14 @@ extern void time_asctime(const _tm* this_tm);
|
||||
void time_struct_format(const _tm* this_tm, char* str);
|
||||
}
|
||||
|
||||
extern pikaMemInfo g_pikaMemInfo;
|
||||
extern PikaMemInfo g_PikaMemInfo;
|
||||
/* the log_buff of printf */
|
||||
extern char log_buff[LOG_BUFF_MAX][LOG_SIZE];
|
||||
|
||||
#if 0
|
||||
TEST(unix_time, time) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
@ -40,7 +40,7 @@ TEST(unix_time, time) {
|
||||
#if PIKA_STD_DEVICE_UNIX_TIME_ENABLE
|
||||
TEST(unix_time, unix_time) {
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
/* run */
|
||||
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
@ -144,7 +144,7 @@ TEST(timetest, sleep) {
|
||||
"t = PikaStdDevice.Time()\n"
|
||||
"t.sleep(0.1)\n";
|
||||
/* init */
|
||||
g_pikaMemInfo.heapUsedMax = 0;
|
||||
g_PikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
extern unsigned char pikaModules_py_a[];
|
||||
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||
|
Loading…
x
Reference in New Issue
Block a user