aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2013-06-06 20:39:22 +0300
committerPekka Enberg <penberg@kernel.org>2013-06-06 20:44:07 +0300
commit11d9db8ec4e6c64ae87be0d16f01db9d8536a341 (patch)
treec4a3b8c36ce6f467844b177a6d389209727991a9
parentd5b16d781e3c6d0ba04d5c9e073606038caade83 (diff)
downloadjato-11d9db8ec4e6c64ae87be0d16f01db9d8536a341.tar.gz
Bye, bye, MMIX!
It seemed like a good testing strategy at the time but it has turned out to be more trouble than it's worth. Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--Makefile2
-rw-r--r--arch/mmix/args.c20
-rw-r--r--arch/mmix/call.c32
-rw-r--r--arch/mmix/include/arch/args.h28
-rw-r--r--arch/mmix/include/arch/instruction.h121
-rw-r--r--arch/mmix/include/arch/registers.h49
-rw-r--r--arch/mmix/include/arch/stack-frame.h16
-rw-r--r--arch/mmix/include/arch/text.h8
-rw-r--r--arch/mmix/instruction.c136
-rw-r--r--arch/mmix/register.c4
-rw-r--r--arch/mmix/stack-frame.c27
-rw-r--r--arch/mmix/use-def.c62
-rw-r--r--test/unit/jit/Makefile91
-rw-r--r--test/unit/jit/args-test-utils.c82
-rw-r--r--test/unit/jit/args-test-utils.h11
-rw-r--r--test/unit/jit/basic-block-assert.h41
-rw-r--r--test/unit/jit/basic-block-test.c71
-rw-r--r--test/unit/jit/bc-test-utils.h56
-rw-r--r--test/unit/jit/cfg-analyzer-test.c218
-rw-r--r--test/unit/jit/compilation-unit-test.c72
-rw-r--r--test/unit/jit/dominance-test.c142
-rw-r--r--test/unit/jit/expression-test.c25
-rw-r--r--test/unit/jit/linear-scan-test.c73
-rw-r--r--test/unit/jit/live-range-test.c138
-rw-r--r--test/unit/jit/liveness-test.c130
-rw-r--r--test/unit/jit/spill-reload-test.c165
-rw-r--r--test/unit/jit/stack-slot-test.c84
-rw-r--r--test/unit/jit/trampoline-stub.c8
-rw-r--r--test/unit/jit/tree-printer-test.c634
-rw-r--r--test/unit/vm/Makefile2
30 files changed, 0 insertions, 2548 deletions
diff --git a/Makefile b/Makefile
index 1a071d9b..a508ec92 100644
--- a/Makefile
+++ b/Makefile
@@ -324,7 +324,6 @@ $(LIB_FILE): monoburg boehmgc $(VERSION_HEADER) $(ASM_OFFSETS_HEADER) $(CLASSPAT
check-unit: arch/$(ARCH)/insn-selector$(ARCH_POSTFIX).c
+$(MAKE) -C test/unit/vm/ SYS=$(SYS) ARCH=$(ARCH) ARCH_POSTFIX=$(ARCH_POSTFIX) $(TEST)
- +$(MAKE) -C test/unit/jit/ SYS=$(SYS) ARCH=$(ARCH) ARCH_POSTFIX=$(ARCH_POSTFIX) $(TEST)
+$(MAKE) -C test/unit/arch-$(ARCH)/ SYS=$(SYS) ARCH=$(ARCH) ARCH_POSTFIX=$(ARCH_POSTFIX) $(TEST)
.PHONY: check-unit
@@ -479,7 +478,6 @@ clean:
+$(Q) - $(MAKE) -C boehmgc/ clean >/dev/null
+$(Q) - $(MAKE) -C test/functional/jni/ clean >/dev/null
+$(Q) - $(MAKE) -C test/unit/vm/ clean >/dev/null
- +$(Q) - $(MAKE) -C test/unit/jit/ clean >/dev/null
+$(Q) - $(MAKE) -C test/unit/arch-$(ARCH)/ clean >/dev/null
+$(Q) - $(MAKE) -C test/integration/ clean >/dev/null
.PHONY: clean
diff --git a/arch/mmix/args.c b/arch/mmix/args.c
deleted file mode 100644
index 94898cca..00000000
--- a/arch/mmix/args.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "vm/method.h"
-#include "jit/args.h"
-
-#include <stdlib.h>
-
-#ifdef CONFIG_ARGS_MAP
-int args_map_init(struct vm_method *method)
-{
- size_t size;
-
- /* If the method isn't static, we have a *this. */
- size = method->args_count + !vm_method_is_static(method);
-
- method->args_map = malloc(sizeof(struct vm_args_map) * size);
- if (!method->args_map)
- return -1;
-
- return 0;
-}
-#endif
diff --git a/arch/mmix/call.c b/arch/mmix/call.c
deleted file mode 100644
index 9c3f2440..00000000
--- a/arch/mmix/call.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2009 Pekka Enberg
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-
-#include "vm/method.h"
-#include "vm/call.h"
-
-void native_call(struct vm_method *method, void *target, unsigned long *args, union jvalue *result)
-{
-}
diff --git a/arch/mmix/include/arch/args.h b/arch/mmix/include/arch/args.h
deleted file mode 100644
index 2f95e73c..00000000
--- a/arch/mmix/include/arch/args.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef MMIX_ARGS_H
-#define MMIX_ARGS_H
-
-#include "arch/registers.h"
-
-#include "jit/expression.h"
-
-#include "vm/method.h"
-
-static inline void args_finish(unsigned long *state)
-{
-}
-
-static inline int args_init(unsigned long *state,
- struct vm_method *method,
- unsigned long nr_args)
-{
- return 0;
-}
-
-static inline int args_set(unsigned long *state,
- struct vm_method *method,
- struct expression *expr)
-{
- return 0;
-}
-
-#endif /* MMIX_ARGS_H */
diff --git a/arch/mmix/include/arch/instruction.h b/arch/mmix/include/arch/instruction.h
deleted file mode 100644
index 245152fa..00000000
--- a/arch/mmix/include/arch/instruction.h
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef __ARCH_INSTRUCTION_H
-#define __ARCH_INSTRUCTION_H
-
-#include "arch/registers.h"
-
-#include "jit/use-position.h"
-#include "jit/basic-block.h"
-#include "jit/vars.h"
-
-#include <stdbool.h>
-
-struct compilation_unit;
-struct stack_slot;
-
-/*
- * This is MMIX. See the following URL for details:
- *
- * http://www-cs-staff.stanford.edu/~uno/mmop.html
- */
-
-enum operand_type {
- OPERAND_NONE,
- OPERAND_BRANCH,
- OPERAND_IMM,
- OPERAND_LOCAL,
- OPERAND_REG,
-};
-
-struct operand {
- enum operand_type type;
- union {
- struct use_position reg;
- unsigned long imm;
- struct stack_slot *slot; /* frame pointer + displacement */
- struct basic_block *branch_target;
- };
-};
-
-enum insn_type {
- INSN_ADD,
- INSN_JMP,
- INSN_SETL,
- INSN_LD_LOCAL, /* X = destination register, Y = source stack slot */
- INSN_ST_LOCAL, /* X = source reg, Y = destination stack slot */
-};
-
-enum insn_flag_type {
- INSN_FLAG_KNOWN_BC_OFFSET = 1U << 0,
-};
-
-struct insn {
- uint8_t type; /* see enum insn_type */
- uint8_t flags; /* see enum insn_flag_type */
- uint16_t bc_offset;
- unsigned long lir_pos; /* offset in LIR */
- unsigned long mach_offset; /* offset in machine code */
- struct list_head insn_list_node;
- union {
- struct operand operands[3];
- struct {
- struct operand x, y, z;
- };
- struct operand operand;
- };
-};
-
-#define MAX_REG_OPERANDS 3
-
-static inline unsigned long lir_position(struct use_position *reg)
-{
- return reg->insn->lir_pos;
-}
-
-struct insn *arithmetic_insn(enum insn_type, struct var_info *, struct var_info *, struct var_info *);
-struct insn *imm_insn(enum insn_type, unsigned long, struct var_info *);
-struct insn *branch_insn(enum insn_type, struct basic_block *);
-struct insn *st_insn(enum insn_type, struct var_info *, struct stack_slot *);
-struct insn *ld_insn(enum insn_type, struct stack_slot *, struct var_info *);
-
-/*
- * These functions are used by generic code to insert spill/reload
- * instructions.
- */
-
-int insert_copy_slot_32_insns(struct stack_slot *, struct stack_slot *, struct list_head *, unsigned long);
-int insert_copy_slot_64_insns(struct stack_slot *, struct stack_slot *, struct list_head *, unsigned long);
-
-static inline struct insn *
-spill_insn(struct var_info *var, struct stack_slot *slot)
-{
- return st_insn(INSN_ST_LOCAL, var, slot);
-}
-
-static inline struct insn *
-reload_insn(struct stack_slot *slot, struct var_info *var)
-{
- return ld_insn(INSN_LD_LOCAL, slot, var);
-}
-
-static inline struct insn *
-exception_spill_insn(struct stack_slot *slot)
-{
- return NULL;
-}
-
-static inline bool insn_is_branch(struct insn *insn)
-{
- return insn->type == INSN_JMP;
-}
-
-static inline const char *reg_name(enum machine_reg reg)
-{
- return "<unknown>";
-}
-
-static inline bool insn_is_call(struct insn *insn)
-{
- return false;
-}
-
-#endif /* __ARCH_INSTRUCTION_H */
diff --git a/arch/mmix/include/arch/registers.h b/arch/mmix/include/arch/registers.h
deleted file mode 100644
index a2d0aa42..00000000
--- a/arch/mmix/include/arch/registers.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef __JIT_REGISTERS_H
-#define __JIT_REGISTERS_H
-
-#include <stdbool.h>
-#include <limits.h>
-
-#include "vm/types.h"
-
-enum machine_reg {
- MACH_REG_R0,
- MACH_REG_R1,
- MACH_REG_R2,
-
- /* Number of general purpose registers. */
- NR_GP_REGISTERS,
-
- /* The above registers are available for register allocator. */
- NR_REGISTERS = NR_GP_REGISTERS,
-
- /* The above registers are available for get_fixed_var(). */
- NR_FIXED_REGISTERS = NR_REGISTERS,
-
- MACH_REG_UNASSIGNED = CHAR_MAX,
-};
-
-struct register_state {
-};
-
-#define NR_CALLER_SAVE_REGS 0
-extern enum machine_reg caller_save_regs[NR_CALLER_SAVE_REGS];
-
-static inline bool reg_supports_type(enum machine_reg reg, enum vm_type type)
-{
- return true;
-}
-
-#define GPR_VM_TYPE J_LONG
-
-static inline enum vm_type reg_default_type(enum machine_reg reg)
-{
- return GPR_VM_TYPE;
-}
-
-static inline enum machine_reg args_map_alloc_gpr(int gpr)
-{
- return gpr;
-}
-
-#endif /* __JIT_REGISTERS_H */
diff --git a/arch/mmix/include/arch/stack-frame.h b/arch/mmix/include/arch/stack-frame.h
deleted file mode 100644
index 6050f28d..00000000
--- a/arch/mmix/include/arch/stack-frame.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef MMIX_STACK_FRAME_H
-#define MMIX_STACK_FRAME_H
-
-#include <stdbool.h>
-
-struct jit_stack_frame {
- void *prev;
- unsigned long return_address;
-};
-
-struct native_stack_frame {
- void *prev;
- unsigned long return_address;
-};
-
-#endif /* MMIX_STACK_FRAME_H */
diff --git a/arch/mmix/include/arch/text.h b/arch/mmix/include/arch/text.h
deleted file mode 100644
index b9c5b497..00000000
--- a/arch/mmix/include/arch/text.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef JATO_MMIX_TEXT_H
-#define JATO_MMIX_TEXT_H
-
-#define TEXT_ALIGNMENT sizeof(void *)
-
-#define TEXT_MAP_FLAGS 0
-
-#endif /* JATO_MMIX_TEXT_H */
diff --git a/arch/mmix/instruction.c b/arch/mmix/instruction.c
deleted file mode 100644
index baa42627..00000000
--- a/arch/mmix/instruction.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (C) 2007 Pekka Enberg
- *
- * This file is released under the GPL version 2. Please refer to the file
- * LICENSE for details.
- */
-
-#include "lib/list.h"
-
-#include "arch/instruction.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-struct insn *alloc_insn(enum insn_type type)
-{
- struct insn *insn = malloc(sizeof *insn);
- if (insn) {
- memset(insn, 0, sizeof *insn);
- INIT_LIST_HEAD(&insn->insn_list_node);
- insn->type = type;
- }
- return insn;
-}
-
-void free_insn(struct insn *insn)
-{
- free(insn);
-}
-
-static void init_none_operand(struct insn *insn, unsigned long idx)
-{
- struct operand *operand = &insn->operands[idx];
-
- operand->type = OPERAND_NONE;
-}
-
-static void init_branch_operand(struct insn *insn, unsigned long idx, struct basic_block *if_true)
-{
- struct operand *operand = &insn->operands[idx];
-
- operand->type = OPERAND_BRANCH;
- operand->branch_target = if_true;
-}
-
-static void init_imm_operand(struct insn *insn, unsigned long idx, unsigned long imm)
-{
- struct operand *operand = &insn->operands[idx];
-
- operand->type = OPERAND_IMM;
- operand->imm = imm;
-}
-
-static void init_local_operand(struct insn *insn, unsigned long idx, struct stack_slot *slot)
-{
- struct operand *operand = &insn->operands[idx];
-
- operand->type = OPERAND_LOCAL;
- operand->slot = slot;
-}
-
-static void init_reg_operand(struct insn *insn, unsigned long idx, struct var_info *reg)
-{
- struct operand *operand = &insn->operands[idx];
-
- operand->type = OPERAND_REG;
- init_register(&operand->reg, insn, reg->interval);
-}
-
-struct insn *imm_insn(enum insn_type insn_type, unsigned long imm, struct var_info *result)
-{
- struct insn *insn = alloc_insn(insn_type);
- if (insn) {
- init_reg_operand(insn, 0, result);
- init_imm_operand(insn, 1, imm);
- /* part of the immediate is stored in z but it's unused here */
- init_none_operand(insn, 2);
- }
- return insn;
-}
-
-struct insn *arithmetic_insn(enum insn_type insn_type, struct var_info *z, struct var_info *y, struct var_info *x)
-{
- struct insn *insn = alloc_insn(insn_type);
- if (insn) {
- init_reg_operand(insn, 0, x);
- init_reg_operand(insn, 1, y);
- init_reg_operand(insn, 2, z);
- }
- return insn;
-}
-
-struct insn *branch_insn(enum insn_type insn_type, struct basic_block *if_true)
-{
- struct insn *insn = alloc_insn(insn_type);
- if (insn) {
- init_branch_operand(insn, 0, if_true);
- init_none_operand(insn, 1);
- init_none_operand(insn, 2);
- }
- return insn;
-}
-
-struct insn *st_insn(enum insn_type insn_type, struct var_info *var, struct stack_slot *slot)
-{
- struct insn *insn = alloc_insn(insn_type);
- if (insn) {
- init_reg_operand(insn, 0, var);
- init_local_operand(insn, 1, slot);
- init_none_operand(insn, 2);
- }
- return insn;
-}
-
-struct insn *ld_insn(enum insn_type insn_type, struct stack_slot *slot, struct var_info *var)
-{
- struct insn *insn = alloc_insn(insn_type);
- if (insn) {
- init_reg_operand(insn, 0, var);
- init_local_operand(insn, 1, slot);
- init_none_operand(insn, 2);
- }
- return insn;
-}
-
-int insert_copy_slot_32_insns(struct stack_slot *from, struct stack_slot *to,
- struct list_head *add_before, unsigned long bc_offset)
-{
- return 0;
-}
-
-int insert_copy_slot_64_insns(struct stack_slot *from, struct stack_slot *to,
- struct list_head *add_before, unsigned long bc_offset)
-{
- return 0;
-}
diff --git a/arch/mmix/register.c b/arch/mmix/register.c
deleted file mode 100644
index 8aa587b8..00000000
--- a/arch/mmix/register.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "arch/registers.h"
-#include "jit/vars.h"
-
-enum machine_reg caller_save_regs[NR_CALLER_SAVE_REGS] = {};
diff --git a/arch/mmix/stack-frame.c b/arch/mmix/stack-frame.c
deleted file mode 100644
index f54c5788..00000000
--- a/arch/mmix/stack-frame.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2009 Tomasz Grabiec
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-
-#include "arch/stack-frame.h"
diff --git a/arch/mmix/use-def.c b/arch/mmix/use-def.c
deleted file mode 100644
index 654bb859..00000000
--- a/arch/mmix/use-def.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2007 Pekka Enberg
- *
- * This file is released under the GPL version 2. Please refer to the file
- * LICENSE for details.
- */
-
-#include "jit/compilation-unit.h"
-#include "arch/instruction.h"
-
-enum {
- NO_USE_DEF = 0,
- DEF_X = 1,
- USE_Y = 4,
- USE_Z = 8,
-};
-
-struct insn_info {
- unsigned char flags;
-};
-
-#define DECLARE_INFO(_type, _flags) [_type] = { .flags = _flags }
-
-static struct insn_info insn_infos[] = {
- DECLARE_INFO(INSN_ADD, DEF_X | USE_Y | USE_Z),
- DECLARE_INFO(INSN_JMP, NO_USE_DEF),
- DECLARE_INFO(INSN_SETL, DEF_X),
-};
-
-static inline struct insn_info *get_info(struct insn *insn)
-{
- return insn_infos + insn->type;
-}
-
-int insn_defs(struct compilation_unit *cu, struct insn *insn, struct var_info **defs)
-{
- struct insn_info *info;
- int nr = 0;
-
- info = get_info(insn);
-
- if (info->flags & DEF_X)
- defs[nr++] = insn->x.reg.interval->var_info;
-
- return nr;
-}
-
-int insn_uses(struct insn *insn, struct var_info **uses)
-{
- struct insn_info *info;
- int nr = 0;
-
- info = get_info(insn);
-
- if (info->flags & USE_Y)
- uses[nr++] = insn->y.reg.interval->var_info;
-
- if (info->flags & USE_Z)
- uses[nr++] = insn->z.reg.interval->var_info;
-
- return nr;
-}
diff --git a/test/unit/jit/Makefile b/test/unit/jit/Makefile
deleted file mode 100644
index 6dc0c624..00000000
--- a/test/unit/jit/Makefile
+++ /dev/null
@@ -1,91 +0,0 @@
-RUNNER=jit-test-runner
-SUITE=jit-test-suite.c
-
-TOPLEVEL_OBJS := \
- sys/$(SYS)-$(ARCH)/backtrace.o \
- cafebabe/attribute_array.o \
- cafebabe/attribute_info.o \
- cafebabe/class.o \
- cafebabe/constant_pool.o \
- cafebabe/error.o \
- cafebabe/field_info.o \
- cafebabe/method_info.o \
- cafebabe/source_file_attribute.o \
- cafebabe/stream.o \
- jit/args.o \
- jit/basic-block.o \
- jit/bc-offset-mapping.o \
- jit/cfg-analyzer.o \
- jit/compilation-unit.o \
- jit/constant-pool.o \
- jit/cu-mapping.o \
- jit/dominance.o \
- jit/exception.o \
- jit/expression.o \
- jit/fixup-site.o \
- jit/interval.o \
- jit/linear-scan.o \
- jit/liveness.o \
- jit/method.o \
- jit/spill-reload.o \
- jit/stack-slot.o \
- jit/statement.o \
- jit/text.o \
- jit/tree-node.o \
- jit/tree-printer.o \
- jit/subroutine.o \
- jit/pc-map.o \
- jit/constant_pool.o \
- lib/arena.o \
- lib/bitset.o \
- lib/buffer.o \
- lib/compile-lock.o \
- lib/guard-page.o \
- lib/hash-map.o \
- lib/list.o \
- lib/pqueue.o \
- lib/radix-tree.o \
- lib/stack.o \
- lib/string.o \
- lib/symbol.o \
- vm/call.o \
- vm/bytecode.o \
- vm/die.o \
- vm/trace.o \
- vm/types.o \
- vm/zalloc.o \
- arch/mmix/args.o \
- arch/mmix/call.o \
- arch/mmix/instruction.o \
- arch/mmix/register.o \
- arch/mmix/stack-frame.o \
- arch/mmix/use-def.o \
- test/unit/libharness/libharness.o \
- test/unit/vm/class-stub.o \
- test/unit/vm/classloader-stub.o \
- test/unit/vm/gc-stub.o \
- test/unit/vm/object-stub.o \
- test/unit/vm/preload-stub.o \
- test/unit/vm/jni-stub.o \
- test/unit/vm/stack-trace-stub.o \
- test/unit/vm/thread-stub.o \
- test/unit/jit/trace-stub.o
-
-TEST_OBJS := \
- args-test-utils.o \
- basic-block-test.o \
- bc-test-utils.o \
- cfg-analyzer-test.o \
- compilation-unit-test.o \
- dominance-test.o \
- expression-test.o \
- linear-scan-test.o \
- live-range-test.o \
- liveness-test.o \
- spill-reload-test.o \
- stack-slot-test.o \
- tree-printer-test.o
-
-include ../../../scripts/build/test.mk
-
-DEFAULT_CFLAGS += -I../../../arch/mmix/include -std=gnu99
diff --git a/test/unit/jit/args-test-utils.c b/test/unit/jit/args-test-utils.c
deleted file mode 100644
index 7fe6b873..00000000
--- a/test/unit/jit/args-test-utils.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2008 Pekka Enberg
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-
-#include "jit/compilation-unit.h"
-#include "jit/expression.h"
-
-#include <bc-test-utils.h>
-#include <libharness.h>
-
-void create_args(struct expression **args, int nr_args)
-{
- int i;
-
- for (i = 0; i < nr_args; i++) {
- args[i] = value_expr(J_INT, i);
- }
-}
-
-void push_args(struct basic_block *bb, struct expression **args, int nr_args)
-{
- int i;
-
- for (i = 0; i < nr_args; i++) {
- stack_push(bb->mimic_stack, args[i]);
- }
-}
-
-void assert_args(struct expression **expected_args,int nr_args,
- struct expression *args_list)
-{
- int i;
- struct expression *tree = args_list;
- struct expression *actual_args[nr_args];
-
- if (nr_args == 0) {
- assert_int_equals(EXPR_NO_ARGS, expr_type(args_list));
- return;
- }
-
- i = 0;
- while (i < nr_args) {
- if (expr_type(tree) == EXPR_ARGS_LIST) {
- struct expression *expr = to_expr(tree->node.kids[1]);
- actual_args[i++] = to_expr(expr->arg_expression);
- tree = to_expr(tree->node.kids[0]);
- } else if (expr_type(tree) == EXPR_ARG) {
- actual_args[i++] = to_expr(tree->arg_expression);
- break;
- } else {
- assert_true(false);
- break;
- }
- }
-
- assert_int_equals(i, nr_args);
-
- for (i = 0; i < nr_args; i++)
- assert_ptr_equals(expected_args[i], actual_args[i]);
-}
diff --git a/test/unit/jit/args-test-utils.h b/test/unit/jit/args-test-utils.h
deleted file mode 100644
index 659e0d27..00000000
--- a/test/unit/jit/args-test-utils.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __ARGS_TEST_UTILS_H
-#define __ARGS_TEST_UTILS_H
-
-struct basic_block;
-struct expression;
-
-void create_args(struct expression **args, int nr_args);
-void push_args(struct basic_block *bb, struct expression **args, int nr_args);
-void assert_args(struct expression **expected_args, int nr_args, struct expression *args_list);
-
-#endif
diff --git a/test/unit/jit/basic-block-assert.h b/test/unit/jit/basic-block-assert.h
deleted file mode 100644
index 546559f9..00000000
--- a/test/unit/jit/basic-block-assert.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef __JIT_BASIC_BLOCK_ASSERT_H
-#define __JIT_BASIC_BLOCK_ASSERT_H
-
-#include <libharness.h>
-
-static void inline
-assert_basic_block(struct compilation_unit *parent, unsigned long start,
- unsigned long end, struct basic_block *bb)
-{
- assert_ptr_equals(parent, bb->b_parent);
- assert_int_equals(start, bb->start);
- assert_int_equals(end, bb->end);
-}
-
-static inline void
-__assert_bb_neighbors(struct basic_block **neigh, int nneigh,
- struct basic_block **array, unsigned long sz)
-{
- int i;
-
- assert_int_equals(sz, nneigh);
-
- for (i = 0; i < nneigh; i++)
- assert_ptr_equals(neigh[i], array[i]);
-}
-
-static inline void
-assert_basic_block_successors(struct basic_block **succ, int nsucc,
- struct basic_block *bb)
-{
- __assert_bb_neighbors(succ, nsucc, bb->successors, bb->nr_successors);
-}
-
-static inline void
-assert_basic_block_predecessors(struct basic_block **pred, int npred,
- struct basic_block *bb)
-{
- __assert_bb_neighbors(pred, npred, bb->predecessors, bb->nr_predecessors);
-}
-
-#endif
diff --git a/test/unit/jit/basic-block-test.c b/test/unit/jit/basic-block-test.c
deleted file mode 100644
index e2c2869b..00000000
--- a/test/unit/jit/basic-block-test.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2006 Pekka Enberg
- */
-
-#include "jit/basic-block.h"
-#include "jit/compilation-unit.h"
-#include <basic-block-assert.h>
-#include "jit/statement.h"
-#include "vm/vm.h"
-
-#include "arch/instruction.h"
-
-#include <libharness.h>
-#include <stddef.h>
-
-static struct cafebabe_method_info method_info;
-static struct vm_method method = { .method = &method_info, };
-
-void test_split_with_out_of_range_offset(void)
-{
- struct compilation_unit *cu;
- struct basic_block *bb;
-
- cu = compilation_unit_alloc(&method);
- bb = get_basic_block(cu, 1, 2);
-
- assert_ptr_equals(NULL, bb_split(bb, 0));
- assert_ptr_equals(NULL, bb_split(bb, 3));
-
- free_compilation_unit(cu);
-}
-
-void test_split_basic_block(void)
-{
- struct basic_block *bb, *new_bb;
- struct compilation_unit *cu;
-
- cu = compilation_unit_alloc(&method);
- bb = get_basic_block(cu, 0, 3);
-
- new_bb = bb_split(bb, 2);
-
- assert_basic_block(cu, 0, 2, bb);
- assert_basic_block(cu, 2, 3, new_bb);
-
- free_compilation_unit(cu);
-}
-
-void test_split_basic_block_with_branch(void)
-{
- struct basic_block *bb, *new_bb, *target_bb;
- struct compilation_unit *cu;
-
- cu = compilation_unit_alloc(&method);
- bb = get_basic_block(cu, 0, 4);
-
- target_bb = bb_split(bb, 3);
-
- bb->has_branch = true;
- bb_add_successor(bb, target_bb);
-
- new_bb = bb_split(bb, 2);
-
- assert_true(new_bb->has_branch);
- assert_false(bb->has_branch);
-
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb);
- assert_basic_block_successors((struct basic_block*[]){target_bb}, 1, new_bb);
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/bc-test-utils.h b/test/unit/jit/bc-test-utils.h
deleted file mode 100644
index 7cbb4593..00000000
--- a/test/unit/jit/bc-test-utils.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef __BYTECODE_CONVERTER_FIXTURE_H
-#define __BYTECODE_CONVERTER_FIXTURE_H
-
-#include "jit/statement.h"
-#include "lib/list.h"
-
-struct compilation_unit;
-struct basic_block;
-struct vm_method;
-
-static inline struct statement *stmt_entry(struct list_head *head)
-{
- return list_entry(head, struct statement, stmt_list_node);
-}
-
-struct compilation_unit *alloc_simple_compilation_unit(struct vm_method *);
-struct basic_block *__alloc_simple_bb(struct vm_method *);
-struct basic_block *alloc_simple_bb(unsigned char *, unsigned long);
-void __free_simple_bb(struct basic_block *);
-void free_simple_bb(struct basic_block *);
-
-void assert_value_expr(enum vm_type, long long, struct tree_node *);
-void assert_nullcheck_value_expr(enum vm_type, long long, struct tree_node *);
-void assert_fvalue_expr(enum vm_type, double, struct tree_node *);
-void assert_local_expr(enum vm_type, unsigned long, struct tree_node *);
-void assert_temporary_expr(enum vm_type, struct tree_node *);
-void assert_array_deref_expr(enum vm_type, struct expression *,
- struct expression *, struct tree_node *);
-void __assert_binop_expr(enum vm_type, enum binary_operator,
- struct tree_node *);
-void assert_binop_expr(enum vm_type, enum binary_operator,
- struct expression *, struct expression *,
- struct tree_node *);
-void assert_conv_expr(enum vm_type, enum expression_type, struct expression *, struct tree_node *);
-void assert_trunc_expr(enum vm_type, enum expression_type, struct expression *, struct tree_node *);
-void assert_class_field_expr(enum vm_type, struct vm_field *, struct tree_node *);
-void assert_instance_field_expr(enum vm_type, struct vm_field *, struct expression *, struct tree_node *);
-void assert_invoke_stmt(enum vm_type, struct vm_method *, struct tree_node *);
-void assert_array_size_check_expr(struct expression *, struct expression *);
-void assert_multiarray_size_check_expr(struct expression **, int, struct expression *);
-void assert_store_stmt(struct statement *);
-void assert_array_store_check_stmt(struct statement *, struct expression *, struct tree_node *);
-void assert_return_stmt(struct expression *, struct statement *);
-void assert_void_return_stmt(struct statement *);
-void assert_null_check_stmt(struct expression *, struct statement *);
-void assert_arraycheck_stmt(enum vm_type, struct expression *,
- struct expression *, struct statement *);
-void assert_monitorenter_stmt(struct expression *, struct statement *);
-void assert_monitorexit_stmt(struct expression *, struct statement *);
-void assert_checkcast_stmt(struct expression *, struct statement *);
-
-void convert_ir_const(struct compilation_unit *, uint32_t *, size_t, uint8_t *);
-
-struct statement *first_stmt(struct compilation_unit *cu);
-
-#endif
diff --git a/test/unit/jit/cfg-analyzer-test.c b/test/unit/jit/cfg-analyzer-test.c
deleted file mode 100644
index 72a2d45c..00000000
--- a/test/unit/jit/cfg-analyzer-test.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2006 Pekka Enberg
- */
-
-#include "vm/method.h"
-#include "vm/system.h"
-#include "vm/vm.h"
-#include "jit/compiler.h"
-#include <libharness.h>
-#include <basic-block-assert.h>
-
-/* public String defaultString(String s) { if (s == null) { s = ""; } return s; } */
-static unsigned char default_string[9] = {
- /* 0 */ OPC_ALOAD_1,
- /* 1 */ OPC_IFNONNULL, 0x00, 0x06, /* Jumps to 0x07 */
-
- /* 4 */ OPC_LDC, 0x02,
- /* 6 */ OPC_ASTORE_1,
-
- /* 7 */ OPC_ALOAD_1,
- /* 8 */ OPC_ARETURN,
-};
-
-void test_branch_opcode_ends_basic_block(void)
-{
- struct basic_block *bb1, *bb2, *bb3;
- struct compilation_unit *cu;
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = default_string,
- .code_attribute.code_length = ARRAY_SIZE(default_string),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
-
- assert_int_equals(3, nr_bblocks(cu));
-
- bb1 = bb_entry(cu->bb_list.next);
- bb2 = bb_entry(bb1->bb_list_node.next);
- bb3 = bb_entry(bb2->bb_list_node.next);
-
- assert_basic_block(cu, 0, 4, bb1);
- assert_basic_block(cu, 4, 7, bb2);
- assert_basic_block(cu, 7, 9, bb3);
-
- assert_basic_block_successors((struct basic_block*[]){bb2, bb3}, 2, bb1);
- assert_basic_block_successors((struct basic_block*[]){bb3 }, 1, bb2);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb3);
-
- free_compilation_unit(cu);
-}
-
-/* public boolean greaterThanZero(int i) { return i > 0; } */
-static unsigned char greater_than_zero[10] = {
- /* 0 */ OPC_ILOAD_1,
- /* 1 */ OPC_IFLE, 0x00, 0x07,
-
- /* 4 */ OPC_ICONST_1,
- /* 5 */ OPC_GOTO, 0x00, 0x04,
-
- /* 8 */ OPC_ICONST_0,
-
- /* 9 */ OPC_IRETURN,
-};
-
-void test_multiple_branches(void)
-{
- struct basic_block *bb1, *bb2, *bb3, *bb4;
- struct compilation_unit *cu;
-
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = greater_than_zero,
- .code_attribute.code_length = ARRAY_SIZE(greater_than_zero),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- assert_int_equals(4, nr_bblocks(cu));
-
- bb1 = bb_entry(cu->bb_list.next);
- bb2 = bb_entry(bb1->bb_list_node.next);
- bb3 = bb_entry(bb2->bb_list_node.next);
- bb4 = bb_entry(bb3->bb_list_node.next);
-
- assert_basic_block_successors((struct basic_block*[]){bb2, bb3}, 2, bb1);
- assert_basic_block_successors((struct basic_block*[]){bb4 }, 1, bb2);
- assert_basic_block_successors((struct basic_block*[]){bb4 }, 1, bb3);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb4);
-
- free_compilation_unit(cu);
-}
-
-/*
- * public void setValue(int i) {
- * int j;
- *
- * if (i == 0)
- * j = 0;
- *
- * j = 0;
- *
- * if (i = 0)
- * j = 0;
- *
- * return;
- * }
- */
-static unsigned char set_value[15] = {
- /* 0 */ OPC_ILOAD_0,
- /* 1 */ OPC_IFNE, 0x00, 0x05, /* jump to 0x06 */
-
- /* 4 */ OPC_ICONST_0,
- /* 5 */ OPC_ISTORE_1,
-
- /* 6 */ OPC_ICONST_0,
- /* 7 */ OPC_ISTORE_1,
- /* 8 */ OPC_ILOAD_0,
- /* 9 */ OPC_IFNE, 0x00, 0x05, /* jump tp 0x0E */
-
- /* 12 */ OPC_ICONST_0,
- /* 13 */ OPC_ISTORE_1,
-
- /* 14 */ OPC_RETURN,
-
-};
-
-void test_multiple_branch_with_target_instruction_splitting(void)
-{
- struct basic_block *bb1, *bb2, *bb3, *bb4, *bb5;
- struct compilation_unit *cu;
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = set_value,
- .code_attribute.code_length = ARRAY_SIZE(set_value),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
-
- assert_int_equals(5, nr_bblocks(cu));
-
- bb1 = bb_entry(cu->bb_list.next);
- bb2 = bb_entry(bb1->bb_list_node.next);
- bb3 = bb_entry(bb2->bb_list_node.next);
- bb4 = bb_entry(bb3->bb_list_node.next);
- bb5 = bb_entry(bb4->bb_list_node.next);
-
- assert_basic_block(cu, 0, 4, bb1);
- assert_basic_block(cu, 4, 6, bb2);
- assert_basic_block(cu, 6, 12, bb3);
- assert_basic_block(cu, 12, 14, bb4);
- assert_basic_block(cu, 14, 15, bb5);
-
- assert_basic_block_successors((struct basic_block*[]){bb2, bb3}, 2, bb1);
- assert_basic_block_successors((struct basic_block*[]){bb3 }, 1, bb2);
- assert_basic_block_successors((struct basic_block*[]){bb4, bb5}, 2, bb3);
- assert_basic_block_successors((struct basic_block*[]){bb5 }, 1, bb4);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb5);
-
- free_compilation_unit(cu);
-}
-
-/* public boolean emptyIf() { boolean d = true; if (d){} return d; } */
-static unsigned char empty_if[8] = {
- /* 0 */ OPC_ICONST_1,
- /* 1 */ OPC_ISTORE_1,
-
- /* 3 */ OPC_ILOAD_1,
- /* 4 */ OPC_IFEQ, 0x00, 0x03,
-
- /* 6 */ OPC_ILOAD_1,
- /* 7 */ OPC_IRETURN,
-};
-
-void test_no_duplicate_in_successors_bb_list(void)
-{
- struct basic_block *bb1, *bb2;
- struct compilation_unit *cu;
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = empty_if,
- .code_attribute.code_length = ARRAY_SIZE(empty_if),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
-
- assert_int_equals(2, nr_bblocks(cu));
-
- bb1 = bb_entry(cu->bb_list.next);
- bb2 = bb_entry(bb1->bb_list_node.next);
-
- assert_basic_block(cu, 0, 6, bb1);
- assert_basic_block(cu, 6, 8, bb2);
-
- assert_basic_block_successors((struct basic_block*[]){bb2}, 1, bb1);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb2);
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/compilation-unit-test.c b/test/unit/jit/compilation-unit-test.c
deleted file mode 100644
index 5ae7eef0..00000000
--- a/test/unit/jit/compilation-unit-test.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2006 Pekka Enberg
- */
-
-#include <libharness.h>
-#include "jit/instruction.h"
-#include "jit/compilation-unit.h"
-#include "vm/method.h"
-#include "vm/vm.h"
-
-static struct cafebabe_method_info method_info;
-static struct vm_method method = { .method = &method_info };
-
-void test_find_basic_block(void)
-{
- struct basic_block *b1;
- struct basic_block *b2;
- struct basic_block *b3;
- struct compilation_unit *cu = compilation_unit_alloc(&method);
-
- b1 = alloc_basic_block(cu, 0, 3);
- b2 = alloc_basic_block(cu, 3, 5);
- b3 = alloc_basic_block(cu, 5, 6);
-
- list_add_tail(&b1->bb_list_node, &cu->bb_list);
- list_add_tail(&b2->bb_list_node, &cu->bb_list);
- list_add_tail(&b3->bb_list_node, &cu->bb_list);
-
- assert_ptr_equals(b1, find_bb(cu, 2));
- assert_ptr_equals(b2, find_bb(cu, 3));
- assert_ptr_equals(b3, find_bb(cu, 5));
-
- free_compilation_unit(cu);
-}
-
-void test_no_basic_block_when_offset_out_of_range(void)
-{
- struct compilation_unit *cu = compilation_unit_alloc(&method);
- struct basic_block *block = alloc_basic_block(cu, 1, 2);
-
- list_add_tail(&block->bb_list_node, &cu->bb_list);
- assert_ptr_equals(NULL, find_bb(cu, 0));
- assert_ptr_equals(NULL, find_bb(cu, 2));
-
- free_compilation_unit(cu);
-}
-
-void test_instruction_positions_are_computed_in_basic_block_order(void)
-{
- struct compilation_unit *cu = compilation_unit_alloc(&method);
- struct basic_block *b1, *b2;
- struct insn *insns[4];
- unsigned long i;
-
- for (i = 0; i < ARRAY_SIZE(insns); i++)
- insns[i] = alloc_insn(INSN_ADD);
-
- b1 = get_basic_block(cu, 0, ARRAY_SIZE(insns)/2);
- for (i = 0 ; i < ARRAY_SIZE(insns) / 2; i++)
- bb_add_insn(b1, insns[i]);
-
- b2 = get_basic_block(cu, ARRAY_SIZE(insns) / 2, ARRAY_SIZE(insns));
- for (i = ARRAY_SIZE(insns) / 2 ; i < ARRAY_SIZE(insns); i++)
- bb_add_insn(b2, insns[i]);
-
- compute_insn_positions(cu);
-
- for (i = 0; i < ARRAY_SIZE(insns); i++)
- assert_int_equals(i * 2, insns[i]->lir_pos);
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/dominance-test.c b/test/unit/jit/dominance-test.c
deleted file mode 100644
index 70770323..00000000
--- a/test/unit/jit/dominance-test.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "vm/method.h"
-#include "vm/system.h"
-#include "vm/vm.h"
-#include "vm/trace.h"
-
-#include "jit/compiler.h"
-#include "lib/bitset.h"
-#include <libharness.h>
-#include <basic-block-assert.h>
-
-/* A complex test:
- public void dominance()
- {
- int a, b, c;
-
- a = 1;
- b = 4;
- c = 5;
-
- if (a > 2)
- {
- a = 3;
- }else
- {
- while(b > 3)
- {
- if (a == 1)
- {
- c = 5;
- }else{
- c = 4;
- }
-
- b--;
- }
- }
- }
-*/
-static unsigned char dominance[40] = {
- /* 0 */ OPC_ICONST_1,
- /* 1 */ OPC_ISTORE_1,
- /* 2 */ OPC_ICONST_4,
- /* 3 */ OPC_ISTORE_2,
- /* 4 */ OPC_ICONST_5,
- /* 5 */ OPC_ISTORE_3,
- /* 6 */ OPC_ILOAD_1,
- /* 7 */ OPC_ICONST_2,
- /* 8 */ OPC_IF_ICMPLE, 0x00, 0x08,
- /* 11 */ OPC_ICONST_3,
- /* 12 */ OPC_ISTORE_1,
- /* 13 */ OPC_GOTO, 0x00, 0x1a,
- /* 16 */ OPC_ILOAD_2,
- /* 17 */ OPC_ICONST_3,
- /* 18 */ OPC_IF_ICMPLE, 0x00, 0x15,
- /* 21 */ OPC_ILOAD_1,
- /* 22 */ OPC_ICONST_1,
- /* 23 */ OPC_IF_ICMPNE, 0x00, 0x08,
- /* 26 */ OPC_ICONST_5,
- /* 27 */ OPC_ISTORE_3,
- /* 28 */ OPC_GOTO, 0x00, 0x05,
- /* 31 */ OPC_ICONST_4,
- /* 32 */ OPC_ISTORE_3,
- /* 33 */ OPC_IINC, 0x02, 0xff,
- /* 36 */ OPC_GOTO, 0xff, 0xec,
- /* 39 */ OPC_RETURN,
-};
-
-void test_dominance(void)
-{
- struct basic_block *bb0, *bb1, *bb2, *bb3, *bb4, *bb5, *bb6, *bb7;
- struct compilation_unit *cu;
-
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = dominance,
- .code_attribute.code_length = ARRAY_SIZE(dominance),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- assert_int_equals(8, nr_bblocks(cu));
-
- bb0 = bb_entry(cu->bb_list.next);
- bb1 = bb_entry(bb0->bb_list_node.next);
- bb2 = bb_entry(bb1->bb_list_node.next);
- bb3 = bb_entry(bb2->bb_list_node.next);
- bb4 = bb_entry(bb3->bb_list_node.next);
- bb5 = bb_entry(bb4->bb_list_node.next);
- bb6 = bb_entry(bb5->bb_list_node.next);
- bb7 = bb_entry(bb6->bb_list_node.next);
-
- compute_dfns(cu);
- compute_dom(cu);
- compute_dom_frontier(cu);
-
- struct bitset *expected = alloc_bitset(cu->nr_vregs);
- bitset_clear_all(expected);
-
- /* There is no block in the dominance frontier set
- * of block 0 */
- assert_bitset_equals(bb0->dom_frontier, expected, bb0->dfn);
-
- /* Block 2 is in the dominance frontier set
- * of block 1 */
- set_bit(expected->bits, 2);
- assert_bitset_equals(bb1->dom_frontier, expected, bb1->dfn);
-
- /* Block 2, 3 are in the dominance frontier set
- * of block 2 */
- set_bit(expected->bits, 3);
- assert_bitset_equals(bb2->dom_frontier, expected, bb2->dfn);
-
- /* Block 3 is in the dominance frontier set
- * of block 3 */
- clear_bit(expected->bits, 2);
- assert_bitset_equals(bb3->dom_frontier, expected, bb3->dfn);
-
- /* Block 6 is in the dominance frontier set
- * of block 4 */
- clear_bit(expected->bits, 3);
- set_bit(expected->bits, 6);
- assert_bitset_equals(bb4->dom_frontier, expected, bb4->dfn);
-
- /* Block 6 is in the dominance frontier set
- * of block 5 */
- assert_bitset_equals(bb5->dom_frontier, expected, bb5->dfn);
-
- /* Block 3 is in the dominance frontier set
- * of block 6 */
- clear_bit(expected->bits, 6);
- set_bit(expected->bits, 3);
- assert_bitset_equals(bb6->dom_frontier, expected, bb6->dfn);
-
- /* There is no block in the dominance frontier set
- * of block 7 */
- clear_bit(expected->bits, 3);
- assert_bitset_equals(bb7->dom_frontier, expected, bb7->dfn);
-}
diff --git a/test/unit/jit/expression-test.c b/test/unit/jit/expression-test.c
deleted file mode 100644
index 9216339a..00000000
--- a/test/unit/jit/expression-test.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2006 Pekka Enberg
- */
-
-#include "jit/expression.h"
-
-#include <libharness.h>
-#include <stdlib.h>
-
-static void assert_nr_args(unsigned long expected, struct expression *args_list)
-{
- assert_int_equals(expected, nr_args(args_list));
- expr_put(args_list);
-}
-
-void test_should_count_zero_arguments_for_noargs(void)
-{
- assert_nr_args(0, no_args_expr());
-}
-
-void test_should_count_all_arguments_in_list(void)
-{
- assert_nr_args(1, arg_expr(value_expr(J_INT, 0)));
- assert_nr_args(2, args_list_expr(arg_expr(value_expr(J_INT, 0)), arg_expr(value_expr(J_INT, 1))));
-}
diff --git a/test/unit/jit/linear-scan-test.c b/test/unit/jit/linear-scan-test.c
deleted file mode 100644
index 88d40cbb..00000000
--- a/test/unit/jit/linear-scan-test.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright © 2007 Pekka Enberg
- */
-
-#include "jit/compiler.h"
-#include "arch/instruction.h"
-#include <libharness.h>
-#include "vm/class.h"
-#include "vm/method.h"
-#include "vm/vm.h"
-
-static struct cafebabe_method_info method_info;
-static struct vm_method method = { .method = &method_info };
-
-void test_allocates_different_registers_for_overlapping_intervals(void)
-{
- struct compilation_unit *cu;
- struct var_info *v1, *v2;
-
- cu = compilation_unit_alloc(&method);
-
- v1 = get_var(cu, J_INT);
- interval_add_range(cu, v1->interval, 0, 2);
-
- v2 = get_var(cu, J_INT);
- interval_add_range(cu, v2->interval, 1, 2);
-
- allocate_registers(cu);
-
- assert(v1->interval->reg != v2->interval->reg);
-
- free_compilation_unit(cu);
-}
-
-void test_reuses_registers_for_non_overlapping_intervals(void)
-{
- struct compilation_unit *cu;
- struct var_info *v1, *v2;
-
- cu = compilation_unit_alloc(&method);
-
- v1 = get_var(cu, J_INT);
- interval_add_range(cu, v1->interval, 0, 2);
-
- v2 = get_var(cu, J_INT);
- interval_add_range(cu, v2->interval, 2, 4);
-
- allocate_registers(cu);
-
- assert_int_equals(v1->interval->reg, v2->interval->reg);
-
- free_compilation_unit(cu);
-}
-
-void test_honors_fixed_interval_register_constraint_for_overlapping_intervals(void)
-{
- struct compilation_unit *cu;
- struct var_info *v1, *v2;
-
- cu = compilation_unit_alloc(&method);
-
- v1 = get_fixed_var(cu, MACH_REG_R0);
- interval_add_range(cu, v1->interval, 0, 2);
-
- v2 = get_var(cu, J_INT);
- interval_add_range(cu, v2->interval, 0, 2);
-
- allocate_registers(cu);
-
- assert(v1->interval->reg != v2->interval->reg);
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/live-range-test.c b/test/unit/jit/live-range-test.c
deleted file mode 100644
index 6d7db6ea..00000000
--- a/test/unit/jit/live-range-test.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2008 Pekka Enberg
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-
-#include "jit/vars.h"
-#include <libharness.h>
-
-void test_empty_range_does_not_contain_anything(void)
-{
- struct live_range range = { .start = 0, .end = 0 };
-
- assert_false(in_range(&range, 0));
- assert_false(in_range(&range, 1));
-}
-
-void test_empy_range_is_empty(void)
-{
- struct live_range range = { .start = 0, .end = 0 };
-
- assert_true(range_is_empty(&range));
-}
-
-void test_range_length_treats_end_as_exclusive(void)
-{
- struct live_range range = { .start = 0, .end = 2 };
-
- assert_int_equals(2, range_len(&range));
-}
-
-void test_in_range_treats_end_as_exclusive(void)
-{
- struct live_range range = { .start = 0, .end = 2 };
-
- assert_true(in_range(&range, 0));
- assert_true(in_range(&range, 1));
- assert_false(in_range(&range, 2));
-}
-
-void test_range_that_is_within_another_range_intersects(void)
-{
- struct live_range range1 = { .start = 0, .end = 3 };
- struct live_range range2 = { .start = 1, .end = 2 };
-
- assert_true(ranges_intersect(&range1, &range2));
- assert_true(ranges_intersect(&range2, &range1));
-}
-
-void test_ranges_that_intersect(void)
-{
- struct live_range range1 = { .start = 0, .end = 2 };
- struct live_range range2 = { .start = 1, .end = 3 };
-
- assert_true(ranges_intersect(&range1, &range2));
- assert_true(ranges_intersect(&range2, &range1));
-}
-
-void test_ranges_that_do_not_intersect(void)
-{
- struct live_range range1 = { .start = 0, .end = 2 };
- struct live_range range2 = { .start = 2, .end = 4 };
-
- assert_false(ranges_intersect(&range1, &range2));
- assert_false(ranges_intersect(&range2, &range1));
-}
-
-void test_interval_add_range(void)
-{
-#if 0
- struct live_interval it;
- struct live_range *r;
-
- INIT_LIST_HEAD(&it.range_list);
-
- interval_add_range(&it, 1, 3);
- r = interval_first_range(&it);
- assert_int_equals(1, r->start);
- assert_int_equals(3, r->end);
- assert_ptr_equals(NULL, next_range(&it.range_list, r));
-
- interval_add_range(&it, 5, 7);
- r = interval_first_range(&it);
- assert_int_equals(1, r->start);
- assert_int_equals(3, r->end);
- r = next_range(&it.range_list, r);
- assert_int_equals(5, r->start);
- assert_int_equals(7, r->end);
- assert_ptr_equals(NULL, next_range(&it.range_list, r));
-
- interval_add_range(&it, 3, 5);
- r = interval_first_range(&it);
- assert_int_equals(1, r->start);
- assert_int_equals(7, r->end);
- assert_ptr_equals(NULL, next_range(&it.range_list, r));
-
- interval_add_range(&it, 7, 8);
- r = interval_first_range(&it);
- assert_int_equals(1, r->start);
- assert_int_equals(8, r->end);
- assert_ptr_equals(NULL, next_range(&it.range_list, r));
-
- interval_add_range(&it, 10, 13);
- r = interval_first_range(&it);
- assert_int_equals(1, r->start);
- assert_int_equals(8, r->end);
- r = next_range(&it.range_list, r);
- assert_int_equals(10, r->start);
- assert_int_equals(13, r->end);
- assert_ptr_equals(NULL, next_range(&it.range_list, r));
-
- interval_add_range(&it, 0, 14);
- r = interval_first_range(&it);
- assert_int_equals(0, r->start);
- assert_int_equals(14, r->end);
- assert_ptr_equals(NULL, next_range(&it.range_list, r));
-#endif
-}
diff --git a/test/unit/jit/liveness-test.c b/test/unit/jit/liveness-test.c
deleted file mode 100644
index 9721e36a..00000000
--- a/test/unit/jit/liveness-test.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2007 Pekka Enberg
- */
-
-#include "jit/compilation-unit.h"
-#include "jit/compiler.h"
-#include "lib/bitset.h"
-#include "vm/class.h"
-#include "vm/method.h"
-#include "vm/vm.h"
-#include "arch/instruction.h"
-#include <libharness.h>
-
-static struct cafebabe_method_info method_info;
-static struct vm_method method = { .method = &method_info };
-
-static void assert_live_range(struct live_interval *interval, unsigned long expected_start, unsigned long expected_end)
-{
- assert_int_equals(expected_start, interval_start(interval));
- assert_int_equals(expected_end, interval_end(interval));
-}
-
-static void assert_uses(struct basic_block *bb, struct var_info *var)
-{
- assert_false(test_bit(bb->def_set->bits, var->vreg));
- assert_true(test_bit(bb->use_set->bits, var->vreg));
-}
-
-static void assert_defines(struct basic_block *bb, struct var_info *var)
-{
- assert_true(test_bit(bb->def_set->bits, var->vreg));
- assert_false(test_bit(bb->use_set->bits, var->vreg));
-}
-
-static void assert_insn_at_equals(struct insn *insn, struct compilation_unit *cu, struct live_interval *interval, int offset)
-{
- struct insn *insn2;
-
- insn2 = radix_tree_lookup(cu->lir_insn_map, interval_start(interval) + offset);
- assert_ptr_equals(insn, insn2);
-}
-
-void test_variable_range_limited_to_basic_block(void)
-{
- struct compilation_unit *cu;
- struct var_info *r1, *r2;
- struct basic_block *bb;
- struct insn *insn[3];
-
- cu = compilation_unit_alloc(&method);
- r1 = get_var(cu, J_INT);
- r2 = get_var(cu, J_INT);
-
- bb = get_basic_block(cu, 0, 3);
-
- insn[0] = imm_insn(INSN_SETL, 0x01, r1);
- bb_add_insn(bb, insn[0]);
-
- insn[1] = imm_insn(INSN_SETL, 0x02, r2);
- bb_add_insn(bb, insn[1]);
-
- insn[2] = arithmetic_insn(INSN_ADD, r1, r2, r2);
- bb_add_insn(bb, insn[2]);
-
- compute_insn_positions(cu);
- analyze_liveness(cu);
-
- assert_defines(bb, r1);
- assert_defines(bb, r2);
-
- assert_live_range(r1->interval, 1, 5);
- assert_live_range(r2->interval, 3, 6);
-
- assert_insn_at_equals(insn[0], cu, r1->interval, -1);
- assert_insn_at_equals(insn[1], cu, r1->interval, 1);
- assert_insn_at_equals(insn[2], cu, r1->interval, 3);
-
- assert_insn_at_equals(insn[1], cu, r2->interval, -1);
- assert_insn_at_equals(insn[2], cu, r2->interval, 1);
-
- free_compilation_unit(cu);
-}
-
-void test_variable_range_spans_two_basic_blocks(void)
-{
- struct basic_block *bb1, *bb2;
- struct compilation_unit *cu;
- struct var_info *r1, *r2;
- struct insn *insn[4];
-
- cu = compilation_unit_alloc(&method);
- r1 = get_var(cu, J_INT);
- r2 = get_var(cu, J_INT);
-
- bb1 = get_basic_block(cu, 0, 2);
- bb2 = get_basic_block(cu, 2, 4);
- bb_add_successor(bb1, bb2);
-
- insn[2] = imm_insn(INSN_SETL, 0x02, r2);
- bb_add_insn(bb2, insn[2]);
-
- insn[3] = arithmetic_insn(INSN_ADD, r1, r2, r2);
- bb_add_insn(bb2, insn[3]);
-
- insn[0] = imm_insn(INSN_SETL, 0x01, r1);
- bb_add_insn(bb1, insn[0]);
-
- insn[1] = branch_insn(INSN_JMP, bb2);
- bb_add_insn(bb1, insn[1]);
-
- compute_insn_positions(cu);
- analyze_liveness(cu);
-
- assert_defines(bb1, r1);
- assert_defines(bb2, r2);
- assert_uses(bb2, r1);
-
- assert_live_range(r1->interval, 1, 7);
- assert_live_range(r2->interval, 5, 8);
-
- assert_insn_at_equals(insn[0], cu, r1->interval, -1);
- assert_insn_at_equals(insn[1], cu, r1->interval, 1);
- assert_insn_at_equals(insn[2], cu, r1->interval, 3);
- assert_insn_at_equals(insn[3], cu, r1->interval, 5);
-
- assert_insn_at_equals(insn[2], cu, r2->interval, -1);
- assert_insn_at_equals(insn[3], cu, r2->interval, 1);
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/spill-reload-test.c b/test/unit/jit/spill-reload-test.c
deleted file mode 100644
index 9739aba2..00000000
--- a/test/unit/jit/spill-reload-test.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2008 Pekka Enberg
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-
-#include "arch/instruction.h"
-#include "jit/compilation-unit.h"
-#include "jit/compiler.h"
-#include "vm/class.h"
-#include "vm/method.h"
-#include "vm/vm.h"
-#include <libharness.h>
-
-struct cafebabe_method_info method_info;
-struct vm_method method = { .method = &method_info, };
-
-static void assert_st_insn(enum insn_type type, struct stack_slot *slot, enum machine_reg reg, struct insn *insn)
-{
- assert_int_equals(type, insn->type);
- assert_int_equals(reg, mach_reg(&insn->x.reg));
- assert_ptr_equals(slot, insn->y.slot);
-}
-
-static void assert_ld_insn(enum insn_type type, enum machine_reg reg, struct stack_slot *slot, struct insn *insn)
-{
- assert_int_equals(type, insn->type);
- assert_int_equals(reg, mach_reg(&insn->x.reg));
- assert_ptr_equals(slot, insn->y.slot);
-}
-
-
-void test_spill_insn_is_inserted_before_last_read_if_necessary(void)
-{
- struct compilation_unit *cu;
- struct insn *insn_array[2];
- struct var_info *r1, *r2;
- struct basic_block *bb;
- struct insn *insn;
-
- cu = compilation_unit_alloc(&method);
- r1 = get_var(cu, J_INT);
- r2 = get_var(cu, J_INT);
-
- insn_array[0] = arithmetic_insn(INSN_ADD, r1, r1, r1);
- insn_array[1] = arithmetic_insn(INSN_ADD, r1, r2, r2);
-
- bb = get_basic_block(cu, 0, 2);
- bb_add_insn(bb, insn_array[0]);
- bb_add_insn(bb, insn_array[1]);
-
- mark_need_spill(r1->interval);
-
- compute_insn_positions(cu);
- analyze_liveness(cu);
- insert_spill_reload_insns(cu);
-
- /*
- * First instruction stays the same.
- */
- insn = list_first_entry(&bb->insn_list, struct insn, insn_list_node);
- assert_ptr_equals(insn_array[0], insn);
-
- /*
- * A spill instruction is inserted before last read-use position
- */
- insn = list_next_entry(&insn->insn_list_node, struct insn, insn_list_node);
- assert_st_insn(INSN_ST_LOCAL, r1->interval->spill_slot, r1->interval->reg, insn);
-
- /*
- * Last instruction stays the same.
- */
- insn = list_next_entry(&insn->insn_list_node, struct insn, insn_list_node);
- assert_ptr_equals(insn_array[1], insn);
-
- free_compilation_unit(cu);
-}
-
-void test_reload_insn_is_inserted_at_the_beginning_of_the_interval_if_necessary(void)
-{
- struct compilation_unit *cu;
- struct insn *insn_array[2];
- struct var_info *r1, *r2;
- struct basic_block *bb;
- struct insn *insn;
-
- cu = compilation_unit_alloc(&method);
- r1 = get_var(cu, J_INT);
- r2 = get_var(cu, J_INT);
-
- insn_array[0] = arithmetic_insn(INSN_ADD, r1, r1, r1);
- insn_array[1] = arithmetic_insn(INSN_ADD, r2, r2, r2);
-
- bb = get_basic_block(cu, 0, 2);
- bb_add_insn(bb, insn_array[0]);
- bb_add_insn(bb, insn_array[1]);
-
- r1->interval->spill_reload_reg.interval = r1->interval;
- r2->interval->spill_reload_reg.interval = r2->interval;
-
- r2->interval->flags |= INTERVAL_FLAG_NEED_RELOAD;
- r2->interval->spill_parent = r1->interval;
-
- compute_insn_positions(cu);
- analyze_liveness(cu);
- insert_spill_reload_insns(cu);
-
- /*
- * A reload instruction is inserted at the beginning.
- */
- insn = list_first_entry(&bb->insn_list, struct insn, insn_list_node);
- assert_ld_insn(INSN_LD_LOCAL, r2->interval->reg, r1->interval->spill_slot, insn);
-
- /*
- * Second instruction stays the same.
- */
- insn = list_next_entry(&insn->insn_list_node, struct insn, insn_list_node);
- assert_ptr_equals(insn_array[0], insn);
-
- /*
- * Last instruction stays the same.
- */
- insn = list_next_entry(&insn->insn_list_node, struct insn, insn_list_node);
- assert_ptr_equals(insn_array[1], insn);
-
- free_compilation_unit(cu);
-}
-
-void test_empty_interval_is_never_spilled(void)
-{
- struct compilation_unit *cu;
- struct var_info *r1;
-
- cu = compilation_unit_alloc(&method);
- get_basic_block(cu, 0, 2);
-
- r1 = get_var(cu, J_INT);
- mark_need_spill(r1->interval);
-
- compute_insn_positions(cu);
- analyze_liveness(cu);
- insert_spill_reload_insns(cu);
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/stack-slot-test.c b/test/unit/jit/stack-slot-test.c
deleted file mode 100644
index e95b2b96..00000000
--- a/test/unit/jit/stack-slot-test.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2008 Pekka Enberg
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-#include "jit/stack-slot.h"
-#include <libharness.h>
-#include <stdlib.h>
-
-#define NR_ARGS 2
-
-/* 32-bit, 64-bit, and 32-bit slots, respectively. */
-#define NR_LOCAL_SLOTS 4
-
-void test_local_slots_are_in_sequential_order(void)
-{
- struct stack_slot *slot1, *slot2, *slot3;
- struct stack_frame *frame;
-
- frame = alloc_stack_frame(NR_ARGS, NR_LOCAL_SLOTS);
-
- slot1 = get_local_slot(frame, 0);
- assert_int_equals(0, slot1->index);
-
- slot2 = get_local_slot(frame, 1);
- assert_int_equals(1, slot2->index);
-
- slot3 = get_local_slot(frame, 3);
- assert_int_equals(3, slot3->index);
-
- free_stack_frame(frame);
-}
-
-void test_32_bit_spill_slot_occupies_one_stack_slot(void)
-{
- struct stack_slot *slot1, *slot2;
- struct stack_frame *frame;
-
- frame = alloc_stack_frame(NR_ARGS, NR_LOCAL_SLOTS);
-
- slot1 = get_spill_slot_32(frame);
- assert_int_equals(4, slot1->index);
-
- slot2 = get_spill_slot_32(frame);
- assert_int_equals(5, slot2->index);
-
- free_stack_frame(frame);
-}
-
-void test_64_bit_spill_slot_occupies_one_stack_slot(void)
-{
- struct stack_slot *slot1, *slot2;
- struct stack_frame *frame;
-
- frame = alloc_stack_frame(NR_ARGS, NR_LOCAL_SLOTS);
-
- slot1 = get_spill_slot_64(frame);
- assert_int_equals(4, slot1->index);
-
- slot2 = get_spill_slot_64(frame);
- assert_int_equals(6, slot2->index);
-
- free_stack_frame(frame);
-}
diff --git a/test/unit/jit/trampoline-stub.c b/test/unit/jit/trampoline-stub.c
deleted file mode 100644
index 2bf4be0a..00000000
--- a/test/unit/jit/trampoline-stub.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "jit/compiler.h"
-#include <stdio.h>
-
-struct jit_trampoline *build_jit_trampoline(struct compilation_unit *cu)
-{
- NOT_IMPLEMENTED;
- return NULL;
-}
diff --git a/test/unit/jit/tree-printer-test.c b/test/unit/jit/tree-printer-test.c
deleted file mode 100644
index a2427048..00000000
--- a/test/unit/jit/tree-printer-test.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * Copyright (C) 2006 Pekka Enberg
- */
-
-#include "jit/tree-printer.h"
-#include "jit/statement.h"
-#include "vm/class.h"
-#include "vm/field.h"
-#include "vm/method.h"
-#include "lib/string.h"
-#include "vm/types.h"
-
-#include <libharness.h>
-#include <stdlib.h>
-
-#include "test/vm.h"
-
-static struct vm_class vmc = {
- .name = "Class",
-};
-
-static struct vm_field vmf = {
- .class = &vmc,
- .name = "field",
- .type_info = { .vm_type = J_INT, .class_name = "I" }
-};
-
-static struct vm_method vmm = {
- .class = &vmc,
- .virtual_index = 255,
- .name = "method",
- .type ="()I",
-};
-
-struct string *str_aprintf(const char *fmt, ...)
-{
- va_list ap;
- struct string *str;
-
- str = alloc_str();
-
- va_start(ap, fmt);
- str_vappend(str, fmt, ap);
- va_end(ap);
-
- return str;
-}
-
-static void assert_tree_print(struct string *expected, struct tree_node *root)
-{
- struct string *str = alloc_str();
-
- tree_print(root, str);
- assert_str_equals(expected->value, str->value);
-
- free_str(str);
- free_str(expected);
-}
-
-static void assert_print_stmt(struct string *expected, struct statement *stmt)
-{
- assert_tree_print(expected, &stmt->node);
- free_statement(stmt);
-}
-
-void test_should_print_store_statement(void)
-{
- struct expression *dest, *src;
- struct statement *stmt;
-
- dest = local_expr(J_INT, 0);
- src = value_expr(J_INT, 1);
-
- stmt = alloc_statement(STMT_STORE);
- stmt->store_dest = &dest->node;
- stmt->store_src = &src->node;
-
- assert_print_stmt(str_aprintf(
- "STORE:\n store_dest: [local int 0]\n"
- " store_src: [value int 0x1]\n"), stmt);
-}
-
-void test_should_print_if_statement(void)
-{
- struct expression *if_conditional;
- struct statement *stmt;
- struct basic_block *if_true = (void *) 0xdeadbeef;
-
- if_conditional = local_expr(J_BOOLEAN, 0);
-
- stmt = alloc_statement(STMT_IF);
- stmt->if_conditional = &if_conditional->node;
- stmt->if_true = if_true;
-
- assert_print_stmt(str_aprintf(
- "IF:\n"
- " if_conditional: [local boolean 0]\n"
- " if_true: [bb %p]\n", if_true), stmt);
-}
-
-void test_should_print_goto_statement(void)
-{
- struct statement *stmt;
- struct basic_block *goto_target = (void *) 0xdeadbeef;
-
- stmt = alloc_statement(STMT_GOTO);
- stmt->goto_target = goto_target;
-
- assert_print_stmt(str_aprintf(
- "GOTO:\n"
- " goto_target: [bb %p]\n", goto_target), stmt);
-}
-
-void test_should_print_return_statement(void)
-{
- struct expression *return_value;
- struct statement *stmt;
-
- return_value = local_expr(J_INT, 0);
-
- stmt = alloc_statement(STMT_RETURN);
- stmt->return_value = &return_value->node;
-
- assert_print_stmt(str_aprintf(
- "RETURN:\n"
- " return_value: [local int 0]\n"), stmt);
-}
-
-void test_should_print_void_return_statement(void)
-{
- struct statement *stmt;
-
- stmt = alloc_statement(STMT_VOID_RETURN);
-
- assert_print_stmt(str_aprintf("VOID_RETURN\n"), stmt);
-}
-
-void test_should_print_expression_statement(void)
-{
- struct expression *expression;
- struct statement *stmt;
-
- expression = local_expr(J_INT, 0);
-
- stmt = alloc_statement(STMT_EXPRESSION);
- stmt->expression = &expression->node;
-
- assert_print_stmt(str_aprintf(
- "EXPRESSION:\n"
- " expression: [local int 0]\n"), stmt);
-}
-
-void test_should_print_arraycheck_statement(void)
-{
- struct expression *expression;
- struct statement *stmt;
-
- expression = local_expr(J_INT, 0);
-
- stmt = alloc_statement(STMT_ARRAY_CHECK);
- stmt->expression = &expression->node;
-
- assert_print_stmt(str_aprintf(
- "ARRAY_CHECK:\n"
- " expression: [local int 0]\n"), stmt);
-}
-
-void test_should_print_monitorenter_statement(void)
-{
- struct expression *expr;
- struct statement *stmt;
-
- expr = local_expr(J_INT, 0);
-
- stmt = alloc_statement(STMT_MONITOR_ENTER);
- stmt->expression = &expr->node;
-
- assert_print_stmt(str_aprintf(
- "MONITOR_ENTER:\n"
- " expression: [local int 0]\n"), stmt);
-}
-
-void test_should_print_monitorexit_statement(void)
-{
- struct expression *expr;
- struct statement *stmt;
-
- expr = local_expr(J_INT, 0);
-
- stmt = alloc_statement(STMT_MONITOR_EXIT);
- stmt->expression = &expr->node;
-
- assert_print_stmt(str_aprintf(
- "MONITOR_EXIT:\n"
- " expression: [local int 0]\n"), stmt);
-}
-
-void test_should_print_checkcast_statement(void)
-{
- struct expression *expr;
- struct statement *stmt;
-
- expr = local_expr(J_INT, 0);
-
- stmt = alloc_statement(STMT_CHECKCAST);
- stmt->checkcast_ref = &expr->node;
- stmt->checkcast_class = &vmc;
-
- assert_print_stmt(str_aprintf(
- "CHECKCAST:\n"
- " checkcast_type: [%p '%s']\n"
- " checkcast_ref: [local int 0]\n", &vmc, vmc.name), stmt);
-}
-
-static void assert_print_expr(struct string *expected, struct expression *expr)
-{
- assert_tree_print(expected, &expr->node);
- expr_put(expr);
-}
-
-void assert_printed_value_expr(struct string *expected, enum vm_type type,
- unsigned long long value)
-{
- struct expression *expr;
-
- expr = value_expr(type, value);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_value_expression(void)
-{
- assert_printed_value_expr(str_aprintf("[value int 0x0]"), J_INT, 0);
- assert_printed_value_expr(str_aprintf("[value boolean 0x1]"), J_BOOLEAN, 1);
-}
-
-void assert_printed_fvalue_expr(struct string *expected, enum vm_type type,
- double fvalue)
-{
- struct expression *expr;
-
- expr = fvalue_expr(type, fvalue);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_fvalue_expression(void)
-{
- assert_printed_fvalue_expr(str_aprintf("[fvalue float 0.000000]"), J_FLOAT, 0.0);
- assert_printed_fvalue_expr(str_aprintf("[fvalue double 1.100000]"), J_DOUBLE, 1.1);
-}
-
-void assert_printed_local_expr(struct string *expected, enum vm_type type,
- unsigned long local_index)
-{
- struct expression *expr;
-
- expr = local_expr(type, local_index);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_local_expression(void)
-{
- assert_printed_local_expr(str_aprintf("[local int 0]"), J_INT, 0);
- assert_printed_local_expr(str_aprintf("[local boolean 1]"), J_BOOLEAN, 1);
-}
-
-void assert_printed_temporary_expr(struct string *expected, enum vm_type type, struct var_info *var, struct var_info *var2)
-{
- struct expression *expr;
-
- if (vm_type_is_float(type))
- expr = alloc_expression(EXPR_FLOAT_TEMPORARY, type);
- else
- expr = alloc_expression(EXPR_TEMPORARY, type);
-
- expr->tmp_low = var2;
-#ifdef CONFIG_32_BIT
- expr->tmp_high = var;
-#endif
-
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_temporary_expression(void)
-{
- assert_printed_temporary_expr(str_aprintf(
- "[temporary int 0x12345678 (low)]"),
- J_INT, NULL, (struct var_info *)0x12345678);
-#ifdef CONFIG_32_BIT
- assert_printed_temporary_expr(str_aprintf(
- "[temporary boolean 0x85215975 (high), 0x87654321 (low)]"),
- J_BOOLEAN,
- (struct var_info *)0x85215975, (struct var_info *)0x87654321);
-#else
- assert_printed_temporary_expr(str_aprintf(
- "[temporary boolean 0x87654321 (low)]"),
- J_BOOLEAN,
- (struct var_info *)0x85215975, (struct var_info *)0x87654321);
-#endif
-}
-
-void assert_printed_array_deref_expr(struct string *expected, enum vm_type type,
- unsigned long arrayref, unsigned long array_index)
-{
- struct expression *expr;
-
- expr = array_deref_expr(type,
- value_expr(J_REFERENCE, arrayref),
- value_expr(J_INT, array_index));
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_array_deref_expression(void)
-{
- assert_printed_array_deref_expr(str_aprintf(
- "ARRAY_DEREF:\n"
- " vm_type: [float]\n"
- " arrayref: [value reference 0x0]\n"
- " array_index: [value int 0x1]\n"), J_FLOAT, 0, 1);
- assert_printed_array_deref_expr(str_aprintf(
- "ARRAY_DEREF:\n"
- " vm_type: [double]\n"
- " arrayref: [value reference 0x1]\n"
- " array_index: [value int 0x2]\n"), J_DOUBLE, 1, 2);
-}
-
-void assert_printed_binop_expr(struct string *expected, enum vm_type type,
- enum binary_operator op,
- struct expression *binary_left,
- struct expression *binary_right)
-{
- struct expression *expr;
-
- expr = binop_expr(type, op, binary_left, binary_right);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_binop_expression(void)
-{
- assert_printed_binop_expr(str_aprintf(
- "BINOP:\n"
- " vm_type: [int]\n"
- " binary_operator: [add]\n"
- " binary_left: [value int 0x0]\n"
- " binary_right: [value int 0x1]\n"),
- J_INT, OP_ADD, value_expr(J_INT, 0), value_expr(J_INT, 1));
-
- assert_printed_binop_expr(str_aprintf(
- "BINOP:\n"
- " vm_type: [long]\n"
- " binary_operator: [add]\n"
- " binary_left: [value long 0x1]\n"
- " binary_right:\n"
- " BINOP:\n"
- " vm_type: [long]\n"
- " binary_operator: [sub]\n"
- " binary_left: [value long 0x2]\n"
- " binary_right: [value long 0x3]\n"),
- J_LONG, OP_ADD,
- value_expr(J_LONG, 1), binop_expr(J_LONG, OP_SUB,
- value_expr(J_LONG, 2), value_expr(J_LONG, 3)));
-}
-
-void assert_printed_unary_op_expr(struct string *expected, enum vm_type type,
- enum unary_operator op,
- struct expression *unary_expr)
-{
- struct expression *expr;
-
- expr = unary_op_expr(type, op, unary_expr);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_unary_op_expression(void)
-{
- assert_printed_unary_op_expr(str_aprintf(
- "UNARY_OP:\n"
- " vm_type: [int]\n"
- " unary_operator: [neg]\n"
- " unary_expression: [value int 0x0]\n"),
- J_INT, OP_NEG, value_expr(J_INT, 0));
-
- assert_printed_unary_op_expr(str_aprintf(
- "UNARY_OP:\n"
- " vm_type: [boolean]\n"
- " unary_operator: [neg]\n"
- " unary_expression: [value boolean 0x1]\n"),
- J_BOOLEAN, OP_NEG, value_expr(J_BOOLEAN, 1));
-}
-
-void assert_printed_conversion_expr(struct string *expected, enum vm_type type,
- struct expression *from_expr)
-{
- struct expression *expr;
-
- expr = conversion_expr(type, from_expr);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_conversion_expression(void)
-{
- assert_printed_conversion_expr(str_aprintf(
- "CONVERSION:\n"
- " vm_type: [long]\n"
- " from_expression: [value int 0x0]\n"),
- J_LONG, value_expr(J_INT, 0));
-
- assert_printed_conversion_expr(str_aprintf(
- "CONVERSION:\n"
- " vm_type: [int]\n"
- " from_expression: [value boolean 0x1]\n"),
- J_INT, value_expr(J_BOOLEAN, 1));
-}
-
-void assert_printed_class_field_expr(struct string *expected, enum vm_type type,
- struct vm_field *field)
-{
- struct expression *expr;
-
- expr = class_field_expr(type, field);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_class_field_expression(void)
-{
- assert_printed_class_field_expr(str_aprintf(
- "[class_field int %p '%s.%s']",
- &vmf, vmf.class->name, vmf.name, "I"), J_INT, &vmf);
-}
-
-void assert_printed_instance_field_expr(struct string *expected, enum vm_type type,
- struct vm_field *field,
- struct expression *objectref)
-{
- struct expression *expr;
-
- expr = instance_field_expr(type, field, objectref);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_instance_field_expression(void)
-{
- struct expression *objectref;
-
- objectref = value_expr(J_REFERENCE, 0xdeadbeef);
-
- assert_printed_instance_field_expr(str_aprintf(
- "INSTANCE_FIELD:\n"
- " vm_type: [int]\n"
- " instance_field: [%p '%s.%s']\n"
- " objectref_expression: [value reference 0xdeadbeef]\n",
- &vmf, vmf.class->name, vmf.name), J_INT, &vmf, objectref);
-}
-
-void assert_printed_invoke_stmt(enum vm_type type,
- struct string *expected,
- struct vm_method *method,
- struct expression *args_list,
- struct expression *result)
-{
- struct statement *stmt;
-
- stmt = alloc_statement(type);
- stmt->invoke_result = result;
- stmt->args_list = &args_list->node;
- stmt->target_method = method;
- assert_print_stmt(expected, stmt);
-}
-
-void test_should_print_invoke_statement(void)
-{
- assert_printed_invoke_stmt(STMT_INVOKE, str_aprintf(
- "INVOKE:\n"
- " target_method: [%p '%s.%s%s' (%lu)]\n"
- " args_list: [no args]\n"
- " result: [void]\n",
- &vmm, vmm.class->name, vmm.name, vmm.type, vmm.virtual_index),
- &vmm, no_args_expr(), NULL);
-}
-
-void test_should_print_invokevirtual_expression(void)
-{
- assert_printed_invoke_stmt(STMT_INVOKEVIRTUAL, str_aprintf(
- "INVOKEVIRTUAL:\n"
- " target_method: [%p '%s.%s%s' (%lu)]\n"
- " args_list: [no args]\n"
- " result: [void]\n",
- &vmm, vmm.class->name, vmm.name, vmm.type, vmm.virtual_index),
- &vmm, no_args_expr(), NULL);
-}
-
-void assert_printed_args_list_expr(struct string *expected,
- struct expression *args_left,
- struct expression *args_right)
-{
- struct expression *expr;
-
- expr = args_list_expr(arg_expr(args_left), arg_expr(args_right));
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_args_list_expression(void)
-{
- assert_printed_args_list_expr(str_aprintf(
- "ARGS_LIST:\n"
- " args_left:\n"
- " ARG:\n"
- " arg_expression: [value int 0x0]\n"
- " args_right:\n"
- " ARG:\n"
- " arg_expression: [value boolean 0x1]\n"),
- value_expr(J_INT, 0), value_expr(J_BOOLEAN, 1));
-}
-
-void assert_printed_arg_expr(struct string *expected,
- struct expression *arg_expression)
-{
- struct expression *expr;
-
- expr = arg_expr(arg_expression);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_arg_expression(void)
-{
- assert_printed_arg_expr(str_aprintf(
- "ARG:\n"
- " arg_expression: [value int 0x0]\n"),
- value_expr(J_INT, 0));
-
- assert_printed_arg_expr(str_aprintf(
- "ARG:\n"
- " arg_expression: [value boolean 0x1]\n"),
- value_expr(J_BOOLEAN, 1));
-}
-
-void test_should_print_no_args_expression(void)
-{
- assert_print_expr(str_aprintf("[no args]"), no_args_expr());
-}
-
-void assert_printed_new_expr(struct string *expected, struct vm_class *class)
-{
- struct expression *expr;
-
- expr = new_expr(class);
- assert_print_expr(expected, expr);
-}
-
-void test_should_print_new_expression(void)
-{
- assert_printed_new_expr(str_aprintf(
- "NEW:\n"
- " vm_type: [reference]\n"
- " class: [%p '%s']\n", &vmc, vmc.name), &vmc);
-}
-
-void test_print_newarray_expression(void)
-{
- assert_print_expr(str_aprintf(
- "NEWARRAY:\n"
- " vm_type: [reference]\n"
- " array_size: [value int 0xff]\n"
- " array_type: [10]\n"),
- newarray_expr(T_INT, value_expr(J_INT, 0xff)));
-}
-
-void test_print_anewarray_expression(void)
-{
- assert_print_expr(str_aprintf(
- "ANEWARRAY:\n"
- " vm_type: [reference]\n"
- " anewarray_size: [value int 0xff]\n"
- " anewarray_ref_type: [%p '%s']\n",
- &vmc, vmc.name),
- anewarray_expr(&vmc, value_expr(J_INT, 0xff)));
-}
-
-void test_print_multianewarray_expression(void)
-{
- struct expression *expr, *args_list;
- args_list = args_list_expr(arg_expr(value_expr(J_INT, 0x02)),
- arg_expr(value_expr(J_INT, 0xff)));
-
- expr = multianewarray_expr(&vmc);
- expr->multianewarray_dimensions = &args_list->node;
-
- assert_print_expr(str_aprintf(
- "MULTIANEWARRAY:\n"
- " vm_type: [reference]\n"
- " multianewarray_ref_type: [%p '%s']\n"
- " dimension list:\n"
- " ARGS_LIST:\n"
- " args_left:\n"
- " ARG:\n"
- " arg_expression: [value int 0x2]\n"
- " args_right:\n"
- " ARG:\n"
- " arg_expression: [value int 0xff]\n",
- &vmc, vmc.name), expr);
-}
-
-void test_print_arraylength_expression(void)
-{
- assert_print_expr(str_aprintf(
- "ARRAYLENGTH:\n"
- " vm_type: [int]\n"
- " arraylength_ref: [value reference 0xcafe]\n"),
- arraylength_expr(value_expr(J_REFERENCE, 0xcafe)));
-}
-
-void test_print_instanceof_expression(void)
-{
- assert_print_expr(str_aprintf(
- "INSTANCEOF:\n"
- " vm_type: [int]\n"
- " instanceof_class: [%p '%s']\n"
- " instanceof_ref: [value reference 0x55]\n",
- &vmc, vmc.name),
- instanceof_expr(value_expr(J_REFERENCE, 0x55), &vmc));
-}
-
-void test_should_print_nullcheck_expression(void)
-{
- struct expression *expression;
- struct expression *expr;
-
- expression = local_expr(J_REFERENCE, 0);
-
- expr = null_check_expr(expression);
-
- assert_print_expr(str_aprintf(
- "NULL_CHECK:\n"
- " ref: [local reference 0]\n"), expr);
-}
diff --git a/test/unit/vm/Makefile b/test/unit/vm/Makefile
index bea13968..6cfafe08 100644
--- a/test/unit/vm/Makefile
+++ b/test/unit/vm/Makefile
@@ -44,6 +44,4 @@ TEST_OBJS := \
string-test.o \
types-test.o
-CFLAGS += -I ../../../arch/mmix/include
-
include ../../../scripts/build/test.mk