You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2006/10/03 01:27:40 UTC
svn commit: r452261 - in /incubator/harmony/enhanced/drlvm/trunk/vm:
jitrino/src/codegenerator/ jitrino/src/codegenerator/ia32/
jitrino/src/optimizer/ jitrino/src/shared/ jitrino/src/translator/
jitrino/src/translator/java/ port/src/encoder/ia32_em64t/
Author: wjwashburn
Date: Mon Oct 2 16:27:39 2006
New Revision: 452261
URL: http://svn.apache.org/viewvc?view=rev&rev=452261
Log:
HARMONY-1489, magic5.diff commit. Jitrino support for MMTk-style vmmagic functions
Modified:
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ComplexAddrFormLoader.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opnd.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/PrintDotFile.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h
incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h
incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h Mon Oct 2 16:27:39 2006
@@ -166,7 +166,8 @@
InitializeArray,
PseudoCanThrow,
SaveThisState,
- ReadThisState
+ ReadThisState,
+ LockedCompareAndExchange
};
};
@@ -243,6 +244,11 @@
virtual void throwException(CG_OpndHandle* exceptionObj, bool createStackTrace) = 0;
virtual void throwSystemException(CompilationInterface::SystemExceptionId) = 0;
virtual void throwLinkingException(Class_Handle encClass, uint32 cp_ndx, uint32 opcode) = 0;
+
+ /// convert unmanaged pointer to object. Boxing
+ virtual CG_OpndHandle* convUPtrToObject(ObjectType * dstType, CG_OpndHandle* val) = 0;
+ /// convert object or integer to unmanaged pointer. Unboxing
+ virtual CG_OpndHandle* convToUPtr(PtrType * dstType, CG_OpndHandle* op) = 0;
virtual CG_OpndHandle* convToInt(ConvertToIntOp::Types, bool isSigned,
ConvertToIntOp::OverflowMod,
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ComplexAddrFormLoader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ComplexAddrFormLoader.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ComplexAddrFormLoader.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ComplexAddrFormLoader.cpp Mon Oct 2 16:27:39 2006
@@ -108,7 +108,12 @@
}
} else {
if (table.baseOp) {
- memOp->setMemOpndSubOpnd(MemOpndSubOpndKind_Base, table.baseOp);
+ Opnd* origOp = memOp->getMemOpndSubOpnd(MemOpndSubOpndKind_Base);
+ Opnd* replacementOp = table.baseOp;
+ if (origOp->getType()->isUnmanagedPtr() && replacementOp->getType()->isInteger()) {
+ replacementOp->setType(origOp->getType());
+ }
+ memOp->setMemOpndSubOpnd(MemOpndSubOpndKind_Base, replacementOp);
}
if (table.indexOp) {
memOp->setMemOpndSubOpnd(MemOpndSubOpndKind_Index, table.indexOp);
@@ -163,6 +168,11 @@
table.baseCand1 = NULL;
walkThroughOpnds(table);
}
+ } else if (table.baseOp) {
+ table.baseOp = table.suspOp;
+ table.baseCand1 = NULL;
+ table.baseCand2 = NULL;
+ table.dispOp = NULL;
}
return;
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp Mon Oct 2 16:27:39 2006
@@ -163,7 +163,13 @@
inst->unlink();
}
if (opndInfos[i].sourceOpndId != i){
- replacements[i] = irManager->getOpnd(opndInfos[i].sourceOpndId);
+ Opnd* origOpnd= irManager->getOpnd(i);
+ Opnd* replacementOpnd = irManager->getOpnd(opndInfos[i].sourceOpndId);
+ //TODO: extends possible convertions.
+ if (origOpnd->getType()->isUnmanagedPtr() && replacementOpnd->getType()->isInteger()) {
+ replacementOpnd->setType(origOpnd->getType());
+ }
+ replacements[i] = replacementOpnd;
hasReplacements = true;
}
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp Mon Oct 2 16:27:39 2006
@@ -187,6 +187,12 @@
Opnd * const * opnds = inst->getOpnds();
const uint32 * roles = inst->getOpndRoles();
+
+ //emit inst prefix
+ if (inst->getPrefix()!=InstPrefix_Null) {
+ stream = (uint8*)EncoderBase::prefix((char*)stream, inst->getPrefix());
+ }
+
for( int idx=0, n=inst->getOpndCount(); idx<n; idx++ ) {
if (!(roles[idx] & Inst::OpndRole_Explicit)) continue;
const Opnd * p = opnds[idx];
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp Mon Oct 2 16:27:39 2006
@@ -215,6 +215,10 @@
if (mn==Mnemonic_MOVSX){
irManager->newInstEx(Mnemonic_CDQ, 1, dst_2, dst_1)->insertBefore(inst);
inst->unlink();
+ } else {
+ Opnd* zero = irManager->newImmOpnd(irManager->getTypeManager().getInt32Type(), 0);
+ irManager->newInstEx(Mnemonic_MOV, 1, dst_2, zero)->insertBefore(inst);
+ inst->unlink();
}
break;
case Mnemonic_PUSH :
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h Mon Oct 2 16:27:39 2006
@@ -185,6 +185,7 @@
/** Returns the type of the operand */
Type * getType()const{ return type; }
+ void setType(Type* newType) {type = newType; }
/** Returns the constraint of the specified kind sk */
Constraint getConstraint(ConstraintKind ck) const
@@ -435,6 +436,7 @@
Properties_MemoryOpndConditional=0x8,
};
+
/**
* Enum OpndRole defines the role of an operand in an instruction.
* The structure of the enumeration is filter-like allowing to combine its values with '|'.
@@ -442,7 +444,7 @@
* It is important to notice that the role mask consists of two parts
* covered by OpndRole_FromEncoder and OpndRole_ForIterator.
* When used as filter values from each part are virtually combined by "and"
- * meanding that an operand must satisfy filters from both parts.
+ * meaning that an operand must satisfy filters from both parts.
*
* For example OpndRole_Use|OpndRole_Def|OpndRole_Explicit
* will filter explicit operand which are both uses and defs while
@@ -544,6 +546,12 @@
/** Returns the mnemonic of the instruction. */
Mnemonic getMnemonic()const{ return mnemonic; }
+ /** Returns the prefix of the instruction. */
+ InstPrefix getPrefix()const{ return prefix; }
+
+ /** Sets the prefix of the instruction. */
+ void setPrefix(InstPrefix newPrefix){prefix = newPrefix;}
+
/** Returns opcode group description associated with this instruction. */
const Encoder::OpcodeGroup* getOpcodeGroup()const
{ assert(opcodeGroup); return opcodeGroup; }
@@ -760,7 +768,7 @@
static inline void operator delete(void * p) {}
Inst(Mnemonic m, uint32 _id, Form f)
- :kind(Kind_Inst), id(_id), mnemonic(m),
+ :kind(Kind_Inst), id(_id), mnemonic(m), prefix(InstPrefix_Null),
form(f), reservedFlags(0),
opcodeGroup(0), index(0), defOpndCount(0), opndCount(0)
{}
@@ -795,6 +803,7 @@
Kind kind;
uint32 id;
Mnemonic mnemonic;
+ InstPrefix prefix;
uint32 form:1;
uint32 reservedFlags:7;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Mon Oct 2 16:27:39 2006
@@ -294,11 +294,15 @@
OpndSize srcSize=irManager.getTypeSize(srcType);
OpndSize dstSize=irManager.getTypeSize(dstType);
- if (dstSize==srcSize){ // trivial conversion without changing type
- if (dstOpnd==NULL)
+ if (dstSize==srcSize){ // trivial conversion
+ if (dstOpnd==NULL && dstType == srcType) {
dstOpnd=srcOpnd;
- else
+ } else {
+ if (dstOpnd == NULL) {
+ dstOpnd = irManager.newOpnd(dstType);
+ }
copyOpndTrivialOrTruncatingConversion(dstOpnd, srcOpnd);
+ }
}else if (dstSize<=srcSize){ // truncating conversion
if (dstOpnd==NULL)
dstOpnd=irManager.newOpnd(dstType);
@@ -387,6 +391,52 @@
}
//_______________________________________________________________________________________________________________
+Opnd * InstCodeSelector::convertToUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd) {
+ assert(dstType->isUnmanagedPtr());
+ Type* srcType = srcOpnd->getType();
+ if (dstOpnd == NULL) {
+ dstOpnd = irManager.newOpnd(dstType);
+ }
+
+ if (srcType->isObject() || srcType->isInteger()) {
+ appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dstOpnd, srcOpnd));
+ } else {
+ assert(0);
+ }
+ return dstOpnd;
+}
+
+
+//_______________________________________________________________________________________________________________
+Opnd * InstCodeSelector::convertUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd) {
+ Type * srcType=srcOpnd->getType();
+ assert(srcType->isUnmanagedPtr());
+
+ if (dstOpnd == NULL) {
+ dstOpnd = irManager.newOpnd(dstType);
+ }
+
+ if (dstType->isObject()) {
+ appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dstOpnd, srcOpnd));
+ } else {
+ assert(dstType->isInteger());
+ OpndSize srcSize=irManager.getTypeSize(srcType);
+ OpndSize dstSize=irManager.getTypeSize(dstType);
+ if (dstSize<=srcSize) {
+ copyOpndTrivialOrTruncatingConversion(dstOpnd, srcOpnd);
+ } else {
+ assert(dstSize==OpndSize_64);
+#ifdef _EM64T_
+ appendInsts(irManager.newInstEx(srcType->isSignedInteger()?Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
+#else
+ appendInsts(irManager.newI8PseudoInst(srcType->isSignedInteger()?Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
+#endif
+ }
+ }
+ return dstOpnd;
+}
+
+//_______________________________________________________________________________________________________________
Opnd * InstCodeSelector::convert(CG_OpndHandle * oph, Type * dstType, Opnd * dstOpnd)
{
if (!oph)
@@ -399,10 +449,13 @@
if (isIntegerType(dstType)){
dstOpnd=convertIntToInt(srcOpnd, dstType, dstOpnd);
converted=true;
- }else if (dstType->isFP()){
+ } else if (dstType->isFP()){
dstOpnd=convertIntToFp(srcOpnd, dstType, dstOpnd);
converted=true;
- }
+ } else if (dstType->isUnmanagedPtr()) {
+ dstOpnd = convertToUnmanagedPtr(srcOpnd, dstType, dstOpnd);
+ converted = true;
+ }
}else if (srcType->isFP()){
if (dstType->isInteger()){
dstOpnd=convertFpToInt(srcOpnd, dstType, dstOpnd);
@@ -411,6 +464,9 @@
dstOpnd=convertFpToFp(srcOpnd, dstType, dstOpnd);
converted=true;
}
+ } else if (srcType->isUnmanagedPtr() && !dstType->isUnmanagedPtr()) {
+ dstOpnd = convertUnmanagedPtr(srcOpnd, dstType, dstOpnd);
+ converted = true;
}
if (!converted){
@@ -465,6 +521,18 @@
return convert(src, dstType);
}
+//_______________________________________________________________________________________________________________
+// Convert to objects to unmanaged pointers and via versa
+
+/// convert unmanaged pointer to object. Boxing
+CG_OpndHandle* InstCodeSelector::convUPtrToObject(ObjectType * dstType, CG_OpndHandle* val) {
+ return convert(val, dstType);
+}
+
+/// convert object or integer to unmanaged pointer.
+CG_OpndHandle* InstCodeSelector::convToUPtr(PtrType * dstType, CG_OpndHandle* src) {
+ return convert(src, dstType);
+}
//_______________________________________________________________________________________________________________
Opnd * InstCodeSelector::createResultOpnd(Type * dstType)
@@ -1789,9 +1857,11 @@
indexOpnd=convert(indexOpnd, indexType);
Opnd * scaledIndexOpnd=NULL;
- if (indexOpnd->isPlacedIn(OpndKind_Imm)){
- scaledIndexOpnd=irManager.newImmOpnd(indexType, indexOpnd->getImmValue()*elemSize);
- }else{
+ if (indexOpnd->isPlacedIn(OpndKind_Imm)) {
+ scaledIndexOpnd=irManager.newImmOpnd(indexType, indexOpnd->getImmValue() * elemSize);
+ //} else if (elemSize == 1 && ptrType->isUnmanagedPtr()) {
+ // scaledIndexOpnd = indexOpnd;
+ } else {
scaledIndexOpnd=irManager.newOpnd(indexType);
appendInsts(irManager.newInstEx(Mnemonic_IMUL, 1, scaledIndexOpnd, indexOpnd, irManager.newImmOpnd(indexType, elemSize)));
}
@@ -2529,8 +2599,6 @@
#ifdef PLATFORM_POSIX
// Not supported
assert(0);
- // Not supported
- assert(0);
#else // PLATFORM_POSIX
// TLS base can be obtained from [fs:0x14]
Opnd * tlsBaseReg = irManager.newOpnd(typeManager.getUnmanagedPtrType(typeManager.getInt32Type()));
@@ -2552,6 +2620,28 @@
irManager.newImmOpnd(typeManager.getInt32Type(),1)));
#endif
+ break;
+ }
+ case LockedCompareAndExchange:
+ {
+ assert(numArgs == 3);
+ Opnd** opnds = (Opnd**)args;
+
+ //deal with constraints
+ Opnd* eaxOpnd = irManager.getRegOpnd(RegName_EAX);
+ Opnd* ecxOpnd = irManager.getRegOpnd(RegName_ECX);
+ Opnd* memOpnd = irManager.newMemOpnd(opnds[0]->getType(), opnds[0]);
+
+ appendInsts(irManager.newInst(Mnemonic_MOV, eaxOpnd, opnds[1]));
+ appendInsts(irManager.newInst(Mnemonic_MOV, ecxOpnd, opnds[2]));
+
+ Inst* inst = irManager.newInst(Mnemonic_CMPXCHG, memOpnd, ecxOpnd, eaxOpnd);
+ inst->setPrefix(InstPrefix_LOCK);
+ appendInsts(inst);
+
+ //save the result
+ appendInsts(irManager.newInst(Mnemonic_MOV, dstOpnd, irManager.newImmOpnd(typeManager.getInt32Type(), 0)));
+ appendInsts(irManager.newInst(Mnemonic_SETZ, dstOpnd));
break;
}
default:
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h Mon Oct 2 16:27:39 2006
@@ -117,6 +117,10 @@
ConvertToIntOp::OverflowMod,Type* dstType, CG_OpndHandle* src);
CG_OpndHandle* convToFp(ConvertToFpOp::Types, Type* dstType, CG_OpndHandle* src);
+ /// convert unmanaged pointer to object. Boxing
+ CG_OpndHandle* convUPtrToObject(ObjectType * dstType, CG_OpndHandle* val);
+ /// convert object or integer to unmanaged pointer.
+ CG_OpndHandle* convToUPtr(PtrType * dstType, CG_OpndHandle* src);
CG_OpndHandle* ldc_i4(uint32 val);
@@ -310,7 +314,9 @@
Opnd * convertIntToFp(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
Opnd * convertFpToInt(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
Opnd * convertFpToFp(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
-
+ Opnd* convertUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
+ Opnd* convertToUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
+
bool isIntegerType(Type * type)
{ return type->isInteger()||type->isBoolean()||type->isChar(); }
void copyOpnd(Opnd *dst, Opnd *src);
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Printer.cpp Mon Oct 2 16:27:39 2006
@@ -898,7 +898,6 @@
<< "nodesep=\".20\";" << ::std::endl
<< "page=\"200,260\";" << ::std::endl
<< "ratio=auto;" << ::std::endl
- << "fontpath=\"c:\\winnt\\fonts\";" << ::std::endl
<< "node [shape=record,fontname=\"Courier\",fontsize=9];" << ::std::endl
<< "edge [minlen=2];" << ::std::endl
<< "label=\""
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp Mon Oct 2 16:27:39 2006
@@ -139,6 +139,7 @@
return ArithmeticOp::I8_Ovf;
return ArithmeticOp::U8_Ovf;
case Type::IntPtr:
+ case Type::UIntPtr:
if ((modifier == Overflow_None) || (excModifier == Exception_Never))
return ArithmeticOp::I;
if (modifier == Overflow_Signed)
@@ -296,6 +297,7 @@
case Type::Int64:
return IntegerOp::I8;
case Type::IntPtr:
+ case Type::UIntPtr:
return IntegerOp::I;
default: assert(0);
}
@@ -313,6 +315,7 @@
case Type::Int64:
return CompareOp::I8;
case Type::IntPtr:
+ case Type::UIntPtr:
return CompareOp::I;
case Type::Float:
return CompareOp::F;
@@ -436,6 +439,7 @@
case PseudoCanThrow: return JitHelperCallOp::PseudoCanThrow;
case SaveThisState: return JitHelperCallOp::SaveThisState;
case ReadThisState: return JitHelperCallOp::ReadThisState;
+ case LockedCompareAndExchange: return JitHelperCallOp::LockedCompareAndExchange;
}
assert(0);
return JitHelperCallOp::InitializeArray; // to keep compiler quiet
@@ -646,8 +650,11 @@
cgInst = instructionCallback.convToFp(mapToFpConvertOpType(inst),
dstType,
getCGInst(inst->getSrc(0)));
- }
- else {
+ } else if (dstType->isObject()){
+ cgInst = instructionCallback.convUPtrToObject((ObjectType*)dstType, getCGInst(inst->getSrc(0)));
+ } else if (dstType->isUnmanagedPtr()) {
+ cgInst = instructionCallback.convToUPtr((PtrType*)dstType, getCGInst(inst->getSrc(0)));
+ } else {
bool isSigned = Type::isSignedInteger(inst->getType());
cgInst = instructionCallback.convToInt(mapToIntConvertOpType(inst),
isSigned,
@@ -991,6 +998,9 @@
if (!genConsts) break;
ConstInst* constInst = (ConstInst*)inst;
switch (inst->getType()) {
+ case Type::UIntPtr://mfursov todo!
+ case Type::IntPtr://mfursov todo!
+ case Type::UnmanagedPtr://mfursov todo!
case Type::Int32:
cgInst = instructionCallback.ldc_i4(constInst->getValue().i4);
break;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Mon Oct 2 16:27:39 2006
@@ -373,6 +373,8 @@
os << (unsigned long)value.i8;
break;
case Type::IntPtr:
+ case Type::UIntPtr:
+ case Type::UnmanagedPtr:
os << value.i;
break;
case Type::Single:
@@ -458,6 +460,8 @@
os << "SaveThisState"; break;
case ReadThisState:
os << "ReadThisState"; break;
+ case LockedCompareAndExchange:
+ os << "LockedCmpExchange"; break;
default:
assert(0); break;
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h Mon Oct 2 16:27:39 2006
@@ -271,7 +271,8 @@
InitializeArray,
PseudoCanThrow,
SaveThisState,
- ReadThisState
+ ReadThisState,
+ LockedCompareAndExchange
};
enum VMHelperCallId {
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opnd.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opnd.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opnd.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opnd.cpp Mon Oct 2 16:27:39 2006
@@ -140,7 +140,8 @@
return typeManager.getInt32Type();
case Type::IntPtr: case Type::UIntPtr:
- return typeManager.getIntPtrType();
+ return ldType;
+ //return typeManager.getIntPtrType();
case Type::Int64: case Type::UInt64:
return typeManager.getInt64Type();
@@ -171,7 +172,7 @@
}
return ldType;
case Type::UnmanagedPtr:
- return typeManager.getIntPtrType();
+ //return typeManager.getIntPtrType();
case Type::ManagedPtr: // Managed ptr is valid only for ldvar or ldarg
case Type::TypedReference: // TypedReference is valid only for ldvar or ldarg
return ldType;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp Mon Oct 2 16:27:39 2006
@@ -669,6 +669,7 @@
case PseudoCanThrow:
case SaveThisState:
case ReadThisState:
+ case LockedCompareAndExchange:
break;
default:
assert(0);
@@ -1274,7 +1275,7 @@
Type *eltType = NULL;
Opnd *thePtr = addri->getSrc(0);
Type *theType = thePtr->getType();
- if (theType->isManagedPtr()) {
+ if (theType->isManagedPtr() || theType->isUnmanagedPtr()) {
PtrType *thePtrType = (PtrType *) theType;
eltType = thePtrType->getPointedToType();
} else {
@@ -1387,6 +1388,12 @@
case Op_LdVarAddr:
case Op_Phi:
break;
+ case Op_Conv: //the result of a conversion
+ case Op_TauLdInd: // the result of static field load
+ {
+ assert(addr->getType()->isUnmanagedPtr());
+ break;
+ }
default:
assert(0);
break;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/PrintDotFile.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/PrintDotFile.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/PrintDotFile.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/PrintDotFile.cpp Mon Oct 2 16:27:39 2006
@@ -121,7 +121,6 @@
void PrintDotFile::printDotHeader(MethodDesc& mh) {
*os << "digraph dotgraph {" << ::std::endl
- << "fontpath=\"c:\\winnt\\fonts\";" << ::std::endl
<< "node [shape=record,fontname=\"Courier\",fontsize=9];" << ::std::endl
<< "label=\""
<< mh.getParentType()->getName()
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp Mon Oct 2 16:27:39 2006
@@ -134,6 +134,7 @@
case Type::NullObject:
case Type::Array:
case Type::Object:
+ case Type::UnmanagedPtr:
case Type::ManagedPtr:
case Type::CompressedSystemObject:
case Type::CompressedSystemClass:
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.cpp Mon Oct 2 16:27:39 2006
@@ -88,11 +88,9 @@
" guardedInlining[={on|OFF}] - do guarded inlining during translation\n"\
" genCharArrayCopy[={on|off}] - generate intrinsic calls to char array copy\n"\
" genArrayCopy[={ON|off}] - inline java/lang/System::arraycopy call\n"\
- " useMagicMethods[={MagicClass name}] - use magic methods with magic class named MagicClass\n"\
" balancedSync[={on|OFF}] - treat all synchronization as balanced\n"\
" ignoreSync[={on|OFF}] - do not generate synchronization\n"\
" syncAsEnterFence[={on|OFF}] - implement synchronization as monitor enter fence\n"\
- " magicMinMaxAbs[={on|OFF}] - treat java/lang/Math::min and max as magic\n"\
" genMinMaxAbs[={on|OFF}] - use special opcodes for Min/Max/Abs\n"\
" genFMinMaxAbs[={on|OFF}] - also use opcodes for float Min/Max/Abs\n";
@@ -127,7 +125,6 @@
flags.inlineMethods = getBoolArg("inlineMethods", false);
flags.guardedInlining = getBoolArg("guardedInlining", false);
- flags.magicMinMaxAbs = getBoolArg("magicMinMaxAbs", false);
flags.genMinMaxAbs = getBoolArg("genMinMaxAbs", false);
flags.genFMinMaxAbs = getBoolArg("genFMinMaxAbs", false);
@@ -138,7 +135,6 @@
flags.inlineSkipTable = new Method_Table(strdup(skipMethods), "SKIP_METHODS", true);
}
- flags.magicClass=(char *)getStringArg("useMagicMethods", NULL);
}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/TranslatorIntfc.h Mon Oct 2 16:27:39 2006
@@ -58,12 +58,10 @@
bool ignoreSync : 1; // do not generate monitor enter/exit instructions
bool syncAsEnterFence : 1; // implement monitor enter as enter fence and
bool newCatchHandling : 1; // use fix for catch handler ordering problem
- bool magicMinMaxAbs : 1; // recognize, e.g., java/lang/Math.min/max/abs
bool genMinMaxAbs : 1; // gen min/max/abs opcodes instead of using select
bool genFMinMaxAbs : 1; // gen min/max/abs opcodes for floats
bool optArrayInit : 1; // skip array initializers from optimizations
Method_Table* inlineSkipTable; // do not inline these methods
- char *magicClass; // Name of the MagicClass. NULL if no class specified.
};
class IRBuilderAction;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Mon Oct 2 16:27:39 2006
@@ -38,6 +38,54 @@
namespace Jitrino {
+
+static bool isMagicClass(Type* type) {
+#ifdef _EM64T_
+ return false;//magics are not supported on EM64T today.
+#endif
+ static const char unboxedName[] = "org/vmmagic/unboxed/";
+ static const unsigned nameLen = sizeof(unboxedName)-1;
+ const char* name = type->getName();
+ return !strncmp(name, unboxedName, nameLen);
+}
+
+static bool isMagicMethod(MethodDesc* md) {
+ return isMagicClass(md->getParentType());
+}
+
+Type* convertMagicType2HIR(TypeManager& tm, Type* type) {
+ if (!type->isObject() || !type->isNamedType()) {
+ return type;
+ }
+ assert(isMagicClass(type));
+ const char* name = type->getName();
+ if (!strcmp(name, "org/vmmagic/unboxed/Address")
+ || !strcmp(name, "org/vmmagic/unboxed/ObjectReference"))
+ {
+ return tm.getUnmanagedPtrType(tm.getInt8Type());
+ } else if (!strcmp(name, "org/vmmagic/unboxed/Word")
+ || !strcmp(name, "org/vmmagic/unboxed/Offset")
+ || !strcmp(name, "org/vmmagic/unboxed/Extent"))
+ {
+ return tm.getUIntPtrType();
+ } else if (!strcmp(name, "org/vmmagic/unboxed/WordArray")
+ || !strcmp(name, "org/vmmagic/unboxed/OffsetArray")
+ || !strcmp(name, "org/vmmagic/unboxed/ExtentArray")
+ || !strcmp(name, "org/vmmagic/unboxed/AddressArray")
+ || !strcmp(name, "org/vmmagic/unboxed/ObjectReferenceArray"))
+ {
+#ifdef _EM64T_
+ return tm.getArrayType(tm.getInt64Type(), false);
+#else
+ return tm.getArrayType(tm.getInt32Type(), false);
+#endif
+ }
+ assert(0);
+ return NULL;
+}
+
+
+
//-----------------------------------------------------------------------------
// inlining policy management
//-----------------------------------------------------------------------------
@@ -1000,6 +1048,9 @@
if (field && field->isStatic()) {
Type* fieldType = getFieldType(field,constPoolIndex);
assert(fieldType);
+ if (isMagicClass(fieldType)) {
+ fieldType = convertMagicType2HIR(typeManager, fieldType);
+ }
pushOpnd(irBuilder.genLdStatic(fieldType,field));
return;
}
@@ -1028,6 +1079,9 @@
if (field && !field->isStatic()) {
Type* fieldType = getFieldType(field,constPoolIndex);
assert(fieldType);
+ if (isMagicClass(fieldType)) {
+ fieldType = convertMagicType2HIR(typeManager, fieldType);
+ }
pushOpnd(irBuilder.genLdField(fieldType,popOpnd(),field));
return;
}
@@ -1724,6 +1778,10 @@
uint32 numArgs = methodSig->getNumParams();
Type* returnType = methodSig->getReturnType();
+ if (isMagicClass(methodDesc->getParentType())) {
+ genMagic(methodDesc, numArgs, srcOpnds, returnType);
+ return;
+ }
// callvirt can throw a null pointer exception
Opnd *tauNullChecked = irBuilder.genTauCheckNull(srcOpnds[0]);
Opnd* thisOpnd = srcOpnds[0];
@@ -2577,42 +2635,9 @@
Type * returnType) {
Opnd *dst;
- if ( (translationFlags.magicClass != NULL) &&
- strcmp(methodDesc->getParentType()->getName(),translationFlags.magicClass)==0) {
-
- const char *methodName = methodDesc->getName();
- if (strcmp(methodName,"add")==0) {
- pushOpnd(irBuilder.genAdd(returnType,Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No),
- srcOpnds[0],srcOpnds[1]));
- return;
- }
- if (strncmp(methodName,"prefetch",8)==0) {
- assert(numArgs == 3);
- assert(returnType->isVoid());
- irBuilder.genPrefetch(srcOpnds[0],srcOpnds[1],srcOpnds[2]);
- return;
- }
- if (strncmp(methodName,"loadField",9)==0) {
- NamedType *fieldType = (NamedType *)returnType;
- int index = ((ConstInst*)srcOpnds[1]->getInst())->getValue().i4;
- FieldDesc *fd = compilationInterface.resolveFieldByIndex(
- (NamedType*)srcOpnds[0]->getType(),index,&fieldType);
- pushOpnd (irBuilder.genLdField(returnType,srcOpnds[0],fd));
- return;
- }
- if (strncmp(methodName,"loadElement",11)==0) {
- Type *type = srcOpnds[0]->getType();
- assert(type->isArrayType());
- pushOpnd(irBuilder.genLdElem(
- ((ArrayType*)type)->getElementType(),srcOpnds[0],srcOpnds[1]));
- return;
- }
- if (strncmp(methodName,"distance",8)==0) {
- pushOpnd(irBuilder.genSub(returnType,Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No),
- srcOpnds[0],srcOpnds[1]));
- return;
- }
- ::std::cerr << "Unknown Magic " << methodName << ::std::endl;
+ if (isMagicMethod(methodDesc)) {
+ genMagic(methodDesc, numArgs, srcOpnds, returnType);
+ return;
}
if (inlineMethod(methodDesc)) {
if(Log::isEnabled()) {
@@ -3430,6 +3455,216 @@
return 0;
}
return off - offset;
+}
+
+void JavaByteCodeTranslator::genMagic(MethodDesc *md, uint32 numArgs, Opnd **srcOpnds, Type *magicRetType) {
+ const char* mname = md->getName();
+ Type* resType = convertMagicType2HIR(typeManager, magicRetType);
+ Opnd* tauSafe = irBuilder.genTauSafe();
+ Opnd* arg0 = numArgs > 0 ? srcOpnds[0]: NULL;
+ Opnd* arg1 = numArgs > 1 ? srcOpnds[1]: NULL;
+ Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
+
+
+ // max, one, zero
+ int theConst = 0;
+ bool loadConst = false;
+ if (!strcmp(mname, "max")) { loadConst = true; theConst = -1;}
+ else if (!strcmp(mname, "one")) { loadConst = true; theConst = 1;}
+ else if (!strcmp(mname, "zero")) { loadConst = true; theConst = 0;}
+ else if (!strcmp(mname, "nullReference")) { loadConst = true; theConst = 0;}
+ if (loadConst) {
+ //todo: recheck and fix the type of the const:
+ ConstInst::ConstValue v; v.i4 = theConst;
+ Opnd* res = irBuilder.genLdConstant(typeManager.getUIntPtrType(), v);//todo:clean typing
+ if (resType->isPtr()) {
+ res = irBuilder.genConv(resType, resType->tag, mod, res);
+ }
+ pushOpnd(res);
+ return;
+ }
+
+ //
+ // fromXXX, toXXX - static creation from something
+ //
+ if (!strcmp(mname, "fromInt")
+ || !strcmp(mname, "fromIntSignExtend")
+ || !strcmp(mname, "fromIntZeroExtend")
+ || !strcmp(mname, "fromObject")
+ || !strcmp(mname, "toAddress")
+ || !strcmp(mname, "toObjectReference")
+ || !strcmp(mname, "toInt")
+ || !strcmp(mname, "toLong")
+ || !strcmp(mname, "toObjectRef")
+ || !strcmp(mname, "toWord")
+ || !strcmp(mname, "toAddress")
+ || !strcmp(mname, "toObject")
+ || !strcmp(mname, "toExtent")
+ || !strcmp(mname, "toOffset"))
+ {
+ assert(numArgs == 1);
+ if (resType == arg0->getType()) {
+ pushOpnd(irBuilder.genCopy(arg0));
+ return;
+ }
+ Opnd* res = irBuilder.genConv(resType, resType->tag, mod, arg0);
+ pushOpnd(res);
+ return;
+ }
+
+ //
+ // is<Smth> one arg testing
+ //
+ bool isOp = false;
+ if (!strcmp(mname, "isZero")) { isOp = true; theConst = 0; }
+ else if (!strcmp(mname, "isMax")) { isOp = true; theConst = ~0; }
+ else if (!strcmp(mname, "isNull")) { isOp = true; theConst = 0; }
+ if (isOp) {
+ assert(numArgs == 1);
+ Opnd* res = irBuilder.genCmp(typeManager.getInt32Type(), Type::Int32, Cmp_EQ, arg0, irBuilder.genLdConstant(theConst));
+ pushOpnd(res);
+ return;
+ }
+
+
+ //
+ // EQ, GE, GT, LE, LT, sXX - 2 args compare
+ //
+ ComparisonModifier cm = Cmp_Mask;
+ bool commuteOpnds=false;
+ if (!strcmp(mname, "EQ")) { cm = Cmp_EQ; }
+ else if (!strcmp(mname, "equals")) { cm = Cmp_EQ; }
+ else if (!strcmp(mname, "NE")) { cm = Cmp_NE_Un; }
+ else if (!strcmp(mname, "GE")) { cm = Cmp_GTE;}
+ else if (!strcmp(mname, "GT")) { cm = Cmp_GT; }
+ else if (!strcmp(mname, "LE")) { cm = Cmp_GTE; commuteOpnds = true;}
+ else if (!strcmp(mname, "LT")) { cm = Cmp_GT; commuteOpnds = true;}
+ if (cm!=Cmp_Mask) {
+ assert(numArgs == 2);
+ assert(arg0->getType() == arg1->getType());
+ Opnd* op0 = commuteOpnds ? arg1 : arg0;
+ Opnd* op1 = commuteOpnds ? arg0 : arg1;
+ Opnd* res = irBuilder.genCmp(typeManager.getInt32Type(), Type::Int32, cm, op0, op1);
+ pushOpnd(res);
+ return;
+ }
+
+
+ //
+ // plus, minus, xor, or, and ... etc - 1,2 args arithmetics
+ //
+ if (!strcmp(mname, "plus")) {
+ assert(numArgs==2);
+ if (resType->isPtr()) {
+ pushOpnd(irBuilder.genAddScaledIndex(arg0, arg1));
+ } else {
+ pushOpnd(irBuilder.genAdd(resType, mod, arg0, arg1));
+ }
+ return;
+ }
+ if (!strcmp(mname, "minus")){
+ assert(numArgs==2);
+ if (resType->isPtr()) {
+ Opnd* negArg1 = irBuilder.genNeg(typeManager.getInt32Type(), arg1);
+ pushOpnd(irBuilder.genAddScaledIndex(arg0, negArg1));
+ } else {
+ pushOpnd(irBuilder.genSub(resType, mod, arg0, arg1));
+ }
+ return;
+ }
+ if (!strcmp(mname, "or")) { assert(numArgs==2); pushOpnd(irBuilder.genOr (resType, arg0, arg1)); return;}
+ if (!strcmp(mname, "xor")) { assert(numArgs==2); pushOpnd(irBuilder.genXor(resType, arg0, arg1)); return;}
+ if (!strcmp(mname, "and")) { assert(numArgs==2); pushOpnd(irBuilder.genAnd(resType, arg0, arg1)); return;}
+ if (!strcmp(mname, "not")) { assert(numArgs==1); pushOpnd(irBuilder.genNot(resType, arg0)); return;}
+ if (!strcmp(mname, "diff")) { assert(numArgs==2); pushOpnd(irBuilder.genSub(resType, mod, arg0, arg1)); return;}
+
+
+ //
+ // shifts
+ //
+ Modifier shMod(ShiftMask_Masked);
+ if (!strcmp(mname, "lsh")) {assert(numArgs==2); pushOpnd(irBuilder.genShl(resType, shMod|SignedOp, arg0, arg1)); return;}
+ else if (!strcmp(mname, "rsha")){assert(numArgs==2); pushOpnd(irBuilder.genShr(resType, shMod|SignedOp, arg0, arg1)); return;}
+ else if (!strcmp(mname, "rshl")){assert(numArgs==2); pushOpnd(irBuilder.genShr(resType, shMod |UnsignedOp, arg0, arg1)); return;}
+
+
+ //
+ // loadXYZ.. prepareXYZ..
+ //
+ if (!strcmp(mname, "loadObjectReference")
+ || !strcmp(mname, "loadAddress")
+ || !strcmp(mname, "loadWord")
+ || !strcmp(mname, "loadByte")
+ || !strcmp(mname, "loadChar")
+ || !strcmp(mname, "loadDouble")
+ || !strcmp(mname, "loadFloat")
+ || !strcmp(mname, "loadInt")
+ || !strcmp(mname, "loadLong")
+ || !strcmp(mname, "loadShort")
+ || !strcmp(mname, "prepareWord")
+ || !strcmp(mname, "prepareObjectReference")
+ || !strcmp(mname, "prepareAddress")
+ || !strcmp(mname, "prepareInt"))
+ {
+ assert(numArgs == 1 || numArgs == 2);
+ Opnd* effectiveAddress = arg0;
+ if (numArgs == 2) {//load by offset
+ effectiveAddress = irBuilder.genAddScaledIndex(arg0, arg1);
+ }
+ Opnd* res = irBuilder.genTauLdInd(AutoCompress_No, resType, resType->tag, effectiveAddress, tauSafe, tauSafe);
+ pushOpnd(res);
+ return;
+ }
+
+ //
+ // store(XYZ)
+ //
+ if (!strcmp(mname, "store")) {
+ assert(numArgs==2 || numArgs == 3);
+ Opnd* effectiveAddress = arg0;
+ if (numArgs == 3) { // store by offset
+ effectiveAddress = irBuilder.genAddScaledIndex(arg0, srcOpnds[2]);
+ }
+ irBuilder.genTauStInd(arg1->getType(), effectiveAddress, arg1, tauSafe, tauSafe, tauSafe);
+ return;
+ }
+
+ if (!strcmp(mname, "attempt")) {
+ assert(numArgs == 3 || numArgs == 4);
+ Opnd* effectiveAddress = arg0;
+ if (numArgs == 4) { // offset opnd
+ effectiveAddress = irBuilder.genAddScaledIndex(arg0, srcOpnds[3]);
+ }
+ Opnd* opnds[3] = {effectiveAddress, arg1, srcOpnds[2]};
+ Opnd* res = irBuilder.genJitHelperCall(LockedCompareAndExchange, resType, 3, opnds);
+ pushOpnd(res);
+ return;
+ }
+
+ //
+ //Arrays
+ //
+ if (!strcmp(mname, "create")) { assert(numArgs==1); pushOpnd(irBuilder.genNewArray(resType->asNamedType(),arg0)); return;}
+ if (!strcmp(mname, "set")) {
+ assert(numArgs == 3);
+ Opnd* arg2 = srcOpnds[2];
+ Type* opType = convertMagicType2HIR(typeManager, arg2->getType());
+ irBuilder.genStElem(opType, arg0, arg1, arg2, tauSafe, tauSafe, tauSafe);
+ return;
+ }
+ if (!strcmp(mname, "get")) {
+ assert(numArgs == 2);
+ Opnd* res = irBuilder.genLdElem(resType, arg0, arg1, tauSafe, tauSafe);
+ pushOpnd(res);
+ return;
+ }
+ if (!strcmp(mname, "length")) {
+ pushOpnd(irBuilder.genArrayLen(typeManager.getInt32Type(), Type::Int32, arg0));
+ return;
+ }
+
+ assert(0);
+ return;
}
} //namespace Jitrino
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h Mon Oct 2 16:27:39 2006
@@ -315,7 +315,8 @@
bool guardedInlineMethod(MethodDesc* methodDesc);
bool needsReturnLabel(uint32 off);
void genInvokeStatic(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds,Type * returnType);
-
+ void genMagic(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds,Type * returnType);
+
bool genCharArrayCopy(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds, Type * returnType);
bool genArrayCopy(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds, Type * returnType);
bool genMinMax(MethodDesc * methodDesc,uint32 numArgs,Opnd ** srcOpnds, Type * returnType);
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h Mon Oct 2 16:27:39 2006
@@ -98,6 +98,7 @@
#define DU_U {2, 1, 2, ((OpndRole_Def|OpndRole_Use)<<2 | OpndRole_Use) }
#define DU_DU {2, 2, 2, ((OpndRole_Def|OpndRole_Use)<<2 | (OpndRole_Def|OpndRole_Use)) }
+#define DU_DU_DU {3, 3, 3, ((OpndRole_Def|OpndRole_Use)<<4) | ((OpndRole_Def|OpndRole_Use)<<2) | (OpndRole_Def|OpndRole_Use) }
#define DU_DU_U {3, 2, 3, (((OpndRole_Def|OpndRole_Use)<<4) | ((OpndRole_Def|OpndRole_Use)<<2) | OpndRole_Use) }
#define D_DU_U {3, 2, 2, (((OpndRole_Def)<<4) | ((OpndRole_Def|OpndRole_Use)<<2) | OpndRole_Use) }
#define D_U_U {3, 1, 2, (((OpndRole_Def)<<4) | ((OpndRole_Use)<<2) | OpndRole_Use) }
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp Mon Oct 2 16:27:39 2006
@@ -411,12 +411,12 @@
END_OPCODES()
END_MNEMONIC()
-BEGIN_MNEMONIC(CMPXCHG, MF_NONE, DU_DU )
+BEGIN_MNEMONIC(CMPXCHG, MF_AFFECTS_FLAGS, N)
BEGIN_OPCODES()
- {OpcodeInfo::all, {0x0F, 0xB0, _r}, {r_m8, r8}, DU_DU },
- {OpcodeInfo::all, {Size16, 0x0F, 0xB1, _r}, {r_m16, r16}, DU_DU },
- {OpcodeInfo::all, {0x0F, 0xB1, _r}, {r_m32, r32}, DU_DU },
- {OpcodeInfo::em64t, {REX_W, 0x0F, 0xB1, _r},{r_m64, r64}, DU_DU },
+ {OpcodeInfo::all, {0x0F, 0xB0, _r}, {r_m8, r8, AL}, DU_DU_DU },
+ {OpcodeInfo::all, {Size16, 0x0F, 0xB1, _r}, {r_m16, r16, AX}, DU_DU_DU },
+ {OpcodeInfo::all, {0x0F, 0xB1, _r}, {r_m32, r32, EAX}, DU_DU_DU},
+ {OpcodeInfo::em64t, {REX_W, 0x0F, 0xB1, _r},{r_m64, r64, RAX}, DU_DU_DU },
END_OPCODES()
END_MNEMONIC()
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl?view=diff&rev=452261&r1=452260&r2=452261
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl Mon Oct 2 16:27:39 2006
@@ -129,6 +129,8 @@
EncoderBase::Operands args;
add_rm(args, rm, sz);
add_r(args, r, sz);
+ RegName implicitReg = getAliasReg(RegName_EAX, map_size(sz));
+ args.add(implicitReg);
return (char*)EncoderBase::encode(stream, Mnemonic_CMPXCHG, args);
}