Merged subtype and current trunk.
[cacao.git] / src / vm / jit / builtin.cpp
index cd53c03dd4c51e11d7391c256fefc82b9085a596..895b6f3b5b36caa241f5355ff9239d73f3b7b30f 100644 (file)
 
 #include "native/llni.h"
 
-#include "threads/lock-common.h"
+#include "threads/lock.hpp"
 #include "threads/mutex.hpp"
 #include "threads/thread.hpp"
 
 #include "toolbox/logging.h"
 #include "toolbox/util.h"
 
-#include "vm/array.h"
+#include "vm/array.hpp"
 #include "vm/jit/builtin.hpp"
 #include "vm/class.h"
 #include "vm/cycles-stats.h"
@@ -872,7 +872,7 @@ java_handle_t *builtin_new(classinfo *c)
        LLNI_vftbl_direct(o) = c->vftbl;
 
 #if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(o));
+       LLNI_DIRECT(o)->lockword.init();
 #endif
 
        CYCLES_STATS_GET(cycles_end);
@@ -954,7 +954,7 @@ java_handle_t *builtin_tlh_new(classinfo *c)
        LLNI_vftbl_direct(o) = c->vftbl;
 
 # if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(o));
+       LLNI_DIRECT(o)->lockword.init();
 # endif
 
        CYCLES_STATS_GET(cycles_end);
@@ -1033,7 +1033,7 @@ java_object_t *builtin_fast_new(classinfo *c)
        o->vftbl = c->vftbl;
 
 #if defined(ENABLE_THREADS)
-       lock_init_object_lock(o);
+       LLNI_DIRECT(o)->lockword.init();
 #endif
 
        CYCLES_STATS_GET(cycles_end);
@@ -1103,7 +1103,7 @@ java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass)
        LLNI_vftbl_direct(a) = arrayclass->vftbl;
 
 #if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(a));
+       LLNI_DIRECT(a)->lockword.init();
 #endif
 
        LLNI_array_size(a) = size;
@@ -1385,11 +1385,7 @@ s8 builtin_ladd(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a + b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1398,11 +1394,7 @@ s8 builtin_lsub(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a - b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1411,11 +1403,7 @@ s8 builtin_lneg(s8 a)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = -a;
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1427,11 +1415,7 @@ s8 builtin_lmul(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a * b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1443,11 +1427,7 @@ s8 builtin_ldiv(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a / b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1456,11 +1436,7 @@ s8 builtin_lrem(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a % b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1472,11 +1448,7 @@ s8 builtin_lshl(s8 a, s4 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a << (b & 63);
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1485,11 +1457,7 @@ s8 builtin_lshr(s8 a, s4 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a >> (b & 63);
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1498,11 +1466,7 @@ s8 builtin_lushr(s8 a, s4 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = ((u8) a) >> (b & 63);
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1514,11 +1478,7 @@ s8 builtin_land(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a & b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1527,11 +1487,7 @@ s8 builtin_lor(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a | b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1540,11 +1496,7 @@ s8 builtin_lxor(s8 a, s8 b)
 {
        s8 c;
 
-#if U8_AVAILABLE
        c = a ^ b; 
-#else
-       c = builtin_i2l(0);
-#endif
 
        return c;
 }
@@ -1554,7 +1506,6 @@ s8 builtin_lxor(s8 a, s8 b)
 #if !(SUPPORT_LONG && SUPPORT_LONG_CMP)
 s4 builtin_lcmp(s8 a, s8 b)
 { 
-#if U8_AVAILABLE
        if (a < b)
                return -1;
 
@@ -1562,9 +1513,6 @@ s4 builtin_lcmp(s8 a, s8 b)
                return 1;
 
        return 0;
-#else
-       return 0;
-#endif
 }
 #endif /* !(SUPPORT_LONG && SUPPORT_LONG_CMP) */
 
@@ -1962,30 +1910,6 @@ double builtin_drem(double a, double b)
 
 /* conversion operations ******************************************************/
 
-#if 0
-s8 builtin_i2l(s4 i)
-{
-#if U8_AVAILABLE
-       return i;
-#else
-       s8 v;
-       v.high = 0;
-       v.low = i;
-       return v;
-#endif
-}
-
-s4 builtin_l2i(s8 l)
-{
-#if U8_AVAILABLE
-       return (s4) l;
-#else
-       return l.low;
-#endif
-}
-#endif
-
-
 #if !(SUPPORT_FLOAT && SUPPORT_I2F)
 float builtin_i2f(s4 a)
 {
@@ -2007,12 +1931,8 @@ double builtin_i2d(s4 a)
 #if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F)
 float builtin_l2f(s8 a)
 {
-#if U8_AVAILABLE
        float f = (float) a;
        return f;
-#else
-       return 0.0;
-#endif
 }
 #endif /* !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) */
 
@@ -2020,12 +1940,8 @@ float builtin_l2f(s8 a)
 #if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D)
 double builtin_l2d(s8 a)
 {
-#if U8_AVAILABLE
        double d = (double) a;
        return d;
-#else
-       return 0.0;
-#endif
 }
 #endif /* !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) */
 
@@ -2340,7 +2256,7 @@ java_handle_t *builtin_clone(void *env, java_handle_t *o)
 #endif
 
 #if defined(ENABLE_THREADS)
-               lock_init_object_lock(LLNI_DIRECT(co));
+               LLNI_DIRECT(co)->lockword.init();
 #endif
 
                LLNI_CRITICAL_END;
@@ -2375,7 +2291,7 @@ java_handle_t *builtin_clone(void *env, java_handle_t *o)
 #endif
 
 #if defined(ENABLE_THREADS)
-       lock_init_object_lock(LLNI_DIRECT(co));
+       LLNI_DIRECT(co)->lockword.init();
 #endif
 
        LLNI_CRITICAL_END;