Index: vm/jitrino/src/optimizer/inliner.h =================================================================== --- vm/jitrino/src/optimizer/inliner.h (revision 631623) +++ vm/jitrino/src/optimizer/inliner.h (working copy) @@ -198,6 +198,9 @@ int32 _inlineExactArgBonus; int32 _inlineExactAllBonus; + int32 _inlineHotnessBonus; + int32 _inlineInstanceInitializerBonus; + uint32 _inlineMaxNodeThreshold; bool _inlineSkipExceptionPath; Index: vm/jitrino/src/optimizer/inliner.cpp =================================================================== --- vm/jitrino/src/optimizer/inliner.cpp (revision 631623) +++ vm/jitrino/src/optimizer/inliner.cpp (working copy) @@ -45,13 +45,16 @@ #define INLINE_LARGE_THRESHOLD 70 -#define MAX_INLINE_GROWTH_FACTOR_PROF 500 +#define MAX_INLINE_GROWTH_FACTOR_PROF 2000 #define MIN_INLINE_STOP_PROF 100 // no negative profile benefit for nodes with freq >= 1/10 of entry freq #define MIN_BENEFIT_THRESHOLD_PROF (MIN_BENEFIT_THRESHOLD / 10) #define INLINE_LARGE_THRESHOLD_PROF 150 +#define INLINE_INSTANCE_INITIALIZER_BONUS 300 +#define INLINE_HOTNESS_BONUS 10 + #define CALL_COST 1 #define INLINE_SMALL_THRESHOLD 12 @@ -109,7 +112,10 @@ _inlineRecursionPenalty = argSource->getIntArg("recursion_penalty", INLINE_RECURSION_PENALTY); _inlineExactArgBonus = argSource->getIntArg("exact_single_parameter_bonus", INLINE_EXACT_ARG_BONUS); _inlineExactAllBonus = argSource->getIntArg("exact_all_parameter_bonus", INLINE_EXACT_ALL_BONUS); - + + _inlineInstanceInitializerBonus = argSource->getIntArg("instance_initializer_bonus", INLINE_INSTANCE_INITIALIZER_BONUS); + _inlineHotnessBonus = argSource->getIntArg("hotness_bonus", INLINE_HOTNESS_BONUS); + _inlineMaxNodeThreshold = irm.getOptimizerFlags().hir_node_threshold * irm.getOptimizerFlags().inline_node_quota / 100; _inlineSkipExceptionPath = argSource->getBoolArg("skip_exception_path", INLINE_SKIP_EXCEPTION_PATH); @@ -213,12 +219,13 @@ // // Recursion penalty - discourage recursive inlining // - for(; parentInlineNode != NULL; parentInlineNode = parentInlineNode->getParent()) { - if(&methodDesc == &(parentInlineNode->getIRManager().getMethodDesc())) { + for(InlineNode* pin = parentInlineNode ; pin != NULL; pin = pin->getParent()) { + if(&methodDesc == &(pin->getIRManager().getMethodDesc())) { benefit -= _inlineRecursionPenalty; Log::out() << " Subtracted one recursion level, benefit now = " << benefit << ::std::endl; } } + // // Leaf bonus - try to inline leaf methods @@ -262,6 +269,18 @@ Log::out() << " Added allexact bonus, benefit now = " << benefit << ::std::endl; } } + + for (InlineNode* pin = parentInlineNode; pin != NULL; pin= pin->getParent()) { + if (pin->getIRManager().getMethodDesc().isInstanceInitializer()) { + benefit += _inlineInstanceInitializerBonus; + Log::out() << " (recursive) InstanceInitializer bonus, benefit now = " << benefit << ::std::endl; + } + } + + if (methodDesc.isInstanceInitializer()) { + benefit += _inlineInstanceInitializerBonus; + Log::out() << " InstanceInitializer bonus, benefit now = " << benefit << ::std::endl; + } // // Use profile information if available @@ -270,18 +289,27 @@ double heatThreshold = _toplevelIRM.getHeatThreshold(); double nodeCount = node->getExecCount(); double scale = nodeCount / heatThreshold; - if(scale > 100) - scale = 100; + + Log::out() << "Using profile information:\n" + << " HeatThreshold=" << heatThreshold + << ", nodeCount=" << nodeCount + << ", scale=" << scale<< ::std::endl; + + Log::out() << " benefit now = " << benefit << ::std::endl; + // Remove any loop bonus as this is already accounted for in block count benefit -= _inlineLoopBonus*loopDepth; - // Scale by call site 'hotness'. - benefit = (uint32) ((double) benefit * scale); + + Log::out() << " substracting loop bonus = " << _inlineLoopBonus*loopDepth + << ", benefit now = " << benefit << ::std::endl; + + // Scale by call site 'hotness'. + benefit = (uint32) (benefit + ((double)_inlineHotnessBonus * scale)); - Log::out() << " HeatThreshold=" << heatThreshold - << ", nodeCount=" << nodeCount - << ", scale=" << scale - << "; benefit now = " << benefit - << ::std::endl; + Log::out() << " scaling by call site hotness = " << scale + << ", benefit now = " << benefit << ::std::endl; + + } return benefit; }