From 54643360353e211b60b368abbdb9643f05bf2f39 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 10 Apr 2017 15:48:27 +0200 Subject: [PATCH] - removed ATAGs from the function builder. --- src/scripting/backend/vmbuilder.cpp | 24 ++++++++---------------- src/scripting/backend/vmbuilder.h | 11 ++--------- src/scripting/backend/vmdisasm.cpp | 2 +- src/scripting/vm/vm.h | 3 --- src/scripting/vm/vmexec.h | 7 +------ 5 files changed, 12 insertions(+), 35 deletions(-) diff --git a/src/scripting/backend/vmbuilder.cpp b/src/scripting/backend/vmbuilder.cpp index 01f1e4050b..d8af3204d4 100644 --- a/src/scripting/backend/vmbuilder.cpp +++ b/src/scripting/backend/vmbuilder.cpp @@ -126,7 +126,7 @@ void VMFunctionBuilder::MakeFunction(VMScriptFunction *func) } if (AddressConstantList.Size() > 0) { - FillAddressConstants(func->KonstA, func->KonstATags()); + FillAddressConstants(func->KonstA); } if (StringConstantList.Size() > 0) { @@ -175,10 +175,9 @@ void VMFunctionBuilder::FillFloatConstants(double *konst) // //========================================================================== -void VMFunctionBuilder::FillAddressConstants(FVoidObj *konst, VM_ATAG *tags) +void VMFunctionBuilder::FillAddressConstants(FVoidObj *konst) { memcpy(konst, &AddressConstantList[0], sizeof(void*) * AddressConstantList.Size()); - memcpy(tags, &AtagConstantList[0], sizeof(VM_ATAG) * AtagConstantList.Size()); } //========================================================================== @@ -258,7 +257,7 @@ unsigned VMFunctionBuilder::GetConstantString(FString val) } else { - int loc = StringConstantList.Push(val); + unsigned loc = StringConstantList.Push(val); StringConstantMap.Insert(val, loc); return loc; } @@ -275,20 +274,16 @@ unsigned VMFunctionBuilder::GetConstantString(FString val) unsigned VMFunctionBuilder::GetConstantAddress(void *ptr) { - AddrKonst *locp = AddressConstantMap.CheckKey(ptr); + unsigned *locp = AddressConstantMap.CheckKey(ptr); if (locp != NULL) { - // There should only be one tag associated with a memory location. Exceptions are made for null pointers that got allocated through constant arrays. - return locp->KonstNum; + return *locp; } else { - unsigned locc = AddressConstantList.Push(ptr); - AtagConstantList.Push(0); - - AddrKonst loc = { locc, 0 }; + unsigned loc = AddressConstantList.Push(ptr); AddressConstantMap.Insert(ptr, loc); - return loc.KonstNum; + return loc; } } @@ -325,13 +320,10 @@ unsigned VMFunctionBuilder::AllocConstantsFloat(unsigned count, double *values) unsigned VMFunctionBuilder::AllocConstantsAddress(unsigned count, void **ptrs) { unsigned addr = AddressConstantList.Reserve(count); - AtagConstantList.Reserve(count); memcpy(&AddressConstantList[addr], ptrs, count * sizeof(void *)); for (unsigned i = 0; i < count; i++) { - AtagConstantList[addr + i] = 0; - AddrKonst loc = { addr+i, 0 }; - AddressConstantMap.Insert(ptrs[i], loc); + AddressConstantMap.Insert(ptrs[i], addr+i); } return addr; } diff --git a/src/scripting/backend/vmbuilder.h b/src/scripting/backend/vmbuilder.h index 97412cbd15..ea5213b66c 100644 --- a/src/scripting/backend/vmbuilder.h +++ b/src/scripting/backend/vmbuilder.h @@ -79,7 +79,7 @@ public: // Write out complete constant tables. void FillIntConstants(int *konst); void FillFloatConstants(double *konst); - void FillAddressConstants(FVoidObj *konst, VM_ATAG *tags); + void FillAddressConstants(FVoidObj *konst); void FillStringConstants(FString *strings); // PARAM increases ActiveParam; CALL decreases it. @@ -96,24 +96,17 @@ public: TArray ConstructedStructs; private: - struct AddrKonst - { - unsigned KonstNum; - VM_ATAG Tag; - }; - TArray LineNumbers; TArray StatementStack; TArray IntConstantList; TArray FloatConstantList; TArray AddressConstantList; - TArray AtagConstantList; TArray StringConstantList; // These map from the constant value to its position in the constant table. TMap IntConstantMap; TMap FloatConstantMap; - TMap AddressConstantMap; + TMap AddressConstantMap; TMap StringConstantMap; int MaxParam; diff --git a/src/scripting/backend/vmdisasm.cpp b/src/scripting/backend/vmdisasm.cpp index 276533e2d1..f0d687b675 100644 --- a/src/scripting/backend/vmdisasm.cpp +++ b/src/scripting/backend/vmdisasm.cpp @@ -243,7 +243,7 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func) { for (j = 0, k = i; j < 4 && k < func->NumKonstA; j++, k += kk) { - mysnprintf(tmp, countof(tmp), "%3d. %p:%d", k, func->KonstA[k].v, func->KonstATags()[k]); + mysnprintf(tmp, countof(tmp), "%3d. %p", k, func->KonstA[k].v); printf_wrapper(out, "%-22s", tmp); } printf_wrapper(out, "\n"); diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index c055fb00c4..6d7ec6b1d2 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -692,9 +692,6 @@ public: ~VMScriptFunction(); void Alloc(int numops, int numkonstd, int numkonstf, int numkonsts, int numkonsta, int numlinenumbers); - VM_ATAG *KonstATags() { return (VM_UBYTE *)(KonstA + NumKonstA); } - const VM_ATAG *KonstATags() const { return (VM_UBYTE *)(KonstA + NumKonstA); } - VMOP *Code; FStatementInfo *LineInfo; FString SourceFileName; diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index 3107ac7bfc..f4297b9346 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -20,7 +20,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret) const double *konstf; const FString *konsts; const FVoidObj *konsta; - const VM_ATAG *konstatag; if (f->Func != NULL && !(f->Func->VarFlags & VARF_Native)) { @@ -29,7 +28,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret) konstf = sfunc->KonstF; konsts = sfunc->KonstS; konsta = sfunc->KonstA; - konstatag = sfunc->KonstATags(); } else { @@ -38,7 +36,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret) konstf = NULL; konsts = NULL; konsta = NULL; - konstatag = NULL; } void *ptr; @@ -81,7 +78,6 @@ begin: OP(LKP): ASSERTA(a); ASSERTKA(BC); reg.a[a] = konsta[BC].v; - reg.atag[a] = konstatag[BC]; NEXTOP; OP(LK_R) : @@ -100,7 +96,6 @@ begin: ASSERTA(a); ASSERTD(B); b = reg.d[B] + C; reg.a[a] = konsta[b].v; - reg.atag[a] = konstatag[b]; NEXTOP; OP(LFP): @@ -603,7 +598,7 @@ begin: break; case REGT_POINTER | REGT_KONST: assert(C < sfunc->NumKonstA); - ::new(param) VMValue(konsta[C].v, konstatag[C]); + ::new(param) VMValue(konsta[C].v, ATAG_GENERIC); break; case REGT_FLOAT: assert(C < f->NumRegF);