From aba6923187e117f90435e0a22536e47c258e8268 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 11 Jul 2012 08:25:51 +0000 Subject: [PATCH] * moved g_test_self() from cgobj to hlcgobj git-svn-id: trunk@21861 - --- compiler/cgobj.pas | 22 ---------------------- compiler/hlcg2ll.pas | 1 - compiler/hlcgobj.pas | 22 +++++++++++++++++++++- compiler/ncginl.pas | 2 +- compiler/ncgutil.pas | 5 ++++- rtl/inc/compproc.inc | 2 +- rtl/inc/system.inc | 4 ++-- rtl/java/jcompproc.inc | 2 +- rtl/java/jsystem.inc | 4 ++-- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/compiler/cgobj.pas b/compiler/cgobj.pas index ec1cc20bde..73cbd8e39d 100644 --- a/compiler/cgobj.pas +++ b/compiler/cgobj.pas @@ -368,7 +368,6 @@ unit cgobj; } procedure g_exception_reason_load(list : TAsmList; const href : treference);virtual; - procedure g_maybe_testself(list : TAsmList;reg:tregister); procedure g_maybe_testvmt(list : TAsmList;reg:tregister;objdef:tobjectdef); {# This should emit the opcode to copy len bytes from the source to destination. @@ -2070,27 +2069,6 @@ implementation {$endif cpuflags} - procedure tcg.g_maybe_testself(list : TAsmList;reg:tregister); - var - OKLabel : tasmlabel; - cgpara1 : TCGPara; - begin - if (cs_check_object in current_settings.localswitches) or - (cs_check_range in current_settings.localswitches) then - begin - current_asmdata.getjumplabel(oklabel); - a_cmp_const_reg_label(list,OS_ADDR,OC_NE,0,reg,oklabel); - cgpara1.init; - paramanager.getintparaloc(pocall_default,1,s32inttype,cgpara1); - a_load_const_cgpara(list,OS_S32,tcgint(210),cgpara1); - paramanager.freecgpara(list,cgpara1); - a_call_name(list,'FPC_HANDLEERROR',false); - a_label(list,oklabel); - cgpara1.done; - end; - end; - - procedure tcg.g_maybe_testvmt(list : TAsmList;reg:tregister;objdef:tobjectdef); var hrefvmt : treference; diff --git a/compiler/hlcg2ll.pas b/compiler/hlcg2ll.pas index 1376cbbdb2..c28e6928ff 100644 --- a/compiler/hlcg2ll.pas +++ b/compiler/hlcg2ll.pas @@ -256,7 +256,6 @@ unit hlcg2ll; procedure g_flags2ref(list: TAsmList; size: tdef; const f: tresflags; const ref:TReference); override; {$endif cpuflags} -// procedure g_maybe_testself(list : TAsmList;reg:tregister); // procedure g_maybe_testvmt(list : TAsmList;reg:tregister;objdef:tobjectdef); {# This should emit the opcode to copy len bytes from the source to destination. diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas index 9cb1f8fbff..e04f785f08 100644 --- a/compiler/hlcgobj.pas +++ b/compiler/hlcgobj.pas @@ -366,7 +366,7 @@ unit hlcgobj; procedure g_flags2ref(list: TAsmList; size: tdef; const f: tresflags; const ref:TReference); virtual; abstract; {$endif cpuflags} -// procedure g_maybe_testself(list : TAsmList;reg:tregister); + procedure g_maybe_testself(list : TAsmList; selftype: tdef; reg:tregister); // procedure g_maybe_testvmt(list : TAsmList;reg:tregister;objdef:tobjectdef); {# This should emit the opcode to copy len bytes from the source to destination. @@ -2756,6 +2756,26 @@ implementation end; end; + procedure thlcgobj.g_maybe_testself(list: TAsmList; selftype: tdef; reg: tregister); + var + OKLabel : tasmlabel; + cgpara1 : TCGPara; + begin + if (cs_check_object in current_settings.localswitches) or + (cs_check_range in current_settings.localswitches) then + begin + current_asmdata.getjumplabel(oklabel); + a_cmp_const_reg_label(list,selftype,OC_NE,0,reg,oklabel); + cgpara1.init; + paramanager.getintparaloc(pocall_default,1,s32inttype,cgpara1); + a_load_const_cgpara(list,s32inttype,aint(210),cgpara1); + paramanager.freecgpara(list,cgpara1); + g_call_system_proc(list,'fpc_handleerror'); + cgpara1.done; + a_label(list,oklabel); + end; + end; + procedure thlcgobj.g_concatcopy(list: TAsmList; size: tdef; const source, dest: treference); begin { diff --git a/compiler/ncginl.pas b/compiler/ncginl.pas index 98265cf399..79879ea299 100644 --- a/compiler/ncginl.pas +++ b/compiler/ncginl.pas @@ -304,7 +304,7 @@ implementation begin { deref class } cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,hregister); - cg.g_maybe_testself(current_asmdata.CurrAsmList,hregister); + hlcg.g_maybe_testself(current_asmdata.CurrAsmList,left.resultdef,hregister); { load VMT pointer } reference_reset_base(hrefvmt,hregister,tobjectdef(left.resultdef).vmt_offset,sizeof(pint)); cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,hrefvmt,hregister); diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index 7f30449866..86d26ccdf1 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -1895,6 +1895,7 @@ implementation procedure gen_load_vmt_register(list:TAsmList;objdef:tobjectdef;selfloc:tlocation;var vmtreg:tregister); var href : treference; + selfdef: tdef; begin if is_object(objdef) then begin @@ -1904,6 +1905,7 @@ implementation begin reference_reset_base(href,cg.getaddressregister(list),objdef.vmt_offset,sizeof(pint)); cg.a_loadaddr_ref_reg(list,selfloc.reference,href.base); + selfdef:=getpointerdef(objdef); end; else internalerror(200305056); @@ -1914,6 +1916,7 @@ implementation and the first "field" of an Objective-C class instance is a pointer to its "meta-class". } begin + selfdef:=objdef; case selfloc.loc of LOC_REGISTER: begin @@ -1941,7 +1944,7 @@ implementation end; end; vmtreg:=cg.getaddressregister(list); - cg.g_maybe_testself(list,href.base); + hlcg.g_maybe_testself(list,selfdef,href.base); cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,vmtreg); { test validity of VMT } diff --git a/rtl/inc/compproc.inc b/rtl/inc/compproc.inc index 8024c715d3..c5913783fc 100644 --- a/rtl/inc/compproc.inc +++ b/rtl/inc/compproc.inc @@ -626,8 +626,8 @@ procedure fpc_InitializeUnits; compilerproc; Procedure fpc_do_exit; compilerproc; Procedure fpc_lib_exit; compilerproc; Procedure fpc_HandleErrorAddrFrame (Errno : longint;addr,frame : pointer); compilerproc; -Procedure fpc_HandleError (Errno : longint); compilerproc; } +Procedure fpc_HandleError (Errno : longint); compilerproc; procedure fpc_AbstractErrorIntern;compilerproc; procedure fpc_assert(Const Msg,FName:Shortstring;LineNo:Longint;ErrorAddr:Pointer); compilerproc; diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc index 47d5d97e95..a246dc413a 100644 --- a/rtl/inc/system.inc +++ b/rtl/inc/system.inc @@ -76,7 +76,7 @@ Const {$endif FPC_OBJFPC_EXTENDED_IF} {$endif FPC_HAS_FEATURE_EXITCODE} -Procedure HandleError (Errno : Longint); forward; +Procedure HandleError (Errno : Longint); external name 'FPC_HANDLEERROR'; Procedure HandleErrorFrame (Errno : longint;frame : Pointer); forward; Procedure HandleErrorAddrFrame (Errno : longint;addr,frame : Pointer); forward; @@ -1046,7 +1046,7 @@ begin end; -Procedure HandleError (Errno : longint);[public,alias : 'FPC_HANDLEERROR']; +procedure fpc_handleerror (Errno : longint); compilerproc; [public,alias : 'FPC_HANDLEERROR']; { Procedure to handle internal errors, i.e. not user-invoked errors Internal function should ALWAYS call HandleError instead of RunError. diff --git a/rtl/java/jcompproc.inc b/rtl/java/jcompproc.inc index 68a9d8bb46..4736e0b223 100644 --- a/rtl/java/jcompproc.inc +++ b/rtl/java/jcompproc.inc @@ -635,8 +635,8 @@ procedure fpc_InitializeUnits; compilerproc; Procedure fpc_do_exit; compilerproc; Procedure fpc_lib_exit; compilerproc; Procedure fpc_HandleErrorAddrFrame (Errno : longint;addr,frame : pointer); compilerproc; -Procedure fpc_HandleError (Errno : longint); compilerproc; } +Procedure fpc_HandleError (Errno : longint); compilerproc; procedure fpc_AbstractErrorIntern;compilerproc; *) diff --git a/rtl/java/jsystem.inc b/rtl/java/jsystem.inc index 97ca5e2361..76f912c085 100644 --- a/rtl/java/jsystem.inc +++ b/rtl/java/jsystem.inc @@ -78,7 +78,7 @@ Const {$endif FPC_OBJFPC_EXTENDED_IF} {$endif FPC_HAS_FEATURE_EXITCODE} -Procedure HandleError (Errno : Longint); forward; +Procedure HandleError (Errno : Longint); external name 'FPC_HANDLEERROR'; Procedure HandleErrorFrame (Errno : longint;frame : Pointer); forward; {$ifdef FPC_HAS_FEATURE_TEXTIO} @@ -1046,7 +1046,7 @@ begin end; -Procedure HandleError (Errno : longint);[public,alias : 'FPC_HANDLEERROR']; +Procedure fpc_handleerror (Errno : longint); compilerproc; [public,alias : 'FPC_HANDLEERROR']; { Procedure to handle internal errors, i.e. not user-invoked errors Internal function should ALWAYS call HandleError instead of RunError.