Commit c5e0c628 authored by John van Groningen's avatar John van Groningen

remove some unnecessary update_a and pop_a instructions when creating an ARRAY node

parent 90bc14c1
...@@ -930,16 +930,17 @@ static void CodeRule (ImpRuleP rule) ...@@ -930,16 +930,17 @@ static void CodeRule (ImpRuleP rule)
case TupleState: case TupleState:
BuildTuple (asize, bsize, asize, bsize, function_state_p[-1].state_arity, BuildTuple (asize, bsize, asize, bsize, function_state_p[-1].state_arity,
function_state_p[-1].state_tuple_arguments,asize,bsize, asize,NormalFill,True); function_state_p[-1].state_tuple_arguments,asize,bsize, asize,NormalFill,True);
GenUpdatePopA (0, asize);
break; break;
case RecordState: case RecordState:
BuildRecord (function_state_p[-1].state_record_symbol,asize, bsize, asize, bsize, BuildRecord (function_state_p[-1].state_record_symbol,asize, bsize, asize, bsize,
asize, bsize, asize, NormalFill,True); asize, bsize, asize, NormalFill,True);
GenUpdatePopA (0, asize);
break; break;
case ArrayState: case ArrayState:
GenBuildArray (0); GenBuildArrayPop();
break; break;
} }
GenUpdatePopA (0, asize);
} }
GenPopB (bsize); GenPopB (bsize);
......
...@@ -1878,21 +1878,17 @@ void ApplyEntry (StateS *const function_state_p,int arity,Label ea_lab,int ea_la ...@@ -1878,21 +1878,17 @@ void ApplyEntry (StateS *const function_state_p,int arity,Label ea_lab,int ea_la
case TupleState: case TupleState:
BuildTuple (asize, bsize, asize, bsize, function_state_p[-1].state_arity, BuildTuple (asize, bsize, asize, bsize, function_state_p[-1].state_arity,
function_state_p[-1].state_tuple_arguments,asize,bsize, asize,NormalFill,True); function_state_p[-1].state_tuple_arguments,asize,bsize, asize,NormalFill,True);
GenUpdatePopA (0, asize);
break; break;
case RecordState: case RecordState:
BuildRecord (function_state_p[-1].state_record_symbol,asize, bsize, asize, bsize, BuildRecord (function_state_p[-1].state_record_symbol,asize, bsize, asize, bsize,
asize, bsize, asize, NormalFill,True); asize, bsize, asize, NormalFill,True);
GenUpdatePopA (0, asize);
break; break;
case ArrayState: case ArrayState:
GenBuildArray (0); GenBuildArrayPop();
break; break;
} }
#if UPDATE_POP
GenUpdatePopA (0, asize);
#else
GenUpdateA (0, asize);
GenPopA (asize);
#endif
GenPopB (bsize); GenPopB (bsize);
GenRtn (1,0,OnAState); GenRtn (1,0,OnAState);
#if SHARE_UPDATE_CODE #if SHARE_UPDATE_CODE
......
...@@ -687,19 +687,27 @@ void CoerceArgumentOnTopOfStack (int *asp_p,int *bsp_p,StateS argstate,StateS no ...@@ -687,19 +687,27 @@ void CoerceArgumentOnTopOfStack (int *asp_p,int *bsp_p,StateS argstate,StateS no
BuildTuple (*asp_p,*bsp_p,*asp_p,*bsp_p,nodestate.state_arity,nodestate.state_tuple_arguments, BuildTuple (*asp_p,*bsp_p,*asp_p,*bsp_p,nodestate.state_arity,nodestate.state_tuple_arguments,
asize,bsize,*asp_p,NormalFill,True); asize,bsize,*asp_p,NormalFill,True);
*asp_p+=1; *asp_p+=1;
GenUpdatePopA (0,asize);
*asp_p-=asize;
break; break;
case RecordState: case RecordState:
BuildRecord (nodestate.state_record_symbol,*asp_p,*bsp_p,*asp_p,*bsp_p, BuildRecord (nodestate.state_record_symbol,*asp_p,*bsp_p,*asp_p,*bsp_p,
asize,bsize,*asp_p,NormalFill,True); asize,bsize,*asp_p,NormalFill,True);
*asp_p+=1; *asp_p+=1;
GenUpdatePopA (0,asize);
*asp_p-=asize;
break; break;
case ArrayState: case ArrayState:
GenBuildArray (0); if (asize==1)
++*asp_p; GenBuildArrayPop();
else {
GenBuildArray (0);
++*asp_p;
GenUpdatePopA (0,asize);
*asp_p-=asize;
}
break; break;
} }
GenUpdatePopA (0,asize);
*asp_p-=asize;
GenPopB (bsize); GenPopB (bsize);
*bsp_p-=bsize; *bsp_p-=bsize;
} else { } else {
...@@ -3845,9 +3853,8 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i ...@@ -3845,9 +3853,8 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i
} }
if (update_immediately){ if (update_immediately){
#if 1
BuildArgs (record_arg->arg_next,asp_p,bsp_p,code_gen_node_ids_p); BuildArgs (record_arg->arg_next,asp_p,bsp_p,code_gen_node_ids_p);
#endif
if (record_node->node_kind==NodeIdNode){ if (record_node->node_kind==NodeIdNode){
NodeIdP record_node_id; NodeIdP record_node_id;
...@@ -3860,9 +3867,6 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i ...@@ -3860,9 +3867,6 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i
#if BOXED_RECORDS #if BOXED_RECORDS
record_node_id->nid_mark2 |= NID_RECORD_USED_BY_NON_SELECTOR_OR_UPDATES; record_node_id->nid_mark2 |= NID_RECORD_USED_BY_NON_SELECTOR_OR_UPDATES;
#endif
#if 0
BuildArgs (record_arg->arg_next,asp_p,bsp_p,code_gen_node_ids_p);
#endif #endif
DetermineSizeOfState (*record_state_p,&record_a_size,&record_b_size); DetermineSizeOfState (*record_state_p,&record_a_size,&record_b_size);
...@@ -3896,11 +3900,9 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i ...@@ -3896,11 +3900,9 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i
#endif #endif
record_arg->arg_state=*record_state_p; record_arg->arg_state=*record_state_p;
#if 1
BuildArg (node->node_arguments,asp_p,bsp_p,code_gen_node_ids_p); BuildArg (node->node_arguments,asp_p,bsp_p,code_gen_node_ids_p);
#else
BuildArgs (node->node_arguments,asp_p,bsp_p,code_gen_node_ids_p);
#endif
DetermineSizeOfState (*record_state_p,&record_a_size,&record_b_size); DetermineSizeOfState (*record_state_p,&record_a_size,&record_b_size);
{ {
......
...@@ -255,15 +255,21 @@ void RedirectResultAndReturn (int asp,int bsp,int source_a_index,int source_b_in ...@@ -255,15 +255,21 @@ void RedirectResultAndReturn (int asp,int bsp,int source_a_index,int source_b_in
BuildTuple (source_a_index,source_b_index,asp,bsp, BuildTuple (source_a_index,source_b_index,asp,bsp,
offstate.state_arity, offstate.state_tuple_arguments, offstate.state_arity, offstate.state_tuple_arguments,
offasize, offbsize, 0, ReleaseAndFill,True); offasize, offbsize, 0, ReleaseAndFill,True);
GenUpdatePopA (0,asp);
break; break;
case RecordState: case RecordState:
BuildRecord (offstate.state_record_symbol,source_a_index,source_b_index, asp, bsp, BuildRecord (offstate.state_record_symbol,source_a_index,source_b_index, asp, bsp,
offasize, offbsize, 0, ReleaseAndFill,True); offasize, offbsize, 0, ReleaseAndFill,True);
GenUpdatePopA (0,asp);
break; break;
case ArrayState: case ArrayState:
GenBuildArray (asp-source_a_index); if (asp==source_a_index && asp==1)
GenBuildArrayPop();
else {
GenBuildArray (asp-source_a_index);
GenUpdatePopA (0,asp);
}
} }
GenUpdatePopA (0,asp);
GenPopB (bsp); GenPopB (bsp);
} else { } else {
switch (offstate.state_type){ switch (offstate.state_type){
......
...@@ -2168,10 +2168,15 @@ void GenBuildU (Label symblab,int a_size,int b_size,Label contlab) ...@@ -2168,10 +2168,15 @@ void GenBuildU (Label symblab,int a_size,int b_size,Label contlab)
GenDescriptorOrNodeEntryLabel (contlab); GenDescriptorOrNodeEntryLabel (contlab);
} }
void GenBuildArrayPop (void)
{
GenBuildh (& BasicDescriptors [ArrayObj], 1);
}
void GenBuildArray (int argoffset) void GenBuildArray (int argoffset)
{ {
GenPushA (argoffset); GenPushA (argoffset);
GenBuildh (& BasicDescriptors [ArrayObj], 1); GenBuildArrayPop();
} }
void GenBuildString (SymbValue val) void GenBuildString (SymbValue val)
......
...@@ -64,6 +64,7 @@ void GenBuild (Label symblab,int arity,Label contlab); ...@@ -64,6 +64,7 @@ void GenBuild (Label symblab,int arity,Label contlab);
void GenBuildh (Label symblab,int arity); void GenBuildh (Label symblab,int arity);
void GenBuildPartialFunctionh (Label symblab,int arity); void GenBuildPartialFunctionh (Label symblab,int arity);
void GenBuildU (Label symblab,int a_size,int b_size,Label contlab); void GenBuildU (Label symblab,int a_size,int b_size,Label contlab);
void GenBuildArrayPop (void);
void GenBuildArray (int argoffset); void GenBuildArray (int argoffset);
void GenBuildString (SymbValue val); void GenBuildString (SymbValue val);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment