Commit 5f239787 authored by John van Groningen's avatar John van Groningen
Browse files

remove some unnecessary update_a and pop_a instructions when updating to an ARRAY node

parent 909b0b60
...@@ -914,16 +914,17 @@ static void CodeRule (ImpRuleP rule) ...@@ -914,16 +914,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, 0, ReleaseAndFill,False); function_state_p[-1].state_tuple_arguments,asize, bsize, 0, ReleaseAndFill,False);
GenPopA (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, 0, ReleaseAndFill, False); asize, bsize, 0, ReleaseAndFill, False);
GenPopA (asize);
break; break;
case ArrayState: case ArrayState:
GenFillArray (0, 1, ReleaseAndFill); GenFillArrayAndPop (1, ReleaseAndFill);
break; break;
} }
GenPopA (asize);
} else { } else {
switch (function_state_p[-1].state_type){ switch (function_state_p[-1].state_type){
case TupleState: case TupleState:
...@@ -938,12 +939,7 @@ static void CodeRule (ImpRuleP rule) ...@@ -938,12 +939,7 @@ static void CodeRule (ImpRuleP rule)
GenBuildArray (0); GenBuildArray (0);
break; break;
} }
#if UPDATE_POP
GenUpdatePopA (0, asize); GenUpdatePopA (0, asize);
#else
GenUpdateA (0, asize);
GenPopA (asize);
#endif
} }
GenPopB (bsize); GenPopB (bsize);
......
...@@ -1103,18 +1103,19 @@ static void GenLazyFieldSelectorEntry (SymbDef field_def,StateS recstate,int tot ...@@ -1103,18 +1103,19 @@ static void GenLazyFieldSelectorEntry (SymbDef field_def,StateS recstate,int tot
BuildTuple (asize,bsize,asize,bsize, BuildTuple (asize,bsize,asize,bsize,
offfieldstate.state_arity,offfieldstate.state_tuple_arguments, offfieldstate.state_arity,offfieldstate.state_tuple_arguments,
asize,bsize,0,ReleaseAndFill,False); asize,bsize,0,ReleaseAndFill,False);
GenPopA (asize);
break; break;
case ArrayState: case ArrayState:
GenFillArray (0,1,ReleaseAndFill); GenFillArrayAndPop (1,ReleaseAndFill);
break; break;
#ifdef ADD_ARGUMENTS_TO_HIGHER_ORDER_FUNCTIONS #ifdef ADD_ARGUMENTS_TO_HIGHER_ORDER_FUNCTIONS
case RecordState: case RecordState:
BuildRecord (offfieldstate.state_record_symbol,asize,bsize,asize,bsize, BuildRecord (offfieldstate.state_record_symbol,asize,bsize,asize,bsize,
asize,bsize,0,ReleaseAndFill,False); asize,bsize,0,ReleaseAndFill,False);
GenPopA (asize);
break; break;
#endif #endif
} }
GenPopA (asize);
GenPopB (bsize); GenPopB (bsize);
GenRtn (1,0,OnAState); GenRtn (1,0,OnAState);
} }
...@@ -1520,18 +1521,19 @@ Bool NodeEntry (StateS *const function_state_p,int arity,Label ealab,SymbDef roo ...@@ -1520,18 +1521,19 @@ Bool NodeEntry (StateS *const function_state_p,int arity,Label ealab,SymbDef roo
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, 0, ReleaseAndFill,False); function_state_p[-1].state_tuple_arguments,asize, bsize, 0, ReleaseAndFill,False);
GenPopA (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,0,ReleaseAndFill,False); asize,bsize,0,ReleaseAndFill,False);
GenPopA (asize);
break; break;
case ArrayState: case ArrayState:
GenFillArray (0, 1, ReleaseAndFill); GenFillArrayAndPop (1, ReleaseAndFill);
break; break;
} }
GenPopA (asize);
GenPopB (bsize);
GenPopB (bsize);
GenRtn (1,0,OnAState); GenRtn (1,0,OnAState);
#if SHARE_UPDATE_CODE #if SHARE_UPDATE_CODE
} }
...@@ -1690,18 +1692,19 @@ Bool NodeEntryUnboxed (StateS *const function_state_p,NodeP call_node_p,int args ...@@ -1690,18 +1692,19 @@ Bool NodeEntryUnboxed (StateS *const function_state_p,NodeP call_node_p,int args
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, 0, ReleaseAndFill,False); function_state_p[-1].state_tuple_arguments,asize, bsize, 0, ReleaseAndFill,False);
GenPopA (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,0,ReleaseAndFill,False); asize,bsize,0,ReleaseAndFill,False);
GenPopA (asize);
break; break;
case ArrayState: case ArrayState:
GenFillArray (0, 1, ReleaseAndFill); GenFillArrayAndPop (1, ReleaseAndFill);
break; break;
} }
GenPopA (asize);
GenPopB (bsize);
GenPopB (bsize);
GenRtn (1,0,OnAState); GenRtn (1,0,OnAState);
# if SHARE_UPDATE_CODE # if SHARE_UPDATE_CODE
} }
......
...@@ -271,15 +271,21 @@ void RedirectResultAndReturn (int asp,int bsp,int source_a_index,int source_b_in ...@@ -271,15 +271,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,False); offasize, offbsize, 0, ReleaseAndFill,False);
GenPopA (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,False); offasize, offbsize, 0, ReleaseAndFill,False);
GenPopA (asp);
break; break;
case ArrayState: case ArrayState:
GenFillArray (asp-source_a_index,asp,ReleaseAndFill); if (asp==source_a_index && asp==1)
GenFillArrayAndPop (asp,ReleaseAndFill);
else {
GenFillArray (asp-source_a_index,asp,ReleaseAndFill);
GenPopA (asp);
}
} }
GenPopA (asp);
GenPopB (bsp); GenPopB (bsp);
} }
} else { } else {
......
...@@ -2351,6 +2351,11 @@ void GenFillFromA (int src, int dst, FillKind fkind) ...@@ -2351,6 +2351,11 @@ void GenFillFromA (int src, int dst, FillKind fkind)
TreatWaitListAfterFill (dst, fkind); TreatWaitListAfterFill (dst, fkind);
} }
void GenFillArrayAndPop (int rootoffset, FillKind fkind)
{
GenFillh (&BasicDescriptors [ArrayObj], 1, rootoffset, fkind);
}
void GenFillArray (int argoffset, int rootoffset, FillKind fkind) void GenFillArray (int argoffset, int rootoffset, FillKind fkind)
{ {
GenPushA (argoffset); GenPushA (argoffset);
......
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