From 8740acc2397257623bf6cbabf52d753cf8c5f914 Mon Sep 17 00:00:00 2001 From: Shinya Sato Date: Sat, 7 Sep 2024 15:21:45 +0900 Subject: v0.13.0-1 --- Changelog.md | 9 +++++++- README.md | 2 +- src/inpla.y | 74 +++++++++++++++++++++++++++++++++--------------------------- 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/Changelog.md b/Changelog.md index dbd8984..3658402 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,12 @@ # Change log +### v0.13.0-1 (released on 7 September 2024) +#### Polished +- **The source code of the compile function is cleaned up more**: Some parts of the compile function were not changed in the previous version. They are now cleaned up. + + + + ### v0.13.0 (released on 3 September 2024) | | v0.12.2 | | -> | v0.13.0 | | @@ -15,7 +22,7 @@ #### Polished -* **Compile method is changed**: A given net is compiled into bytecodes by using a compile function. This follows a depth-first search algorithm. For instance, `A(t1,t2,t3)` is compiled as follows: +- **Compile method is changed**: A given net is compiled into bytecodes by using a compile function. This follows a depth-first search algorithm. For instance, `A(t1,t2,t3)` is compiled as follows: ``` compile(A(t1, t2, t3)) diff --git a/README.md b/README.md index 277e240..e1f4233 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Inpla is a multi-threaded parallel interpreter of interaction nets. Once you write programs for sequential execution, it works also in multi-threaded parallel execution. Each thread is managed on each CPU-core with POSIX-thread library. -* The current version is 0.13.0, released on **3 September 2024**. (See [Changelog.md](Changelog.md) for details.) +* The current version is 0.13.0-1, released on **7 September 2024**. (See [Changelog.md](Changelog.md) for details.) * The below graph shows speed-up ratio to threads numbers for programs in the following benchmark table. ![speedup-ratio](pic/benchmark_reuse_v0.13.0.png) diff --git a/src/inpla.y b/src/inpla.y index 6d78f37..7e10795 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -22,8 +22,8 @@ // ---------------------------------------------- -#define VERSION "0.13.0" -#define BUILT_DATE "3 September 2024" +#define VERSION "0.13.0-1" +#define BUILT_DATE "7 September 2024" // ------------------------------------------------------------------ @@ -5681,7 +5681,7 @@ int Compile_term_on_ast(Ast *ptr, int target) { int result, mkagent; int i, arity; - int alloc[MAX_PORT]; + int alloc; if (ptr == NULL) { return -1; @@ -5736,7 +5736,6 @@ int Compile_term_on_ast(Ast *ptr, int target) { /* A register of the element alloc[0] = Compile_term_on_ast(ptr->left, -1); */ - alloc[1] = Compile_term_on_ast(ptr->right->left, -1); if (target == -1) { @@ -5745,23 +5744,26 @@ int Compile_term_on_ast(Ast *ptr, int target) { // expanded operations IMCode_genCode2(OP_MKAGENT, ID_CONS, result); - alloc[0] = Compile_term_on_ast(ptr->left, -1); - IMCode_genCode3(OP_LOADP, alloc[0], 0, result); + alloc = Compile_term_on_ast(ptr->left, -1); + IMCode_genCode3(OP_LOADP, alloc, 0, result); - IMCode_genCode3(OP_LOADP, alloc[1], 1, result); + alloc = Compile_term_on_ast(ptr->right->left, -1); + IMCode_genCode3(OP_LOADP, alloc, 1, result); } else { result = target; - alloc[0] = Compile_term_on_ast(ptr->left, -1); if (target == VM_OFFSET_ANNOTATE_L) { if (CmEnv.idL != ID_CONS) { IMCode_genCode1(OP_CHID_L, ID_CONS); } for (i=0; i<2; i++) { - if (alloc[i] != VM_OFFSET_METAVAR_L(i)) { - IMCode_genCode2(OP_LOADP_L, alloc[i], i); + alloc = Compile_term_on_ast(ptr->left, -1); + ptr = ast_getTail(ptr); + + if (alloc != VM_OFFSET_METAVAR_L(i)) { + IMCode_genCode2(OP_LOADP_L, alloc, i); } } } else { @@ -5769,8 +5771,11 @@ int Compile_term_on_ast(Ast *ptr, int target) { IMCode_genCode1(OP_CHID_R, ID_CONS); } for (i=0; i<2; i++) { - if (alloc[i] != VM_OFFSET_METAVAR_R(i)) { - IMCode_genCode2(OP_LOADP_R, alloc[i], i); + alloc = Compile_term_on_ast(ptr->left, -1); + ptr = ast_getTail(ptr); + + if (alloc != VM_OFFSET_METAVAR_R(i)) { + IMCode_genCode2(OP_LOADP_R, alloc, i); } } } @@ -5789,8 +5794,8 @@ int Compile_term_on_ast(Ast *ptr, int target) { // The case of the single tuple such as `(A)'. // The `A' is recognised as not an argument, but as a first-class object. ptr=ptr->right; - alloc[0] = Compile_term_on_ast(ptr->left, target); - result = alloc[0]; + alloc = Compile_term_on_ast(ptr->left, target); + result = alloc; } else { @@ -5804,9 +5809,9 @@ int Compile_term_on_ast(Ast *ptr, int target) { for (i=0; ileft, -1); + alloc = Compile_term_on_ast(ptr->left, -1); ptr = ast_getTail(ptr); - IMCode_genCode3(OP_LOADP, alloc[0], i, result); + IMCode_genCode3(OP_LOADP, alloc, i, result); } } else { @@ -5819,11 +5824,11 @@ int Compile_term_on_ast(Ast *ptr, int target) { IMCode_genCode1(OP_CHID_L, GET_TUPLEID(arity)); } for (i=0; ileft, -1); + alloc = Compile_term_on_ast(ptr->left, -1); ptr = ast_getTail(ptr); - if (alloc[0] != VM_OFFSET_METAVAR_L(i)) { - IMCode_genCode2(OP_LOADP_L, alloc[0], i); + if (alloc != VM_OFFSET_METAVAR_L(i)) { + IMCode_genCode2(OP_LOADP_L, alloc, i); } } @@ -5832,11 +5837,11 @@ int Compile_term_on_ast(Ast *ptr, int target) { IMCode_genCode1(OP_CHID_R, GET_TUPLEID(arity)); } for (i=0; ileft, -1); + alloc = Compile_term_on_ast(ptr->left, -1); ptr = ast_getTail(ptr); - if (alloc[0] != VM_OFFSET_METAVAR_R(i)) { - IMCode_genCode2(OP_LOADP_R, alloc[0], i); + if (alloc != VM_OFFSET_METAVAR_R(i)) { + IMCode_genCode2(OP_LOADP_R, alloc, i); } } } @@ -5866,11 +5871,11 @@ int Compile_term_on_ast(Ast *ptr, int target) { } // printf("id=%d\n", id); - alloc[0] = CmEnv_newvar(); - IMCode_genCode2(OP_LOADI, id, alloc[0]); + alloc = CmEnv_newvar(); + IMCode_genCode2(OP_LOADI, id, alloc); // IMCode_genCode2(OP_MKAGENT, ID_PERCENT, result); - IMCode_genCode3(OP_LOADP, alloc[0], 0, result); + IMCode_genCode3(OP_LOADP, alloc, 0, result); } return result; break; @@ -5916,10 +5921,10 @@ int Compile_term_on_ast(Ast *ptr, int target) { IMCode_genCode2(OP_MKAGENT, id, result); for (i=0; ileft, -1); + alloc = Compile_term_on_ast(ptr->left, -1); ptr = ast_getTail(ptr); - IMCode_genCode3(OP_LOADP, alloc[0], i, result); + IMCode_genCode3(OP_LOADP, alloc, i, result); } } else { @@ -5930,11 +5935,11 @@ int Compile_term_on_ast(Ast *ptr, int target) { IMCode_genCode1(OP_CHID_L, id); } for (i=0; ileft, -1); + alloc = Compile_term_on_ast(ptr->left, -1); ptr = ast_getTail(ptr); - if (alloc[0] != VM_OFFSET_METAVAR_L(i)) { - IMCode_genCode2(OP_LOADP_L, alloc[0], i); + if (alloc != VM_OFFSET_METAVAR_L(i)) { + IMCode_genCode2(OP_LOADP_L, alloc, i); } } @@ -5945,11 +5950,11 @@ int Compile_term_on_ast(Ast *ptr, int target) { IMCode_genCode1(OP_CHID_R, id); } for (i=0; ileft, -1); + alloc = Compile_term_on_ast(ptr->left, -1); ptr = ast_getTail(ptr); - if (alloc[0] != VM_OFFSET_METAVAR_R(i)) { - IMCode_genCode2(OP_LOADP_R, alloc[0], i); + if (alloc != VM_OFFSET_METAVAR_R(i)) { + IMCode_genCode2(OP_LOADP_R, alloc, i); } } } @@ -6004,7 +6009,10 @@ int Compile_term_on_ast(Ast *ptr, int target) { +// Checks for variable occurrences in equations in rules. +// When this function is called, meta names have been stored in CmEnv. +// Japanese: // rule の中の eqs をコンパイルするときに使う // この関数が呼ばれる前に、rule agents の meta names は // Environment に積まれている。 -- cgit v1.2.3