Shows array content with -Xtrace:invoke-verbose:
args : J_REFERENCE : 0x898b618 = {'/' ,'u' ,'s' ,'r' ,'/' ,'l' ,'o'
,'c' ,'a' ,'l' ,'/' ,'c' ,'l' ,'a' ,'s' ,'s' ,'p' ,'a' ,'t'
,'h', ...30 more} ([C)
Signed-off-by: Tomek Grabiec <[email protected]>
---
include/vm/object.h | 37 +++++++++++++++++++++++++++
jit/trace-jit.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 105 insertions(+), 0 deletions(-)
diff --git a/include/vm/object.h b/include/vm/object.h
index 8d7ad3e..a97282f 100644
--- a/include/vm/object.h
+++ b/include/vm/object.h
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <stdint.h>
+#include "vm/jni.h"
#include "vm/field.h"
#include "vm/thread.h"
#include "vm/vm.h"
@@ -137,6 +138,42 @@ array_set_field_byte(struct vm_object *obj, int index,
uint8_t value)
*(uint8_t *) &obj->fields[index * get_vmtype_size(J_BYTE)] = value;
}
+static inline jboolean
+array_get_field_boolean(struct vm_object *obj, int index)
+{
+ return *(jboolean *) &obj->fields[index * get_vmtype_size(J_BOOLEAN)];
+}
+
+static inline jshort
+array_get_field_short(struct vm_object *obj, int index)
+{
+ return *(jshort *) &obj->fields[index * get_vmtype_size(J_SHORT)];
+}
+
+static inline jint
+array_get_field_int(struct vm_object *obj, int index)
+{
+ return *(jint *) &obj->fields[index * get_vmtype_size(J_INT)];
+}
+
+static inline jlong
+array_get_field_long(struct vm_object *obj, int index)
+{
+ return *(jlong *) &obj->fields[index * get_vmtype_size(J_LONG)];
+}
+
+static inline float
+array_get_field_float(struct vm_object *obj, int index)
+{
+ return *(float *) &obj->fields[index * get_vmtype_size(J_FLOAT)];
+}
+
+static inline double
+array_get_field_double(struct vm_object *obj, int index)
+{
+ return *(double *) &obj->fields[index * get_vmtype_size(J_DOUBLE)];
+}
+
static inline void
array_set_field_ptr(struct vm_object *obj, int index, void *value)
{
diff --git a/jit/trace-jit.c b/jit/trace-jit.c
index 420eaef..bb0984e 100644
--- a/jit/trace-jit.c
+++ b/jit/trace-jit.c
@@ -22,6 +22,7 @@
#include "lib/string.h"
#include "vm/bytecodes.h"
#include "vm/class.h"
+#include "vm/jni.h"
#include "vm/method.h"
#include "vm/object.h"
#include "vm/preload.h"
@@ -30,6 +31,7 @@
#include "arch/stack-frame.h"
+#include <ctype.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
@@ -356,6 +358,69 @@ void trace_magic_trampoline(struct compilation_unit *cu)
trace_flush();
}
+static void print_array(struct vm_object *obj)
+{
+ const int max_elems = 20;
+ struct vm_class *elem_class;
+ enum vm_type type;
+
+ elem_class = vm_class_get_array_element_class(obj->class);
+ type = vm_class_get_storage_vmtype(elem_class);
+
+ trace_printf("= {");
+
+ for (int i = 0; i < obj->array_length && i < max_elems; i++) {
+ if (i > 0)
+ trace_printf(" ,");
+
+ if (type == J_CHAR) {
+ jchar c = array_get_field_char(obj, i);
+
+ if (isprint(c))
+ trace_printf("'%c'", c);
+ else
+ trace_printf("<%d>", c);
+
+ continue;
+ }
+
+ switch (type) {
+ case J_REFERENCE:
+ trace_printf("%p", array_get_field_ptr(obj, i));
+ break;
+ case J_BYTE:
+ trace_printf("%x", (int)array_get_field_byte(obj, i));
+ break;
+ case J_SHORT:
+ trace_printf("%x", (int)array_get_field_short(obj, i));
+ break;
+ case J_INT:
+ trace_printf("%x", array_get_field_int(obj, i));
+ break;
+ case J_LONG:
+ trace_printf("%llx", array_get_field_long(obj, i));
+ break;
+ case J_FLOAT:
+ trace_printf("%f", array_get_field_float(obj, i));
+ break;
+ case J_DOUBLE:
+ trace_printf("%f", array_get_field_double(obj, i));
+ break;
+ case J_BOOLEAN:
+ trace_printf("%s", array_get_field_boolean(obj, i)
+ ? "true" : "false");
+ break;
+ default:
+ error("invalid array element type");
+ }
+ }
+
+ if (obj->array_length > max_elems)
+ trace_printf(", ...%d more", obj->array_length - max_elems);
+
+ trace_printf("}");
+}
+
static void print_arg(enum vm_type arg_type, const unsigned long *args,
int *arg_index)
{
@@ -411,6 +476,9 @@ static void print_arg(enum vm_type arg_type, const unsigned
long *args,
free(str);
}
+ if (vm_class_is_array_class(obj->class))
+ print_array(obj);
+
trace_printf(" (%s)", obj->class->name);
}
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel