mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
fix build
This commit is contained in:
parent
efb30b2256
commit
f1809897bd
@ -134,7 +134,8 @@ class Assembler {
|
|||||||
public:
|
public:
|
||||||
virtual ~Client() { }
|
virtual ~Client() { }
|
||||||
|
|
||||||
virtual int acquireTemporary() = 0;
|
virtual int acquireTemporary
|
||||||
|
(uint32_t mask = ~static_cast<uint32_t>(0)) = 0;
|
||||||
virtual void releaseTemporary(int r) = 0;
|
virtual void releaseTemporary(int r) = 0;
|
||||||
|
|
||||||
virtual void save(int r) = 0;
|
virtual void save(int r) = 0;
|
||||||
@ -157,11 +158,11 @@ class Assembler {
|
|||||||
virtual int argumentRegister(unsigned index) = 0;
|
virtual int argumentRegister(unsigned index) = 0;
|
||||||
|
|
||||||
virtual void plan(UnaryOperation op, unsigned size, uint8_t* typeMask,
|
virtual void plan(UnaryOperation op, unsigned size, uint8_t* typeMask,
|
||||||
uint64_t* registerMask, uintptr_t* procedure);
|
uint64_t* registerMask, uintptr_t* procedure) = 0;
|
||||||
|
|
||||||
virtual void plan(UnaryOperation op, unsigned size, uint8_t* aTypeMask,
|
virtual void plan(BinaryOperation op, unsigned size, uint8_t* aTypeMask,
|
||||||
uint64_t* aRegisterMask, uint8_t* bTypeMask,
|
uint64_t* aRegisterMask, uint8_t* bTypeMask,
|
||||||
uint64_t* bRegisterMask, uintptr_t* procedure);
|
uint64_t* bRegisterMask, uintptr_t* procedure) = 0;
|
||||||
|
|
||||||
virtual void apply(Operation op) = 0;
|
virtual void apply(Operation op) = 0;
|
||||||
|
|
||||||
|
131
src/compile.cpp
131
src/compile.cpp
@ -27,7 +27,7 @@ vmCall();
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const bool Verbose = false;
|
const bool Verbose = true;
|
||||||
const bool DebugNatives = false;
|
const bool DebugNatives = false;
|
||||||
const bool DebugCallTable = false;
|
const bool DebugCallTable = false;
|
||||||
const bool DebugMethodTree = false;
|
const bool DebugMethodTree = false;
|
||||||
@ -463,9 +463,8 @@ class Context {
|
|||||||
thread(t),
|
thread(t),
|
||||||
zone(t->m->system, t->m->heap, 16 * 1024),
|
zone(t->m->system, t->m->heap, 16 * 1024),
|
||||||
assembler(makeAssembler(t->m->system, t->m->heap, &zone)),
|
assembler(makeAssembler(t->m->system, t->m->heap, &zone)),
|
||||||
compiler(makeCompiler(t->m->system, assembler, &zone)),
|
compiler(makeCompiler(t->m->system, assembler, &zone, indirection)),
|
||||||
method(method),
|
method(method),
|
||||||
indirection(indirection),
|
|
||||||
objectPool(0),
|
objectPool(0),
|
||||||
traceLog(0),
|
traceLog(0),
|
||||||
traceLogCount(0),
|
traceLogCount(0),
|
||||||
@ -481,7 +480,6 @@ class Context {
|
|||||||
assembler(makeAssembler(t->m->system, t->m->heap, &zone)),
|
assembler(makeAssembler(t->m->system, t->m->heap, &zone)),
|
||||||
compiler(0),
|
compiler(0),
|
||||||
method(0),
|
method(0),
|
||||||
indirection(0),
|
|
||||||
objectPool(0),
|
objectPool(0),
|
||||||
traceLog(0),
|
traceLog(0),
|
||||||
traceLogCount(0),
|
traceLogCount(0),
|
||||||
@ -501,7 +499,6 @@ class Context {
|
|||||||
Assembler* assembler;
|
Assembler* assembler;
|
||||||
Compiler* compiler;
|
Compiler* compiler;
|
||||||
object method;
|
object method;
|
||||||
void* indirection;
|
|
||||||
PoolElement* objectPool;
|
PoolElement* objectPool;
|
||||||
TraceElement* traceLog;
|
TraceElement* traceLog;
|
||||||
unsigned traceLogCount;
|
unsigned traceLogCount;
|
||||||
@ -1637,7 +1634,6 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target)
|
|||||||
(reinterpret_cast<intptr_t>
|
(reinterpret_cast<intptr_t>
|
||||||
(&singletonBody(t, nativeCompiled(t), 0))),
|
(&singletonBody(t, nativeCompiled(t), 0))),
|
||||||
0,
|
0,
|
||||||
0,
|
|
||||||
frame->trace(target, false),
|
frame->trace(target, false),
|
||||||
rSize,
|
rSize,
|
||||||
0);
|
0);
|
||||||
@ -1646,7 +1642,6 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target)
|
|||||||
(c->constant
|
(c->constant
|
||||||
(reinterpret_cast<intptr_t>
|
(reinterpret_cast<intptr_t>
|
||||||
(&singletonBody(t, defaultCompiled(t), 0))),
|
(&singletonBody(t, defaultCompiled(t), 0))),
|
||||||
0,
|
|
||||||
Compiler::Aligned,
|
Compiler::Aligned,
|
||||||
frame->trace(target, false),
|
frame->trace(target, false),
|
||||||
rSize,
|
rSize,
|
||||||
@ -1657,7 +1652,6 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target)
|
|||||||
(reinterpret_cast<intptr_t>
|
(reinterpret_cast<intptr_t>
|
||||||
(&singletonBody(t, methodCompiled(t, target), 0))),
|
(&singletonBody(t, methodCompiled(t, target), 0))),
|
||||||
0,
|
0,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
rSize,
|
rSize,
|
||||||
0);
|
0);
|
||||||
@ -1687,8 +1681,7 @@ handleMonitorEvent(MyThread* t, Frame* frame, intptr_t function)
|
|||||||
}
|
}
|
||||||
|
|
||||||
c->call(c->constant(function),
|
c->call(c->constant(function),
|
||||||
frame->context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
2, c->thread(), lock);
|
2, c->thread(), lock);
|
||||||
@ -1756,8 +1749,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(gcIfNecessary)),
|
(c->constant(reinterpret_cast<intptr_t>(gcIfNecessary)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
1, c->thread());
|
1, c->thread());
|
||||||
@ -1806,8 +1798,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(throwArrayIndexOutOfBounds)),
|
(c->constant(reinterpret_cast<intptr_t>(throwArrayIndexOutOfBounds)),
|
||||||
context->indirection,
|
Compiler::NoReturn | Compiler::Indirect,
|
||||||
Compiler::NoReturn,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
3, c->thread(), array, index);
|
3, c->thread(), array, index);
|
||||||
@ -1923,8 +1914,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(throwArrayIndexOutOfBounds)),
|
(c->constant(reinterpret_cast<intptr_t>(throwArrayIndexOutOfBounds)),
|
||||||
context->indirection,
|
Compiler::NoReturn | Compiler::Indirect,
|
||||||
Compiler::NoReturn,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
3, c->thread(), array, index);
|
3, c->thread(), array, index);
|
||||||
@ -1950,8 +1940,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case aastore: {
|
case aastore: {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(setMaybeNull)),
|
(c->constant(reinterpret_cast<intptr_t>(setMaybeNull)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
4, c->thread(), array,
|
4, c->thread(), array,
|
||||||
@ -1983,8 +1972,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case aastore: {
|
case aastore: {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(setMaybeNull)),
|
(c->constant(reinterpret_cast<intptr_t>(setMaybeNull)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
4, c->thread(), array,
|
4, c->thread(), array,
|
||||||
@ -2050,8 +2038,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(makeBlankObjectArray)),
|
(c->constant(reinterpret_cast<intptr_t>(makeBlankObjectArray)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
3, c->thread(), frame->append(class_), length));
|
3, c->thread(), frame->append(class_), length));
|
||||||
@ -2091,8 +2078,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case athrow: {
|
case athrow: {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(throw_)),
|
(c->constant(reinterpret_cast<intptr_t>(throw_)),
|
||||||
context->indirection,
|
Compiler::NoReturn | Compiler::Indirect,
|
||||||
Compiler::NoReturn,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
2, c->thread(), frame->popObject());
|
2, c->thread(), frame->popObject());
|
||||||
@ -2113,8 +2099,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(checkCast)),
|
(c->constant(reinterpret_cast<intptr_t>(checkCast)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
3, c->thread(), frame->append(class_), instance);
|
3, c->thread(), frame->append(class_), instance);
|
||||||
@ -2124,21 +2109,21 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(doubleToFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(doubleToFloat)),
|
||||||
context->indirection, 0, 0, 4, 1, frame->popLong()));
|
Compiler::Indirect, 0, 4, 1, frame->popLong()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case d2i: {
|
case d2i: {
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(doubleToInt)),
|
(c->constant(reinterpret_cast<intptr_t>(doubleToInt)),
|
||||||
context->indirection, 0, 0, 4, 1, frame->popLong()));
|
Compiler::Indirect, 0, 4, 1, frame->popLong()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case d2l: {
|
case d2l: {
|
||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(doubleToLong)),
|
(c->constant(reinterpret_cast<intptr_t>(doubleToLong)),
|
||||||
context->indirection, 0, 0, 8, 1, frame->popLong()));
|
Compiler::Indirect, 0, 8, 1, frame->popLong()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dadd: {
|
case dadd: {
|
||||||
@ -2148,7 +2133,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(addDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(addDouble)),
|
||||||
context->indirection, 0, 0, 8, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 8, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dcmpg: {
|
case dcmpg: {
|
||||||
@ -2158,7 +2143,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(compareDoublesG)),
|
(c->constant(reinterpret_cast<intptr_t>(compareDoublesG)),
|
||||||
context->indirection, 0, 0, 4, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 4, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dcmpl: {
|
case dcmpl: {
|
||||||
@ -2168,7 +2153,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(compareDoublesL)),
|
(c->constant(reinterpret_cast<intptr_t>(compareDoublesL)),
|
||||||
context->indirection, 0, 0, 4, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 4, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dconst_0:
|
case dconst_0:
|
||||||
@ -2186,7 +2171,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(divideDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(divideDouble)),
|
||||||
context->indirection, 0, 0, 8, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 8, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dmul: {
|
case dmul: {
|
||||||
@ -2196,14 +2181,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(multiplyDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(multiplyDouble)),
|
||||||
context->indirection, 0, 0, 8, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 8, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dneg: {
|
case dneg: {
|
||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(negateDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(negateDouble)),
|
||||||
context->indirection, 0, 0, 8, 2, 0, frame->popLong()));
|
Compiler::Indirect, 0, 8, 2, 0, frame->popLong()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case vm::drem: {
|
case vm::drem: {
|
||||||
@ -2213,7 +2198,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(moduloDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(moduloDouble)),
|
||||||
context->indirection, 0, 0, 8, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 8, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dsub: {
|
case dsub: {
|
||||||
@ -2223,7 +2208,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(subtractDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(subtractDouble)),
|
||||||
context->indirection, 0, 0, 8, 4, 0, a, 0, b));
|
Compiler::Indirect, 0, 8, 4, 0, a, 0, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dup:
|
case dup:
|
||||||
@ -2254,21 +2239,21 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(floatToDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(floatToDouble)),
|
||||||
context->indirection, 0, 0, 8, 1, frame->popInt()));
|
Compiler::Indirect, 0, 8, 1, frame->popInt()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case f2i: {
|
case f2i: {
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(floatToInt)),
|
(c->constant(reinterpret_cast<intptr_t>(floatToInt)),
|
||||||
context->indirection, 0, 0, 4, 1, frame->popInt()));
|
Compiler::Indirect, 0, 4, 1, frame->popInt()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case f2l: {
|
case f2l: {
|
||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(floatToLong)),
|
(c->constant(reinterpret_cast<intptr_t>(floatToLong)),
|
||||||
context->indirection, 0, 0, 8, 1, frame->popInt()));
|
Compiler::Indirect, 0, 8, 1, frame->popInt()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fadd: {
|
case fadd: {
|
||||||
@ -2278,7 +2263,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(addFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(addFloat)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fcmpg: {
|
case fcmpg: {
|
||||||
@ -2288,7 +2273,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(compareFloatsG)),
|
(c->constant(reinterpret_cast<intptr_t>(compareFloatsG)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fcmpl: {
|
case fcmpl: {
|
||||||
@ -2298,7 +2283,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(compareFloatsL)),
|
(c->constant(reinterpret_cast<intptr_t>(compareFloatsL)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fconst_0:
|
case fconst_0:
|
||||||
@ -2320,7 +2305,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(divideFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(divideFloat)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fmul: {
|
case fmul: {
|
||||||
@ -2330,14 +2315,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(multiplyFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(multiplyFloat)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fneg: {
|
case fneg: {
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(negateFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(negateFloat)),
|
||||||
context->indirection, 0, 0, 4, 1, frame->popInt()));
|
Compiler::Indirect, 0, 4, 1, frame->popInt()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case vm::frem: {
|
case vm::frem: {
|
||||||
@ -2347,7 +2332,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(moduloFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(moduloFloat)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case fsub: {
|
case fsub: {
|
||||||
@ -2357,7 +2342,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(subtractFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(subtractFloat)),
|
||||||
context->indirection, 0, 0, 4, 2, a, b));
|
Compiler::Indirect, 0, 4, 2, a, b));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case getfield:
|
case getfield:
|
||||||
@ -2375,8 +2360,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
{
|
{
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(tryInitClass)),
|
(c->constant(reinterpret_cast<intptr_t>(tryInitClass)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
2, c->thread(), frame->append(fieldClass(t, field)));
|
2, c->thread(), frame->append(fieldClass(t, field)));
|
||||||
@ -2455,14 +2439,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(intToDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(intToDouble)),
|
||||||
context->indirection, 0, 0, 8, 1, frame->popInt()));
|
Compiler::Indirect, 0, 8, 1, frame->popInt()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2f: {
|
case i2f: {
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(intToFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(intToFloat)),
|
||||||
context->indirection, 0, 0, 4, 1, frame->popInt()));
|
Compiler::Indirect, 0, 4, 1, frame->popInt()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2l:
|
case i2l:
|
||||||
@ -2689,7 +2673,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(instanceOf)),
|
(c->constant(reinterpret_cast<intptr_t>(instanceOf)),
|
||||||
context->indirection, 0, 0, 4,
|
Compiler::Indirect, 0, 4,
|
||||||
3, c->thread(), frame->append(class_), frame->popObject()));
|
3, c->thread(), frame->append(class_), frame->popObject()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -2710,14 +2694,12 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
(c->call
|
(c->call
|
||||||
(c->constant
|
(c->constant
|
||||||
(reinterpret_cast<intptr_t>(findInterfaceMethodFromInstance)),
|
(reinterpret_cast<intptr_t>(findInterfaceMethodFromInstance)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
3, c->thread(), frame->append(target),
|
3, c->thread(), frame->append(target),
|
||||||
c->peek(BytesPerWord, instance)),
|
c->peek(BytesPerWord, instance)),
|
||||||
0,
|
0,
|
||||||
0,
|
|
||||||
frame->trace(target, true),
|
frame->trace(target, true),
|
||||||
rSize,
|
rSize,
|
||||||
0);
|
0);
|
||||||
@ -2773,7 +2755,6 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
(BytesPerWord, c->constant(PointerMask),
|
(BytesPerWord, c->constant(PointerMask),
|
||||||
c->memory(instance, 0, 0, 1)), offset, 0, 1),
|
c->memory(instance, 0, 0, 1)), offset, 0, 1),
|
||||||
0,
|
0,
|
||||||
0,
|
|
||||||
frame->trace(target, true),
|
frame->trace(target, true),
|
||||||
rSize,
|
rSize,
|
||||||
0);
|
0);
|
||||||
@ -2885,14 +2866,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(longToDouble)),
|
(c->constant(reinterpret_cast<intptr_t>(longToDouble)),
|
||||||
context->indirection, 0, 0, 8, 1, frame->popLong()));
|
Compiler::Indirect, 0, 8, 1, frame->popLong()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case l2f: {
|
case l2f: {
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(longToFloat)),
|
(c->constant(reinterpret_cast<intptr_t>(longToFloat)),
|
||||||
context->indirection, 0, 0, 4, 1, frame->popLong()));
|
Compiler::Indirect, 0, 4, 1, frame->popLong()));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case l2i:
|
case l2i:
|
||||||
@ -3070,7 +3051,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
c->jmp
|
c->jmp
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(lookUpAddress)),
|
(c->constant(reinterpret_cast<intptr_t>(lookUpAddress)),
|
||||||
context->indirection, 0, 0, BytesPerWord,
|
Compiler::Indirect, 0, BytesPerWord,
|
||||||
4, key, start, c->constant(pairCount), default_));
|
4, key, start, c->constant(pairCount), default_));
|
||||||
|
|
||||||
for (int32_t i = 0; i < pairCount; ++i) {
|
for (int32_t i = 0; i < pairCount; ++i) {
|
||||||
@ -3157,15 +3138,15 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case monitorenter: {
|
case monitorenter: {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(acquireMonitorForObject)),
|
(c->constant(reinterpret_cast<intptr_t>(acquireMonitorForObject)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0, frame->trace(0, false), 0, 2, c->thread(), frame->popObject());
|
frame->trace(0, false), 0, 2, c->thread(), frame->popObject());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case monitorexit: {
|
case monitorexit: {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(releaseMonitorForObject)),
|
(c->constant(reinterpret_cast<intptr_t>(releaseMonitorForObject)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0, frame->trace(0, false), 0, 2, c->thread(), frame->popObject());
|
frame->trace(0, false), 0, 2, c->thread(), frame->popObject());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case multianewarray: {
|
case multianewarray: {
|
||||||
@ -3178,8 +3159,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
Compiler::Operand* result = c->call
|
Compiler::Operand* result = c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(makeMultidimensionalArray)),
|
(c->constant(reinterpret_cast<intptr_t>(makeMultidimensionalArray)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
4, c->thread(), frame->append(class_),
|
4, c->thread(), frame->append(class_),
|
||||||
@ -3199,8 +3179,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(makeNewWeakReference)),
|
(c->constant(reinterpret_cast<intptr_t>(makeNewWeakReference)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
2, c->thread(), frame->append(class_)));
|
2, c->thread(), frame->append(class_)));
|
||||||
@ -3208,8 +3187,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(makeNew)),
|
(c->constant(reinterpret_cast<intptr_t>(makeNew)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
2, c->thread(), frame->append(class_)));
|
2, c->thread(), frame->append(class_)));
|
||||||
@ -3261,8 +3239,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(makeBlankArray)),
|
(c->constant(reinterpret_cast<intptr_t>(makeBlankArray)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
3, c->thread(), c->constant(reinterpret_cast<intptr_t>(constructor)),
|
3, c->thread(), c->constant(reinterpret_cast<intptr_t>(constructor)),
|
||||||
@ -3294,8 +3271,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
{
|
{
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(tryInitClass)),
|
(c->constant(reinterpret_cast<intptr_t>(tryInitClass)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
2, c->thread(), frame->append(fieldClass(t, field)));
|
2, c->thread(), frame->append(fieldClass(t, field)));
|
||||||
@ -3360,15 +3336,14 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
if (instruction == putfield) {
|
if (instruction == putfield) {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(setMaybeNull)),
|
(c->constant(reinterpret_cast<intptr_t>(setMaybeNull)),
|
||||||
context->indirection,
|
Compiler::Indirect,
|
||||||
0,
|
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
0,
|
0,
|
||||||
4, c->thread(), table, c->constant(fieldOffset(t, field)), value);
|
4, c->thread(), table, c->constant(fieldOffset(t, field)), value);
|
||||||
} else {
|
} else {
|
||||||
c->call
|
c->call
|
||||||
(c->constant(reinterpret_cast<intptr_t>(set)),
|
(c->constant(reinterpret_cast<intptr_t>(set)),
|
||||||
context->indirection, 0, 0, 0,
|
Compiler::Indirect, 0, 0,
|
||||||
4, c->thread(), table, c->constant(fieldOffset(t, field)), value);
|
4, c->thread(), table, c->constant(fieldOffset(t, field)), value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3872,7 +3847,7 @@ finish(MyThread* t, Context* context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for debugging:
|
// for debugging:
|
||||||
if (false and
|
if (//false and
|
||||||
strcmp
|
strcmp
|
||||||
(reinterpret_cast<const char*>
|
(reinterpret_cast<const char*>
|
||||||
(&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)),
|
(&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)),
|
||||||
|
227
src/compiler.cpp
227
src/compiler.cpp
@ -154,10 +154,11 @@ class Value: public Compiler::Operand {
|
|||||||
|
|
||||||
class Context {
|
class Context {
|
||||||
public:
|
public:
|
||||||
Context(System* system, Assembler* assembler, Zone* zone):
|
Context(System* system, Assembler* assembler, Zone* zone, void* indirection):
|
||||||
system(system),
|
system(system),
|
||||||
assembler(assembler),
|
assembler(assembler),
|
||||||
zone(zone),
|
zone(zone),
|
||||||
|
indirection(indirection),
|
||||||
logicalIp(-1),
|
logicalIp(-1),
|
||||||
state(new (zone->allocate(sizeof(State))) State(0, 0)),
|
state(new (zone->allocate(sizeof(State))) State(0, 0)),
|
||||||
logicalCode(0),
|
logicalCode(0),
|
||||||
@ -186,6 +187,7 @@ class Context {
|
|||||||
System* system;
|
System* system;
|
||||||
Assembler* assembler;
|
Assembler* assembler;
|
||||||
Zone* zone;
|
Zone* zone;
|
||||||
|
void* indirection;
|
||||||
int logicalIp;
|
int logicalIp;
|
||||||
State* state;
|
State* state;
|
||||||
LogicalInstruction* logicalCode;
|
LogicalInstruction* logicalCode;
|
||||||
@ -628,9 +630,9 @@ matchRegister(Context* c, Site* s, uint64_t mask)
|
|||||||
assert(c, s->type(c) == RegisterOperand);
|
assert(c, s->type(c) == RegisterOperand);
|
||||||
|
|
||||||
RegisterSite* r = static_cast<RegisterSite*>(s);
|
RegisterSite* r = static_cast<RegisterSite*>(s);
|
||||||
return ((static_cast<uint64_t>(1) << r->low) & mask)
|
return ((static_cast<uint64_t>(1) << r->register_.low) & mask)
|
||||||
and (r->high == NoRegister
|
and (r->register_.high == NoRegister
|
||||||
or ((static_cast<uint64_t>(1) << (r->high + 32)) & mask));
|
or ((static_cast<uint64_t>(1) << (r->register_.high + 32)) & mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -641,75 +643,6 @@ match(Context* c, Site* s, uint8_t typeMask, uint64_t registerMask)
|
|||||||
and (t != RegisterOperand or matchRegister(c, s, registerMask));
|
and (t != RegisterOperand or matchRegister(c, s, registerMask));
|
||||||
}
|
}
|
||||||
|
|
||||||
class AbstractSite: public Site {
|
|
||||||
public:
|
|
||||||
AbstractSite(Value* value, uint8_t typeMask, uint64_t registerMask):
|
|
||||||
value(value), registerMask(registerMask), typeMask(typeMask)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
virtual Site* readTarget(Context* c, Read* r, Event*) {
|
|
||||||
if (value) {
|
|
||||||
Site* s = targetOrNull(c, value, event);
|
|
||||||
if (s and match(c, s, typeMask, registerMask)) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Site* site = 0;
|
|
||||||
unsigned copyCost = 0xFFFFFFFF;
|
|
||||||
for (Site* s = r->value->sites; s; s = s->next) {
|
|
||||||
if (match(c, s, typeMask, registerMask)) {
|
|
||||||
unsigned v = s->copyCost(c, 0);
|
|
||||||
if (v < copyCost) {
|
|
||||||
site = s;
|
|
||||||
copyCost = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (site) {
|
|
||||||
return site;
|
|
||||||
} else {
|
|
||||||
return freeRegister(c, r->size, registerMask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual unsigned copyCost(Context* c, Site*) {
|
|
||||||
abort(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void copyTo(Context* c, unsigned, Site*) {
|
|
||||||
abort(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual OperandType type(Context* c) {
|
|
||||||
abort(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Assembler::Operand* asAssemblerOperand(Context* c) {
|
|
||||||
abort(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
Value* value;
|
|
||||||
uint64_t registerMask;
|
|
||||||
uint8_t typeMask;
|
|
||||||
};
|
|
||||||
|
|
||||||
AbstractSite*
|
|
||||||
abstractSite(Context* c, Value* v = 0,
|
|
||||||
uint8_t typeMask = ~static_cast<uint8_t>(0),
|
|
||||||
uint64_t registerMask = ~static_cast<uint64_t>(0))
|
|
||||||
{
|
|
||||||
return new (c->zone->allocate(sizeof(AbstractSite)))
|
|
||||||
AbstractSite(v, typeMask, registerMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractSite*
|
|
||||||
anyRegisterSite(Context* c)
|
|
||||||
{
|
|
||||||
return abstractSite(c, 0, 1 << RegisterOperand, ~static_cast<uint64_t>(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
Site*
|
Site*
|
||||||
targetOrNull(Context* c, Read* r, Event* event)
|
targetOrNull(Context* c, Read* r, Event* event)
|
||||||
{
|
{
|
||||||
@ -735,6 +668,78 @@ targetOrNull(Context* c, Value* v, Event* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AbstractSite: public Site {
|
||||||
|
public:
|
||||||
|
virtual unsigned copyCost(Context* c, Site*) {
|
||||||
|
abort(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void copyTo(Context* c, unsigned, Site*) {
|
||||||
|
abort(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual OperandType type(Context* c) {
|
||||||
|
abort(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Assembler::Operand* asAssemblerOperand(Context* c) {
|
||||||
|
abort(c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class VirtualSite: public AbstractSite {
|
||||||
|
public:
|
||||||
|
VirtualSite(Value* value, uint8_t typeMask, uint64_t registerMask):
|
||||||
|
value(value), registerMask(registerMask), typeMask(typeMask)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual Site* readTarget(Context* c, Read* r, Event* e) {
|
||||||
|
if (value) {
|
||||||
|
Site* s = targetOrNull(c, value, e);
|
||||||
|
if (s and match(c, s, typeMask, registerMask)) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Site* site = 0;
|
||||||
|
unsigned copyCost = 0xFFFFFFFF;
|
||||||
|
for (Site* s = r->value->sites; s; s = s->next) {
|
||||||
|
if (match(c, s, typeMask, registerMask)) {
|
||||||
|
unsigned v = s->copyCost(c, 0);
|
||||||
|
if (v < copyCost) {
|
||||||
|
site = s;
|
||||||
|
copyCost = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (site) {
|
||||||
|
return site;
|
||||||
|
} else {
|
||||||
|
return freeRegister(c, r->size, registerMask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value* value;
|
||||||
|
uint64_t registerMask;
|
||||||
|
uint8_t typeMask;
|
||||||
|
};
|
||||||
|
|
||||||
|
VirtualSite*
|
||||||
|
virtualSite(Context* c, Value* v = 0,
|
||||||
|
uint8_t typeMask = ~static_cast<uint8_t>(0),
|
||||||
|
uint64_t registerMask = ~static_cast<uint64_t>(0))
|
||||||
|
{
|
||||||
|
return new (c->zone->allocate(sizeof(VirtualSite)))
|
||||||
|
VirtualSite(v, typeMask, registerMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
VirtualSite*
|
||||||
|
anyRegisterSite(Context* c)
|
||||||
|
{
|
||||||
|
return virtualSite(c, 0, 1 << RegisterOperand, ~static_cast<uint64_t>(0));
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
used(Context* c, int r)
|
used(Context* c, int r)
|
||||||
{
|
{
|
||||||
@ -1032,12 +1037,11 @@ ignore(Context* c, unsigned count)
|
|||||||
|
|
||||||
class CallEvent: public Event {
|
class CallEvent: public Event {
|
||||||
public:
|
public:
|
||||||
CallEvent(Context* c, Value* address, void* indirection, unsigned flags,
|
CallEvent(Context* c, Value* address, unsigned flags,
|
||||||
TraceHandler* traceHandler, Value* result, unsigned resultSize,
|
TraceHandler* traceHandler, Value* result, unsigned resultSize,
|
||||||
Stack* argumentStack, unsigned argumentCount):
|
Stack* argumentStack, unsigned argumentCount):
|
||||||
Event(c),
|
Event(c),
|
||||||
address(address),
|
address(address),
|
||||||
indirection(indirection),
|
|
||||||
traceHandler(traceHandler),
|
traceHandler(traceHandler),
|
||||||
result(result),
|
result(result),
|
||||||
flags(flags),
|
flags(flags),
|
||||||
@ -1066,7 +1070,8 @@ class CallEvent: public Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addRead(c, address, BytesPerWord,
|
addRead(c, address, BytesPerWord,
|
||||||
(indirection ? registerSite(c, c->assembler->returnLow()) : 0));
|
((flags & Compiler::Indirect) ?
|
||||||
|
registerSite(c, c->assembler->returnLow()) : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void compile(Context* c) {
|
virtual void compile(Context* c) {
|
||||||
@ -1077,9 +1082,9 @@ class CallEvent: public Event {
|
|||||||
pushNow(c, stack);
|
pushNow(c, stack);
|
||||||
|
|
||||||
UnaryOperation type = ((flags & Compiler::Aligned) ? AlignedCall : Call);
|
UnaryOperation type = ((flags & Compiler::Aligned) ? AlignedCall : Call);
|
||||||
if (indirection) {
|
if (flags & Compiler::Indirect) {
|
||||||
apply(c, type, BytesPerWord,
|
apply(c, type, BytesPerWord,
|
||||||
constantSite(c, reinterpret_cast<intptr_t>(indirection)));
|
constantSite(c, reinterpret_cast<intptr_t>(c->indirection)));
|
||||||
} else {
|
} else {
|
||||||
apply(c, type, BytesPerWord, address->source);
|
apply(c, type, BytesPerWord, address->source);
|
||||||
}
|
}
|
||||||
@ -1117,7 +1122,6 @@ class CallEvent: public Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Value* address;
|
Value* address;
|
||||||
void* indirection;
|
|
||||||
TraceHandler* traceHandler;
|
TraceHandler* traceHandler;
|
||||||
Value* result;
|
Value* result;
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
@ -1126,7 +1130,7 @@ class CallEvent: public Event {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
appendCall(Context* c, Value* address, void* indirection, unsigned flags,
|
appendCall(Context* c, Value* address, unsigned flags,
|
||||||
TraceHandler* traceHandler, Value* result, unsigned resultSize,
|
TraceHandler* traceHandler, Value* result, unsigned resultSize,
|
||||||
Stack* argumentStack, unsigned argumentCount)
|
Stack* argumentStack, unsigned argumentCount)
|
||||||
{
|
{
|
||||||
@ -1135,7 +1139,7 @@ appendCall(Context* c, Value* address, void* indirection, unsigned flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
new (c->zone->allocate(sizeof(CallEvent)))
|
new (c->zone->allocate(sizeof(CallEvent)))
|
||||||
CallEvent(c, address, indirection, flags, traceHandler, result,
|
CallEvent(c, address, flags, traceHandler, result,
|
||||||
resultSize, argumentStack, argumentCount);
|
resultSize, argumentStack, argumentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1189,7 +1193,7 @@ class MoveEvent: public Event {
|
|||||||
Value* dst, Site* srcTarget):
|
Value* dst, Site* srcTarget):
|
||||||
Event(c), type(type), size(size), src(src), dst(dst)
|
Event(c), type(type), size(size), src(src), dst(dst)
|
||||||
{
|
{
|
||||||
addRead(c, src, size, target);
|
addRead(c, src, size, srcTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void compile(Context* c) {
|
virtual void compile(Context* c) {
|
||||||
@ -1240,15 +1244,8 @@ appendMove(Context* c, BinaryOperation type, unsigned size, Value* src,
|
|||||||
fprintf(stderr, "appendMove\n");
|
fprintf(stderr, "appendMove\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Site* target;
|
VirtualSite* srcTarget = virtualSite(c, dst);
|
||||||
if (type == Move and size >= BytesPerWord) {
|
VirtualSite* dstTarget = virtualSite(c);
|
||||||
target = moveSite(c, dst);
|
|
||||||
} else {
|
|
||||||
target = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractSite* srcTarget = abstractSite(c, dst);
|
|
||||||
AbstractSite* dstTarget = abstractSite(c);
|
|
||||||
uintptr_t procedure;
|
uintptr_t procedure;
|
||||||
|
|
||||||
c->assembler->plan(type, size,
|
c->assembler->plan(type, size,
|
||||||
@ -1259,7 +1256,7 @@ appendMove(Context* c, BinaryOperation type, unsigned size, Value* src,
|
|||||||
assert(c, procedure == 0); // todo
|
assert(c, procedure == 0); // todo
|
||||||
|
|
||||||
new (c->zone->allocate(sizeof(MoveEvent)))
|
new (c->zone->allocate(sizeof(MoveEvent)))
|
||||||
MoveEvent(c, type, size, src, dst, srcTarget, dstTarget);
|
MoveEvent(c, type, size, src, dst, srcTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CompareEvent: public Event {
|
class CompareEvent: public Event {
|
||||||
@ -1349,12 +1346,18 @@ class CombineEvent: public Event {
|
|||||||
void
|
void
|
||||||
appendStackSync(Context* c);
|
appendStackSync(Context* c);
|
||||||
|
|
||||||
|
Value*
|
||||||
|
value(Context* c, Site* site = 0, Site* target = 0)
|
||||||
|
{
|
||||||
|
return new (c->zone->allocate(sizeof(Value))) Value(site, target);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
appendCombine(Context* c, BinaryOperation type, unsigned size, Value* first,
|
appendCombine(Context* c, BinaryOperation type, unsigned size, Value* first,
|
||||||
Value* second, Value* result)
|
Value* second, Value* result)
|
||||||
{
|
{
|
||||||
AbstractSite* firstTarget = abstractSite(c);
|
VirtualSite* firstTarget = virtualSite(c);
|
||||||
AbstractSite* secondTarget = abstractSite(c, result);
|
VirtualSite* secondTarget = virtualSite(c, result);
|
||||||
uintptr_t procedure;
|
uintptr_t procedure;
|
||||||
|
|
||||||
c->assembler->plan(type, size,
|
c->assembler->plan(type, size,
|
||||||
@ -1363,16 +1366,16 @@ appendCombine(Context* c, BinaryOperation type, unsigned size, Value* first,
|
|||||||
&procedure);
|
&procedure);
|
||||||
|
|
||||||
if (procedure) {
|
if (procedure) {
|
||||||
Stack* oldStack = c.state->stack;
|
Stack* oldStack = c->state->stack;
|
||||||
|
|
||||||
::push(&c, size, second);
|
::push(c, size, second);
|
||||||
::push(&c, size, first);
|
::push(c, size, first);
|
||||||
|
|
||||||
Stack* argumentStack = c.state->stack;
|
Stack* argumentStack = c->state->stack;
|
||||||
c.state->stack = oldStack;
|
c->state->stack = oldStack;
|
||||||
|
|
||||||
Value* result = value(c);
|
Value* result = value(c);
|
||||||
appendCall(&c, constant(c, procedure), Compiler::Indirect,
|
appendCall(c, value(c, constantSite(c, procedure)), Compiler::Indirect,
|
||||||
0, result, size, argumentStack, 2);
|
0, result, size, argumentStack, 2);
|
||||||
} else {
|
} else {
|
||||||
if (DebugAppend) {
|
if (DebugAppend) {
|
||||||
@ -1425,7 +1428,7 @@ appendTranslate(Context* c, UnaryOperation type, unsigned size, Value* value,
|
|||||||
fprintf(stderr, "appendTranslate\n");
|
fprintf(stderr, "appendTranslate\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractSite* target = abstractSite(c, result);
|
VirtualSite* target = virtualSite(c, result);
|
||||||
uintptr_t procedure;
|
uintptr_t procedure;
|
||||||
|
|
||||||
c->assembler->plan
|
c->assembler->plan
|
||||||
@ -1503,12 +1506,6 @@ stack(Context* c, Value* value, unsigned size, unsigned index, Stack* next)
|
|||||||
Stack(value, size, index, next);
|
Stack(value, size, index, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value*
|
|
||||||
value(Context* c, Site* site = 0, Site* target = 0)
|
|
||||||
{
|
|
||||||
return new (c->zone->allocate(sizeof(Value))) Value(site, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
resetStack(Context* c)
|
resetStack(Context* c)
|
||||||
{
|
{
|
||||||
@ -1958,8 +1955,8 @@ class Client: public Assembler::Client {
|
|||||||
public:
|
public:
|
||||||
Client(Context* c): c(c) { }
|
Client(Context* c): c(c) { }
|
||||||
|
|
||||||
virtual int acquireTemporary() {
|
virtual int acquireTemporary(uint32_t mask) {
|
||||||
int r = freeRegister2(c, ~static_cast<uint64_t>(0));
|
int r = freeRegister2(c, mask);
|
||||||
save(r);
|
save(r);
|
||||||
increment(c, r);
|
increment(c, r);
|
||||||
return r;
|
return r;
|
||||||
@ -1991,8 +1988,8 @@ class Client: public Assembler::Client {
|
|||||||
|
|
||||||
class MyCompiler: public Compiler {
|
class MyCompiler: public Compiler {
|
||||||
public:
|
public:
|
||||||
MyCompiler(System* s, Assembler* assembler, Zone* zone):
|
MyCompiler(System* s, Assembler* assembler, Zone* zone, void* indirection):
|
||||||
c(s, assembler, zone), client(&c)
|
c(s, assembler, zone, indirection), client(&c)
|
||||||
{
|
{
|
||||||
assembler->setClient(&client);
|
assembler->setClient(&client);
|
||||||
}
|
}
|
||||||
@ -2194,7 +2191,6 @@ class MyCompiler: public Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* call(Operand* address,
|
virtual Operand* call(Operand* address,
|
||||||
void* indirection,
|
|
||||||
unsigned flags,
|
unsigned flags,
|
||||||
TraceHandler* traceHandler,
|
TraceHandler* traceHandler,
|
||||||
unsigned resultSize,
|
unsigned resultSize,
|
||||||
@ -2240,7 +2236,7 @@ class MyCompiler: public Compiler {
|
|||||||
c.state->stack = oldStack;
|
c.state->stack = oldStack;
|
||||||
|
|
||||||
Value* result = value(&c);
|
Value* result = value(&c);
|
||||||
appendCall(&c, static_cast<Value*>(address), indirection, flags,
|
appendCall(&c, static_cast<Value*>(address), flags,
|
||||||
traceHandler, result, resultSize, argumentStack,
|
traceHandler, result, resultSize, argumentStack,
|
||||||
index);
|
index);
|
||||||
|
|
||||||
@ -2425,10 +2421,11 @@ class MyCompiler: public Compiler {
|
|||||||
namespace vm {
|
namespace vm {
|
||||||
|
|
||||||
Compiler*
|
Compiler*
|
||||||
makeCompiler(System* system, Assembler* assembler, Zone* zone)
|
makeCompiler(System* system, Assembler* assembler, Zone* zone,
|
||||||
|
void* indirection)
|
||||||
{
|
{
|
||||||
return new (zone->allocate(sizeof(MyCompiler)))
|
return new (zone->allocate(sizeof(MyCompiler)))
|
||||||
MyCompiler(system, assembler, zone);
|
MyCompiler(system, assembler, zone, indirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace vm
|
} // namespace vm
|
||||||
|
@ -21,6 +21,7 @@ class Compiler {
|
|||||||
public:
|
public:
|
||||||
static const unsigned Aligned = 1 << 0;
|
static const unsigned Aligned = 1 << 0;
|
||||||
static const unsigned NoReturn = 1 << 1;
|
static const unsigned NoReturn = 1 << 1;
|
||||||
|
static const unsigned Indirect = 1 << 2;
|
||||||
|
|
||||||
class Operand { };
|
class Operand { };
|
||||||
|
|
||||||
@ -67,7 +68,6 @@ class Compiler {
|
|||||||
virtual Operand* peek(unsigned size, unsigned index) = 0;
|
virtual Operand* peek(unsigned size, unsigned index) = 0;
|
||||||
|
|
||||||
virtual Operand* call(Operand* address,
|
virtual Operand* call(Operand* address,
|
||||||
void* indirection,
|
|
||||||
unsigned flags,
|
unsigned flags,
|
||||||
TraceHandler* traceHandler,
|
TraceHandler* traceHandler,
|
||||||
unsigned resultSize,
|
unsigned resultSize,
|
||||||
@ -109,7 +109,8 @@ class Compiler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Compiler*
|
Compiler*
|
||||||
makeCompiler(System* system, Assembler* assembler, Zone* zone);
|
makeCompiler(System* system, Assembler* assembler, Zone* zone,
|
||||||
|
void* indirection);
|
||||||
|
|
||||||
} // namespace vm
|
} // namespace vm
|
||||||
|
|
||||||
|
@ -1089,7 +1089,7 @@ multiplyCR(Context* c, unsigned size, Assembler::Constant* a,
|
|||||||
c->client->acquireTemporary(mask));
|
c->client->acquireTemporary(mask));
|
||||||
|
|
||||||
moveCR(c, size, a, &tmp);
|
moveCR(c, size, a, &tmp);
|
||||||
remainderRR(c, size, &tmp, b);
|
multiplyRR(c, size, &tmp, b);
|
||||||
|
|
||||||
c->client->releaseTemporary(tmp.low);
|
c->client->releaseTemporary(tmp.low);
|
||||||
c->client->releaseTemporary(tmp.high);
|
c->client->releaseTemporary(tmp.high);
|
||||||
@ -1869,7 +1869,7 @@ class MyAssembler: public Assembler {
|
|||||||
*procedure = 0;
|
*procedure = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void plan(UnaryOperation op, unsigned size, uint8_t* aTypeMask,
|
virtual void plan(BinaryOperation op, unsigned size, uint8_t* aTypeMask,
|
||||||
uint64_t* aRegisterMask, uint8_t* bTypeMask,
|
uint64_t* aRegisterMask, uint8_t* bTypeMask,
|
||||||
uint64_t* bRegisterMask, uintptr_t* procedure)
|
uint64_t* bRegisterMask, uintptr_t* procedure)
|
||||||
{
|
{
|
||||||
@ -1928,11 +1928,11 @@ class MyAssembler: public Assembler {
|
|||||||
|
|
||||||
case ShiftLeft:
|
case ShiftLeft:
|
||||||
case ShiftRight:
|
case ShiftRight:
|
||||||
case UnsignedShiftRight:
|
case UnsignedShiftRight: {
|
||||||
*aRegisterMask = static_cast<uint64_t>(1) << rcx;
|
*aRegisterMask = static_cast<uint64_t>(1) << rcx;
|
||||||
const uint32_t mask = ~(1 << rcx);
|
const uint32_t mask = ~(1 << rcx);
|
||||||
*bRegisterMask = (static_cast<uint64_t>(mask) << 32) | mask;
|
*bRegisterMask = (static_cast<uint64_t>(mask) << 32) | mask;
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user