Merge branch 'master' of oss.readytalk.com:/var/local/git/avian

This commit is contained in:
Joel Dice 2010-07-13 18:03:30 -06:00
commit 71972fd1b5
9 changed files with 628 additions and 239 deletions

@ -87,7 +87,7 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code,
object method = tripleFirst(t, calls);
uintptr_t address;
if (methodFlags(t, method) & ACC_NATIVE) {
address = reinterpret_cast<uintptr_t>(code + image->nativeThunk);
address = reinterpret_cast<uintptr_t>(code + image->thunks.native.start);
} else {
address = methodCompiled(t, method);
}
@ -389,7 +389,7 @@ main(int ac, const char** av)
Processor* p = makeProcessor(s, h, false);
BootImage image;
const unsigned CodeCapacity = 32 * 1024 * 1024;
const unsigned CodeCapacity = 16 * 1024 * 1024;
uint8_t* code = static_cast<uint8_t*>(h->allocate(CodeCapacity));
p->initialize(&image, code, CodeCapacity);

@ -24,6 +24,30 @@ const unsigned BootHeapOffset = 1 << (BootShift + 1);
class BootImage {
public:
class Thunk {
public:
Thunk():
start(0), frameSavedOffset(0), length(0)
{ }
Thunk(unsigned start, unsigned frameSavedOffset, unsigned length):
start(start), frameSavedOffset(frameSavedOffset), length(length)
{ }
unsigned start;
unsigned frameSavedOffset;
unsigned length;
};
class ThunkCollection {
public:
Thunk default_;
Thunk defaultVirtual;
Thunk native;
Thunk aioob;
Thunk table;
};
static const unsigned Magic = 0x22377322;
unsigned magic;
@ -43,13 +67,7 @@ class BootImage {
uintptr_t codeBase;
unsigned defaultThunk;
unsigned defaultVirtualThunk;
unsigned nativeThunk;
unsigned aioobThunk;
unsigned thunkTable;
unsigned thunkSize;
ThunkCollection thunks;
unsigned compileMethodCall;
unsigned compileVirtualMethodCall;

@ -24,11 +24,12 @@
# define GLOBAL(x) x
#endif
#define THREAD_CONTINUATION 112
#define THREAD_STACK 2152
#define THREAD_CONTINUATION 2156
#define THREAD_EXCEPTION 44
#define THREAD_EXCEPTION_STACK_ADJUSTMENT 116
#define THREAD_EXCEPTION_OFFSET 120
#define THREAD_EXCEPTION_HANDLER 124
#define THREAD_EXCEPTION_STACK_ADJUSTMENT 2160
#define THREAD_EXCEPTION_OFFSET 2164
#define THREAD_EXCEPTION_HANDLER 2168
#define CONTINUATION_NEXT 4
#define CONTINUATION_ADDRESS 16
@ -103,9 +104,21 @@ LOCAL(vmInvoke_argumentTest):
mtctr r4
bctrl
LOCAL(vmInvoke_returnAddress):
.globl GLOBAL(vmInvoke_returnAddress)
GLOBAL(vmInvoke_returnAddress):
// restore stack pointer
lwz r1,0(r1)
// clear MyThread::stack to avoid confusing another thread calling
// java.lang.Thread.getStackTrace on this one. See
// MyProcess::getStackTrace in compile.cpp for details on how we get
// a reliable stack trace from a thread that might be interrupted at
// any point in its execution.
li r5,0
stw r5,THREAD_STACK(r13)
.globl GLOBAL(vmInvoke_safeStack)
GLOBAL(vmInvoke_safeStack):
#ifdef AVIAN_CONTINUATIONS
// call the next continuation, if any
@ -138,7 +151,7 @@ LOCAL(vmInvoke_continuationTest):
LOCAL(vmInvoke_getPC):
mflr r10
la r10,lo16(LOCAL(vmInvoke_returnAddress)-LOCAL(vmInvoke_getPC))(r10)
la r10,lo16(GLOBAL(vmInvoke_returnAddress)-LOCAL(vmInvoke_getPC))(r10)
stwx r10,r1,r7
lwz r7,CONTINUATION_FRAME_POINTER_OFFSET(r5)
@ -271,7 +284,7 @@ LOCAL(vmJumpAndInvoke_argumentTest):
LOCAL(vmJumpAndInvoke_getPC):
mflr r10
la r10,lo16(LOCAL(vmInvoke_returnAddress)-LOCAL(vmJumpAndInvoke_getPC))(r10)
la r10,lo16(GLOBAL(vmInvoke_returnAddress)-LOCAL(vmJumpAndInvoke_getPC))(r10)
mtlr r10
mtctr r4

@ -22,6 +22,8 @@
#ifdef __x86_64__
#define THREAD_STACK 2216
#if defined __MINGW32__ || defined __CYGWIN32__
#define CALLEE_SAVED_REGISTER_FOOTPRINT 64
@ -79,6 +81,16 @@ GLOBAL(vmInvoke_returnAddress):
// restore stack pointer
movq %rbp,%rsp
// clear MyThread::stack to avoid confusing another thread calling
// java.lang.Thread.getStackTrace on this one. See
// MyProcess::getStackTrace in compile.cpp for details on how we get
// a reliable stack trace from a thread that might be interrupted at
// any point in its execution.
movq $0,THREAD_STACK(%rbx)
.globl GLOBAL(vmInvoke_safeStack)
GLOBAL(vmInvoke_safeStack):
#ifdef AVIAN_CONTINUATIONS
# include "continuations-x86.S"
#endif // AVIAN_CONTINUATIONS
@ -207,6 +219,16 @@ LOCAL(vmInvoke_argumentTest):
GLOBAL(vmInvoke_returnAddress):
// restore stack pointer
movq %rbp,%rsp
// clear MyThread::stack to avoid confusing another thread calling
// java.lang.Thread.getStackTrace on this one. See
// MyProcess::getStackTrace in compile.cpp for details on how we get
// a reliable stack trace from a thread that might be interrupted at
// any point in its execution.
movq $0,THREAD_STACK(%rbx)
.globl GLOBAL(vmInvoke_safeStack)
GLOBAL(vmInvoke_safeStack):
#ifdef AVIAN_CONTINUATIONS
# include "continuations-x86.S"
@ -283,6 +305,8 @@ LOCAL(vmJumpAndInvoke_argumentTest):
#elif defined __i386__
#define THREAD_STACK 2144
#define CALLEE_SAVED_REGISTER_FOOTPRINT 16
.globl GLOBAL(vmInvoke)
@ -329,13 +353,23 @@ LOCAL(vmInvoke_argumentTest):
// call function
call *12(%ebp)
.globl vmInvoke_returnAddress
vmInvoke_returnAddress:
.globl GLOBAL(vmInvoke_returnAddress)
GLOBAL(vmInvoke_returnAddress):
// restore stack pointer, preserving the area containing saved
// registers
movl %ebp,%ecx
subl $CALLEE_SAVED_REGISTER_FOOTPRINT,%ecx
movl %ecx,%esp
// clear MyThread::stack to avoid confusing another thread calling
// java.lang.Thread.getStackTrace on this one. See
// MyProcess::getStackTrace in compile.cpp for details on how we get
// a reliable stack trace from a thread that might be interrupted at
// any point in its execution.
movl $0,THREAD_STACK(%ebx)
.globl GLOBAL(vmInvoke_safeStack)
GLOBAL(vmInvoke_safeStack):
#ifdef AVIAN_CONTINUATIONS
# include "continuations-x86.S"
@ -397,15 +431,15 @@ GLOBAL(vmJumpAndInvoke):
// set return address
#if defined __MINGW32__ || defined __CYGWIN32__
movl $vmInvoke_returnAddress,%esi
movl $GLOBAL(vmInvoke_returnAddress),%esi
#else
call LOCAL(getPC)
# if defined __APPLE__
LOCAL(vmJumpAndInvoke_offset):
leal vmInvoke_returnAddress-LOCAL(vmJumpAndInvoke_offset)(%esi),%esi
leal GLOBAL(vmInvoke_returnAddress)-LOCAL(vmJumpAndInvoke_offset)(%esi),%esi
# else
addl $_GLOBAL_OFFSET_TABLE_,%esi
movl vmInvoke_returnAddress@GOT(%esi),%esi
movl GLOBAL(vmInvoke_returnAddress)@GOT(%esi),%esi
# endif
#endif
movl %esi,(%ecx)

File diff suppressed because it is too large Load Diff

@ -10,11 +10,11 @@
#ifdef __x86_64__
#define THREAD_CONTINUATION 192
#define THREAD_CONTINUATION 2224
#define THREAD_EXCEPTION 80
#define THREAD_EXCEPTION_STACK_ADJUSTMENT 200
#define THREAD_EXCEPTION_OFFSET 208
#define THREAD_EXCEPTION_HANDLER 216
#define THREAD_EXCEPTION_STACK_ADJUSTMENT 2232
#define THREAD_EXCEPTION_OFFSET 2240
#define THREAD_EXCEPTION_HANDLER 2248
#define CONTINUATION_NEXT 8
#define CONTINUATION_ADDRESS 32
@ -89,11 +89,11 @@ LOCAL(vmInvoke_exit):
#elif defined __i386__
#define THREAD_CONTINUATION 108
#define THREAD_CONTINUATION 2148
#define THREAD_EXCEPTION 44
#define THREAD_EXCEPTION_STACK_ADJUSTMENT 112
#define THREAD_EXCEPTION_OFFSET 116
#define THREAD_EXCEPTION_HANDLER 120
#define THREAD_EXCEPTION_STACK_ADJUSTMENT 2152
#define THREAD_EXCEPTION_OFFSET 2156
#define THREAD_EXCEPTION_HANDLER 2160
#define CONTINUATION_NEXT 4
#define CONTINUATION_ADDRESS 16
@ -138,15 +138,15 @@ LOCAL(vmInvoke_continuationTest):
// set the return address to vmInvoke_returnAddress
movl CONTINUATION_RETURN_ADDRESS_OFFSET(%ecx),%edi
#if defined __MINGW32__ || defined __CYGWIN32__
movl $vmInvoke_returnAddress,%esi
movl $GLOBAL(vmInvoke_returnAddress),%esi
#else
call LOCAL(getPC)
# if defined __APPLE__
LOCAL(vmInvoke_offset):
leal vmInvoke_returnAddress-LOCAL(vmInvoke_offset)(%esi),%esi
leal GLOBAL(vmInvoke_returnAddress)-LOCAL(vmInvoke_offset)(%esi),%esi
# else
addl $_GLOBAL_OFFSET_TABLE_,%esi
movl vmInvoke_returnAddress@GOT(%esi),%esi
movl GLOBAL(vmInvoke_returnAddress)@GOT(%esi),%esi
# endif
#endif
movl %esi,(%esp,%edi,1)

@ -570,12 +570,11 @@ postCollect(Thread* t)
t->heapOffset = 0;
t->heapIndex = 0;
if (t->backupHeap) {
t->m->heap->free
(t->backupHeap, t->backupHeapSizeInWords * BytesPerWord);
t->backupHeap = 0;
if (t->useBackupHeap) {
memset(t->backupHeap, 0, ThreadBackupHeapSizeInBytes);
t->useBackupHeap = false;
t->backupHeapIndex = 0;
t->backupHeapSizeInWords = 0;
}
for (Thread* c = t->child; c; c = c->peer) {
@ -1978,7 +1977,6 @@ boot(Thread* t)
m->bootstrapClassMap = makeHashMap(t, 0, 0);
m->stringMap = makeWeakHashMap(t, 0, 0);
m->processor->boot(t, 0);
{ object bootCode = makeCode(t, 0, 0, 0, 0, 0, 1);
@ -2123,6 +2121,8 @@ Machine::Machine(System* system, Heap* heap, Finder* finder,
tenuredWeakReferences(0),
shutdownHooks(0),
objectsToFinalize(0),
nullPointerException(0),
arrayIndexOutOfBoundsException(0),
unsafe(false),
triedBuiltinOnLoad(false),
heapPoolIndex(0)
@ -2196,9 +2196,8 @@ Thread::Thread(Machine* m, object javaThread, Thread* parent):
defaultHeap(static_cast<uintptr_t*>
(m->heap->allocate(ThreadHeapSizeInBytes))),
heap(defaultHeap),
backupHeap(0),
backupHeapIndex(0),
backupHeapSizeInWords(0),
useBackupHeap(false),
waiting(false),
tracing(false)
#ifdef VM_STRESS
@ -2210,6 +2209,7 @@ void
Thread::init()
{
memset(defaultHeap, 0, ThreadHeapSizeInBytes);
memset(backupHeap, 0, ThreadBackupHeapSizeInBytes);
if (parent == 0) {
assert(this, m->rootThread == 0);
@ -2248,6 +2248,11 @@ Thread::init()
m->jniMethodTable = makeVector(this, 0, 0);
m->nullPointerException = makeNullPointerException(this);
m->arrayIndexOutOfBoundsException
= makeArrayIndexOutOfBoundsException(this, 0);
m->localThread->set(this);
} else {
peer = parent->child;
@ -2539,15 +2544,15 @@ object
allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
unsigned sizeInBytes, bool objectMask)
{
if (t->backupHeap) {
if (UNLIKELY(t->useBackupHeap)) {
expect(t, t->backupHeapIndex + ceiling(sizeInBytes, BytesPerWord)
<= t->backupHeapSizeInWords);
<= ThreadBackupHeapSizeInWords);
object o = reinterpret_cast<object>(t->backupHeap + t->backupHeapIndex);
t->backupHeapIndex += ceiling(sizeInBytes, BytesPerWord);
cast<object>(o, 0) = 0;
return o;
} else if (t->tracing) {
} else if (UNLIKELY(t->tracing)) {
expect(t, t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
<= ThreadHeapSizeInWords);
return allocateSmall(t, sizeInBytes);
@ -3676,6 +3681,8 @@ visitRoots(Machine* m, Heap::Visitor* v)
v->visit(&(m->jniMethodTable));
v->visit(&(m->shutdownHooks));
v->visit(&(m->objectsToFinalize));
v->visit(&(m->nullPointerException));
v->visit(&(m->arrayIndexOutOfBoundsException));
for (Thread* t = m->rootThread; t; t = t->peer) {
::visitRoots(t, v);

@ -49,6 +49,10 @@ const uintptr_t FixedMark = 3;
const unsigned ThreadHeapSizeInBytes = 64 * 1024;
const unsigned ThreadHeapSizeInWords = ThreadHeapSizeInBytes / BytesPerWord;
const unsigned ThreadBackupHeapSizeInBytes = 2 * 1024;
const unsigned ThreadBackupHeapSizeInWords
= ThreadBackupHeapSizeInBytes / BytesPerWord;
const unsigned ThreadHeapPoolSize = 64;
const unsigned FixedFootprintThresholdInBytes
@ -1207,6 +1211,8 @@ class Machine {
object tenuredWeakReferences;
object shutdownHooks;
object objectsToFinalize;
object nullPointerException;
object arrayIndexOutOfBoundsException;
bool unsafe;
bool triedBuiltinOnLoad;
JavaVMVTable javaVMVTable;
@ -1360,9 +1366,9 @@ class Thread {
Runnable runnable;
uintptr_t* defaultHeap;
uintptr_t* heap;
uintptr_t* backupHeap;
uintptr_t backupHeap[ThreadBackupHeapSizeInWords];
unsigned backupHeapIndex;
unsigned backupHeapSizeInWords;
bool useBackupHeap;
bool waiting;
bool tracing;
#ifdef VM_STRESS
@ -1550,20 +1556,23 @@ class FixedAllocator: public Allocator {
unsigned capacity;
};
inline void
inline bool
ensure(Thread* t, unsigned sizeInBytes)
{
if (t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
> ThreadHeapSizeInWords)
{
expect(t, t->backupHeap == 0);
t->backupHeap = static_cast<uintptr_t*>
(t->m->heap->allocate(pad(sizeInBytes)));
if (sizeInBytes <= ThreadBackupHeapSizeInBytes) {
expect(t, not t->useBackupHeap);
memset(t->backupHeap, 0, sizeInBytes);
t->useBackupHeap = true;
t->backupHeapIndex = 0;
t->backupHeapSizeInWords = ceiling(sizeInBytes, BytesPerWord);
return true;
} else {
return false;
}
} else {
return true;
}
}

@ -2421,7 +2421,7 @@ class MyAssembler: public Assembler {
for (ConstantPoolEntry* e = c.constantPool; e; e = e->next) {
*static_cast<uint32_t*>(e->address) = e->constant->value();
fprintf(stderr, "constant %p at %p\n", reinterpret_cast<void*>(e->constant->value()), e->address);
// fprintf(stderr, "constant %p at %p\n", reinterpret_cast<void*>(e->constant->value()), e->address);
}
}