Fully implemented call lowering for methods with compound return values
[libfirm] / ir / lower / lower_calls.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/lower/lower_calls.c
4  * Purpose:     lowering of Calls with compound parameters
5  * Author:      Michael Beck
6  * Created:
7  * CVS-ID:      $Id$
8  * Copyright:   (c) 1998-2005 Universität Karlsruhe
9  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
10  */
11
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #ifdef HAVE_ALLOCA_H
17 #include <alloca.h>
18 #endif
19 #ifdef HAVE_MALLOC_H
20 #include <malloc.h>
21 #endif
22
23 #include "irprog_t.h"
24 #include "irnode_t.h"
25 #include "type_t.h"
26 #include "irmode_t.h"
27 #include "ircons.h"
28 #include "irgmod.h"
29 #include "irgwalk.h"
30 #include "typewalk.h"
31 #include "lower_calls.h"
32 #include "return.h"
33 #include "irtools.h"
34 #include "array.h"
35 #include "pmap.h"
36
37 /** A type map for def_find_pointer_type. */
38 static pmap *type_map;
39
40 /**
41  * Default implementation for finding a pointer type for a given element type.
42  * Simple create a new one.
43  */
44 static ir_type *def_find_pointer_type(ir_type *e_type, ir_mode *mode, int alignment)
45 {
46   ir_type *res;
47   pmap_entry *e;
48
49   /* Mode and alignment are always identical in all calls to def_find_pointer_type(), so
50      we simply can use a map from the element type to the pointer type. */
51   e = pmap_find(type_map, e_type);
52   if (e)
53     res = e->value;
54   else {
55     res = new_type_pointer(mangle_u(get_type_ident(e_type), new_id_from_chars("Ptr", 3)), e_type, mode);
56     set_type_alignment_bytes(res, alignment);
57     pmap_insert(type_map, e_type, res);
58   }
59   return res;
60 }
61
62 /**
63  * Creates a new lowered type for a method type with compound
64  * arguments. The new type is associated to the old one and returned.
65  *
66  * @param lp   parameter struct
67  * @param mtp  the method type to lower
68  *
69  * The current implementation expects that a lowered type already
70  * includes the necessery changes ...
71  */
72 static ir_type *create_modified_mtd_type(const lower_params_t *lp, ir_type *mtp)
73 {
74   ir_type *lowered;
75   ir_type **params, **results, *res_tp;
76   int n_ress, n_params, nn_ress, nn_params, i, first_variadic;
77   ident *id;
78   add_hidden hidden_params;
79   variadicity var;
80
81   if (is_lowered_type(mtp)) {
82     /* the type is already lowered. Not handled yet. */
83     assert(0 && "lowered types NYI");
84   }
85
86   lowered = get_associated_type(mtp);
87   if (lowered)
88     return lowered;
89
90   n_ress   = get_method_n_ress(mtp);
91   NEW_ARR_A(ir_type *, results, n_ress);
92
93   n_params = get_method_n_params(mtp);
94   NEW_ARR_A(ir_type *, params, n_params + n_ress);
95
96   first_variadic = get_method_first_variadic_param_index(mtp);
97
98   hidden_params = lp->hidden_params;
99   if (hidden_params == ADD_HIDDEN_SMART &&
100     get_method_variadicity(mtp) == variadicity_variadic)
101         hidden_params = ADD_HIDDEN_ALWAYS_IN_FRONT;
102
103   if (hidden_params == ADD_HIDDEN_ALWAYS_IN_FRONT) {
104     /* add hidden in front */
105     for (nn_ress = nn_params = i = 0; i < n_ress; ++i) {
106       res_tp = get_method_res_type(mtp, i);
107
108       if (is_compound_type(res_tp))
109         params[nn_params++] = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
110       else
111         results[nn_ress++] = res_tp;
112     }
113
114     /* move the index of the first variadic parameter */
115     first_variadic += nn_params;
116
117     for (i = 0; i < n_params; ++i)
118       params[nn_params++] = get_method_param_type(mtp, i);
119   }
120   else {
121     /* add hidden parameters last */
122     assert(get_method_variadicity(mtp) == variadicity_non_variadic &&
123       "Cannot add hidden parameters at end of variadic function");
124
125     for (nn_params = 0; nn_params < n_params; ++nn_params)
126       params[nn_params] = get_method_param_type(mtp, nn_params);
127
128     for (nn_ress = i = 0; i < n_ress; ++i) {
129       res_tp = get_method_res_type(mtp, i);
130
131       if (is_compound_type(res_tp))
132         params[nn_params++] = lp->find_pointer_type(res_tp, get_modeP_data(), lp->def_ptr_alignment);
133       else
134         results[nn_ress++] = res_tp;
135     }
136   }
137
138   /* create the new type */
139   id = mangle_u(new_id_from_chars("L", 1), get_type_ident(mtp));
140   lowered = new_d_type_method(id, nn_params, nn_ress, get_type_dbg_info(mtp));
141
142   /* fill it */
143   for (i = 0; i < nn_params; ++i)
144     set_method_param_type(lowered, i, params[i]);
145   for (i = 0; i < nn_ress; ++i)
146     set_method_res_type(lowered, i, results[i]);
147
148   var = get_method_variadicity(mtp);
149   set_method_variadicity(lowered, var);
150   if (var == variadicity_variadic)
151     set_method_first_variadic_param_index(lowered, first_variadic);
152
153   /* associate the lowered type with the original one for easier access */
154   set_lowered_type(mtp, lowered);
155
156   return lowered;
157 }
158
159 /**
160  * A call list entry.
161  */
162 typedef struct cl_entry cl_entry;
163 struct cl_entry {
164   cl_entry *next;   /**< Pointer to the next entry. */
165   ir_node  *call;   /**< Pointer to the Call node. */
166   ir_node  *copyb;  /**< List of all CopyB nodes. */
167 };
168
169 /**
170  * Walker environment for fix_args_and_collect_calls().
171  */
172 typedef struct _wlk_env_t {
173   int            arg_shift;     /**< The Argument index shift for parameters. */
174   int            first_hidden;  /**< The index of the first hidden argument. */
175   struct obstack obst;          /**< An obstack to allocate the data on. */
176   cl_entry       *cl_list;      /**< The call list. */
177   pmap           *dummy_map;    /**< A map for finding the dummy arguments. */
178   unsigned       dnr;           /**< The dummy index number. */
179 } wlk_env;
180
181 /**
182  * Return the call list entry of a call node.
183  * If no entry exists yet, allocate one and enter the node into
184  * the call list of the environment.
185  *
186  * @param call   A Call node.
187  * @param env    The environment.
188  */
189 static cl_entry *get_Call_entry(ir_node *call, wlk_env *env) {
190   cl_entry *res = get_irn_link(call);
191   if (res == NULL) {
192     cl_entry *res = obstack_alloc(&env->obst, sizeof(*res));
193     res->next  = env->cl_list;
194     res->call  = call;
195     res->copyb = NULL;
196     set_irn_link(call, res);
197     env->cl_list = res;
198   }
199   return res;
200 }
201
202 /**
203  * Post walker: shift all parameter indeces
204  * and collect Calls with compound returns in the call list.
205  */
206 static void fix_args_and_collect_calls(ir_node *n, void *ctx) {
207   wlk_env *env = ctx;
208   int i;
209   ir_type *ctp;
210   ir_op *op = get_irn_op(n);
211
212   if (env->arg_shift > 0 && op == op_Proj) {
213     ir_node *pred = get_Proj_pred(n);
214
215     /* Fix the argument numbers */
216     if (pred == get_irg_args(current_ir_graph)) {
217       long pnr = get_Proj_proj(n);
218       set_Proj_proj(n, pnr + env->arg_shift);
219     }
220   }
221   else if (op == op_Call) {
222     ctp = get_Call_type(n);
223     for (i = get_method_n_ress(ctp) -1; i >= 0; --i) {
224       if (is_compound_type(get_method_res_type(ctp, i))) {
225         /*
226          * This is a call with a compound return. As the result
227          * might be ignored, we must put it in the list.
228          */
229         (void)get_Call_entry(n, env);
230       }
231     }
232   }
233   else if (op == op_CopyB) {
234     ir_node *src = get_CopyB_src(n);
235     /* older scheme using value_res_ent */
236     if (is_Sel(src)) {
237       ir_node *proj = get_Sel_ptr(src);
238       if (is_Proj(proj) && get_Proj_proj(proj) == pn_Call_P_value_res_base) {
239         ir_node *call = get_Proj_pred(proj);
240         if (is_Call(call)) {
241           /* found a CopyB from compound Call result */
242           cl_entry *e = get_Call_entry(call, env);
243           set_irn_link(n, e->copyb);
244           e->copyb = n;
245         }
246       }
247     } else
248     /* new scheme: compound results are determined by the call type only */
249     if (is_Proj(src)) {
250       ir_node *proj = get_Proj_pred(src);
251       if (is_Proj(proj) && get_Proj_proj(proj) == pn_Call_T_result) {
252         ir_node *call = get_Proj_pred(proj);
253         if (is_Call(call)) {
254           ctp = get_Call_type(call);
255           if (is_compound_type(get_method_res_type(ctp, get_Proj_proj(src)))) {
256             /* found a CopyB from compound Call result */
257             cl_entry *e = get_Call_entry(call, env);
258             set_irn_link(n, e->copyb);
259             e->copyb = n;
260           }
261         }
262       }
263     }
264   }
265 }
266
267 /**
268  * Returns non-zero if a node is a compound address
269  * of a frame-type entity.
270  *
271  * @param ft   the frame type
272  * @param adr  the node
273  */
274 static int is_compound_address(ir_type *ft, ir_node *adr)
275 {
276   entity *ent;
277
278   if (! is_Sel(adr))
279     return 0;
280   if (get_Sel_n_indexs(adr) != 0)
281     return 0;
282   ent = get_Sel_entity(adr);
283   return get_entity_owner(ent) == ft;
284 }
285
286 /** A pair for the copy-return-optimization. */
287 typedef struct cr_pair {
288   entity *ent;    /**< the entity than can be removed from the frame */
289   ir_node *arg;   /**< the argument that replaces the entities address */
290 } cr_pair;
291
292 /**
293  * Post walker: fixes all entities addresses for the copy-return
294  * optimization.
295  *
296  * Note: We expect the length of the cr_pair array (ie number of compound
297  * return values) to be 1 (C, C++) in almost all cases, so ignore the
298  * linear search complexity here.
299  */
300 static void do_copy_return_opt(ir_node *n, void *ctx) {
301   cr_pair *arr = ctx;
302   int i;
303
304   if (is_Sel(n)) {
305     entity *ent = get_Sel_entity(n);
306
307     for (i = ARR_LEN(arr) - 1; i >= 0; --i) {
308       if (ent == arr[i].ent) {
309         exchange(n, arr[i].arg);
310         break;
311       }
312     }
313   }
314 }
315
316 /**
317  * Return a Sel node that selects a dummy argument of type tp.
318  * Dummy arguments are only needed once and we use a map
319  * to store them.
320  * We could even assign all dummy arguments the same offset
321  * in the frame type ...
322  *
323  * @param irg    the graph
324  * @param block  the block where a newly create Sel should be placed
325  * @param tp     the type of the dummy entity that should be create
326  * @param env    the environment
327  */
328 static ir_node *get_dummy_sel(ir_graph *irg, ir_node *block, ir_type *tp, wlk_env *env)
329 {
330   ir_node *sel;
331   pmap_entry *e;
332
333   /* use a map the check if we already create such an entity */
334   e = pmap_find(env->dummy_map, tp);
335   if (e)
336     sel = e->value;
337   else {
338     ir_type *ft = get_irg_frame_type(irg);
339     entity *ent;
340     char buf[16];
341
342     snprintf(buf, sizeof(buf), "dummy.%u", env->dnr++);
343     ent = new_entity(ft, new_id_from_str(buf), tp);
344     sel = new_r_simpleSel(
345       irg,
346       block,
347       get_irg_no_mem(irg),
348       get_irg_frame(irg),
349       ent);
350     pmap_insert(env->dummy_map, tp, sel);
351
352     if (get_type_state(ft) == layout_fixed) {
353       /* Fix the layout again */
354       assert(0 && "Fixed layout not implemented");
355     }
356   }
357   return sel;
358 }
359
360 /**
361  * Add the hidden parameter from the CopyB node to the Call node.
362  *
363  * @param irg    the graph
364  * @param n_com  number of compound results (will be number of hidden parameters)
365  * @param ins    in array to store the hidden parameters into
366  * @param entry  the call list
367  * @param env    the environment
368  */
369 static void add_hidden_param(ir_graph *irg, int n_com, ir_node **ins, cl_entry *entry, wlk_env *env)
370 {
371   ir_node *p, *n, *src, *mem;
372   entity *ent;
373   ir_type *owner;
374   int idx, n_args;
375
376   n_args = 0;
377   for (p = entry->copyb; p; p = n) {
378     n   = get_irn_link(p);
379     src = get_CopyB_src(p);
380
381     /* old scheme using value_res_ent */
382     if (is_Sel(src)) {
383       ent = get_Sel_entity(src);
384       owner = get_entity_owner(ent);
385
386       /* find the hidden parameter index */
387       for (idx = 0; idx < get_struct_n_members(owner); ++idx)
388         if (get_struct_member(owner, idx) == ent)
389           break;
390       assert(idx < get_struct_n_members(owner));
391     }
392     else
393
394     /* new scheme: compound returns are determined by the call type and are Proj's */
395     idx = get_Proj_proj(src);
396
397     ins[idx] = get_CopyB_dst(p);
398     mem      = get_CopyB_mem(p);
399
400     /* get rid of the CopyB */
401     turn_into_tuple(p, pn_CopyB_max);
402     set_Tuple_pred(p, pn_CopyB_M_regular, mem);
403     set_Tuple_pred(p, pn_CopyB_M_except, get_irg_bad(irg));
404     set_Tuple_pred(p, pn_CopyB_X_except, get_irg_bad(irg));
405     ++n_args;
406   }
407
408   /* now create dummy entities for function with ignored return value */
409   if (n_args < n_com) {
410     ir_type *ctp = get_Call_type(entry->call);
411     int i, j;
412
413     if (is_lowered_type(ctp))
414       ctp = get_associated_type(ctp);
415
416     for (j = i = 0; i < get_method_n_ress(ctp); ++i) {
417       ir_type *rtp = get_method_res_type(ctp, i);
418       if (is_compound_type(rtp)) {
419         if (ins[j] == NULL)
420           ins[j] = get_dummy_sel(irg, get_nodes_block(entry->call), rtp, env);
421         ++j;
422       }
423     }
424   }
425 }
426
427 /**
428  * Fix all calls on a call list by adding hidden parameters.
429  *
430  * @param lp   the parameter struct
431  * @param irg  the graph
432  * @param env  the environment
433  */
434 static void fix_call_list(const lower_params_t *lp, ir_graph *irg, wlk_env *env) {
435   cl_entry *p;
436   ir_node *call, **new_in;
437   ir_type *ctp, *lowered_mtp;
438   add_hidden hidden_params;
439   int i, n_params, n_com, pos;
440   unsigned dnr = 0;
441
442   new_in = NEW_ARR_F(ir_node *, 0);
443   for (p = env->cl_list; p; p = p->next) {
444     call = p->call;
445     ctp = get_Call_type(call);
446     lowered_mtp = create_modified_mtd_type(lp, ctp);
447     set_Call_type(call, lowered_mtp);
448
449     hidden_params = lp->hidden_params;
450     if (hidden_params == ADD_HIDDEN_SMART &&
451       get_method_variadicity(ctp) == variadicity_variadic)
452       hidden_params = ADD_HIDDEN_ALWAYS_IN_FRONT;
453
454     n_params = get_Call_n_params(call);
455
456     n_com = 0;
457     for (i = get_method_n_ress(ctp) - 1; i >= 0; --i) {
458       if (is_compound_type(get_method_res_type(ctp, i)))
459         ++n_com;
460     }
461     pos = 2;
462     ARR_RESIZE(ir_node *, new_in, n_params + n_com + pos);
463     memset(new_in, 0, sizeof(*new_in) * (n_params + n_com + pos));
464     if (hidden_params == ADD_HIDDEN_ALWAYS_IN_FRONT) {
465       add_hidden_param(irg, n_com, &new_in[pos], p, env);
466       pos += n_com;
467     }
468     /* copy all other parameters */
469     for (i = 0; i < n_params; ++i)
470       new_in[pos++] = get_Call_param(call, i);
471     if (hidden_params == ADD_HIDDEN_ALWAYS_LAST) {
472       add_hidden_param(irg, n_com, &new_in[pos], p, env);
473       pos += n_com;
474     }
475     new_in[0] = get_Call_mem(call);
476     new_in[1] = get_Call_ptr(call);
477
478     set_irn_in(call, n_params + n_com + 2, new_in);
479   }
480 }
481
482 /**
483  * Transform a graph. If it has compound parameter returns,
484  * remove them and use the hidden parameter instead.
485  * If it calls methods with compound parameter returns, add hidden
486  * parameters.
487  *
488  * @param lp   parameter struct
489  * @param irg  the graph to transform
490  */
491 static void transform_irg(const lower_params_t *lp, ir_graph *irg)
492 {
493   entity *ent = get_irg_entity(irg);
494   ir_type *mtp, *lowered_mtp, *res_tp, *ft;
495   int i, j, k, n_ress, n_com, n_cr_opt;
496   ir_node **new_in, *ret, *endbl, *bl, *mem, *copy;
497   cr_pair *cr_opt;
498   wlk_env env;
499   add_hidden hidden_params;
500
501   assert(ent && "Cannot tranform graph without an entity");
502   assert(get_irg_phase_state(irg) == phase_high && "call lowering must be done in phase high");
503
504   mtp    = get_entity_type(ent);
505   n_ress = get_method_n_ress(mtp);
506   for (n_com = i = 0; i < n_ress; ++i) {
507     res_tp = get_method_res_type(mtp, i);
508
509     if (is_compound_type(res_tp))
510       ++n_com;
511   }
512
513   if (n_com) {
514     /* much easier if we have only one return */
515     normalize_one_return(irg);
516
517     /* This graph has a compound argument. Create a new type */
518     lowered_mtp = create_modified_mtd_type(lp, mtp);
519     set_entity_type(ent, lowered_mtp);
520
521     hidden_params = lp->hidden_params;
522     if (hidden_params == ADD_HIDDEN_SMART &&
523       get_method_variadicity(mtp) == variadicity_variadic)
524       hidden_params = ADD_HIDDEN_ALWAYS_IN_FRONT;
525
526     if (hidden_params == ADD_HIDDEN_ALWAYS_IN_FRONT) {
527       /* hidden arguments are added first */
528       env.arg_shift    = n_com;
529       env.first_hidden = 0;
530     }
531     else {
532       /* hidden arguments are added last */
533       env.arg_shift    = 0;
534       env.first_hidden = get_method_n_params(mtp);
535     }
536   }
537   else {
538     /* we must only search for calls */
539     env.arg_shift = 0;
540   }
541   obstack_init(&env.obst);
542   env.cl_list   = NULL;
543   env.dummy_map = pmap_create_ex(8);
544   env.dnr       = 0;
545
546   /* scan the code, fix argument numbers and collect calls. */
547   irg_walk_graph(irg, firm_clear_link, fix_args_and_collect_calls, &env);
548
549   /* fix all calls */
550   if (env.cl_list)
551     fix_call_list(lp, irg, &env);
552
553   if (n_com) {
554     /*
555      * Now fix the Return node of the current graph.
556      */
557
558     /* STEP 1: find the return. This is simple, we have normalized the graph. */
559     endbl = get_irg_end_block(irg);
560     ret = NULL;
561     for (i = get_Block_n_cfgpreds(endbl) - 1; i >= 0; --i) {
562       ir_node *pred = get_Block_cfgpred(endbl, i);
563
564       if (is_Return(pred)) {
565         ret = pred;
566         break;
567       }
568     }
569     /* there should always be a return */
570     assert(ret);
571
572     /*
573      * STEP 2: fix it. For all compound return values add a CopyB,
574      * all others are copied.
575      */
576     NEW_ARR_A(ir_node *, new_in, n_ress - n_com + 1);
577
578     bl  = get_nodes_block(ret);
579     mem = get_Return_mem(ret);
580
581     ft = get_irg_frame_type(irg);
582     NEW_ARR_A(cr_pair, cr_opt, n_com);
583     n_cr_opt = 0;
584     for (j = 1, i = k = 0; i < n_ress; ++i) {
585       ir_node *pred = get_Return_res(ret, i);
586       res_tp = get_method_res_type(mtp, i);
587
588       if (is_compound_type(res_tp)) {
589         ir_node *arg = get_irg_args(irg);
590         arg = new_r_Proj(irg, get_nodes_block(arg), arg, mode_P_data, env.first_hidden + k);
591         ++k;
592
593         if (is_compound_address(ft, pred)) {
594           /* we can do the copy-return optimization here */
595           cr_opt[n_cr_opt].ent = get_Sel_entity(pred);
596           cr_opt[n_cr_opt].arg = arg;
597           ++n_cr_opt;
598         }
599         else { /* copy-return optimization is impossible, do the copy. */
600           copy = new_r_CopyB(
601                   irg, bl,
602                   mem,
603                   arg,
604                   pred,
605                   res_tp
606                  );
607           mem = new_r_Proj(irg, bl, copy, mode_M, pn_CopyB_M_regular);
608         }
609       }
610       else { /* skalar return value */
611         new_in[j] = pred;
612         ++j;
613       }
614     }
615     new_in[0] = mem;
616     set_irn_in(ret, j, new_in);
617
618     if (n_cr_opt > 0) {
619       irg_walk_graph(irg, NULL, do_copy_return_opt, cr_opt);
620
621       for (i = ARR_LEN(cr_opt) - 1; i >= 0; --i) {
622         remove_class_member(ft, cr_opt[i].ent);
623       }
624     }
625   } /* n_com */
626
627   pmap_destroy(env.dummy_map);
628   obstack_free(&env.obst, NULL);
629 }
630
631 /**
632  * Returns non-zero if the given type is a method
633  * type that must be lowered.
634  *
635  * @param tp  The type.
636  */
637 static int must_be_lowered(ir_type *tp) {
638   int i, n_ress;
639   ir_type *res_tp;
640
641   if (is_Method_type(tp)) {
642     n_ress = get_method_n_ress(tp);
643     for (i = 0; i < n_ress; ++i) {
644       res_tp = get_method_res_type(tp, i);
645
646       if (is_compound_type(res_tp))
647         return 1;
648     }
649   }
650   return 0;
651 }
652
653 /**
654  * type-walker: lower all method types of entities
655  * and points-to types.
656  */
657 static void lower_method_types(type_or_ent *tore, void *env)
658 {
659   const lower_params_t *lp = env;
660   ir_type *tp;
661
662   /* fix method entities */
663   if (is_entity(tore)) {
664     entity *ent = (entity *)tore;
665     tp = get_entity_type(ent);
666
667     if (must_be_lowered(tp)) {
668       tp = create_modified_mtd_type(lp, tp);
669       set_entity_type(ent, tp);
670     }
671   }
672   else {
673     tp = (ir_type *)tore;
674
675     /* fix pointer to methods */
676     if (is_Pointer_type(tp)) {
677       ir_type *etp = get_pointer_points_to_type(tp);
678       if (must_be_lowered(etp)) {
679         etp = create_modified_mtd_type(lp, etp);
680         set_pointer_points_to_type(tp, etp);
681       }
682     }
683   }
684 }
685
686 /*
687  * Lower calls with compound return types.
688  * This function does the following transformations:
689  *
690  * - Adds a new (hidden) pointer parameter for
691  *   any return compound type.
692  *
693  * - Use of the hidden parameters in the function code.
694  *
695  * - Change all calls to functions with compound return
696  *   by providing space for the hidden parameter on the callers
697  *   stack.
698  *
699  * - Replace a possible block copy after the function call.
700  */
701 void lower_compound_ret_calls(const lower_params_t *params)
702 {
703   int i;
704   ir_graph *irg;
705   lower_params_t param = *params;
706
707   if (param.find_pointer_type == NULL) {
708     param.find_pointer_type = def_find_pointer_type;
709     type_map = pmap_create_ex(8);
710   }
711   else
712     type_map = NULL;
713
714   /* first step: Transform all graphs */
715   for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
716     irg = get_irp_irg(i);
717
718     if (irg == get_const_code_irg())
719       continue;
720
721     transform_irg(&param, irg);
722   }
723
724   /* second step: Lower all method types of visible entities */
725   type_walk(NULL, lower_method_types, &param);
726
727   if (type_map)
728     pmap_destroy(type_map);
729 }