Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#310 from r30shah/circualBufferInsta…
Browse files Browse the repository at this point in the history
…nceOfPR

Implement an onsite cicular buffer for instanceOf
  • Loading branch information
fjeremic authored Oct 18, 2017
2 parents acaf415 + d424841 commit 7ebf432
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 97 deletions.
14 changes: 12 additions & 2 deletions runtime/tr.source/trj9/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ uint32_t J9::TreeEvaluator::calculateInstanceOfOrCheckCastSequences(TR::Node *in
bool isInstanceOf = instanceOfOrCheckCastNode->getOpCodeValue() == TR::instanceof;
bool mayBeNull = !instanceOfOrCheckCastNode->isReferenceNonNull() && !objectNode->isNonNull();

// By default maxOnsiteCacheSlotForInstanceOf is set to 0 which means cache is disable.
// To enable test pass JIT option maxOnsiteCacheSlotForInstanceOf=<number_of_slots>
bool createDynamicCacheTests = cg->comp()->getOptions()->getMaxOnsiteCacheSlotForInstanceOf() > 0;


uint32_t i = 0;
uint32_t numProfiledClasses = 0;

Expand Down Expand Up @@ -245,6 +250,8 @@ uint32_t J9::TreeEvaluator::calculateInstanceOfOrCheckCastSequences(TR::Node *in
// There is a possibility of attempt to cast object to another class and having cache on that object updated by helper.
// Before going to helper checking the cache.
sequences[i++] = CastClassCacheTest;
if (createDynamicCacheTests)
sequences[i++] = DynamicCacheObjectClassTest;
sequences[i++] = HelperCall;
}
// Cast class is a runtime variable, still not a lot of room to be fancy.
Expand All @@ -261,7 +268,9 @@ uint32_t J9::TreeEvaluator::calculateInstanceOfOrCheckCastSequences(TR::Node *in
if (cg->supportsInliningOfIsInstance() &&
instanceOfOrCheckCastNode->getOpCodeValue() == TR::instanceof &&
instanceOfOrCheckCastNode->getSecondChild()->getOpCodeValue() != TR::loadaddr)
sequences[i++] = SuperClassTest;
sequences[i++] = SuperClassTest;
if (createDynamicCacheTests)
sequences[i++] = DynamicCacheDynamicCastClassTest;
sequences[i++] = HelperCall;
}

Expand Down Expand Up @@ -426,7 +435,8 @@ uint32_t J9::TreeEvaluator::calculateInstanceOfOrCheckCastSequences(TR::Node *in
{
sequences[i++] = CastClassCacheTest;
}

if (createDynamicCacheTests)
sequences[i++] = DynamicCacheObjectClassTest;
sequences[i++] = HelperCall;
}
// Cast class is an abstract class, we can skip the class equality test, a superclass test is enough.
Expand Down
4 changes: 3 additions & 1 deletion runtime/tr.source/trj9/codegen/J9TreeEvaluator.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2017 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -54,6 +54,8 @@ class OMR_EXTENSIBLE TreeEvaluator: public OMR::TreeEvaluatorConnector
ClassEqualityTest, // Needs object class: y, needs cast class: y
SuperClassTest, // Needs object class: y, needs cast class: y
CastClassCacheTest, // Needs object class: y, needs cast class: y
DynamicCacheObjectClassTest, // Needs object class: y, needs cast class: n
DynamicCacheDynamicCastClassTest, // Needs object class: y, needs cast class: y
HelperCall, // Needs object class: n, needs cast class: y

InstanceOfOrCheckCastMaxSequences
Expand Down
3 changes: 3 additions & 0 deletions runtime/tr.source/trj9/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ int32_t J9::Options::_relaxedCompilationLimitsSampleThreshold = 120; // normally
int32_t J9::Options::_sampleThresholdVariationAllowance = 30;

int32_t J9::Options::_maxCheckcastProfiledClassTests = 3;
int32_t J9::Options::_maxOnsiteCacheSlotForInstanceOf = 0; // Setting this value to zero will disable onsite cache in instanceof.
int32_t J9::Options::_cpuEntitlementForConservativeScorching = 801; // 801 means more than 800%, i.e. 8 cpus
// A very large number disables the feature
int32_t J9::Options::_sampleHeartbeatInterval = 10;
Expand Down Expand Up @@ -866,6 +867,8 @@ TR::OptionTable OMR::Options::_feOptions[] = {
TR::Options::setStaticNumeric, (intptrj_t)&TR::Options::_lowVirtualMemoryMBThreshold, 0, "F%d", NOT_IN_SUBSET},
{"maxCheckcastProfiledClassTests=", "R<nnn>\tnumber inlined profiled classes for profiledclass test in checkcast/instanceof",
TR::Options::setStaticNumeric, (intptrj_t)&TR::Options::_maxCheckcastProfiledClassTests, 0, "%d", NOT_IN_SUBSET},
{"maxOnsiteCacheSlotForInstanceOf=", "R<nnn>\tnumber of onsite cache slots for instanceOf",
TR::Options::setStaticNumeric, (intptrj_t)&TR::Options::_maxOnsiteCacheSlotForInstanceOf, 0, "%d", NOT_IN_SUBSET},
{"minSamplingPeriod=", "R<nnn>\tminimum number of milliseconds between samples for hotness",
TR::Options::setStaticNumeric, (intptrj_t)&TR::Options::_minSamplingPeriod, 0, "P%d", NOT_IN_SUBSET},
{"minSuperclassArraySize=", "I<nnn>\t set the size of the minimum superclass array size",
Expand Down
18 changes: 17 additions & 1 deletion runtime/tr.source/trj9/control/J9Options.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2017 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -73,6 +73,22 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector
static int32_t _maxCheckcastProfiledClassTests;
static int32_t getCheckcastMaxProfiledClassTests() {return _maxCheckcastProfiledClassTests;}

static int32_t _maxOnsiteCacheSlotForInstanceOf;
/** \brief
* Returns the _maxOnsiteCacheSlotForInstanceOf
*
* \details
* maxOnsiteCacheSlotForInstanceOf node defines number of onsite cache slots to generate per site of instanceOf
* Set this value to 0 to disable generation of onsite cache test for instanceOf
*
*/
static int32_t getMaxOnsiteCacheSlotForInstanceOf() {return _maxOnsiteCacheSlotForInstanceOf;}
/** \brief
* Setter for _maxOnsiteCacheSlotForInstanceOf
*
*/
static int32_t setMaxOnsiteCacheSlotForInstanceOf(int32_t m) {return _maxOnsiteCacheSlotForInstanceOf = m;}

static int32_t _resetCountThreshold;

static int32_t _scorchingSampleThreshold;
Expand Down
6 changes: 6 additions & 0 deletions runtime/tr.source/trj9/p/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3797,6 +3797,12 @@ TR::Register *J9::Power::TreeEvaluator::VMinstanceOfEvaluator2(TR::Node *node, T
if (comp->getOption(TR_TraceCG)) traceMsg(comp, "%s: Emitting ArrayOfJavaLangObjectTest\n", node->getOpCode().getName());
genInstanceOfOrCheckCastObjectArrayTest(node, cr0Reg, objectClassReg, nextSequenceLabel, srm, cg);
break;
case DynamicCacheObjectClassTest:
TR_ASSERT_FATAL(false, "%s: DynamicCacheObjectClassTest is not implemented on P\n", node->getOpCode().getName());
break;
case DynamicCacheDynamicCastClassTest:
TR_ASSERT_FATAL(false, "%s: DynamicCacheDynamicCastClassTest is not implemented on P\n", node->getOpCode().getName());
break;
case HelperCall:
TR_ASSERT(false, "Doesn't make sense, HelperCall should be the terminal sequence");
break;
Expand Down
Loading

0 comments on commit 7ebf432

Please sign in to comment.