Commit 09733ce9 authored by johnvg@science.ru.nl's avatar johnvg@science.ru.nl
Browse files

add instance call optimisation (not enabled by default)

parent 863fe4e0
......@@ -132,6 +132,7 @@ Bool CallCompiler (int argc, char **argv)
DoDescriptors=False;
ExportLocalLabels=False;
AddStrictnessToExportedFunctionTypes=False;
OptimizeInstanceCalls=False;
Dynamics=False;
StrictDoAnnots = False;
......@@ -193,6 +194,8 @@ Bool CallCompiler (int argc, char **argv)
AddStrictnessToExportedFunctionTypes=True;
else if (strcmp (argv_i,"-dynamics") == 0)
Dynamics=True;
else if (strcmp (argv_i,"-oic") == 0)
OptimizeInstanceCalls=True;
else if (strncmp (argv_i, "-sa", 3) == 0){
if (!SetStrictOption (argv[i]+3)){
CmdError ("unknown flag %s", argv[i]);
......
......@@ -3,8 +3,6 @@
Authors:Sjaak Smetsers & John van Groningen
*/
#pragma segment codegen1
#define SHARE_UPDATE_CODE 0 /* also in codegen.c */
#define FREE_STRICT_LHS_TUPLE_ELEMENTS 1 /* also in codegen2.c */
#define BIND_UNBOXED_LHS_TUPLE_AND_RECORD_ARGUMENTS_IN_BIND_ARGUMENTS 1
......@@ -1183,8 +1181,9 @@ static int generate_instance_entry_arguments
field_type_alt=dictionary_field->sdef_member_type_of_field;
member_arity=field_type_alt->type_alt_lhs->type_node_arity-1;
member_state_p=dictionary_field->sdef_member_states_of_field;
FPrintF (OutFile, "\n||\tmember type %s %d %d",
dictionary_field->sdef_ident->ident_name,member_arity,function_arity);
if (DoDebug)
FPrintF (OutFile, "\n||\tmember type %s %d %d",dictionary_field->sdef_ident->ident_name,member_arity,function_arity);
n_dictionary_args = function_arity-member_arity;
......@@ -1239,7 +1238,8 @@ static int generate_unboxed_record_cons_instance_entry
int dictionary_sdef_mark;
if (rule_sdef->sdef_mark & SDEF_RULE_INSTANCE_RULE_P){
FPrintF (OutFile, "\n||\tinstance fused");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance fused");
if (rule_sdef->sdef_instance_rule->sdef_mark & SDEF_INSTANCE_RULE_WITH_FIELD_P){
dictionary_field=rule_sdef->sdef_instance_rule->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
......@@ -1248,7 +1248,8 @@ static int generate_unboxed_record_cons_instance_entry
}
} else {
/* SDEF_INSTANCE_RULE_WITH_FIELD_P */
FPrintF (OutFile, "\n||\tinstance");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance");
dictionary_field=rule_sdef->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
}
......@@ -1285,7 +1286,8 @@ static int generate_unboxed_record_decons_instance_entry (struct symbol_def *rul
int dictionary_sdef_mark;
if (rule_sdef->sdef_mark & SDEF_RULE_INSTANCE_RULE_P){
FPrintF (OutFile, "\n||\tinstance fused");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance fused");
if (rule_sdef->sdef_instance_rule->sdef_mark & SDEF_INSTANCE_RULE_WITH_FIELD_P){
dictionary_field=rule_sdef->sdef_instance_rule->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
......@@ -1294,7 +1296,8 @@ static int generate_unboxed_record_decons_instance_entry (struct symbol_def *rul
}
} else {
/* SDEF_INSTANCE_RULE_WITH_FIELD_P */
FPrintF (OutFile, "\n||\tinstance");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance");
dictionary_field=rule_sdef->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
}
......@@ -1332,7 +1335,8 @@ static int generate_unboxed_record_instance_entry (struct symbol_def *rule_sdef,
int dictionary_sdef_mark;
if (rule_sdef->sdef_mark & SDEF_RULE_INSTANCE_RULE_P){
FPrintF (OutFile, "\n||\tinstance fused");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance fused");
if (rule_sdef->sdef_instance_rule->sdef_mark & SDEF_INSTANCE_RULE_WITH_FIELD_P){
dictionary_field=rule_sdef->sdef_instance_rule->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
......@@ -1341,7 +1345,8 @@ static int generate_unboxed_record_instance_entry (struct symbol_def *rule_sdef,
}
} else {
/* SDEF_INSTANCE_RULE_WITH_FIELD_P */
FPrintF (OutFile, "\n||\tinstance");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance");
dictionary_field=rule_sdef->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
}
......@@ -2028,7 +2033,8 @@ int generate_instance_entry (struct symbol_def *rule_sdef,struct state *function
int dictionary_sdef_mark;
if (rule_sdef->sdef_mark & SDEF_RULE_INSTANCE_RULE_P){
FPrintF (OutFile, "\n||\tinstance fused");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance fused");
if (rule_sdef->sdef_instance_rule->sdef_mark & SDEF_INSTANCE_RULE_WITH_FIELD_P){
dictionary_field=rule_sdef->sdef_instance_rule->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
......@@ -2037,7 +2043,8 @@ int generate_instance_entry (struct symbol_def *rule_sdef,struct state *function
}
} else {
/* SDEF_INSTANCE_RULE_WITH_FIELD_P */
FPrintF (OutFile, "\n||\tinstance");
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance");
dictionary_field=rule_sdef->sdef_dictionary_field;
dictionary_sdef_mark=dictionary_field->sdef_mark;
}
......@@ -4564,6 +4571,45 @@ static void repl_overloaded_cons_arguments (NodeP node_p,int *asp_p,int *bsp_p,S
ab_node_ids_p->a_node_ids=code_gen_node_ids.a_node_ids;
ab_node_ids_p->b_node_ids=code_gen_node_ids.b_node_ids;
if (DoDebug)
FPrintF (OutFile, "\n||\tinstance %d %d",node_p->node_push_symbol->symb_head_strictness,node_p->node_push_symbol->symb_instance_apply);
if (node_p->node_decons_node->node_kind==SelectorNode &&
(node_p->node_decons_node->node_symbol->symb_def->sdef_mark & SDEF_FIELD_HAS_MEMBER_TYPE)!=0)
{
struct symbol_def *field_sdef;
field_sdef=node_p->node_decons_node->node_symbol->symb_def;
if (DoDebug)
FPrintF (OutFile, "\n||\t%s",field_sdef->sdef_ident->ident_name);
if (OptimizeInstanceCalls){
struct state *member_states_of_field;
int member_arity,member_called_with_root_node;
member_states_of_field=field_sdef->sdef_member_states_of_field;
member_arity=field_sdef->sdef_member_type_of_field->type_alt_lhs->type_node_arity;
member_called_with_root_node = member_states_of_field[-1].state_type==SimpleState
&& !(member_states_of_field[-1].state_kind==StrictRedirection || member_states_of_field[-1].state_kind==OnB);
if (member_states_of_field[-1].state_type==TupleState){
int a_size,b_size;
DetermineSizeOfStates (member_arity-1,&member_states_of_field[1],&a_size,&b_size);
GenDStackLayoutOfStates (a_size+1+member_called_with_root_node,b_size,member_arity-1,&member_states_of_field[1]);
GenJsrI (1);
DetermineSizeOfState (member_states_of_field[-1],&a_size,&b_size);
GenOStackLayoutOfState (a_size,b_size,member_states_of_field[-1]);
return;
}
}
}
GenJsrAp (1);
GenReplArgs (2,2);
......
......@@ -1121,7 +1121,7 @@ void DetermineFieldSizeAndPositionAndRecordSize
*rec_bsize_p = *bsize_p + *bpos_p;
for (i=fieldnr+1; i<record_state_p->state_arity; ++i)
AddSizeOfState (record_state_p->state_record_arguments[i],rec_asize_p,rec_bsize_p);
AddSizeOfState (record_state_p->state_record_arguments[i],rec_asize_p,rec_bsize_p);
}
int get_a_index_of_unpacked_lhs_node (ArgS *arg)
......@@ -2654,7 +2654,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
CallFunction (&name,sdef,True,node);
AddSizeOfState (node->node_state,asp_p,bsp_p);
AddSizeOfState (node->node_state,asp_p,bsp_p);
GenPopA (1);
*asp_p-=1;
......@@ -2679,7 +2679,7 @@ static void FillSymbol (Node node,SymbDef sdef,int *asp_p,int *bsp_p,NodeId upda
CallFunction (&name,sdef,True,node);
AddSizeOfState (node->node_state,asp_p,bsp_p);
AddSizeOfState (node->node_state,asp_p,bsp_p);
}
}
return;
......@@ -2860,9 +2860,16 @@ static void generate_code_for_apply_in_strict_context (NodeP node,int *asp_p,int
int a_size,b_size,n_apply_args;
ArgP node_args;
node_args=node->node_arguments;
a_size=0;
if (OptimizeInstanceCalls && node->node_symbol->symb_instance_apply==1 && ExpectsResultNode (node->node_state)){
NewEmptyNode (asp_p,-1);
a_size=1;
}
node_args=node->node_arguments;
b_size=0;
n_apply_args=build_apply_arguments (node_args,&a_size,&b_size,asp_p,bsp_p,code_gen_node_ids_p);
*asp_p-=a_size;
......@@ -2871,9 +2878,61 @@ static void generate_code_for_apply_in_strict_context (NodeP node,int *asp_p,int
&code_gen_node_ids_p->free_node_ids,code_gen_node_ids_p->moved_node_ids_l,
code_gen_node_ids_p->doesnt_fail);
if (node->node_symbol->symb_instance_apply==1){
struct arg *arg_p;
struct symbol_def *field_sdef;
field_sdef = (struct symbol_def *)node->node_symbol->symb_next;
arg_p=node_args;
while (arg_p!=NULL && arg_p->arg_node->node_kind==NormalNode && arg_p->arg_node->node_symbol->symb_kind==apply_symb)
arg_p=arg_p->arg_node->node_arguments;
if (arg_p!=NULL && arg_p->arg_node->node_kind==SelectorNode && arg_p->arg_node->node_arity==1){
struct node *selector_node_p;
selector_node_p=arg_p->arg_node;
if ((selector_node_p->node_symbol->symb_def->sdef_mark & SDEF_FIELD_HAS_MEMBER_TYPE)!=0){
struct type_alt *member_type_alt;
field_sdef=selector_node_p->node_symbol->symb_def;
member_type_alt=field_sdef->sdef_member_type_of_field;
if (DoDebug)
if (member_type_alt->type_alt_lhs->type_node_arity==n_apply_args+1){
FPrintF (OutFile, "\n||\t%s",selector_node_p->node_symbol->symb_def->sdef_ident->ident_name);
} else
FPrintF (OutFile, "\n||\t(no dictionary) %s",field_sdef->sdef_ident->ident_name);
} else if (DoDebug)
FPrintF (OutFile, "\n||\t(no dictionary) %s",field_sdef->sdef_ident->ident_name);
} else if (DoDebug)
FPrintF (OutFile, "\n||\t(no dictionary) %s",field_sdef->sdef_ident->ident_name);
if (field_sdef!=NULL && OptimizeInstanceCalls){
struct state *member_states_of_field;
int member_arity,member_called_with_root_node,a_size,b_size;
member_states_of_field=field_sdef->sdef_member_states_of_field;
member_arity=field_sdef->sdef_member_type_of_field->type_alt_lhs->type_node_arity;
member_called_with_root_node = member_states_of_field[-1].state_type==SimpleState
&& !(member_states_of_field[-1].state_kind==StrictRedirection || member_states_of_field[-1].state_kind==OnB);
DetermineSizeOfStates (member_arity-1,&member_states_of_field[1],&a_size,&b_size);
GenDStackLayoutOfStates (a_size+1+member_called_with_root_node,b_size,member_arity-1,&member_states_of_field[1]);
GenJsrI (n_apply_args);
AddSizeOfState (node->node_state,asp_p,bsp_p);
DetermineSizeOfState (member_states_of_field[-1],&a_size,&b_size);
GenOStackLayoutOfState (a_size,b_size,member_states_of_field[-1]);
return;
}
}
GenJsrAp (n_apply_args);
AddSizeOfState (node->node_state,asp_p,bsp_p);
AddSizeOfState (node->node_state,asp_p,bsp_p);
}
static void FillApply (Node node,int *asp_p,int *bsp_p,NodeId update_node_id,CodeGenNodeIdsP code_gen_node_ids_p)
......@@ -2914,7 +2973,7 @@ static void FillApply (Node node,int *asp_p,int *bsp_p,NodeId update_node_id,Cod
GenJsrAp (1);
AddSizeOfState (node->node_state,asp_p,bsp_p);
AddSizeOfState (node->node_state,asp_p,bsp_p);
GenPopA (1);
*asp_p-=1;
......@@ -4163,8 +4222,8 @@ static void FillUpdateNode (Node node,int *asp_p,int *bsp_p,NodeId update_node_i
*asp_p-update_node_id->nid_a_index,node->node_state.state_kind==SemiStrict ? PartialFill : NormalFill,False);
GenPopA (end_args_a_offset);
*asp_p-=end_args_a_offset;
GenPopB (end_args_b_offset);
*bsp_p-=end_args_b_offset;
GenPopB (end_args_b_offset);
*bsp_p-=end_args_b_offset;
}
}
......@@ -5508,7 +5567,7 @@ static void ReorderParallelAndNonParallelArgs (Args args)
if (arg->arg_state.state_mark & STATE_PARALLEL_MASK)
AddSizeOfState (arg->arg_state,&par_a_size,&par_b_size);
else
AddSizeOfState (arg->arg_state,&npar_a_size,&npar_b_size);
AddSizeOfState (arg->arg_state,&npar_a_size,&npar_b_size);
if ((par_a_size==0 || npar_a_size==0) && (par_b_size==0 || npar_b_size==0))
return;
......
......@@ -260,10 +260,10 @@ void RedirectResultAndReturn (int asp,int bsp,int source_a_index,int source_b_in
break;
case RecordState:
if (source_a_index==asp && (source_b_index==bsp || offbsize==0))
BuildNewRecordPop (offstate.state_record_symbol,offasize,offbsize);
BuildNewRecordPop (offstate.state_record_symbol,offasize,offbsize);
else {
BuildNewRecord (offstate.state_record_symbol,source_a_index,source_b_index,asp,bsp,offasize,offbsize);
GenUpdatePopA (0,asp);
GenUpdatePopA (0,asp);
GenPopB (bsp);
}
break;
......@@ -273,8 +273,8 @@ void RedirectResultAndReturn (int asp,int bsp,int source_a_index,int source_b_in
else {
GenBuildArray (asp-source_a_index);
GenUpdatePopA (0,asp);
}
GenPopB (bsp);
}
GenPopB (bsp);
}
} else {
switch (offstate.state_type){
......@@ -621,15 +621,95 @@ static void CodeRootApply (Node root,NodeId rootid,int asp,int bsp,CodeGenNodeId
CreateSemiStrictRootNode (&name,&codelab,root,rootid,asp,bsp,code_gen_node_ids_p,resultstate);
} else {
int a_size,b_size,n_apply_args;
int a_size,b_size,n_apply_args,no_tail_call;
a_size=0;
if (OptimizeInstanceCalls && root->node_symbol->symb_instance_apply==1){
Coercions moveact;
moveact = DetermineResultAdjustment (resultstate, root->node_state);
if (moveact==AToB || moveact==BToA || moveact==AToRoot){
no_tail_call=1;
if (ResultNodeNecessary (moveact,root->node_state)){
NewEmptyNode (&asp,-1);
a_size=1;
}
} else
no_tail_call=0;
} else
no_tail_call = !IsSimpleState (resultstate) || resultstate.state_kind!=StrictRedirection;
b_size=0;
n_apply_args=build_apply_arguments (root->node_arguments,&a_size,&b_size,&asp,&bsp,code_gen_node_ids_p);
UpdateAAndBStack (asp,bsp,a_size,b_size,&asp,&bsp);
if (!IsSimpleState (resultstate) || resultstate.state_kind!=StrictRedirection){
if (root->node_symbol->symb_instance_apply==1){
struct arg *arg_p;
struct symbol_def *field_sdef;
field_sdef = (struct symbol_def *)root->node_symbol->symb_next;
arg_p=root->node_arguments;
while (arg_p!=NULL && arg_p->arg_node->node_kind==NormalNode && arg_p->arg_node->node_symbol->symb_kind==apply_symb)
arg_p=arg_p->arg_node->node_arguments;
if (arg_p!=NULL && arg_p->arg_node->node_kind==SelectorNode && arg_p->arg_node->node_arity==1){
struct node *selector_node_p;
selector_node_p=arg_p->arg_node;
if ((selector_node_p->node_symbol->symb_def->sdef_mark & SDEF_FIELD_HAS_MEMBER_TYPE)!=0){
struct type_alt *member_type_alt;
field_sdef=selector_node_p->node_symbol->symb_def;
member_type_alt=field_sdef->sdef_member_type_of_field;
if (DoDebug)
if (member_type_alt->type_alt_lhs->type_node_arity==n_apply_args+1){
FPrintF (OutFile, "\n||\t%d %s",root->node_symbol->symb_instance_apply,selector_node_p->node_symbol->symb_def->sdef_ident->ident_name);
} else
FPrintF (OutFile, "\n||\t(no dictionary) %s",field_sdef->sdef_ident->ident_name);
} else if (DoDebug)
FPrintF (OutFile, "\n||\t(no dictionary) %s",field_sdef->sdef_ident->ident_name);
} else if (DoDebug)
FPrintF (OutFile, "\n||\t(no dictionary) %s",field_sdef->sdef_ident->ident_name);
if (field_sdef!=NULL && OptimizeInstanceCalls){
struct state *member_states_of_field;
int member_arity,member_called_with_root_node;
int a_size,b_size;
member_states_of_field=field_sdef->sdef_member_states_of_field;
member_arity=field_sdef->sdef_member_type_of_field->type_alt_lhs->type_node_arity;
member_called_with_root_node = member_states_of_field[-1].state_type==SimpleState
&& !(member_states_of_field[-1].state_kind==StrictRedirection || member_states_of_field[-1].state_kind==OnB);
DetermineSizeOfStates (member_arity-1,&member_states_of_field[1],&a_size,&b_size);
GenDStackLayoutOfStates (a_size+1+member_called_with_root_node,b_size,member_arity-1,&member_states_of_field[1]);
if (no_tail_call){
int result_a_size,result_b_size,jsr_i_result_a_size,jsr_i_result_b_size;
GenJsrI (n_apply_args);
DetermineSizeOfState (member_states_of_field[-1],&jsr_i_result_a_size,&jsr_i_result_b_size);
GenOStackLayoutOfState (jsr_i_result_a_size,jsr_i_result_b_size,member_states_of_field[-1]);
DetermineSizeOfState (root->node_state,&result_a_size,&result_b_size);
asp+=result_a_size-(a_size+1+member_called_with_root_node);
bsp+=result_b_size-b_size;
RedirectResultAndReturn (asp,bsp,asp,bsp,root->node_state,resultstate,result_a_size,result_b_size);
} else
GenJmpI (n_apply_args);
return;
}
}
if (no_tail_call){
int result_a_size,result_b_size;
GenJsrAp (n_apply_args);
......
......@@ -86,7 +86,7 @@ static int tuple_state_has_more_strictness (StateS *state_p,TypeNode type_node,S
++function_arg_state_p;
}
return 0;
return 0;
}
static int equal_strictness_in_types (TypeNode lazy_type_node,TypeNode strict_type_node)
......@@ -1148,6 +1148,66 @@ static int add_n_new_arguments_for_local_function (ArgP arg_p,int n_arguments)
return n_arguments;
}
static struct arg *remove_apply_nodes (struct node *node,int n_apply_args)
{
struct arg *old_arg_p,*new_arg_list,*arg_p;
int arg_n;
new_arg_list=NULL;
arg_p=node->node_arguments;
old_arg_p=arg_p;
for (arg_n=n_apply_args; arg_n>1; --arg_n){
struct arg *arg_next_p;
arg_next_p=arg_p->arg_next;
arg_next_p->arg_next=new_arg_list;
new_arg_list=arg_next_p;
arg_p=arg_p->arg_node->node_arguments;
}
arg_p->arg_next->arg_next=new_arg_list;
node->node_arguments=arg_p;
return old_arg_p;
}
static void restore_removed_apply_nodes (struct node *node,struct arg *old_arg_p,int n_apply_args)
{
struct arg *arg_p;
int arg_n;
node->node_arguments=old_arg_p;
arg_p=old_arg_p;
for (arg_n=n_apply_args; arg_n>1; --arg_n){
arg_p->arg_next->arg_next=NULL;
arg_p=arg_p->arg_node->node_arguments;
}
arg_p->arg_next->arg_next=NULL;
}
static struct arg *store_args_in_apply_nodes (int n_apply_args,struct arg *arg_p,struct node *apply_node)
{
struct arg *remaining_args;
if (n_apply_args==1){
apply_node->node_arguments=arg_p;
remaining_args=arg_p->arg_next->arg_next;
arg_p->arg_next->arg_next=NULL;
return remaining_args;
} else {
struct arg *first_arg_p,*next_arg_p;
first_arg_p=apply_node->node_arguments;
next_arg_p=store_args_in_apply_nodes (n_apply_args-1,arg_p,first_arg_p->arg_node);
remaining_args=next_arg_p->arg_next;
next_arg_p->arg_next=NULL;
first_arg_p->arg_next=next_arg_p;
return remaining_args;
}
}
static char *create_arguments_for_local_function (NodeP node_p,ArgS ***arg_h,ArgS ***lhs_arg_h,ArgS **rhs_arg_p,StateP arg_state_p,int *arity_p,char *function_name_p,char *end_function_name,int *n_arguments_p)
{
NodeIdP arg_node_id;
......@@ -1321,6 +1381,84 @@ static char *create_arguments_for_local_function (NodeP node_p,ArgS ***arg_h,Arg
#endif
#ifdef MOVE_APPLY_NODES_IN_LAZY_CONTEXT_TO_NEW_FUNCTION
case apply_symb:
if (arg_node->node_arity==2){
struct arg *arg_p;
int n_apply_args;
n_apply_args=1;
arg_p=arg_node->node_arguments;
while (arg_p!=NULL && arg_p->arg_node->node_arity==2 && arg_p->arg_node->node_kind==NormalNode &&
arg_p->arg_node->node_symbol->symb_kind==apply_symb)
{
++n_apply_args;
arg_p=arg_p->arg_node->node_arguments;
}
if (arg_p!=NULL && arg_p->arg_node->node_kind==SelectorNode && arg_p->arg_node->node_arity==1){
struct node *selector_node_p;
selector_node_p=arg_p->arg_node;
if ((selector_node_p->node_symbol->symb_def->sdef_mark & SDEF_FIELD_HAS_MEMBER_TYPE)!=0){
struct symbol_def *field_sdef;
struct type_alt *member_type_alt;
field_sdef=selector_node_p->node_symbol->symb_def;
member_type_alt=field_sdef->sdef_member_type_of_field;
if (member_type_alt->type_alt_lhs->type_node_arity==n_apply_args+1){
struct symbol *new_symbol_p;
new_symbol_p = CompAlloc (sizeof (struct symbol));
*new_symbol_p = *arg_node->node_symbol;
new_symbol_p->symb_instance_apply = 1;
new_symbol_p->symb_next = (struct symbol*)selector_node_p->node_symbol->symb_def;
arg_node->node_symbol = new_symbol_p;
if (arg_state_p->state_type==SimpleState && (arg_state_p->state_kind==StrictOnA || arg_state_p->state_kind==StrictRedirection)
&& OptimizeInstanceCalls)
{
struct state *member_states_of_field;
struct arg *old_arg_p;
Node function_node;
ArgP new_arg;
int new_n_arguments;
member_states_of_field=field_sdef->sdef_member_states_of_field;
old_arg_p = remove_apply_nodes (arg_node,n_apply_args);
new_n_arguments=add_n_new_arguments_for_local_function (arg_node->node_arguments,*n_arguments_p-1);
if (new_n_arguments>MAX_N_FUNCTION_ARGUMENTS){
restore_removed_apply_nodes (arg_node,old_arg_p,n_apply_args);
break;
}
*n_arguments_p=new_n_arguments;
function_node=NewNode (arg_node->node_symbol,NULL,arg_node->node_arity);
function_node->node_state=LazyState;
function_node->node_number=0;
new_arg=NewArgument (function_node);
new_arg->arg_state=LazyState;
*rhs_arg_p=new_arg;
rhs_arg_p=&new_arg->arg_next;
function_name_p = create_arguments_for_local_function (arg_node,arg_h,lhs_arg_h,&function_node->node_arguments,
member_states_of_field,arity_p,function_name_p,end_function_name,n_arguments_p);
++arg_state_p;
arg_p=function_node->node_arguments;
function_node->node_arguments=old_arg_p;
store_args_in_apply_nodes (n_apply_args,arg_p,function_node);
continue;
}
}
}
}
}
if (arg_state_p->state_type==SimpleState && (arg_state_p->state_kind==StrictOnA || arg_state_p->state_kind==StrictRedirection)){
Node function_node;
ArgP new_arg;
......@@ -1503,7 +1641,7 @@ static char *create_arguments_for_local_function (NodeP node_p,ArgS ***arg_h,Arg
**lhs_arg_h=lhs_arg;
*lhs_arg_h=&lhs_arg->arg_next;
**arg_h=arg;
*arg_h=&arg->arg_next;
}
......@@ -1521,7 +1659,7 @@ static char *create_arguments_for_local_function (NodeP node_p,ArgS ***arg_h,Arg
return function_name_p;
}
static void create_new_local_function (Node node,StateP function_state_p)
static struct node *create_new_local_function (Node node,StateP function_state_p)
{
static char function_name[64];
Symbol function_symbol;
......@@ -1534,7 +1672,7 @@ static void create_new_local_function (Node node,StateP function_state_p)
n_arguments = add_n_new_arguments_for_local_function (node->node_arguments,0);