Added aop_join_on_copy().
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 12 Aug 2010 19:51:27 +0000 (15:51 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 12 Aug 2010 19:51:27 +0000 (15:51 -0400)
src/aop-main.c
src/aop-pc-assign.c
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c
src/aop-pointcut.h
src/aop.h

index 0acac47c55561763c2d1fc0d8b9cb2c7c5da4850..f8b4506a82047959dafeea5914be5722a3707b67 100644 (file)
@@ -51,6 +51,7 @@
 #include <c-common.h>
 
 #include "aop.h"
+#include "aop-duplicate.h"
 #include "aop-pointcut.h"
 
 //#define PAUSE_ON_START
@@ -90,6 +91,25 @@ aop_join_on (struct aop_pointcut *pc, join_callback callback,
   }
 }
 
+void
+aop_join_on_copy (struct aop_pointcut *pc, int copy, join_callback callback,
+                 void *callback_param)
+{
+  aop_assert (pc != NULL && pc->join_on != NULL);
+
+  if (!is_current_func_duplicated ())
+    fatal_error ("(InterAspect) Attempt to use aop_join_on_copy() to join on a"
+                " function that was not duplicated.");
+
+  pc->join_on_copy (pc, copy, callback, callback_param);
+
+  /* Call regimplification only if the pointcut needs it */
+  if (pc->need_regimplification) {
+    regimplify();
+    pc->need_regimplification = false;
+  }
+}
+
 /* Store a list of all struct opt_pass objects we create so that we
    can free them at cleanup time. */
 typedef struct opt_pass *aop_pass;
index 07b88b8b31ce4610eb087c20bfe2fef84bfb950e..84dc685914375a3a5fcb49c79f69b3815028643a 100644 (file)
@@ -327,6 +327,14 @@ op_join_on_assign (struct aop_pointcut *pc, join_callback cb,
     }
 }
 
+static void
+op_join_on_copy_assign (struct aop_pointcut *pc, int copy, join_callback cb,
+                       void *callback_param)
+{
+  /* Not yet supported. */
+  aop_assert(0);
+}
+
 /**
  * Include compiler-created temporary variables in an assignment
  * pointcut.
@@ -372,6 +380,7 @@ aop_match_assignment_by_type (const struct aop_type *type)
   pc = create_pointcut (ATP_ASSIGN);
 
   pc->join_on = op_join_on_assign;
+  pc->join_on_copy = op_join_on_copy_assign;
   pc->prepare_for_weave = op_prepare_assign;
 
   pc->pc_assign.type = type;
index 33c985be5f6d979647a1f7b971b0421b15e01ce8..a3fae6ab76754f35ea1a84b792aaaa7d2a7389fc 100644 (file)
@@ -69,6 +69,14 @@ op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
   cb (&jp, callback_param);
 }
 
+static void 
+op_join_on_copy_function_entry (struct aop_pointcut *pc, int copy,
+                               join_callback cb, void *callback_param)
+{
+  /* Not yet supported. */
+  aop_assert(0);
+}
+
 /* There is no GIMPLE statement that is suitable as an anchor point
    for inserting advice at the beginning of a function.
 
@@ -117,6 +125,7 @@ aop_match_function_entry ()
   pc = create_pointcut (ATP_ENTRY);
 
   pc->join_on = op_join_on_function_entry;
+  pc->join_on_copy = op_join_on_copy_function_entry;
   pc->prepare_for_weave = op_prepare_entry;
 
   pc->pc_entry.function_name = NULL;
index ca31b762370e8f26571a60b274c6a62d4fc55166..9f6f9e366e3b8f5af3be8c1fb7a96bd1de1aec52 100644 (file)
@@ -74,6 +74,14 @@ op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb,
     } 
 }
 
+static void
+op_join_on_copy_function_exit (struct aop_pointcut *pc, int copy,
+                              join_callback cb, void *callback_param)
+{
+  /* Not yet supported. */
+  aop_assert(0);
+}
+
 /* Prepare for an insert at a function entry join point.
 
    Attempting to insert an advice call _after_ a return statement
@@ -103,6 +111,7 @@ aop_match_function_exit ()
   pc = create_pointcut (ATP_EXIT);
 
   pc->join_on = op_join_on_function_exit;
+  pc->join_on_copy = op_join_on_copy_function_exit;
   pc->prepare_for_weave = op_prepare_exit;
 
   return pc;
index 5cc0da07da8c802cad46934502d6d9017297556d..96f4f3e273e990424f09481d9786c28103b75d88 100644 (file)
 #include <string.h>
 
 #include "aop.h"
+#include "aop-duplicate.h"
+#include "aop-dynval.h"
 #include "aop-pointcut.h"
 #include "aop-type.h"
-#include "aop-dynval.h"
 
 /**
  * \defgroup call_pc Function Call Pointcut Functions
@@ -131,38 +132,63 @@ call_matches (struct aop_pointcut *pc, gimple call_stmt)
 }
 
 static void
-op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
-                         void *callback_param)
+join_on_bb_function_call (basic_block bb, struct aop_pointcut *pc,
+                         join_callback cb, void *callback_param)
 {
-  basic_block my_basic_block;
   gimple_stmt_iterator gsi;
 
-  aop_assert (pc->kind == ATP_CALL);
-
-  FOR_EACH_BB(my_basic_block)
+  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) 
     {
-      for (gsi = gsi_start_bb (my_basic_block) ; !gsi_end_p (gsi) ;
-          gsi_next (&gsi)) 
+      gimple stmt = gsi_stmt (gsi);
+
+      /* At this stage, there should be no GIMPLE statements with
+        sub-statements. */
+      gcc_assert(!gimple_has_substatements (stmt));
+
+      if (gimple_code (stmt) == GIMPLE_CALL)
        {
-         gimple stmt = gsi_stmt (gsi);
-
-         /* At this stage, there should be no GIMPLE statements with
-            sub-statements. */
-         gcc_assert(!gimple_has_substatements (stmt));
-
-         if (gimple_code (stmt) == GIMPLE_CALL)
-           {
-             if (call_matches (pc, stmt))
-               {                       
-                 struct aop_joinpoint jp;
-                 init_joinpoint (&jp, &gsi, pc, stmt);
-                 cb (&jp, callback_param);             
-               }
+         if (call_matches (pc, stmt))
+           {                   
+             struct aop_joinpoint jp;
+             init_joinpoint (&jp, &gsi, pc, stmt);
+             cb (&jp, callback_param);         
            }
        }
     }
 }
 
+static void
+op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
+                         void *callback_param)
+{
+  basic_block bb;
+
+  aop_assert (pc->kind == ATP_CALL);
+
+  FOR_EACH_BB(bb)
+    {
+      join_on_bb_function_call (bb, pc, cb, callback_param);
+    }
+}
+
+static void
+op_join_on_copy_function_call (struct aop_pointcut *pc, int copy,
+                              join_callback cb, void *callback_param)
+{
+  unsigned int pair_index;
+  bb_pair *pair;
+
+  aop_assert (is_current_func_duplicated ());
+  aop_assert (pc->kind == ATP_CALL);
+
+  FOR_EACH_BB_PAIR (bb_pairs, pair_index, pair)
+    {
+      basic_block bb = (copy == 0) ? pair->old : pair->new;
+
+      join_on_bb_function_call (bb, pc, cb, callback_param);
+    }
+}
+
 /**
  * Return a pointcut that matches all function calls.  Use filter
  * functions on the resulting pointcut to produce a pointcut that
@@ -178,6 +204,7 @@ aop_match_function_call ()
   pc = create_pointcut (ATP_CALL);
 
   pc->join_on = op_join_on_function_call;
+  pc->join_on_copy = op_join_on_copy_function_call;
 
   pc->pc_call.function_name = NULL;
   pc->pc_call.return_type = NULL;
index 6c6ff8c51fb98911c2e3a3bc42a2546c44abb906..e12966dec045cc89adaab6817ae67b1163315a46 100644 (file)
@@ -68,10 +68,10 @@ struct aop_pointcut {
   enum aop_pckind kind;
 
   void (*join_on) (struct aop_pointcut *, join_callback, void *);
+  void (*join_on_copy) (struct aop_pointcut *, int copy, join_callback, void *);
   insert_callback insert_before;
   insert_callback insert_after;
   
-
   /* prepare_for_weave() gets called once for each joinpoint before
      any advice gets inserted at that joinpoint.  */
   void (*prepare_for_weave) (struct aop_joinpoint *);
index 7a73d8045f75be17fb2b16b6c130c022f293d736..b555853218331e32fbce0111ceff3a487f9e275b 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -170,6 +170,8 @@ extern const struct aop_type *aop_t_all_pointer ();
 extern void aop_register_pass (const char *pass_name, pass_callback callback);
 extern void aop_join_on (struct aop_pointcut *pc, join_callback callback,
                         void *callback_param);
+extern void aop_join_on_copy (struct aop_pointcut *pc, int copy,
+                             join_callback callback, void *callback_param);
 extern void aop_main ();
 
 extern void aop_abort (const char *filename, int lineno, const char *function)