# VM kinds

- Thread: https://externals.io/message/116310
- Original archive: https://news-web.php.net/php.internals/116310
- Started by Tim Starling on 2021-11-10T07:12:45+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #116310 — Tim Starling — 2021-11-10T07:12:45+00:00

URL: https://externals.io/message/116310#116310

What are VM kinds for? Are they just a prototyping tool to allow
different implementation strategies to be benchmarked? Or are they
permanent? Does anyone use them?

I ask because I'm working on a VM bug, and non-default VM kinds make
already complex code even more complex and harder to edit.

-- Tim Starling

---

## #116311 — Nikita Popov — 2021-11-10T08:35:07+00:00

URL: https://externals.io/message/116310#116311 · In reply to: #116310

On Wed, Nov 10, 2021 at 8:13 AM Tim Starling <tstarling@wikimedia.org>
wrote:

> What are VM kinds for? Are they just a prototyping tool to allow
> different implementation strategies to be benchmarked? Or are they
> permanent? Does anyone use them?
>
> I ask because I'm working on a VM bug, and non-default VM kinds make
> already complex code even more complex and harder to edit.
>
> -- Tim Starling
>

I don't think anyone uses them, and the GOTO/SWITCH VMs receive little
testing in practice (we don't use them in CI), and I believe they're not
supported by the JIT either. Personally, I would be fine with simply
dropping them, as they do add additional maintenance burden without any
apparent benefit. Maybe Dmitry has some thoughts on this.

Regards,
Nikita

---

## #116313 — Dmitry Stogov — 2021-11-10T09:10:34+00:00

URL: https://externals.io/message/116310#116313 · In reply to: #116311

I prefer to keep GOTO and SWITCH VMs. It's easy to drop something, but it's
going to be much more complex to reimplement it again.

Note that HYBRID VM (based on CALL and GOTO VMs) was introduced only in
PHP-7.2, because GOTO was already implemented a long time ago. In the
future, it's possible to extend HYBRID VM, to make it work with
GCC-incompatible compilers through SWITCH. We might also like to move from
direct-threaded to indirect-threaded dispatch.

Thanks. Dmitry.



> On Wed, Nov 10, 2021 at 8:13 AM Tim Starling <tstarling@wikimedia.org>
> wrote:
>
> > […]
>
> I don't think anyone uses them, and the GOTO/SWITCH VMs receive little
> testing in practice (we don't use them in CI), and I believe they're not
> supported by the JIT either. Personally, I would be fine with simply
> dropping them, as they do add additional maintenance burden without any
> apparent benefit. Maybe Dmitry has some thoughts on this.
>
> Regards,
> Nikita

---

## #116319 — Tim Starling — 2021-11-11T07:20:21+00:00

URL: https://externals.io/message/116310#116319 · In reply to: #116313

OK, thanks for the answer.

My PR is up now, with a fixme comment for the GOTO and SWITCH VMs. I'm
still not sure how to make them work.

https://github.com/php/php-src/pull/7642

-- Tim Starling


> I prefer to keep GOTO and SWITCH VMs. It's easy to drop something,
> but it's going to be much more complex to reimplement it again.
>
> Note that HYBRID VM (based on CALL and GOTO VMs) was introduced only
> in PHP-7.2, because GOTO was already implemented a long time ago. In
> the future, it's possible to extend HYBRID VM, to make it work with
> GCC-incompatible compilers through SWITCH. We might also like to
> move from direct-threaded to indirect-threaded dispatch.
>
> Thanks. Dmitry.
>
> On Wed, Nov 10, 2021 at 11:35 AM Nikita Popov <nikita.ppv@gmail.com
> <mailto:nikita.ppv@gmail.com>> wrote:
>
>     On Wed, Nov 10, 2021 at 8:13 AM Tim Starling
>     <tstarling@wikimedia.org <mailto:tstarling@wikimedia.org>>
>     wrote:
>
> > […]
>     kinds make
> > […]
>
>     I don't think anyone uses them, and the GOTO/SWITCH VMs receive
>     little
>     testing in practice (we don't use them in CI), and I believe
>     they're not
>     supported by the JIT either. Personally, I would be fine with simply
>     dropping them, as they do add additional maintenance burden
>     without any
>     apparent benefit. Maybe Dmitry has some thoughts on this.
>
>     Regards,
>     Nikita
