atomic functions in asmpart.S because of MIPSPro compiler
[cacao.git] / src / vm / builtin.c
index a8813f76f9d70c7e8914726151ea978168762bb3..6f99656c38b292b4c066fa086a096c729383bf79 100644 (file)
@@ -34,7 +34,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 1082 2004-05-26 15:04:54Z jowenn $
+   $Id: builtin.c 1113 2004-06-02 10:31:09Z twisti $
 
 */
 
@@ -444,29 +444,21 @@ java_objectheader *builtin_new(classinfo *c)
        java_objectheader *o;
 
        /* is the class loaded */
-       if (!c->loaded) {
-               class_load(c);
-       }
+       if (!c->loaded)
+               if (!class_load(c))
+                       return NULL;
 
        /* is the class linked */
-       if (!c->linked) {
-               class_link(c);
-       }
+       if (!c->linked)
+               if (!class_link(c))
+                       return NULL;
 
        if (!c->initialized) {
-               if (initverbose) {
-                       char logtext[MAXLOGTEXT];
-                       sprintf(logtext, "Initialize class ");
-                       utf_sprint_classname(logtext + strlen(logtext), c->name);
-                       sprintf(logtext + strlen(logtext), " (from builtin_new)");
-                       log_text(logtext);
-               }
-               (void) class_init(c);
+               if (initverbose)
+                       log_message_class("Initialize class (from builtin_new): ", c);
 
-               /* we had an ExceptionInInitializerError */
-               if (*exceptionptr) {
+               if (!class_init(c))
                        return NULL;
-               }
        }
 
 #ifdef SIZE_FROM_CLASSINFO
@@ -475,6 +467,7 @@ java_objectheader *builtin_new(classinfo *c)
 #else
        o = heap_allocate(c->instancesize, true, c->finalizer);
 #endif
+
        if (!o)
                return NULL;
        
@@ -485,6 +478,7 @@ java_objectheader *builtin_new(classinfo *c)
        return o;
 }
 
+
 /********************** Function: builtin_newarray **************************
 
        Creates an array with the given vftbl on the heap.
@@ -559,11 +553,13 @@ java_objectarray *builtin_anewarray(s4 size, classinfo *component)
 {
        /* is class loaded */
        if (!component->loaded)
-               class_load(component);
+               if (!class_load(component))
+                       return NULL;
 
        /* is class linked */
        if (!component->linked)
-               class_link(component);
+               if (!class_link(component))
+                       return NULL;
 
        return (java_objectarray *) builtin_newarray(size, class_array_of(component)->vftbl);
 }
@@ -1806,7 +1802,9 @@ inline void* builtin_asm_get_stackframeinfo()
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
        return &THREADINFO->_stackframeinfo;
 #else
+#if defined(__GNUC__)
 #warning FIXME FOR OLD THREAD IMPL (jowenn)
+#endif
                return &_thread_nativestackframeinfo; /* no threading, at least no native*/
 #endif
 }
@@ -1816,10 +1814,12 @@ stacktraceelement *builtin_stacktrace_copy(stacktraceelement **el,stacktraceelem
        size_t s;
        s=(end-begin);
        /*printf ("begin: %p, end: %p, diff: %ld, size :%ld\n",begin,end,s,s*sizeof(stacktraceelement));*/
-       *el=GCNEW(stacktraceelement,s+1);
+       *el=MNEW(stacktraceelement,s+1); /*GC*/
        memcpy(*el,begin,(end-begin)*sizeof(stacktraceelement));
        (*el)[s].method=0;
+#if defined(__GNUC__)
 #warning change this if line numbers bigger than u2 are allowed, the currently supported class file format does no allow that
+#endif
        (*el)[s].linenumber=-1; /* -1 can never be reched otherwise, since line numbers are only u2, so it is save to use that as flag */
        return *el;
 }