summaryrefslogtreecommitdiff
path: root/sparc.c
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-15 04:42:31 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-15 04:42:31 +0000
commitfa00b6516c96ffc888c194caf9bf964255c6ec54 (patch)
treee577e3fd596b3ff8bee5a6c8c7947c0fab153cb2 /sparc.c
parent9cdd62bd19f7872bab25912ed0485c098ea141d2 (diff)
* include/ruby/defines.h (FLUSH_REGISTER_WINDOWS): move sparc asm code
to a separete file sparc.c for preventing inlining optimization. Patched by Jurij Smakov. [Bug #5244] [ruby-core:40685] * sparc.c (rb_sparc_flush_register_windows): ditto. * configure.in: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sparc.c')
-rw-r--r--sparc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sparc.c b/sparc.c
new file mode 100644
index 0000000000..b764e900d7
--- /dev/null
+++ b/sparc.c
@@ -0,0 +1,30 @@
+/********************************************************************
+ Flush register windows on sparc.
+
+ This function is in a separate file to prevent inlining. The "flushw"
+ assembler instruction used on sparcv9 flushes all register windows
+ except the current one, so if it is inlined, the current register
+ window of the process executing the instruction will not be flushed
+ correctly.
+
+ See http://redmine.ruby-lang.org/issues/5244 for discussion.
+*********************************************************************/
+void rb_sparc_flush_register_windows()
+{
+ asm
+#ifdef __GNUC__
+ __volatile__
+#endif
+
+/* This condition should be in sync with one in configure.in */
+#if defined(__sparcv9) || defined(__sparc_v9__) || defined(__arch64__)
+# ifdef __GNUC__
+ ("flushw" : : : "%o7")
+# else
+ ("flushw")
+# endif /* __GNUC__ */
+#else
+ ("ta 0x03")
+#endif
+ ;
+}