From 7d15b688e8ec64f5925b2f41f534fd0130996340 Mon Sep 17 00:00:00 2001 From: nickysn Date: Fri, 7 Oct 2016 20:18:02 +0000 Subject: [PATCH] * TInterfaceEntry changed to a variant record, that overlays a CodePointer on top of the IOffset: SizeUInt field, because it is sometimes used as a CodePointer (for etStaticMethodResult and etStaticMethodClass) and sometimes as a SizeInt and these two types can be of different size in certain i8086 memory models git-svn-id: trunk@34645 - --- compiler/ncgvmt.pas | 15 ++++++++++++--- rtl/inc/objpas.inc | 4 ++-- rtl/inc/objpash.inc | 12 +++++++++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/compiler/ncgvmt.pas b/compiler/ncgvmt.pas index 7aee00db1e..bdcc1cb74a 100644 --- a/compiler/ncgvmt.pas +++ b/compiler/ncgvmt.pas @@ -747,6 +747,7 @@ implementation begin tcb.maybe_begin_aggregate(interfaceentrydef); { GUID (or nil for Corba interfaces) } + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('IIDREF') as tfieldvarsym; siid:=''; if AImplIntf.IntfDef.objecttype in [odt_interfacecom] then begin @@ -758,29 +759,36 @@ implementation tcb.emit_tai(Tai_const.Create_nil_dataptr,cpointerdef.getreusable(rec_tguid)); { VTable } + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('VTABLE') as tfieldvarsym; tcb.queue_init(voidpointertype); tcb.queue_emit_asmsym(fintfvtablelabels[intfindex],AImplIntf.VtblImplIntf.IntfDef); { IOffset field } case AImplIntf.VtblImplIntf.IType of etFieldValue, etFieldValueClass, etStandard: - tcb.emit_tai(Tai_const.Create_pint(AImplIntf.VtblImplIntf.IOffset),ptruinttype); + begin + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('IOFFSET') as tfieldvarsym; + tcb.emit_tai(Tai_const.Create_sizeint(AImplIntf.VtblImplIntf.IOffset),sizeuinttype); + end; etStaticMethodResult, etStaticMethodClass: begin + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('IOFFSETASCODEPTR') as tfieldvarsym; pd:=tprocdef(tpropertysym(AImplIntf.ImplementsGetter).propaccesslist[palt_read].procdef); - tcb.queue_init(ptruinttype); + tcb.queue_init(codeptruinttype); tcb.queue_emit_proc(pd); end; etVirtualMethodResult, etVirtualMethodClass: begin + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('IOFFSET') as tfieldvarsym; pd:=tprocdef(tpropertysym(AImplIntf.ImplementsGetter).propaccesslist[palt_read].procdef); - tcb.emit_tai(Tai_const.Create_pint(tobjectdef(pd.struct).vmtmethodoffset(pd.extnumber)),ptruinttype); + tcb.emit_tai(Tai_const.Create_sizeint(tobjectdef(pd.struct).vmtmethodoffset(pd.extnumber)),sizeuinttype); end; else internalerror(200802162); end; { IIDStr } + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('IIDSTRREF') as tfieldvarsym; siidstr:=make_mangledname('IIDSTR',AImplIntf.IntfDef.owner,AImplIntf.IntfDef.objname^); tcb.queue_init(cpointerdef.getreusable(cshortstringtype)); tcb.queue_emit_asmsym( @@ -790,6 +798,7 @@ implementation true), cpointerdef.getreusable(carraydef.getreusable(cansichartype,length(AImplIntf.IntfDef.iidstr^)+1))); { IType } + tcb.next_field:=tabstractrecorddef(interfaceentrydef).symtable.Find('ITYPE') as tfieldvarsym; tcb.emit_ord_const(aint(AImplIntf.VtblImplIntf.IType),interfaceentrytypedef); tcb.maybe_end_aggregate(interfaceentrydef); diff --git a/rtl/inc/objpas.inc b/rtl/inc/objpas.inc index 9651f81753..07eeaab663 100644 --- a/rtl/inc/objpas.inc +++ b/rtl/inc/objpas.inc @@ -779,12 +779,12 @@ end; etStaticMethodResult: begin - Getter.code := CodePointer(IEntry^.IOffset); + Getter.code := IEntry^.IOffsetAsCodePtr; TInterfaceGetter(Getter)(obj); end; etStaticMethodClass: begin - Getter.code := CodePointer(IEntry^.IOffset); + Getter.code := IEntry^.IOffsetAsCodePtr; TObject(obj) := TClassGetter(Getter)(); end; end; diff --git a/rtl/inc/objpash.inc b/rtl/inc/objpash.inc index e198f2187d..dad397f9ec 100644 --- a/rtl/inc/objpash.inc +++ b/rtl/inc/objpash.inc @@ -176,9 +176,15 @@ public IIDRef : {$IFNDEF VER3_0}^{$ENDIF}pguid; { if assigned(IID) then Com else Corba} VTable : Pointer; - IOffset : sizeuint; - IIDStrRef : {$IFNDEF VER3_0}^{$ENDIF}pshortstring; { never nil. Com: upper(GuidToString(IID^)) } - IType : tinterfaceentrytype; + case integer of + 1 : ( + IOffset: sizeuint; + ); + 2 : ( + IOffsetAsCodePtr: CodePointer; + IIDStrRef : {$IFNDEF VER3_0}^{$ENDIF}pshortstring; { never nil. Com: upper(GuidToString(IID^)) } + IType : tinterfaceentrytype; + ); end; tinterfacetable = record