summaryrefslogtreecommitdiff
path: root/compiler/compiled_method.h
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2017-10-31 11:38:30 +0000
committer Vladimir Marko <vmarko@google.com> 2017-11-15 14:29:52 +0000
commit92f7f3ce3b01f7c7df1c15b81c900e087248093f (patch)
tree37647ac824e450f80d752539cabbe631ba795c75 /compiler/compiled_method.h
parent5dcb0d2cabe9d67987a6a7477fb124cef92abefb (diff)
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
Diffstat (limited to 'compiler/compiled_method.h')
-rw-r--r--compiler/compiled_method.h48
1 files changed, 44 insertions, 4 deletions
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 <vector>
#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<InstructionSetField>();
}
ArrayRef<const uint8_t> 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<size_t>(InstructionSet::kLast));
+ static constexpr size_t kNumberOfCompiledCodePackedBits = kInstructionSetFieldSize;
+ static constexpr size_t kMaxNumberOfPackedBits = sizeof(uint32_t) * kBitsPerByte;
+
template <typename T>
static ArrayRef<const T> GetArray(const LengthPrefixedArray<T>* array);
@@ -75,13 +82,26 @@ class CompiledCode {
return compiler_driver_;
}
+ template <typename BitFieldType>
+ typename BitFieldType::value_type GetPackedField() const {
+ return BitFieldType::Decode(packed_fields_);
+ }
+
+ template <typename BitFieldType>
+ void SetPackedField(typename BitFieldType::value_type value) {
+ DCHECK(IsUint<BitFieldType::size>(static_cast<uintptr_t>(value)));
+ packed_fields_ = BitFieldType::Update(value, packed_fields_);
+ }
+
private:
- CompilerDriver* const compiler_driver_;
+ using InstructionSetField = BitField<InstructionSet, 0u, kInstructionSetFieldSize>;
- const InstructionSet instruction_set_;
+ CompilerDriver* const compiler_driver_;
- // Used to store the PIC code for Quick.
+ // Used to store the compiled code.
const LengthPrefixedArray<uint8_t>* 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<IsIntrinsicField>();
+ }
+
+ // 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<IsIntrinsicField>(/* value */ true);
+ }
+
size_t GetFrameSizeInBytes() const {
return frame_size_in_bytes_;
}
@@ -137,6 +169,14 @@ class CompiledMethod FINAL : public CompiledCode {
ArrayRef<const linker::LinkerPatch> 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<bool, kIsIntrinsicLsb, kIsIntrinsicSize>;
+
// 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.