1 / 17

Cflow in AOFL

Cflow in AOFL. Outline. Syntax for cflow and cflowbelow Composition, logical operations Type-scoped cflow Impact Formal proof/semantics Compilation Translation Lifting functions to monadic space Discussion. Syntax (Basic). n@advice around {k+cflow(f)} (arg) And with “ + ”

mimi
Download Presentation

Cflow in AOFL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cflow in AOFL

  2. Outline • Syntax for cflow and cflowbelow • Composition, logical operations • Type-scoped cflow • Impact • Formal proof/semantics • Compilation • Translation • Lifting functions to monadic space • Discussion

  3. Syntax (Basic) • n@advice around {k+cflow(f)} (arg) • And with “+” • n@advice around {k+cflowbelow(f)} • cflowbelow works better with “Not” • {k - cflowbelow(f)}

  4. Syntax (Composition) • And-ing by concatenation • n@advice around {k+cflow(g)+cflow(h)} (arg) • Or-ing joinpoints by “,” • Only on top level • Like DNF (disjunctive normal form) • Can be treated like two different advices • {k+cflow(g), k+cflow(f)}

  5. Syntax (Type-Scoped Cflow) • Not only under the cflow, also the calling type should match • n@advice around {k+cflow(f@ _ :: Int)} • Syntactic sugar: translated to • n_1@advice around {f} (arg :: Int) = proceed arg • n_2@advice around {k+cflow(n_1)}

  6. Modification of Formal Things • Ignoring cflow in pointcut when testing if an advise should apply on a function • Add formal semantics for cflow • Reduction rule

  7. Modification of Compiling Process • Pointcut data structure changed, related functions have to be changed • Already done (w/o type-scoped cflow) • Modifying IL tree • After IL generation • Implemented as a pass of compiler • Evaluator • Reduction of guarded advise

  8. Translation – Big Picture • Put functions in monadic space • Bind it when calling • Left predefined operation unchanged • Reader monad: • newtype Reader e a = Reader { runReader :: (e -> a) } • Feed the context, give the answer • return a = Reader $ \e -> a • Only (\e -> a) in IL

  9. Translation – Basic Blocks • local f c = Reader $ \e -> runReader c (f e) • (\e -> c (f e)) in IL • ask = Reader id • asks sel = ask >>= return . sel • (\e -> sel e) in IL • We can record functions in the stack, i.e. the cflows currently in

  10. Translation – Basic Blocks (cont.) • type Env = • [String] : list of function names • Set String • String -> Bool • bit map (instance of class Bits) • type EnvReader a = Reader Env a

  11. Translation – Functions & Advices • f :: forall a1 a2… an. P => t1 -> t2 • f arg = {expression} • wrapped_f :: forall a1 a2… an. P => EnvReader (t1 -> t2) • wrapped_f = local (cflowEnter “f”) $ Reader $ \e -> \arg -> runReader {expression’} e

  12. Translation – Functions & Advices (cont.) • {expression’}: translated expression • Not change the names of functions • No change on joinpoint • No change on invocation • cflowEnter :: String -> Env -> Env • [String] => name : env • Set => insert name env • Bit map => setBit env offset_of_f

  13. Translation – Expressions • “Return”-ing outer most expression • Functions calls • Get a temporary variable, bind the function on it and replace the call with it • Predefined operations unchanged f (g 1) 2 ~> g >>= \g’-> f >>= \f’-> return $ f’ (g’ 1) 2 if x == 1 then x else x + 1 ~> return $ if x == 1 then x else x + 1 unchanged

  14. Translation – Advices in Chain • cflow-conditioned advice has a non-constant guard • n@advice around {k+cflowbelow(f)} ~> «asks (cflowIn “f”), n» • cflowIn • [String] => name `elem` env • Set => name `member` env • Bit map => testBit offset_of_f env • “And”-ed condition: and-ing asks

  15. Translation – Main Expression • Let the modified main expression be “expr” • runReader (expr) emptyEnv • emptyEnv • [String] => [] • Set => empty • Bit map => all bit unset

  16. Discussion • Translated IL of n@advice{k+cflowbelow(f)} • call(* k(*)) && cflow(execute(* f(*))) • Semantically equivalent tocall(* k(*)) && cflowbelow(call(* f(*))) • cflow vs. cflowbelow • Only different when the advised functions and cflowed functions intersects • cflow(call (* f(*)) = cflowbelow(call(* f(*))) || call(* f(*)) • Can implements cflow by cflowbelow

  17. Discussion (cont.) • Type of Env • [String]: easy for hand-writing • Map: better performance • Bit map: best performance, prevent incremental weaving

More Related