diff --git a/makefile b/makefile index 6e5f439d2f..e97c24905d 100755 --- a/makefile +++ b/makefile @@ -192,6 +192,8 @@ common-cflags = $(warnings) -fno-rtti -fno-exceptions \ -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \ -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" $(target-cflags) +asmflags = $(target-cflags) + ifneq (,$(filter i386 x86_64,$(arch))) ifeq ($(use-frame-pointer),true) common-cflags += -fno-omit-frame-pointer -DAVIAN_USE_FRAME_POINTER diff --git a/src/compile-arm.S b/src/compile-arm.S index 2dedb94af8..427378c1f8 100644 --- a/src/compile-arm.S +++ b/src/compile-arm.S @@ -9,6 +9,7 @@ details. */ #include "types.h" +#include "target-fields.h" .text @@ -22,14 +23,6 @@ # define GLOBAL(x) x #endif -#define THREAD_STACK 2148 -#define THREAD_SCRATCH 2156 -#define THREAD_CONTINUATION 2160 -#define THREAD_EXCEPTION 44 -#define THREAD_EXCEPTION_STACK_ADJUSTMENT 2164 -#define THREAD_EXCEPTION_OFFSET 2168 -#define THREAD_EXCEPTION_HANDLER 2172 - #define CONTINUATION_NEXT 4 #define CONTINUATION_ADDRESS 16 #define CONTINUATION_RETURN_ADDRESS_OFFSET 20 @@ -57,7 +50,7 @@ GLOBAL(vmInvoke): ldr r4, [sp, #4] str r4, [sp, #-4]! - str sp, [r0, #THREAD_SCRATCH] + str sp, [r0, #TARGET_THREAD_SCRATCH] // align stack, if necessary eor r4, sp, r3 @@ -88,7 +81,7 @@ LOCAL(vmInvoke_argumentTest): .align 2 GLOBAL(vmInvoke_returnAddress): // restore stack pointer - ldr sp, [r8, #THREAD_SCRATCH] + ldr sp, [r8, #TARGET_THREAD_SCRATCH] // clear MyThread::stack to avoid confusing another thread calling // java.lang.Thread.getStackTrace on this one. See @@ -96,7 +89,7 @@ GLOBAL(vmInvoke_returnAddress): // a reliable stack trace from a thread that might be interrupted at // any point in its execution. mov r5, #0 - str r5, [r8, #THREAD_STACK] + str r5, [r8, #TARGET_THREAD_STACK] .globl GLOBAL(vmInvoke_safeStack) .align 2 @@ -104,7 +97,7 @@ GLOBAL(vmInvoke_safeStack): #ifdef AVIAN_CONTINUATIONS // call the next continuation, if any - ldr r5,[r8,#THREAD_CONTINUATION] + ldr r5,[r8,#TARGET_THREAD_CONTINUATION] cmp r5,#0 beq LOCAL(vmInvoke_exit) @@ -138,10 +131,10 @@ LOCAL(vmInvoke_getAddress): str r11,[sp,r7] ldr r7,[r5,#CONTINUATION_NEXT] - str r7,[r8,#THREAD_CONTINUATION] + str r7,[r8,#TARGET_THREAD_CONTINUATION] // call the continuation unless we're handling an exception - ldr r7,[r8,#THREAD_EXCEPTION] + ldr r7,[r8,#TARGET_THREAD_EXCEPTION] cmp r7,#0 bne LOCAL(vmInvoke_handleException) ldr r7,[r5,#CONTINUATION_ADDRESS] @@ -150,22 +143,22 @@ LOCAL(vmInvoke_getAddress): LOCAL(vmInvoke_handleException): // we're handling an exception - call the exception handler instead mov r11,#0 - str r11,[r8,#THREAD_EXCEPTION] - ldr r11,[r8,#THREAD_EXCEPTION_STACK_ADJUSTMENT] + str r11,[r8,#TARGET_THREAD_EXCEPTION] + ldr r11,[r8,#TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT] ldr r9,[sp] neg r11,r11 str r9,[sp,r11]! - ldr r11,[r8,#THREAD_EXCEPTION_OFFSET] + ldr r11,[r8,#TARGET_THREAD_EXCEPTIONOFFSET] str r7,[sp,r11] - ldr r7,[r8,#THREAD_EXCEPTION_HANDLER] + ldr r7,[r8,#TARGET_THREAD_EXCEPTIONHANDLER] bx r7 LOCAL(vmInvoke_exit): #endif // AVIAN_CONTINUATIONS mov ip, #0 - str ip, [r8, #THREAD_STACK] + str ip, [r8, #TARGET_THREAD_STACK] // restore return type ldr ip, [sp], #4 diff --git a/src/compile-powerpc.S b/src/compile-powerpc.S index 170fe47dd0..667ae40ed7 100644 --- a/src/compile-powerpc.S +++ b/src/compile-powerpc.S @@ -9,6 +9,7 @@ details. */ #include "types.h" +#include "target-fields.h" .text @@ -28,13 +29,6 @@ #endif #define ARGUMENT_BASE BYTES_PER_WORD * LINKAGE_AREA - -#define THREAD_STACK 2148 -#define THREAD_CONTINUATION 2160 -#define THREAD_EXCEPTION 44 -#define THREAD_EXCEPTION_STACK_ADJUSTMENT 2164 -#define THREAD_EXCEPTION_OFFSET 2168 -#define THREAD_EXCEPTION_HANDLER 2172 #define CONTINUATION_NEXT 4 #define CONTINUATION_ADDRESS 16 @@ -121,14 +115,14 @@ GLOBAL(vmInvoke_returnAddress): // 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) + stw r5,TARGET_THREAD_STACK(r13) .globl GLOBAL(vmInvoke_safeStack) GLOBAL(vmInvoke_safeStack): #ifdef AVIAN_CONTINUATIONS // call the next continuation, if any - lwz r5,THREAD_CONTINUATION(r13) + lwz r5,TARGET_THREAD_CONTINUATION(r13) cmplwi r5,0 beq LOCAL(vmInvoke_exit) @@ -171,10 +165,10 @@ LOCAL(vmInvoke_getPC): stw r7,0(r1) lwz r7,CONTINUATION_NEXT(r5) - stw r7,THREAD_CONTINUATION(r13) + stw r7,TARGET_THREAD_CONTINUATION(r13) // call the continuation unless we're handling an exception - lwz r7,THREAD_EXCEPTION(r13) + lwz r7,TARGET_THREAD_EXCEPTION(r13) cmpwi r7,0 bne LOCAL(vmInvoke_handleException) lwz r7,CONTINUATION_ADDRESS(r5) @@ -184,15 +178,15 @@ LOCAL(vmInvoke_getPC): LOCAL(vmInvoke_handleException): // we're handling an exception - call the exception handler instead li r8,0 - stw r8,THREAD_EXCEPTION(r13) - lwz r8,THREAD_EXCEPTION_STACK_ADJUSTMENT(r13) + stw r8,TARGET_THREAD_EXCEPTION(r13) + lwz r8,TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT(r13) lwz r9,0(r1) subfic r8,r8,0 stwux r9,r1,r8 - lwz r8,THREAD_EXCEPTION_OFFSET(r13) + lwz r8,TARGET_THREAD_EXCEPTIONOFFSET(r13) stwx r7,r1,r8 - lwz r7,THREAD_EXCEPTION_HANDLER(r13) + lwz r7,TARGET_THREAD_EXCEPTIONHANDLER(r13) mtctr r7 bctr diff --git a/src/compile-x86.S b/src/compile-x86.S index d81129765a..a5d0e1930f 100644 --- a/src/compile-x86.S +++ b/src/compile-x86.S @@ -9,6 +9,7 @@ details. */ #include "types.h" +#include "target-fields.h" #define LOCAL(x) .L##x @@ -23,9 +24,6 @@ #ifdef __x86_64__ -#define THREAD_STACK 2224 -#define THREAD_SCRATCH 2240 - #ifdef AVIAN_USE_FRAME_POINTER # define ALIGNMENT_ADJUSTMENT 0 #else @@ -53,7 +51,7 @@ GLOBAL(vmInvoke): // remember this stack position, since we won't be able to rely on // %rbp being restored when the call returns - movq %rsp,THREAD_SCRATCH(%rcx) + movq %rsp,TARGET_THREAD_SCRATCH(%rcx) // save callee-saved registers movq %rbx,0(%rsp) @@ -90,14 +88,14 @@ LOCAL(vmInvoke_argumentTest): .globl GLOBAL(vmInvoke_returnAddress) GLOBAL(vmInvoke_returnAddress): // restore stack pointer - movq THREAD_SCRATCH(%rbx),%rsp + movq TARGET_THREAD_SCRATCH(%rbx),%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) + movq $0,TARGET_THREAD_STACK(%rbx) .globl GLOBAL(vmInvoke_safeStack) GLOBAL(vmInvoke_safeStack): @@ -188,7 +186,7 @@ GLOBAL(vmInvoke): // remember this stack position, since we won't be able to rely on // %rbp being restored when the call returns - movq %rsp,THREAD_SCRATCH(%rdi) + movq %rsp,TARGET_THREAD_SCRATCH(%rdi) // save callee-saved registers movq %rbx,0(%rsp) @@ -222,14 +220,14 @@ LOCAL(vmInvoke_argumentTest): .globl GLOBAL(vmInvoke_returnAddress) GLOBAL(vmInvoke_returnAddress): // restore stack pointer - movq THREAD_SCRATCH(%rbx),%rsp + movq TARGET_THREAD_SCRATCH(%rbx),%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) + movq $0,TARGET_THREAD_STACK(%rbx) .globl GLOBAL(vmInvoke_safeStack) GLOBAL(vmInvoke_safeStack): @@ -299,9 +297,6 @@ LOCAL(vmJumpAndInvoke_argumentTest): #elif defined __i386__ -#define THREAD_STACK 2148 -#define THREAD_SCRATCH 2156 - #ifdef AVIAN_USE_FRAME_POINTER # define ALIGNMENT_ADJUSTMENT 0 #else @@ -328,7 +323,7 @@ GLOBAL(vmInvoke): // remember this stack position, since we won't be able to rely on // %rbp being restored when the call returns movl 8(%ebp),%eax - movl %esp,THREAD_SCRATCH(%eax) + movl %esp,TARGET_THREAD_SCRATCH(%eax) movl %ebx,0(%esp) movl %esi,4(%esp) @@ -360,14 +355,14 @@ LOCAL(vmInvoke_argumentTest): .globl GLOBAL(vmInvoke_returnAddress) GLOBAL(vmInvoke_returnAddress): // restore stack pointer - movl THREAD_SCRATCH(%ebx),%esp + movl TARGET_THREAD_SCRATCH(%ebx),%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) + movl $0,TARGET_THREAD_STACK(%ebx) .globl GLOBAL(vmInvoke_safeStack) GLOBAL(vmInvoke_safeStack): diff --git a/src/compile.cpp b/src/compile.cpp index 6b7e4ea6f0..d1518871d3 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -1392,7 +1392,7 @@ class Frame { return c->add (TargetBytesPerWord, c->memory (c->register_(t->arch->thread()), Compiler::AddressType, - TargetThreadHeapImage), c->promiseConstant + TARGET_THREAD_HEAPIMAGE), c->promiseConstant (p, Compiler::AddressType)); } else { for (PoolElement* e = context->objectPool; e; e = e->next) { @@ -1622,7 +1622,7 @@ class Frame { ? c->add (TargetBytesPerWord, c->memory (c->register_(t->arch->thread()), Compiler::AddressType, - TargetThreadCodeImage), c->promiseConstant + TARGET_THREAD_CODEIMAGE), c->promiseConstant (new(&context->zone) OffsetPromise (p, - reinterpret_cast(codeAllocator(t)->base)), @@ -1932,8 +1932,7 @@ class Frame { subroutine->handle = c->startSubroutine(); this->subroutine = subroutine; - SubroutineCall* call = new - (context->zone.allocate(sizeof(SubroutineCall))) + SubroutineCall* call = new(&context->zone) SubroutineCall(subroutine, returnAddress); context->eventLog.append(PushSubroutineEvent); @@ -3380,7 +3379,7 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target, bool tailCall, frame->absoluteAddressOperand(returnAddressPromise), TargetBytesPerWord, c->memory (c->register_(t->arch->thread()), Compiler::AddressType, - TargetThreadTailAddress)); + TARGET_THREAD_TAILADDRESS)); c->exit (c->constant @@ -5563,7 +5562,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, (context->bootContext ? c->add (TargetBytesPerWord, c->memory (c->register_(t->arch->thread()), Compiler::AddressType, - TargetThreadCodeImage), address) + TARGET_THREAD_CODEIMAGE), address) : address); Compiler::State* state = c->saveState(); @@ -6110,7 +6109,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, ? c->add (TargetBytesPerWord, c->memory (c->register_(t->arch->thread()), Compiler::AddressType, - TargetThreadCodeImage), entry) + TARGET_THREAD_CODEIMAGE), entry) : entry, TargetBytesPerWord)); @@ -7033,7 +7032,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context) // of cycles if another thread compiles the same method in parallel, // which might be mitigated by fine-grained, per-method locking): c->compile(context->leaf ? 0 : stackOverflowThunk(t), - TargetThreadStackLimit); + TARGET_THREAD_STACKLIMIT); // we must acquire the class lock here at the latest @@ -8529,6 +8528,16 @@ public: Processor::CompilationHandler* handler; }; +template +int checkConstant(MyThread* t, size_t expected, T C::* field, const char* name) { + size_t actual = reinterpret_cast(&(t->*field)) - reinterpret_cast(t); + if(expected != actual) { + fprintf(stderr, "constant mismatch (%s): \n\tconstant says: %d\n\tc++ compiler says: %d\n", name, (unsigned) expected, (unsigned) actual); + return 1; + } + return 0; +} + class MyProcessor: public Processor { public: class Thunk { @@ -8605,38 +8614,25 @@ class MyProcessor: public Processor { t->codeImage = codeImage; t->thunkTable = thunkTable; - if (false) { - fprintf(stderr, "stack %d\n", - difference(&(t->stack), t)); - fprintf(stderr, "scratch %d\n", - difference(&(t->scratch), t)); - fprintf(stderr, "continuation %d\n", - difference(&(t->continuation), t)); - fprintf(stderr, "exception %d\n", - difference(&(t->exception), t)); - fprintf(stderr, "exceptionStackAdjustment %d\n", - difference(&(t->exceptionStackAdjustment), t)); - fprintf(stderr, "exceptionOffset %d\n", - difference(&(t->exceptionOffset), t)); - fprintf(stderr, "exceptionHandler %d\n", - difference(&(t->exceptionHandler), t)); - fprintf(stderr, "tailAddress %d\n", - difference(&(t->tailAddress), t)); - fprintf(stderr, "stackLimit %d\n", - difference(&(t->stackLimit), t)); - fprintf(stderr, "ip %d\n", - difference(&(t->ip), t)); - fprintf(stderr, "virtualCallTarget %d\n", - difference(&(t->virtualCallTarget), t)); - fprintf(stderr, "virtualCallIndex %d\n", - difference(&(t->virtualCallIndex), t)); - fprintf(stderr, "heapImage %d\n", - difference(&(t->heapImage), t)); - fprintf(stderr, "codeImage %d\n", - difference(&(t->codeImage), t)); - fprintf(stderr, "thunkTable %d\n", - difference(&(t->thunkTable), t)); - exit(0); + int mismatches = + checkConstant(t, TARGET_THREAD_EXCEPTION, &Thread::exception, "TARGET_THREAD_EXCEPTION") + + checkConstant(t, TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT, &MyThread::exceptionStackAdjustment, "TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT") + + checkConstant(t, TARGET_THREAD_EXCEPTIONOFFSET, &MyThread::exceptionOffset, "TARGET_THREAD_EXCEPTIONOFFSET") + + checkConstant(t, TARGET_THREAD_EXCEPTIONHANDLER, &MyThread::exceptionHandler, "TARGET_THREAD_EXCEPTIONHANDLER") + + checkConstant(t, TARGET_THREAD_IP, &MyThread::ip, "TARGET_THREAD_IP") + + checkConstant(t, TARGET_THREAD_STACK, &MyThread::stack, "TARGET_THREAD_STACK") + + checkConstant(t, TARGET_THREAD_NEWSTACK, &MyThread::newStack, "TARGET_THREAD_NEWSTACK") + + checkConstant(t, TARGET_THREAD_TAILADDRESS, &MyThread::tailAddress, "TARGET_THREAD_TAILADDRESS") + + checkConstant(t, TARGET_THREAD_VIRTUALCALLTARGET, &MyThread::virtualCallTarget, "TARGET_THREAD_VIRTUALCALLTARGET") + + checkConstant(t, TARGET_THREAD_VIRTUALCALLINDEX, &MyThread::virtualCallIndex, "TARGET_THREAD_VIRTUALCALLINDEX") + + checkConstant(t, TARGET_THREAD_HEAPIMAGE, &MyThread::heapImage, "TARGET_THREAD_HEAPIMAGE") + + checkConstant(t, TARGET_THREAD_CODEIMAGE, &MyThread::codeImage, "TARGET_THREAD_CODEIMAGE") + + checkConstant(t, TARGET_THREAD_THUNKTABLE, &MyThread::thunkTable, "TARGET_THREAD_THUNKTABLE") + + checkConstant(t, TARGET_THREAD_STACKLIMIT, &MyThread::stackLimit, "TARGET_THREAD_STACKLIMIT"); + + if(mismatches > 0) { + fprintf(stderr, "%d constant mismatches\n", mismatches); + abort(t); } t->init(); @@ -9801,7 +9797,7 @@ compileCall(MyThread* t, Context* c, ThunkIndex index, bool call = true) Assembler* a = c->assembler; if (processor(t)->bootImage) { - Assembler::Memory table(t->arch->thread(), TargetThreadThunkTable); + Assembler::Memory table(t->arch->thread(), TARGET_THREAD_THUNKTABLE); Assembler::Register scratch(t->arch->scratch()); a->apply(Move, TargetBytesPerWord, MemoryOperand, &table, TargetBytesPerWord, RegisterOperand, &scratch); @@ -9827,7 +9823,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) { Context context(t); Assembler* a = context.assembler; - a->saveFrame(TargetThreadStack, TargetThreadIp); + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); p->thunks.default_.frameSavedOffset = a->length(); @@ -9860,19 +9856,19 @@ compileThunks(MyThread* t, FixedAllocator* allocator) TargetBytesPerWord, RegisterOperand, &class_); Assembler::Memory virtualCallTargetDst - (t->arch->thread(), TargetThreadVirtualCallTarget); + (t->arch->thread(), TARGET_THREAD_VIRTUALCALLTARGET); a->apply(Move, TargetBytesPerWord, RegisterOperand, &class_, TargetBytesPerWord, MemoryOperand, &virtualCallTargetDst); Assembler::Register index(t->arch->virtualCallIndex()); Assembler::Memory virtualCallIndex - (t->arch->thread(), TargetThreadVirtualCallIndex); + (t->arch->thread(), TARGET_THREAD_VIRTUALCALLINDEX); a->apply(Move, TargetBytesPerWord, RegisterOperand, &index, TargetBytesPerWord, MemoryOperand, &virtualCallIndex); - a->saveFrame(TargetThreadStack, TargetThreadIp); + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); p->thunks.defaultVirtual.frameSavedOffset = a->length(); @@ -9895,7 +9891,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) { Context context(t); Assembler* a = context.assembler; - a->saveFrame(TargetThreadStack, TargetThreadIp); + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); p->thunks.native.frameSavedOffset = a->length(); @@ -9905,7 +9901,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) compileCall(t, &context, invokeNativeIndex); a->popFrameAndUpdateStackAndReturn - (t->arch->alignFrameSize(1), TargetThreadNewStack); + (t->arch->alignFrameSize(1), TARGET_THREAD_NEWSTACK); p->thunks.native.length = a->endBlock(false)->resolve(0, 0); @@ -9916,7 +9912,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) { Context context(t); Assembler* a = context.assembler; - a->saveFrame(TargetThreadStack, TargetThreadIp); + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); p->thunks.aioob.frameSavedOffset = a->length(); @@ -9934,7 +9930,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) { Context context(t); Assembler* a = context.assembler; - a->saveFrame(TargetThreadStack, TargetThreadIp); + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); p->thunks.stackOverflow.frameSavedOffset = a->length(); @@ -9952,7 +9948,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) { { Context context(t); Assembler* a = context.assembler; - a->saveFrame(TargetThreadStack, TargetThreadIp); + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); p->thunks.table.frameSavedOffset = a->length(); @@ -9971,7 +9967,7 @@ compileThunks(MyThread* t, FixedAllocator* allocator) Context context(t); \ Assembler* a = context.assembler; \ \ - a->saveFrame(TargetThreadStack, TargetThreadIp); \ + a->saveFrame(TARGET_THREAD_STACK, TARGET_THREAD_IP); \ \ p->thunks.table.frameSavedOffset = a->length(); \ \ diff --git a/src/target-fields.h b/src/target-fields.h new file mode 100644 index 0000000000..3481d4516e --- /dev/null +++ b/src/target-fields.h @@ -0,0 +1,63 @@ +/* Copyright (c) 2011, Avian Contributors + + Permission to use, copy, modify, and/or distribute this software + for any purpose with or without fee is hereby granted, provided + that the above copyright notice and this permission notice appear + in all copies. + + There is NO WARRANTY for this software. See license.txt for + details. */ + +#ifndef AVIAN_TARGET_FIELDS_H +#define AVIAN_TARGET_FIELDS_H + + +#ifdef TARGET_BYTES_PER_WORD +# if (TARGET_BYTES_PER_WORD == 8) + +#define TARGET_THREAD_EXCEPTION 80 +#define TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT 2256 +#define TARGET_THREAD_EXCEPTIONOFFSET 2264 +#define TARGET_THREAD_EXCEPTIONHANDLER 2272 + +#define TARGET_THREAD_IP 2216 +#define TARGET_THREAD_STACK 2224 +#define TARGET_THREAD_NEWSTACK 2232 +#define TARGET_THREAD_SCRATCH 2240 +#define TARGET_THREAD_CONTINUATION 2248 +#define TARGET_THREAD_TAILADDRESS 2280 +#define TARGET_THREAD_VIRTUALCALLTARGET 2288 +#define TARGET_THREAD_VIRTUALCALLINDEX 2296 +#define TARGET_THREAD_HEAPIMAGE 2304 +#define TARGET_THREAD_CODEIMAGE 2312 +#define TARGET_THREAD_THUNKTABLE 2320 +#define TARGET_THREAD_STACKLIMIT 2368 + +# elif (TARGET_BYTES_PER_WORD == 4) + +#define TARGET_THREAD_EXCEPTION 44 +#define TARGET_THREAD_EXCEPTIONSTACKADJUSTMENT 2164 +#define TARGET_THREAD_EXCEPTIONOFFSET 2168 +#define TARGET_THREAD_EXCEPTIONHANDLER 2172 + +#define TARGET_THREAD_IP 2144 +#define TARGET_THREAD_STACK 2148 +#define TARGET_THREAD_NEWSTACK 2152 +#define TARGET_THREAD_SCRATCH 2156 +#define TARGET_THREAD_CONTINUATION 2160 +#define TARGET_THREAD_TAILADDRESS 2176 +#define TARGET_THREAD_VIRTUALCALLTARGET 2180 +#define TARGET_THREAD_VIRTUALCALLINDEX 2184 +#define TARGET_THREAD_HEAPIMAGE 2188 +#define TARGET_THREAD_CODEIMAGE 2192 +#define TARGET_THREAD_THUNKTABLE 2196 +#define TARGET_THREAD_STACKLIMIT 2220 + +# else +# error +# endif +#else +# error +#endif + +#endif \ No newline at end of file diff --git a/src/target.h b/src/target.h index 071a4d743a..996d76348f 100644 --- a/src/target.h +++ b/src/target.h @@ -11,6 +11,8 @@ #ifndef TARGET_H #define TARGET_H +#include "target-fields.h" + namespace vm { template @@ -90,19 +92,6 @@ targetVW(T v) typedef uint64_t target_uintptr_t; typedef int64_t target_intptr_t; -const unsigned TargetBytesPerWord = 8; - -const unsigned TargetThreadIp = 2216; -const unsigned TargetThreadStack = 2224; -const unsigned TargetThreadNewStack = 2232; -const unsigned TargetThreadTailAddress = 2280; -const unsigned TargetThreadVirtualCallTarget = 2288; -const unsigned TargetThreadVirtualCallIndex = 2296; -const unsigned TargetThreadHeapImage = 2304; -const unsigned TargetThreadCodeImage = 2312; -const unsigned TargetThreadThunkTable = 2320; -const unsigned TargetThreadStackLimit = 2368; - const unsigned TargetClassFixedSize = 12; const unsigned TargetClassArrayElementSize = 14; const unsigned TargetClassVtable = 128; @@ -121,19 +110,6 @@ targetVW(T v) typedef uint32_t target_uintptr_t; typedef int32_t target_intptr_t; -const unsigned TargetBytesPerWord = 4; - -const unsigned TargetThreadIp = 2144; -const unsigned TargetThreadStack = 2148; -const unsigned TargetThreadNewStack = 2152; -const unsigned TargetThreadTailAddress = 2176; -const unsigned TargetThreadVirtualCallTarget = 2180; -const unsigned TargetThreadVirtualCallIndex = 2184; -const unsigned TargetThreadHeapImage = 2188; -const unsigned TargetThreadCodeImage = 2192; -const unsigned TargetThreadThunkTable = 2196; -const unsigned TargetThreadStackLimit = 2220; - const unsigned TargetClassFixedSize = 8; const unsigned TargetClassArrayElementSize = 10; const unsigned TargetClassVtable = 68; @@ -147,6 +123,8 @@ const unsigned TargetFieldOffset = 8; # error #endif +const unsigned TargetBytesPerWord = TARGET_BYTES_PER_WORD; + const unsigned TargetBitsPerWord = TargetBytesPerWord * 8; const target_uintptr_t TargetPointerMask