aboutsummaryrefslogtreecommitdiff
path: root/backendC/CleanCompilerSources
diff options
context:
space:
mode:
authorjohnvg2016-04-07 13:19:59 +0000
committerjohnvg2016-04-07 13:19:59 +0000
commite20c4eddd468430ab4865bfd18908324d4c4128d (patch)
tree1696351af5f035490958ebc093923509d27231bb /backendC/CleanCompilerSources
parentremove an unnecessary record copy in the abc code for some record updates (diff)
remove some unnecessary copying on the stack for root record updates
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@2685 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'backendC/CleanCompilerSources')
-rw-r--r--backendC/CleanCompilerSources/codegen3.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/backendC/CleanCompilerSources/codegen3.c b/backendC/CleanCompilerSources/codegen3.c
index 4391c29..5f33ea4 100644
--- a/backendC/CleanCompilerSources/codegen3.c
+++ b/backendC/CleanCompilerSources/codegen3.c
@@ -1323,9 +1323,7 @@ static void CodeRootUpdateNode (Node root,NodeId rootid,int asp,int bsp,CodeGenN
RemoveSelectorsFromUpdateNode (record_arg,first_field_arg);
-#if 1
BuildArgs (record_arg->arg_next,&asp,&bsp,code_gen_node_ids_p);
-#endif
if (IsSimpleState (root->node_state) && record_arg->arg_node->node_kind==NodeIdNode){
NodeIdP record_node_id;
@@ -1388,16 +1386,11 @@ static void CodeRootUpdateNode (Node root,NodeId rootid,int asp,int bsp,CodeGenN
record_state_p=&root->node_symbol->symb_def->sdef_record_state;
record_arg->arg_state=*record_state_p;
-#if 1
+
BuildArg (record_arg,&asp,&bsp,code_gen_node_ids_p);
-#else
- BuildArgs (record_arg,&asp,&bsp,code_gen_node_ids_p);
-#endif
+
DetermineSizeOfArguments (record_arg,&a_size,&b_size);
- UpdateAAndBStack (asp,bsp,a_size,b_size,&asp,&bsp);
- /* BuildNewStackFrame (record_arg,asp,bsp,False,code_gen_node_ids_p); */
-
if (IsSimpleState (root->node_state)){
LabDef record_label;
int end_args_a_offset,end_args_b_offset;
@@ -1406,10 +1399,8 @@ static void CodeRootUpdateNode (Node root,NodeId rootid,int asp,int bsp,CodeGenN
UpdateRecordAndAddSelectorsToUpdateNode (record_arg,first_field_arg,
record_state_p->state_record_arguments,record_a_size,record_b_size,&end_args_a_offset,&end_args_b_offset);
- RemoveFieldsFromStackAfterUpdate (end_args_a_offset,end_args_b_offset,record_a_size,record_b_size,&asp,&bsp);
ConvertSymbolToRLabel (&record_label,record_sdef);
-
GenFillR (&record_label,record_a_size,record_b_size,asp,0,0,ReleaseAndFill,False);
GenPopA (asp);
@@ -1422,10 +1413,25 @@ static void CodeRootUpdateNode (Node root,NodeId rootid,int asp,int bsp,CodeGenN
UpdateRecordAndAddSelectorsToUpdateNode (record_arg,first_field_arg,
result_state.state_record_arguments,record_a_size,record_b_size,&end_args_a_offset,&end_args_b_offset);
- RemoveFieldsFromStackAfterUpdate (end_args_a_offset,end_args_b_offset,record_a_size,record_b_size,&asp,&bsp);
- if (!function_called_only_curried_or_lazy_with_one_return)
+ if (!function_called_only_curried_or_lazy_with_one_return){
+ UpdateAAndBStack (asp,bsp,record_a_size,record_b_size,&asp,&bsp);
GenRtn (record_a_size,record_b_size,result_state);
+ } else {
+ if (CurrentSymbol->symb_def->sdef_mark & SDEF_USED_LAZILY_MASK){
+ BuildRecord (record_state_p->state_record_symbol,asp,bsp,asp,bsp,record_a_size,record_b_size,
+ 0,ReleaseAndFill,False);
+ GenPopA (asp);
+ } else {
+ BuildRecord (record_state_p->state_record_symbol,asp,bsp,asp,bsp,record_a_size,record_b_size,
+ asp,NormalFill,True);
+ GenUpdatePopA (0,asp);
+ }
+ GenPopB (bsp);
+ GenRtn (1,0,OnAState);
+
+ function_called_only_curried_or_lazy_with_one_return = 0;
+ }
}
}