This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++/Java: Don't use type size in object allocation


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]