From bb331e94147f70cad9c8643bff7d6074cda1b2b3 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Sat, 28 Jun 2014 21:08:10 -0600 Subject: [PATCH] make callNode and methodRuntimeData.native better statically typed --- src/classpath-android.cpp | 4 +-- src/compile.cpp | 56 +++++++++++++++++++-------------------- src/types.def | 16 +++++------ 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index 35a9771e93..7f2d2a98a9 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -654,8 +654,8 @@ closeMemoryMappedFile(Thread* t, GcMethod* method, uintptr_t* arguments) } t->m->processor->invoke - (t, cast(t, nativeInterceptOriginal - (t, getMethodRuntimeData(t, method)->native())), + (t, cast(t, + getMethodRuntimeData(t, method)->native()->as(t)->original()), file); } diff --git a/src/compile.cpp b/src/compile.cpp index a4fed7e7ba..743002400d 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -1963,7 +1963,7 @@ savedTargetIndex(MyThread* t UNUSED, GcMethod* method) return method->code()->maxLocals(); } -object +GcCallNode* findCallNode(MyThread* t, void* address); void @@ -6863,7 +6863,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context) if (p->target) { insertCallNode (t, reinterpret_cast(makeCallNode - (t, p->address->value(), reinterpret_cast(p->target), p->flags, 0))); + (t, p->address->value(), p->target, p->flags, 0))); } } } @@ -7314,9 +7314,9 @@ invokeNative(MyThread* t) ip = getIp(t); } - object node = findCallNode(t, ip); - GcMethod* target = cast(t, callNodeTarget(t, node)); - if (callNodeFlags(t, node) & TraceElement::VirtualCall) { + GcCallNode* node = findCallNode(t, ip); + GcMethod* target = node->target(); + if (node->flags() & TraceElement::VirtualCall) { target = resolveTarget(t, t->stack, target); } t->trace->nativeMethod = target; @@ -8845,15 +8845,15 @@ class MyProcessor: public Processor { unsigned index = 0; for (unsigned i = 0; i < arrayLength(t, root(t, CallTable)); ++i) { - for (object p = arrayBody(t, root(t, CallTable), i); - p; p = callNodeNext(t, p)) + for (GcCallNode* p = cast(t, arrayBody(t, root(t, CallTable), i)); + p; p = p->next()) { table[index++] = targetVW( - callNodeAddress(t, p) + p->address() - reinterpret_cast(codeAllocator.memory.begin())); table[index++] = targetVW( - w->map()->find(callNodeTarget(t, p)) - | (static_cast(callNodeFlags(t, p)) << TargetBootShift)); + w->map()->find(reinterpret_cast(p->target())) + | (static_cast(p->flags()) << TargetBootShift)); } } @@ -9027,8 +9027,8 @@ logCompile(MyThread* t, const void* code, unsigned size, const char* class_, void* compileMethod2(MyThread* t, void* ip) { - object node = findCallNode(t, ip); - GcMethod* target = cast(t, callNodeTarget(t, node)); + GcCallNode* node = findCallNode(t, ip); + GcMethod* target = node->target(); PROTECT(t, node); PROTECT(t, target); @@ -9056,13 +9056,13 @@ compileMethod2(MyThread* t, void* ip) if (updateCaller) { avian::codegen::lir::UnaryOperation op; - if (callNodeFlags(t, node) & TraceElement::LongCall) { - if (callNodeFlags(t, node) & TraceElement::TailCall) { + if (node->flags() & TraceElement::LongCall) { + if (node->flags() & TraceElement::TailCall) { op = avian::codegen::lir::AlignedLongJump; } else { op = avian::codegen::lir::AlignedLongCall; } - } else if (callNodeFlags(t, node) & TraceElement::TailCall) { + } else if (node->flags() & TraceElement::TailCall) { op = avian::codegen::lir::AlignedJump; } else { op = avian::codegen::lir::AlignedCall; @@ -9161,7 +9161,7 @@ isThunkUnsafeStack(MyThread* t, void* ip) or isThunkUnsafeStack(&(p->bootThunks), ip)); } -object +GcCallNode* findCallNode(MyThread* t, void* address) { if (DebugCallTable) { @@ -9178,10 +9178,10 @@ findCallNode(MyThread* t, void* address) intptr_t key = reinterpret_cast(address); unsigned index = static_cast(key) & (arrayLength(t, table) - 1); - for (object n = arrayBody(t, table, index); - n; n = callNodeNext(t, n)) + for (GcCallNode* n = cast(t, arrayBody(t, table, index)); + n; n = n->next()) { - intptr_t k = callNodeAddress(t, n); + intptr_t k = n->address(); if (k == key) { return n; @@ -9196,26 +9196,26 @@ resizeTable(MyThread* t, object oldTable, unsigned newLength) { PROTECT(t, oldTable); - object oldNode = 0; + GcCallNode* oldNode = 0; PROTECT(t, oldNode); object newTable = reinterpret_cast(makeArray(t, newLength)); PROTECT(t, newTable); for (unsigned i = 0; i < arrayLength(t, oldTable); ++i) { - for (oldNode = arrayBody(t, oldTable, i); + for (oldNode = cast(t, arrayBody(t, oldTable, i)); oldNode; - oldNode = callNodeNext(t, oldNode)) + oldNode = oldNode->next()) { - intptr_t k = callNodeAddress(t, oldNode); + intptr_t k = oldNode->address(); unsigned index = k & (newLength - 1); object newNode = reinterpret_cast(makeCallNode - (t, callNodeAddress(t, oldNode), - callNodeTarget(t, oldNode), - callNodeFlags(t, oldNode), - arrayBody(t, newTable, index))); + (t, oldNode->address(), + oldNode->target(), + oldNode->flags(), + cast(t, arrayBody(t, newTable, index)))); set(t, newTable, ArrayBody + (index * BytesPerWord), newNode); } @@ -9320,7 +9320,7 @@ makeCallTable(MyThread* t, uintptr_t* heap, unsigned* calls, unsigned count, unsigned target = calls[(i * 2) + 1]; object node = reinterpret_cast(makeCallNode - (t, base + address, bootObject(heap, target & BootMask), + (t, base + address, cast(t, bootObject(heap, target & BootMask)), target >> BootShift, 0)); table = insertCallNode(t, table, &size, node); diff --git a/src/types.def b/src/types.def index f54dab904d..588bdc857c 100644 --- a/src/types.def +++ b/src/types.def @@ -49,16 +49,16 @@ (object pool) (object signers)) -(type methodRuntimeData - (object native)) - -(type pointer - (void* value)) - (type native (void* function) (uint8_t fast)) +(type methodRuntimeData + (native native)) + +(type pointer + (void* value)) + (type nativeIntercept (extends native) (object original)) @@ -120,9 +120,9 @@ (type callNode (intptr_t address) - (object target) + (method target) (uintptr_t flags) - (object next)) + (callNode next)) (type wordArray (array uintptr_t body))