From 60dd58e7d2874b78303cb328d334afda14c5be5a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 10 Apr 2017 16:06:18 +0200 Subject: [PATCH] - most ATAG stuff is gone, except for the static storage space in the VMFunction. --- src/info.cpp | 2 +- src/p_actionfunctions.cpp | 2 +- src/scripting/vm/vm.h | 30 +++++------------------------- src/scripting/vm/vmexec.cpp | 3 +-- src/scripting/vm/vmexec.h | 30 ++++++------------------------ 5 files changed, 14 insertions(+), 53 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index fdda8633e2..e895253b5c 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -76,7 +76,7 @@ bool FState::CallAction(AActor *self, AActor *stateowner, FStateParamInfo *info, { ActionCycles.Clock(); - VMValue params[3] = { self, stateowner, VMValue(info, ATAG_GENERIC) }; + VMValue params[3] = { self, stateowner, VMValue(info) }; // If the function returns a state, store it at *stateret. // If it doesn't return a state but stateret is non-NULL, we need // to set *stateret to NULL. diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 1b2c0b3db9..97be1b1082 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -153,7 +153,7 @@ bool AStateProvider::CallStateChain (AActor *actor, FState *state) VMReturn *wantret; FStateParamInfo stp = { state, STATE_StateChain, PSP_WEAPON }; - params[2] = VMValue(&stp, ATAG_GENERIC); + params[2] = VMValue(&stp); retval = true; // assume success wantret = NULL; // assume no return value wanted numret = 0; diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 6d7ec6b1d2..66e0f2931f 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -176,13 +176,6 @@ enum #define RET_FINAL (0x80) // Used with RET and RETI in the destination slot: this is the final return value -// Tags for address registers -enum -{ - ATAG_GENERIC, // pointer to something; we don't care what - ATAG_OBJECT, // pointer to an object; will be followed by GC -}; - enum EVMAbortException { X_OTHER, @@ -445,19 +438,11 @@ struct VMValue VMValue(DObject *v) { a = v; - atag = ATAG_OBJECT; Type = REGT_POINTER; } VMValue(void *v) { a = v; - atag = ATAG_GENERIC; - Type = REGT_POINTER; - } - VMValue(void *v, int tag) - { - a = v; - atag = tag; Type = REGT_POINTER; } VMValue &operator=(const VMValue &o) @@ -488,7 +473,6 @@ struct VMValue VMValue &operator=(DObject *v) { a = v; - atag = ATAG_OBJECT; Type = REGT_POINTER; return *this; } @@ -640,7 +624,7 @@ struct VMFrame return (VM_UBYTE *)this + ((ofs + NumRegA + 15) & ~15); } - void GetAllRegs(int *&d, double *&f, FString *&s, void **&a, VM_ATAG *&atag, VMValue *¶m) const + void GetAllRegs(int *&d, double *&f, FString *&s, void **&a, VMValue *¶m) const { // Calling the individual functions produces suboptimal code. :( param = GetParam(); @@ -648,7 +632,6 @@ struct VMFrame s = (FString *)(f + NumRegF); a = (void **)(s + NumRegS); d = (int *)(a + NumRegA); - atag = (VM_ATAG *)(d + NumRegD); } void InitRegS(); @@ -658,18 +641,17 @@ struct VMRegisters { VMRegisters(const VMFrame *frame) { - frame->GetAllRegs(d, f, s, a, atag, param); + frame->GetAllRegs(d, f, s, a, param); } VMRegisters(const VMRegisters &o) - : d(o.d), f(o.f), s(o.s), a(o.a), atag(o.atag), param(o.param) + : d(o.d), f(o.f), s(o.s), a(o.a), param(o.param) { } int *d; double *f; FString *s; void **a; - VM_ATAG *atag; VMValue *param; }; @@ -796,14 +778,12 @@ public: void ParamObject(DObject *obj) { Reg.a[RegA] = obj; - Reg.atag[RegA] = ATAG_OBJECT; RegA++; } - void ParamPointer(void *ptr, VM_ATAG atag) + void ParamPointer(void *ptr) { Reg.a[RegA] = ptr; - Reg.atag[RegA] = atag; RegA++; } @@ -1052,7 +1032,7 @@ class AActor; PARAM_PROLOGUE; \ PARAM_OBJECT(self, type); -// for structs we need to check for ATAG_GENERIC instead of ATAG_OBJECT +// for structs we cannot do a class validation #define PARAM_SELF_STRUCT_PROLOGUE(type) \ PARAM_PROLOGUE; \ PARAM_POINTER(self, type); diff --git a/src/scripting/vm/vmexec.cpp b/src/scripting/vm/vmexec.cpp index 8d6c188f0a..1e3afd709e 100644 --- a/src/scripting/vm/vmexec.cpp +++ b/src/scripting/vm/vmexec.cpp @@ -227,8 +227,7 @@ void VMFillParams(VMValue *params, VMFrame *callee, int numparam) else { assert(p.Type == REGT_POINTER); - calleereg.a[rega] = p.a; - calleereg.atag[rega++] = p.atag; + calleereg.a[rega++] = p.a; } } } diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index f4297b9346..5e6647474d 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -101,19 +101,16 @@ begin: OP(LFP): ASSERTA(a); assert(sfunc != NULL); assert(sfunc->ExtraSpace > 0); reg.a[a] = f->GetExtra(); - reg.atag[a] = ATAG_GENERIC; // using ATAG_FRAMEPOINTER will cause endless asserts. NEXTOP; OP(CLSS): ASSERTA(a); ASSERTA(B); reg.a[a] = ((DObject*)reg.a[B])->GetClass(); // I wish this could be done without a special opcode but there's really no good way to guarantee initialization of the Class pointer... - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(META): ASSERTA(a); ASSERTA(B); reg.a[a] = ((DObject*)reg.a[B])->GetClass()->Meta; // I wish this could be done without a special opcode but there's really no good way to guarantee initialization of the Class pointer... - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(LB): @@ -212,37 +209,31 @@ begin: ASSERTA(a); ASSERTA(B); ASSERTKD(C); GETADDR(PB,KC,X_READ_NIL); reg.a[a] = GC::ReadBarrier(*(DObject **)ptr); - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(LO_R): ASSERTA(a); ASSERTA(B); ASSERTD(C); GETADDR(PB,RC,X_READ_NIL); reg.a[a] = GC::ReadBarrier(*(DObject **)ptr); - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(LOS): ASSERTA(a); ASSERTA(B); ASSERTKD(C); GETADDR(PB,KC,X_READ_NIL); reg.a[a] = *(DObject **)ptr; - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(LOS_R): ASSERTA(a); ASSERTA(B); ASSERTD(C); GETADDR(PB,RC,X_READ_NIL); reg.a[a] = *(DObject **)ptr; - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(LP): ASSERTA(a); ASSERTA(B); ASSERTKD(C); GETADDR(PB,KC,X_READ_NIL); reg.a[a] = *(void **)ptr; - reg.atag[a] = ATAG_GENERIC; NEXTOP; OP(LP_R): ASSERTA(a); ASSERTA(B); ASSERTD(C); GETADDR(PB,RC,X_READ_NIL); reg.a[a] = *(void **)ptr; - reg.atag[a] = ATAG_GENERIC; NEXTOP; OP(LV2): ASSERTF(a+1); ASSERTA(B); ASSERTKD(C); @@ -437,7 +428,6 @@ begin: ASSERTA(a); ASSERTA(B); b = B; reg.a[a] = reg.a[b]; - reg.atag[a] = reg.atag[b]; NEXTOP; } OP(MOVEV2): @@ -461,25 +451,21 @@ begin: ASSERTA(a); ASSERTA(B); ASSERTA(C); b = B; reg.a[a] = (reg.a[b] && ((DObject*)(reg.a[b]))->IsKindOf((PClass*)(reg.a[C]))) ? reg.a[b] : nullptr; - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(DYNCAST_K) : ASSERTA(a); ASSERTA(B); ASSERTKA(C); b = B; reg.a[a] = (reg.a[b] && ((DObject*)(reg.a[b]))->IsKindOf((PClass*)(konsta[C].o))) ? reg.a[b] : nullptr; - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(DYNCASTC_R) : ASSERTA(a); ASSERTA(B); ASSERTA(C); b = B; reg.a[a] = (reg.a[b] && ((PClass*)(reg.a[b]))->IsDescendantOf((PClass*)(reg.a[C]))) ? reg.a[b] : nullptr; - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(DYNCASTC_K) : ASSERTA(a); ASSERTA(B); ASSERTKA(C); b = B; reg.a[a] = (reg.a[b] && ((PClass*)(reg.a[b]))->IsDescendantOf((PClass*)(konsta[C].o))) ? reg.a[b] : nullptr; - reg.atag[a] = ATAG_OBJECT; NEXTOP; OP(CAST): if (C == CAST_I2F) @@ -570,7 +556,7 @@ begin: break; case REGT_INT | REGT_ADDROF: assert(C < f->NumRegD); - ::new(param) VMValue(®.d[C], ATAG_GENERIC); + ::new(param) VMValue(®.d[C]); break; case REGT_INT | REGT_KONST: assert(C < sfunc->NumKonstD); @@ -582,7 +568,7 @@ begin: break; case REGT_STRING | REGT_ADDROF: assert(C < f->NumRegS); - ::new(param) VMValue(®.s[C], ATAG_GENERIC); + ::new(param) VMValue((void*)®.s[C]); // Note that this may not use the FString* version of the constructor! break; case REGT_STRING | REGT_KONST: assert(C < sfunc->NumKonstS); @@ -590,15 +576,15 @@ begin: break; case REGT_POINTER: assert(C < f->NumRegA); - ::new(param) VMValue(reg.a[C], reg.atag[C]); + ::new(param) VMValue(reg.a[C]); break; case REGT_POINTER | REGT_ADDROF: assert(C < f->NumRegA); - ::new(param) VMValue(®.a[C], ATAG_GENERIC); + ::new(param) VMValue(®.a[C]); break; case REGT_POINTER | REGT_KONST: assert(C < sfunc->NumKonstA); - ::new(param) VMValue(konsta[C].v, ATAG_GENERIC); + ::new(param) VMValue(konsta[C].v); break; case REGT_FLOAT: assert(C < f->NumRegF); @@ -621,7 +607,7 @@ begin: break; case REGT_FLOAT | REGT_ADDROF: assert(C < f->NumRegF); - ::new(param) VMValue(®.f[C], ATAG_GENERIC); + ::new(param) VMValue(®.f[C]); break; case REGT_FLOAT | REGT_KONST: assert(C < sfunc->NumKonstF); @@ -818,7 +804,6 @@ begin: c = C; if (c) FScopeBarrier::ValidateNew(cls, c - 1); reg.a[a] = cls->CreateNew(); - reg.atag[a] = ATAG_OBJECT; NEXTOP; } @@ -1651,7 +1636,6 @@ begin: c = 0; } reg.a[a] = (VM_UBYTE *)reg.a[B] + c; - reg.atag[a] = c == 0 ? reg.atag[B] : (int)ATAG_GENERIC; NEXTOP; OP(ADDA_RK): ASSERTA(a); ASSERTA(B); ASSERTKD(C); @@ -1710,7 +1694,6 @@ begin: // Found a handler. Store the exception in pC, skip the JMP, // and begin executing its code. reg.a[pc->c] = exception; - reg.atag[pc->c] = ATAG_OBJECT; pc += 2; goto begin; } @@ -1723,7 +1706,6 @@ begin: // Catch any type of VMException. This terminates the chain. ASSERTA(pc->c); reg.a[pc->c] = exception; - reg.atag[pc->c] = ATAG_OBJECT; pc += 1; goto begin; }