mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
add ArchitecturePlanTest
This commit is contained in:
parent
33d245d0f7
commit
a3fb540ec3
2
makefile
2
makefile
@ -936,7 +936,7 @@ vm-sources = \
|
||||
$(src)/finder.cpp \
|
||||
$(src)/machine.cpp \
|
||||
$(src)/util.cpp \
|
||||
$(src)/heap.cpp \
|
||||
$(src)/heap/heap.cpp \
|
||||
$(src)/$(process).cpp \
|
||||
$(src)/classpath-$(classpath).cpp \
|
||||
$(src)/builtin.cpp \
|
||||
|
@ -8,7 +8,7 @@
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
#include "heap.h"
|
||||
#include "heap/heap.h"
|
||||
#include "heapwalk.h"
|
||||
#include "common.h"
|
||||
#include "machine.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
#include "heap.h"
|
||||
#include "heap/heap.h"
|
||||
#include "system.h"
|
||||
#include "common.h"
|
||||
#include "arch.h"
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "system.h"
|
||||
#include "heap.h"
|
||||
#include "heap/heap.h"
|
||||
#include "finder.h"
|
||||
#include "processor.h"
|
||||
#include "constants.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "system.h"
|
||||
#include "heap.h"
|
||||
#include "heap/heap.h"
|
||||
#include "bootimage.h"
|
||||
#include "heapwalk.h"
|
||||
#include "zone.h"
|
||||
|
@ -11,27 +11,86 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "heap/heap.h"
|
||||
#include "system.h"
|
||||
#include "target.h"
|
||||
|
||||
#include "codegen/assembler.h"
|
||||
#include "codegen/targets.h"
|
||||
#include "codegen/lir.h"
|
||||
|
||||
#include "test-harness.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
|
||||
using namespace avian::codegen;
|
||||
using namespace vm;
|
||||
|
||||
class BasicAssemblerTest : public Test {
|
||||
class BasicEnv {
|
||||
public:
|
||||
BasicAssemblerTest():
|
||||
Test("BasicAssemblerTest")
|
||||
{}
|
||||
System* s;
|
||||
Heap* heap;
|
||||
Assembler::Architecture* arch;
|
||||
|
||||
virtual void run() {
|
||||
System* s = makeSystem(0);
|
||||
Assembler::Architecture* arch = makeArchitectureNative(s, true);
|
||||
BasicEnv():
|
||||
s(makeSystem(0)),
|
||||
heap(makeHeap(s, 32 * 1024)),
|
||||
arch(makeArchitectureNative(s, true))
|
||||
{
|
||||
arch->acquire();
|
||||
}
|
||||
|
||||
~BasicEnv() {
|
||||
arch->release();
|
||||
s->dispose();
|
||||
}
|
||||
};
|
||||
|
||||
class Asm {
|
||||
public:
|
||||
Zone zone;
|
||||
Assembler* a;
|
||||
|
||||
Asm(BasicEnv& env):
|
||||
zone(env.s, env.heap, 8192),
|
||||
a(env.arch->makeAssembler(env.heap, &zone))
|
||||
{ }
|
||||
|
||||
~Asm() {
|
||||
a->dispose();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class BasicAssemblerTest : public Test {
|
||||
public:
|
||||
BasicAssemblerTest():
|
||||
Test("BasicAssembler")
|
||||
{}
|
||||
|
||||
virtual void run() {
|
||||
BasicEnv env;
|
||||
Asm a(env);
|
||||
}
|
||||
} basicAssemblerTest;
|
||||
|
||||
class ArchitecturePlanTest : public Test {
|
||||
public:
|
||||
ArchitecturePlanTest():
|
||||
Test("ArchitecturePlan")
|
||||
{}
|
||||
|
||||
virtual void run() {
|
||||
BasicEnv env;
|
||||
|
||||
for(int op = (int)lir::Call; op < (int)lir::AlignedJump; op++) {
|
||||
bool thunk;
|
||||
uint8_t typeMask;
|
||||
uint64_t registerMask;
|
||||
env.arch->plan((lir::UnaryOperation)op, vm::TargetBytesPerWord, &typeMask, ®isterMask, &thunk);
|
||||
assertFalse(thunk);
|
||||
assertNotEqual(static_cast<uint8_t>(0), typeMask);
|
||||
assertNotEqual(static_cast<uint64_t>(0), registerMask);
|
||||
}
|
||||
|
||||
}
|
||||
} architecturePlanTest;
|
||||
|
@ -27,12 +27,20 @@ private:
|
||||
fprintf(stderr, "%s", value ? "true" : "false");
|
||||
}
|
||||
|
||||
void print(uint8_t value) {
|
||||
fprintf(stderr, "0x%02x", value);
|
||||
}
|
||||
|
||||
void print(uint64_t value) {
|
||||
fprintf(stderr, "0x%" LLD, value);
|
||||
}
|
||||
|
||||
int failures;
|
||||
int runs;
|
||||
|
||||
protected:
|
||||
template<class T>
|
||||
void assertEquals(T expected, T actual) {
|
||||
void assertEqual(T expected, T actual) {
|
||||
if(expected != actual) {
|
||||
fprintf(stderr, "assertion failure, expected: ");
|
||||
print(expected);
|
||||
@ -43,9 +51,26 @@ protected:
|
||||
}
|
||||
runs++;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void assertNotEqual(T expected, T actual) {
|
||||
if(expected == actual) {
|
||||
fprintf(stderr, "assertion failure, expected: not ");
|
||||
print(expected);
|
||||
fprintf(stderr, ", actual: ");
|
||||
print(actual);
|
||||
fprintf(stderr, "\n");
|
||||
failures++;
|
||||
}
|
||||
runs++;
|
||||
}
|
||||
|
||||
void assertTrue(bool value) {
|
||||
assertEquals(true, value);
|
||||
assertEqual(true, value);
|
||||
}
|
||||
|
||||
void assertFalse(bool value) {
|
||||
assertEqual(false, value);
|
||||
}
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user