mirror of
https://github.com/corda/corda.git
synced 2025-01-09 14:33:30 +00:00
Merge branch 'wip' of oss.readytalk.com:/var/local/git/avian into wip
This commit is contained in:
commit
993d210232
@ -266,7 +266,7 @@ doAccept(JNIEnv* e, int s)
|
|||||||
int r = ::accept(s, &address, &length);
|
int r = ::accept(s, &address, &length);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
return r;
|
return r;
|
||||||
} else {
|
} else if (errno != EINTR) {
|
||||||
throwIOException(e);
|
throwIOException(e);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -47,7 +47,14 @@ public class ServerSocketChannel extends SelectableChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int doAccept() throws IOException {
|
private int doAccept() throws IOException {
|
||||||
return natDoAccept(channel.socket);
|
while (true) {
|
||||||
|
int s = natDoAccept(channel.socket);
|
||||||
|
if (s != -1) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
// todo: throw ClosedByInterruptException if this thread was
|
||||||
|
// interrupted during the accept call
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int doListen(String host, int port) throws IOException {
|
private int doListen(String host, int port) throws IOException {
|
||||||
|
@ -38,8 +38,6 @@ public class ArrayList<T> extends AbstractList<T> {
|
|||||||
private void shrink() {
|
private void shrink() {
|
||||||
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
||||||
resize(array.length / 2);
|
resize(array.length / 2);
|
||||||
} else if (size == 0) {
|
|
||||||
resize(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,6 @@ public class HashMap<K, V> implements Map<K, V> {
|
|||||||
private void shrink() {
|
private void shrink() {
|
||||||
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
if (array.length / 2 >= MinimumCapacity && size <= array.length / 3) {
|
||||||
resize(array.length / 2);
|
resize(array.length / 2);
|
||||||
} else if (size == 0) {
|
|
||||||
resize(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
makefile
17
makefile
@ -159,6 +159,18 @@ ifeq ($(platform),darwin)
|
|||||||
strip-all = -S -x
|
strip-all = -S -x
|
||||||
so-suffix = .jnilib
|
so-suffix = .jnilib
|
||||||
shared = -dynamiclib
|
shared = -dynamiclib
|
||||||
|
|
||||||
|
ifeq ($(arch),powerpc)
|
||||||
|
cflags += -arch ppc
|
||||||
|
asmflags += -arch ppc
|
||||||
|
lflags += -arch ppc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(arch),i386)
|
||||||
|
cflags += -arch i386
|
||||||
|
asmflags += -arch i386
|
||||||
|
lflags += -arch i386
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(platform),windows)
|
ifeq ($(platform),windows)
|
||||||
@ -228,6 +240,11 @@ ifeq ($(mode),small)
|
|||||||
cflags += -Os -g3 -DNDEBUG
|
cflags += -Os -g3 -DNDEBUG
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(arch),i386)
|
||||||
|
# this is necessary to support __sync_bool_compare_and_swap:
|
||||||
|
cflags += -march=i486
|
||||||
|
endif
|
||||||
|
|
||||||
output = -o $(1)
|
output = -o $(1)
|
||||||
as := $(cc)
|
as := $(cc)
|
||||||
ld := $(cc)
|
ld := $(cc)
|
||||||
|
@ -325,6 +325,14 @@ markBit(uintptr_t* map, unsigned i)
|
|||||||
map[wordOf(i)] |= static_cast<uintptr_t>(1) << bitOf(i);
|
map[wordOf(i)] |= static_cast<uintptr_t>(1) << bitOf(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
markBitAtomic(uintptr_t* map, unsigned i)
|
||||||
|
{
|
||||||
|
uintptr_t* p = map + wordOf(i);
|
||||||
|
uintptr_t v = static_cast<uintptr_t>(1) << bitOf(i);
|
||||||
|
while (not __sync_bool_compare_and_swap(p, *p, *p | v)) { }
|
||||||
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
clearBit(uintptr_t* map, unsigned i)
|
clearBit(uintptr_t* map, unsigned i)
|
||||||
{
|
{
|
||||||
|
77
src/heap.cpp
77
src/heap.cpp
@ -303,6 +303,13 @@ class Segment {
|
|||||||
if (child) child->set(p, v);
|
if (child) child->set(p, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void markAtomic(void* p) {
|
||||||
|
assert(segment->context, bitsPerRecord == 1);
|
||||||
|
markBitAtomic(data, indexOf(p));
|
||||||
|
assert(segment->context, getBit(data, indexOf(p)));
|
||||||
|
if (child) child->markAtomic(p);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned get(void* p) {
|
unsigned get(void* p) {
|
||||||
return getBits(data, bitsPerRecord, indexOf(p));
|
return getBits(data, bitsPerRecord, indexOf(p));
|
||||||
}
|
}
|
||||||
@ -1013,8 +1020,12 @@ void
|
|||||||
markDirty(Context* c, Fixie* f)
|
markDirty(Context* c, Fixie* f)
|
||||||
{
|
{
|
||||||
if (not f->dirty) {
|
if (not f->dirty) {
|
||||||
f->dirty = true;
|
ACQUIRE(c->lock);
|
||||||
f->move(c, &(c->dirtyTenuredFixies));
|
|
||||||
|
if (not f->dirty) {
|
||||||
|
f->dirty = true;
|
||||||
|
f->move(c, &(c->dirtyTenuredFixies));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1784,7 +1795,7 @@ class MyHeap: public Heap {
|
|||||||
Fixie(&c, sizeInWords, objectMask, 0, true))->body();
|
Fixie(&c, sizeInWords, objectMask, 0, true))->body();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool needsMark(void* p) {
|
bool needsMark(void* p) {
|
||||||
assert(&c, c.client->isFixed(p) or (not immortalHeapContains(&c, p)));
|
assert(&c, c.client->isFixed(p) or (not immortalHeapContains(&c, p)));
|
||||||
|
|
||||||
if (c.client->isFixed(p)) {
|
if (c.client->isFixed(p)) {
|
||||||
@ -1794,11 +1805,6 @@ class MyHeap: public Heap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool needsMark(void* p, unsigned offset) {
|
|
||||||
return needsMark(p) and targetNeedsMark
|
|
||||||
(mask(*(static_cast<void**>(p) + offset)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool targetNeedsMark(void* target) {
|
bool targetNeedsMark(void* target) {
|
||||||
return target
|
return target
|
||||||
and not c.gen2.contains(target)
|
and not c.gen2.contains(target)
|
||||||
@ -1809,38 +1815,41 @@ class MyHeap: public Heap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void mark(void* p, unsigned offset, unsigned count) {
|
virtual void mark(void* p, unsigned offset, unsigned count) {
|
||||||
if (c.client->isFixed(p)) {
|
if (needsMark(p)) {
|
||||||
Fixie* f = fixie(p);
|
if (c.client->isFixed(p)) {
|
||||||
assert(&c, offset == 0 or f->hasMask);
|
Fixie* f = fixie(p);
|
||||||
|
assert(&c, offset == 0 or f->hasMask);
|
||||||
|
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
for (unsigned i = 0; i < count; ++i) {
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
void** target = static_cast<void**>(p) + offset + i;
|
void** target = static_cast<void**>(p) + offset + i;
|
||||||
if (targetNeedsMark(mask(*target))) {
|
if (targetNeedsMark(mask(*target))) {
|
||||||
if (DebugFixies) {
|
if (DebugFixies) {
|
||||||
fprintf(stderr, "dirty fixie %p at %d (%p): %p\n",
|
fprintf(stderr, "dirty fixie %p at %d (%p): %p\n",
|
||||||
f, offset, f->body() + offset, mask(*target));
|
f, offset, f->body() + offset, mask(*target));
|
||||||
|
}
|
||||||
|
|
||||||
|
dirty = true;
|
||||||
|
markBitAtomic(f->mask(), offset + i);
|
||||||
|
assert(&c, getBit(f->mask(), offset + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
dirty = true;
|
|
||||||
markBit(f->mask(), offset + i);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (dirty) markDirty(&c, f);
|
if (dirty) markDirty(&c, f);
|
||||||
} else {
|
|
||||||
Segment::Map* map;
|
|
||||||
if (c.gen2.contains(p)) {
|
|
||||||
map = &(c.heapMap);
|
|
||||||
} else {
|
} else {
|
||||||
assert(&c, c.nextGen2.contains(p));
|
Segment::Map* map;
|
||||||
map = &(c.nextHeapMap);
|
if (c.gen2.contains(p)) {
|
||||||
}
|
map = &(c.heapMap);
|
||||||
|
} else {
|
||||||
|
assert(&c, c.nextGen2.contains(p));
|
||||||
|
map = &(c.nextHeapMap);
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < count; ++i) {
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
void** target = static_cast<void**>(p) + offset + i;
|
void** target = static_cast<void**>(p) + offset + i;
|
||||||
if (targetNeedsMark(mask(*target))) {
|
if (targetNeedsMark(mask(*target))) {
|
||||||
map->set(target);
|
map->markAtomic(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,6 @@ class Heap: public Allocator {
|
|||||||
virtual void* allocateImmortalFixed(Allocator* allocator,
|
virtual void* allocateImmortalFixed(Allocator* allocator,
|
||||||
unsigned sizeInWords, bool objectMask,
|
unsigned sizeInWords, bool objectMask,
|
||||||
unsigned* totalInBytes) = 0;
|
unsigned* totalInBytes) = 0;
|
||||||
virtual bool needsMark(void* p) = 0;
|
|
||||||
virtual bool needsMark(void* p, unsigned offset) = 0;
|
|
||||||
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
|
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
|
||||||
virtual void pad(void* p) = 0;
|
virtual void pad(void* p) = 0;
|
||||||
virtual void* follow(void* p) = 0;
|
virtual void* follow(void* p) = 0;
|
||||||
|
@ -195,6 +195,8 @@ GetArrayLength(Thread* t, jarray array)
|
|||||||
jstring JNICALL
|
jstring JNICALL
|
||||||
NewString(Thread* t, const jchar* chars, jsize size)
|
NewString(Thread* t, const jchar* chars, jsize size)
|
||||||
{
|
{
|
||||||
|
if (chars == 0) return 0;
|
||||||
|
|
||||||
ENTER(t, Thread::ActiveState);
|
ENTER(t, Thread::ActiveState);
|
||||||
|
|
||||||
object a = 0;
|
object a = 0;
|
||||||
@ -210,6 +212,8 @@ NewString(Thread* t, const jchar* chars, jsize size)
|
|||||||
jstring JNICALL
|
jstring JNICALL
|
||||||
NewStringUTF(Thread* t, const char* chars)
|
NewStringUTF(Thread* t, const char* chars)
|
||||||
{
|
{
|
||||||
|
if (chars == 0) return 0;
|
||||||
|
|
||||||
ENTER(t, Thread::ActiveState);
|
ENTER(t, Thread::ActiveState);
|
||||||
|
|
||||||
object a = 0;
|
object a = 0;
|
||||||
@ -2169,7 +2173,10 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
System* s = makeSystem(crashDumpDirectory);
|
System* s = makeSystem(crashDumpDirectory);
|
||||||
Heap* h = makeHeap(s, heapLimit);
|
Heap* h = makeHeap(s, heapLimit);
|
||||||
Finder* f = makeFinder(s, RUNTIME_ARRAY_BODY(classpathBuffer), bootLibrary);
|
Finder* f = makeFinder(s, RUNTIME_ARRAY_BODY(classpathBuffer), bootLibrary);
|
||||||
Processor* p = makeProcessor(s, h, true);
|
Processor* p = makeProcessor(s, h, false); // change back to true
|
||||||
|
// once use of SSE is
|
||||||
|
// fixed on 32-bit
|
||||||
|
// systems
|
||||||
|
|
||||||
const char** properties = static_cast<const char**>
|
const char** properties = static_cast<const char**>
|
||||||
(h->allocate(sizeof(const char*) * propertyCount));
|
(h->allocate(sizeof(const char*) * propertyCount));
|
||||||
|
@ -1584,19 +1584,13 @@ allocate(Thread* t, unsigned sizeInBytes, bool objectMask)
|
|||||||
inline void
|
inline void
|
||||||
mark(Thread* t, object o, unsigned offset, unsigned count)
|
mark(Thread* t, object o, unsigned offset, unsigned count)
|
||||||
{
|
{
|
||||||
if (t->m->heap->needsMark(o)) {
|
t->m->heap->mark(o, offset / BytesPerWord, count);
|
||||||
ACQUIRE_RAW(t, t->m->heapLock);
|
|
||||||
t->m->heap->mark(o, offset / BytesPerWord, count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
mark(Thread* t, object o, unsigned offset)
|
mark(Thread* t, object o, unsigned offset)
|
||||||
{
|
{
|
||||||
if (t->m->heap->needsMark(o, offset / BytesPerWord)) {
|
t->m->heap->mark(o, offset / BytesPerWord, 1);
|
||||||
ACQUIRE_RAW(t, t->m->heapLock);
|
|
||||||
t->m->heap->mark(o, offset / BytesPerWord, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -2931,7 +2931,7 @@ class MyArchitecture: public Assembler::Architecture {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Int2Float:
|
case Int2Float:
|
||||||
if (useSSE(&c)) {
|
if (useSSE(&c) and (aSize <= BytesPerWord)) {
|
||||||
*aTypeMask = (1 << RegisterOperand) | (1 << MemoryOperand);
|
*aTypeMask = (1 << RegisterOperand) | (1 << MemoryOperand);
|
||||||
*aRegisterMask = GeneralRegisterMask
|
*aRegisterMask = GeneralRegisterMask
|
||||||
| (static_cast<uint64_t>(GeneralRegisterMask) << 32);
|
| (static_cast<uint64_t>(GeneralRegisterMask) << 32);
|
||||||
|
@ -46,11 +46,13 @@ public class Floats {
|
|||||||
|
|
||||||
expect(subtract(0.5d, 0.1d) == 0.4d);
|
expect(subtract(0.5d, 0.1d) == 0.4d);
|
||||||
|
|
||||||
double d = 1d;
|
{ double d = 1d;
|
||||||
expect(((int) d) == 1);
|
expect(((int) d) == 1);
|
||||||
|
}
|
||||||
|
|
||||||
float f = 1f;
|
{ float f = 1f;
|
||||||
expect(((int) f) == 1);
|
expect(((int) f) == 1);
|
||||||
|
}
|
||||||
|
|
||||||
expect(Math.round(0.4f) == 0);
|
expect(Math.round(0.4f) == 0);
|
||||||
expect(Math.round(0.5f) == 1);
|
expect(Math.round(0.5f) == 1);
|
||||||
@ -62,8 +64,14 @@ public class Floats {
|
|||||||
expect(Math.round(1.0d) == 1);
|
expect(Math.round(1.0d) == 1);
|
||||||
expect(Math.round(1.9d) == 2);
|
expect(Math.round(1.9d) == 2);
|
||||||
|
|
||||||
float b = 1.0f;
|
{ float b = 1.0f;
|
||||||
int blue = (int)(b * 255 + 0.5);
|
int blue = (int)(b * 255 + 0.5);
|
||||||
expect(blue == 255);
|
expect(blue == 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ long z = 6553311036568663L;
|
||||||
|
double d = (double) z;
|
||||||
|
expect(d == 6553311036568663.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user