testcase including fillInStackTrace and rethrow examples
[cacao.git] / builtin.c
index cfacf49eb80100d57fa857737bc379c07a9dabd3..1278ac04517bb055efff434b433c2d97599b1396 100644 (file)
--- a/builtin.c
+++ b/builtin.c
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 921 2004-02-16 04:00:59Z jowenn $
+   $Id: builtin.c 951 2004-03-11 17:30:03Z jowenn $
 
 */
 
@@ -61,6 +61,9 @@
 #undef DEBUG /*define DEBUG 1*/
 
 
+THREADSPECIFIC methodinfo* _threadrootmethod = NULL;
+THREADSPECIFIC void *_thread_nativestackframeinfo=NULL;
+
 /*****************************************************************************
                                                                TYPE CHECKS
 *****************************************************************************/
@@ -483,6 +486,10 @@ s4 builtin_canstore_onedim_class(java_objectarray *a, java_objectheader *o)
 java_objectheader *builtin_new(classinfo *c)
 {
        java_objectheader *o;
+/*DEBUGING - NOT THREAD SAFE*/
+/*     static long depth=0;
+       depth++;
+       printf("Entering builtin_new:depth(%ld)",depth);*/
 
        if (!c->initialized) {
                if (initverbose) {
@@ -501,12 +508,20 @@ java_objectheader *builtin_new(classinfo *c)
 #else
        o = heap_allocate(c->instancesize, true, c->finalizer);
 #endif
-       if (!o) return NULL;
+       if (!o) {
+               /*DEBUGING - NOT THREAD SAFE*/
+               /*printf("Leaving builtin_new: depth(%ld): NULL",depth);
+               depth--;*/
+               return NULL;
+       }
        
        memset(o, 0, c->instancesize);
 
        o->vftbl = c->vftbl;
 
+       /*DEBUGING - NOT THREAD SAFE*/
+       /* printf("Leaving builtin_new: depth(%ld): object",depth);
+       depth--;*/
        return o;
 }
 
@@ -1782,6 +1797,27 @@ s4 builtin_dummy()
 }
 
 
+inline methodinfo *builtin_asm_get_threadrootmethod() {
+        return *threadrootmethod;
+}
+
+
+inline void* 
+builtin_asm_get_stackframeinfo(){
+/*log_text("builtin_asm_get_stackframeinfo()");*/
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#ifdef HAVE___THREAD
+        return &_thread_nativestackframeinfo; /*support for __thread attribute*/
+#else
+    return &((nativethread*) pthread_getspecific(tkey_stackframeinfo))->_stackframeinfo /*copied from exception handling, is that really */
+        /*old pthread*/
+#endif
+#else
+#warning FIXME FOR OLD THREAD IMPL (jowenn)
+        return &_thread_nativestackframeinfo; /* no threading, at least no native*/
+#endif
+}
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where