Class field setters and getters got renamed from vm_field_* to static_field_*.
They are also using now JNI types as arguments.

Signed-off-by: Tomek Grabiec <tgrab...@gmail.com>
---
 include/vm/class.h |  108 +++++++++++++++++++++++++--------------------------
 vm/field.c         |   11 +++--
 2 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/include/vm/class.h b/include/vm/class.h
index 7c8af6c..722d3db 100644
--- a/include/vm/class.h
+++ b/include/vm/class.h
@@ -164,85 +164,83 @@ enum vm_type vm_class_get_storage_vmtype(const struct 
vm_class *class);
 struct vm_class *vm_class_get_class_from_class_object(struct vm_object *clazz);
 struct vm_class *vm_class_get_array_class(struct vm_class *element_class);
 
-static inline void
-vm_field_set_int32(const struct vm_field *field, int32_t value)
-{
-       assert(vm_field_is_static(field));
-
-       *(int32_t *) &field->class->static_values[field->offset] = value;
-}
-
-static inline int32_t
-vm_field_get_int32(const struct vm_field *field)
-{
-       assert(vm_field_is_static(field));
-
-       return *(int32_t *) &field->class->static_values[field->offset];
-}
+#define DECLARE_STATIC_FIELD_GETTER(type)                              \
+static inline j ## type                                                        
\
+static_field_get_ ## type (const struct vm_field *field)               \
+{                                                                      \
+       assert(vm_field_is_static(field));                              \
+                                                                       \
+       return *(j ## type *) &field->class->static_values[field->offset]; \
+}
+
+DECLARE_STATIC_FIELD_GETTER(byte);
+DECLARE_STATIC_FIELD_GETTER(boolean);
+DECLARE_STATIC_FIELD_GETTER(char);
+DECLARE_STATIC_FIELD_GETTER(double);
+DECLARE_STATIC_FIELD_GETTER(float);
+DECLARE_STATIC_FIELD_GETTER(int);
+DECLARE_STATIC_FIELD_GETTER(long);
+DECLARE_STATIC_FIELD_GETTER(object);
+DECLARE_STATIC_FIELD_GETTER(short);
+
+#define DECLARE_STATIC_FIELD_SETTER(type)                              \
+static inline void                                                     \
+static_field_set_ ## type (const struct vm_field *field,               \
+                          j ## type value)                             \
+{                                                                      \
+       assert(vm_field_is_static(field));                              \
+                                                                       \
+       *(j ## type *) &field->class->static_values[field->offset] = value; \
+}
+
+/*
+ * We can not use generic setters for types of size less than machine
+ * word. We currently load/store whole machine words therefore we must
+ * set higher bits too, with sign extension for signed types.
+ *
+ * This should be fixed when register allocator finally supports
+ * register constraints so that 8-bit and 16-bit load and stores can
+ * be implemented in instruction selector.
+ */
 
 static inline void
-vm_field_set_int64(const struct vm_field *field, int64_t value)
-{
-       assert(vm_field_is_static(field));
-
-       *(int64_t *) &field->class->static_values[field->offset] = value;
-}
-
-static inline int64_t
-vm_field_get_int64(const struct vm_field *field)
+static_field_set_byte(const struct vm_field *field, jbyte value)
 {
        assert(vm_field_is_static(field));
 
-       return *(int64_t *) &field->class->static_values[field->offset];
+       *(long *) &field->class->static_values[field->offset] = value;
 }
 
 static inline void
-vm_field_set_float(const struct vm_field *field, float value)
+static_field_set_short(const struct vm_field *field,
+               jshort value)
 {
        assert(vm_field_is_static(field));
 
-       *(float *) &field->class->static_values[field->offset] = value;
-}
-
-static inline float
-vm_field_get_float(const struct vm_field *field)
-{
-       assert(vm_field_is_static(field));
-
-       return *(float *) &field->class->static_values[field->offset];
+       *(long *) &field->class->static_values[field->offset] = value;
 }
 
 static inline void
-vm_field_set_double(const struct vm_field *field, double value)
-{
-       assert(vm_field_is_static(field));
-
-       *(double *) &field->class->static_values[field->offset] = value;
-}
-
-static inline double
-vm_field_get_double(const struct vm_field *field)
+static_field_set_boolean(const struct vm_field *field,
+                 jboolean value)
 {
        assert(vm_field_is_static(field));
 
-       return *(double *) &field->class->static_values[field->offset];
+       *(unsigned long *) &field->class->static_values[field->offset] = value;
 }
 
 static inline void
-vm_field_set_object(const struct vm_field *field, struct vm_object *value)
+static_field_set_char(const struct vm_field *field, jchar value)
 {
        assert(vm_field_is_static(field));
 
-       *(void **) &field->class->static_values[field->offset] = value;
+       *(unsigned long *) &field->class->static_values[field->offset] = value;
 }
 
-static inline struct vm_object *
-vm_field_get_object(const struct vm_field *field)
-{
-       assert(vm_field_is_static(field));
-
-       return *(struct vm_object **)
-               &field->class->static_values[field->offset];
-}
+DECLARE_STATIC_FIELD_SETTER(double);
+DECLARE_STATIC_FIELD_SETTER(float);
+DECLARE_STATIC_FIELD_SETTER(int);
+DECLARE_STATIC_FIELD_SETTER(long);
+DECLARE_STATIC_FIELD_SETTER(object);
 
 #endif /* __CLASS_H */
diff --git a/vm/field.c b/vm/field.c
index babc286..5755d7f 100644
--- a/vm/field.c
+++ b/vm/field.c
@@ -111,7 +111,7 @@ int vm_field_init_static(struct vm_field *vmf)
                        return -1;
                }
 
-               vm_field_set_int32(vmf, cp->integer_.bytes);
+               static_field_set_int(vmf, cp->integer_.bytes);
                break;
        case CAFEBABE_CONSTANT_TAG_FLOAT:
                if (strcmp(vmf->type, "F")) {
@@ -119,7 +119,7 @@ int vm_field_init_static(struct vm_field *vmf)
                        return -1;
                }
 
-               vm_field_set_float(vmf, uint32_to_float(cp->float_.bytes));
+               static_field_set_float(vmf, cp->float_.bytes);
                break;
        case CAFEBABE_CONSTANT_TAG_STRING: {
                if (strcmp(vmf->type, "Ljava/lang/String;")) {
@@ -143,7 +143,7 @@ int vm_field_init_static(struct vm_field *vmf)
                        return -1;
                }
 
-               vm_field_set_object(vmf, string);
+               static_field_set_object(vmf, string);
                break;
        }
        case CAFEBABE_CONSTANT_TAG_LONG:
@@ -152,7 +152,7 @@ int vm_field_init_static(struct vm_field *vmf)
                        return -1;
                }
 
-               vm_field_set_int64(vmf,
+               static_field_set_long(vmf,
                        ((uint64_t) cp->long_.high_bytes << 32)
                        + (uint64_t) cp->long_.low_bytes);
                break;
@@ -162,7 +162,8 @@ int vm_field_init_static(struct vm_field *vmf)
                        return -1;
                }
 
-               vm_field_set_double(vmf, 
uint64_to_double(cp->double_.low_bytes, cp->double_.high_bytes));
+               static_field_set_double(vmf, ((uint64_t) cp->long_.high_bytes 
<< 32)
+                       + (uint64_t) cp->long_.low_bytes);
                break;
        default:
                return -1;
-- 
1.6.0.6


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to