C++/Java: Don't use type size in object allocation
Bryce McKinlay
mckinlay@redhat.com
Fri Apr 16 12:44:00 GMT 2004
Per Bothner wrote:
> Bryce McKinlay wrote:
>
>> Currently, calls to the Java object allocation routines (eg
>> _Jv_AllocObject) pass both a class parameter and a size parameter.
>> Hard coding the size parameter at the call site contradicts binary
>> compatibility, since the size of the object being created may change
>> at runtime. Even without binary compatibility, passing the size
>> parameter is redundant because the size of the type can be trivially
>> obtained from class metadata.
>
>
> I think the reason was so _Jv_AllocObject could also be used to allocate
> arrays. As long as arrays no longer use _Jv_AllocObject, it's fine to
> remove the size perhaps.
Right, array allocation uses a different set of calls:
_Jv_New{...}Array. The only other case where size matters is for String
objects where the char array is inlined into the String, but we have
_Jv_AllocString() for those.
Regards
Bryce.
More information about the Java-patches
mailing list