diff options
author | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-27 23:11:09 +0000 |
---|---|---|
committer | nickysn <nickysn@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-04-27 23:11:09 +0000 |
commit | a491c935588745154b576226b73833bac78fcb6e (patch) | |
tree | 973289073fb5d21573a6be2b5cfeba9abd2a9472 /compiler/wasm32 | |
parent | 38b5e0606069cc5985e995e1da5b6855db67f507 (diff) | |
parent | ae5b0de491a91321675f73eae5db628d068f4e05 (diff) | |
download | fpc-a491c935588745154b576226b73833bac78fcb6e.tar.gz |
* synchronized with trunkunicodekvm
git-svn-id: https://svn.freepascal.org/svn/fpc/branches/unicodekvm@49282 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/wasm32')
-rw-r--r-- | compiler/wasm32/agllvmmc.pas | 62 | ||||
-rw-r--r-- | compiler/wasm32/agwat.pas | 7 | ||||
-rw-r--r-- | compiler/wasm32/nwasmflw.pas | 72 |
3 files changed, 110 insertions, 31 deletions
diff --git a/compiler/wasm32/agllvmmc.pas b/compiler/wasm32/agllvmmc.pas index 4468a56f27..de9e0a8b99 100644 --- a/compiler/wasm32/agllvmmc.pas +++ b/compiler/wasm32/agllvmmc.pas @@ -70,31 +70,36 @@ implementation procedure TLLVMMachineCodePlaygroundAssembler.WriteImports; var i : integer; + def : tdef; proc : tprocdef; list : TAsmList; cur_unit: tused_unit; begin for i:=0 to current_module.deflist.Count-1 do - if assigned(current_module.deflist[i]) and (tdef(current_module.deflist[i]).typ=procdef) then - begin - proc := tprocdef(current_module.deflist[i]); - if (po_external in proc.procoptions) and assigned(proc.import_dll) then - begin - //WriteProcDef(proc); - list:=TAsmList.Create; - thlcgwasm(hlcg).g_procdef(list,proc); - WriteTree(list); - list.free; - writer.AsmWrite(#9'.import_module'#9); - writer.AsmWrite(proc.mangledname); - writer.AsmWrite(', '); - writer.AsmWriteLn(proc.import_dll^); - writer.AsmWrite(#9'.import_name'#9); - writer.AsmWrite(proc.mangledname); - writer.AsmWrite(', '); - writer.AsmWriteLn(proc.import_name^); - end; - end; + begin + def:=tdef(current_module.deflist[i]); + { since commit 48986 deflist might have NIL entries } + if assigned(def) and (def.typ=procdef) then + begin + proc := tprocdef(def); + if (po_external in proc.procoptions) and assigned(proc.import_dll) then + begin + //WriteProcDef(proc); + list:=TAsmList.Create; + thlcgwasm(hlcg).g_procdef(list,proc); + WriteTree(list); + list.free; + writer.AsmWrite(#9'.import_module'#9); + writer.AsmWrite(proc.mangledname); + writer.AsmWrite(', '); + writer.AsmWriteLn(proc.import_dll^); + writer.AsmWrite(#9'.import_name'#9); + writer.AsmWrite(proc.mangledname); + writer.AsmWrite(', '); + writer.AsmWriteLn(proc.import_name^); + end; + end; + end; list:=TAsmList.Create; cur_unit:=tused_unit(usedunits.First); while assigned(cur_unit) do @@ -107,13 +112,16 @@ implementation list.Concat(tai_functype.create(make_mangledname('FINALIZE$',cur_unit.u.globalsymtable,''),TWasmFuncType.Create([],[]))); end; for i:=0 to cur_unit.u.deflist.Count-1 do - if assigned(cur_unit.u.deflist[i]) and (tdef(cur_unit.u.deflist[i]).typ = procdef) then - begin - proc := tprocdef(cur_unit.u.deflist[i]); - if (not proc.owner.iscurrentunit or (po_external in proc.procoptions)) and - ((proc.paras.Count=0) or (proc.has_paraloc_info in [callerside,callbothsides])) then - thlcgwasm(hlcg).g_procdef(list,proc); - end; + begin + def:=tdef(cur_unit.u.deflist[i]); + if assigned(def) and (tdef(def).typ = procdef) then + begin + proc := tprocdef(def); + if (not proc.owner.iscurrentunit or (po_external in proc.procoptions)) and + ((proc.paras.Count=0) or (proc.has_paraloc_info in [callerside,callbothsides])) then + thlcgwasm(hlcg).g_procdef(list,proc); + end; + end; cur_unit:=tused_unit(cur_unit.Next); end; WriteTree(list); diff --git a/compiler/wasm32/agwat.pas b/compiler/wasm32/agwat.pas index 7d40c64936..13684044dd 100644 --- a/compiler/wasm32/agwat.pas +++ b/compiler/wasm32/agwat.pas @@ -957,14 +957,17 @@ implementation procedure TWabtTextAssembler.WriteImports; var i : integer; + def : tdef; proc : tprocdef; sym : tsym; j : integer; psym : tprocsym; begin for i:=0 to current_module.deflist.Count-1 do begin - if tdef(current_module.deflist[i]).typ = procdef then begin - proc := tprocdef(current_module.deflist[i]); + def:=tdef(current_module.deflist[i]); + { since commit 48986 deflist might have NIL entries } + if assigned(def) and (def.typ=procdef) then begin + proc := tprocdef(def); if (po_external in proc.procoptions) and assigned(proc.import_dll) then begin writer.AsmWrite(#9'(import "'); writer.AsmWrite(proc.import_dll^); diff --git a/compiler/wasm32/nwasmflw.pas b/compiler/wasm32/nwasmflw.pas index aa82e0e700..84a230dc1b 100644 --- a/compiler/wasm32/nwasmflw.pas +++ b/compiler/wasm32/nwasmflw.pas @@ -49,6 +49,13 @@ interface procedure pass_generate_code;override; end; + { twasmraisenode } + + twasmraisenode = class(tcgraisenode) + public + function pass_1 : tnode;override; + end; + { twasmtryexceptnode } twasmtryexceptnode = class(tcgtryexceptnode) @@ -68,9 +75,9 @@ implementation uses verbose,globals,systems,globtype,constexp, symconst,symdef,symsym,aasmtai,aasmdata,aasmcpu,defutil,defcmp, - procinfo,cgbase,pass_1,pass_2,parabase, + procinfo,cgbase,pass_1,pass_2,parabase,compinnr, cpubase,cpuinfo, - nbas,nld,ncon,ncnv, + nbas,nld,ncon,ncnv,ncal,ninl,nmem,nadd, tgobj,paramgr, cgutils,hlcgobj,hlcgcpu; @@ -204,6 +211,66 @@ implementation end; {***************************************************************************** + twasmraisenode +*****************************************************************************} + + function twasmraisenode.pass_1 : tnode; + var + statements : tstatementnode; + //current_addr : tlabelnode; + raisenode : tcallnode; + begin + result:=internalstatements(statements); + + if assigned(left) then + begin + { first para must be a class } + firstpass(left); + { insert needed typeconvs for addr,frame } + if assigned(right) then + begin + { addr } + firstpass(right); + { frame } + if assigned(third) then + firstpass(third) + else + third:=cpointerconstnode.Create(0,voidpointertype); + end + else + begin + third:=cinlinenode.create(in_get_frame,false,nil); + //current_addr:=clabelnode.create(cnothingnode.create,clabelsym.create('$raiseaddr')); + //addstatement(statements,current_addr); + //right:=caddrnode.create(cloadnode.create(current_addr.labsym,current_addr.labsym.owner)); + right:=cnilnode.create; + + { raise address off by one so we are for sure inside the action area for the raise } + if tf_use_psabieh in target_info.flags then + right:=caddnode.create_internal(addn,right,cordconstnode.create(1,sizesinttype,false)); + end; + + raisenode:=ccallnode.createintern('fpc_raiseexception', + ccallparanode.create(third, + ccallparanode.create(right, + ccallparanode.create(left,nil))) + ); + include(raisenode.callnodeflags,cnf_call_never_returns); + addstatement(statements,raisenode); + end + else + begin + addstatement(statements,ccallnode.createintern('fpc_popaddrstack',nil)); + raisenode:=ccallnode.createintern('fpc_reraise',nil); + include(raisenode.callnodeflags,cnf_call_never_returns); + addstatement(statements,raisenode); + end; + left:=nil; + right:=nil; + third:=nil; + end; + +{***************************************************************************** twasmtryexceptnode *****************************************************************************} @@ -258,6 +325,7 @@ implementation initialization cifnode:=twasmifnode; cwhilerepeatnode:=twasmwhilerepeatnode; + craisenode:=twasmraisenode; ctryexceptnode:=twasmtryexceptnode; ctryfinallynode:=twasmtryfinallynode; end. |