From 92f7f3ce3b01f7c7df1c15b81c900e087248093f Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 31 Oct 2017 11:38:30 +0000 Subject: Use intrinsic codegen for compiling intrinsic methods. When compiling an intrinsic method, generate a graph that invokes the same method and try to compile it. If the call is actually intrinsified (or simplified to other HIR) and yields a leaf method, use the result of this compilation attempt, otherwise compile the actual code or JNI stub. Note that CodeGenerator::CreateThrowingSlowPathLocations() actually marks the locations as kNoCall if the throw is not in a catch block, thus considering some throwing methods (for example, String.charAt()) as leaf methods. We would ideally want to use the intrinsic codegen for all intrinsics that do not generate a slow-path call to the default implementation. Relying on the leaf method is suboptimal as we're missing out on methods that do other types of calls, for example runtime calls. This shall be fixed in a subsequent CL. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 67717501 Change-Id: I640fda7c22d4ff494b5ff77ebec3b7f5f75af652 --- compiler/compiled_method.h | 48 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'compiler/compiled_method.h') diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h index 892bc592db..acdce260e5 100644 --- a/compiler/compiled_method.h +++ b/compiler/compiled_method.h @@ -22,6 +22,8 @@ #include #include "arch/instruction_set.h" +#include "base/bit_field.h" +#include "base/bit_utils.h" namespace art { @@ -44,7 +46,7 @@ class CompiledCode { virtual ~CompiledCode(); InstructionSet GetInstructionSet() const { - return instruction_set_; + return GetPackedField(); } ArrayRef GetQuickCode() const; @@ -68,6 +70,11 @@ class CompiledCode { static const void* CodePointer(const void* code_pointer, InstructionSet instruction_set); protected: + static constexpr size_t kInstructionSetFieldSize = + MinimumBitsToStore(static_cast(InstructionSet::kLast)); + static constexpr size_t kNumberOfCompiledCodePackedBits = kInstructionSetFieldSize; + static constexpr size_t kMaxNumberOfPackedBits = sizeof(uint32_t) * kBitsPerByte; + template static ArrayRef GetArray(const LengthPrefixedArray* array); @@ -75,13 +82,26 @@ class CompiledCode { return compiler_driver_; } + template + typename BitFieldType::value_type GetPackedField() const { + return BitFieldType::Decode(packed_fields_); + } + + template + void SetPackedField(typename BitFieldType::value_type value) { + DCHECK(IsUint(static_cast(value))); + packed_fields_ = BitFieldType::Update(value, packed_fields_); + } + private: - CompilerDriver* const compiler_driver_; + using InstructionSetField = BitField; - const InstructionSet instruction_set_; + CompilerDriver* const compiler_driver_; - // Used to store the PIC code for Quick. + // Used to store the compiled code. const LengthPrefixedArray* const quick_code_; + + uint32_t packed_fields_; }; class CompiledMethod FINAL : public CompiledCode { @@ -116,6 +136,18 @@ class CompiledMethod FINAL : public CompiledCode { static void ReleaseSwapAllocatedCompiledMethod(CompilerDriver* driver, CompiledMethod* m); + bool IsIntrinsic() const { + return GetPackedField(); + } + + // Marks the compiled method as being generated using an intrinsic codegen. + // Such methods have no relationships to their code items. + // This affects debug information generated at link time. + void MarkAsIntrinsic() { + DCHECK(!IsIntrinsic()); + SetPackedField(/* value */ true); + } + size_t GetFrameSizeInBytes() const { return frame_size_in_bytes_; } @@ -137,6 +169,14 @@ class CompiledMethod FINAL : public CompiledCode { ArrayRef GetPatches() const; private: + static constexpr size_t kIsIntrinsicLsb = kNumberOfCompiledCodePackedBits; + static constexpr size_t kIsIntrinsicSize = 1u; + static constexpr size_t kNumberOfCompiledMethodPackedBits = kIsIntrinsicLsb + kIsIntrinsicSize; + static_assert(kNumberOfCompiledMethodPackedBits <= CompiledCode::kMaxNumberOfPackedBits, + "Too many packed fields."); + + using IsIntrinsicField = BitField; + // For quick code, the size of the activation used by the code. const size_t frame_size_in_bytes_; // For quick code, a bit mask describing spilled GPR callee-save registers. -- cgit v1.2.3-59-g8ed1b