changeset 102:bfaca67eeb78

allocate a new native code chunk when we run out of space
author Mike Pavone <pavone@retrodev.com>
date Thu, 27 Dec 2012 22:41:28 -0800
parents d7789186ba5e
children a71544cd01ea
files m68k_to_x86.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_to_x86.c	Thu Dec 27 22:35:26 2012 -0800
+++ b/m68k_to_x86.c	Thu Dec 27 22:41:28 2012 -0800
@@ -2162,8 +2162,16 @@
 	do {
 		do {
 			if (dst_end-dst < 128) {
-				puts("out of code memory");
-				exit(1);
+				if (dst_end-dst < 5) {
+					puts("out of code memory, not enough space for jmp to next chunk");
+					exit(1);
+				}
+				size_t size = 1024*1024;
+				opts->cur_code = alloc_code(&size);
+				opts->code_end = opts->cur_code + size;
+				jmp(dst, opts->cur_code);
+				dst = opts->cur_code;
+				dst_end = opts->code_end;
 			}
 			next = m68k_decode(encoded, &instbuf, address);
 			address += (next-encoded)*2;