/* src/toolbox/hashtable.hpp - hashtable classes
- Copyright (C) 2009
+ Copyright (C) 2009, 2011
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
Copyright (C) 2009 Theobroma Systems Ltd.
#if __cplusplus
-// XXX This is a TR1 header and not (yet) part of the C++ standard, so we
-// should not use it. The solution is to implement the below stuff
-// ourselves. This will be done, sometimes, soon, I hope ...
#include <tr1/unordered_map>
finalizer.hpp \
globals.cpp \
globals.hpp \
+ hook.cpp \
hook.hpp \
initialize.cpp \
initialize.hpp \
--- /dev/null
+/* src/vm/hook.cpp - hook points inside the VM
+
+ Copyright (C) 2009, 2011
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+#include "vm/global.h"
+#include "vm/globals.hpp"
+
+#include "mm/memory.hpp"
+#include "vm/hook.hpp"
+#include "vm/javaobjects.hpp"
+
+bool Hook::class_linked_dynoffsets(classinfo *c)
+{
+ return jobjects_run_dynoffsets_hook(c);
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
/* src/vm/hook.hpp - hook points inside the VM
- Copyright (C) 2009, 2010
+ Copyright (C) 2009, 2011
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
*/
namespace Hook {
void breakpoint (Breakpoint *bp);
- void class_linked (classinfo *c);
+ bool class_linked (classinfo *c);
void class_loaded (classinfo *c);
void jit_generated (methodinfo *m, codeinfo *code);
void jit_recycled (methodinfo *m, codeinfo *code);
void vm_init ();
void vm_preinit ();
void vm_shutdown ();
+
+ // Non-inline functions
+ bool class_linked_dynoffsets(classinfo *c);
}
#endif
}
-inline void Hook::class_linked(classinfo *c)
+inline bool Hook::class_linked(classinfo *c)
{
if (c == class_java_lang_String)
linker_initialize_deferred_strings();
+
+ return class_linked_dynoffsets(c);
}
inline void Hook::class_loaded(classinfo *c)
/* src/vm/javaobjects.cpp - functions to create and access Java objects
+ Copyright (C) 2010, 2011
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
Copyright (C) 2008, 2009 Theobroma Systems Ltd.
This file is part of CACAO.
#include "vm/initialize.hpp"
#include "vm/javaobjects.hpp"
+#include <map>
#if defined(ENABLE_JAVASE)
return result;
}
+struct DynOffsetEntry {
+ void (*setter)(int32_t);
+ const char *name;
+};
+
+typedef std::map<classinfo *, DynOffsetEntry *> RegisteredDynMap;
+static RegisteredDynMap dynEntryMap;
+
+static void register_dyn_entry_table(classinfo *c, DynOffsetEntry *entries)
+{
+ dynEntryMap.insert(std::make_pair(c, entries));
+}
+
+static bool runAllSetters(classinfo *c, DynOffsetEntry entries[])
+{
+ do {
+ fieldinfo *fi = class_findfield_by_name(c, utf_new_char(entries->name));
+ if (!fi)
+ return false;
+ entries->setter(fi->offset);
+ } while ((++entries)->setter);
+ return true;
+}
+
+bool jobjects_run_dynoffsets_hook(classinfo *c)
+{
+ RegisteredDynMap::const_iterator it = dynEntryMap.find(c);
+ if (it == dynEntryMap.end())
+ return true;
+
+ if (!runAllSetters(c, it->second))
+ return false;
+
+ return true;
+}
+
+
+void jobjects_register_dyn_offsets()
+{
+}
+
#endif // ENABLE_JAVASE
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/
/* src/vm/javaobjects.hpp - functions to create and access Java objects
+ Copyright (C) 2010, 2011
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
Copyright (C) 2008, 2009 Theobroma Systems Ltd.
This file is part of CACAO.
#endif // ENABLE_JAVASE
+void jobjects_register_dyn_offsets();
+bool jobjects_run_dynoffsets_hook(classinfo *c);
#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH)
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/
/* src/vm/linker.cpp - class linker functions
- Copyright (C) 1996-2005, 2006, 2007, 2008, 2010
+ Copyright (C) 1996, 2011
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
if (c == NULL) {
exceptions_throw_nullpointerexception();
- return NULL;
+ return 0;
}
LOCK_MONITOR_ENTER(c);
RT_TIMING_TIME_DIFF(time_start,time_end,RT_TIMING_LINK_TOTAL);
// Hook point just after a class was linked.
- Hook::class_linked(r);
+ if (!Hook::class_linked(r))
+ return 0;
return r;
}
-/* src/vm/linker.h - class linker header
+/* src/vm/linker.hpp - class linker header
- Copyright (C) 1996-2005, 2006, 2007, 2008, 2010
+ Copyright (C) 1996, 2011
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/
#include "vm/globals.hpp"
#include "vm/hook.hpp"
#include "vm/initialize.hpp"
+#include "vm/javaobjects.hpp"
#include "vm/options.h"
#include "vm/os.hpp"
#include "vm/primitive.hpp"
Primitive::initialize_table();
loader_init();
+ jobjects_register_dyn_offsets();
linker_init();
// AFTER: loader_init, linker_init