From 84b5129f1dc443351e7b914686bf70e9b81b99f6 Mon Sep 17 00:00:00 2001 From: yury Date: Tue, 16 Oct 2018 17:24:07 +0000 Subject: [PATCH] * Fixed writing of method's RTTI for aarch64 by explicitly writing the $self parameter first. git-svn-id: trunk@39947 - --- compiler/ncgrtti.pas | 49 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/compiler/ncgrtti.pas b/compiler/ncgrtti.pas index de5ab94cc3..040fe42080 100644 --- a/compiler/ncgrtti.pas +++ b/compiler/ncgrtti.pas @@ -176,6 +176,26 @@ implementation ***************************************************************************} procedure TRTTIWriter.write_methods(tcb:ttai_typedconstbuilder;st:tsymtable;visibilities:tvisibilities); + + procedure _write_para(para : tparavarsym); + begin + tcb.begin_anonymous_record('',defaultpacking,min(reqalign,SizeOf(PInt)), + targetinfos[target_info.system]^.alignment.recordalignmin, + targetinfos[target_info.system]^.alignment.maxCrecordalign); + + if is_open_array(para.vardef) or is_array_of_const(para.vardef) then + write_rtti_reference(tcb,tarraydef(para.vardef).elementdef,fullrtti) + else + write_rtti_reference(tcb,para.vardef,fullrtti); + write_param_flag(tcb,para); + + tcb.emit_pooled_shortstring_const_ref(para.realname); + + write_paralocs(tcb,@para.paraloc[callerside]); + + tcb.end_anonymous_record; + end; + var rtticount, totalcount, @@ -231,25 +251,24 @@ implementation tcb.emit_ord_const(def.callerargareasize,ptrsinttype); tcb.emit_pooled_shortstring_const_ref(sym.realname); + { Always write $self first. It is needed to find it, since at least for aarch64 + $self is placed after $result in the list. } for k:=0 to def.paras.count-1 do begin para:=tparavarsym(def.paras[k]); + if vo_is_self in para.varoptions then + begin + _write_para(para); + break; + end; + end; - tcb.begin_anonymous_record('',defaultpacking,min(reqalign,SizeOf(PInt)), - targetinfos[target_info.system]^.alignment.recordalignmin, - targetinfos[target_info.system]^.alignment.maxCrecordalign); - - if is_open_array(para.vardef) or is_array_of_const(para.vardef) then - write_rtti_reference(tcb,tarraydef(para.vardef).elementdef,fullrtti) - else - write_rtti_reference(tcb,para.vardef,fullrtti); - write_param_flag(tcb,para); - - tcb.emit_pooled_shortstring_const_ref(para.realname); - - write_paralocs(tcb,@para.paraloc[callerside]); - - tcb.end_anonymous_record; + { Write all other parameters } + for k:=0 to def.paras.count-1 do + begin + para:=tparavarsym(def.paras[k]); + if not (vo_is_self in para.varoptions) then + _write_para(para); end; if not is_void(def.returndef) then