aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2012-08-17 12:43:05 +0300
committerPekka Enberg <penberg@kernel.org>2012-08-17 12:46:47 +0300
commitd7c88a0292ff2441faa84751444c2da37cf9a75a (patch)
tree1f461911fe6677ede31360f517d310f26a7c81fa
parent0ad3b910dd6e749441382cb3e4537b95a315556b (diff)
downloadjato-d7c88a0292ff2441faa84751444c2da37cf9a75a.tar.gz
test/unit: Remove more obsolete BC2IR test cases
The BC2IR test cases in test/unit were a good idea for bootstrapping Jato back in 2005. However, their usefulness has since decreased and in fact they have held back code cleanups because of the weird dependencies they introduce. So drop them for good. Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--test/unit/jit/Makefile22
-rw-r--r--test/unit/jit/arithmetic-bc-test.c242
-rw-r--r--test/unit/jit/bc-test-utils.c353
-rw-r--r--test/unit/jit/branch-bc-test.c233
-rw-r--r--test/unit/jit/bytecode-to-ir-stub.c10
-rw-r--r--test/unit/jit/bytecode-to-ir-test.c82
-rw-r--r--test/unit/jit/load-store-bc-test.c360
-rw-r--r--test/unit/jit/object-bc-test.c339
-rw-r--r--test/unit/jit/ostack-bc-test.c316
-rw-r--r--test/unit/jit/switch-bc-test.c249
-rw-r--r--test/unit/jit/typeconv-bc-test.c99
11 files changed, 1 insertions, 2304 deletions
diff --git a/test/unit/jit/Makefile b/test/unit/jit/Makefile
index 9947773a..6dc0c624 100644
--- a/test/unit/jit/Makefile
+++ b/test/unit/jit/Makefile
@@ -13,40 +13,28 @@ TOPLEVEL_OBJS := \
cafebabe/source_file_attribute.o \
cafebabe/stream.o \
jit/args.o \
- jit/arithmetic-bc.o \
jit/basic-block.o \
jit/bc-offset-mapping.o \
- jit/branch-bc.o \
- jit/bytecode-to-ir.o \
jit/cfg-analyzer.o \
jit/compilation-unit.o \
jit/constant-pool.o \
jit/cu-mapping.o \
jit/dominance.o \
- jit/exception-bc.o \
jit/exception.o \
jit/expression.o \
jit/fixup-site.o \
jit/interval.o \
- jit/invoke-bc.o \
jit/linear-scan.o \
jit/liveness.o \
- jit/load-store-bc.o \
jit/method.o \
- jit/nop-bc.o \
- jit/object-bc.o \
- jit/ostack-bc.o \
jit/spill-reload.o \
jit/stack-slot.o \
jit/statement.o \
- jit/switch-bc.o \
jit/text.o \
jit/tree-node.o \
jit/tree-printer.o \
- jit/typeconv-bc.o \
jit/subroutine.o \
jit/pc-map.o \
- jit/wide-bc.o \
jit/constant_pool.o \
lib/arena.o \
lib/bitset.o \
@@ -85,11 +73,8 @@ TOPLEVEL_OBJS := \
TEST_OBJS := \
args-test-utils.o \
- arithmetic-bc-test.o \
basic-block-test.o \
bc-test-utils.o \
- branch-bc-test.o \
- bytecode-to-ir-test.o \
cfg-analyzer-test.o \
compilation-unit-test.o \
dominance-test.o \
@@ -97,14 +82,9 @@ TEST_OBJS := \
linear-scan-test.o \
live-range-test.o \
liveness-test.o \
- load-store-bc-test.o \
- object-bc-test.o \
- ostack-bc-test.o \
spill-reload-test.o \
stack-slot-test.o \
- switch-bc-test.o \
- tree-printer-test.o \
- typeconv-bc-test.o
+ tree-printer-test.o
include ../../../scripts/build/test.mk
diff --git a/test/unit/jit/arithmetic-bc-test.c b/test/unit/jit/arithmetic-bc-test.c
deleted file mode 100644
index 94ece92d..00000000
--- a/test/unit/jit/arithmetic-bc-test.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include "jit/statement.h"
-#include "jit/compiler.h"
-#include "lib/list.h"
-#include "lib/stack.h"
-#include "vm/system.h"
-
-#include <libharness.h>
-#include <stdlib.h>
-
-#include <bc-test-utils.h>
-
-static void assert_unary_op_expr(enum vm_type vm_type,
- enum unary_operator unary_operator,
- struct expression *expression,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(EXPR_UNARY_OP, expr_type(expr));
- assert_int_equals(vm_type, expr->vm_type);
- assert_int_equals(unary_operator, expr_unary_op(expr));
- assert_ptr_equals(expression, to_expr(expr->unary_expression));
-}
-
-static void assert_convert_binop(enum vm_type vm_type,
- enum binary_operator binary_operator,
- unsigned char opc)
-{
- unsigned char code[] = { opc };
- struct expression *left, *right, *expr;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code)
- };
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
-
- left = temporary_expr(vm_type, bb->b_parent);
- right = temporary_expr(vm_type, bb->b_parent);
-
- stack_push(bb->mimic_stack, left);
- stack_push(bb->mimic_stack, right);
-
- convert_to_ir(bb->b_parent);
- expr = stack_pop(bb->mimic_stack);
-
- assert_binop_expr(vm_type, binary_operator, left, right, &expr->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(expr);
- __free_simple_bb(bb);
-}
-
-void test_convert_add(void)
-{
- assert_convert_binop(J_INT, OP_ADD, OPC_IADD);
- assert_convert_binop(J_LONG, OP_ADD, OPC_LADD);
- assert_convert_binop(J_FLOAT, OP_FADD, OPC_FADD);
- assert_convert_binop(J_DOUBLE, OP_DADD, OPC_DADD);
-}
-
-void test_convert_sub(void)
-{
- assert_convert_binop(J_INT, OP_SUB, OPC_ISUB);
- assert_convert_binop(J_LONG, OP_SUB, OPC_LSUB);
- assert_convert_binop(J_FLOAT, OP_FSUB, OPC_FSUB);
- assert_convert_binop(J_DOUBLE, OP_DSUB, OPC_DSUB);
-}
-
-void test_convert_mul(void)
-{
- assert_convert_binop(J_INT, OP_MUL, OPC_IMUL);
- assert_convert_binop(J_LONG, OP_MUL_64, OPC_LMUL);
- assert_convert_binop(J_FLOAT, OP_FMUL, OPC_FMUL);
- assert_convert_binop(J_DOUBLE, OP_DMUL, OPC_DMUL);
-}
-
-void test_convert_div(void)
-{
- assert_convert_binop(J_INT, OP_DIV, OPC_IDIV);
- assert_convert_binop(J_LONG, OP_DIV_64, OPC_LDIV);
- assert_convert_binop(J_FLOAT, OP_FDIV, OPC_FDIV);
- assert_convert_binop(J_DOUBLE, OP_DDIV, OPC_DDIV);
-}
-
-void test_convert_rem(void)
-{
- assert_convert_binop(J_INT, OP_REM, OPC_IREM);
- assert_convert_binop(J_LONG, OP_REM_64, OPC_LREM);
- assert_convert_binop(J_FLOAT, OP_FREM, OPC_FREM);
- assert_convert_binop(J_DOUBLE, OP_DREM, OPC_DREM);
-}
-
-static void assert_convert_unop(enum vm_type vm_type,
- enum unary_operator unary_operator,
- unsigned char opc)
-{
- unsigned char code[] = { opc };
- struct expression *expression, *unary_expression;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code)
- };
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
-
- expression = temporary_expr(vm_type, bb->b_parent);
- stack_push(bb->mimic_stack, expression);
-
- convert_to_ir(bb->b_parent);
- unary_expression = stack_pop(bb->mimic_stack);
-
- assert_unary_op_expr(vm_type, unary_operator, expression,
- &unary_expression->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(unary_expression);
- __free_simple_bb(bb);
-}
-
-void test_convert_neg(void)
-{
- assert_convert_unop(J_INT, OP_NEG, OPC_INEG);
- assert_convert_unop(J_LONG, OP_NEG, OPC_LNEG);
- assert_convert_unop(J_FLOAT, OP_FNEG, OPC_FNEG);
- assert_convert_unop(J_DOUBLE, OP_DNEG, OPC_DNEG);
-}
-
-void test_convert_shl(void)
-{
- assert_convert_binop(J_INT, OP_SHL, OPC_ISHL);
- assert_convert_binop(J_LONG, OP_SHL_64, OPC_LSHL);
-}
-
-void test_convert_shr(void)
-{
- assert_convert_binop(J_INT, OP_SHR, OPC_ISHR);
- assert_convert_binop(J_LONG, OP_SHR_64, OPC_LSHR);
-}
-
-void test_convert_ushr(void)
-{
- assert_convert_binop(J_INT, OP_USHR, OPC_IUSHR);
- assert_convert_binop(J_LONG, OP_USHR_64, OPC_LUSHR);
-}
-
-void test_convert_and(void)
-{
- assert_convert_binop(J_INT, OP_AND, OPC_IAND);
- assert_convert_binop(J_LONG, OP_AND, OPC_LAND);
-}
-
-void test_convert_or(void)
-{
- assert_convert_binop(J_INT, OP_OR, OPC_IOR);
- assert_convert_binop(J_LONG, OP_OR, OPC_LOR);
-}
-
-void test_convert_xor(void)
-{
- assert_convert_binop(J_INT, OP_XOR, OPC_IXOR);
- assert_convert_binop(J_LONG, OP_XOR, OPC_LXOR);
-}
-
-static void assert_iinc_stmt(unsigned char expected_index,
- int8_t expected_value)
-{
- unsigned char code[] = { OPC_IINC, expected_index, expected_value };
- struct statement *store_stmt;
- struct tree_node *local_expression, *const_expression;
- struct compilation_unit *cu;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code)
- };
-
- cu = alloc_simple_compilation_unit(&method);
-
- convert_to_ir(cu);
- store_stmt = stmt_entry(bb_entry(cu->bb_list.next)->stmt_list.next);
- local_expression = store_stmt->store_dest;
- const_expression = to_expr(store_stmt->store_src)->binary_right;
-
- assert_binop_expr(J_INT, OP_ADD, to_expr(local_expression),
- to_expr(const_expression),
- store_stmt->store_src);
- assert_local_expr(J_INT, expected_index, local_expression);
- assert_value_expr(J_INT, expected_value, const_expression);
-
- free_compilation_unit(cu);
-}
-
-void test_convert_iinc(void)
-{
- assert_iinc_stmt(0, 1);
- assert_iinc_stmt(1, 2);
- assert_iinc_stmt(1, -1);
-}
-
-static void assert_convert_cmp(unsigned char opc, enum binary_operator op,
- enum vm_type type)
-{
- unsigned char code[] = { opc };
- struct expression *left, *right, *cmp_expression;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
-
- left = temporary_expr(type, bb->b_parent);
- right = temporary_expr(type, bb->b_parent);
-
- stack_push(bb->mimic_stack, left);
- stack_push(bb->mimic_stack, right);
-
- convert_to_ir(bb->b_parent);
- cmp_expression = stack_pop(bb->mimic_stack);
- assert_binop_expr(J_INT, op, left, right, &cmp_expression->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(cmp_expression);
- __free_simple_bb(bb);
-}
-
-void test_convert_cmp(void)
-{
- assert_convert_cmp(OPC_LCMP, OP_CMP, J_LONG);
- assert_convert_cmp(OPC_FCMPL, OP_CMPL, J_FLOAT);
- assert_convert_cmp(OPC_FCMPG, OP_CMPG, J_FLOAT);
- assert_convert_cmp(OPC_DCMPL, OP_CMPL, J_DOUBLE);
- assert_convert_cmp(OPC_DCMPG, OP_CMPG, J_DOUBLE);
-}
-
diff --git a/test/unit/jit/bc-test-utils.c b/test/unit/jit/bc-test-utils.c
deleted file mode 100644
index 4b108b8b..00000000
--- a/test/unit/jit/bc-test-utils.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include "cafebabe/constant_pool.h"
-#include "cafebabe/method_info.h"
-#include "cafebabe/class.h"
-
-#include "jit/compilation-unit.h"
-#include "jit/basic-block.h"
-#include <bc-test-utils.h>
-#include <args-test-utils.h>
-#include "jit/tree-node.h"
-#include "jit/expression.h"
-#include "jit/statement.h"
-#include "jit/compiler.h"
-#include "vm/types.h"
-#include <libharness.h>
-#include <stdlib.h>
-
-#include "test/vm.h"
-
-struct compilation_unit *
-alloc_simple_compilation_unit(struct vm_method *method)
-{
- static struct cafebabe_method_info method_info;
- struct compilation_unit *cu;
- struct basic_block *bb;
-
- method->method = &method_info;
-
- cu = compilation_unit_alloc(method);
- bb = get_basic_block(cu, 0, method->code_attribute.code_length);
- cu->entry_bb = bb;
-
- return cu;
-}
-
-struct basic_block *__alloc_simple_bb(struct vm_method *method)
-{
- static struct cafebabe_method_info method_info;
- struct compilation_unit *cu;
- struct basic_block *bb;
-
- method->method = &method_info;
-
- cu = compilation_unit_alloc(method);
- bb = get_basic_block(cu, 0, method->code_attribute.code_length);
- cu->entry_bb = bb;
-
- return bb;
-}
-
-struct basic_block *
-alloc_simple_bb(unsigned char *code, unsigned long code_size)
-{
- struct vm_method *method;
-
- method = malloc(sizeof *method);
- method->code_attribute.code = code;
- method->code_attribute.code_length = code_size;
- method->args_count = 0;
- method->code_attribute.max_locals = 0;
-
- return __alloc_simple_bb(method);
-}
-
-void __free_simple_bb(struct basic_block *bb)
-{
- free_compilation_unit(bb->b_parent);
-}
-
-void free_simple_bb(struct basic_block *bb)
-{
- struct compilation_unit *cu = bb->b_parent;
-
- free(cu->method);
- __free_simple_bb(bb);
-}
-
-void assert_value_expr(enum vm_type expected_vm_type,
- long long expected_value, struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(EXPR_VALUE, expr_type(expr));
- assert_int_equals(expected_vm_type, expr->vm_type);
- assert_int_equals(expected_value, expr->value);
-}
-
-void assert_nullcheck_value_expr(enum vm_type expected_vm_type,
- long long expected_value,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(EXPR_NULL_CHECK, expr_type(expr));
- assert_value_expr(expected_vm_type, expected_value,
- expr->null_check_ref);
-}
-
-void assert_fvalue_expr(enum vm_type expected_vm_type,
- double expected_value, struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(EXPR_FVALUE, expr_type(expr));
- assert_int_equals(expected_vm_type, expr->vm_type);
- assert_float_equals(expected_value, expr->fvalue, 0.01f);
-}
-
-void assert_local_expr(enum vm_type expected_vm_type,
- unsigned long expected_index, struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- if (vm_type_is_float(expected_vm_type))
- assert_int_equals(EXPR_FLOAT_LOCAL, expr_type(expr));
- else
- assert_int_equals(EXPR_LOCAL, expr_type(expr));
-
- assert_int_equals(expected_vm_type, expr->vm_type);
- assert_int_equals(expected_index, expr->local_index);
-}
-
-void assert_temporary_expr(enum vm_type expected_vm_type,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- if (vm_type_is_float(expected_vm_type))
- assert_int_equals(EXPR_FLOAT_TEMPORARY, expr_type(expr));
- else
- assert_int_equals(EXPR_TEMPORARY, expr_type(expr));
-}
-
-void assert_null_check_expr(struct expression *expected,
- struct expression *actual)
-{
- assert_int_equals(EXPR_NULL_CHECK, expr_type(actual));
- assert_ptr_equals(expected, to_expr(actual->null_check_ref));
-}
-
-void assert_array_deref_expr(enum vm_type expected_vm_type,
- struct expression *expected_arrayref,
- struct expression *expected_index,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(EXPR_ARRAY_DEREF, expr_type(expr));
- assert_int_equals(expected_vm_type, expr->vm_type);
- assert_ptr_equals(expected_arrayref, to_expr(expr->arrayref));
- assert_ptr_equals(expected_index, to_expr(expr->array_index));
-}
-
-void __assert_binop_expr(enum vm_type vm_type,
- enum binary_operator binary_operator,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(EXPR_BINOP, expr_type(expr));
- assert_int_equals(vm_type, expr->vm_type);
- assert_int_equals(binary_operator, expr_bin_op(expr));
-}
-
-void assert_binop_expr(enum vm_type vm_type,
- enum binary_operator binary_operator,
- struct expression *binary_left,
- struct expression *binary_right, struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- __assert_binop_expr(vm_type, binary_operator, node);
- assert_ptr_equals(binary_left, to_expr(expr->binary_left));
- assert_ptr_equals(binary_right, to_expr(expr->binary_right));
-}
-
-void assert_conv_expr(enum vm_type expected_type,
- enum expression_type expected_expr_type,
- struct expression *expected_expression,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(expected_expr_type, expr_type(expr));
- assert_int_equals(expected_type, expr->vm_type);
- assert_ptr_equals(expected_expression, to_expr(expr->from_expression));
-}
-
-void assert_trunc_expr(enum vm_type expected_to_type,
- enum expression_type expected_expr_type,
- struct expression *expected_expression,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- assert_int_equals(expected_expr_type, expr_type(expr));
- assert_int_equals(expected_to_type, expr->to_type);
- assert_int_equals(J_INT, expr->vm_type);
- assert_ptr_equals(expected_expression, to_expr(expr->from_expression));
-}
-
-static void __assert_field_expr(enum expression_type expected_expr_type,
- enum vm_type expected_type,
- struct expression *expr)
-{
- assert_int_equals(expected_expr_type, expr_type(expr));
- assert_int_equals(expected_type, expr->vm_type);
-}
-
-void assert_class_field_expr(enum vm_type expected_vm_type,
- struct vm_field *expected_field,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- if (vm_type_is_float(expected_vm_type))
- __assert_field_expr(EXPR_FLOAT_CLASS_FIELD, expected_vm_type, expr);
- else
- __assert_field_expr(EXPR_CLASS_FIELD, expected_vm_type, expr);
-
- assert_ptr_equals(expected_field, expr->class_field);
-}
-
-void assert_instance_field_expr(enum vm_type expected_vm_type,
- struct vm_field *expected_field,
- struct expression *expected_objectref,
- struct tree_node *node)
-{
- struct expression *expr = to_expr(node);
-
- if (vm_type_is_float(expected_vm_type))
- __assert_field_expr(EXPR_FLOAT_INSTANCE_FIELD, expected_vm_type, expr);
- else
- __assert_field_expr(EXPR_INSTANCE_FIELD, expected_vm_type, expr);
-
- assert_ptr_equals(expected_field, expr->instance_field);
- assert_ptr_equals(expected_objectref, to_expr(expr->objectref_expression));
-}
-
-void assert_invoke_stmt(enum vm_type result_type,
- struct vm_method *expected_method,
- struct tree_node *node)
-{
- struct statement *stmt = to_stmt(node);
-
- assert_int_equals(STMT_INVOKE, stmt_type(stmt));
-
- if (result_type == J_VOID)
- assert_ptr_equals(NULL, stmt->invoke_result);
- else
- assert_temporary_expr(result_type, &stmt->invoke_result->node);
-
- assert_ptr_equals(expected_method, stmt->target_method);
-}
-
-void assert_array_size_check_expr(struct expression *expected,
- struct expression *actual)
-{
- assert_int_equals(EXPR_ARRAY_SIZE_CHECK, expr_type(actual));
- assert_ptr_equals(&expected->node, actual->size_expr);
-}
-
-void assert_store_stmt(struct statement *stmt)
-{
- assert_int_equals(STMT_STORE, stmt_type(stmt));
-}
-
-void assert_array_store_check_stmt(struct statement *stmt,
- struct expression *arrayref,
- struct tree_node *store_src)
-{
- assert_int_equals(STMT_ARRAY_STORE_CHECK, stmt_type(stmt));
- assert_ptr_equals(arrayref, to_expr(stmt->store_check_array));
- assert_ptr_equals(store_src, stmt->store_check_src);
-}
-
-void assert_return_stmt(struct expression *return_value, struct statement *stmt)
-{
- assert_int_equals(STMT_RETURN, stmt_type(stmt));
- assert_ptr_equals(return_value, to_expr(stmt->return_value));
-}
-
-void assert_void_return_stmt(struct statement *stmt)
-{
- assert_int_equals(STMT_VOID_RETURN, stmt_type(stmt));
- assert_ptr_equals(NULL, stmt->return_value);
-}
-
-void assert_arraycheck_stmt(enum vm_type expected_vm_type,
- struct expression *expected_arrayref,
- struct expression *expected_index,
- struct statement *actual)
-{
- assert_int_equals(STMT_ARRAY_CHECK, stmt_type(actual));
- assert_array_deref_expr(expected_vm_type, expected_arrayref,
- expected_index, actual->expression);
-}
-
-void assert_monitorenter_stmt(struct expression *expected,
- struct statement *actual)
-{
- assert_int_equals(STMT_MONITOR_ENTER, stmt_type(actual));
- assert_nullcheck_value_expr(J_REFERENCE, expected->value,
- actual->expression);
-}
-
-void assert_monitorexit_stmt(struct expression *expected,
- struct statement *actual)
-{
- assert_int_equals(STMT_MONITOR_EXIT, stmt_type(actual));
- assert_nullcheck_value_expr(J_REFERENCE, expected->value,
- actual->expression);
-}
-
-void assert_checkcast_stmt(struct expression *expected,
- struct statement *actual)
-{
- assert_int_equals(STMT_CHECKCAST, stmt_type(actual));
- assert_value_expr(J_REFERENCE, expected->value, actual->expression);
-}
-
-void convert_ir_const(struct compilation_unit *cu,
- uint32_t *cp_infos,
- size_t nr_cp_infos, uint8_t *cp_types)
-{
- struct vm_class *vmc = new_class();
- struct cafebabe_class *class = malloc(sizeof *class);
- unsigned i;
-
- for (i = 0; i < nr_cp_infos; i++) {
- struct cafebabe_constant_pool *cp = &class->constant_pool[i];
-
- cp->long_ = *(struct cafebabe_constant_info_long *) &cp_infos[i];
- cp->tag = cp_types[i];
- }
-
- class->constant_pool_count = nr_cp_infos;
- vmc->class = class;
-
- cu->method->class = vmc;
- convert_to_ir(cu);
-
- free(class);
- free(vmc);
-}
-
-struct statement *first_stmt(struct compilation_unit *cu)
-{
- return stmt_entry(bb_entry(cu->bb_list.next)->stmt_list.next);
-}
diff --git a/test/unit/jit/branch-bc-test.c b/test/unit/jit/branch-bc-test.c
deleted file mode 100644
index 8d448460..00000000
--- a/test/unit/jit/branch-bc-test.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include "jit/basic-block.h"
-#include "jit/compilation-unit.h"
-#include "jit/compiler.h"
-#include "jit/expression.h"
-#include "jit/statement.h"
-#include "lib/list.h"
-#include "vm/vm.h"
-
-#include <bc-test-utils.h>
-#include <libharness.h>
-
-/*
- * The branch bytes contain a relative branch target offset from the beginning
- * of the branch bytecode instruction.
- */
-#define BRANCH_INSN_SIZE 3
-
-/* Where we are branching at. */
-#define BRANCH_OFFSET 0
-
-/* Target offset stored in the branch instruction */
-#define BRANCH_TARGET 4
-
-/* The absolute offset we are branching to */
-#define TARGET_OFFSET BRANCH_OFFSET + BRANCH_TARGET
-
-static void assert_convert_if(enum binary_operator expected_operator,
- unsigned char opc)
-{
- struct basic_block *branch_bb, *bb, *target_bb;
- struct statement *if_stmt;
- struct expression *if_value;
- struct compilation_unit *cu;
- unsigned char code[] = { opc, 0, BRANCH_TARGET, OPC_NOP, OPC_NOP };
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- branch_bb = alloc_basic_block(cu, 0, BRANCH_OFFSET + BRANCH_INSN_SIZE);
-
- bb = alloc_basic_block(cu, BRANCH_OFFSET + BRANCH_INSN_SIZE, TARGET_OFFSET);
- bb_add_successor(branch_bb, bb);
-
- target_bb = alloc_basic_block(cu, TARGET_OFFSET, TARGET_OFFSET + 1);
- bb_add_successor(bb, target_bb);
-
- cu->entry_bb = branch_bb;
-
- list_add_tail(&branch_bb->bb_list_node, &cu->bb_list);
- list_add_tail(&bb->bb_list_node, &cu->bb_list);
- list_add_tail(&target_bb->bb_list_node, &cu->bb_list);
-
- if_value = temporary_expr(J_INT, cu);
- stack_push(branch_bb->mimic_stack, if_value);
-
- convert_to_ir(cu);
- assert_true(stack_is_empty(branch_bb->mimic_stack));
-
- if_stmt = stmt_entry(branch_bb->stmt_list.next);
- assert_int_equals(STMT_IF, stmt_type(if_stmt));
- assert_ptr_equals(target_bb, if_stmt->if_true);
- __assert_binop_expr(J_INT, expected_operator, if_stmt->if_conditional);
- assert_ptr_equals(if_value, to_expr(to_expr(if_stmt->if_conditional)->binary_left));
- assert_value_expr(J_INT, 0, to_expr(if_stmt->if_conditional)->binary_right);
-
- free_compilation_unit(cu);
-}
-
-void test_convert_if(void)
-{
- assert_convert_if(OP_EQ, OPC_IFEQ);
- assert_convert_if(OP_NE, OPC_IFNE);
- assert_convert_if(OP_LT, OPC_IFLT);
- assert_convert_if(OP_GE, OPC_IFGE);
- assert_convert_if(OP_GT, OPC_IFGT);
- assert_convert_if(OP_LE, OPC_IFLE);
-}
-
-static void assert_convert_if_cmp(enum binary_operator expected_operator,
- enum vm_type vm_type, unsigned char opc)
-{
- struct expression *if_value1, *if_value2;
- struct basic_block *stmt_bb, *true_bb;
- struct statement *if_stmt;
- struct compilation_unit *cu;
- unsigned char code[] = { opc, 0, TARGET_OFFSET, OPC_NOP, OPC_NOP };
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
- stmt_bb = alloc_basic_block(cu, 0, 1);
- true_bb = alloc_basic_block(cu, TARGET_OFFSET, TARGET_OFFSET + 1);
- bb_add_successor(stmt_bb, true_bb);
- cu->entry_bb = stmt_bb;
-
- list_add_tail(&stmt_bb->bb_list_node, &cu->bb_list);
- list_add_tail(&true_bb->bb_list_node, &cu->bb_list);
-
- if_value1 = temporary_expr(vm_type, cu);
- stack_push(stmt_bb->mimic_stack, if_value1);
-
- if_value2 = temporary_expr(vm_type, cu);
- stack_push(stmt_bb->mimic_stack, if_value2);
-
- convert_to_ir(cu);
- assert_true(stack_is_empty(stmt_bb->mimic_stack));
-
- if_stmt = stmt_entry(stmt_bb->stmt_list.next);
- assert_int_equals(STMT_IF, stmt_type(if_stmt));
- assert_ptr_equals(true_bb, if_stmt->if_true);
- assert_binop_expr(vm_type, expected_operator, if_value1, if_value2,
- if_stmt->if_conditional);
-
- free_compilation_unit(cu);
-}
-
-void test_convert_if_icmp(void)
-{
- assert_convert_if_cmp(OP_EQ, J_INT, OPC_IF_ICMPEQ);
- assert_convert_if_cmp(OP_NE, J_INT, OPC_IF_ICMPNE);
- assert_convert_if_cmp(OP_LT, J_INT, OPC_IF_ICMPLT);
- assert_convert_if_cmp(OP_GE, J_INT, OPC_IF_ICMPGE);
- assert_convert_if_cmp(OP_GT, J_INT, OPC_IF_ICMPGT);
- assert_convert_if_cmp(OP_LE, J_INT, OPC_IF_ICMPLE);
-}
-
-void test_convert_if_acmp(void)
-{
- assert_convert_if_cmp(OP_EQ, J_REFERENCE, OPC_IF_ACMPEQ);
- assert_convert_if_cmp(OP_NE, J_REFERENCE, OPC_IF_ACMPNE);
-}
-
-void test_convert_goto(void)
-{
- struct basic_block *goto_bb, *target_bb;
- struct statement *goto_stmt;
- struct compilation_unit *cu;
- unsigned char code[] = { OPC_GOTO, 0, TARGET_OFFSET, OPC_NOP, OPC_NOP };
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
- goto_bb = alloc_basic_block(cu, 0, 1);
-
- target_bb = alloc_basic_block(cu, TARGET_OFFSET, TARGET_OFFSET + 1);
- bb_add_successor(goto_bb, target_bb);
-
- cu->entry_bb = goto_bb;
-
- list_add_tail(&goto_bb->bb_list_node, &cu->bb_list);
- list_add_tail(&target_bb->bb_list_node, &cu->bb_list);
-
- convert_to_ir(cu);
- assert_true(stack_is_empty(goto_bb->mimic_stack));
-
- goto_stmt = stmt_entry(goto_bb->stmt_list.next);
- assert_int_equals(STMT_GOTO, stmt_type(goto_stmt));
- assert_ptr_equals(target_bb, goto_stmt->goto_target);
-
- free_compilation_unit(cu);
-}
-
-void test_convert_ifnull(void)
-{
- assert_convert_if(OP_EQ, OPC_IFNULL);
-}
-
-void test_convert_ifnonnull(void)
-{
- assert_convert_if(OP_NE, OPC_IFNONNULL);
-}
-
-static unsigned char is_zero_bytecode[] = {
- OPC_ILOAD_0,
- OPC_ICONST_0,
- OPC_IF_ICMPEQ, 0x00, 0x05,
-
- OPC_ICONST_0,
- OPC_IRETURN,
-
- OPC_ICONST_1,
- OPC_IRETURN,
-};
-
-void test_insn_after_branch_are_added_to_another_bb(void)
-{
- struct compilation_unit *cu;
- struct basic_block *bb;
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = is_zero_bytecode,
- .code_attribute.code_length = ARRAY_SIZE(is_zero_bytecode),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- convert_to_ir(cu);
-
- bb = list_first_entry(&cu->bb_list, struct basic_block, bb_list_node);
- assert_false(list_is_empty(&bb->stmt_list));
-
- bb = list_next_entry(&bb->bb_list_node, struct basic_block, bb_list_node);
- assert_false(list_is_empty(&bb->stmt_list));
-
- free_compilation_unit(cu);
-}
diff --git a/test/unit/jit/bytecode-to-ir-stub.c b/test/unit/jit/bytecode-to-ir-stub.c
deleted file mode 100644
index 3af7e262..00000000
--- a/test/unit/jit/bytecode-to-ir-stub.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "jit/compiler.h"
-#include "jit/expression.h"
-
-void convert_expression(struct parse_context *ctx, struct expression *expr)
-{
-}
-
-void convert_statement(struct parse_context *ctx, struct statement *stmt)
-{
-}
diff --git a/test/unit/jit/bytecode-to-ir-test.c b/test/unit/jit/bytecode-to-ir-test.c
deleted file mode 100644
index 057f4469..00000000
--- a/test/unit/jit/bytecode-to-ir-test.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2005 Pekka Enberg
- */
-
-#include "jit/compiler.h"
-#include "jit/statement.h"
-#include "lib/list.h"
-#include "lib/stack.h"
-#include "vm/system.h"
-
-#include <bc-test-utils.h>
-#include <libharness.h>
-#include <stdlib.h>
-
-void test_convert_nop(void)
-{
- unsigned char code[] = { OPC_NOP };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
- convert_to_ir(bb->b_parent);
- assert_true(stack_is_empty(bb->mimic_stack));
- __free_simple_bb(bb);
-}
-
-/* MISSING: jsr */
-
-/* MISSING: ret */
-
-/* MISSING: tableswitch */
-
-/* MISSING: lookupswitch */
-
-/* MISSING: getfield */
-
-/* MISSING: putfield */
-
-/* MISSING: new */
-
-/* MISSING: newarray */
-
-/* MISSING: athrow */
-
-/* MISSING: checkcast */
-
-/* MISSING: instanceof */
-
-/* MISSING: monitorenter */
-
-/* MISSING: monitorexit */
-
-/* MISSING: wide */
-
-/* MISSING: ifnull */
-
-/* MISSING: ifnonnull */
-
-/* MISSING: goto_w */
-
-/* MISSING: jsr_w */
-
-void test_converts_complete_basic_block(void)
-{
- unsigned char code[] = { OPC_ILOAD_0, OPC_ILOAD_1, OPC_IADD, OPC_IRETURN };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
- convert_to_ir(bb->b_parent);
-
- assert_false(list_is_empty(&bb->stmt_list));
- assert_true(stack_is_empty(bb->mimic_stack));
-
- __free_simple_bb(bb);
-}
diff --git a/test/unit/jit/load-store-bc-test.c b/test/unit/jit/load-store-bc-test.c
deleted file mode 100644
index 8acda3bc..00000000
--- a/test/unit/jit/load-store-bc-test.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include "cafebabe/constant_pool.h"
-
-#include "vm/system.h"
-#include "vm/types.h"
-#include "vm/vm.h"
-#include "vm/limits.h"
-#include "jit/expression.h"
-#include "jit/compiler.h"
-#include <libharness.h>
-#include <string.h>
-#include "test/vm.h"
-
-#include "bc-test-utils.h"
-
-static void __assert_convert_const(enum vm_type expected_type,
- long long expected_value,
- unsigned char *code,
- unsigned long code_size)
-{
- struct expression *expr;
- struct basic_block *bb;
-
- bb = alloc_simple_bb(code, code_size);
- convert_to_ir(bb->b_parent);
-
- expr = stack_pop(bb->mimic_stack);
- assert_value_expr(expected_type, expected_value, &expr->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(expr);
- free_simple_bb(bb);
-}
-
-static void assert_convert_const(enum vm_type expected_type,
- long long expected_value,
- unsigned char opc)
-{
- __assert_convert_const(expected_type, expected_value, &opc, 1);
-}
-
-static void assert_convert_bipush(long long expected_value,
- unsigned char byte, char opc)
-{
- unsigned char code[] = { opc, byte };
-
- __assert_convert_const(J_INT, expected_value, code, ARRAY_SIZE(code));
-}
-
-static void assert_convert_sipush(long long expected_value,
- unsigned char high_byte,
- unsigned char low_byte,
- unsigned char opc)
-{
- unsigned char code[] = { opc, high_byte, low_byte };
-
- __assert_convert_const(J_INT, expected_value, code, ARRAY_SIZE(code));
-}
-
-static void assert_convert_fconst(enum vm_type expected_type,
- double expected_value, unsigned char opc)
-{
- struct expression *expr;
- struct basic_block *bb;
-
- bb = alloc_simple_bb(&opc, 1);
- convert_to_ir(bb->b_parent);
-
- expr = stack_pop(bb->mimic_stack);
- assert_fvalue_expr(expected_type, expected_value, &expr->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(expr);
- free_simple_bb(bb);
-}
-
-void test_convert_aconst_null(void)
-{
- assert_convert_const(J_REFERENCE, 0, OPC_ACONST_NULL);
-}
-
-void test_convert_iconst(void)
-{
- assert_convert_const(J_INT, -1, OPC_ICONST_M1);
- assert_convert_const(J_INT, 0, OPC_ICONST_0);
- assert_convert_const(J_INT, 1, OPC_ICONST_1);
- assert_convert_const(J_INT, 2, OPC_ICONST_2);
- assert_convert_const(J_INT, 3, OPC_ICONST_3);
- assert_convert_const(J_INT, 4, OPC_ICONST_4);
- assert_convert_const(J_INT, 5, OPC_ICONST_5);
-}
-
-void test_convert_lconst(void)
-{
- assert_convert_const(J_LONG, 0, OPC_LCONST_0);
- assert_convert_const(J_LONG, 1, OPC_LCONST_1);
-}
-
-void test_convert_fconst(void)
-{
- assert_convert_fconst(J_FLOAT, 0, OPC_FCONST_0);
- assert_convert_fconst(J_FLOAT, 1, OPC_FCONST_1);
- assert_convert_fconst(J_FLOAT, 2, OPC_FCONST_2);
-}
-
-void test_convert_dconst(void)
-{
- assert_convert_fconst(J_DOUBLE, 0, OPC_DCONST_0);
- assert_convert_fconst(J_DOUBLE, 1, OPC_DCONST_1);
-}
-
-void test_convert_bipush(void)
-{
- assert_convert_bipush(0, 0x00, OPC_BIPUSH);
- assert_convert_bipush(1, 0x01, OPC_BIPUSH);
- assert_convert_bipush(J_BYTE_MIN, 0x80, OPC_BIPUSH);
- assert_convert_bipush(J_BYTE_MAX, 0x7F, OPC_BIPUSH);
-}
-
-void test_convert_sipush(void)
-{
- assert_convert_sipush(0, 0x00, 0x00, OPC_SIPUSH);
- assert_convert_sipush(1, 0x00, 0x01, OPC_SIPUSH);
- assert_convert_sipush(J_SHORT_MIN, 0x80, 0x00, OPC_SIPUSH);
- assert_convert_sipush(J_SHORT_MAX, 0x7F, 0xFF, OPC_SIPUSH);
-}
-
-static void __assert_convert_load(unsigned char *code,
- unsigned long code_size,
- enum vm_type expected_type,
- unsigned char expected_index)
-{
- struct expression *expr;
- struct statement *stmt;
- struct basic_block *bb;
-
- bb = alloc_simple_bb(code, code_size);
-
- convert_to_ir(bb->b_parent);
-
- expr = stack_pop(bb->mimic_stack);
- assert_temporary_expr(expected_type, &expr->node);
-
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_store_stmt(stmt);
- assert_local_expr(expected_type, expected_index, stmt->store_src);
- assert_ptr_equals(&expr->node, stmt->store_dest);
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(expr);
- free_simple_bb(bb);
-}
-
-static void assert_convert_load(unsigned char opc,
- enum vm_type expected_type,
- unsigned char expected_index)
-{
- unsigned char code[] = { opc, expected_index };
-
- __assert_convert_load(code, ARRAY_SIZE(code), expected_type, expected_index);
-}
-
-static void assert_convert_load_n(unsigned char opc,
- enum vm_type expected_type,
- unsigned char expected_index)
-{
- __assert_convert_load(&opc, 1, expected_type, expected_index);
-}
-
-void test_convert_iload(void)
-{
- assert_convert_load(OPC_ILOAD, J_INT, 0x00);
- assert_convert_load(OPC_ILOAD, J_INT, 0x01);
- assert_convert_load(OPC_ILOAD, J_INT, 0xFF);
-}
-
-void test_convert_lload(void)
-{
- assert_convert_load(OPC_LLOAD, J_LONG, 0x00);
- assert_convert_load(OPC_LLOAD, J_LONG, 0x01);
- assert_convert_load(OPC_LLOAD, J_LONG, 0xFF);
-}
-
-void test_convert_fload(void)
-{
- assert_convert_load(OPC_FLOAD, J_FLOAT, 0x00);
- assert_convert_load(OPC_FLOAD, J_FLOAT, 0x01);
- assert_convert_load(OPC_FLOAD, J_FLOAT, 0xFF);
-}
-
-void test_convert_dload(void)
-{
- assert_convert_load(OPC_DLOAD, J_DOUBLE, 0x00);
- assert_convert_load(OPC_DLOAD, J_DOUBLE, 0x01);
- assert_convert_load(OPC_DLOAD, J_DOUBLE, 0xFF);
-}
-
-void test_convert_aload(void)
-{
- assert_convert_load(OPC_ALOAD, J_REFERENCE, 0x00);
- assert_convert_load(OPC_ALOAD, J_REFERENCE, 0x01);
- assert_convert_load(OPC_ALOAD, J_REFERENCE, 0xFF);
-}
-
-void test_convert_iload_n(void)
-{
- assert_convert_load_n(OPC_ILOAD_0, J_INT, 0x00);
- assert_convert_load_n(OPC_ILOAD_1, J_INT, 0x01);
- assert_convert_load_n(OPC_ILOAD_2, J_INT, 0x02);
- assert_convert_load_n(OPC_ILOAD_3, J_INT, 0x03);
-}
-
-void test_convert_lload_n(void)
-{
- assert_convert_load_n(OPC_LLOAD_0, J_LONG, 0x00);
- assert_convert_load_n(OPC_LLOAD_1, J_LONG, 0x01);
- assert_convert_load_n(OPC_LLOAD_2, J_LONG, 0x02);
- assert_convert_load_n(OPC_LLOAD_3, J_LONG, 0x03);
-}
-
-void test_convert_fload_n(void)
-{
- assert_convert_load_n(OPC_FLOAD_0, J_FLOAT, 0x00);
- assert_convert_load_n(OPC_FLOAD_1, J_FLOAT, 0x01);
- assert_convert_load_n(OPC_FLOAD_2, J_FLOAT, 0x02);
- assert_convert_load_n(OPC_FLOAD_3, J_FLOAT, 0x03);
-}
-
-void test_convert_dload_n(void)
-{
- assert_convert_load_n(OPC_DLOAD_0, J_DOUBLE, 0x00);
- assert_convert_load_n(OPC_DLOAD_1, J_DOUBLE, 0x01);
- assert_convert_load_n(OPC_DLOAD_2, J_DOUBLE, 0x02);
- assert_convert_load_n(OPC_DLOAD_3, J_DOUBLE, 0x03);
-}
-
-void test_convert_aload_n(void)
-{
- assert_convert_load_n(OPC_ALOAD_0, J_REFERENCE, 0x00);
- assert_convert_load_n(OPC_ALOAD_1, J_REFERENCE, 0x01);
- assert_convert_load_n(OPC_ALOAD_2, J_REFERENCE, 0x02);
- assert_convert_load_n(OPC_ALOAD_3, J_REFERENCE, 0x03);
-}
-
-static void __assert_convert_store(unsigned char *code,
- unsigned long code_size,
- enum vm_type expected_type,
- unsigned char expected_index)
-{
- struct statement *stmt;
- struct basic_block *bb;
-
- bb = alloc_simple_bb(code, code_size);
-
- stack_push(bb->mimic_stack, temporary_expr(expected_type, bb->b_parent));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_store_stmt(stmt);
- assert_temporary_expr(expected_type, stmt->store_src);
- assert_local_expr(expected_type, expected_index, stmt->store_dest);
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-static void assert_convert_store(unsigned char opc,
- enum vm_type expected_type,
- unsigned char expected_index)
-{
- unsigned char code[] = { opc, expected_index };
-
- __assert_convert_store(code, ARRAY_SIZE(code), expected_type,
- expected_index);
-}
-
-static void assert_convert_store_n(unsigned char opc,
- enum vm_type expected_type,
- unsigned char expected_index)
-{
- __assert_convert_store(&opc, 1, expected_type, expected_index);
-}
-
-void test_convert_istore(void)
-{
- assert_convert_store(OPC_ISTORE, J_INT, 0x00);
- assert_convert_store(OPC_ISTORE, J_INT, 0x01);
-}
-
-void test_convert_lstore(void)
-{
- assert_convert_store(OPC_LSTORE, J_LONG, 0x00);
- assert_convert_store(OPC_LSTORE, J_LONG, 0x01);
-}
-
-void test_convert_fstore(void)
-{
- assert_convert_store(OPC_FSTORE, J_FLOAT, 0x00);
- assert_convert_store(OPC_FSTORE, J_FLOAT, 0x01);
-}
-
-void test_convert_dstore(void)
-{
- assert_convert_store(OPC_DSTORE, J_DOUBLE, 0x00);
- assert_convert_store(OPC_DSTORE, J_DOUBLE, 0x01);
-}
-
-void test_convert_astore(void)
-{
- assert_convert_store(OPC_ASTORE, J_REFERENCE, 0x00);
- assert_convert_store(OPC_ASTORE, J_REFERENCE, 0x01);
-}
-
-void test_convert_istore_n(void)
-{
- assert_convert_store_n(OPC_ISTORE_0, J_INT, 0x00);
- assert_convert_store_n(OPC_ISTORE_1, J_INT, 0x01);
- assert_convert_store_n(OPC_ISTORE_2, J_INT, 0x02);
- assert_convert_store_n(OPC_ISTORE_3, J_INT, 0x03);
-}
-
-void test_convert_lstore_n(void)
-{
- assert_convert_store_n(OPC_LSTORE_0, J_LONG, 0x00);
- assert_convert_store_n(OPC_LSTORE_1, J_LONG, 0x01);
- assert_convert_store_n(OPC_LSTORE_2, J_LONG, 0x02);
- assert_convert_store_n(OPC_LSTORE_3, J_LONG, 0x03);
-}
-
-void test_convert_fstore_n(void)
-{
- assert_convert_store_n(OPC_FSTORE_0, J_FLOAT, 0x00);
- assert_convert_store_n(OPC_FSTORE_1, J_FLOAT, 0x01);
- assert_convert_store_n(OPC_FSTORE_2, J_FLOAT, 0x02);
- assert_convert_store_n(OPC_FSTORE_3, J_FLOAT, 0x03);
-}
-
-void test_convert_dstore_n(void)
-{
- assert_convert_store_n(OPC_DSTORE_0, J_DOUBLE, 0x00);
- assert_convert_store_n(OPC_DSTORE_1, J_DOUBLE, 0x01);
- assert_convert_store_n(OPC_DSTORE_2, J_DOUBLE, 0x02);
- assert_convert_store_n(OPC_DSTORE_3, J_DOUBLE, 0x03);
-}
-
-void test_convert_astore_n(void)
-{
- assert_convert_store_n(OPC_ASTORE_0, J_REFERENCE, 0x00);
- assert_convert_store_n(OPC_ASTORE_1, J_REFERENCE, 0x01);
- assert_convert_store_n(OPC_ASTORE_2, J_REFERENCE, 0x02);
- assert_convert_store_n(OPC_ASTORE_3, J_REFERENCE, 0x03);
-}
-
diff --git a/test/unit/jit/object-bc-test.c b/test/unit/jit/object-bc-test.c
deleted file mode 100644
index 4bc9619f..00000000
--- a/test/unit/jit/object-bc-test.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include <bc-test-utils.h>
-#include <args-test-utils.h>
-#include "jit/compilation-unit.h"
-#include "jit/expression.h"
-#include "jit/compiler.h"
-#include <libharness.h>
-#include "lib/stack.h"
-#include "vm/system.h"
-#include "vm/types.h"
-#include "vm/vm.h"
-
-#include "test/vm.h"
-
-#include <string.h>
-
-struct type_mapping {
- char *type;
- enum vm_type vm_type;
-};
-
-static void assert_convert_array_load(enum vm_type expected_type,
- unsigned char opc,
- unsigned long arrayref,
- unsigned long index)
-{
- unsigned char code[] = { opc };
- struct expression *arrayref_expr, *index_expr, *temporary_expr;
- struct statement *stmt;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
-
- arrayref_expr = value_expr(J_REFERENCE, arrayref);
- index_expr = value_expr(J_INT, index);
-
- stack_push(bb->mimic_stack, arrayref_expr);
- stack_push(bb->mimic_stack, index_expr);
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- struct statement *arrayref_pure_stmt = stmt;
- struct statement *arraycheck_stmt = stmt_entry(arrayref_pure_stmt->stmt_list_node.next);
- struct statement *store_stmt = stmt_entry(arraycheck_stmt->stmt_list_node.next);
-
- assert_store_stmt(arrayref_pure_stmt);
- assert_nullcheck_value_expr(J_REFERENCE, arrayref,
- arrayref_pure_stmt->store_src);
- assert_temporary_expr(J_REFERENCE, arrayref_pure_stmt->store_dest);
-
- assert_arraycheck_stmt(expected_type,
- to_expr(arrayref_pure_stmt->store_dest),
- index_expr,
- arraycheck_stmt);
-
- assert_store_stmt(store_stmt);
- assert_array_deref_expr(expected_type,
- to_expr(arrayref_pure_stmt->store_dest),
- index_expr,
- store_stmt->store_src);
-
- temporary_expr = stack_pop(bb->mimic_stack);
-
- assert_temporary_expr(expected_type, &temporary_expr->node);
- expr_put(temporary_expr);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- __free_simple_bb(bb);
-}
-
-void test_convert_iaload(void)
-{
- assert_convert_array_load(J_INT, OPC_IALOAD, 0, 1);
- assert_convert_array_load(J_INT, OPC_IALOAD, 1, 2);
-}
-
-void test_convert_laload(void)
-{
- assert_convert_array_load(J_LONG, OPC_LALOAD, 0, 1);
- assert_convert_array_load(J_LONG, OPC_LALOAD, 1, 2);
-}
-
-void test_convert_faload(void)
-{
- assert_convert_array_load(J_FLOAT, OPC_FALOAD, 0, 1);
- assert_convert_array_load(J_FLOAT, OPC_FALOAD, 1, 2);
-}
-
-void test_convert_daload(void)
-{
- assert_convert_array_load(J_DOUBLE, OPC_DALOAD, 0, 1);
- assert_convert_array_load(J_DOUBLE, OPC_DALOAD, 1, 2);
-}
-
-void test_convert_aaload(void)
-{
- assert_convert_array_load(J_REFERENCE, OPC_AALOAD, 0, 1);
- assert_convert_array_load(J_REFERENCE, OPC_AALOAD, 1, 2);
-}
-
-void test_convert_baload(void)
-{
- assert_convert_array_load(J_BYTE, OPC_BALOAD, 0, 1);
- assert_convert_array_load(J_BYTE, OPC_BALOAD, 1, 2);
-}
-
-void test_convert_caload(void)
-{
- assert_convert_array_load(J_CHAR, OPC_CALOAD, 0, 1);
- assert_convert_array_load(J_CHAR, OPC_CALOAD, 1, 2);
-}
-
-void test_convert_saload(void)
-{
- assert_convert_array_load(J_SHORT, OPC_SALOAD, 0, 1);
- assert_convert_array_load(J_SHORT, OPC_SALOAD, 1, 2);
-}
-
-static void assert_convert_array_store(enum vm_type expected_type,
- unsigned char opc,
- unsigned long arrayref,
- unsigned long index)
-{
- unsigned char code[] = { opc };
- struct expression *arrayref_expr, *index_expr, *expr;
- struct statement *stmt;
- struct basic_block *bb;
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
-
- bb = __alloc_simple_bb(&method);
-
- arrayref_expr = value_expr(J_REFERENCE, arrayref);
- index_expr = value_expr(J_INT, index);
- expr = temporary_expr(expected_type, bb->b_parent);
-
- stack_push(bb->mimic_stack, arrayref_expr);
- stack_push(bb->mimic_stack, index_expr);
- stack_push(bb->mimic_stack, expr);
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- struct statement *arrayref_pure_stmt = stmt;
- struct statement *arraycheck_stmt = stmt_entry(arrayref_pure_stmt->stmt_list_node.next);
- struct statement *storecheck_stmt = stmt_entry(arraycheck_stmt->stmt_list_node.next);
- struct statement *store_stmt = stmt_entry(storecheck_stmt->stmt_list_node.next);
-
- assert_store_stmt(arrayref_pure_stmt);
- assert_nullcheck_value_expr(J_REFERENCE, arrayref,
- arrayref_pure_stmt->store_src);
- assert_temporary_expr(J_REFERENCE, arrayref_pure_stmt->store_dest);
-
- assert_arraycheck_stmt(expected_type,
- to_expr(arrayref_pure_stmt->store_dest),
- index_expr,
- arraycheck_stmt);
-
- assert_array_store_check_stmt(storecheck_stmt,
- to_expr(arrayref_pure_stmt->store_dest),
- store_stmt->store_src);
- assert_store_stmt(store_stmt);
- assert_array_deref_expr(expected_type,
- to_expr(arrayref_pure_stmt->store_dest),
- index_expr,
- store_stmt->store_dest);
- assert_temporary_expr(expected_type, store_stmt->store_src);
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- __free_simple_bb(bb);
-}
-
-void test_convert_iastore(void)
-{
- assert_convert_array_store(J_INT, OPC_IASTORE, 0, 1);
- assert_convert_array_store(J_INT, OPC_IASTORE, 2, 3);
-}
-
-void test_convert_lastore(void)
-{
- assert_convert_array_store(J_LONG, OPC_LASTORE, 0, 1);
- assert_convert_array_store(J_LONG, OPC_LASTORE, 2, 3);
-}
-
-void test_convert_fastore(void)
-{
- assert_convert_array_store(J_FLOAT, OPC_FASTORE, 0, 1);
- assert_convert_array_store(J_FLOAT, OPC_FASTORE, 2, 3);
-}
-
-void test_convert_dastore(void)
-{
- assert_convert_array_store(J_DOUBLE, OPC_DASTORE, 0, 1);
- assert_convert_array_store(J_DOUBLE, OPC_DASTORE, 2, 3);
-}
-
-void test_convert_aastore(void)
-{
- assert_convert_array_store(J_REFERENCE, OPC_AASTORE, 0, 1);
- assert_convert_array_store(J_REFERENCE, OPC_AASTORE, 2, 3);
-}
-
-void test_convert_bastore(void)
-{
- assert_convert_array_store(J_BYTE, OPC_BASTORE, 0, 1);
- assert_convert_array_store(J_BYTE, OPC_BASTORE, 2, 3);
-}
-
-void test_convert_castore(void)
-{
- assert_convert_array_store(J_CHAR, OPC_CASTORE, 0, 1);
- assert_convert_array_store(J_CHAR, OPC_CASTORE, 2, 3);
-}
-
-void test_convert_sastore(void)
-{
- assert_convert_array_store(J_SHORT, OPC_SASTORE, 0, 1);
- assert_convert_array_store(J_SHORT, OPC_SASTORE, 2, 3);
-}
-
-void test_convert_newarray(void)
-{
- unsigned char code[] = { OPC_NEWARRAY, T_INT };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct expression *size, *arrayref;
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
-
- size = value_expr(J_INT, 0xff);
- stack_push(bb->mimic_stack, size);
-
- convert_to_ir(bb->b_parent);
-
- arrayref = stack_pop(bb->mimic_stack);
- assert_int_equals(EXPR_NEWARRAY, expr_type(arrayref));
- assert_int_equals(J_REFERENCE, arrayref->vm_type);
- assert_array_size_check_expr(size, to_expr(arrayref->array_size));
- assert_int_equals(T_INT, arrayref->array_type);
-
- expr_put(arrayref);
- __free_simple_bb(bb);
-}
-
-void test_convert_arraylength(void)
-{
- unsigned char code[] = { OPC_ARRAYLENGTH };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct expression *arrayref, *arraylen_exp;
- struct basic_block *bb;
- struct vm_class *class = new_class();
-
- bb = __alloc_simple_bb(&method);
-
- arrayref = value_expr(J_REFERENCE, (unsigned long) class);
- stack_push(bb->mimic_stack, arrayref);
-
- convert_to_ir(bb->b_parent);
-
- arraylen_exp = stack_pop(bb->mimic_stack);
- assert_int_equals(EXPR_ARRAYLENGTH, expr_type(arraylen_exp));
- assert_int_equals(J_INT, arraylen_exp->vm_type);
- assert_nullcheck_value_expr(J_REFERENCE, (unsigned long) class, arraylen_exp->arraylength_ref);
-
- expr_put(arraylen_exp);
- __free_simple_bb(bb);
- free(class);
-}
-
-void test_convert_monitorenter(void)
-{
- unsigned char code[] = { OPC_MONITORENTER };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct expression *ref;
- struct statement *stmt;
- struct basic_block *bb;
- struct vm_class *class = new_class();
-
- bb = __alloc_simple_bb(&method);
-
- ref = value_expr(J_REFERENCE, (unsigned long) class);
- stack_push(bb->mimic_stack, ref);
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_monitorenter_stmt(ref, stmt);
-
- expr_put(ref);
- __free_simple_bb(bb);
- free(class);
-}
-
-void test_convert_monitorexit(void)
-{
- unsigned char code[] = { OPC_MONITOREXIT };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct expression *ref;
- struct statement *stmt;
- struct basic_block *bb;
- struct vm_class *class = new_class();
-
- bb = __alloc_simple_bb(&method);
-
- ref = value_expr(J_REFERENCE, (unsigned long) class);
- stack_push(bb->mimic_stack, ref);
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_monitorexit_stmt(ref, stmt);
-
- expr_put(ref);
- __free_simple_bb(bb);
- free(class);
-}
diff --git a/test/unit/jit/ostack-bc-test.c b/test/unit/jit/ostack-bc-test.c
deleted file mode 100644
index dd16a148..00000000
--- a/test/unit/jit/ostack-bc-test.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include "vm/vm.h"
-#include "jit/expression.h"
-#include "jit/compiler.h"
-#include <stdlib.h>
-#include <libharness.h>
-
-#include "bc-test-utils.h"
-
-/* The returned pointer could be stale because of expr_put() so only use the
- return value for pointer comparison. */
-static struct expression *pop_and_put_expr(struct stack *stack)
-{
- struct expression *expr;
-
- expr = stack_pop(stack);
- expr_put(expr);
-
- return expr;
-}
-
-static void assert_dup_stack(unsigned char opc, struct expression *value)
-{
- struct basic_block *bb;
- struct statement *stmt;
-
- bb = alloc_simple_bb(&opc, 1);
- stack_push(bb->mimic_stack, expr_get(value));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_store_stmt(stmt);
- assert_ptr_equals(value, to_expr(stmt->store_src));
- assert_temporary_expr(value->vm_type, stmt->store_dest);
-
- assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value, pop_and_put_expr(bb->mimic_stack));
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-static void assert_dup2_stack(unsigned char opc, struct expression *value, struct expression *value2)
-{
- struct statement *stmt, *stmt2;
- struct basic_block *bb;
-
- if (value->vm_type == J_LONG || value->vm_type == J_DOUBLE) {
- assert_dup_stack(opc, value);
- return;
- }
-
- bb = alloc_simple_bb(&opc, 1);
-
- stack_push(bb->mimic_stack, expr_get(value2));
- stack_push(bb->mimic_stack, expr_get(value));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
- stmt2 = stmt_entry(stmt->stmt_list_node.next);
-
- assert_store_stmt(stmt);
- assert_ptr_equals(value2, to_expr(stmt->store_src));
- assert_temporary_expr(value2->vm_type, stmt->store_dest);
-
- assert_store_stmt(stmt2);
- assert_ptr_equals(value, to_expr(stmt2->store_src));
- assert_temporary_expr(value->vm_type, stmt->store_dest);
-
- assert_ptr_equals(to_expr(stmt2->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack));
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-void test_convert_dup(void)
-{
- struct expression *value1, *value2, *value3;
-
- value1 = value_expr(J_REFERENCE, 0xdeadbeef);
- value2 = value_expr(J_REFERENCE, 0xcafedeca);
- value3 = value_expr(J_LONG, 0xcafecafecafecafe);
-
- assert_dup_stack(OPC_DUP, value1);
- assert_dup2_stack(OPC_DUP2, value1, value2);
- assert_dup2_stack(OPC_DUP2, value3, NULL);
-
- expr_put(value1);
- expr_put(value2);
- expr_put(value3);
-}
-
-static void assert_dup_x1_stack(unsigned char opc, struct expression *value1,
- struct expression *value2)
-{
- struct basic_block *bb;
- struct statement *stmt;
-
- bb = alloc_simple_bb(&opc, 1);
-
- stack_push(bb->mimic_stack, expr_get(value2));
- stack_push(bb->mimic_stack, expr_get(value1));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_store_stmt(stmt);
- assert_ptr_equals(value1, to_expr(stmt->store_src));
- assert_temporary_expr(value1->vm_type, stmt->store_dest);
-
- assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value1, pop_and_put_expr(bb->mimic_stack));
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-static void assert_dup2_x1_stack(unsigned char opc, struct expression *value1,
- struct expression *value2, struct expression *value3)
-{
- struct statement *stmt, *stmt2;
- struct basic_block *bb;
-
- if (value1->vm_type == J_LONG || value2->vm_type == J_DOUBLE) {
- assert_dup_x1_stack(opc, value1, value2);
- return;
- }
-
- bb = alloc_simple_bb(&opc, 1);
-
- stack_push(bb->mimic_stack, expr_get(value3));
- stack_push(bb->mimic_stack, expr_get(value2));
- stack_push(bb->mimic_stack, expr_get(value1));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
- stmt2 = stmt_entry(stmt->stmt_list_node.next);
-
- assert_store_stmt(stmt);
- assert_ptr_equals(value2, to_expr(stmt->store_src));
- assert_temporary_expr(value2->vm_type, stmt->store_dest);
-
- assert_store_stmt(stmt2);
- assert_ptr_equals(value1, to_expr(stmt2->store_src));
- assert_temporary_expr(value1->vm_type, stmt2->store_dest);
-
- assert_ptr_equals(to_expr(stmt2->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value3, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value1, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack));
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-void test_convert_dup_x1(void)
-{
- struct expression *value1, *value2, *value3;
-
- value1 = value_expr(J_REFERENCE, 0xdeadbeef);
- value2 = value_expr(J_REFERENCE, 0xcafebabe);
- value3 = value_expr(J_LONG, 0xdecacafebabebeef);
-
- assert_dup_x1_stack(OPC_DUP_X1, value1, value2);
- assert_dup2_x1_stack(OPC_DUP2_X1, value1, value2, value3);
- assert_dup2_x1_stack(OPC_DUP2_X1, value3, value2, value1);
-
- expr_put(value1);
- expr_put(value2);
- expr_put(value3);
-}
-
-static void assert_dup_x2_stack(unsigned char opc, struct expression *value1,
- struct expression *value2, struct expression *value3)
-{
- struct basic_block *bb;
- struct statement *stmt;
-
- bb = alloc_simple_bb(&opc, 1);
-
- stack_push(bb->mimic_stack, expr_get(value3));
- stack_push(bb->mimic_stack, expr_get(value2));
- stack_push(bb->mimic_stack, expr_get(value1));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
-
- assert_store_stmt(stmt);
- assert_ptr_equals(value1, to_expr(stmt->store_src));
- assert_temporary_expr(value1->vm_type, stmt->store_dest);
-
- assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value3, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value1, pop_and_put_expr(bb->mimic_stack));
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-static void assert_dup2_x2_stack(unsigned char opc, struct expression *value1,
- struct expression *value2, struct expression *value3,
- struct expression *value4)
-{
- struct statement *stmt, *stmt2;
- struct basic_block *bb;
-
- if (value1->vm_type == J_LONG || value1->vm_type == J_DOUBLE) {
- if (value2->vm_type == J_LONG || value2->vm_type == J_DOUBLE) {
- assert_dup_x1_stack(opc, value1, value2);
- return;
- } else {
- assert_dup_x2_stack(opc, value1, value2, value3);
- return;
- }
- } else {
- if (value3->vm_type == J_LONG || value3->vm_type == J_DOUBLE) {
- assert_dup2_x1_stack(opc, value1, value2, value3);
- return;
- }
- }
-
- bb = alloc_simple_bb(&opc, 1);
-
- stack_push(bb->mimic_stack, expr_get(value4));
- stack_push(bb->mimic_stack, expr_get(value3));
- stack_push(bb->mimic_stack, expr_get(value2));
- stack_push(bb->mimic_stack, expr_get(value1));
-
- convert_to_ir(bb->b_parent);
- stmt = stmt_entry(bb->stmt_list.next);
- stmt2 = stmt_entry(stmt->stmt_list_node.next);
-
- assert_store_stmt(stmt);
- assert_ptr_equals(value2, to_expr(stmt->store_src));
- assert_temporary_expr(value2->vm_type, stmt->store_dest);
-
- assert_store_stmt(stmt2);
- assert_ptr_equals(value1, to_expr(stmt2->store_src));
- assert_temporary_expr(value1->vm_type, stmt2->store_dest);
-
- assert_ptr_equals(to_expr(stmt2->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(to_expr(stmt->store_dest), pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value3, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value4, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value1, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack));
-
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-void test_convert_dup_x2(void)
-{
- struct expression *value1, *value2, *value3, *value4;
-
- value1 = value_expr(J_REFERENCE, 0xdeadbeef);
- value2 = value_expr(J_REFERENCE, 0xcafebabe);
- value3 = value_expr(J_REFERENCE, 0xb4df00d);
- value4 = value_expr(J_REFERENCE, 0x6559570);
-
- assert_dup_x2_stack(OPC_DUP_X2, value1, value2, value3);
- assert_dup2_x2_stack(OPC_DUP2_X2, value1, value2, value3, value4);
-
- expr_put(value1);
- expr_put(value2);
- expr_put(value3);
- expr_put(value4);
-}
-
-static void
-assert_swap_stack(unsigned char opc, void *value1, void *value2)
-{
- struct basic_block *bb;
-
- bb = alloc_simple_bb(&opc, 1);
-
- stack_push(bb->mimic_stack, expr_get(value1));
- stack_push(bb->mimic_stack, expr_get(value2));
-
- convert_to_ir(bb->b_parent);
- assert_ptr_equals(value1, pop_and_put_expr(bb->mimic_stack));
- assert_ptr_equals(value2, pop_and_put_expr(bb->mimic_stack));
- assert_true(stack_is_empty(bb->mimic_stack));
-
- free_simple_bb(bb);
-}
-
-void test_convert_swap(void)
-{
- struct expression *expr1;
- struct expression *expr2;
-
- expr1 = value_expr(J_INT, 1);
- expr2 = value_expr(J_INT, 2);
-
- assert_swap_stack(OPC_SWAP, expr1, expr2);
-
- expr_put(expr1);
- expr_put(expr2);
-}
diff --git a/test/unit/jit/switch-bc-test.c b/test/unit/jit/switch-bc-test.c
deleted file mode 100644
index ce281e13..00000000
--- a/test/unit/jit/switch-bc-test.c
+++ /dev/null
@@ -1,249 +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>
-
-/* Test1 for tableswitch:
- int tableswitch(int i) {
- switch (i) {
- case 0: return 0;
- case 1: return 1;
- case 2: return 2;
- default: return -1;
- }
- }
- */
-static unsigned char tableswitch1[36] = {
- 0x1b, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x1d,
- 0x00, 0x00, 0x00, 0x1f, 0x03, 0xac, 0x04, 0xac,
- 0x05, 0xac, 0x02, 0xac,
-};
-
-void test_convert_tableswitch_bbs1(void)
-{
- struct basic_block *bb0, *bb1, *bb2, *bb3, *bb4, *bb5, *bb6;
- struct compilation_unit *cu;
-
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = tableswitch1,
- .code_attribute.code_length = ARRAY_SIZE(tableswitch1),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- convert_to_ir(cu);
- assert_int_equals(7, 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);
-
- assert_basic_block_successors((struct basic_block*[]){bb6, bb1}, 2, bb0);
- assert_basic_block_successors((struct basic_block*[]){bb6, bb2}, 2, bb1);
- assert_basic_block_successors((struct basic_block*[]){bb3, bb4, bb5}, 3, bb2);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb3);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb4);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb5);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb6);
-}
-
-/* Test2 for tableswitch:
- void tableswitch() {
- int a = 1;
- switch (a) {
- case 0:
- a = 10;
- case 1:
- a = 30;
- case 5:
- a = 50;
- }
- }
- */
-static unsigned char tableswitch2[46] = {
- 0x04, 0x3c, 0x1b, 0xab, 0x00, 0x00, 0x00, 0x2a,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x05,
- 0x00, 0x00, 0x00, 0x27, 0x10, 0x0a, 0x3c, 0x10,
- 0x1e, 0x3c, 0x10, 0x28, 0x3c, 0xb1,
-};
-
-void test_convert_tableswitch_bbs2(void)
-{
- struct basic_block *bb0, *bb1, *bb2, *bb3, *bb4, *bb5;
- struct compilation_unit *cu;
-
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = tableswitch2,
- .code_attribute.code_length = ARRAY_SIZE(tableswitch2),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- convert_to_ir(cu);
- assert_int_equals(6, 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);
-
- assert_basic_block_successors((struct basic_block*[]){bb5, bb1}, 2, bb0);
- assert_basic_block_successors((struct basic_block*[]){bb2, bb3, bb4}, 3, bb1);
- assert_basic_block_successors((struct basic_block*[]){bb3}, 1, bb2);
- assert_basic_block_successors((struct basic_block*[]){bb4}, 1, bb3);
- assert_basic_block_successors((struct basic_block*[]){bb5}, 1, bb4);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb5);
-}
-
-/* Test1 for lookupswitch:
- public void lookupswitch()
- {
- int a = 1;
-
- switch(a)
- {
- case 0:
- a = 0;
- case 1:
- a = 1;
- default:
- a = 3;
- }
-
- }
- */
-static unsigned char lookupswitch1[35] = {
- 0x04, 0x3c, 0x1b, 0xab, 0x00, 0x00, 0x00, 0x1d,
- 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x1b, 0x03, 0x3c, 0x04, 0x3c,
- 0x06, 0x3c, 0xb1,
-};
-
-void test_convert_lookupswitch_bbs1(void)
-{
- struct basic_block *bb0, *bb1, *bb2, *bb3, *bb4;
- struct compilation_unit *cu;
-
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = lookupswitch1,
- .code_attribute.code_length = ARRAY_SIZE(lookupswitch1),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- convert_to_ir(cu);
- assert_int_equals(5, 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);
-
- assert_basic_block_successors((struct basic_block*[]){bb4, bb1}, 2, bb0);
- 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}, 1, bb3);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb4);
-}
-
- /* Test2 for lookupswitch:
- void lookupswitch()
- {
- int a = 2;
-
- switch(a) {
- case 1:
- if (a == 2)
- a = 3;
- case 6:
- switch(a) {
- case 1:
- if (a == 2)
- a = 4;
- case 4:
- }
- case 7:
- }
- }
- */
-static unsigned char lookupswitch2[73] = {
- 0x05, 0x3c, 0x1b, 0xab, 0x00, 0x00, 0x00, 0x45,
- 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x06,
- 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x07,
- 0x00, 0x00, 0x00, 0x45, 0x1b, 0x05, 0xa0, 0x00,
- 0x05, 0x06, 0x3c, 0x1b, 0xab, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c,
- 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1c,
- 0xb1,
-};
-
-void test_convert_lookupswitch_bbs2(void)
-{
- struct basic_block *bb0, *bb1, *bb2, *bb3, *bb4, *bb5, *bb6;
- struct compilation_unit *cu;
-
- struct cafebabe_method_info method_info;
- struct vm_method method = {
- .code_attribute.code = lookupswitch2,
- .code_attribute.code_length = ARRAY_SIZE(lookupswitch2),
- .method = &method_info,
- };
-
- memset(&method_info, 0, sizeof(method_info));
-
- cu = compilation_unit_alloc(&method);
-
- analyze_control_flow(cu);
- convert_to_ir(cu);
- assert_int_equals(7, 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);
-
- assert_basic_block_successors((struct basic_block*[]){bb6, bb1}, 2, bb0);
- assert_basic_block_successors((struct basic_block*[]){bb2, bb4, bb6}, 3, bb1);
- assert_basic_block_successors((struct basic_block*[]){bb3, bb4}, 2, bb2);
- assert_basic_block_successors((struct basic_block*[]){bb4}, 1, bb3);
- assert_basic_block_successors((struct basic_block*[]){bb6, bb5}, 2, bb4);
- assert_basic_block_successors((struct basic_block*[]){bb6}, 1, bb5);
- assert_basic_block_successors((struct basic_block*[]){ }, 0, bb6);
-}
diff --git a/test/unit/jit/typeconv-bc-test.c b/test/unit/jit/typeconv-bc-test.c
deleted file mode 100644
index 6c9dc0d2..00000000
--- a/test/unit/jit/typeconv-bc-test.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2005-2006 Pekka Enberg
- */
-
-#include "vm/vm.h"
-#include "jit/expression.h"
-#include "jit/compiler.h"
-#include <libharness.h>
-
-#include "bc-test-utils.h"
-
-static void assert_conversion_mimic_stack(unsigned char opc,
- enum expression_type expr_type,
- enum vm_type from_type,
- enum vm_type to_type)
-{
- unsigned char code[] = { opc };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct expression *conversion_expression;
- struct expression *expression;
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
- expression = temporary_expr(from_type, bb->b_parent);
- stack_push(bb->mimic_stack, expression);
- convert_to_ir(bb->b_parent);
-
- conversion_expression = stack_pop(bb->mimic_stack);
- assert_conv_expr(to_type, expr_type, expression, &conversion_expression->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(conversion_expression);
- __free_simple_bb(bb);
-}
-
-static void assert_truncation_mimic_stack(unsigned char opc,
- enum expression_type expr_type,
- enum vm_type from_type,
- enum vm_type to_type)
-{
- unsigned char code[] = { opc };
- struct vm_method method = {
- .code_attribute.code = code,
- .code_attribute.code_length = ARRAY_SIZE(code),
- };
- struct expression *truncation_expression;
- struct expression *expression;
- struct basic_block *bb;
-
- bb = __alloc_simple_bb(&method);
- expression = temporary_expr(from_type, bb->b_parent);
- stack_push(bb->mimic_stack, expression);
- convert_to_ir(bb->b_parent);
-
- truncation_expression = stack_pop(bb->mimic_stack);
- assert_trunc_expr(to_type, expr_type, expression, &truncation_expression->node);
- assert_true(stack_is_empty(bb->mimic_stack));
-
- expr_put(truncation_expression);
- __free_simple_bb(bb);
-}
-
-void test_convert_int_widening(void)
-{
- assert_conversion_mimic_stack(OPC_I2L, EXPR_CONVERSION, J_INT, J_LONG);
- assert_conversion_mimic_stack(OPC_I2F, EXPR_CONVERSION_TO_FLOAT, J_INT, J_FLOAT);
- assert_conversion_mimic_stack(OPC_I2D, EXPR_CONVERSION_TO_DOUBLE, J_INT, J_DOUBLE);
-}
-
-void test_convert_long_conversion(void)
-{
- assert_conversion_mimic_stack(OPC_L2I, EXPR_CONVERSION, J_LONG, J_INT);
- assert_conversion_mimic_stack(OPC_L2F, EXPR_CONVERSION_TO_FLOAT, J_LONG, J_FLOAT);
- assert_conversion_mimic_stack(OPC_L2D, EXPR_CONVERSION_TO_DOUBLE, J_LONG, J_DOUBLE);
-}
-
-void test_convert_float_conversion(void)
-{
- assert_conversion_mimic_stack(OPC_F2I, EXPR_CONVERSION_FROM_FLOAT, J_FLOAT, J_INT);
- assert_conversion_mimic_stack(OPC_F2L, EXPR_CONVERSION_FROM_FLOAT, J_FLOAT, J_LONG);
- assert_conversion_mimic_stack(OPC_F2D, EXPR_CONVERSION_FLOAT_TO_DOUBLE, J_FLOAT, J_DOUBLE);
-}
-
-void test_convert_double_conversion(void)
-{
- assert_conversion_mimic_stack(OPC_D2I, EXPR_CONVERSION_FROM_DOUBLE, J_DOUBLE, J_INT);
- assert_conversion_mimic_stack(OPC_D2L, EXPR_CONVERSION_FROM_DOUBLE, J_DOUBLE, J_LONG);
- assert_conversion_mimic_stack(OPC_D2F, EXPR_CONVERSION_DOUBLE_TO_FLOAT, J_DOUBLE, J_FLOAT);
-}
-
-void test_convert_int_narrowing(void)
-{
- assert_truncation_mimic_stack(OPC_I2B, EXPR_TRUNCATION, J_INT, J_BYTE);
- assert_truncation_mimic_stack(OPC_I2C, EXPR_TRUNCATION, J_INT, J_CHAR);
- assert_truncation_mimic_stack(OPC_I2S, EXPR_TRUNCATION, J_INT, J_SHORT);
-}