*/
-// FIXME For now we export everything as C functions.
-extern "C" {
-
#include "config.h"
#include <stdio.h>
#include "arch.h"
#include "md-abi.h"
-#include "mm/memory.h"
+#include "mm/memory.hpp"
-#include "native/jni.h"
#include "native/llni.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
-
-#include "threads/thread.h"
+#include "threads/thread.hpp"
-#include "toolbox/logging.h"
+#include "toolbox/logging.hpp"
#include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/jit/argument.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/globals.hpp"
+#include "vm/javaobjects.hpp"
+#include "vm/options.h"
+#include "vm/string.hpp"
+#include "vm/utf8.h"
+
+#include "vm/jit/argument.hpp"
+#include "vm/jit/codegen-common.hpp"
#include "vm/jit/trace.hpp"
-#include "vm/jit/show.h"
-
-#include "vmcore/globals.hpp"
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
+#include "vm/jit/show.hpp"
#if !defined(NDEBUG)
+// FIXME For now we export everything as C functions.
+extern "C" {
/* global variables ***********************************************************/
/* Cast to java.lang.Object. */
- o = (java_object_t *) (ptrint) imu.l;
+ o = (java_handle_t*) (uintptr_t) imu.l;
/* Check return argument for java.lang.Class or
java.lang.String. */
/* realloc memory for string length */
- logtext = DMREALLOC(logtext, char, *logtextlen, *logtextlen + len);
+ logtext = (char*) DumpMemory::reallocate(logtext, *logtextlen, *logtextlen + len);
*logtextlen += len;
/* convert to utf8 string and strcat it to the logtext */
/* realloc memory for string length */
- logtext = DMREALLOC(logtext, char, *logtextlen, *logtextlen + len);
+ logtext = (char*) DumpMemory::reallocate(logtext, *logtextlen, *logtextlen + len);
*logtextlen += len;
/* strcat to the logtext */
s4 logtextlen;
s4 i;
s4 pos;
- int32_t dumpmarker;
/* We don't trace builtin functions here because the argument
passing happens via the native ABI and does not fit these
strlen("...(255)") +
strlen(")");
- /* allocate memory */
-
- DMARKER;
+ // Create new dump memory area.
+ DumpMemoryArea dma;
- logtext = DMNEW(char, logtextlen);
+ // TODO Use a std::string here.
+ logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
TRACEJAVACALLCOUNT++;
log_text(logtext);
- /* release memory */
-
- DRELEASE;
-
TRACEJAVACALLINDENT++;
-
}
/* trace_java_call_exit ********************************************************
s4 i;
s4 pos;
imm_union val;
- int32_t dumpmarker;
/* We don't trace builtin functions here because the argument
passing happens via the native ABI and does not fit these
logtextlen += strlen("->0.4872328470301428 (0x0123456789abcdef)");
- /* allocate memory */
-
- DMARKER;
+ // Create new dump memory area.
+ DumpMemoryArea dma;
- logtext = DMNEW(char, logtextlen);
+ // TODO Use a std::string here.
+ logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
/* generate the message */
}
log_text(logtext);
-
- /* release memory */
-
- DRELEASE;
}
char *logtext;
s4 logtextlen;
codeinfo *code;
- int32_t dumpmarker;
/* calculate message length */
logtextlen += strlen("0");
- /* allocate memory */
-
- DMARKER;
+ // Create new dump memory area.
+ DumpMemoryArea dma;
- logtext = DMNEW(char, logtextlen);
+ // TODO Use a std::string here.
+ logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
if (xptr) {
strcpy(logtext, "Exception ");
strcat(logtext, "call_java_method");
log_text(logtext);
-
- /* release memory */
-
- DRELEASE;
}
*******************************************************************************/
-void trace_exception_builtin(java_object_t *xptr)
+void trace_exception_builtin(java_handle_t* h)
{
- java_lang_Throwable *t;
- java_lang_String *s;
char *logtext;
s4 logtextlen;
- int32_t dumpmarker;
- t = (java_lang_Throwable *) xptr;
+ java_lang_Throwable jlt(h);
+
+ // Get detail message.
+ java_handle_t* s = NULL;
+
+ if (jlt.get_handle() != NULL)
+ s = jlt.get_detailMessage();
- /* get detail message */
- if (t)
- LLNI_field_get_ref(t, detailMessage, s);
+ java_lang_String jls(s);
/* calculate message length */
logtextlen = strlen("Builtin exception thrown: ") + strlen("0");
- if (t) {
- logtextlen +=
- utf_bytes(xptr->vftbl->clazz->name);
- if (s) {
+ if (jlt.get_handle() != NULL) {
+ logtextlen += utf_bytes(jlt.get_vftbl()->clazz->name);
+
+ if (jls.get_handle()) {
+ // FIXME This is not handle capable!
logtextlen += strlen(": ") +
- u2_utflength(LLNI_field_direct(s, value)->data
- + LLNI_field_direct(s, offset),
- LLNI_field_direct(s,count));
+ u2_utflength(jls.get_value()->data + jls.get_offset(), jls.get_count());
}
}
else {
logtextlen += strlen("(nil)");
}
- /* allocate memory */
-
- DMARKER;
+ // Create new dump memory area.
+ DumpMemoryArea dma;
- logtext = DMNEW(char, logtextlen);
+ logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen);
strcpy(logtext, "Builtin exception thrown: ");
- if (t) {
- utf_cat_classname(logtext, xptr->vftbl->clazz->name);
+ if (jlt.get_handle()) {
+ utf_cat_classname(logtext, jlt.get_vftbl()->clazz->name);
if (s) {
char *buf;
- buf = javastring_tochar((java_handle_t *) s);
+ buf = javastring_tochar(jls.get_handle());
strcat(logtext, ": ");
strcat(logtext, buf);
MFREE(buf, char, strlen(buf) + 1);
}
log_text(logtext);
-
- /* release memory */
-
- DRELEASE;
}
-#endif /* !defined(NDEBUG) */
-
} // extern "C"
+#endif /* !defined(NDEBUG) */
+
/*
* These are local overrides for various environment variables in Emacs.