From 669aef06ef7909460280fb2d3634372749fd0f40 Mon Sep 17 00:00:00 2001 From: Zeex Date: Sat, 11 Apr 2015 22:42:18 +0600 Subject: [PATCH] Remove remaining string expansion business from optimizer This makes optimization work again. Fixed #56 --- source/compiler/sc1.c | 3 --- source/compiler/sc7.c | 49 +------------------------------------------ 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 89931d4..c82c48d 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -478,8 +478,6 @@ int pc_compile(int argc, char *argv[]) litq=(cell*)malloc(litmax*sizeof(cell)); if (litq==NULL) error(103); /* insufficient memory */ - if (!phopt_init()) - error(103); /* insufficient memory */ setopt(argc,argv,outfname,errfname,incfname,reportname,codepage); strcpy(binfname,outfname); @@ -742,7 +740,6 @@ cleanup: } /* if */ if (litq!=NULL) free(litq); - phopt_cleanup(); stgbuffer_cleanup(); clearstk(); assert(jmpcode!=0 || loctab.next==NULL);/* on normal flow, local symbols diff --git a/source/compiler/sc7.c b/source/compiler/sc7.c index abe28d4..f68efe0 100644 --- a/source/compiler/sc7.c +++ b/source/compiler/sc7.c @@ -64,7 +64,7 @@ typedef struct { int savesize; /* number of bytes saved (in bytecode) */ } SEQUENCE; -static SEQUENCE sequences_cmp[] = { +static SEQUENCE sequences[] = { /* A very common sequence in four varieties * load.s.pri n1 load.s.pri n2 * push.pri load.s.alt n1 @@ -1568,53 +1568,6 @@ SC_FUNC void stgset(int onoff) stgbuf[0]='\0'; } -/* phopt_init - * Initialize all sequence strings of the peehole optimizer. The strings - * are embedded in the .EXE file in compressed format, here we expand - * them (and allocate memory for the sequences). - */ -static SEQUENCE *sequences; - -SC_FUNC int phopt_init(void) -{ - int number, i; - - /* count number of sequences */ - for (number=0; sequences_cmp[number].find!=NULL; number++) - /* nothing */; - number++; /* include an item for the NULL terminator */ - - if ((sequences=(SEQUENCE*)malloc(number * sizeof(SEQUENCE)))==NULL) - return FALSE; - - /* pre-initialize all to NULL (in case of failure) */ - for (i=0; i (PAWN_CELL_SIZE/4) * MAX_OPT_CAT