# "decompiled prolog"

**URL:** <https://swi-prolog.discourse.group/t/decompiled-prolog/729>\
**Category:** General\
**Created:** [May 26, 2019, 7:08pm UTC](https://swi-prolog.discourse.group/t/decompiled-prolog/729 "2019-05-26T19:08:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [May 26, 2019, 7:08pm UTC](https://swi-prolog.discourse.group/t/decompiled-prolog/729/1 "2019-05-26T19:08:49Z")

</div>

Hello,

As i review the performance of my Prolog code, i noticed that I don’t really understand what happens under the hood (trying to get my head around “The Craft of Prolog” by O’Keefe - doesn’t yet help me shed light onto this).

When i work with C / C++ i usually can see assembly code side-by-side during debugging., which sometimes is instructive.

Wouldn’t it be great to have something like this as well in Prolog as well.

Dan

---

<div class="post-metadata">

**Author:** ![barb](https://avatars.discourse-cdn.com/v4/letter/b/58956e/32.png) [@barb](https://swi-prolog.discourse.group/u/barb)\
**Post date:** [May 26, 2019, 9:15pm UTC](https://swi-prolog.discourse.group/t/decompiled-prolog/729/3 "2019-05-26T21:15:01Z")

</div>

An actual answer to your question (without the Spanish Inquisition) is to use  
vm\_list(Predicate\_name)

---

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [May 27, 2019, 3:21am UTC](https://swi-prolog.discourse.group/t/decompiled-prolog/729/4 "2019-05-27T03:21:23Z")

</div>

Hi Barb,

Thank you.

This is great.

It also lead me to a location in the manual I have never seen before.

Is there some documentation of the virtual machine instructions, and memory layout as well.

thank you,

Dan

---

<div class="post-metadata">

**Author:** ![grossdan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/grossdan/32/23_2.png) [@grossdan](https://swi-prolog.discourse.group/u/grossdan)\
**Post date:** [May 27, 2019, 3:32am UTC](https://swi-prolog.discourse.group/t/decompiled-prolog/729/5 "2019-05-27T03:32:40Z")

</div>

Hi Eric,

Thank you,

Since I am looking into optimization; i am in the realm of machine, and must take the inner machine workings into account.

Once I understand that, I can try to revise my declarative code, to make it more efficient, which comes from such an understanding of what the machine does under the hood with each Prolog idiom i am using.

thanks,

Dan

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [May 27, 2019, 7:13am UTC](https://swi-prolog.discourse.group/t/decompiled-prolog/729/6 "2019-05-27T07:13:08Z")

</div>

> [@grossdan](#):
>
> some documentation of the virtual machine instructions

Get the source and see `pl-vmi.c`. There you find `VMI(Name, ...)` and with some luck some explanation on what it does. You can also look at `pl-comp.c`, which provides the compiler that generates these things.

The VM started from \_ **Bowen _et al._ , 1983** D. L. Bowen, L. M. Byrd, and WF. Clocksin. A portable Prolog compiler. In L. M. Pereira, editor, _Proceedings of the Logic Programming Workshop 1983_ , Lisabon, Portugal, 1983. Universidade nova de Lisboa.\_ ([pdf](https://www.swi-prolog.org/download/publications/A_Portable_Prolog_Compiler.pdf))
