Labels as values and threaded-code interpretation

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Jun 2 13:15:32 PDT 2013


02-Jun-2013 22:25, Alex Rønne Petersen пишет:
> On 02-06-2013 19:58, Dmitry Olshansky wrote:
>>>
>>> The problem here is assuming the interpreter state can be global. Once
>>> you make it non-global (and thus have to pass it in the goto start(...)
>>> call) you get all the overhead of a regular function call.
>>>
>>
>> One pointer to a struct MyInterpreterState. Think of it as 'this'
>> pointer :)
>
> That's one load and store for every single step in the interpreter.
> Sounds harmless, but every cycle matters when every goto start(...)
> amounts to a single instruction in the program you're running.
>
>> Anyhow cramming the whole interpreter in one huge function too has
>> downsides (and hopelessly inefficent register allocation is one).
>
> I'd frankly be surprised if that was the case. But without any
> investigation, it's just word against word.

See my reply to Walter. Again I personally have not done any 
measurements but what that post by LuaJIt author makes a lot of sense to me.

>
>> And you still access most locals via stack pointer. And then there got
>> to be something beyond locals - 'context', that is still passed from one
>> bytecode execution to another.
>
> It depends on what you mean by context. Can you elaborate?
>

Context is what a virtual thread represents in the global world. Any 
outside hooks into it like argv in C's main are there, function tables 
(=extensions) and whatnot.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list