Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 arch/x86/include/arch/instruction.h |    5 +++++
 arch/x86/use-def.c                  |   10 ++++++++++
 vm/jato.c                           |    9 +++++++++
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/arch/instruction.h 
b/arch/x86/include/arch/instruction.h
index 13c8540..33e2117 100644
--- a/arch/x86/include/arch/instruction.h
+++ b/arch/x86/include/arch/instruction.h
@@ -139,6 +139,9 @@ enum insn_type {
        INSN_XOR_IMM_REG,
        INSN_XOR_REG_REG,
        INSN_XOR_XMM_REG_REG,
+
+       /* Must be last */
+       NR_INSN_TYPES,
 };
 
 struct insn {
@@ -161,6 +164,8 @@ struct insn {
        unsigned long bytecode_offset;
 };
 
+void insn_sanity_check(void);
+
 static inline unsigned long lir_position(struct use_position *reg)
 {
        return reg->insn->lir_pos;
diff --git a/arch/x86/use-def.c b/arch/x86/use-def.c
index 7320887..bef72f4 100644
--- a/arch/x86/use-def.c
+++ b/arch/x86/use-def.c
@@ -121,6 +121,16 @@ static struct insn_info insn_infos[] = {
        DECLARE_INFO(INSN_XOR_XMM_REG_REG, USE_SRC | USE_DST | DEF_DST),
 };
 
+void insn_sanity_check(void)
+{
+       assert(ARRAY_SIZE(insn_infos) == NR_INSN_TYPES);
+
+       for (unsigned int i = 0; i < NR_INSN_TYPES; ++i) {
+               if (insn_infos[i].flags == 0)
+                       die("missing insn_info for %d", i);
+       }
+}
+
 static inline struct insn_info *get_info(struct insn *insn)
 {
        return insn_infos + insn->type;
diff --git a/vm/jato.c b/vm/jato.c
index 4e47a07..b1d69f8 100644
--- a/vm/jato.c
+++ b/vm/jato.c
@@ -1014,6 +1014,12 @@ do_method_trace(void)
        return 0;
 }
 
+/* XXX: This should probably be in arch headers, BUT: it's only used in one
+ * place _anyway_ (namely here), and we can't include arch headers here
+ * because our register definitions conflict with the system header
+ * ucontext.h. */
+void insn_sanity_check(void);
+
 int
 main(int argc, char *argv[])
 {
@@ -1027,6 +1033,9 @@ main(int argc, char *argv[])
        setvbuf(stderr, NULL, _IONBF, 0);
 #endif
 
+       /* Sanity checks first of all. */
+       insn_sanity_check();
+
        parse_options(argc, argv);
 
        init_system_properties();
-- 
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