The "VM" is not an interpreter, but rather a compiled set of builtin objects
(quotation, byte array, strings, bignum), garbage collection, and primitive
methods (a lot of which is math related and other stuff like supporting the
FFI) and functionality that is exposed to bootstrap the system.
We have an optimizing compiler that generates pretty efficient machine code
from the Factor code. When it encounters a primitive, it's basically just a C
function call to that method in the VM.
Alex Vondrak wrote a bunch of compiler improvements as part of his thesis work
on "Global Value Numbering in Factor". You might find some parts of his paper
useful in describing how it works.
https://github.com/ajvondrak/thesis/raw/master/thesis.pdf
In addition there is a bunch of documentation for the compiler in the normal
places:
http://docs.factorcode.org/content/article-compiler.html
Thanks!
John.
> On Sep 15, 2015, at 3:22 AM, Alexander Ilin <[email protected]> wrote:
>
> Hi, John!
>
> I see, those "primitives" have roots in the C++ VM implementation.
>
> This leads me to another question that I've been wanting to ask for a while
> now.
> In Slava's Google Talk I heard him explaining how Factor is a compiled
> language, and has great performance (the fractals demo). How does that
> statement relate to the fact that there is a VM involved (presumably, with an
> interpreter)? Is there a whitepaper on the Factor architecture you could
> refer me to?
>
> 15.09.2015, 12:49, "John Benediktsson" <[email protected]>:
>> Hi Alexander,
>>
>> The "primitive registration system" is a little more involved than
>> PRIMITIVE: but we defined that as syntax so we could grep and keep track of
>> our primitives better and as a placeholder for some future cleanup.
>>
>> When you make a new "primitive", it needs several things including this in
>> Factor (which we hope PRIMITIVE: will replace someday):
>>
>> * core/bootstrap/primitives.factor (make-primitive)
>> * basis/stack-checker/known-words/known-words.factor (define-primitive)
>>
>> And this in the VM:
>>
>> * vm/vm.hpp (defined)
>> * vm/primities.hpp (exported)
>> * vm/*.cpp (implemented)
>>
>> We have an issue for improving this, although we won't likely get to it
>> right away:
>>
>> https://github.com/slavapestov/factor/issues/1134
>>
>> Thanks,
>> John.
>>
>>> On Tue, Sep 15, 2015 at 2:03 AM, Alexander Ilin <[email protected]> wrote:
>>> Hello!
>>>
>>> I was looking at some words, like <wrapper>, and I saw PRIMITIVE:
>>>
>>> IN: scratchpad \ <wrapper> see
>>> IN: kernel
>>> PRIMITIVE: <wrapper> ( obj -- wrapper ) foldable flushable
>>>
>>> But when I tried to look up PRIMITIVE:, here's what I saw:
>>>
>>> If I do IN: scratchpad \ PRIMITIVE: see
>>> USING: kernel ;
>>> IN: syntax
>>> SYNTAX: PRIMITIVE:
>>> "Primitive definition is not supported" throw ;
>>>
>>> Is this the actual definition of PRIMITIVE:? To throw an error? How can
>>> the <wrapper> work then?
>>>
>>> If it is not the actual definition, please help me find the real one.
>>>
>>> ---=====---
>>> Александр
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Factor-talk mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>> ,
>>
>> ------------------------------------------------------------------------------
>> ,
>>
>> _______________________________________________
>> Factor-talk mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
> ---=====---
> Александр
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk