From 5f84607854775be67a8eb2437ce1071af7d477d2 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 9 Apr 2020 13:20:11 +0100 Subject: Optimizing: Construct intrinsic HIR in builder. To help baseline compiler emit better code, construct intermediate representation for intrinsics that have corresponding HIR classes in the instruction builder, instead of doing it in the instruction simplifier. Note: The generated code is sometimes different than before because GVN uses instruction ids for input ordering for commutative operations. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: aosp_taimen-userdebug boots. Change-Id: Ifa3a5774f8f3fbff4e3ca359c38eceee993d62cd --- compiler/optimizing/instruction_builder.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'compiler/optimizing/instruction_builder.h') diff --git a/compiler/optimizing/instruction_builder.h b/compiler/optimizing/instruction_builder.h index c0211342ff..95d331558f 100644 --- a/compiler/optimizing/instruction_builder.h +++ b/compiler/optimizing/instruction_builder.h @@ -243,17 +243,22 @@ class HInstructionBuilder : public ValueObject { uint32_t dex_pc, HInvoke* invoke); - bool SetupInvokeArguments(HInvoke* invoke, + enum class ReceiverArg { + kNone, // No receiver, static method. + kNullCheckedArg, // Normal instance invoke, null check and pass the argument. + kNullCheckedOnly, // Null check but do not use the arg, used for intrinsic replacements. + kPlainArg, // Do not null check but pass the argument, used for unresolved methods. + kIgnored, // No receiver despite allocated vreg, used for String.. + }; + bool SetupInvokeArguments(HInstruction* invoke, const InstructionOperands& operands, const char* shorty, - size_t start_index, - size_t* argument_index); + ReceiverArg receiver_arg); bool HandleInvoke(HInvoke* invoke, const InstructionOperands& operands, const char* shorty, - bool is_unresolved, - HClinitCheck* clinit_check = nullptr); + bool is_unresolved); bool HandleStringInit(HInvoke* invoke, const InstructionOperands& operands, @@ -265,6 +270,14 @@ class HInstructionBuilder : public ValueObject { ArtMethod* method, HInvokeStaticOrDirect::ClinitCheckRequirement* clinit_check_requirement); + // Try to build a replacement for an intrinsic invoke. Returns true on success, + // false on failure. Failure can be either lack of replacement HIR classes, or + // input register mismatch. + bool BuildSimpleIntrinsic(ArtMethod* method, + uint32_t dex_pc, + const InstructionOperands& operands, + const char* shorty); + // Build a HNewInstance instruction. HNewInstance* BuildNewInstance(dex::TypeIndex type_index, uint32_t dex_pc); -- cgit v1.2.3-59-g8ed1b