mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +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)/finder.cpp \
|
||||||
$(src)/machine.cpp \
|
$(src)/machine.cpp \
|
||||||
$(src)/util.cpp \
|
$(src)/util.cpp \
|
||||||
$(src)/heap.cpp \
|
$(src)/heap/heap.cpp \
|
||||||
$(src)/$(process).cpp \
|
$(src)/$(process).cpp \
|
||||||
$(src)/classpath-$(classpath).cpp \
|
$(src)/classpath-$(classpath).cpp \
|
||||||
$(src)/builtin.cpp \
|
$(src)/builtin.cpp \
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
There is NO WARRANTY for this software. See license.txt for
|
There is NO WARRANTY for this software. See license.txt for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include "heap.h"
|
#include "heap/heap.h"
|
||||||
#include "heapwalk.h"
|
#include "heapwalk.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "machine.h"
|
#include "machine.h"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
There is NO WARRANTY for this software. See license.txt for
|
There is NO WARRANTY for this software. See license.txt for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
#include "heap.h"
|
#include "heap/heap.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "arch.h"
|
#include "arch.h"
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "heap.h"
|
#include "heap/heap.h"
|
||||||
#include "finder.h"
|
#include "finder.h"
|
||||||
#include "processor.h"
|
#include "processor.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "heap.h"
|
#include "heap/heap.h"
|
||||||
#include "bootimage.h"
|
#include "bootimage.h"
|
||||||
#include "heapwalk.h"
|
#include "heapwalk.h"
|
||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
|
@ -11,27 +11,86 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "heap/heap.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "target.h"
|
||||||
|
|
||||||
#include "codegen/assembler.h"
|
#include "codegen/assembler.h"
|
||||||
#include "codegen/targets.h"
|
#include "codegen/targets.h"
|
||||||
|
#include "codegen/lir.h"
|
||||||
|
|
||||||
#include "test-harness.h"
|
#include "test-harness.h"
|
||||||
|
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace avian::codegen;
|
using namespace avian::codegen;
|
||||||
using namespace vm;
|
using namespace vm;
|
||||||
|
|
||||||
class BasicAssemblerTest : public Test {
|
class BasicEnv {
|
||||||
public:
|
public:
|
||||||
BasicAssemblerTest():
|
System* s;
|
||||||
Test("BasicAssemblerTest")
|
Heap* heap;
|
||||||
{}
|
Assembler::Architecture* arch;
|
||||||
|
|
||||||
virtual void run() {
|
BasicEnv():
|
||||||
System* s = makeSystem(0);
|
s(makeSystem(0)),
|
||||||
Assembler::Architecture* arch = makeArchitectureNative(s, true);
|
heap(makeHeap(s, 32 * 1024)),
|
||||||
|
arch(makeArchitectureNative(s, true))
|
||||||
|
{
|
||||||
|
arch->acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
~BasicEnv() {
|
||||||
arch->release();
|
arch->release();
|
||||||
s->dispose();
|
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;
|
} 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");
|
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 failures;
|
||||||
int runs;
|
int runs;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template<class T>
|
template<class T>
|
||||||
void assertEquals(T expected, T actual) {
|
void assertEqual(T expected, T actual) {
|
||||||
if(expected != actual) {
|
if(expected != actual) {
|
||||||
fprintf(stderr, "assertion failure, expected: ");
|
fprintf(stderr, "assertion failure, expected: ");
|
||||||
print(expected);
|
print(expected);
|
||||||
@ -44,8 +52,25 @@ protected:
|
|||||||
runs++;
|
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) {
|
void assertTrue(bool value) {
|
||||||
assertEquals(true, value);
|
assertEqual(true, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertFalse(bool value) {
|
||||||
|
assertEqual(false, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user