Reviewed by Maciej and Darin.
authorstaikos <staikos@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2006 05:44:33 +0000 (05:44 +0000)
committerstaikos <staikos@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2006 05:44:33 +0000 (05:44 +0000)
        * kjs/collector.cpp: merge major speedup from KDE on Linux
                             patch by Maks Orlovich, bug #6145
                             Also unify cpu detection
        * kjs/config.h: define simpler CPU macros

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@12300 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/collector.cpp
JavaScriptCore/kjs/config.h

index 933fa1c..811713d 100644 (file)
@@ -2,6 +2,15 @@
 
         Reviewed by Maciej.
 
+        * kjs/collector.cpp: merge major speedup from KDE on Linux
+                             patch by Maks Orlovich, bug #6145
+                             Also unify cpu detection
+        * kjs/config.h: define simpler CPU macros
+
+2006-01-22  George Staikos <staikos@opensource.apple.com>
+
+        Reviewed by Maciej.
+
         * kjs/collector.cpp: merge FreeBSD compile fix from KDE
                              -> requires build magic for use
 
index bc06854..9a2e782 100644 (file)
@@ -313,19 +313,24 @@ void Collector::markCurrentThreadConservatively()
     }
     void *stackBase = (void *)pTib->StackBase;
 #else
-    void *stackBase = 0;
-    pthread_attr_t sattr;
+    static void *stackBase = 0;
+    static pthread_t stackThread;
+    pthread_t thread = pthread_self();
+    if (stackBase == 0 || thread != stackThread) {
+        pthread_attr_t sattr;
 #ifdef HAVE_PTHREAD_NP_H
-    // e.g. on FreeBSD 5.4, neundorf@kde.org
-    pthread_attr_get_np(thread, &sattr);
+        // e.g. on FreeBSD 5.4, neundorf@kde.org
+        pthread_attr_get_np(thread, &sattr);
 #else
-    // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
-    pthread_getattr_np(pthread_self(), &sattr);
+        // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
+        pthread_getattr_np(thread, &sattr);
 #endif
-    // Should work but fails on Linux (?)
-    //  pthread_attr_getstack(&sattr, &stackBase, &stackSize);
-    pthread_attr_getstackaddr(&sattr, &stackBase);
-    assert(stackBase);
+        // Should work but fails on Linux (?)
+        //  pthread_attr_getstack(&sattr, &stackBase, &stackSize);
+        pthread_attr_getstackaddr(&sattr, &stackBase);
+        assert(stackBase);
+        stackThread = thread;
+    }
 #endif
 
     int dummy;
@@ -342,15 +347,15 @@ void Collector::markOtherThreadConservatively(Thread *thread)
 {
   thread_suspend(thread->machThread);
 
-#if __i386__
+#if KJS_CPU_X86
   i386_thread_state_t regs;
   unsigned user_count = sizeof(regs)/sizeof(int);
   thread_state_flavor_t flavor = i386_THREAD_STATE;
-#elif __ppc__
+#elif KJS_CPU_PPC
   ppc_thread_state_t  regs;
   unsigned user_count = PPC_THREAD_STATE_COUNT;
   thread_state_flavor_t flavor = PPC_THREAD_STATE;
-#elif __ppc64__
+#elif KJS_CPU_PPC64
   ppc_thread_state64_t  regs;
   unsigned user_count = PPC_THREAD_STATE64_COUNT;
   thread_state_flavor_t flavor = PPC_THREAD_STATE64;
@@ -364,9 +369,9 @@ void Collector::markOtherThreadConservatively(Thread *thread)
   markStackObjectsConservatively((void *)&regs, (void *)((char *)&regs + (user_count * sizeof(usword_t))));
   
   // scan the stack
-#if __i386__
+#if KJS_CPU_X86
   markStackObjectsConservatively((void *)regs.esp, pthread_get_stackaddr_np(thread->posixThread));
-#elif defined(__ppc__) || defined(__ppc64__)
+#elif KJS_CPU_PPC || KJS_CPU_PPC64
   markStackObjectsConservatively((void *)regs.r1, pthread_get_stackaddr_np(thread->posixThread));
 #else
 #error Unknown Architecture
index fbaa2d7..1b3e4eb 100644 (file)
 #define HAVE_STDINT_H 1
 #define HAVE_STRING_H 1
 
-#ifdef __ppc__
+#ifdef __ppc__ || __PPC__ || __powerpc__
+#define KJS_CPU_PPC 1
 #define WORDS_BIGENDIAN 1
+#elif __ppc64__ || __PPC64__
+#define KJS_CPU_PPC64 1
+#define WORDS_BIGENDIAN 1
+#elif __i386__
+#define KJS_CPU_X86 1
 #endif
 
 #define KXC_CHANGES 1