59:
The purpose of compiling Prolog code to the more low-level WAM code is to make subsequent interpretation of the Prolog program more efficient. Prolog code is reasonably easy to translate to WAM instructions, which can be more efficiently interpreted. Also, subsequent code improvements and
63:
In order to write efficient Prolog programs, a basic understanding of how the WAM works can be advantageous. Some of the most important WAM concepts are first argument indexing and its relation to choice-points,
482:
An important characteristic of this code is its ability to cope with the various modes in which the predicates can be evoked: any argument might be a variable, a
521:
620:
539:
513:
573:
558:
610:
605:
615:
65:
172:
A WAM-based Prolog compiler will compile this into WAM instructions similar to the following:
60:
compilations to native code are often easier to perform on the more low-level representation.
8:
504:
552:
486:, or a partly instantiated term. The "switch" instructions handle the different cases.
20:
517:
574:"Warren's Abstract Machine: A Tutorial Reconstruction; the book, errata and slides"
32:
24:
36:
599:
483:
102:
to record which variables bindings ought to be undone on backtracking
48:
577:
28:
541:
Warren's
Abstract Machine: A Tutorial Reconstruction
502:
597:
537:
16:Abstract machine for the execution of Prolog
571:
547:. Archived from the original on 2003-02-13.
95:for environment frames and choice-points
76:The WAM has the following memory areas:
598:
538:Hassan Aït-Kaci (February 18, 1999).
68:, and memory reclamation on failure.
503:David H. D. Warren (October 1983).
13:
506:An abstract Prolog instruction set
39:. This design became known as the
14:
632:
527:from the original on 2022-06-19.
111:Here is a piece of Prolog code:
71:
565:
531:
514:Artificial Intelligence Center
496:
88:, used to store compound terms
1:
489:
7:
47:standard target for Prolog
10:
637:
621:SRI International software
106:
54:
557:: CS1 maint: unfit URL (
43:(WAM) and has become the
174:
113:
512:. Menlo Park, CA, USA:
41:Warren Abstract Machine
66:tail call optimization
27:for the execution of
35:architecture and an
580:on 19 January 2022
333:trust_me_else_fail
21:David H. D. Warren
611:Abstract machines
606:Logic programming
572:Hassan Aït-Kaci.
518:SRI International
441:unify_local_value
628:
616:Virtual machines
590:
589:
587:
585:
576:. Archived from
569:
563:
562:
556:
548:
546:
535:
529:
528:
526:
511:
500:
478:
475:
472:
469:
466:
463:
460:
457:
454:
451:
448:
445:
442:
439:
436:
433:
430:
427:
424:
421:
418:
415:
412:
409:
406:
403:
400:
397:
394:
391:
388:
385:
382:
379:
376:
373:
370:
367:
364:
361:
358:
355:
352:
349:
346:
343:
340:
337:
334:
331:
328:
325:
322:
319:
316:
313:
310:
307:
304:
301:
298:
295:
292:
289:
286:
283:
280:
277:
274:
271:
268:
265:
262:
259:
256:
253:
250:
247:
244:
241:
238:
235:
232:
229:
226:
223:
220:
217:
214:
211:
208:
205:
202:
199:
196:
193:
190:
187:
184:
181:
178:
168:
165:
162:
159:
156:
153:
150:
147:
144:
141:
138:
135:
132:
129:
126:
123:
120:
117:
31:consisting of a
25:abstract machine
636:
635:
631:
630:
629:
627:
626:
625:
596:
595:
594:
593:
583:
581:
570:
566:
550:
549:
544:
536:
532:
524:
509:
501:
497:
492:
480:
479:
476:
473:
470:
467:
464:
461:
458:
455:
452:
449:
446:
443:
440:
437:
434:
431:
428:
425:
422:
419:
416:
413:
410:
407:
404:
401:
398:
395:
392:
389:
386:
383:
380:
377:
374:
371:
368:
365:
362:
359:
356:
353:
350:
347:
344:
341:
338:
335:
332:
329:
326:
323:
320:
317:
314:
311:
308:
305:
302:
299:
296:
293:
290:
287:
284:
281:
278:
275:
272:
269:
266:
263:
260:
257:
254:
251:
248:
245:
242:
239:
236:
233:
230:
227:
224:
221:
218:
215:
212:
209:
206:
203:
200:
197:
194:
191:
188:
185:
182:
179:
176:
170:
169:
166:
163:
160:
157:
154:
151:
148:
145:
142:
139:
136:
133:
130:
127:
124:
121:
118:
115:
109:
74:
57:
37:instruction set
17:
12:
11:
5:
634:
624:
623:
618:
613:
608:
592:
591:
564:
530:
494:
493:
491:
488:
249:switch_on_atom
198:switch_on_term
175:
114:
108:
105:
104:
103:
96:
89:
73:
70:
56:
53:
15:
9:
6:
4:
3:
2:
633:
622:
619:
617:
614:
612:
609:
607:
604:
603:
601:
579:
575:
568:
560:
554:
543:
542:
534:
523:
519:
515:
508:
507:
499:
495:
487:
485:
417:put_structure
173:
112:
101:
97:
94:
90:
87:
83:
79:
78:
77:
69:
67:
61:
52:
50:
46:
42:
38:
34:
30:
26:
22:
582:. Retrieved
578:the original
567:
540:
533:
505:
498:
481:
393:get_variable
171:
110:
99:
92:
85:
82:global stack
81:
75:
72:Memory areas
62:
58:
44:
40:
23:designed an
18:
484:ground term
270:try_me_else
93:local stack
600:Categories
490:References
553:cite book
372:predicate
177:predicate
49:compilers
19:In 1983,
522:Archived
351:get_atom
297:get_atom
45:de facto
584:7 March
459:execute
369:proceed
315:proceed
107:Example
55:Purpose
33:memory
29:Prolog
545:(PDF)
525:(PDF)
510:(PDF)
336:label
318:label
303:sally
282:label
255:label
234:label
122:sally
100:trail
586:2011
559:link
423:girl
357:jane
228:fail
222:fail
216:fail
183:girl
158:girl
134:jane
128:girl
116:girl
98:The
91:The
86:heap
80:The
516:at
477:)])
378:boy
140:boy
84:or
602::
555:}}
551:{{
520:.
465:\+
462:((
456:))
408:),
252:()
231:),
167:).
155:\+
152::-
137:).
125:).
51:.
588:.
561:)
474:1
471:/
468:)
453:1
450:(
447:x
444:(
438:)
435:0
432:,
429:1
426:/
420:(
414:)
411:0
405:1
402:(
399:x
396:(
390::
387:)
384:1
381:/
375:(
366:)
363:0
360:,
354:(
348::
345:)
342:5
339:(
330::
327:)
324:4
321:(
312:)
309:0
306:,
300:(
294::
291:)
288:3
285:(
279:)
276:4
273:(
267::
264:)
261:2
258:(
246::
243:)
240:1
237:(
225:,
219:,
213:,
210:1
207:,
204:2
201:(
195::
192:)
189:1
186:/
180:(
164:B
161:(
149:)
146:B
143:(
131:(
119:(
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.