mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
various bugfixes
This commit is contained in:
parent
4e07acb26c
commit
91b9dc7382
1
makefile
1
makefile
@ -51,6 +51,7 @@ interpreter-sources = \
|
|||||||
$(src)/main.cpp
|
$(src)/main.cpp
|
||||||
interpreter-objects = $(call cpp-objects,$(interpreter-sources),$(src))
|
interpreter-objects = $(call cpp-objects,$(interpreter-sources),$(src))
|
||||||
interpreter-cflags = $(slow) $(cflags)
|
interpreter-cflags = $(slow) $(cflags)
|
||||||
|
input = Test
|
||||||
|
|
||||||
generator-headers = \
|
generator-headers = \
|
||||||
$(src)/input.h \
|
$(src)/input.h \
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
#define NO_RETURN __attribute__((noreturn))
|
#define NO_RETURN __attribute__((noreturn))
|
||||||
|
|
||||||
#define LIKELY(v) __builtin_expect((v) != 0, true)
|
#define LIKELY(v) __builtin_expect((v) != 0, true)
|
||||||
#define UNLIKELY(v) __builtin_expect((v) == 0, true)
|
#define UNLIKELY(v) __builtin_expect((v) != 0, false)
|
||||||
|
|
||||||
#define MACRO_XY(X, Y) X##Y
|
#define MACRO_XY(X, Y) X##Y
|
||||||
#define MACRO_MakeNameXY(FX, LINE) MACRO_XY(FX, LINE)
|
#define MACRO_MakeNameXY(FX, LINE) MACRO_XY(FX, LINE)
|
||||||
|
@ -103,10 +103,12 @@ class Segment {
|
|||||||
scale(scale),
|
scale(scale),
|
||||||
child(child)
|
child(child)
|
||||||
{
|
{
|
||||||
|
if (segment) {
|
||||||
assert(segment->context, bitsPerRecord);
|
assert(segment->context, bitsPerRecord);
|
||||||
assert(segment->context, scale);
|
assert(segment->context, scale);
|
||||||
assert(segment->context, powerOfTwo(scale));
|
assert(segment->context, powerOfTwo(scale));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned offset() {
|
unsigned offset() {
|
||||||
unsigned n = segment->capacity;
|
unsigned n = segment->capacity;
|
||||||
|
24
src/main.cpp
24
src/main.cpp
@ -12,6 +12,21 @@ namespace {
|
|||||||
|
|
||||||
class System: public vm::System {
|
class System: public vm::System {
|
||||||
public:
|
public:
|
||||||
|
class Monitor: public vm::System::Monitor {
|
||||||
|
public:
|
||||||
|
Monitor(vm::System* s): s(s) { }
|
||||||
|
|
||||||
|
virtual bool tryAcquire(void*) { return true; }
|
||||||
|
virtual void acquire(void*) { }
|
||||||
|
virtual void release(void*) { }
|
||||||
|
virtual void wait(void*) { }
|
||||||
|
virtual void notify(void*) { }
|
||||||
|
virtual void notifyAll(void*) { }
|
||||||
|
virtual void dispose() { s->free(this); }
|
||||||
|
|
||||||
|
vm::System* s;
|
||||||
|
};
|
||||||
|
|
||||||
System(unsigned limit): limit(limit), count(0) { }
|
System(unsigned limit): limit(limit), count(0) { }
|
||||||
|
|
||||||
virtual bool success(Status s) {
|
virtual bool success(Status s) {
|
||||||
@ -42,8 +57,9 @@ class System: public vm::System {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Status make(Monitor**) {
|
virtual Status make(vm::System::Monitor** m) {
|
||||||
return 1;
|
*m = new (vm::System::allocate(sizeof(Monitor))) Monitor(this);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void abort() {
|
virtual void abort() {
|
||||||
@ -159,7 +175,7 @@ parsePath(vm::System* s, const char* path)
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsigned count = 0;
|
unsigned count = 0;
|
||||||
for (Tokenizer t(path, ':'); t.hasMore();) ++ count;
|
for (Tokenizer t(path, ':'); t.hasMore(); t.next()) ++ count;
|
||||||
|
|
||||||
const char** v = static_cast<const char**>
|
const char** v = static_cast<const char**>
|
||||||
(s->allocate((count + 1) * sizeof(const char*)));
|
(s->allocate((count + 1) * sizeof(const char*)));
|
||||||
@ -204,7 +220,7 @@ void
|
|||||||
usageAndExit(const char* name)
|
usageAndExit(const char* name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [-cp <classpath>] [-hs <maximum heap size>] "
|
fprintf(stderr, "usage: %s [-cp <classpath>] [-hs <maximum heap size>] "
|
||||||
"<class name> [<argument> ...]", name);
|
"<class name> [<argument> ...]\n", name);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace vm {
|
|||||||
|
|
||||||
class System {
|
class System {
|
||||||
public:
|
public:
|
||||||
typedef int Status;
|
typedef intptr_t Status;
|
||||||
|
|
||||||
class Thread {
|
class Thread {
|
||||||
public:
|
public:
|
||||||
|
@ -928,15 +928,11 @@ parse(Input* in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
writeAccessorName(Output* out, Object* member, bool respectHide = false,
|
writeAccessorName(Output* out, Object* member, bool respectHide = false)
|
||||||
bool unsafe = false)
|
|
||||||
{
|
{
|
||||||
const char* owner = typeShortName(memberOwner(member));
|
const char* owner = typeShortName(memberOwner(member));
|
||||||
out->write(owner);
|
out->write(owner);
|
||||||
out->write(capitalize(memberName(member)));
|
out->write(capitalize(memberName(member)));
|
||||||
if (unsafe) {
|
|
||||||
out->write("Unsafe");
|
|
||||||
}
|
|
||||||
if (respectHide and memberHide(member)) {
|
if (respectHide and memberHide(member)) {
|
||||||
out->write("0");
|
out->write("0");
|
||||||
}
|
}
|
||||||
@ -1013,7 +1009,7 @@ writeAccessor(Output* out, Object* member, Object* offset, bool unsafe = false)
|
|||||||
out->write("&");
|
out->write("&");
|
||||||
}
|
}
|
||||||
out->write("\n");
|
out->write("\n");
|
||||||
writeAccessorName(out, member, true, unsafe);
|
writeAccessorName(out, member, true);
|
||||||
if (memberOwner(member)->type == Object::Pod) {
|
if (memberOwner(member)->type == Object::Pod) {
|
||||||
out->write("(");
|
out->write("(");
|
||||||
out->write(capitalize(::typeName(memberOwner(member))));
|
out->write(capitalize(::typeName(memberOwner(member))));
|
||||||
@ -1027,7 +1023,10 @@ writeAccessor(Output* out, Object* member, Object* offset, bool unsafe = false)
|
|||||||
}
|
}
|
||||||
out->write(") {\n");
|
out->write(") {\n");
|
||||||
|
|
||||||
if (not unsafe and memberOwner(member)->type == Object::Type) {
|
if (memberOwner(member)->type == Object::Type) {
|
||||||
|
if (unsafe) {
|
||||||
|
out->write(" assert(t, true);");
|
||||||
|
} else {
|
||||||
out->write(" assert(t, objectClass(o) == 0 or ");
|
out->write(" assert(t, objectClass(o) == 0 or ");
|
||||||
out->write("objectClass(o) == arrayBody(t, t->vm->types, Machine::");
|
out->write("objectClass(o) == arrayBody(t, t->vm->types, Machine::");
|
||||||
out->write(capitalize(::typeName(memberOwner(member))));
|
out->write(capitalize(::typeName(memberOwner(member))));
|
||||||
@ -1041,6 +1040,7 @@ writeAccessor(Output* out, Object* member, Object* offset, bool unsafe = false)
|
|||||||
out->write("Length(t, o));\n");
|
out->write("Length(t, o));\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out->write(" return reinterpret_cast<");
|
out->write(" return reinterpret_cast<");
|
||||||
out->write(typeName);
|
out->write(typeName);
|
||||||
@ -1155,14 +1155,13 @@ writeAccessors(Output* out, Object* declarations)
|
|||||||
switch (m->type) {
|
switch (m->type) {
|
||||||
case Object::Scalar: {
|
case Object::Scalar: {
|
||||||
if (it.padding()) offset = cons(Number::make(it.padding()), offset);
|
if (it.padding()) offset = cons(Number::make(it.padding()), offset);
|
||||||
writeAccessor(out, m, offset);
|
writeAccessor(out, m, offset, memberNoAssert(m));
|
||||||
if (memberNoAssert(m)) writeAccessor(out, m, offset, true);
|
|
||||||
offset = cons(Number::make(it.size()), offset);
|
offset = cons(Number::make(it.size()), offset);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Object::Array: {
|
case Object::Array: {
|
||||||
if (it.padding()) offset = cons(Number::make(it.padding()), offset);
|
if (it.padding()) offset = cons(Number::make(it.padding()), offset);
|
||||||
writeAccessor(out, m, offset);
|
writeAccessor(out, m, offset, memberNoAssert(m));
|
||||||
offset = cons(m, offset);
|
offset = cons(m, offset);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -1489,6 +1488,20 @@ typeCount(Object* declarations)
|
|||||||
void
|
void
|
||||||
writeInitializations(Output* out, Object* declarations)
|
writeInitializations(Output* out, Object* declarations)
|
||||||
{
|
{
|
||||||
|
unsigned count = typeCount(declarations);
|
||||||
|
|
||||||
|
out->write("t->vm->types = allocate(t, pad((");
|
||||||
|
out->write(count);
|
||||||
|
out->write(" * ");
|
||||||
|
out->write(sizeof(void*));
|
||||||
|
out->write(") + 4 + ");
|
||||||
|
out->write(sizeof(void*));
|
||||||
|
out->write("));\n");
|
||||||
|
out->write("objectClass(t->vm->types) = 0;\n");
|
||||||
|
out->write("arrayLength(t, t->vm->types) = ");
|
||||||
|
out->write(count);
|
||||||
|
out->write(";\n");
|
||||||
|
|
||||||
out->write("t->vm->types = makeArray(t, ");
|
out->write("t->vm->types = makeArray(t, ");
|
||||||
out->write(typeCount(declarations));
|
out->write(typeCount(declarations));
|
||||||
out->write(");\n\n");
|
out->write(");\n\n");
|
||||||
|
@ -163,7 +163,7 @@
|
|||||||
(uint64_t value))
|
(uint64_t value))
|
||||||
|
|
||||||
(type array
|
(type array
|
||||||
(array object body))
|
(noassert array object body))
|
||||||
|
|
||||||
(type objectArray
|
(type objectArray
|
||||||
(object elementClass)
|
(object elementClass)
|
||||||
|
@ -511,12 +511,14 @@ object
|
|||||||
makeTrace(Thread* t)
|
makeTrace(Thread* t)
|
||||||
{
|
{
|
||||||
object trace = 0;
|
object trace = 0;
|
||||||
|
if (t->frame) {
|
||||||
PROTECT(t, trace);
|
PROTECT(t, trace);
|
||||||
frameIp(t, t->frame) = t->ip;
|
frameIp(t, t->frame) = t->ip;
|
||||||
for (; t->frame; t->frame = frameNext(t, t->frame)) {
|
for (; t->frame; t->frame = frameNext(t, t->frame)) {
|
||||||
trace = makeTrace
|
trace = makeTrace
|
||||||
(t, frameMethod(t, t->frame), frameIp(t, t->frame), trace);
|
(t, frameMethod(t, t->frame), frameIp(t, t->frame), trace);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return trace;
|
return trace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user