diff options
-rw-r--r-- | compiler/optimizing/inliner.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/instruction_builder.cc | 4 | ||||
-rw-r--r-- | test/733-icce/expected-stderr.txt | 0 | ||||
-rw-r--r-- | test/733-icce/expected-stdout.txt | 0 | ||||
-rw-r--r-- | test/733-icce/info.txt | 1 | ||||
-rw-r--r-- | test/733-icce/smali/Cls.smali | 29 | ||||
-rw-r--r-- | test/733-icce/smali/Other.smali | 28 | ||||
-rw-r--r-- | test/733-icce/src/Main.java | 21 |
8 files changed, 85 insertions, 0 deletions
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index d679261d42..5281346644 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -1593,6 +1593,8 @@ bool HInliner::TryBuildAndInline(HInvoke* invoke_instruction, ReferenceTypeInfo receiver_type, HInstruction** return_replacement, bool is_speculative) { + DCHECK_IMPLIES(method->IsStatic(), !receiver_type.IsValid()); + DCHECK_IMPLIES(!method->IsStatic(), receiver_type.IsValid()); // If invoke_instruction is devirtualized to a different method, give intrinsics // another chance before we try to inline it. if (invoke_instruction->GetResolvedMethod() != method && diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index c66fd3bb26..8226987968 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -992,6 +992,10 @@ static ArtMethod* ResolveMethod(uint16_t method_idx, (!resolved_method->IsPublic() && !declaring_class_accessible)) { return nullptr; } + + if (UNLIKELY(resolved_method->CheckIncompatibleClassChange(*invoke_type))) { + return nullptr; + } } // We have to special case the invoke-super case, as ClassLinker::ResolveMethod does not. diff --git a/test/733-icce/expected-stderr.txt b/test/733-icce/expected-stderr.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/733-icce/expected-stderr.txt diff --git a/test/733-icce/expected-stdout.txt b/test/733-icce/expected-stdout.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/733-icce/expected-stdout.txt diff --git a/test/733-icce/info.txt b/test/733-icce/info.txt new file mode 100644 index 0000000000..de28c6d51d --- /dev/null +++ b/test/733-icce/info.txt @@ -0,0 +1 @@ +Regression test for a missing incompatible class change check in the compiler. diff --git a/test/733-icce/smali/Cls.smali b/test/733-icce/smali/Cls.smali new file mode 100644 index 0000000000..af35234543 --- /dev/null +++ b/test/733-icce/smali/Cls.smali @@ -0,0 +1,29 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.class public LCls; +.super LMissing; + +.method public constructor <init>()V +.registers 1 + invoke-direct {v0}, Ljava/lang/Object;-><init>()V + return-void +.end method + +.method public callVirtualAsStatic()V +.registers 1 + invoke-static {}, LOther;->virtualMethod()V + return-void +.end method diff --git a/test/733-icce/smali/Other.smali b/test/733-icce/smali/Other.smali new file mode 100644 index 0000000000..e8a7ba70b4 --- /dev/null +++ b/test/733-icce/smali/Other.smali @@ -0,0 +1,28 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.class public LOther; +.super Ljava/lang/Object; + +.method public constructor <init>()V +.registers 1 + invoke-direct {v0}, Ljava/lang/Object;-><init>()V + return-void +.end method + +.method public virtualMethod()V +.registers 1 + return-void +.end method diff --git a/test/733-icce/src/Main.java b/test/733-icce/src/Main.java new file mode 100644 index 0000000000..8e254b2c2a --- /dev/null +++ b/test/733-icce/src/Main.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class Main { + + public static void main(String[] args) { + } +} |