8218201: Failures when vmIntrinsics::_getClass is not inlined

Mon, 11 Mar 2019 11:42:57 +0100

author
thartmann
date
Mon, 11 Mar 2019 11:42:57 +0100
changeset 9736
940791dabea2
parent 9735
bd6ec847115e
child 9737
c06dc174d786

8218201: Failures when vmIntrinsics::_getClass is not inlined
Summary: Fix BCEscapeAnalyzer to correctly handle _getClass intrinsic.
Reviewed-by: kvn, dlong, redestad, neliasso

src/share/vm/ci/bcEscapeAnalyzer.cpp file | annotate | diff | comparison | revisions
src/share/vm/ci/bcEscapeAnalyzer.hpp file | annotate | diff | comparison | revisions
test/compiler/escapeAnalysis/TestGetClass.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Aug 19 17:36:36 2019 +0200
     1.2 +++ b/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Mar 11 11:42:57 2019 +0100
     1.3 @@ -1170,45 +1170,43 @@
     1.4    }
     1.5  }
     1.6  
     1.7 -bool BCEscapeAnalyzer::do_analysis() {
     1.8 +void BCEscapeAnalyzer::do_analysis() {
     1.9    Arena* arena = CURRENT_ENV->arena();
    1.10    // identify basic blocks
    1.11    _methodBlocks = _method->get_method_blocks();
    1.12  
    1.13    iterate_blocks(arena);
    1.14 -  // TEMPORARY
    1.15 -  return true;
    1.16  }
    1.17  
    1.18  vmIntrinsics::ID BCEscapeAnalyzer::known_intrinsic() {
    1.19    vmIntrinsics::ID iid = method()->intrinsic_id();
    1.20 -
    1.21    if (iid == vmIntrinsics::_getClass ||
    1.22        iid ==  vmIntrinsics::_fillInStackTrace ||
    1.23 -      iid == vmIntrinsics::_hashCode)
    1.24 +      iid == vmIntrinsics::_hashCode) {
    1.25      return iid;
    1.26 -  else
    1.27 +  } else {
    1.28      return vmIntrinsics::_none;
    1.29 +  }
    1.30  }
    1.31  
    1.32 -bool BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) {
    1.33 +void BCEscapeAnalyzer::compute_escape_for_intrinsic(vmIntrinsics::ID iid) {
    1.34    ArgumentMap arg;
    1.35    arg.clear();
    1.36    switch (iid) {
    1.37 -  case vmIntrinsics::_getClass:
    1.38 -    _return_local = false;
    1.39 -    break;
    1.40 -  case vmIntrinsics::_fillInStackTrace:
    1.41 -    arg.set(0); // 'this'
    1.42 -    set_returned(arg);
    1.43 -    break;
    1.44 -  case vmIntrinsics::_hashCode:
    1.45 -    // initialized state is correct
    1.46 -    break;
    1.47 +    case vmIntrinsics::_getClass:
    1.48 +      _return_local = false;
    1.49 +      _return_allocated = false;
    1.50 +      break;
    1.51 +    case vmIntrinsics::_fillInStackTrace:
    1.52 +      arg.set(0); // 'this'
    1.53 +      set_returned(arg);
    1.54 +      break;
    1.55 +    case vmIntrinsics::_hashCode:
    1.56 +      // initialized state is correct
    1.57 +      break;
    1.58    default:
    1.59      assert(false, "unexpected intrinsic");
    1.60    }
    1.61 -  return true;
    1.62  }
    1.63  
    1.64  void BCEscapeAnalyzer::initialize() {
    1.65 @@ -1279,7 +1277,7 @@
    1.66    vmIntrinsics::ID iid = known_intrinsic();
    1.67  
    1.68    // check if method can be analyzed
    1.69 -  if (iid ==  vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized()
    1.70 +  if (iid == vmIntrinsics::_none && (method()->is_abstract() || method()->is_native() || !method()->holder()->is_initialized()
    1.71        || _level > MaxBCEAEstimateLevel
    1.72        || method()->code_size() > MaxBCEAEstimateSize)) {
    1.73      if (BCEATraceLevel >= 1) {
    1.74 @@ -1312,8 +1310,6 @@
    1.75      tty->print_cr(" (%d bytes)", method()->code_size());
    1.76    }
    1.77  
    1.78 -  bool success;
    1.79 -
    1.80    initialize();
    1.81  
    1.82    // Do not scan method if it has no object parameters and
    1.83 @@ -1329,9 +1325,9 @@
    1.84    }
    1.85  
    1.86    if (iid != vmIntrinsics::_none)
    1.87 -    success = compute_escape_for_intrinsic(iid);
    1.88 +    compute_escape_for_intrinsic(iid);
    1.89    else {
    1.90 -    success = do_analysis();
    1.91 +    do_analysis();
    1.92    }
    1.93  
    1.94    // don't store interprocedural escape information if it introduces
     2.1 --- a/src/share/vm/ci/bcEscapeAnalyzer.hpp	Mon Aug 19 17:36:36 2019 +0200
     2.2 +++ b/src/share/vm/ci/bcEscapeAnalyzer.hpp	Mon Mar 11 11:42:57 2019 +0100
     2.3 @@ -101,8 +101,8 @@
     2.4    void clear_escape_info();
     2.5    void compute_escape_info();
     2.6    vmIntrinsics::ID known_intrinsic();
     2.7 -  bool compute_escape_for_intrinsic(vmIntrinsics::ID iid);
     2.8 -  bool do_analysis();
     2.9 +  void compute_escape_for_intrinsic(vmIntrinsics::ID iid);
    2.10 +  void do_analysis();
    2.11  
    2.12    void read_escape_info();
    2.13  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/compiler/escapeAnalysis/TestGetClass.java	Mon Mar 11 11:42:57 2019 +0100
     3.3 @@ -0,0 +1,52 @@
     3.4 +/*
     3.5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 8218201
    3.30 + * @summary BCEscapeAnalyzer assigns wrong escape state to getClass return value.
    3.31 + * @run main/othervm -XX:-TieredCompilation -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_getClass
    3.32 + *                   -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,compiler.escapeAnalysis.TestGetClass::test
    3.33 + *                   -XX:+PrintCompilation compiler.escapeAnalysis.TestGetClass
    3.34 + */
    3.35 +
    3.36 +package compiler.escapeAnalysis;
    3.37 +
    3.38 +public class TestGetClass {
    3.39 +    static Object obj = new Object();
    3.40 +
    3.41 +    public static boolean test() {
    3.42 +        if (obj.getClass() == Object.class) {
    3.43 +            synchronized (obj) {
    3.44 +                return true;
    3.45 +            }
    3.46 +        }
    3.47 +        return false;
    3.48 +    }
    3.49 +
    3.50 +    public static void main(String[] args) {
    3.51 +        if (!test()) {
    3.52 +            throw new RuntimeException("Test failed");
    3.53 +        }
    3.54 +    }
    3.55 +}

mercurial