1 / 11

From WAM to ATOAM

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

Jims
Download Presentation

From WAM to ATOAM

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. From WAM to ATOAM • WAM (Warren Abstract Machine) • de facto standard Prolog machine • Indexing on one argument • Parameter passing through registers • ATOAM (Another Tree-Oriented Abstract Machine) • Matching trees • Parameter passing through frames • Facilitates software emulation by Neng-Fa Zhou

  2. The WAM Architecture registers code area A1 A2 ... An s P H T stack heap trail E B by Neng-Fa Zhou

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

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

  5. 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 by Neng-Fa Zhou

  6. The ATOAM Architecture registers code area X1 X2 ... Xn s P AR stack H heap T trail TOP by Neng-Fa Zhou

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

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

  9. 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 by Neng-Fa Zhou

  10. Performance Comparison As of April 2003 by Neng-Fa Zhou

  11. Papers • N.F. Zhou: Global Optimizations in a Prolog Compiler for the TOAM, Journal of Logic Programming, pp.275-294, 1993. • 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. • N.F Zhou: A High-Performance Abstract Machine for Prolog and its Extensions, CUNY Computer Science, TR2003014, 2003. by Neng-Fa Zhou

More Related