Remove remaining string expansion business from optimizer
This makes optimization work again. Fixed #56
This commit is contained in:
parent
1d7a961dc6
commit
669aef06ef
@ -478,8 +478,6 @@ int pc_compile(int argc, char *argv[])
|
|||||||
litq=(cell*)malloc(litmax*sizeof(cell));
|
litq=(cell*)malloc(litmax*sizeof(cell));
|
||||||
if (litq==NULL)
|
if (litq==NULL)
|
||||||
error(103); /* insufficient memory */
|
error(103); /* insufficient memory */
|
||||||
if (!phopt_init())
|
|
||||||
error(103); /* insufficient memory */
|
|
||||||
|
|
||||||
setopt(argc,argv,outfname,errfname,incfname,reportname,codepage);
|
setopt(argc,argv,outfname,errfname,incfname,reportname,codepage);
|
||||||
strcpy(binfname,outfname);
|
strcpy(binfname,outfname);
|
||||||
@ -742,7 +740,6 @@ cleanup:
|
|||||||
} /* if */
|
} /* if */
|
||||||
if (litq!=NULL)
|
if (litq!=NULL)
|
||||||
free(litq);
|
free(litq);
|
||||||
phopt_cleanup();
|
|
||||||
stgbuffer_cleanup();
|
stgbuffer_cleanup();
|
||||||
clearstk();
|
clearstk();
|
||||||
assert(jmpcode!=0 || loctab.next==NULL);/* on normal flow, local symbols
|
assert(jmpcode!=0 || loctab.next==NULL);/* on normal flow, local symbols
|
||||||
|
@ -64,7 +64,7 @@ typedef struct {
|
|||||||
int savesize; /* number of bytes saved (in bytecode) */
|
int savesize; /* number of bytes saved (in bytecode) */
|
||||||
} SEQUENCE;
|
} SEQUENCE;
|
||||||
|
|
||||||
static SEQUENCE sequences_cmp[] = {
|
static SEQUENCE sequences[] = {
|
||||||
/* A very common sequence in four varieties
|
/* A very common sequence in four varieties
|
||||||
* load.s.pri n1 load.s.pri n2
|
* load.s.pri n1 load.s.pri n2
|
||||||
* push.pri load.s.alt n1
|
* push.pri load.s.alt n1
|
||||||
@ -1568,53 +1568,6 @@ SC_FUNC void stgset(int onoff)
|
|||||||
stgbuf[0]='\0';
|
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<number; i++) {
|
|
||||||
sequences[i].find=NULL;
|
|
||||||
sequences[i].replace=NULL;
|
|
||||||
sequences[i].savesize=0;
|
|
||||||
} /* for */
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SC_FUNC int phopt_cleanup(void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (sequences!=NULL) {
|
|
||||||
i=0;
|
|
||||||
while (sequences[i].find!=NULL || sequences[i].replace!=NULL) {
|
|
||||||
if (sequences[i].find!=NULL)
|
|
||||||
free(sequences[i].find);
|
|
||||||
if (sequences[i].replace!=NULL)
|
|
||||||
free(sequences[i].replace);
|
|
||||||
i++;
|
|
||||||
} /* while */
|
|
||||||
free(sequences);
|
|
||||||
sequences=NULL;
|
|
||||||
} /* if */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MAX_OPT_VARS 5
|
#define MAX_OPT_VARS 5
|
||||||
#define MAX_OPT_CAT 5 /* max. values that are concatenated */
|
#define MAX_OPT_CAT 5 /* max. values that are concatenated */
|
||||||
#if sNAMEMAX > (PAWN_CELL_SIZE/4) * MAX_OPT_CAT
|
#if sNAMEMAX > (PAWN_CELL_SIZE/4) * MAX_OPT_CAT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user