Skip to content

Commit

Permalink
refactor: remove redundant CFG2seh from backend
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 4, 2016
1 parent 4f32280 commit 06d4e07
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/backend/backconfig.c
Expand Up @@ -84,7 +84,6 @@ void out_config_init(
{
config.exe = EX_WIN32;
config.ehmethod = EH_WIN32;
config.flags2 |= CFG2seh; // Win32 eh
config.objfmt = mscoff ? OBJ_MSCOFF : OBJ_OMF;
}

Expand Down
1 change: 0 additions & 1 deletion src/backend/cdef.h
Expand Up @@ -754,7 +754,6 @@ struct Config
#define CFG2noobj 0x1000 // we are not generating a .OBJ file
#define CFG2noerrmax 0x4000 // no error count maximum
#define CFG2expand 0x8000 // expanded output to list file
#define CFG2seh 0x10000 // use Win32 SEH to support any exception handling
#define CFG2stomp 0x20000 // enable stack stomping code
#define CFG2gms 0x40000 // optimize debug symbols for microsoft debuggers
#define CFGX2 (CFG2warniserr | CFG2phuse | CFG2phgen | CFG2phauto | \
Expand Down
12 changes: 6 additions & 6 deletions src/backend/cgcod.c
Expand Up @@ -184,7 +184,7 @@ void codgen()
#else
if (CPP)
{
if (config.flags2 & CFG2seh &&
if (config.exe == EX_WIN32 &&
(funcsym_p->Stype->Tflags & TFemptyexc || funcsym_p->Stype->Texcspec))
usednteh |= NTEHexcspec;
except_reset();
Expand Down Expand Up @@ -438,7 +438,7 @@ void codgen()

#if SCPP
if (CPP &&
!(config.flags2 & CFG2seh))
!(config.exe == EX_WIN32))
{
//printf("b = %p, index = %d\n",b,b->Bindex);
//except_index_set(b->Bindex);
Expand Down Expand Up @@ -675,7 +675,7 @@ code *prolog()
/* The exception stack unwinding mechanism relies on the EBP chain being intact,
* so need frame if function can possibly throw
*/
!(config.flags2 & CFG2seh) && !(funcsym_p->Sfunc->Fflags3 & Fnothrow) ||
!(config.exe == EX_WIN32) && !(funcsym_p->Sfunc->Fflags3 & Fnothrow) ||
sv64
)
needframe = 1;
Expand Down Expand Up @@ -1499,7 +1499,7 @@ STATIC void cgcod_eh()
case ESCdtor:
//printf("ESCdtor\n");
except_pop(c,c->IEV1.Vtor,NULL);
L1: if (config.flags2 & CFG2seh)
L1: if (config.exe == EX_WIN32)
{
c1 = nteh_gensindex(except_index_get() - 1);
code_next(c1) = code_next(c);
Expand All @@ -1518,7 +1518,7 @@ STATIC void cgcod_eh()
list_pop(&stack);
if (idx != except_index_get())
{
if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
{ c1 = nteh_gensindex(idx - 1);
code_next(c1) = code_next(c);
code_next(c) = c1;
Expand Down Expand Up @@ -1586,7 +1586,7 @@ STATIC void cgcod_eh()
}
}

if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
for (b = startblock; b; b = b->Bnext)
{
if (/*!b->Bcount ||*/ b->BC == BCtry)
Expand Down
12 changes: 6 additions & 6 deletions src/backend/cod3.c
Expand Up @@ -813,7 +813,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym

case BCtry:
usednteh |= EHtry;
if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
usednteh |= NTEHtry;
goto case_goto;
#endif
Expand Down Expand Up @@ -841,7 +841,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
}
}
#endif
if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
c = cat(c,nteh_unwind(0,toindex));
#if MARS
else if (
Expand Down Expand Up @@ -906,7 +906,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
goto L2;

case BC_try:
if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
{ usednteh |= NTEH_try;
nteh_usevars();
}
Expand Down Expand Up @@ -1054,7 +1054,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
continue;
}
#endif
if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
{
if (bt->Bscope_index == 0)
{
Expand Down Expand Up @@ -2974,7 +2974,7 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
(*xlocalsize >= 0x1000 && config.exe & EX_flat) ||
localsize >= 0x10000 ||
#if NTEXCEPTIONS == 2
(usednteh & ~NTEHjmonitor && (config.flags2 & CFG2seh)) ||
(usednteh & ~NTEHjmonitor && (config.exe == EX_WIN32)) ||
#endif
(config.target_cpu >= TARGET_80386 &&
config.flags4 & CFG4speed)
Expand All @@ -2988,7 +2988,7 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
// Don't reorder instructions, as dwarf CFA relies on it
code_orflag(c, CFvolatile);
#if NTEXCEPTIONS == 2
if (usednteh & ~NTEHjmonitor && (config.flags2 & CFG2seh))
if (usednteh & ~NTEHjmonitor && (config.exe == EX_WIN32))
{
code *ce = nteh_prolog();
c = cat(c,ce);
Expand Down
10 changes: 5 additions & 5 deletions src/backend/nteh.c
Expand Up @@ -59,7 +59,7 @@ int nteh_offset_info() { return 4; }

unsigned char *nteh_context_string()
{
if (config.flags2 & CFG2seh)
if (config.exe == EX_WIN32)
return (unsigned char *)text_nt;
else
return NULL;
Expand Down Expand Up @@ -408,7 +408,7 @@ code *nteh_prolog()

code *nteh_epilog()
{
if (!(config.flags2 & CFG2seh))
if (config.exe != EX_WIN32)
return NULL;

/* Generate:
Expand Down Expand Up @@ -542,7 +542,7 @@ code *nteh_patchindex(code* c, int sindex)
code *nteh_gensindex(int sindex)
{ code *c;

if (!(config.flags2 & CFG2seh))
if (config.exe != EX_WIN32)
return NULL;

// Generate:
Expand Down Expand Up @@ -813,7 +813,7 @@ code *nteh_monitor_prolog(Symbol *shandle)
Symbol *s;
regm_t desregs;

assert(config.flags2 & CFG2seh); // BUG: figure out how to implement for other EX's
assert(config.exe == EX_WIN32); // BUG: figure out how to implement for other EX's

if (shandle->Sclass == SCfastpar)
{ assert(shandle->Spreg != DX);
Expand Down Expand Up @@ -897,7 +897,7 @@ code *nteh_monitor_epilog(regm_t retregs)
regm_t desregs;
Symbol *s;

assert(config.flags2 & CFG2seh); // BUG: figure out how to implement for other EX's
assert(config.exe == EX_WIN32); // BUG: figure out how to implement for other EX's

s = getRtlsym(RTLSYM_MONITOR_EPILOG);
//desregs = ~s->Sregsaved & ALLREGS;
Expand Down
4 changes: 2 additions & 2 deletions src/eh.c
Expand Up @@ -251,7 +251,7 @@ void except_fillInEHTable(symbol *s)
if (c->Iop == (ESCAPE | ESCdctor))
{
code *c2 = code_next(c);
if (config.flags2 & CFG2seh)
if (config.ehmethod == EH_WIN32)
nteh_patchindex(c2, scopeindex);
if (config.ehmethod == EH_DM)
pdt = dtdword(pdt,boffset - startblock->Boffset); // guard offset
Expand All @@ -273,7 +273,7 @@ void except_fillInEHTable(symbol *s)
{
foffset = eoffset;
code *cf = code_next(c2);
if (config.flags2 & CFG2seh)
if (config.ehmethod == EH_WIN32)
{
nteh_patchindex(cf, stack[stacki - 1]);
foffset += calccodsize(cf);
Expand Down

0 comments on commit 06d4e07

Please sign in to comment.