mirror of
https://github.com/corda/corda.git
synced 2025-06-05 17:01:45 +00:00
various bugfixes
This commit is contained in:
parent
f698c24ea6
commit
a8a030140c
@ -40,7 +40,7 @@ codeMapSize(unsigned codeSize)
|
|||||||
object
|
object
|
||||||
makeCodeImage(Thread* t, BootImage* image, uint8_t* code, unsigned capacity)
|
makeCodeImage(Thread* t, BootImage* image, uint8_t* code, unsigned capacity)
|
||||||
{
|
{
|
||||||
unsigned size;
|
unsigned size = 0;
|
||||||
t->m->processor->compileThunks(t, image, code, &size, capacity);
|
t->m->processor->compileThunks(t, image, code, &size, capacity);
|
||||||
|
|
||||||
Zone zone(t->m->system, t->m->heap, 64 * 1024);
|
Zone zone(t->m->system, t->m->heap, 64 * 1024);
|
||||||
@ -56,15 +56,18 @@ makeCodeImage(Thread* t, BootImage* image, uint8_t* code, unsigned capacity)
|
|||||||
const char* name = it.next(&nameSize);
|
const char* name = it.next(&nameSize);
|
||||||
|
|
||||||
if (endsWith(".class", name, nameSize)) {
|
if (endsWith(".class", name, nameSize)) {
|
||||||
|
fprintf(stderr, "%.*s\n", nameSize - 6, name);
|
||||||
object c = resolveClass
|
object c = resolveClass
|
||||||
(t, makeByteArray(t, "%*s", nameSize - 5, name));
|
(t, makeByteArray(t, "%.*s", nameSize - 6, name));
|
||||||
PROTECT(t, c);
|
PROTECT(t, c);
|
||||||
|
|
||||||
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, c)); ++i) {
|
if (classMethodTable(t, c)) {
|
||||||
object method = arrayBody(t, classMethodTable(t, c), i);
|
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, c)); ++i) {
|
||||||
if (methodCode(t, method)) {
|
object method = arrayBody(t, classMethodTable(t, c), i);
|
||||||
t->m->processor->compileMethod
|
if (methodCode(t, method)) {
|
||||||
(t, &zone, code, &size, capacity, &constants, &calls, method);
|
t->m->processor->compileMethod
|
||||||
|
(t, &zone, code, &size, capacity, &constants, &calls, method);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,13 +117,14 @@ makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
|||||||
position(0), capacity(capacity)
|
position(0), capacity(capacity)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void visit(object p, unsigned number) {
|
void visit(unsigned number) {
|
||||||
if (currentObject) {
|
if (currentObject) {
|
||||||
markBit(map, (currentObject - heap) + currentOffset);
|
unsigned index = currentObject - 1 + currentOffset;
|
||||||
currentObject[currentOffset] = number;
|
markBit(map, index);
|
||||||
|
heap[index] = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentObject = reinterpret_cast<uintptr_t*>(p);
|
currentObject = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void root() {
|
virtual void root() {
|
||||||
@ -137,7 +141,7 @@ makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
|||||||
unsigned number = position + 1;
|
unsigned number = position + 1;
|
||||||
position += size;
|
position += size;
|
||||||
|
|
||||||
visit(p, number);
|
visit(number);
|
||||||
|
|
||||||
return number;
|
return number;
|
||||||
} else {
|
} else {
|
||||||
@ -146,7 +150,7 @@ makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void visitOld(object, unsigned number) {
|
virtual void visitOld(object, unsigned number) {
|
||||||
visit(0, number);
|
visit(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void push(unsigned offset) {
|
virtual void push(unsigned offset) {
|
||||||
@ -158,7 +162,7 @@ makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Thread* t;
|
Thread* t;
|
||||||
uintptr_t* currentObject;
|
unsigned currentObject;
|
||||||
unsigned currentOffset;
|
unsigned currentOffset;
|
||||||
uintptr_t* heap;
|
uintptr_t* heap;
|
||||||
uintptr_t* map;
|
uintptr_t* map;
|
||||||
@ -200,7 +204,7 @@ offset(object a, uintptr_t* b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
writeBootImage(Thread* t, FILE* out)
|
writeBootImage(Thread* t, FILE*)
|
||||||
{
|
{
|
||||||
BootImage image;
|
BootImage image;
|
||||||
|
|
||||||
@ -228,13 +232,15 @@ writeBootImage(Thread* t, FILE* out)
|
|||||||
|
|
||||||
image.magic = BootImage::Magic;
|
image.magic = BootImage::Magic;
|
||||||
|
|
||||||
fwrite(&image, sizeof(BootImage), 1, out);
|
fprintf(stderr, "heap size %d code size %d\n",
|
||||||
|
image.heapSize, image.codeSize);
|
||||||
|
// fwrite(&image, sizeof(BootImage), 1, out);
|
||||||
|
|
||||||
fwrite(heapMap, pad(heapMapSize(image.heapSize)), 1, out);
|
// fwrite(heapMap, pad(heapMapSize(image.heapSize)), 1, out);
|
||||||
fwrite(heap, pad(image.heapSize), 1, out);
|
// fwrite(heap, pad(image.heapSize), 1, out);
|
||||||
|
|
||||||
fwrite(codeMap, pad(codeMapSize(image.codeSize)), 1, out);
|
// fwrite(codeMap, pad(codeMapSize(image.codeSize)), 1, out);
|
||||||
fwrite(code, pad(image.codeSize), 1, out);
|
// fwrite(code, pad(image.codeSize), 1, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -249,7 +255,7 @@ main(int ac, const char** av)
|
|||||||
|
|
||||||
System* s = makeSystem(0);
|
System* s = makeSystem(0);
|
||||||
Heap* h = makeHeap(s, 128 * 1024 * 1024);
|
Heap* h = makeHeap(s, 128 * 1024 * 1024);
|
||||||
Finder* f = makeFinder(s, av[0], 0);
|
Finder* f = makeFinder(s, av[1], 0);
|
||||||
Processor* p = makeProcessor(s, h);
|
Processor* p = makeProcessor(s, h);
|
||||||
Machine* m = new (h->allocate(sizeof(Machine))) Machine(s, h, f, p, 0, 0);
|
Machine* m = new (h->allocate(sizeof(Machine))) Machine(s, h, f, p, 0, 0);
|
||||||
Thread* t = p->makeThread(m, 0, 0);
|
Thread* t = p->makeThread(m, 0, 0);
|
||||||
|
@ -4725,6 +4725,7 @@ class MyProcessor: public Processor {
|
|||||||
callTableSize(0),
|
callTableSize(0),
|
||||||
methodTree(0),
|
methodTree(0),
|
||||||
methodTreeSentinal(0),
|
methodTreeSentinal(0),
|
||||||
|
objectPools(0),
|
||||||
codeAllocator(s),
|
codeAllocator(s),
|
||||||
codeZone(s, &codeAllocator, 64 * 1024)
|
codeZone(s, &codeAllocator, 64 * 1024)
|
||||||
{ }
|
{ }
|
||||||
@ -5130,13 +5131,6 @@ compileThunks(MyThread* t, Allocator* allocator, MyProcessor* p,
|
|||||||
|
|
||||||
Assembler::Register result(a->returnLow());
|
Assembler::Register result(a->returnLow());
|
||||||
a->apply(Jump, BytesPerWord, RegisterOperand, &result);
|
a->apply(Jump, BytesPerWord, RegisterOperand, &result);
|
||||||
|
|
||||||
void* p = defaultContext.promise.listener->resolve
|
|
||||||
(reinterpret_cast<intptr_t>(voidPointer(compileMethod)));
|
|
||||||
|
|
||||||
if (image) {
|
|
||||||
image->defaultThunk = static_cast<uint8_t*>(p) - imageBase;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkContext nativeContext(t, &zone);
|
ThunkContext nativeContext(t, &zone);
|
||||||
@ -5151,13 +5145,6 @@ compileThunks(MyThread* t, Allocator* allocator, MyProcessor* p,
|
|||||||
popThread(t, a);
|
popThread(t, a);
|
||||||
|
|
||||||
a->apply(Return);
|
a->apply(Return);
|
||||||
|
|
||||||
void* p = nativeContext.promise.listener->resolve
|
|
||||||
(reinterpret_cast<intptr_t>(voidPointer(invokeNative)));
|
|
||||||
|
|
||||||
if (image) {
|
|
||||||
image->nativeThunk = static_cast<uint8_t*>(p) - imageBase;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkContext aioobContext(t, &zone);
|
ThunkContext aioobContext(t, &zone);
|
||||||
@ -5169,13 +5156,6 @@ compileThunks(MyThread* t, Allocator* allocator, MyProcessor* p,
|
|||||||
|
|
||||||
Assembler::Constant proc(&(aioobContext.promise));
|
Assembler::Constant proc(&(aioobContext.promise));
|
||||||
a->apply(LongCall, BytesPerWord, ConstantOperand, &proc);
|
a->apply(LongCall, BytesPerWord, ConstantOperand, &proc);
|
||||||
|
|
||||||
void* p = aioobContext.promise.listener->resolve
|
|
||||||
(reinterpret_cast<intptr_t>(voidPointer(throwArrayIndexOutOfBounds)));
|
|
||||||
|
|
||||||
if (image) {
|
|
||||||
image->aioobThunk = static_cast<uint8_t*>(p) - imageBase;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkContext tableContext(t, &zone);
|
ThunkContext tableContext(t, &zone);
|
||||||
@ -5203,12 +5183,35 @@ compileThunks(MyThread* t, Allocator* allocator, MyProcessor* p,
|
|||||||
p->defaultThunk = finish
|
p->defaultThunk = finish
|
||||||
(t, allocator, defaultContext.context.assembler, "default");
|
(t, allocator, defaultContext.context.assembler, "default");
|
||||||
|
|
||||||
|
{ void* p = defaultContext.promise.listener->resolve
|
||||||
|
(reinterpret_cast<intptr_t>(voidPointer(compileMethod)));
|
||||||
|
if (image) {
|
||||||
|
image->defaultThunk = static_cast<uint8_t*>(p) - imageBase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p->nativeThunk = finish
|
p->nativeThunk = finish
|
||||||
(t, allocator, nativeContext.context.assembler, "native");
|
(t, allocator, nativeContext.context.assembler, "native");
|
||||||
|
|
||||||
|
{ void* p = nativeContext.promise.listener->resolve
|
||||||
|
(reinterpret_cast<intptr_t>(voidPointer(invokeNative)));
|
||||||
|
|
||||||
|
if (image) {
|
||||||
|
image->nativeThunk = static_cast<uint8_t*>(p) - imageBase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p->aioobThunk = finish
|
p->aioobThunk = finish
|
||||||
(t, allocator, aioobContext.context.assembler, "aioob");
|
(t, allocator, aioobContext.context.assembler, "aioob");
|
||||||
|
|
||||||
|
{ void* p = aioobContext.promise.listener->resolve
|
||||||
|
(reinterpret_cast<intptr_t>(voidPointer(throwArrayIndexOutOfBounds)));
|
||||||
|
|
||||||
|
if (image) {
|
||||||
|
image->aioobThunk = static_cast<uint8_t*>(p) - imageBase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p->thunkTable = static_cast<uint8_t*>
|
p->thunkTable = static_cast<uint8_t*>
|
||||||
(allocator->allocate(p->thunkSize * ThunkCount));
|
(allocator->allocate(p->thunkSize * ThunkCount));
|
||||||
|
|
||||||
@ -5291,8 +5294,10 @@ compile(MyThread* t, Allocator* allocator, BootContext* bootContext,
|
|||||||
ACQUIRE(t, t->m->classLock);
|
ACQUIRE(t, t->m->classLock);
|
||||||
|
|
||||||
if (methodCompiled(t, method) == defaultThunk(t)) {
|
if (methodCompiled(t, method) == defaultThunk(t)) {
|
||||||
initClass(t, methodClass(t, method));
|
if (bootContext == 0) {
|
||||||
if (UNLIKELY(t->exception)) return;
|
initClass(t, methodClass(t, method));
|
||||||
|
if (UNLIKELY(t->exception)) return;
|
||||||
|
}
|
||||||
|
|
||||||
if (methodCompiled(t, method) == defaultThunk(t)) {
|
if (methodCompiled(t, method) == defaultThunk(t)) {
|
||||||
object node;
|
object node;
|
||||||
|
@ -79,8 +79,8 @@ class DirectoryElement: public Element {
|
|||||||
public:
|
public:
|
||||||
class Iterator: public Element::Iterator {
|
class Iterator: public Element::Iterator {
|
||||||
public:
|
public:
|
||||||
Iterator(System* s, const char* name):
|
Iterator(System* s, const char* name, unsigned skip):
|
||||||
s(s), directory(0)
|
s(s), name(name), skip(skip), directory(0), last(0), it(0)
|
||||||
{
|
{
|
||||||
if (not s->success(s->open(&directory, name))) {
|
if (not s->success(s->open(&directory, name))) {
|
||||||
directory = 0;
|
directory = 0;
|
||||||
@ -88,14 +88,35 @@ class DirectoryElement: public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* next(unsigned* size) {
|
virtual const char* next(unsigned* size) {
|
||||||
|
if (it) {
|
||||||
|
const char* v = it->next(size);
|
||||||
|
if (v) {
|
||||||
|
return v;
|
||||||
|
} else {
|
||||||
|
it->dispose();
|
||||||
|
it = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last) {
|
||||||
|
s->free(last);
|
||||||
|
}
|
||||||
|
|
||||||
if (directory) {
|
if (directory) {
|
||||||
for (const char* v = directory->next(); v; v = directory->next()) {
|
for (const char* v = directory->next(); v; v = directory->next()) {
|
||||||
if (v[0] != '.') {
|
if (v[0] != '.') {
|
||||||
*size = strlen(v);
|
last = append(s, name, "/", v);
|
||||||
return v;
|
if (s->identify(last) == System::TypeDirectory) {
|
||||||
|
it = new (allocate(s, sizeof(Iterator))) Iterator(s, last, skip);
|
||||||
|
it->name = last;
|
||||||
|
}
|
||||||
|
const char* result = last + skip;
|
||||||
|
*size = strlen(result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +126,11 @@ class DirectoryElement: public Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System* s;
|
System* s;
|
||||||
|
const char* name;
|
||||||
|
unsigned skip;
|
||||||
System::Directory* directory;
|
System::Directory* directory;
|
||||||
|
const char* last;
|
||||||
|
Iterator* it;
|
||||||
};
|
};
|
||||||
|
|
||||||
DirectoryElement(System* s, const char* name):
|
DirectoryElement(System* s, const char* name):
|
||||||
@ -113,7 +138,8 @@ class DirectoryElement: public Element {
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual Element::Iterator* iterator() {
|
virtual Element::Iterator* iterator() {
|
||||||
return new (allocate(s, sizeof(Iterator))) Iterator(s, name);
|
return new (allocate(s, sizeof(Iterator)))
|
||||||
|
Iterator(s, name, strlen(name) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual System::Region* find(const char* name) {
|
virtual System::Region* find(const char* name) {
|
||||||
@ -449,6 +475,8 @@ class JarElement: public Element {
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual Element::Iterator* iterator() {
|
virtual Element::Iterator* iterator() {
|
||||||
|
init();
|
||||||
|
|
||||||
return new (allocate(s, sizeof(Iterator))) Iterator(s, index);
|
return new (allocate(s, sizeof(Iterator))) Iterator(s, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,6 +654,8 @@ class MyIterator: public Finder::IteratorImp {
|
|||||||
if (e) {
|
if (e) {
|
||||||
it = e->iterator();
|
it = e->iterator();
|
||||||
e = e->next;
|
e = e->next;
|
||||||
|
} else {
|
||||||
|
it = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,16 @@ class Finder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hasMore() {
|
bool hasMore() {
|
||||||
|
if (current) return true;
|
||||||
|
current = it->next(¤tSize);
|
||||||
return current != 0;
|
return current != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* next(unsigned* size) {
|
const char* next(unsigned* size) {
|
||||||
if (current) {
|
if (hasMore()) {
|
||||||
const char* v = current;
|
|
||||||
*size = currentSize;
|
*size = currentSize;
|
||||||
current = it->next(¤tSize);
|
const char* v = current;
|
||||||
|
current = 0;
|
||||||
return v;
|
return v;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user