Commit 6c39cd56 authored by John van Groningen's avatar John van Groningen

remove first argument type for BESetMemberTypeOfField and...

remove first argument type for BESetMemberTypeOfField and sdef_member_type_of_field and first State of sdef_member_states_of_field
parent 677b58f1
......@@ -1020,11 +1020,8 @@ where
= convert_exported_generic_member_selector moduleIndex selectors (arg_is_strict index strictness) symbols.[index] field_list_p type_var_heap bes
= convertSelector moduleIndex selectors (arg_is_strict index strictness) symbols.[index] field_list_p type_var_heap bes
// the first argument type (record of the class) of the BESetMemberTypeOfField type is not used in the backend
// replace it by TE to prevent marking and generating unused descriptors
// to do: update the backend and remove the argument instead
make_first_arg_type_TE expanded_member_type=:{st_args=[{at_attribute}:args]}
= {expanded_member_type & st_args = [{at_attribute=at_attribute,at_type=TE}:tl expanded_member_type.st_args]}
remove_first_arg_type expanded_member_type=:{st_args=[_:args],st_arity}
= {expanded_member_type & st_args = args, st_arity = st_arity-1}
convertMemberSelector :: ModuleIndex {#SelectorDef} Bool FieldSymbol !BEFieldListP !*TypeVarHeap !*BackEndState -> (!BEFieldListP,!*TypeVarHeap,!*BackEndState)
convertMemberSelector moduleIndex selectorDefs is_strict {fs_index} field_list_p type_var_heap bes
......@@ -1046,12 +1043,12 @@ convertMemberSelector moduleIndex selectorDefs is_strict {fs_index} field_list_p
-> (st_result,No,bes)
VI_ExpandedMemberType expanded_member_type (VI_ExpandedType {st_result})
# (dont_care_symbol_p,bes) = accBackEnd BEDontCareDefinitionSymbol bes
expanded_member_type = make_first_arg_type_TE expanded_member_type
expanded_member_type = remove_first_arg_type expanded_member_type
(type_alt_p,bes) = convertTypeAltForSymbolP dont_care_symbol_p expanded_member_type bes
-> (st_result,Yes type_alt_p,bes)
VI_ExpandedMemberType expanded_member_type VI_Empty
# (dont_care_symbol_p,bes) = accBackEnd BEDontCareDefinitionSymbol bes
expanded_member_type = make_first_arg_type_TE expanded_member_type
expanded_member_type = remove_first_arg_type expanded_member_type
(type_alt_p,bes) = convertTypeAltForSymbolP dont_care_symbol_p expanded_member_type bes
-> (sd_type.st_result,Yes type_alt_p,bes)
_
......@@ -1077,12 +1074,12 @@ convert_exported_generic_member_selector moduleIndex selectorDefs is_strict {fs_
-> (st_result,No,bes)
VI_ExpandedMemberType expanded_member_type (VI_ExpandedType {st_result})
# (dont_care_symbol_p,bes) = accBackEnd BEDontCareDefinitionSymbol bes
expanded_member_type = make_first_arg_type_TE expanded_member_type
expanded_member_type = remove_first_arg_type expanded_member_type
(type_alt_p,bes) = convertExportedTypeAltForSymbolP dont_care_symbol_p expanded_member_type bes
-> (st_result,Yes type_alt_p,bes)
VI_ExpandedMemberType expanded_member_type VI_Empty
# (dont_care_symbol_p,bes) = accBackEnd BEDontCareDefinitionSymbol bes
expanded_member_type = make_first_arg_type_TE expanded_member_type
expanded_member_type = remove_first_arg_type expanded_member_type
(type_alt_p,bes) = convertExportedTypeAltForSymbolP dont_care_symbol_p expanded_member_type bes
-> (sd_type.st_result,Yes type_alt_p,bes)
_
......
......@@ -1150,14 +1150,12 @@ static void coerce_args_from_class_to_instance_member
static int generate_instance_entry_arguments
(struct symbol_def *dictionary_field,int function_arity,struct state *function_state_p,struct label *i_label_p,int *asize_p,int *bsize_p)
{
struct type_alt *field_type_alt;
struct state *member_state_p;
int member_arity,n_dictionary_args;
int arg_n,asp,bsp,asize,bsize,oldamax,oldbmax,a_ind,b_ind,maxasize;
int member_called_with_root_node,function_updates_node,create_new_node;
field_type_alt=dictionary_field->sdef_member_type_of_field;
member_arity=field_type_alt->type_alt_lhs_arity-1;
member_arity=dictionary_field->sdef_member_type_of_field->type_alt_lhs_arity;
member_state_p=dictionary_field->sdef_member_states_of_field;
if (DoDebug){
......@@ -1171,8 +1169,6 @@ static int generate_instance_entry_arguments
n_dictionary_args = function_arity-member_arity;
++member_state_p;
DetermineSizeOfStates (member_arity,member_state_p,&asp,&bsp);
asize=0;
......@@ -1181,8 +1177,8 @@ static int generate_instance_entry_arguments
for (arg_n=0; arg_n<function_arity; ++arg_n)
AddStateSizeAndMaxFrameSize (function_state_p[arg_n],&maxasize,&asize,&bsize);
member_called_with_root_node = member_state_p[-2].state_type==SimpleState
&& !(member_state_p[-2].state_kind==StrictRedirection || member_state_p[-2].state_kind==OnB);
member_called_with_root_node = member_state_p[-1].state_type==SimpleState
&& !(member_state_p[-1].state_kind==StrictRedirection || member_state_p[-1].state_kind==OnB);
function_updates_node = function_state_p[-1].state_type==SimpleState
&& !(function_state_p[-1].state_kind==StrictRedirection || function_state_p[-1].state_kind==OnB);
......@@ -1246,17 +1242,15 @@ static int generate_unboxed_record_cons_instance_entry
member_state_p=dictionary_field->sdef_member_states_of_field;
++member_state_p;
GenFillR (unboxed_record_cons_lab_p,a_size,b_size,a_size,0,0,ReleaseAndFill,True);
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-2])){
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-1])){
GenRtn (1,0,OnAState);
} else {
int result_asize,result_bsize;
DetermineSizeOfState (function_state_p[-1],&result_asize,&result_bsize);
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-2],result_asize,result_bsize);
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-1],result_asize,result_bsize);
}
return 1;
......@@ -1294,8 +1288,6 @@ static int generate_unboxed_record_decons_instance_entry (struct symbol_def *rul
member_state_p=dictionary_field->sdef_member_states_of_field;
++member_state_p;
DetermineSizeOfState (function_state_p[-1],&result_asize,&result_bsize);
if (result_bsize==0)
......@@ -1303,10 +1295,10 @@ static int generate_unboxed_record_decons_instance_entry (struct symbol_def *rul
else
GenReplRArgs (result_asize,result_bsize);
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-2]))
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-1]))
GenRtn (result_asize,result_bsize,function_state_p[-1]);
else
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-2],result_asize,result_bsize);
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-1],result_asize,result_bsize);
return 1;
}
......@@ -1342,16 +1334,14 @@ static int generate_unboxed_record_instance_entry (struct symbol_def *rule_sdef,
member_state_p=dictionary_field->sdef_member_states_of_field;
++member_state_p;
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-2]))
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-1]))
CallArrayFunction (rule_sdef,False,&rule_sdef->sdef_rule_type->rule_type_state_p[-1]);
else {
int result_asize,result_bsize;
CallArrayFunction (rule_sdef,True,&rule_sdef->sdef_rule_type->rule_type_state_p[-1]);
DetermineSizeOfState (function_state_p[-1],&result_asize,&result_bsize);
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-2],result_asize,result_bsize);
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-1],result_asize,result_bsize);
}
return 1;
......@@ -2078,8 +2068,6 @@ int generate_instance_entry (struct symbol_def *rule_sdef,struct state *function
member_state_p=dictionary_field->sdef_member_states_of_field;
++member_state_p;
GenDStackLayoutOfStates (asize+function_updates_node,bsize,rule_sdef->sdef_arity,function_state_p);
current_alt_label = CurrentAltLabel;
......@@ -2088,7 +2076,7 @@ int generate_instance_entry (struct symbol_def *rule_sdef,struct state *function
if (rule_sdef->sdef_exported)
current_alt_label.lab_mod = NULL;
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-2]))
if (function_updates_node || EqualState (function_state_p[-1],member_state_p[-1]))
GenJmp (&current_alt_label);
else {
int result_asize,result_bsize;
......@@ -2098,7 +2086,7 @@ int generate_instance_entry (struct symbol_def *rule_sdef,struct state *function
DetermineSizeOfState (function_state_p[-1],&result_asize,&result_bsize);
GenOStackLayoutOfState (result_asize,result_bsize,function_state_p[-1]);
function_called_only_curried_or_lazy_with_one_return = 0;
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-2],result_asize,result_bsize);
RedirectResultAndReturn (result_asize,result_bsize,result_asize,result_bsize,function_state_p[-1],member_state_p[-1],result_asize,result_bsize);
}
return 1;
......@@ -5092,8 +5080,8 @@ static void repl_overloaded_cons_or_just_arguments (NodeP node_p,int *asp_p,int
if (node_p->node_push_symbol->symb_kind==just_symb || 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]);
DetermineSizeOfStates (member_arity,member_states_of_field,&a_size,&b_size);
GenDStackLayoutOfStates (a_size+1+member_called_with_root_node,b_size,member_arity,member_states_of_field);
GenJsrI (1);
......
......@@ -2886,12 +2886,10 @@ static void generate_code_for_apply_in_strict_context (NodeP node,int *asp_p,int
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_arity==n_apply_args+1){
if (field_sdef->sdef_member_type_of_field->type_alt_lhs_arity==n_apply_args){
PutSOutFile ("\n||\t");
PutSOutFile (selector_node_p->node_symbol->symb_def->sdef_name);
} else {
......@@ -2917,8 +2915,8 @@ static void generate_code_for_apply_in_strict_context (NodeP node,int *asp_p,int
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]);
DetermineSizeOfStates (member_arity,member_states_of_field,&a_size,&b_size);
GenDStackLayoutOfStates (a_size+1+member_called_with_root_node,b_size,member_arity,member_states_of_field);
GenJsrI (n_apply_args);
......
......@@ -660,12 +660,10 @@ static void CodeRootApply (Node root,NodeId rootid,int asp,int bsp,CodeGenNodeId
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_arity==n_apply_args+1){
if (field_sdef->sdef_member_type_of_field->type_alt_lhs_arity==n_apply_args){
PutSOutFile ("\n||\t");
PutIOutFile (root->node_symbol->symb_instance_apply);
PutCOutFile (' ');
......@@ -694,8 +692,8 @@ static void CodeRootApply (Node root,NodeId rootid,int asp,int bsp,CodeGenNodeId
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]);
DetermineSizeOfStates (member_arity,member_states_of_field,&a_size,&b_size);
GenDStackLayoutOfStates (a_size+1+member_called_with_root_node,b_size,member_arity,member_states_of_field);
if (no_tail_call){
int result_a_size,result_b_size,jsr_i_result_a_size,jsr_i_result_b_size;
......
......@@ -1388,11 +1388,9 @@ static char *create_arguments_for_local_function (NodeP node_p,ArgS ***arg_h,Arg
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_arity==n_apply_args+1){
if (field_sdef->sdef_member_type_of_field->type_alt_lhs_arity==n_apply_args){
struct symbol *new_symbol_p;
new_symbol_p = CompAlloc (sizeof (struct symbol));
......@@ -2182,7 +2180,7 @@ static void optimise_instance_call (NodeP node,int n_apply_args,struct state *me
int arg_n;
arg_n=n_apply_args;
if (arg_n>1 || is_optimisable_argument (node->node_arguments->arg_next->arg_node,&member_states_of_field[1])){
if (arg_n>1 || is_optimisable_argument (node->node_arguments->arg_next->arg_node,member_states_of_field)){
struct arg *old_arg_p;
struct node *rhs_root_of_function;
......@@ -2268,11 +2266,9 @@ static void optimise_normal_node (Node node)
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_arity==n_apply_args+1){
if (field_sdef->sdef_member_type_of_field->type_alt_lhs_arity==n_apply_args){
struct symbol *new_symbol_p;
new_symbol_p = CompAlloc (sizeof (struct symbol));
......
......@@ -2280,7 +2280,7 @@ static Exp ConvertNode (Node node, NodeId nid)
struct type_arg *type_arg_p;
member_type_alt=arg_p->arg_node->node_symbol->symb_def->sdef_member_type_of_field;
if (member_type_alt->type_alt_lhs_arity==n_apply_args+1){
if (member_type_alt->type_alt_lhs_arity==n_apply_args){
int arg_n;
unsigned int arg_strictness;
NodeP first_arg_of_apply_node_p;
......@@ -2288,7 +2288,7 @@ static Exp ConvertNode (Node node, NodeId nid)
arg_strictness=0;
arg_n=0;
for_l (type_arg_p,member_type_alt->type_alt_lhs_arguments->type_arg_next,type_arg_next){
for_l (type_arg_p,member_type_alt->type_alt_lhs_arguments,type_arg_next){
if (type_arg_p->type_arg_node->type_node_annotation==StrictAnnot)
arg_strictness |= 1<<arg_n;
++arg_n;
......
......@@ -2037,8 +2037,8 @@ static Bool OptimizedMemberCallInAStrictContext (Node node,int arg_n,struct stat
parallel = DetermineStrictArgContext (arg1_p, StrictState, local_scope);
}
if (! IsLazyState (member_states_of_field[arg_n+1])){
if (DetermineStrictArgContext (arg2_p, member_states_of_field[arg_n+1], local_scope))
if (! IsLazyState (member_states_of_field[arg_n])){
if (DetermineStrictArgContext (arg2_p, member_states_of_field[arg_n], local_scope))
parallel = True;
} else
if (ShouldDecrRefCount)
......@@ -2131,14 +2131,14 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop
member_type_alt=field_sdef->sdef_member_type_of_field;
if (OptimizeInstanceCalls){
arg_n=member_type_alt->type_alt_lhs_arity-1;
arg_n=member_type_alt->type_alt_lhs_arity;
node->node_state = field_sdef->sdef_member_states_of_field[-1];
return OptimizedMemberCallInAStrictContext (node,arg_n,field_sdef->sdef_member_states_of_field,local_scope);
}
arg_strictness=0;
arg_n=0;
for_l (type_arg_p,member_type_alt->type_alt_lhs_arguments->type_arg_next,type_arg_next){
for_l (type_arg_p,member_type_alt->type_alt_lhs_arguments,type_arg_next){
if (type_arg_p->type_arg_node->type_node_annotation==StrictAnnot){
arg_strictness |= 1<<arg_n;
}
......@@ -2171,7 +2171,7 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop
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_arity==n_apply_args+1){
if (member_type_alt->type_alt_lhs_arity==n_apply_args){
int arg_n;
unsigned int arg_strictness;
struct type_arg *type_arg_p;
......@@ -2187,14 +2187,14 @@ static Bool NodeInAStrictContext (Node node,StateS demanded_state,int local_scop
}
if (OptimizeInstanceCalls){
arg_n=member_type_alt->type_alt_lhs_arity-1;
arg_n=member_type_alt->type_alt_lhs_arity;
node->node_state = field_sdef->sdef_member_states_of_field[-1];
return OptimizedMemberCallInAStrictContext (node,arg_n,field_sdef->sdef_member_states_of_field,local_scope);
}
arg_strictness=0;
arg_n=0;
for_l (type_arg_p,member_type_alt->type_alt_lhs_arguments->type_arg_next,type_arg_next){
for_l (type_arg_p,member_type_alt->type_alt_lhs_arguments,type_arg_next){
if (type_arg_p->type_arg_node->type_node_annotation==StrictAnnot){
arg_strictness |= 1<<arg_n;
}
......
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