diff --git a/src/compile.cpp b/src/compile.cpp index d7c1e24b4f..5702ca48d6 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2062,7 +2062,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case d2f: { Operand* a = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(doubleToFloat)), 2, 0, a); c->release(a); @@ -2074,7 +2074,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case d2i: { Operand* a = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(doubleToInt)), 2, 0, a); c->release(a); @@ -2086,7 +2086,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case d2l: { Operand* a = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(doubleToLong)), 2, 0, a); c->release(a); @@ -2099,7 +2099,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(addDouble)), 4, 0, a, 0, b); c->release(a); c->release(b); @@ -2113,7 +2113,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(compareDoublesG)), 4, 0, a, 0, b); c->release(a); @@ -2128,7 +2128,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(compareDoublesL)), 4, 0, a, 0, b); c->release(a); @@ -2151,7 +2151,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(divideDouble)), 4, 0, a, 0, b); c->release(a); @@ -2166,7 +2166,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(multiplyDouble)), 4, 0, a, 0, b); c->release(a); @@ -2180,8 +2180,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case dneg: { Operand* a = frame->popLong(); - c->directCall - (c->constant(reinterpret_cast(negateDouble)), 2, 0, a); + c->indirectCall + (c->constant(reinterpret_cast(negateDouble)), 0, 2, 0, a); c->release(a); Operand* result = c->result8(); @@ -2193,8 +2193,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall - (c->constant(reinterpret_cast(moduloDouble)), 4, 0, a, 0, b); + c->indirectCall + (c->constant(reinterpret_cast(moduloDouble)), + 4, 0, a, 0, b); c->release(a); c->release(b); @@ -2207,7 +2208,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popLong(); Operand* b = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(subtractDouble)), 4, 0, a, 0, b); c->release(a); @@ -2245,7 +2246,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case f2d: { Operand* a = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(floatToDouble)), 1, a); c->release(a); @@ -2257,8 +2258,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case f2i: { Operand* a = frame->popInt(); - c->directCall - (c->constant(reinterpret_cast(floatToInt)), 1, a); + c->indirectCall + (c->constant(reinterpret_cast(floatToInt)), 1, a); c->release(a); Operand* result = c->result4(); @@ -2269,7 +2270,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case f2l: { Operand* a = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(floatToLong)), 1, a); c->release(a); @@ -2282,7 +2283,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(addFloat)), 2, a, b); c->release(a); c->release(b); @@ -2296,7 +2297,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(compareFloatsG)), 2, a, b); c->release(a); c->release(b); @@ -2310,7 +2311,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(compareFloatsL)), 2, a, b); c->release(a); c->release(b); @@ -2336,7 +2337,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(divideFloat)), 2, a, b); c->release(a); c->release(b); @@ -2350,7 +2351,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(multiplyFloat)), 2, a, b); c->release(a); c->release(b); @@ -2363,7 +2364,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case fneg: { Operand* a = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(negateFloat)), 1, a); c->release(a); @@ -2376,7 +2377,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(moduloFloat)), 2, a, b); c->release(a); c->release(b); @@ -2390,7 +2391,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* a = frame->popInt(); Operand* b = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(subtractFloat)), 2, a, b); c->release(a); c->release(b); @@ -2486,7 +2487,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case i2d: { Operand* a = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(intToDouble)), 1, a); Operand* result = c->result8(); @@ -2498,7 +2499,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case i2f: { Operand* a = frame->popInt(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(intToFloat)), 1, a); Operand* result = c->result4(); @@ -2737,7 +2738,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, Operand* classOperand = frame->append(class_); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(instanceOf)), 3, c->thread(), classOperand, instance); @@ -2923,7 +2924,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case l2d: { Operand* a = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(longToDouble)), 2, 0, a); Operand* result = c->result8(); @@ -2935,7 +2936,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, case l2f: { Operand* a = frame->popLong(); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(longToDouble)), 2, 0, a); Operand* result = c->result4(); @@ -3113,7 +3114,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, } assert(t, start); - c->directCall + c->indirectCall (c->constant(reinterpret_cast(lookUpAddress)), 4, key, start, c->constant(pairCount), default_); @@ -3428,9 +3429,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip, frame->trace(0, false), 4, c->thread(), table, c->constant(fieldOffset(t, field)), value); } else { - c->directCall + c->indirectCall (c->constant(reinterpret_cast(set)), - 4, c->thread(), table, c->constant(fieldOffset(t, field)), value); + 4, c->thread(), table, c->constant(fieldOffset(t, field)), + value); } break; @@ -5006,9 +5008,11 @@ class MyProcessor: public Processor { void* oldBase = target->ip; void* oldStack = target->stack; - target->ip = ip; - target->base = base; - target->stack = stack; + if (methodForIp(t, ip)) { + target->ip = ip; + target->base = base; + target->stack = stack; + } trace = makeTrace(t, target); @@ -5147,7 +5151,7 @@ object findCallNode(MyThread* t, void* address) { if (DebugCallTable) { - fprintf(stderr, "find trace node %p\n", address); + fprintf(stderr, "find call node %p\n", address); } MyProcessor* p = processor(t); @@ -5207,7 +5211,7 @@ void insertCallNode(MyThread* t, object node) { if (DebugCallTable) { - fprintf(stderr, "insert trace node %p\n", + fprintf(stderr, "insert call node %p\n", reinterpret_cast(callNodeAddress(t, node))); } diff --git a/src/compiler.cpp b/src/compiler.cpp index ec7514292d..a64eeeea79 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -1103,13 +1103,9 @@ pushArguments(Context* c, unsigned count, va_list list) unsigned index = 0; for (unsigned i = 0; i < count; ++i) { - if (BytesPerWord == 8) { - arguments[index] = va_arg(list, MyOperand*); - if (arguments[index]) { - ++ index; - } - } else { - arguments[index++] = va_arg(list, MyOperand*); + arguments[index] = va_arg(list, MyOperand*); + if (BytesPerWord == 4 or arguments[index]) { + ++ index; } } @@ -2540,6 +2536,23 @@ class MyCompiler: public Compiler { (&c, static_cast(machineIp())); } + virtual void indirectCall + (Operand* address, unsigned argumentCount, ...) + { + va_list a; va_start(a, argumentCount); + pushArguments(&c, argumentCount, a); + va_end(a); + + appendOperation + (&c, MyOperand::mov, address, register_(&c, rax)); + call(immediate(&c, c.indirectCaller), 0); + + appendOperation + (&c, MyOperand::add, + immediate(&c, argumentFootprint(argumentCount)), + register_(&c, rsp)); + } + virtual void indirectCall (Operand* address, TraceHandler* traceHandler, unsigned argumentCount, ...) { diff --git a/src/compiler.h b/src/compiler.h index 4efa780b2d..1f95683dd6 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -65,6 +65,8 @@ class Compiler { virtual Operand* label() = 0; virtual void mark(Operand*) = 0; + virtual void indirectCall + (Operand* address, unsigned argumentCount, ...) = 0; virtual void indirectCall (Operand* address, TraceHandler* traceHandler, unsigned argumentCount, ...) = 0;