public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch libjava]: Fix PR target/51500
@ 2012-01-29 14:15 Kai Tietz
  2012-01-30 10:16 ` Andrew Haley
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Tietz @ 2012-01-29 14:15 UTC (permalink / raw)
  To: GCC Patches

Hello,

this patch adds thiscall-call feature via libffi for 32-bit Windows
native target.

ChangeLog

2012-01-29  Kai Tietz  <ktietz@redhat.com>

	PR target/51500
	* interpret.cc (_Jv_init_cif): Handle thiscall
	convention for 32-bit Windows.
	* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA):
	Likewise.
	* java/lang/reflect/natVMProxy.cc (ncode): Force SYSV
	closure for 32-bit Windows.
	(invoke_t): Add thiscall-attribute for 32-bit Windows.

Patch tested for i686-w64-mingw32, i686-pc-cygwin, and
x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Index: gcc/libjava/interpret.cc
===================================================================
--- gcc.orig/libjava/interpret.cc
+++ gcc/libjava/interpret.cc
@@ -1303,7 +1303,12 @@ _Jv_init_cif (_Jv_Utf8Const* signature,
   if (ptr != (unsigned char*)signature->chars() + signature->len())
     throw_internal_error ("did not find end of signature");

-  if (ffi_prep_cif (cif, FFI_DEFAULT_ABI,
+  ffi_abi cabi = FFI_DEFAULT_ABI;
+#if defined (X86_WIN32) && !defined (__CYGWIN__)
+  if (!staticp)
+    cabi = FFI_THISCALL;
+#endif
+  if (ffi_prep_cif (cif, cabi,
 		    arg_count, rtype, arg_types) != FFI_OK)
     throw_internal_error ("ffi_prep_cif failed");

Index: gcc/libjava/java/lang/reflect/natMethod.cc
===================================================================
--- gcc.orig/libjava/java/lang/reflect/natMethod.cc
+++ gcc/libjava/java/lang/reflect/natMethod.cc
@@ -436,7 +436,12 @@ _Jv_CallAnyMethodA (jobject obj,
       p += size_per_arg;
     }

-  if (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, param_count,
+  ffi_abi cabi = FFI_DEFAULT_ABI;
+#if defined (X86_WIN32) && !defined (__CYGWIN__)
+  if (needs_this)
+    cabi = FFI_THISCALL;
+#endif
+  if (ffi_prep_cif (&cif, cabi, param_count,
 		    rtype, argtypes) != FFI_OK)
     throw new java::lang::VirtualMachineError(JvNewStringLatin1("internal
error: ffi_prep_cif failed"));

Index: gcc/libjava/java/lang/reflect/natVMProxy.cc
===================================================================
--- gcc.orig/libjava/java/lang/reflect/natVMProxy.cc
+++ gcc/libjava/java/lang/reflect/natVMProxy.cc
@@ -79,7 +79,11 @@ typedef void (*closure_fun) (ffi_cif*, v
 static void *ncode (int method_index, jclass klass, _Jv_Method *self,
closure_fun fun);
 static void run_proxy (ffi_cif*, void*, void**, void*);

-typedef jobject invoke_t (jobject, Proxy *, Method *, JArray< jobject > *);
+typedef jobject
+#if defined (X86_WIN32) && !defined (__CYGWIN__)
+ __attribute__ ((thiscall))
+#endif
+ invoke_t (jobject, Proxy *, Method *, JArray< jobject > *);

 // True if pc points to a proxy frame.

@@ -442,6 +446,11 @@ ncode (int method_index, jclass klass, _
 		&closure->cif,
 		&closure->arg_types[0],
 		NULL);
+#if defined (X86_WIN32) && !defined (__CYGWIN__)
+  /* Redirect via SYSV, as actual function will be invoked via
+     invoke methods.  */
+  closure->cif.abi = FFI_SYSV;
+#endif
   closure->self = self;

   JvAssert ((self->accflags & Modifier::NATIVE) == 0);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch libjava]: Fix PR target/51500
  2012-01-29 14:15 [patch libjava]: Fix PR target/51500 Kai Tietz
@ 2012-01-30 10:16 ` Andrew Haley
  2012-02-01  9:48   ` Kai Tietz
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Haley @ 2012-01-30 10:16 UTC (permalink / raw)
  To: gcc-patches

On 01/29/2012 02:15 PM, Kai Tietz wrote:
> 2012-01-29  Kai Tietz  <ktietz@redhat.com>
> 
> 	PR target/51500
> 	* interpret.cc (_Jv_init_cif): Handle thiscall
> 	convention for 32-bit Windows.
> 	* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA):
> 	Likewise.
> 	* java/lang/reflect/natVMProxy.cc (ncode): Force SYSV
> 	closure for 32-bit Windows.
> 	(invoke_t): Add thiscall-attribute for 32-bit Windows.
> 
> Patch tested for i686-w64-mingw32, i686-pc-cygwin, and
> x86_64-unknown-linux-gnu.  Ok for apply?

Is it upstream?  OK if so.

Andrew.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch libjava]: Fix PR target/51500
  2012-01-30 10:16 ` Andrew Haley
@ 2012-02-01  9:48   ` Kai Tietz
  2012-02-01 10:31     ` Andrew Haley
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Tietz @ 2012-02-01  9:48 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gcc-patches

2012/1/30 Andrew Haley <aph@redhat.com>:
> On 01/29/2012 02:15 PM, Kai Tietz wrote:
>> 2012-01-29  Kai Tietz  <ktietz@redhat.com>
>>
>>       PR target/51500
>>       * interpret.cc (_Jv_init_cif): Handle thiscall
>>       convention for 32-bit Windows.
>>       * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA):
>>       Likewise.
>>       * java/lang/reflect/natVMProxy.cc (ncode): Force SYSV
>>       closure for 32-bit Windows.
>>       (invoke_t): Add thiscall-attribute for 32-bit Windows.
>>
>> Patch tested for i686-w64-mingw32, i686-pc-cygwin, and
>> x86_64-unknown-linux-gnu.  Ok for apply?
>
> Is it upstream?  OK if so.
>
> Andrew.

Andrew,

I sent update-patch to ML for libffi to support closure-code for
thiscall.  So the hunk in patch for java/lang/reflect/natVMProxy.cc
(ncode): Force SYSV closure for 32-bit Windows. Isn't necessary, if
the fix in libffi gets applied.

Ok to commit patch without that hunk?  The standard-thiscall call
feature is already in libffi.

Regards,
Kai

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch libjava]: Fix PR target/51500
  2012-02-01  9:48   ` Kai Tietz
@ 2012-02-01 10:31     ` Andrew Haley
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Haley @ 2012-02-01 10:31 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gcc-patches

On 02/01/2012 09:47 AM, Kai Tietz wrote:
> I sent update-patch to ML for libffi to support closure-code for
> thiscall.  So the hunk in patch for java/lang/reflect/natVMProxy.cc
> (ncode): Force SYSV closure for 32-bit Windows. Isn't necessary, if
> the fix in libffi gets applied.
> 
> Ok to commit patch without that hunk?  The standard-thiscall call
> feature is already in libffi.

Yes.  A goal is to minimize divergence from upstream libffi.
Several of us have done a lot of work to make this happen.

Andrew.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-01 10:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-29 14:15 [patch libjava]: Fix PR target/51500 Kai Tietz
2012-01-30 10:16 ` Andrew Haley
2012-02-01  9:48   ` Kai Tietz
2012-02-01 10:31     ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).