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
diff --git a/compiler/optimizing/instruction_builder.h b/compiler/optimizing/instruction_builder.h
index c021134..95d3315 100644
--- a/compiler/optimizing/instruction_builder.h
+++ b/compiler/optimizing/instruction_builder.h
@@ -243,17 +243,22 @@
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.<init>.
+ };
+ 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 @@
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);