From 8758454d380a2b0de1f4a99e9623cfac5460ccdf Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 12 Dec 2017 17:47:52 +0000 Subject: Clean up InstanceOf/CheckCast. Avoid read barriers for boot image class InstanceOf. Boot image classes are non-moveable, so comparing them against from-space and to-space reference yields the same result. Change the notion of a "fatal" type check slow path to mean that the runtime call shall not return by normal path, i.e. "fatal" now includes certainly throwing in a try-block. This avoids unnecessary code to restore registers and jump back. For boot image classes the CheckCast comparisons do not need read barriers (for the same reason as for InstanceOf), so we shall not have any false negatives and can treat the check's slow paths as final in the same cases as in non-CC configs. Boot image size for aosp_taimen-userdebug in AOSP master: - before: arm boot*.oat: 37075460 arm64 boot*.oat: 43431768 - after: arm boot*.oat: 36894292 (-177KiB, -0.5%) arm64 boot*.oat: 43201256 (-225KiB, -0.5%) Also remove some obsolete helpers from CodeGenerator. Test: Additional test in 603-checker-instanceof. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Pixel 2 XL boots. Test: testrunner.py --target --optimizing Bug: 12687968 Change-Id: Ib1381084e46a10e70320dcc618f0502ad725f0b8 --- compiler/optimizing/nodes.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index affd54ed72..6527cd3b4c 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -6600,7 +6600,7 @@ std::ostream& operator<<(std::ostream& os, TypeCheckKind rhs); class HInstanceOf FINAL : public HExpression<2> { public: HInstanceOf(HInstruction* object, - HLoadClass* constant, + HLoadClass* target_class, TypeCheckKind check_kind, uint32_t dex_pc) : HExpression(DataType::Type::kBool, @@ -6609,7 +6609,13 @@ class HInstanceOf FINAL : public HExpression<2> { SetPackedField(check_kind); SetPackedFlag(true); SetRawInputAt(0, object); - SetRawInputAt(1, constant); + SetRawInputAt(1, target_class); + } + + HLoadClass* GetTargetClass() const { + HInstruction* load_class = InputAt(1); + DCHECK(load_class->IsLoadClass()); + return load_class->AsLoadClass(); } bool IsClonable() const OVERRIDE { return true; } @@ -6703,14 +6709,20 @@ class HBoundType FINAL : public HExpression<1> { class HCheckCast FINAL : public HTemplateInstruction<2> { public: HCheckCast(HInstruction* object, - HLoadClass* constant, + HLoadClass* target_class, TypeCheckKind check_kind, uint32_t dex_pc) : HTemplateInstruction(SideEffects::CanTriggerGC(), dex_pc) { SetPackedField(check_kind); SetPackedFlag(true); SetRawInputAt(0, object); - SetRawInputAt(1, constant); + SetRawInputAt(1, target_class); + } + + HLoadClass* GetTargetClass() const { + HInstruction* load_class = InputAt(1); + DCHECK(load_class->IsLoadClass()); + return load_class->AsLoadClass(); } bool IsClonable() const OVERRIDE { return true; } -- cgit v1.2.3-59-g8ed1b