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: PATCH: [4.1 Regression]: java compiler generates wrong code onia64


H. J. Lu wrote:

On Mon, Apr 18, 2005 at 12:34:04PM -0700, H. J. Lu wrote:


On Mon, Apr 18, 2005 at 12:16:10PM -0700, H. J. Lu wrote:


On Mon, Apr 18, 2005 at 03:03:02PM -0400, Bryce McKinlay wrote:


H. J. Lu wrote:



The function pointers in the GCJ method metadata (_Jv_Method) are always local, except in the case of CNI functions. But, even local function references in a .so will point at PLT entries if the function is also referenced from the main binary.




Whan you said "local function", did you mean

1. A local data variable with function type. Or
2. A function symbol which isn't visible to the outside. Or
3. A global data variable with function type pointing to a local
function.

I ran into a very tricky issue. But I don't have a testcase. This
problem may be related.




I mean "a reference to a function which is public (visible to the outside) and defined within the same compilation unit"


That makes senses now. For me, "local function" means a different
thing :-). If you want to know if a function will be bound locally
at the run time, you should use targetm.binds_local_p. I think this
patch is correct.


H.J. --- 2005-04-18 H.J. Lu <hongjiu.lu@intel.com>

	PR java/21070
	* class.c (make_local_function_alias): Use targetm.binds_local_p
	to check if a function is bound locally.



Second thought. Since you can only create an aliase for a symbol
defined within the same file, targetm.binds_local_p alone may not be
suitable for this purpose.




I am not familiar with Java semantics. targetm.binds_local_p will tell you if a function may be discarded at the link time or overriden by something else at the run time. If a function is public and defined within the same compilation unit, it can be discarded at the link time due to linkonce/comdat and can be overriden by dynamic linker. If it is discarded or overriden, does a local alias make any more senses for Java? It seems that

 if (DECL_EXTERNAL (method) || !targetm.binds_local_p (method))
   return method;

will make sure that an aliase will only be created when the function
is defined within the compilation unit and won't be discarded or
overriden.



Well, this is certainly the behaviour we would like for Java, but AFAIK we have no way to ensure that something always binds locally.


binds_local_p is described as:

 /* True if EXP names an object for which name resolution must resolve
    to the current module.  */

It seems to me that, given ELF semantics, a public symbol can always be overriden by the linker at runtime, thus targetm.binds_local_p will always be false? If there was some way to force targetm.binds_local_p then we wouldn't need make_local_function_alias()!

Bryce


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