From 9419332450f315f70582970aaaac12dd0905672b Mon Sep 17 00:00:00 2001 From: Henry Zongaro Date: Thu, 13 Sep 2018 12:24:41 -0400 Subject: [PATCH 1/3] Allow some Unsafe atomic ops to be inlined on POWER Allow for the possibility that the parent OMR class will want to inline a direct call by delegating to the parent class's implementation of inlineDirectCall. In particular, we will want to do that for some atomic operations in Unsafe. Signed-off-by: Henry Zongaro --- .../optimizer/J9RecognizedCallTransformer.cpp | 13 +++++++++++-- runtime/compiler/p/codegen/J9TreeEvaluator.cpp | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp b/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp index c85f9176e55..9e59c1bd7bf 100644 --- a/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp +++ b/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp @@ -139,10 +139,19 @@ bool J9::RecognizedCallTransformer::isInlineable(TR::TreeTop* treetop) { case TR::sun_misc_Unsafe_getAndAddInt: case TR::sun_misc_Unsafe_getAndSetInt: - return TR::Compiler->target.cpu.isX86() && !comp()->getOption(TR_DisableUnsafe) && !comp()->compileRelocatableCode() && !TR::Compiler->om.canGenerateArraylets(); + return (TR::Compiler->target.cpu.isX86() + || TR::Compiler->target.cpu.isPower()) + && !comp()->getOption(TR_DisableUnsafe) + && !comp()->compileRelocatableCode() + && !TR::Compiler->om.canGenerateArraylets(); case TR::sun_misc_Unsafe_getAndAddLong: case TR::sun_misc_Unsafe_getAndSetLong: - return TR::Compiler->target.cpu.isX86() && !comp()->getOption(TR_DisableUnsafe) && !comp()->compileRelocatableCode() && TR::Compiler->target.is64Bit() && !TR::Compiler->om.canGenerateArraylets(); + return (TR::Compiler->target.cpu.isX86() + || TR::Compiler->target.cpu.isPower()) + && !comp()->getOption(TR_DisableUnsafe) + && !comp()->compileRelocatableCode() + && TR::Compiler->target.is64Bit() + && !TR::Compiler->om.canGenerateArraylets(); case TR::java_lang_Class_isAssignableFrom: return cg()->supportsInliningOfIsAssignableFrom(); case TR::java_lang_Integer_rotateLeft: diff --git a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp index bf221bc473b..5d61cd55f09 100644 --- a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp @@ -11824,6 +11824,10 @@ J9::Power::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&result resultReg = inlineSinglePrecisionFP(node, TR::InstOpCode::fsqrts, cg); return true; } + else if (OMR::Power::CodeGenerator::inlineDirectCall(node, resultReg)) + { + return true; + } else if (methodSymbol) { switch (methodSymbol->getRecognizedMethod()) From f40b1f13b9f808b23f91e3eede77071b14dc06b9 Mon Sep 17 00:00:00 2001 From: Henry Zongaro Date: Thu, 13 Sep 2018 12:24:41 -0400 Subject: [PATCH 2/3] Allow some Unsafe atomic ops to be inlined on POWER Allow for the possibility that the parent OMR class will want to inline a direct call by delegating to the parent class's implementation of inlineDirectCall. In particular, we will want to do that for some atomic operations in Unsafe. Signed-off-by: Henry Zongaro --- .../optimizer/J9RecognizedCallTransformer.cpp | 13 +++++++++++-- runtime/compiler/p/codegen/J9TreeEvaluator.cpp | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp b/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp index c85f9176e55..9e59c1bd7bf 100644 --- a/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp +++ b/runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp @@ -139,10 +139,19 @@ bool J9::RecognizedCallTransformer::isInlineable(TR::TreeTop* treetop) { case TR::sun_misc_Unsafe_getAndAddInt: case TR::sun_misc_Unsafe_getAndSetInt: - return TR::Compiler->target.cpu.isX86() && !comp()->getOption(TR_DisableUnsafe) && !comp()->compileRelocatableCode() && !TR::Compiler->om.canGenerateArraylets(); + return (TR::Compiler->target.cpu.isX86() + || TR::Compiler->target.cpu.isPower()) + && !comp()->getOption(TR_DisableUnsafe) + && !comp()->compileRelocatableCode() + && !TR::Compiler->om.canGenerateArraylets(); case TR::sun_misc_Unsafe_getAndAddLong: case TR::sun_misc_Unsafe_getAndSetLong: - return TR::Compiler->target.cpu.isX86() && !comp()->getOption(TR_DisableUnsafe) && !comp()->compileRelocatableCode() && TR::Compiler->target.is64Bit() && !TR::Compiler->om.canGenerateArraylets(); + return (TR::Compiler->target.cpu.isX86() + || TR::Compiler->target.cpu.isPower()) + && !comp()->getOption(TR_DisableUnsafe) + && !comp()->compileRelocatableCode() + && TR::Compiler->target.is64Bit() + && !TR::Compiler->om.canGenerateArraylets(); case TR::java_lang_Class_isAssignableFrom: return cg()->supportsInliningOfIsAssignableFrom(); case TR::java_lang_Integer_rotateLeft: diff --git a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp index bf221bc473b..5d61cd55f09 100644 --- a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp @@ -11824,6 +11824,10 @@ J9::Power::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&result resultReg = inlineSinglePrecisionFP(node, TR::InstOpCode::fsqrts, cg); return true; } + else if (OMR::Power::CodeGenerator::inlineDirectCall(node, resultReg)) + { + return true; + } else if (methodSymbol) { switch (methodSymbol->getRecognizedMethod()) From 545a95fa85e2d80a2492b2bc3bd60e955da9806a Mon Sep 17 00:00:00 2001 From: Henry Zongaro Date: Tue, 30 Oct 2018 10:07:32 -0400 Subject: [PATCH 3/3] Call OMR's inlineDirectCall through connector Adjusted call to overridden inlineDirectCall to be done through the connector, rather than calling the implementation of OMR::Power::CodeGenerator::inlineDirectCall directly. Signed-off-by: Henry Zongaro --- runtime/compiler/p/codegen/J9TreeEvaluator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp index a6976b3205b..2b99b36b1ea 100644 --- a/runtime/compiler/p/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/p/codegen/J9TreeEvaluator.cpp @@ -12174,7 +12174,7 @@ J9::Power::CodeGenerator::inlineDirectCall(TR::Node *node, TR::Register *&result resultReg = inlineSinglePrecisionFP(node, TR::InstOpCode::fsqrts, cg); return true; } - else if (OMR::Power::CodeGenerator::inlineDirectCall(node, resultReg)) + else if (OMR::CodeGeneratorConnector::inlineDirectCall(node, resultReg)) { return true; }