From fbb184a1c6df22d9302b32b55206396c8278edcf Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 13 Nov 2015 14:47:00 +0000 Subject: Fix ClinitCheck pruning. Make sure we merge the ClinitCheck only with LoadClass and HInvokeStaticOrDirect that is a part of the very same dex instruction. This fixes incorrect stack traces from class initializers (wrong dex pcs). Rewrite the pruning to do all the ClinitCheck merging when we see the ClinitCheck, instead of merging ClinitCheck into LoadClass and then LoadClass into HInvokeStaticOrDirect. When we later see an HInvokeStaticOrDirect with an explicit check (i.e. not merged), we know that some other instruction is doing the check and the invoke doesn't need to, so we mark it as not requiring the check at all. (Previously it would have been marked as having an implicit check.) Remove the restriction on merging with inlined invoke static as this is not necessary anymore. This was a workaround for X.test(): invoke-static C.foo() [1] C.foo(): invoke-static C.bar() [2] After inlining and GVN we have X.test(): LoadClass C (from [1]) ClinitCheck C (from [1], to be merged to LoadClass) InvokeStaticOrDirect C.bar() (from [2]) and the LoadClass must not be merged into the invoke as this would cause the resolution trampoline to see an inlined frame from the not-yet-loaded class C during the stack walk and try to load the class. However, we're not allowed to load new classes at that point, so an attempt to do so leads to an assertion failure. With this CL, LoadClass is not merged when it comes from a different instruction, so we can guarantee that all inlined frames seen by the stack walk in the resolution trampoline belong to already loaded classes. Change-Id: I2b8da8d4f295355dce17141f0fab2dace126684d --- compiler/optimizing/graph_visualizer.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/optimizing/graph_visualizer.cc') diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 2b7790184a..af3ecb1031 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -397,6 +397,9 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { << invoke->IsRecursive() << std::noboolalpha; StartAttributeStream("intrinsic") << invoke->GetIntrinsic(); + if (invoke->IsStatic()) { + StartAttributeStream("clinit_check") << invoke->GetClinitCheckRequirement(); + } } void VisitUnresolvedInstanceFieldGet(HUnresolvedInstanceFieldGet* field_access) OVERRIDE { -- cgit v1.2.3