As far as I understand it:
1. The optimizing compiler (written in Factor) generates raw machine code
that is saved in an "image file":
http://docs.factorcode.org/content/article-images.html (more about the
voodoo of bootstrapping image files:
http://factor-language.blogspot.com/2010/01/factors-bootstrap-process-explained.html
)
2. The VM's job is to load & execute the image file contents, along with
handling primitve stuff like garbage collection. When installing Factor,
you'll compile the C++ VM into a binary on your machine (check out the
Makefile: https://github.com/slavapestov/factor/blob/master/GNUmakefile).
3. To generate a standalone executable, you use the tools.deploy
vocabulary: http://docs.factorcode.org/content/article-tools.deploy.html
This creates a binary by embedding the image file of your compiled code
into the compiled VM executable. I'm fuzzy on the details, but it seems to
just straight-up copy the contents of the binary image file into a "magic"
spot where the VM executable will know to look:
https://github.com/slavapestov/factor/blob/fe2c2d23de9e300d7cd1b04e139dfbdd2069d00a/vm/image.hpp
&
https://github.com/slavapestov/factor/blob/master/basis/tools/deploy/embed/embed.factor
The deploy tool does some other fancy stuff, like trying to minimize the
total image size using the "shaker":
http://factor-language.blogspot.com/2007/06/generating-minimal-images-deploying.html
So, short answer: Factor's standalone executables are copies of the VM
executable (itself fairly small) + your compiled code.
Hope that helps,
--Alex Vondrak
On Sat, Feb 28, 2015 at 2:15 PM, <relm...@rambler.ru> wrote:
> Hello! I'm very interested in Factor. I don't quite understand how
> Factor's native code compiler works, so I'd like to ask some questions
> about it. Can factor code run on bare metal (without operating system)? How
> does the compiler generate standalone executables? Factor has a VM code
> written in C++, how does the compiler links C++ code with compiled Factor
> code? Or the VM is only used in Factor's interactive tools and all the code
> that gets compiled into standalone executable is written in Factor? If so
> how is low level stuff like GC can be implemented in Factor code?
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk