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/12/13 05:56:12 UTC
svn commit: r486493 - in /harmony/enhanced/drlvm/trunk: build/make/
build/make/components/vm/ vm/em/src/ vm/gc_cc/src/ vm/jitrino/config/ia32/
vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/optimizer/
vm/jitrino/src/shared/ vm/jitrino/src/translator...
Author: wjwashburn
Date: Tue Dec 12 20:56:10 2006
New Revision: 486493
URL: http://svn.apache.org/viewvc?view=rev&rev=486493
Log:
Harmony-2500, monenter helper inlining support
build, build test pass on win32 and lin32 w/ gcc 4.0.2
Added:
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/thread/
harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java
Modified:
harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml
harmony/enhanced/drlvm/trunk/build/make/deploy.xml
harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp
harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ConstraintsResolver.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.h
harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/globalopndanalyzer.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp
harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp
harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl
harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml Tue Dec 12 20:56:10 2006
@@ -27,8 +27,7 @@
<project name="vm.hythr">
<target name="init" depends="common_vm">
- <property name="build.depends" value="extra.apr,vm.encoder,
-vm.port,extra.log4cxx, extra.aprutil" />
+ <property name="build.depends" value="extra.apr,vm.encoder,vm.port,extra.log4cxx,extra.aprutil,vm.kernel_classes" />
<property name="libname" value="hythr" />
<property name="outtype" value="shared" />
<property name="src" location="${build.vm.home}" />
@@ -60,10 +59,10 @@
<select os="lnx">
<defineset define="LINUX" />
</select>
- <select os="lnx" arch="em64t,ipf">
+ <select os="lnx" arch="em64t,ipf">
<defineset define="LINUX64" />
<defineset define="LINUXPPC64" />
- </select>
+ </select>
<!--
<select os="lnx">
<compilerarg value="-Wno-deprecated" />
@@ -105,5 +104,23 @@
<syslibset libs="advapi32,ws2_32" />
</select>
</linker>
+
+ <!-- Java helpers -->
+ <property name="build.java.depends" value=""/>
+
+ <path id="java.source">
+ <pathelement location="${build.vm.home}/thread/javasrc" />
+ </path>
+
+ <path id="java.class.path">
+ <pathelement location="${java.build.dir}"/>
+
+ <fileset dir="${external.dep.CLASSLIB.jardir}" includes="*.jar" />
+ <pathelement location="${vm.kernel_classes.jardir}/kernel.jar"/>
+ <fileset dir="${build.MMTK.home}" includes="mmtk-20061012.jar" />
+ </path>
+
+ <property name="jarname" value="hythr.jar"/>
+
</target>
</project>
Modified: harmony/enhanced/drlvm/trunk/build/make/deploy.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/deploy.xml?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/deploy.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/deploy.xml Tue Dec 12 20:56:10 2006
@@ -68,6 +68,7 @@
<hythr>
<shared>bin/default:hythr</shared>
+ <jar>bin/default:hythr</jar>
</hythr>
</vm>
Modified: harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp Tue Dec 12 20:56:10 2006
@@ -728,12 +728,12 @@
INFO2(nextStep->catName.c_str(), msg.str().c_str());
}
- vm_compile_method(nextStep->jit, mp->mh);
+ JIT_Result res = vm_compile_method(nextStep->jit, mp->mh);
if (nextStep->loggingEnabled) {
std::ostringstream msg;
- msg << "EM: recompile done:["<<nextStep->jitName.c_str()<<" n="<<n<<"] "
- <<className<<"::"<<methodName<<signature;
+ msg << "EM: recompile done:["<<nextStep->jitName.c_str()<<" n="<<n<<": "
+ <<(res ==JIT_SUCCESS ? "OK" : "FAILED")<<"] "<<className<<"::"<<methodName<<signature;
INFO2(nextStep->catName.c_str(), msg.str().c_str());
}
Modified: harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_jni.cpp Tue Dec 12 20:56:10 2006
@@ -9,7 +9,7 @@
/*
* Class: org_apache_harmony_drlvm_gc_cc_GCHelper
- * Method: getGCTlsOffset
+ * Method: getCurrentOffset
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1cc_GCHelper_getCurrentOffset(JNIEnv *e, jclass c)
@@ -19,7 +19,7 @@
/*
* Class: org_apache_harmony_drlvm_gc_cc_GCHelper
- * Method: getGCTlsOffset
+ * Method: getCleanedOffset
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_gc_1cc_GCHelper_getCleanedOffset(JNIEnv *e, jclass c)
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf Tue Dec 12 20:56:10 2006
@@ -80,10 +80,21 @@
-XDjit.SD2_OPT.arg.optimizer.inline_helpers.newObj_methodName=alloc
-XDjit.SD2_OPT.arg.optimizer.inline_helpers.newObj_hotnessPercent=1
--XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray=on
--XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray_className=org/apache/harmony/drlvm/gc_cc/GCHelper
--XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray_methodName=allocArray
--XDjit.CS_OPT.arg.optimizer.inline_helpers.newArray_hotnessPercent=1
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.newArray=on
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.newArray_className=org/apache/harmony/drlvm/gc_cc/GCHelper
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.newArray_methodName=allocArray
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.newArray_hotnessPercent=1
+
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonEnter=on
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonEnter_className=org/apache/harmony/drlvm/thread/ThreadHelper
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonEnter_methodName=monitorEnterUseReservation
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonEnter_hotnessPercent=1
+
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonExit=on
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonExit_className=org/apache/harmony/drlvm/thread/ThreadHelper
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonExit_methodName=monitorExit
+-XDjit.SD2_OPT.arg.optimizer.inline_helpers.objMonExit_hotnessPercent=1
+
-XDjit.SD2_OPT.arg.codegen.dce1.early=yes
-XDjit.SD2_OPT.arg.codegen.regalloc.bp_regalloc1.regs=ALL_GP
@@ -96,3 +107,8 @@
#GC magics support
-Dvm.components.gc_cc.startupclass=org.apache.harmony.drlvm.gc_cc.GCHelper
-XDvm.component.classpath.gc_cc=gc_cc.jar
+
+#TM properties
+-Dvm.components.hythr.startupclass=org.apache.harmony.drlvm.thread.ThreadHelper
+-XDvm.component.classpath.hythr=hythr.jar
+
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ConstraintsResolver.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ConstraintsResolver.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ConstraintsResolver.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32ConstraintsResolver.cpp Tue Dec 12 20:56:10 2006
@@ -483,6 +483,7 @@
// an operand different to the current replacement
// is required to be over this call site, append splitting below the call site
// this is like restoring from a call-safe location under a call
+ assert(currentOpnd->getType() == opndToSet->getType());
Inst * copySequence=irManager.newCopyPseudoInst(Mnemonic_MOV, currentOpnd, opndToSet);
copySequence->insertAfter(inst);
}
@@ -564,6 +565,7 @@
if (currentOpnd!=NULL){
if (currentOpnd!=originalOpnd){
// assert(irManager.getLiveAtEntry(bb)->isLive(originalOpnd));
+ assert(currentOpnd->getType() == originalOpnd->getType());
Inst * copySequence=irManager.newCopyPseudoInst(Mnemonic_MOV, currentOpnd, originalOpnd);
bb->prependInst(copySequence);
}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp Tue Dec 12 20:56:10 2006
@@ -186,6 +186,14 @@
}
}
+static bool isTypeConversionAllowed(Opnd* fromOpnd, Opnd* toOpnd) {
+ Type * fromType = fromOpnd->getType();
+ Type * toType = toOpnd->getType();
+ bool fromIsGCType = fromType->isObject() || fromType->isManagedPtr();
+ bool toIsGCType = toType->isObject() || toType->isManagedPtr();
+ return fromIsGCType == toIsGCType;
+}
+
//_________________________________________________________________________________________________
bool SimpleStackOpndCoalescer::isCandidate(const Inst * inst)const
{
@@ -193,7 +201,7 @@
Opnd * dstOpnd = inst->getOpnd(0), * srcOpnd = inst->getOpnd(1);
if (dstOpnd != srcOpnd &&
intervals[srcOpnd->getId()] != NULL && intervals[dstOpnd->getId()] != NULL
- && dstOpnd->getSize() == srcOpnd->getSize())
+ && dstOpnd->getSize() == srcOpnd->getSize() && isTypeConversionAllowed(srcOpnd, dstOpnd))
return true;
}
return false;
@@ -322,7 +330,7 @@
void runImpl();
void restoreRegUsage(Node * bb, Inst * toInst, uint32& gpRegUsageMask, uint32& appRegUsageMask);
uint32 getNeedInfo()const{ return NeedInfo_LivenessInfo; }
- uint32 getSideEffects()const{ return 0; }
+ uint32 getSideEffects()const{ return SideEffect_InvalidatesLivenessInfo; }
};
@@ -421,7 +429,6 @@
}
}
}
- irManager->fixLivenessInfo();
}
//_________________________________________________________________________________________________
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp Tue Dec 12 20:56:10 2006
@@ -59,6 +59,14 @@
static ActionFactory<EarlyPropagation> _early_prop("early_prop");
+static bool isTypeConversionAllowed(Opnd* fromOpnd, Opnd* toOpnd) {
+ Type * fromType = fromOpnd->getType();
+ Type * toType = toOpnd->getType();
+ bool fromIsGCType = fromType->isObject() || fromType->isManagedPtr();
+ bool toIsGCType = toType->isObject() || toType->isManagedPtr();
+ return fromIsGCType == toIsGCType;
+}
+
//___________________________________________________________________________________________________
void EarlyPropagation::runImpl()
{
@@ -135,7 +143,8 @@
uint32 defOpndId = defOpnd->getId();
OpndInfo * opndInfo = opndInfos + defOpndId;
bool instHandled=false;
- if (opndInfo->defCount == 1 && ! srcOpnd->isPlacedIn(OpndKind_Reg)){
+ bool typeConvOk = isTypeConversionAllowed(srcOpnd, defOpnd);
+ if (typeConvOk && opndInfo->defCount == 1 && ! srcOpnd->isPlacedIn(OpndKind_Reg)){
if (!defOpnd->hasAssignedPhysicalLocation()){
opndInfo->sourceInst = inst;
opndInfo->sourceOpndId = srcOpnd->getId();
@@ -165,13 +174,12 @@
if (opndInfos[i].sourceOpndId != i){
Opnd* origOpnd= irManager->getOpnd(i);
Opnd* replacementOpnd = irManager->getOpnd(opndInfos[i].sourceOpndId);
- //TODO: extends possible convertions.
- if ( (origOpnd->getType()->isUnmanagedPtr() && replacementOpnd->getType()->isInteger())
- //TODO: should we prohibit <type> <-> Mptr|Obj convertion when <type> is not Mptr|Obj ?
- || (origOpnd->getType()->isObject() || origOpnd->getType()->isManagedPtr()))
- {
+ assert(isTypeConversionAllowed(replacementOpnd, origOpnd));
+ if (origOpnd->getType()->isUnmanagedPtr() && replacementOpnd->getType()->isInteger()) {
replacementOpnd->setType(origOpnd->getType());
- }
+ }/* else if (origOpnd->getType()->isObject() && replacementOpnd->getType()->isUnmanagedPtr()) {
+ replacementOpnd->setType(origOpnd->getType());
+ }*/
replacements[i] = replacementOpnd;
hasReplacements = true;
}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.cpp Tue Dec 12 20:56:10 2006
@@ -68,7 +68,7 @@
for (Inst* inst = (Inst*)block->getLastInst(); inst!=NULL; inst = inst->getPrevInst()) {
if (IRManager::isGCSafePoint(inst)) {
registerGCSafePoint(irm, ls, inst);
-#ifndef _DEBUG //for debug mode we collect all hardware exception points too
+#ifndef GCMAP_TRACK_IDS //for debug mode we collect all hardware exception points too
if (--safePointsInBlock == 0) {
break;
}
@@ -86,7 +86,7 @@
GCSafePoint* gcSafePoint = new (mm) GCSafePoint(mm, eip);
GCSafePointPairs& pairs = offsetsInfo->getGCSafePointPairs(inst);
const StlSet<Opnd*>& staticFieldsMptrs = offsetsInfo->getStaticFieldMptrs();
-#ifdef GC_MAP_DUMP_ENABLED
+
StlVector<int>* offsets = NULL;
StlVector<Opnd*>* basesAndMptrs = NULL;
bool loggingGCInst = Log::isEnabled();
@@ -94,8 +94,7 @@
offsets = new (mm) StlVector<int>(mm);
basesAndMptrs = new (mm) StlVector<Opnd*>(mm);
}
-#endif
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
gcSafePoint->instId = inst->getId();
#endif
BitSet::IterB liveOpnds(ls);
@@ -106,7 +105,21 @@
if (callRes == opnd) {
continue;
}
- if (!opnd->getType()->isManagedPtr() && !opnd->getType()->isObject()) {
+ Type* opndType = opnd->getType();
+#ifdef _DEBUG
+ //check that unmanaged opnd live range does not cross enumeration points
+ if (opndType->isUnmanagedPtr() && opndType->asPtrType()->getPointedToType()->isInt1()) {
+ CallInst * callInst=(CallInst*)inst;
+ Opnd * targetOpnd=callInst->getOpnd(callInst->getTargetOpndIndex());
+ assert(targetOpnd->isPlacedIn(OpndKind_Imm));
+ Opnd::RuntimeInfo * ri=targetOpnd->getRuntimeInfo();
+ if (!ri) {
+ assert (ri->getKind() != Opnd::RuntimeInfo::Kind_MethodVtableSlotOffset);
+ assert (ri->getKind() != Opnd::RuntimeInfo::Kind_MethodDirectAddr);
+ }
+ }
+#endif
+ if (!opndType->isManagedPtr() && !opndType->isObject()) {
continue;
}
if (staticFieldsMptrs.find(opnd) != staticFieldsMptrs.end()) {
@@ -141,19 +154,17 @@
assert(opnd->getMemOpndKind() == MemOpndKind_Heap);
continue;
}
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
gcOpnd->firstId = opnd->getFirstId();
#endif
gcSafePoint->gcOpnds.push_back(gcOpnd);
-#ifdef GC_MAP_DUMP_ENABLED
+
if (loggingGCInst) {
basesAndMptrs->push_back(opnd);
offsets->push_back(gcOpnd->getMPtrOffset());
}
-#endif
}
gcSafePoints.push_back(gcSafePoint);
-#ifdef GC_MAP_DUMP_ENABLED
if (loggingGCInst && !offsets->empty()) {
GCInfoPseudoInst* gcInst = irm.newGCInfoPseudoInst(*basesAndMptrs);
gcInst->desc = "gcmap";
@@ -161,7 +172,6 @@
std::copy(offsets->begin(), offsets->end(), gcInst->offsets.begin());
gcInst->insertAfter(inst);
}
-#endif
}
bool GCMap::isHardwareExceptionPoint(const Inst* inst) const {
Inst::Opnds opnds(inst, Inst::OpndRole_Explicit|Inst::OpndRole_UseDef);
@@ -177,7 +187,7 @@
void GCMap::registerHardwareExceptionPoint(Inst* inst) {
POINTER_SIZE_INT eip = (POINTER_SIZE_INT)inst->getCodeStartAddr();
GCSafePoint* gcSafePoint = new (mm) GCSafePoint(mm, eip);
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
gcSafePoint->instId = inst->getId();
gcSafePoint->hardwareExceptionPoint = true;
#endif
@@ -205,7 +215,7 @@
}
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
struct hwecompare {
bool operator() (const GCSafePoint* p1, const GCSafePoint* p2) const {
if (p1->isHardwareExceptionPoint() == p2->isHardwareExceptionPoint()) {
@@ -222,7 +232,7 @@
data[1] = gcSafePoints.size();
POINTER_SIZE_INT offs = 2;
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
// make sure that hwe-points are after normal gcpoints
// this is depends on findGCSafePointStart algorithm -> choose normal gcpoint
// if both hwe and normal points are registered for the same IP
@@ -265,13 +275,13 @@
POINTER_SIZE_INT offs = 2;
for (uint32 i = 0; i< nOpnds; i++, offs+=3) {
GCSafePointOpnd* gcOpnd= new (mm) GCSafePointOpnd(image[offs], int(image[offs+1]), int32(image[offs+2]));
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
gcOpnd->firstId = image[offs+3];
offs++;
#endif
gcOpnds.push_back(gcOpnd);
}
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
instId = image[offs];
hardwareExceptionPoint = (bool)image[offs+1];
#endif
@@ -279,7 +289,7 @@
POINTER_SIZE_INT GCSafePoint::getUint32Size() const {
POINTER_SIZE_INT size = 1/*ip*/+1/*nOpnds*/+GCSafePointOpnd::IMAGE_SIZE_UINT32 * gcOpnds.size()/*opnds images*/;
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
size++; //instId
size++; //hardwareExceptionPoint
#endif
@@ -295,12 +305,12 @@
data[offs] = gcOpnd->flags;
data[offs+1] = gcOpnd->val;
data[offs+2] = gcOpnd->mptrOffset;
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
data[offs+3] = gcOpnd->firstId;
offs++;
#endif
}
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
data[offs++] = instId;
data[offs++] = (POINTER_SIZE_INT)hardwareExceptionPoint;
#endif
@@ -312,7 +322,7 @@
}
static inline void m_assert(bool cond) {
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
assert(cond);
#else
#ifdef WIN32
@@ -454,7 +464,8 @@
const char* methodName = methodDesc->getName();
const char* className = class_get_name(parentClassHandle);
const char* methodSignature = methodDesc->getSignatureString();
- printf("enumerate: %s::%s %s\n", className, methodName, methodSignature);*/
+ printf("enumerate: %s::%s %s ip=%d\n", className, methodName, methodSignature, *context->p_eip);
+*/
// Compute stack information
uint32 stackInfoSize = StackInfo::getByteSize(methodDesc);
@@ -481,9 +492,7 @@
}
} else {
//NPE + GC -> nothing to enumerate for this frame;
-#ifdef _DEBUG
assert(0); //in debug mode all hardware exceptions are saved as empty gcsafepoints
-#endif
}
}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.h?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCMap.h Tue Dec 12 20:56:10 2006
@@ -28,12 +28,14 @@
#include "Ia32StackInfo.h"
#include "Ia32BCMap.h"
#include "DrlVMInterface.h"
+
+#ifdef _DEBUG
+#define GCMAP_TRACK_IDS
+#endif
+
namespace Jitrino
{
namespace Ia32 {
-#ifdef _DEBUG
-#define GC_MAP_DUMP_ENABLED
-#endif
class GCSafePointsInfo;
class GCSafePoint;
@@ -74,7 +76,7 @@
typedef StlVector<GCSafePointOpnd*> GCOpnds;
public:
GCSafePoint(MemoryManager& mm, POINTER_SIZE_INT _ip):gcOpnds(mm), ip(_ip) {
-#ifdef _DEBUG
+#ifdef _GCMAP_TRACK_IDS
instId = 0;
hardwareExceptionPoint = false;
#endif
@@ -93,7 +95,7 @@
POINTER_SIZE_INT getOpndSaveAddr(const JitFrameContext* ctx, const StackInfo& sInfo,const GCSafePointOpnd* gcOpnd) const;
GCOpnds gcOpnds;
POINTER_SIZE_INT ip;
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
POINTER_SIZE_INT instId;
bool hardwareExceptionPoint;
public:
@@ -109,7 +111,7 @@
static const uint32 COMPRESSED_MASK = 0x4;
#endif
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
// flags + val + mptrOffset + firstId
static const uint32 IMAGE_SIZE_UINT32 = 4; //do not use sizeof due to the potential struct layout problems
#else
@@ -127,7 +129,7 @@
#endif
flags = isObject ? OBJ_MASK : 0;
flags = flags | (isOnRegister ? REG_MASK: 0);
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
firstId = 0;
#endif
}
@@ -147,7 +149,7 @@
int32 getMPtrOffset() const {return mptrOffset;}
void getMPtrOffset(int newOffset) {mptrOffset = newOffset;}
-#ifdef _DEBUG
+#ifdef GCMAP_TRACK_IDS
uint32 firstId;
#endif
@@ -165,13 +167,8 @@
class GCMapCreator : public SessionAction {
void runImpl();
uint32 getNeedInfo()const{ return NeedInfo_LivenessInfo;}
-#ifdef GC_MAP_DUMP_ENABLED
uint32 getSideEffects() {return Log::isEnabled();}
bool isIRDumpEnabled(){ return true;}
-#else
- uint32 getSideEffects() {return 0;}
- bool isIRDumpEnabled(){ return false;}
-#endif
};
class InfoBlockWriter : public SessionAction {
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Tue Dec 12 20:56:10 2006
@@ -607,7 +607,7 @@
switch(opType){
case ArithmeticOp::I4:
case ArithmeticOp::I:{
- Type * dstType=opType==ArithmeticOp::I?irManager.getManagedPtrType(((Opnd*)src1)->getType()):irManager.getTypeFromTag(Type::Int32);
+ Type * dstType=opType==ArithmeticOp::I?irManager.getTypeFromTag(Type::IntPtr):irManager.getTypeFromTag(Type::Int32);
return simpleOp_I4(Mnemonic_ADD, dstType, (Opnd*)src1, (Opnd*)src2);
}
case ArithmeticOp::I8:
@@ -633,7 +633,7 @@
switch(opType){
case ArithmeticOp::I4:
case ArithmeticOp::I:{
- Type * dstType=opType==ArithmeticOp::I?irManager.getManagedPtrType(((Opnd*)src1)->getType()):irManager.getTypeFromTag(Type::Int32);
+ Type * dstType=opType==ArithmeticOp::I?irManager.getTypeFromTag(Type::IntPtr):irManager.getTypeFromTag(Type::Int32);
return simpleOp_I4(Mnemonic_SUB, dstType, (Opnd*)src1, (Opnd*)src2);
}
case ArithmeticOp::I8:
@@ -1032,7 +1032,7 @@
switch(opType){
case IntegerOp::I4:
case IntegerOp::I:{
- Type * dstType=opType==IntegerOp::I?irManager.getManagedPtrType(((Opnd*)src1)->getType()):irManager.getTypeFromTag(Type::Int32);
+ Type * dstType=opType==IntegerOp::I?irManager.getTypeFromTag(Type::IntPtr):irManager.getTypeFromTag(Type::Int32);
return simpleOp_I4(Mnemonic_AND, dstType, (Opnd*)src1, (Opnd*)src2);
}
case IntegerOp::I8:
@@ -1053,7 +1053,7 @@
switch(opType){
case IntegerOp::I4:
case IntegerOp::I:{
- Type * dstType=opType==IntegerOp::I?irManager.getManagedPtrType(((Opnd*)src1)->getType()):irManager.getTypeFromTag(Type::Int32);
+ Type * dstType=opType==IntegerOp::I?irManager.getTypeFromTag(Type::IntPtr):irManager.getTypeFromTag(Type::Int32);
return simpleOp_I4(Mnemonic_OR, dstType, (Opnd*)src1, (Opnd*)src2);
}
case IntegerOp::I8:
@@ -1074,7 +1074,7 @@
switch(opType){
case IntegerOp::I4:
case IntegerOp::I:{
- Type * dstType=opType==IntegerOp::I?irManager.getManagedPtrType(((Opnd*)src1)->getType()):irManager.getTypeFromTag(Type::Int32);
+ Type * dstType=opType==IntegerOp::I?irManager.getTypeFromTag(Type::IntPtr):irManager.getTypeFromTag(Type::Int32);
return simpleOp_I4(Mnemonic_XOR, dstType, (Opnd*)src1, (Opnd*)src2);
}
case IntegerOp::I8:
@@ -1094,7 +1094,7 @@
switch(opType){
case IntegerOp::I4:
case IntegerOp::I:{
- Type * dstType=opType==IntegerOp::I?irManager.getManagedPtrType(((Opnd*)src)->getType()):irManager.getTypeFromTag(Type::Int32);
+ Type * dstType=opType==IntegerOp::I?irManager.getTypeFromTag(Type::IntPtr):irManager.getTypeFromTag(Type::Int32);
return simpleOp_I4(Mnemonic_NOT, dstType, (Opnd*)src, 0);
}
case IntegerOp::I8:
@@ -2863,8 +2863,10 @@
}
case CompilationInterface::Helper_NewObj_UsingVtable:
case CompilationInterface::Helper_NewVector_UsingVtable:
+ case CompilationInterface::Helper_ObjMonitorEnter:
+ case CompilationInterface::Helper_ObjMonitorExit:
{
- dstOpnd = irManager.newOpnd(retType);
+ dstOpnd = retType==NULL ? NULL: irManager.newOpnd(retType);
CallInst * callInst=irManager.newRuntimeHelperCallInst(callId, numArgs, (Opnd**)args, dstOpnd);
appendInsts(callInst);
break;
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp Tue Dec 12 20:56:10 2006
@@ -638,6 +638,7 @@
}
break;
case Op_Conv:
+ case Op_ConvUnmanaged:
{
assert(inst->getNumSrcOperands() == 1);
Type * dstType = inst->getDst()->getType();
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp Tue Dec 12 20:56:10 2006
@@ -946,7 +946,11 @@
Modifier ovfMod,
Opnd* src) {
src = propagateCopy(src);
- Operation operation(Op_Conv, toType, ovfMod);
+ Opcode opcode = Op_Conv;
+ if ((dstType->isUnmanagedPtr() && src->getType()->isObject()) || (dstType->isObject() && src->getType()->isUnmanagedPtr())) {
+ opcode = Op_ConvUnmanaged;
+ }
+ Operation operation(opcode, toType, ovfMod);
uint32 hashcode = operation.encodeForHashing();
Opnd* dst = lookupHash(hashcode, src->getId());
if (dst) return dst;
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Tue Dec 12 20:56:10 2006
@@ -1873,7 +1873,13 @@
// conversion
Inst* InstFactory::makeConv(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src) {
- return makeInst(Op_Conv, mod, toType, dst, src);
+ Opcode opcode = Op_Conv;
+ if (dst->getType()->isUnmanagedPtr() && src->getType()->isObject()
+ || dst->getType()->isObject() && src->getType()->isUnmanagedPtr())
+ {
+ opcode = Op_ConvUnmanaged;
+ }
+ return makeInst(opcode, mod, toType, dst, src);
}
// shifts
@@ -2746,6 +2752,7 @@
case Op_Not: return caseNot(inst);
case Op_Select: return caseSelect(inst);
case Op_Conv: return caseConv(inst);
+ case Op_ConvUnmanaged: return caseConvUnmanaged(inst);
case Op_Shladd: return caseShladd(inst);
case Op_Shl: return caseShl(inst);
case Op_Shr: return caseShr(inst);
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h Tue Dec 12 20:56:10 2006
@@ -1624,6 +1624,10 @@
virtual Inst*
caseConv(Inst* inst)=0;// {return caseDefault(inst);}
+ // conversion
+ virtual Inst*
+ caseConvUnmanaged(Inst* inst)=0;// {return caseDefault(inst);}
+
// shifts
virtual Inst*
caseShladd(Inst* inst)=0;// {return caseDefault(inst);}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp Tue Dec 12 20:56:10 2006
@@ -92,6 +92,7 @@
{ Op_Not, false, MB::Movable, MK::None, "not ", "not %s -) %l", },
{ Op_Select, false, MB::Movable, MK::None, "select", "select %s -) %l", }, // (src1 ? src2 : src3)
{ Op_Conv, false, MB::Movable, MK::Overflow_and_Exception_and_Strict, "conv ", "conv%t%m %s -) %l", },
+ { Op_ConvUnmanaged, false, MB::StoreOrSync, MK::Overflow_and_Exception_and_Strict, "convu ", "convu%t%m %s -) %l", },
{ Op_Shladd, false, MB::Movable, MK::None, "shladd", "shladd %s -) %l", }, // no mods, 2nd operand must be LdConstant
{ Op_Shl, false, MB::Movable, MK::ShiftMask, "shl ", "shl%m %s -) %l", },
{ Op_Shr, false, MB::Movable, MK::ShiftMask_and_Signed, "shr ", "shr%m %s -) %l", },
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h Tue Dec 12 20:56:10 2006
@@ -291,6 +291,7 @@
Op_Select, // (src1 ? src2 : src3)
// Conversion
Op_Conv, // OverflowModifier, ExceptionModifier
+ Op_ConvUnmanaged, // OverflowModifier, ExceptionModifier
// Shift
Op_Shladd, // no mods, 2nd operand must be LdConstant
Op_Shl, // ShiftMaskModifier
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h Tue Dec 12 20:56:10 2006
@@ -103,6 +103,9 @@
// conversion
Inst* caseConv(Inst* inst) {return caseDefault(inst);}
+ // conversion
+ Inst* caseConvUnmanaged(Inst* inst) {return caseDefault(inst);}
+
// shifts
Inst* caseShladd(Inst* inst) {return caseDefault(inst);}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp Tue Dec 12 20:56:10 2006
@@ -136,6 +136,7 @@
// conversion to unmanaged pointer is also an escape!
//
case Op_Conv:
+ case Op_ConvUnmanaged:
break;
// in the absence of ssa form, stores to vars can conservatively escape
case Op_StVar:
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/globalopndanalyzer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/globalopndanalyzer.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/globalopndanalyzer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/globalopndanalyzer.cpp Tue Dec 12 20:56:10 2006
@@ -223,8 +223,12 @@
Opnd* src = inst->getSrc(0);
Opnd* dst = inst->getDst();
if(!src->isGlobal() && dst->isGlobal()) {
- assert(dst->getType()->isManagedPtr());
- src->setIsGlobal(true);
+ if (dst->getType()->isManagedPtr()) {
+ src->setIsGlobal(true);
+ } else {
+ assert(dst->getType()->isUnmanagedPtr());
+ }
+
}
};
break;
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp Tue Dec 12 20:56:10 2006
@@ -157,6 +157,7 @@
// conversion
Inst* caseConv(Inst* inst) { return hashIfNoException(inst); }
+ Inst* caseConvUnmanaged(Inst* inst) { return caseDefault(inst); }
// shifts
Inst* caseShladd(Inst* inst) { return hashInst(inst); }
@@ -2344,7 +2345,7 @@
void InstValueNumberer::addInfoFromPEI(Inst *pei, bool isExceptionEdge)
{
switch (pei->getOpcode()) {
- case Op_Add: case Op_Mul: case Op_Sub: case Op_Conv:
+ case Op_Add: case Op_Mul: case Op_Sub: case Op_Conv: case Op_ConvUnmanaged:
case Op_TauCheckDivOpnds:
break;
case Op_DirectCall: case Op_TauVirtualCall: case Op_IndirectCall:
@@ -2537,7 +2538,7 @@
if (optimizedOpcode == Op_TauUnsafe && instOpcode == Op_Cmp){
// optimizedInst is tauUnsafe so srcOpnd for copying must be 'false'
copy = irManager.getInstFactory().makeLdConst(dstOpnd,(int32)0);
- } else if (optimizedOpcode == Op_TauEdge) {
+ } else if (optimizedOpcode == Op_TauEdge && dstOpnd->getType()->isNumeric()) {
copy = irManager.getInstFactory().makeLdConst(dstOpnd,(int32)1);
} else {
srcOpnd = optimizedInst->getDst();
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/helper_inliner.cpp Tue Dec 12 20:56:10 2006
@@ -22,6 +22,8 @@
#include "PMFAction.h"
#include "optpass.h"
#include "inliner.h"
+#include "LoopTree.h"
+#include "Dominator.h"
namespace Jitrino {
@@ -31,17 +33,18 @@
bool insertInitilizers;
bool doInlining;
- bool newObj_doInlining;
- int newObj_hotnessPercentToInline;
- const char* newObj_className;
- const char* newObj_methodName;
- const char* newObj_signature;
-
- bool newArray_doInlining;
- int newArray_hotnessPercentToInline;
- const char* newArray_className;
- const char* newArray_methodName;
- const char* newArray_signature;
+#define DECLARE_STANDARD_HELPER_FLAGS(name) \
+ bool name##_doInlining;\
+ int name##_hotnessPercentToInline;\
+ const char* name##_className;\
+ const char* name##_methodName;\
+ const char* name##_signature;\
+
+DECLARE_STANDARD_HELPER_FLAGS(newObj);
+DECLARE_STANDARD_HELPER_FLAGS(newArray);
+DECLARE_STANDARD_HELPER_FLAGS(objMonEnter);
+DECLARE_STANDARD_HELPER_FLAGS(objMonExit);
+
};
class HelperInlinerAction: public Action {
@@ -60,45 +63,35 @@
flags.doInlining = true;
- //new obj inlining params;
- flags.newObj_doInlining = getBoolArg("newObj", false);
+#define READ_STANDARD_HELPER_FLAGS(name)\
+ flags.name##_doInlining = getBoolArg(#name, false);\
+ if (flags.name##_doInlining) {\
+ flags.name##_className = getStringArg(#name"_className", NULL);\
+ flags.name##_methodName = getStringArg(#name"_methodName", NULL);\
+ flags.name##_hotnessPercentToInline = getIntArg(#name"_hotnessPercent", 0);\
+ if (flags.name##_className == NULL || flags.name##_methodName == NULL) {\
+ if (Log::isEnabled()) {\
+ Log::out()<<"Invalid fast path helper name:"<<flags.name##_className<<"::"<<flags.name##_methodName<<std::endl;\
+ }\
+ flags.name##_doInlining = false;\
+ }\
+ }\
+ if (!flags.name##_doInlining){\
+ flags.name##_className = NULL;\
+ flags.name##_methodName = NULL;\
+ }\
+ READ_STANDARD_HELPER_FLAGS(newObj);
flags.newObj_signature = "(II)Lorg/vmmagic/unboxed/Address;";
- if (flags.newObj_doInlining) {
- flags.newObj_className = getStringArg("newObj_className", NULL);
- flags.newObj_methodName = getStringArg("newObj_methodName", NULL);
- flags.newObj_hotnessPercentToInline = getIntArg("newObj_hotnessPercent", 0);
- if (flags.newObj_className == NULL || flags.newObj_methodName == NULL) {
- //TODO:? crash("Invalid newObj fast path helper name: %s::%s\n", flags.newObj_className, flags.newObj_methodName);
- flags.newObj_doInlining = false;
- }
- }
-
- if (!flags.newObj_doInlining){
- flags.newObj_className = NULL;
- flags.newObj_methodName = NULL;
- }
-
-
- //new array inlining params;
- flags.newArray_doInlining = getBoolArg("newArray", false);
+ READ_STANDARD_HELPER_FLAGS(newArray);
flags.newArray_signature = "(III)Lorg/vmmagic/unboxed/Address;";
- if (flags.newArray_doInlining) {
- flags.newArray_className = getStringArg("newArray_className", NULL);
- flags.newArray_methodName = getStringArg("newArray_methodName", NULL);
- flags.newArray_hotnessPercentToInline = getIntArg("newArray_hotnessPercent", 0);
- if (flags.newArray_className == NULL || flags.newArray_methodName == NULL) {
- //TODO:? crash("Invalid newArray fast path helper name: %s::%s\n", flags.newArray_className, flags.newArray_methodName);
- flags.newArray_doInlining = false;
- }
- }
- if (!flags.newArray_doInlining){
- flags.newArray_className = NULL;
- flags.newArray_methodName = NULL;
- }
+ READ_STANDARD_HELPER_FLAGS(objMonEnter);
+ flags.objMonEnter_signature = "(Ljava/lang/Object;)V";
+ READ_STANDARD_HELPER_FLAGS(objMonExit);
+ flags.objMonExit_signature = "(Ljava/lang/Object;)V";
}
@@ -106,13 +99,21 @@
public:
HelperInliner(HelperInlinerSession* _sessionAction, MemoryManager& tmpMM, CompilationContext* _cc, Inst* _inst)
: flags(((HelperInlinerAction*)_sessionAction->getAction())->getFlags()), localMM(tmpMM),
- cc(_cc), inst(_inst), action(_sessionAction)
- {}
- virtual ~HelperInliner(){};
+ cc(_cc), inst(_inst), action(_sessionAction), method(NULL)
+ {
+ irm = cc->getHIRManager();
+ instFactory = &irm->getInstFactory();
+ opndManager = &irm->getOpndManager();
+ typeManager = &irm->getTypeManager();
+ cfg = &irm->getFlowGraph();
+ }
- virtual void doInline() = 0;
+ virtual ~HelperInliner(){};
+
+ virtual void run()=0;
protected:
MethodDesc* ensureClassIsResolvedAndInitialized(const char* className, const char* methodName, const char* signature);
+ virtual void doInline() = 0;
void inlineVMHelper(MethodCallInst* call);
HelperInlinerFlags& flags;
@@ -120,24 +121,37 @@
CompilationContext* cc;
Inst* inst;
HelperInlinerSession* action;
-};
-
-class NewObjHelperInliner : public HelperInliner {
-public:
- NewObjHelperInliner(HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst)
- : HelperInliner(session, tmpMM, cc, inst){}
-
- virtual void doInline();
-};
+ MethodDesc* method;
+//these fields used by almost every subclass -> cache them
+ IRManager* irm;
+ InstFactory* instFactory;
+ OpndManager* opndManager;
+ TypeManager* typeManager;
+ ControlFlowGraph* cfg;
-class NewArrayHelperInliner : public HelperInliner {
-public:
- NewArrayHelperInliner(HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst)
- : HelperInliner(session, tmpMM, cc, inst){}
- virtual void doInline();
};
-
+#define DECLARE_HELPER_INLINER(name, flagPrefix)\
+class name : public HelperInliner {\
+public:\
+ name (HelperInlinerSession* session, MemoryManager& tmpMM, CompilationContext* cc, Inst* inst)\
+ : HelperInliner(session, tmpMM, cc, inst){}\
+ \
+ virtual void run() { \
+ if (Log::isEnabled()) {\
+ Log::out() << "Processing inst:"; inst->print(Log::out()); Log::out()<<std::endl; \
+ }\
+ method = ensureClassIsResolvedAndInitialized(flags.flagPrefix##_className, flags.flagPrefix##_methodName, flags.flagPrefix##_signature);\
+ if (!method) return;\
+ doInline();\
+ }\
+ virtual void doInline();\
+};\
+
+DECLARE_HELPER_INLINER(NewObjHelperInliner, newObj)
+DECLARE_HELPER_INLINER(NewArrayHelperInliner, newArray)
+DECLARE_HELPER_INLINER(ObjMonitorEnterHelperInliner, objMonEnter)
+DECLARE_HELPER_INLINER(ObjMonitorExitHelperInliner, objMonExit)
void HelperInlinerSession::_run(IRManager& irm) {
CompilationContext* cc = getCompilationContext();
@@ -155,7 +169,7 @@
for (Nodes::const_iterator it = nodes.begin(), end = nodes.end(); it!=end; ++it) {
Node* node = *it;
int nodePercent = fg.hasEdgeProfile() ? (int)(node->getExecCount()*100/entryExecCount) : 0;
- if (node->isBlockNode()) { //only block nodes can have helper calls today
+ if (node->isBlockNode()) {
for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst()) {
Opcode opcode = inst->getOpcode();
switch(opcode) {
@@ -169,6 +183,16 @@
helperInliners.push_back(new (tmpMM) NewArrayHelperInliner(this, tmpMM, cc, inst));
}
break;
+ case Op_TauMonitorEnter:
+ if (flags.objMonEnter_doInlining && nodePercent >= flags.objMonEnter_hotnessPercentToInline) {
+ helperInliners.push_back(new (tmpMM) ObjMonitorEnterHelperInliner(this, tmpMM, cc, inst));
+ }
+ break;
+ case Op_TauMonitorExit:
+ if (flags.objMonExit_doInlining && nodePercent >= flags.objMonExit_hotnessPercentToInline) {
+ helperInliners.push_back(new (tmpMM) ObjMonitorExitHelperInliner(this, tmpMM, cc, inst));
+ }
+ break;
default: break;
}
}
@@ -179,7 +203,7 @@
//TODO: set inline limit!
for (StlVector<HelperInliner*>::const_iterator it = helperInliners.begin(), end = helperInliners.end(); it!=end; ++it) {
HelperInliner* inliner = *it;
- inliner->doInline();
+ inliner->run();
}
}
@@ -194,11 +218,9 @@
return NULL;
}
//helper class is resolved here -> check if initialized
- IRManager* irm = cc->getHIRManager();
- InstFactory& instFactory = irm->getInstFactory();
if (clazz->needsInitialization()) {
if (flags.insertInitilizers) {
- instFactory.makeInitType(clazz)->insertBefore(inst);
+ instFactory->makeInitType(clazz)->insertBefore(inst);
}
return NULL;
}
@@ -228,8 +250,7 @@
}
CompilationInterface* ci = cc->getVMCompilationInterface();
- IRManager* irm = cc->getHIRManager();
-
+
//now inline the call
CompilationContext inlineCC(cc->getCompilationLevelMemoryManager(), ci, cc->getCurrentJITContext());
inlineCC.setPipeline(cc->getPipeline());
@@ -247,7 +268,7 @@
//add all methods with pragma inline into the list.
const Nodes& nodesInRegion = regionToInline->getIRManager().getFlowGraph().getNodes();
for (Nodes::const_iterator it = nodesInRegion.begin(), end = nodesInRegion.end(); it!=end; ++it) {
- Node* node = *it;
+ Node* node = *it;
for (Inst* inst = (Inst*)node->getFirstInst(); inst!=NULL; inst = inst->getNextInst()) {
if (inst->isMethodCall()) {
MethodCallInst* methodCall = inst->asMethodCallInst();
@@ -276,17 +297,8 @@
#if defined (_EM64T_) || defined (_IPF_)
return;
#else
- if (Log::isEnabled()) {
- Log::out() << "Processing inst:"; inst->print(Log::out()); Log::out()<<std::endl;
- }
assert(inst->getOpcode() == Op_NewObj);
- //find the method
- MethodDesc* method = ensureClassIsResolvedAndInitialized(flags.newObj_className, flags.newObj_methodName, flags.newObj_signature);
- if (!method) {
- return;
- }
-
Opnd* dstOpnd= inst->getDst();
Type * type = dstOpnd->getType();
assert(type->isObject());
@@ -302,20 +314,15 @@
int allocationHandle= (int)objType->getAllocationHandle();
int objSize=objType->getObjectSize();
- IRManager* irm = cc->getHIRManager();
- InstFactory& instFactory = irm->getInstFactory();
- OpndManager& opndManager = irm->getOpndManager();
- TypeManager& typeManager = irm->getTypeManager();
-
- Opnd* tauSafeOpnd = opndManager.createSsaTmpOpnd(typeManager.getTauType());
- instFactory.makeTauSafe(tauSafeOpnd)->insertBefore(inst);
- Opnd* objSizeOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
- Opnd* allocationHandleOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
- Opnd* callResOpnd = opndManager.createSsaTmpOpnd(typeManager.getUnmanagedPtrType(typeManager.getInt8Type()));
- instFactory.makeLdConst(objSizeOpnd, objSize)->insertBefore(inst);
- instFactory.makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
+ Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
+ instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+ Opnd* objSizeOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type());
+ Opnd* allocationHandleOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type());
+ Opnd* callResOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type()));
+ instFactory->makeLdConst(objSizeOpnd, objSize)->insertBefore(inst);
+ instFactory->makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
Opnd* args[2] = {objSizeOpnd, allocationHandleOpnd};
- MethodCallInst* call = instFactory.makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
+ MethodCallInst* call = instFactory->makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 2, args, method)->asMethodCallInst();
call->insertBefore(inst);
inst->unlink();
assert(call == call->getNode()->getLastInst());
@@ -326,32 +333,20 @@
Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
Node* fallNode = fallEdge->getTargetNode();
if (fallNode->getInDegree()>1) {
- fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory.makeLabel());
+ fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory->makeLabel());
}
- fallNode->prependInst(instFactory.makeConv(mod, type->tag, dstOpnd, callResOpnd));
+ fallNode->prependInst(instFactory->makeConv(mod, type->tag, dstOpnd, callResOpnd));
- //inline the method
inlineVMHelper(call);
#endif
}
-
void NewArrayHelperInliner::doInline() {
#if defined (_EM64T_) || defined (_IPF_)
return;
#else
- if (Log::isEnabled()) {
- Log::out() << "Processing inst:"; inst->print(Log::out()); Log::out()<<std::endl;
- }
assert(inst->getOpcode() == Op_NewArray);
- //find the method
- MethodDesc* method = ensureClassIsResolvedAndInitialized(flags.newArray_className, flags.newArray_methodName, flags.newArray_signature);
- if (!method) {
- return;
- }
-
-
//the method signature is (int objSize, int allocationHandle)
Opnd* dstOpnd = inst->getDst();
ArrayType* arrayType = dstOpnd->getType()->asArrayType();
@@ -366,21 +361,16 @@
elemSize = 1;
}
- IRManager* irm = cc->getHIRManager();
- InstFactory& instFactory = irm->getInstFactory();
- OpndManager& opndManager = irm->getOpndManager();
- TypeManager& typeManager = irm->getTypeManager();
-
- Opnd* tauSafeOpnd = opndManager.createSsaTmpOpnd(typeManager.getTauType());
- instFactory.makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+ Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
+ instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
Opnd* numElements = inst->getSrc(0);
- Opnd* elemSizeOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
- Opnd* allocationHandleOpnd = opndManager.createSsaTmpOpnd(typeManager.getInt32Type());
- instFactory.makeLdConst(elemSizeOpnd, elemSize)->insertBefore(inst);
- instFactory.makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
+ Opnd* elemSizeOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type());
+ Opnd* allocationHandleOpnd = opndManager->createSsaTmpOpnd(typeManager->getInt32Type());
+ instFactory->makeLdConst(elemSizeOpnd, elemSize)->insertBefore(inst);
+ instFactory->makeLdConst(allocationHandleOpnd, allocationHandle)->insertBefore(inst);
Opnd* args[3] = {numElements, elemSizeOpnd, allocationHandleOpnd};
- Opnd* callResOpnd = opndManager.createSsaTmpOpnd(typeManager.getUnmanagedPtrType(typeManager.getInt8Type()));
- MethodCallInst* call = instFactory.makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 3, args, method)->asMethodCallInst();
+ Opnd* callResOpnd = opndManager->createSsaTmpOpnd(typeManager->getUnmanagedPtrType(typeManager->getInt8Type()));
+ MethodCallInst* call = instFactory->makeDirectCall(callResOpnd, tauSafeOpnd, tauSafeOpnd, 3, args, method)->asMethodCallInst();
call->insertBefore(inst);
inst->unlink();
assert(call == call->getNode()->getLastInst());
@@ -391,11 +381,69 @@
Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
Node* fallNode = fallEdge->getTargetNode();
if (fallNode->getInDegree()>1) {
- fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory.makeLabel());
+ fallNode = irm->getFlowGraph().spliceBlockOnEdge(fallEdge, instFactory->makeLabel());
+ }
+ fallNode->prependInst(instFactory->makeConv(mod, arrayType->tag, dstOpnd, callResOpnd));
+
+ inlineVMHelper(call);
+#endif
+}
+
+
+void ObjMonitorEnterHelperInliner::doInline() {
+#if defined (_EM64T_) || defined (_IPF_)
+ return;
+#else
+ assert(inst->getOpcode() == Op_TauMonitorEnter);
+
+ Opnd* objOpnd = inst->getSrc(0);
+ assert(objOpnd->getType()->isObject());
+ Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
+ instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+ Opnd* args[1] = {objOpnd};
+ MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 1, args, method)->asMethodCallInst();
+ call->insertBefore(inst);
+ inst->unlink();
+
+
+ //if call is not last inst -> make it last inst
+ if (call != call->getNode()->getLastInst()) {
+ cfg->splitNodeAtInstruction(call, true, true, instFactory->makeLabel());
+ }
+
+ //every call must have exception edge -> add it
+ if (call->getNode()->getExceptionEdge() == NULL) {
+ Node* node = call->getNode();
+ Node* dispatchNode = node->getUnconditionalEdgeTarget()->getExceptionEdgeTarget();
+ if (dispatchNode == NULL) {
+ dispatchNode = cfg->getUnwindNode();
+ assert(dispatchNode != NULL); //method with monitors must have unwind, so no additional checks is done
+ }
+ cfg->addEdge(node, dispatchNode);
}
- fallNode->prependInst(instFactory.makeConv(mod, arrayType->tag, dstOpnd, callResOpnd));
- //inline the method
+ inlineVMHelper(call);
+#endif
+}
+
+void ObjMonitorExitHelperInliner::doInline() {
+#if defined (_EM64T_) || defined (_IPF_)
+ return;
+#else
+ assert(inst->getOpcode() == Op_TauMonitorExit);
+
+ Opnd* objOpnd = inst->getSrc(0);
+ assert(objOpnd->getType()->isObject());
+ Opnd* tauSafeOpnd = opndManager->createSsaTmpOpnd(typeManager->getTauType());
+ instFactory->makeTauSafe(tauSafeOpnd)->insertBefore(inst);
+ Opnd* args[1] = {objOpnd};
+ MethodCallInst* call = instFactory->makeDirectCall(opndManager->getNullOpnd(), tauSafeOpnd, tauSafeOpnd, 1, args, method)->asMethodCallInst();
+ call->insertBefore(inst);
+ inst->unlink();
+
+ assert(call == call->getNode()->getLastInst());
+ assert(call->getNode()->getExceptionEdge()!=NULL);
+
inlineVMHelper(call);
#endif
}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp Tue Dec 12 20:56:10 2006
@@ -874,6 +874,7 @@
case Op_Select:
return false;
case Op_Conv:
+ case Op_ConvUnmanaged:
return true;
case Op_Shladd:
case Op_Shl:
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp Tue Dec 12 20:56:10 2006
@@ -929,7 +929,7 @@
case Op_Add: case Op_Mul: case Op_Sub: case Op_TauDiv: case Op_TauRem:
case Op_Neg: case Op_MulHi: case Op_Min: case Op_Max: case Op_Abs:
case Op_And: case Op_Or: case Op_Xor:
- case Op_Not: case Op_Select: case Op_Conv: case Op_Shladd: case Op_Shl:
+ case Op_Not: case Op_Select: case Op_Conv: case Op_ConvUnmanaged: case Op_Shladd: case Op_Shl:
case Op_Shr: case Op_Cmp: case Op_Cmp3:
case Op_Branch: case Op_Jump: case Op_Switch:
case Op_LdConstant:
@@ -1389,8 +1389,10 @@
case Op_Alloca:
case Op_LdVarAddr:
case Op_Phi:
+ case Op_DefArg: //magic as method param
break;
case Op_Conv: //the result of a conversion
+ case Op_ConvUnmanaged:
case Op_TauLdInd: // the result of static field load
break;
default:
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp Tue Dec 12 20:56:10 2006
@@ -4083,6 +4083,7 @@
return inst;
}
+
Inst*
SimplifierWithInstFactory::genShladd(Type* type,
Opnd* value, Opnd* shiftAmount,
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h Tue Dec 12 20:56:10 2006
@@ -416,6 +416,11 @@
return inst;
}
+ // conversion
+ Inst* caseConvUnmanaged(Inst* inst) {
+ return inst;
+ }
+
// shifts
Inst* caseShladd(Inst* inst) {
Opnd* opnd = simplifyShladd(inst->getDst()->getType(),
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp Tue Dec 12 20:56:10 2006
@@ -918,7 +918,10 @@
}
// if loop will make multiple iteration exitsFlow becomes equals to inFlow
double loopCycles = inFlow / exitsFlow;
- assert(loopCycles > 1);
+ if (loopCycles < 1) {
+ assert(ABS(inFlow-exitsFlow) < PROFILE_ERROR_ALLOWED);
+ loopCycles = 1;
+ }
cyclicFreqs[cfgLoopHead->getDfNum()] = loopCycles;
}
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Tue Dec 12 20:56:10 2006
@@ -250,7 +250,11 @@
//
arg = irBuilder.genArgDef(NonNullThisArg,argTypes[i]);
} else {
- arg = irBuilder.genArgDef(DefArgNoModifier,argTypes[i]);
+ Type* type = argTypes[i];
+ if (isMagicClass(type)) {
+ type = convertMagicType2HIR(typeManager, type);
+ }
+ arg = irBuilder.genArgDef(DefArgNoModifier,type);
}
JavaLabelPrepass::JavaVarType javaType = JavaLabelPrepass::getJavaType(argTypes[i]);
VarOpnd *var = getVarOpndStVar(javaType,j,arg);
@@ -2735,8 +2739,12 @@
jsrEntryMap);
} else {
Opnd *tauNullChecked = irBuilder.genTauSafe(); // always safe, is a static method call
+ Type* resType = returnType;
+ if (isMagicClass(resType)) {
+ resType = convertMagicType2HIR(typeManager, resType);
+ }
dst = irBuilder.genDirectCall(methodDesc,
- returnType,
+ resType,
tauNullChecked,
0, // let IRBuilder check types
numArgs,
@@ -3730,9 +3738,8 @@
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
+ Opnd* res = irBuilder.genLdConstant(typeManager.getUIntPtrType(), v);
if (resType->isPtr()) {
res = irBuilder.genConv(resType, resType->tag, mod, res);
}
@@ -3951,6 +3958,18 @@
assert(numArgs == 3);
Opnd* res = irBuilder.genVMHelperCall(CompilationInterface::Helper_NewVector_UsingVtable, resType, numArgs, srcOpnds);
pushOpnd(res);
+ return;
+ }
+
+ if (!strcmp(mname,"monitorEnter")) {
+ assert(numArgs == 1);
+ irBuilder.genVMHelperCall(CompilationInterface::Helper_ObjMonitorEnter, resType, numArgs, srcOpnds);
+ return;
+ }
+
+ if (!strcmp(mname,"monitorExit")) {
+ assert(numArgs == 1);
+ irBuilder.genVMHelperCall(CompilationInterface::Helper_ObjMonitorExit, resType, numArgs, srcOpnds);
return;
}
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp Tue Dec 12 20:56:10 2006
@@ -420,14 +420,15 @@
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()
+
#undef DEFINE_ALU_OPCODES
//
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl Tue Dec 12 20:56:10 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);
}
Added: harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java?view=auto&rev=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java (added)
+++ harmony/enhanced/drlvm/trunk/vm/thread/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java Tue Dec 12 20:56:10 2006
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.drlvm.thread;
+
+import org.apache.harmony.drlvm.VMHelper;
+import org.vmmagic.unboxed.*;
+import org.vmmagic.pragma.*;
+
+public class ThreadHelper {
+
+ public static final int THREAD_SHIFT = 16;
+ public static final int RECURSION_BOUND_IN_PLACE = 0xf400;
+ public static final int HI_BITS = 0xffff0000;
+ public static final int RECURSION_INC_IN_PLACE = 0x800;
+ public static final int ZEROED_BITS_FOR_INITIAL_LOCK = 0xffff0400;
+ public static final int LOCK_WORD_OFFSET = 4;
+
+ public static final int TLS_THREAD_ID_OFFSET=getThreadIdOffset();
+
+ static int getThreadId() throws InlinePragma {
+ Address tlsAddr = VMHelper.getTlsBaseAddress();
+ Address tlsThreadIdFieldAddr = tlsAddr.plus(TLS_THREAD_ID_OFFSET);
+ return tlsThreadIdFieldAddr.loadInt();
+ }
+
+ static void monitorEnterUseReservation(Object obj) {
+ Address lockWordPtr = ObjectReference.fromObject(obj).toAddress().plus(LOCK_WORD_OFFSET);
+ int threadId = getThreadId();
+ int lockword = lockWordPtr.loadInt();
+ int new_lockword = (threadId<<THREAD_SHIFT) ^ lockword;
+
+ if ((new_lockword & HI_BITS) == 0){
+ // comparison above is some kind of tricky, two things are checked at once;
+ // if we got zero it meants that there is NO fat lock here, and thread_id stored in lockword
+ // is the same as current thread_id
+
+ if ( new_lockword <= RECURSION_BOUND_IN_PLACE ) {
+ //This is the most frequent path.
+ //lockword updated without atomic operation.
+ //this path works for reservation locks (already reserved) and thin locks if the lock
+ //was already captured by this thread.
+ lockword+= RECURSION_INC_IN_PLACE;
+ lockWordPtr.store(lockword);
+ return ;
+ }
+ } else {
+ // avaliable possiblities here:
+ // 1. fat lock - 0x80000000 is set to 1 ; need goto slow path
+ // 2. captured thin lock for another thread ; need goto slow path
+ // 3. reserved lock for another thread. ; need goto slow path
+ // 4. non-locked thin lock.
+ // 5. The first lock for the object.
+ if ((lockword & ZEROED_BITS_FOR_INITIAL_LOCK)==0 ) {
+ // no locks was here. Reserve it.
+ new_lockword+=RECURSION_INC_IN_PLACE;
+ if (lockWordPtr.attempt(lockword, new_lockword)) {
+ return;
+ }
+ } else {
+ if ((lockword & HI_BITS)==0) {
+ if (lockWordPtr.attempt(lockword, new_lockword)) {
+ return;
+ }
+ }
+ }
+ }
+ VMHelper.monitorEnter(obj);
+ }
+
+ public static final int FAT_LOCK_MASK = 0x80000000;
+ public static final int RECURSION_MASK = 0x0000f800;
+
+ static void monitorExit(Object obj) {
+ Address lockWordPtr = ObjectReference.fromObject(obj).toAddress().plus(LOCK_WORD_OFFSET);
+ int lockword = lockWordPtr.loadInt();
+ if (((lockword & (FAT_LOCK_MASK|RECURSION_MASK)))!=0) {
+ if ((lockword & FAT_LOCK_MASK)==0) {
+ lockword-=RECURSION_INC_IN_PLACE;
+ lockWordPtr.store(lockword);
+ return;
+ }
+ } else {
+ lockword&=~HI_BITS;
+ lockWordPtr.store(lockword);
+ return;
+ }
+ VMHelper.monitorExit(obj);
+ }
+
+ private static native int getThreadIdOffset();
+}
+
+
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Tue Dec 12 20:56:10 2006
@@ -148,3 +148,5 @@
array_get
get_local_pool
get_java_thread_group
+
+Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Tue Dec 12 20:56:10 2006
@@ -160,6 +160,7 @@
get_local_pool;
get_java_thread_group;
+Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset;
local: *;
};
Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_tls.c Tue Dec 12 20:56:10 2006
@@ -27,7 +27,7 @@
#include <open/hythread_ext.h>
#include "thread_private.h"
-
+#include <jni.h>
/** @name Thread local storage support
*/
@@ -131,6 +131,16 @@
UDATA VMCALL hythread_tls_get_offset(hythread_tls_key_t key) {
assert(key < (UDATA)tm_tls_capacity);
return ((UDATA)&((hythread_t)0)->thread_local_storage) + (key * sizeof(void*));
+}
+
+
+/*
+ * Class: org_apache_harmony_drlvm_thread_ThreadHelper
+ * Method: getThreadIdOffset
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset(JNIEnv *e, jclass c) {
+ return (uint32)&((HyThread *)0)->thread_id;
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java?view=diff&rev=486493&r1=486492&r2=486493
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java Tue Dec 12 20:56:10 2006
@@ -34,6 +34,9 @@
public static Address newVectorUsingAllocHandle(int arrayLen, int elemSize, int allocationHandle) {fail(); return null;}
+ public static void monitorEnter(Object obj) {fail();}
+
+ public static void monitorExit(Object obj) {fail();}