mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 17:19:32 +02:00
* refactored the handling of the frame pointer and base pointer to use local temps instead
git-svn-id: branches/wasm@46837 -
This commit is contained in:
parent
921ec47bc0
commit
4a5e2dbd23
@ -1626,12 +1626,12 @@ implementation
|
||||
procedure thlcgwasm.g_proc_entry(list: TAsmList; localsize: longint; nostackframe: boolean);
|
||||
var
|
||||
functype: tai_functype;
|
||||
pd: tprocdef;
|
||||
pd: tcpuprocdef;
|
||||
i: integer;
|
||||
prm: tcpuparavarsym;
|
||||
bt: TWasmBasicType;
|
||||
begin
|
||||
pd:=current_procinfo.procdef;
|
||||
pd:=tcpuprocdef(current_procinfo.procdef);
|
||||
functype:=tai_functype.create(pd.mangledname);
|
||||
if Assigned(pd.paras) and (pd.paras.Count>0) then
|
||||
begin
|
||||
@ -1670,6 +1670,9 @@ implementation
|
||||
end;
|
||||
list.Concat(functype);
|
||||
|
||||
tg.gethltemp(list,voidpointertype,voidpointertype.size,tt_persistent,pd.frame_pointer_ref);
|
||||
tg.gethltemp(list,voidpointertype,voidpointertype.size,tt_persistent,pd.base_pointer_ref);
|
||||
|
||||
{ the localsize is based on tg.lasttemp -> already in terms of stack
|
||||
slots rather than bytes }
|
||||
//list.concat(tai_directive.Create(asd_jlimit,'locals '+tostr(localsize)));
|
||||
@ -1677,28 +1680,31 @@ implementation
|
||||
and it uses one stack slot }
|
||||
//if (current_procinfo.procdef.proctypeoption=potype_proginit) then
|
||||
//fmaxevalstackheight:=max(1,fmaxevalstackheight);
|
||||
list.Concat(tai_local.create(wbt_i32, FRAME_POINTER_SYM)); //TWasmBasicType
|
||||
list.Concat(tai_local.create(wbt_i32, BASE_POINTER_SYM)); //TWasmBasicType
|
||||
list.Concat(tai_local.create(wbt_i32,FRAME_POINTER_SYM)); //TWasmBasicType
|
||||
list.Concat(tai_local.create(wbt_i32,BASE_POINTER_SYM)); //TWasmBasicType
|
||||
|
||||
list.Concat(taicpu.op_sym(a_get_global , current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_sym(a_set_local, current_asmdata.RefAsmSymbol(BASE_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_sym(a_get_global,current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_ref(a_set_local,pd.base_pointer_ref));
|
||||
|
||||
if (localsize>0) then begin
|
||||
list.Concat(taicpu.op_sym(a_get_local, current_asmdata.RefAsmSymbol(BASE_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_ref(a_get_local,pd.base_pointer_ref));
|
||||
list.concat(taicpu.op_const(a_i32_const, localsize ));
|
||||
list.concat(taicpu.op_none(a_i32_sub));
|
||||
list.Concat(taicpu.op_sym(a_set_local, current_asmdata.RefAsmSymbol(FRAME_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_sym(a_get_local, current_asmdata.RefAsmSymbol(FRAME_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_sym(a_set_global, current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_ref(a_set_local,pd.frame_pointer_ref));
|
||||
list.Concat(taicpu.op_ref(a_get_local,pd.frame_pointer_ref));
|
||||
list.Concat(taicpu.op_sym(a_set_global,current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
|
||||
end;
|
||||
|
||||
//list.concat(tai_directive.Create(asd_jlimit,'stack '+tostr(fmaxevalstackheight)));
|
||||
end;
|
||||
|
||||
procedure thlcgwasm.g_proc_exit(list: TAsmList; parasize: longint; nostackframe: boolean);
|
||||
var
|
||||
pd: tcpuprocdef;
|
||||
begin
|
||||
list.Concat(taicpu.op_sym(a_get_local, current_asmdata.RefAsmSymbol(BASE_POINTER_SYM,AT_LABEL)));
|
||||
list.Concat(taicpu.op_sym(a_set_global , current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
|
||||
pd:=tcpuprocdef(current_procinfo.procdef);
|
||||
list.Concat(taicpu.op_ref(a_get_local,pd.base_pointer_ref));
|
||||
list.Concat(taicpu.op_sym(a_set_global,current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
|
||||
|
||||
list.concat(taicpu.op_none(a_return));
|
||||
end;
|
||||
|
@ -29,7 +29,8 @@ uses
|
||||
globtype,
|
||||
aasmdata,
|
||||
symtype,
|
||||
symdef,symsym;
|
||||
symdef,symsym,
|
||||
cgutils;
|
||||
|
||||
type
|
||||
{ defs }
|
||||
@ -98,6 +99,8 @@ type
|
||||
{ tcpuprocdef }
|
||||
|
||||
tcpuprocdef = class(tprocdef)
|
||||
frame_pointer_ref,
|
||||
base_pointer_ref: treference;
|
||||
{ generated assembler code; used by WebAssembly backend so it can afterwards
|
||||
easily write out all methods grouped per class }
|
||||
exprasmlist : TAsmList;
|
||||
|
Loading…
Reference in New Issue
Block a user