... | ... |
@@ -74,11 +74,13 @@ static inline int bcfail(const char *msg, long a, long b, |
74 | 74 |
#define TRACE_R(x) cli_dbgmsg("bytecode trace: %u, read %llx\n", pc, (long long)x); |
75 | 75 |
#define TRACE_W(x, w, p) cli_dbgmsg("bytecode trace: %u, write%d @%u %llx\n", pc, p, w, (long long)(x)); |
76 | 76 |
#define TRACE_EXEC(id, dest, ty, stack) cli_dbgmsg("bytecode trace: executing %d, -> %u (%u); %u\n", id, dest, ty, stack) |
77 |
+#define TRACE_API(s, dest, ty, stack) cli_dbgmsg("bytecode trace: executing %s, -> %u (%u); %u\n", s, dest, ty, stack) |
|
77 | 78 |
#else |
78 | 79 |
#define CHECK_UNREACHABLE return CL_EBYTECODE |
79 | 80 |
#define TRACE_R(x) |
80 | 81 |
#define TRACE_W(x, w, p) |
81 | 82 |
#define TRACE_EXEC(id, dest, ty, stack) |
83 |
+#define TRACE_API(s, dest, ty, stack) |
|
82 | 84 |
#endif |
83 | 85 |
|
84 | 86 |
#define SIGNEXT(a, from) CLI_SRS(((int64_t)(a)) << (64-(from)), (64-(from))) |
... | ... |
@@ -561,7 +563,7 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, |
561 | 561 |
info = &infos->glob_infos[ptrid]; |
562 | 562 |
} |
563 | 563 |
if (LIKELY(ptroff < info->size && |
564 |
- read_size < info->size && |
|
564 |
+ read_size <= info->size && |
|
565 | 565 |
ptroff + read_size <= info->size)) { |
566 | 566 |
return info->base+ptroff; |
567 | 567 |
} |
... | ... |
@@ -768,15 +770,17 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
768 | 768 |
|
769 | 769 |
DEFINE_OP(OP_BC_CALL_API) { |
770 | 770 |
const struct cli_apicall *api = &cli_apicalls[inst->u.ops.funcid]; |
771 |
- int32_t res; |
|
771 |
+ int32_t res32; |
|
772 |
+ int64_t res64; |
|
772 | 773 |
CHECK_APIID(inst->u.ops.funcid); |
773 |
- TRACE_EXEC(-inst->u.ops.funcid, inst->dest, inst->type, stack_depth); |
|
774 |
+ TRACE_API(api->name, inst->dest, inst->type, stack_depth); |
|
774 | 775 |
switch (api->kind) { |
775 | 776 |
case 0: { |
776 | 777 |
int32_t a, b, r; |
777 | 778 |
READ32(a, inst->u.ops.ops[0]); |
778 | 779 |
READ32(b, inst->u.ops.ops[1]); |
779 |
- res = cli_apicalls0[api->idx](ctx, a, b); |
|
780 |
+ res32 = cli_apicalls0[api->idx](ctx, a, b); |
|
781 |
+ WRITE32(inst->dest, res32); |
|
780 | 782 |
break; |
781 | 783 |
} |
782 | 784 |
case 1: { |
... | ... |
@@ -785,13 +789,15 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
785 | 785 |
/* check that arg2 is size of arg1 */ |
786 | 786 |
READ32(arg2, inst->u.ops.ops[1]); |
787 | 787 |
READP(arg1, inst->u.ops.ops[0], arg2); |
788 |
- res = cli_apicalls1[api->idx](ctx, arg1, arg2); |
|
788 |
+ res32 = cli_apicalls1[api->idx](ctx, arg1, arg2); |
|
789 |
+ WRITE32(inst->dest, res32); |
|
789 | 790 |
break; |
790 | 791 |
} |
791 | 792 |
case 2: { |
792 | 793 |
int32_t a; |
793 | 794 |
READ32(a, inst->u.ops.ops[0]); |
794 |
- res = cli_apicalls2[api->idx](ctx, a); |
|
795 |
+ res32 = cli_apicalls2[api->idx](ctx, a); |
|
796 |
+ WRITE32(inst->dest, res32); |
|
795 | 797 |
break; |
796 | 798 |
} |
797 | 799 |
case 3: { |
... | ... |
@@ -799,7 +805,8 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
799 | 799 |
void *resp; |
800 | 800 |
READ32(a, inst->u.ops.ops[0]); |
801 | 801 |
resp = cli_apicalls3[api->idx](ctx, a); |
802 |
- res = ptr_register_glob(&ptrinfos, resp, a); |
|
802 |
+ res64 = ptr_register_glob(&ptrinfos, resp, a); |
|
803 |
+ WRITE64(inst->dest, res64); |
|
803 | 804 |
break; |
804 | 805 |
} |
805 | 806 |
case 4: { |
... | ... |
@@ -810,11 +817,13 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
810 | 810 |
READ32(arg3, inst->u.ops.ops[2]); |
811 | 811 |
READ32(arg4, inst->u.ops.ops[3]); |
812 | 812 |
READ32(arg5, inst->u.ops.ops[4]); |
813 |
- res = cli_apicalls4[api->idx](ctx, arg1, arg2, arg3, arg4, arg5); |
|
813 |
+ res32 = cli_apicalls4[api->idx](ctx, arg1, arg2, arg3, arg4, arg5); |
|
814 |
+ WRITE32(inst->dest, res32); |
|
814 | 815 |
break; |
815 | 816 |
} |
816 | 817 |
case 5: { |
817 |
- res = cli_apicalls5[api->idx](ctx); |
|
818 |
+ res32 = cli_apicalls5[api->idx](ctx); |
|
819 |
+ WRITE32(inst->dest, res32); |
|
818 | 820 |
break; |
819 | 821 |
} |
820 | 822 |
case 6: { |
... | ... |
@@ -823,7 +832,8 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
823 | 823 |
READ32(arg1, inst->u.ops.ops[0]); |
824 | 824 |
READ32(arg2, inst->u.ops.ops[1]); |
825 | 825 |
resp = cli_apicalls6[api->idx](ctx, arg1, arg2); |
826 |
- res = ptr_register_glob(&ptrinfos, resp, arg2); |
|
826 |
+ res64 = ptr_register_glob(&ptrinfos, resp, arg2); |
|
827 |
+ WRITE64(inst->dest, res64); |
|
827 | 828 |
break; |
828 | 829 |
} |
829 | 830 |
case 7: { |
... | ... |
@@ -831,14 +841,14 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
831 | 831 |
READ32(arg1, inst->u.ops.ops[0]); |
832 | 832 |
READ32(arg2, inst->u.ops.ops[1]); |
833 | 833 |
READ32(arg3, inst->u.ops.ops[2]); |
834 |
- res = cli_apicalls7[api->idx](ctx, arg1, arg2, arg3); |
|
834 |
+ res32 = cli_apicalls7[api->idx](ctx, arg1, arg2, arg3); |
|
835 |
+ WRITE32(inst->dest, res32); |
|
835 | 836 |
break; |
836 | 837 |
} |
837 | 838 |
default: |
838 | 839 |
cli_warnmsg("bytecode: type %u apicalls not yet implemented!\n", api->kind); |
839 | 840 |
stop = CL_EBYTECODE; |
840 | 841 |
} |
841 |
- WRITE32(inst->dest, res); |
|
842 | 842 |
break; |
843 | 843 |
} |
844 | 844 |
|
... | ... |
@@ -221,9 +221,8 @@ END_TEST |
221 | 221 |
START_TEST (test_inflate) |
222 | 222 |
{ |
223 | 223 |
cl_init(CL_INIT_DEFAULT); |
224 |
- if (have_clamjit) |
|
225 |
- runtest("input/inflate.cbc", 0xbeef, 0, 0, NULL, NULL, NULL, NULL); |
|
226 |
-// runtest("input/inflate.cbc", 0xbeef, 0, 1, NULL, NULL, NULL, NULL); |
|
224 |
+ runtest("input/inflate.cbc", 0xbeef, 0, 0, NULL, NULL, NULL, NULL); |
|
225 |
+ runtest("input/inflate.cbc", 0xbeef, 0, 1, NULL, NULL, NULL, NULL); |
|
227 | 226 |
} |
228 | 227 |
END_TEST |
229 | 228 |
|
... | ... |
@@ -1,12 +1,12 @@ |
1 |
-ClamBCafhom`cjjkd|afefdfggifnf```````|bhacflfafmfbfcfmb`cnbac`cmbacdcmbgfffdfbcafbfafbc``baaaap`clamcoincidencejb:444 |
|
1 |
+ClamBCafhdhff`kkd|afefdfggifnf```````|bjacflfafmfbfcfmb`cnbac`cmbdcicdc`cmbgfffhcafafacgcbf``baaaap`clamcoincidencejb:444 |
|
2 | 2 |
|
3 |
-Tedeb`eebodebadaaa`aabb`bb`baacbadb`bb`baacb`bb`bb`baadb`bb`bb`bb`baadb`bbadbadb`baae`badbadb`bb`bdafahdblaah |
|
3 |
+Tedeb`eebodebadaaa`aabb`bb`baacbadb`bb`baacb`bb`bb`baadb`bb`bb`bb`baadb`bbadbadb`baae`badbadb`bb`bdaeahdblaah |
|
4 | 4 |
Ebibaibnabid|b`abfegffffefbgoe`gif`gefoenfefgg``b`bbid|bgabfegffffefbgoe`gif`gefoebgefafdfoeaffgafiflf``bcbbid|bhabfegffffefbgoe`gif`gefoeggbgifdgefoeaffgafiflf``bibbid|amifnffflfafdgefoedfofnfef``bhbbid|b`aifnffflfafdgefoe`gbgofcfefcgcg``babbjd|beabfegffffefbgoe`gif`gefoebgefafdfoegfefdg``bdbbjd|bfabfegffffefbgoe`gif`gefoeggbgifdgefoegfefdg``bebbkd|bjabfegffffefbgoe`gif`gefoeggbgifdgefoecgdgof`g`gefdf``bgbbld|amifnffflfafdgefoeifnfifdg`` |
5 |
-G`ae`@`b`eBoaBkhAhAhB`jBjaBejBkd@AcBffBofBof@BkbBidBmbBnbAa@AlBngBogBhmAd@@@`bodBdgBefBcgBdgBkc@`bad@Aa`bad@Ab` |
|
5 |
+G`ae`@`b`eBoaBkhAhAhB`jBjaBejBkd@AcBffBofBof@BkbBidBmbBnbAa@AlBngBogBhmAd@@@`bodBdgBefBcgBdg@`bad@Aa`bad@Ab` |
|
6 | 6 |
A`b`bLbfab`bab`b`b`b`aa`aa`aa```b`b`bad```b`b`b`b`aa```b`b`b`b`bad`b`b`aa```b`b`b`b`Fbjaae |
7 |
-Bb`baaababnaD```adb`babababnaD```adaaacnab`baa@daaadnab`bab@daaael`adac``bbEamjnmd`Taaaeadaa |
|
7 |
+Bb`baaababnaD```adb`babababnaD```adaaacnab`baa@daaadnab`bab@daaael`acad``bbEamjnmd`Taaaeadaa |
|
8 | 8 |
Bb`bagababcbaabadahabbbdbaaag``ibahAc`Bladb`bajabbbebaaBladb`bakabcbgbaaabBoadaaalnab`bak@d``bbEbmjnmd`Taaaladab |
9 |
-Bb`banababhbakb`baoabab`babbadb`aabbbababaob`bbaakbb`aAd`Aedaabbaeab`bbaa@d``bbEcmjnmd`Taabbaacad |
|
9 |
+Bb`banababhbakb`baoabab`babbadb`aabbbababaob`bbaakbb`aAd`Addaabbaeab`bbaa@d``bbEcmjnmd`Taabbaacad |
|
10 | 10 |
Bb`bbdaababibakTcab`bDonnkd |
11 | 11 |
Bb`bbeabb`beaTcab`bbeaE |
12 | 12 |
Scgdgafdgifcf`bcfofnfcgdg`begifnfdghcoedg`bifnf`gegdgkeme`bmc`bkgS`chgacfflb`b`chghcbflb`b`chg`chclb`b`chg`chclb`b`chgaf`clb`b`chgacaflb`b`chgafeclb`b`chgdcbflb`b`chg`c`clb`b`chg`ccclb`b`chgfcfclb`b`chgfcfflb |
... | ... |
@@ -17,4 +17,4 @@ affgafiflf`bmc`bbfegffffefbgoe`gif`gefoeggbgifdgefoeaffgafiflfhbifnf`gegdgoebfeg |
17 | 17 |
mfefmfcf`gighbifnf`gegdgoebflb`bifnf`gegdglb`bcgifjgefofffhbifnf`gegdgibibkcSbfegffffefbgoe`gif`gefoeggbgifdgefoecgdgof`g`gefdfhbifnf`gegdgoebfegfflb`bcgifjgefofffhbifnf`gegdgibibkc |
18 | 18 |
Sifnfdgccbcoedg`bifdf`bmc`bifnffflfafdgefoeifnfifdghbifnf`gegdgoebfegfflb`bofegdg`gegdgoebfegfflb`bccacibkcSifff`bhbifdf`blc`b`cibSbgefdgegbgnf`b`chgdfefafdfbckcSifnffflfafdgefoe`gbgofcfefcgcghbifdfibkc |
19 | 19 |
affgafiflf`bmc`bbfegffffefbgoe`gif`gefoebgefafdfoeaffgafiflfhbofegdg`gegdgoebfegffibkcSofegdgoebf`bmc`bbfegffffefbgoe`gif`gefoebgefafdfoegfefdghbofegdg`gegdgoebfegfflb`baffgafiflfibkc |
20 |
-ifff`bhbmfefmfcfmf`ghbofegdgoebflb`bbbdgefcgdgkcbblb`becibibSbgefdgegbgnf`b`chgdfefafdfcckcSifnffflfafdgefoedfofnfefhbifdfibkcSbgefdgegbgnf`b`chgbfefefffkcSmgSS |
|
21 | 20 |
\ No newline at end of file |
21 |
+ifff`bhbmfefmfcfmf`ghbofegdgoebflb`bbbdgefcgdgbblb`bdcibibSbgefdgegbgnf`b`chgdfefafdfcckcSifnffflfafdgefoedfofnfefhbifdfibkcSbgefdgegbgnf`b`chgbfefefffkcSmgSS |
|
22 | 22 |
\ No newline at end of file |