- removed the last remnants of the ATAGs.

This commit is contained in:
Christoph Oelckers 2017-04-10 17:08:52 +02:00
parent 60dd58e7d2
commit 9ae97502be
3 changed files with 11 additions and 24 deletions

View File

@ -23,7 +23,6 @@ typedef unsigned short VM_UHALF;
typedef signed short VM_SHALF; typedef signed short VM_SHALF;
typedef unsigned int VM_UWORD; typedef unsigned int VM_UWORD;
typedef signed int VM_SWORD; typedef signed int VM_SWORD;
typedef VM_UBYTE VM_ATAG;
#define VM_EPSILON (1/65536.0) #define VM_EPSILON (1/65536.0)
@ -301,7 +300,6 @@ extern const VMOpInfo OpInfo[NUM_OPS];
struct VMReturn struct VMReturn
{ {
void *Location; void *Location;
VM_SHALF TagOfs; // for pointers: Offset from Location to ATag; set to 0 if the caller is native code and doesn't care
VM_UBYTE RegType; // Same as VMParam RegType, except REGT_KONST is invalid; only used by asserts VM_UBYTE RegType; // Same as VMParam RegType, except REGT_KONST is invalid; only used by asserts
void SetInt(int val) void SetInt(int val)
@ -361,25 +359,21 @@ struct VMReturn
void IntAt(int *loc) void IntAt(int *loc)
{ {
Location = loc; Location = loc;
TagOfs = 0;
RegType = REGT_INT; RegType = REGT_INT;
} }
void FloatAt(double *loc) void FloatAt(double *loc)
{ {
Location = loc; Location = loc;
TagOfs = 0;
RegType = REGT_FLOAT; RegType = REGT_FLOAT;
} }
void StringAt(FString *loc) void StringAt(FString *loc)
{ {
Location = loc; Location = loc;
TagOfs = 0;
RegType = REGT_STRING; RegType = REGT_STRING;
} }
void PointerAt(void **loc) void PointerAt(void **loc)
{ {
Location = loc; Location = loc;
TagOfs = 0;
RegType = REGT_POINTER; RegType = REGT_POINTER;
} }
VMReturn() { } VMReturn() { }
@ -397,7 +391,7 @@ struct VMValue
union union
{ {
int i; int i;
struct { void *a; int atag; }; void *a;
double f; double f;
struct { int pad[3]; VM_UBYTE Type; }; struct { int pad[3]; VM_UBYTE Type; };
struct { int foo[4]; } biggest; struct { int foo[4]; } biggest;
@ -575,7 +569,7 @@ struct VMFrame
int size = (sizeof(VMFrame) + 15) & ~15; int size = (sizeof(VMFrame) + 15) & ~15;
size += numparam * sizeof(VMValue); size += numparam * sizeof(VMValue);
size += numregf * sizeof(double); size += numregf * sizeof(double);
size += numrega * (sizeof(void *) + sizeof(VM_UBYTE)); size += numrega * sizeof(void *);
size += numregs * sizeof(FString); size += numregs * sizeof(FString);
size += numregd * sizeof(int); size += numregd * sizeof(int);
if (numextra != 0) if (numextra != 0)
@ -586,9 +580,10 @@ struct VMFrame
return size; return size;
} }
int *GetRegD() const VMValue *GetParam() const
{ {
return (int *)(GetRegA() + NumRegA); assert(((size_t)this & 15) == 0 && "VM frame is unaligned");
return (VMValue *)(((size_t)(this + 1) + 15) & ~15);
} }
double *GetRegF() const double *GetRegF() const
@ -606,22 +601,16 @@ struct VMFrame
return (void **)(GetRegS() + NumRegS); return (void **)(GetRegS() + NumRegS);
} }
VM_ATAG *GetRegATag() const int *GetRegD() const
{ {
return (VM_ATAG *)(GetRegD() + NumRegD); return (int *)(GetRegA() + NumRegA);
}
VMValue *GetParam() const
{
assert(((size_t)this & 15) == 0 && "VM frame is unaligned");
return (VMValue *)(((size_t)(this + 1) + 15) & ~15);
} }
void *GetExtra() const void *GetExtra() const
{ {
VM_ATAG *ptag = GetRegATag(); uint8_t *pbeg = (uint8_t*)(GetRegD() + NumRegD);
ptrdiff_t ofs = ptag - (VM_ATAG *)this; ptrdiff_t ofs = pbeg - (uint8_t *)this;
return (VM_UBYTE *)this + ((ofs + NumRegA + 15) & ~15); return (VM_UBYTE *)this + ((ofs + 15) & ~15);
} }
void GetAllRegs(int *&d, double *&f, FString *&s, void **&a, VMValue *&param) const void GetAllRegs(int *&d, double *&f, FString *&s, void **&a, VMValue *&param) const

View File

@ -1887,7 +1887,6 @@ static void FillReturns(const VMRegisters &reg, VMFrame *frame, VMReturn *return
for (i = 0, ret = returns; i < numret; ++i, ++ret, ++retval) for (i = 0, ret = returns; i < numret; ++i, ++ret, ++retval)
{ {
assert(retval->op == OP_RESULT); // opcode assert(retval->op == OP_RESULT); // opcode
ret->TagOfs = 0;
ret->RegType = type = retval->b; ret->RegType = type = retval->b;
regnum = retval->c; regnum = retval->c;
assert(!(type & REGT_KONST)); assert(!(type & REGT_KONST));
@ -1915,7 +1914,6 @@ static void FillReturns(const VMRegisters &reg, VMFrame *frame, VMReturn *return
assert(type == REGT_POINTER); assert(type == REGT_POINTER);
assert(regnum < frame->NumRegA); assert(regnum < frame->NumRegA);
ret->Location = &reg.a[regnum]; ret->Location = &reg.a[regnum];
ret->TagOfs = (VM_SHALF)(&frame->GetRegATag()[regnum] - (VM_ATAG *)ret->Location);
} }
} }
} }

View File

@ -97,7 +97,7 @@ void VMScriptFunction::Alloc(int numops, int numkonstd, int numkonstf, int numko
numkonstd * sizeof(int) + numkonstd * sizeof(int) +
numkonstf * sizeof(double) + numkonstf * sizeof(double) +
numkonsts * sizeof(FString) + numkonsts * sizeof(FString) +
numkonsta * (sizeof(FVoidObj) + 1) + numkonsta * sizeof(FVoidObj) +
numlinenumbers * sizeof(FStatementInfo)); numlinenumbers * sizeof(FStatementInfo));
Code = (VMOP *)mem; Code = (VMOP *)mem;
mem = (void *)((VMOP *)mem + numops); mem = (void *)((VMOP *)mem + numops);