mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-07 08:21:04 +00:00
- removed ATAGs from the function builder.
This commit is contained in:
parent
e551ef52f8
commit
5464336035
5 changed files with 12 additions and 35 deletions
|
@ -126,7 +126,7 @@ void VMFunctionBuilder::MakeFunction(VMScriptFunction *func)
|
||||||
}
|
}
|
||||||
if (AddressConstantList.Size() > 0)
|
if (AddressConstantList.Size() > 0)
|
||||||
{
|
{
|
||||||
FillAddressConstants(func->KonstA, func->KonstATags());
|
FillAddressConstants(func->KonstA);
|
||||||
}
|
}
|
||||||
if (StringConstantList.Size() > 0)
|
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(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
|
else
|
||||||
{
|
{
|
||||||
int loc = StringConstantList.Push(val);
|
unsigned loc = StringConstantList.Push(val);
|
||||||
StringConstantMap.Insert(val, loc);
|
StringConstantMap.Insert(val, loc);
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
@ -275,20 +274,16 @@ unsigned VMFunctionBuilder::GetConstantString(FString val)
|
||||||
|
|
||||||
unsigned VMFunctionBuilder::GetConstantAddress(void *ptr)
|
unsigned VMFunctionBuilder::GetConstantAddress(void *ptr)
|
||||||
{
|
{
|
||||||
AddrKonst *locp = AddressConstantMap.CheckKey(ptr);
|
unsigned *locp = AddressConstantMap.CheckKey(ptr);
|
||||||
if (locp != NULL)
|
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;
|
||||||
return locp->KonstNum;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned locc = AddressConstantList.Push(ptr);
|
unsigned loc = AddressConstantList.Push(ptr);
|
||||||
AtagConstantList.Push(0);
|
|
||||||
|
|
||||||
AddrKonst loc = { locc, 0 };
|
|
||||||
AddressConstantMap.Insert(ptr, loc);
|
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 VMFunctionBuilder::AllocConstantsAddress(unsigned count, void **ptrs)
|
||||||
{
|
{
|
||||||
unsigned addr = AddressConstantList.Reserve(count);
|
unsigned addr = AddressConstantList.Reserve(count);
|
||||||
AtagConstantList.Reserve(count);
|
|
||||||
memcpy(&AddressConstantList[addr], ptrs, count * sizeof(void *));
|
memcpy(&AddressConstantList[addr], ptrs, count * sizeof(void *));
|
||||||
for (unsigned i = 0; i < count; i++)
|
for (unsigned i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
AtagConstantList[addr + i] = 0;
|
AddressConstantMap.Insert(ptrs[i], addr+i);
|
||||||
AddrKonst loc = { addr+i, 0 };
|
|
||||||
AddressConstantMap.Insert(ptrs[i], loc);
|
|
||||||
}
|
}
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
// Write out complete constant tables.
|
// Write out complete constant tables.
|
||||||
void FillIntConstants(int *konst);
|
void FillIntConstants(int *konst);
|
||||||
void FillFloatConstants(double *konst);
|
void FillFloatConstants(double *konst);
|
||||||
void FillAddressConstants(FVoidObj *konst, VM_ATAG *tags);
|
void FillAddressConstants(FVoidObj *konst);
|
||||||
void FillStringConstants(FString *strings);
|
void FillStringConstants(FString *strings);
|
||||||
|
|
||||||
// PARAM increases ActiveParam; CALL decreases it.
|
// PARAM increases ActiveParam; CALL decreases it.
|
||||||
|
@ -96,24 +96,17 @@ public:
|
||||||
TArray<FxLocalVariableDeclaration *> ConstructedStructs;
|
TArray<FxLocalVariableDeclaration *> ConstructedStructs;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct AddrKonst
|
|
||||||
{
|
|
||||||
unsigned KonstNum;
|
|
||||||
VM_ATAG Tag;
|
|
||||||
};
|
|
||||||
|
|
||||||
TArray<FStatementInfo> LineNumbers;
|
TArray<FStatementInfo> LineNumbers;
|
||||||
TArray<FxExpression *> StatementStack;
|
TArray<FxExpression *> StatementStack;
|
||||||
|
|
||||||
TArray<int> IntConstantList;
|
TArray<int> IntConstantList;
|
||||||
TArray<double> FloatConstantList;
|
TArray<double> FloatConstantList;
|
||||||
TArray<void *> AddressConstantList;
|
TArray<void *> AddressConstantList;
|
||||||
TArray<VM_ATAG> AtagConstantList;
|
|
||||||
TArray<FString> StringConstantList;
|
TArray<FString> StringConstantList;
|
||||||
// These map from the constant value to its position in the constant table.
|
// These map from the constant value to its position in the constant table.
|
||||||
TMap<int, unsigned> IntConstantMap;
|
TMap<int, unsigned> IntConstantMap;
|
||||||
TMap<double, unsigned> FloatConstantMap;
|
TMap<double, unsigned> FloatConstantMap;
|
||||||
TMap<void *, AddrKonst> AddressConstantMap;
|
TMap<void *, unsigned> AddressConstantMap;
|
||||||
TMap<FString, unsigned> StringConstantMap;
|
TMap<FString, unsigned> StringConstantMap;
|
||||||
|
|
||||||
int MaxParam;
|
int MaxParam;
|
||||||
|
|
|
@ -243,7 +243,7 @@ void VMDumpConstants(FILE *out, const VMScriptFunction *func)
|
||||||
{
|
{
|
||||||
for (j = 0, k = i; j < 4 && k < func->NumKonstA; j++, k += kk)
|
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, "%-22s", tmp);
|
||||||
}
|
}
|
||||||
printf_wrapper(out, "\n");
|
printf_wrapper(out, "\n");
|
||||||
|
|
|
@ -692,9 +692,6 @@ public:
|
||||||
~VMScriptFunction();
|
~VMScriptFunction();
|
||||||
void Alloc(int numops, int numkonstd, int numkonstf, int numkonsts, int numkonsta, int numlinenumbers);
|
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;
|
VMOP *Code;
|
||||||
FStatementInfo *LineInfo;
|
FStatementInfo *LineInfo;
|
||||||
FString SourceFileName;
|
FString SourceFileName;
|
||||||
|
|
|
@ -20,7 +20,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
||||||
const double *konstf;
|
const double *konstf;
|
||||||
const FString *konsts;
|
const FString *konsts;
|
||||||
const FVoidObj *konsta;
|
const FVoidObj *konsta;
|
||||||
const VM_ATAG *konstatag;
|
|
||||||
|
|
||||||
if (f->Func != NULL && !(f->Func->VarFlags & VARF_Native))
|
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;
|
konstf = sfunc->KonstF;
|
||||||
konsts = sfunc->KonstS;
|
konsts = sfunc->KonstS;
|
||||||
konsta = sfunc->KonstA;
|
konsta = sfunc->KonstA;
|
||||||
konstatag = sfunc->KonstATags();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -38,7 +36,6 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
|
||||||
konstf = NULL;
|
konstf = NULL;
|
||||||
konsts = NULL;
|
konsts = NULL;
|
||||||
konsta = NULL;
|
konsta = NULL;
|
||||||
konstatag = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
@ -81,7 +78,6 @@ begin:
|
||||||
OP(LKP):
|
OP(LKP):
|
||||||
ASSERTA(a); ASSERTKA(BC);
|
ASSERTA(a); ASSERTKA(BC);
|
||||||
reg.a[a] = konsta[BC].v;
|
reg.a[a] = konsta[BC].v;
|
||||||
reg.atag[a] = konstatag[BC];
|
|
||||||
NEXTOP;
|
NEXTOP;
|
||||||
|
|
||||||
OP(LK_R) :
|
OP(LK_R) :
|
||||||
|
@ -100,7 +96,6 @@ begin:
|
||||||
ASSERTA(a); ASSERTD(B);
|
ASSERTA(a); ASSERTD(B);
|
||||||
b = reg.d[B] + C;
|
b = reg.d[B] + C;
|
||||||
reg.a[a] = konsta[b].v;
|
reg.a[a] = konsta[b].v;
|
||||||
reg.atag[a] = konstatag[b];
|
|
||||||
NEXTOP;
|
NEXTOP;
|
||||||
|
|
||||||
OP(LFP):
|
OP(LFP):
|
||||||
|
@ -603,7 +598,7 @@ begin:
|
||||||
break;
|
break;
|
||||||
case REGT_POINTER | REGT_KONST:
|
case REGT_POINTER | REGT_KONST:
|
||||||
assert(C < sfunc->NumKonstA);
|
assert(C < sfunc->NumKonstA);
|
||||||
::new(param) VMValue(konsta[C].v, konstatag[C]);
|
::new(param) VMValue(konsta[C].v, ATAG_GENERIC);
|
||||||
break;
|
break;
|
||||||
case REGT_FLOAT:
|
case REGT_FLOAT:
|
||||||
assert(C < f->NumRegF);
|
assert(C < f->NumRegF);
|
||||||
|
|
Loading…
Reference in a new issue