On Oct 7, 2011, at 10:07 AM, Evan Phoenix wrote:
> On Friday, October 7, 2011 at 12:44 AM, KOSAKI Motohiro wrote:
>>>> No, it isn't. MVM-aware extensions shall obey the MVM-safe APIs.
>>>>=20
>>>> But MVM-unaware extensions are OK if and only if the whole ruby
>>>> process don't use MVM features at all. And even if you don't
>>>> touch MVM things, binary compatibility is broken. Recompilation
>>>> is mandatory for everything.
>>>=20
>>> So, MVM will not be part of 2.0? Cause Matz said breaking even =
binary compatibility would not be an option...
>>=20
>> If ruby code doesn't use MVM APIs, we can't see any incompatibility.
>> IOW, it is binary api addtion, but it is not binary api change.
> So therefore using MVM and current C extensions would be mutually =
exclusive. I'd expect that if the MVM API was used, it would set a flag =
that would prohibit any C extensions with the current API from being =
loaded. Also, if a C extension using the current API is loaded, a flag =
should be set which would raise an exception if the MVM API were used.=20=

>=20
> Without these checks, it's trivial for users to crash the process. =
This confuses the users and creates more work for ruby-core, since =
ruby-core then has to educate people on how you can use MVM.

I spoke with Evan about this and we had the following ideas:

If an extension has InitVM_foo() it should not need to define =
Init_foo().

Ruby should always attempt to be MVM-capable.

Ruby should try to load extensions using InitVM_foo() before trying =
Init_foo().

If an extension does not have InitVM_foo() and only one VM has been =
spawned, Init_foo() is used and the current process is marked as =
Single-VM only (SVM).

When ruby is in SVM mode, if a users tries to spawn a separate VM they =
get an exception that explains which extension is not MVM-capable:

  old_style_extension.so is not MVM-capable (SpawnError)

If a VM is spawned (ruby enters MVM mode) and an the user tries to load =
an extension that is not MVM-safe (no InitVM_foo()) a LoadError is =
raised by require/load:

  old_style_extension.so is not MVM-capable (LoadError)

A command-line argument or run-time attribute could be used to force =
ruby into MVM mode.  (maybe ruby -m)=