From: Justin Seyster Date: Wed, 10 Feb 2010 23:00:43 +0000 (-0500) Subject: Filled in aop_join_on for assignment pointcuts. X-Git-Tag: release-v1.0~124 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=0e5b3534982358465f1bc8c5f1dc5e278bb10bb5;p=interaspect.git Filled in aop_join_on for assignment pointcuts. Added joinpoint data structure. --- diff --git a/src/aop-pc-assign.c b/src/aop-pc-assign.c index 048599c..7912732 100644 --- a/src/aop-pc-assign.c +++ b/src/aop-pc-assign.c @@ -23,15 +23,56 @@ #include #include +#include +#include +#include #include +#include +#include #include "aop.h" #include "aop-pointcut.h" +#include "aop-type.h" + +static bool +stmt_matches_pointcut (struct aop_pointcut *pc, gimple stmt) +{ + if (gimple_has_lhs (stmt)) + { + tree type = TREE_TYPE (gimple_get_lhs (stmt)); + return does_type_match (type, pc->pc_assign.type); + } + else + { + return false; + } +} static void op_join_on_assign (struct aop_pointcut *pc, join_callback cb) { - aop_assert(pc->kind == ATP_ASSIGN); + basic_block bb; + + aop_assert (pc->kind == ATP_ASSIGN); + + FOR_EACH_BB(bb) + { + gimple_stmt_iterator gsi; + + for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + + if (stmt_matches_pointcut (pc, stmt)) + { + struct aop_joinpoint jp; + jp.pc = pc; + jp.gsi = &gsi; + + cb (&jp); + } + } + } } struct aop_pointcut * diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h index 82beda8..fae1b39 100644 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@ -28,6 +28,12 @@ struct aop_pc_assign { struct aop_type *type; }; +/* An AOP pointcut represents the a set of joinponts: locations in the + source code that are available for inserting instrumentation. + + In practice, we do not directly store the set of joinpoints. + Instead, we store a description of the set that a join function can + use to find matching joinpoints. */ struct aop_pointcut { enum aop_pckind kind; @@ -38,4 +44,17 @@ struct aop_pointcut { }; }; +/* An AOP joinpoint represents a specific location in the code where + it is possible to insert instrumentation. Because joinpoints are + passed to do_weave functions, they must have all the information + necessary to directly add a hook function. */ +struct aop_joinpoint { + /* The pointcut that this joinpoint is a member of. */ + struct aop_pointcut *pc; + + /* A GCC iterator for where weave functions can insert their + instrumentation.*/ + gimple_stmt_iterator *gsi; +}; + #endif diff --git a/src/aop-type.c b/src/aop-type.c index a7e6587..3c31ae7 100644 --- a/src/aop-type.c +++ b/src/aop-type.c @@ -12,8 +12,21 @@ along with this program. If not, see . */ +/* Whether we want them or not (we don't), Autoconf _insists_ on + defining these. Since GCC's config.h (which we must include) also + defines them, we have to undef them here. */ +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + #include +#include +#include +#include + #include "aop-type.h" static struct aop_type _aop_t_all_signed = { @@ -63,3 +76,10 @@ aop_t_all_pointer () { return &_aop_t_all_pointer; } + +/* Match an actual GCC type with an AOP type specification. */ +bool +does_type_match (tree gcc_type, struct aop_type *aop_type) +{ + return true; +} diff --git a/src/aop-type.h b/src/aop-type.h index d4c6c86..66607fb 100644 --- a/src/aop-type.h +++ b/src/aop-type.h @@ -35,4 +35,6 @@ struct aop_type { const char *tag; }; +bool does_type_match (tree gcc_type, struct aop_type *aop_type); + #endif diff --git a/src/aop.h b/src/aop.h index 134c4f8..ccd67bf 100644 --- a/src/aop.h +++ b/src/aop.h @@ -47,11 +47,12 @@ #define aop_assert(EXPR) ((void)(0 && (EXPR))) #endif +struct aop_joinpoint; struct aop_pointcut; struct aop_type; typedef unsigned int (*pass_callback) (); -typedef void (*join_callback) (); +typedef void (*join_callback) (struct aop_joinpoint *); extern struct aop_pointcut *aop_match_assignment_by_type (struct aop_type *type);