Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Neng-Fa Zhou1 From WAM to ATOAM 4 WAM (Warren Abstract Machine) –de facto standard Prolog machine –Indexing on one argument –Parameter passing through.

Similar presentations


Presentation on theme: "By Neng-Fa Zhou1 From WAM to ATOAM 4 WAM (Warren Abstract Machine) –de facto standard Prolog machine –Indexing on one argument –Parameter passing through."— Presentation transcript:

1 by Neng-Fa Zhou1 From WAM to ATOAM 4 WAM (Warren Abstract Machine) –de facto standard Prolog machine –Indexing on one argument –Parameter passing through registers 4 ATOAM (Another Tree-Oriented Abstract Machine) –Matching trees –Parameter passing through frames –Facilitates software emulation

2 by Neng-Fa Zhou The WAM Architecture P code area A1 A2... An registers s E stackheap trail HT B

3 by Neng-Fa Zhou3 The WAM Frame Structures Parent CP Y1 … Yn Environment frame Am … A1 HB H T B E CPF CP Choice point frame Head:-G1,G2. Head:-B1. Head:-B2.

4 by Neng-Fa Zhou4 Parameter Passing in WAM Caller’s environment Callee’s choice point Callee’s environment

5 by Neng-Fa Zhou5 Compilation for the WAM member(X,[X|_]). member(X,[_|L):- member(X,L). member/2: try_me_else C2,2 get_list A2 unify_value A1 unify_var A1 proceed C2:trust_me 2 get_list A2 unify_var X3 unify_var A2 execute member/2

6 by Neng-Fa Zhou The ATOAM Architecture P code area X1 X2... Xn registers s AR stackheap trail HT TOP

7 by Neng-Fa Zhou7 The ATOAM Architecture for Determinate Programs 4 Frame structure 4 Registers –AR: Parent’s frame –CP: Continuation PC –TOP: Top of the stack 4 The trail stack is not used

8 by Neng-Fa Zhou8 The ATOAM Architecture for Nondeterminate Programs 4 Frame structure 4 Registers –B: The latest choice point frame –HB: same as B->H 4 The trail stack –Updates of variables need be saved if the variables are older than B or HB Machine status

9 by Neng-Fa Zhou9 Matching Trees p(A1,[0,1]):-true ? true. p(A1,[0,0]):-true ? true. p(A1,A2):-A1>0 : q(A1,A2). P/3: allocate_nondet 8 jmpn_list y(1), L1 fetch_var y(-7) % car fetch_var y(-8) % cdr jmpn_eq_int y(-7),0,L1 jmpn_list y(-8), L1 fetch_var y(-7) fetch_var y(-8) jmpn_eq_int y(-7),1,L0 jmpn_eq_atom y(-8),[],L1 fork L1 return_b L0:jmpn_eq_int y(-7),0,L1 jmpn_eq_atom y(-8),[],L1 fork L1 return_b L1:move_int x(1),0 jmpn_gt y(2),x(1),cut_fail cut execute q/2

10 by Neng-Fa Zhou10 Performance Comparison As of April 2003

11 by Neng-Fa Zhou11 Papers 1.N.F. Zhou: Global Optimizations in a Prolog Compiler for the TOAM, Journal of Logic Programming, pp.275-294, 1993. 2.N.F. Zhou: Parameter Passing and Control Stack Management in Prolog Implementation Revisited, ACM Transactions on Programming Languages and Systems, Vol18, No6, pp.752-779, 1996. 3.N.F Zhou: A High-Performance Abstract Machine for Prolog and its Extensions, CUNY Computer Science, TR2003014, 2003.


Download ppt "By Neng-Fa Zhou1 From WAM to ATOAM 4 WAM (Warren Abstract Machine) –de facto standard Prolog machine –Indexing on one argument –Parameter passing through."

Similar presentations


Ads by Google