8158639: C2 compilation fails with SIGSEGV

Thu, 17 Nov 2016 16:06:56 +0000

author
dbuck
date
Thu, 17 Nov 2016 16:06:56 +0000
changeset 8999
53d23b6b25cd
parent 8998
1e225dabccc5
child 9000
f5ded236c413

8158639: C2 compilation fails with SIGSEGV
Summary: fixed the jvms for callsite traps based on declared signature.
Reviewed-by: jcm, coleenp, vlivanov

src/share/vm/ci/ciMethod.hpp file | annotate | diff | comparison | revisions
src/share/vm/opto/callGenerator.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/graphKit.hpp file | annotate | diff | comparison | revisions
test/compiler/jsr292/NullConstantReceiver.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/ci/ciMethod.hpp	Mon Jul 24 09:32:40 2017 -0700
     1.2 +++ b/src/share/vm/ci/ciMethod.hpp	Thu Nov 17 16:06:56 2016 +0000
     1.3 @@ -243,6 +243,11 @@
     1.4  
     1.5    ciField*      get_field_at_bci( int bci, bool &will_link);
     1.6    ciMethod*     get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
     1.7 +  ciMethod*     get_method_at_bci(int bci) {
     1.8 +    bool ignored_will_link;
     1.9 +    ciSignature* ignored_declared_signature;
    1.10 +    return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);
    1.11 +  }
    1.12    // Given a certain calling environment, find the monomorphic target
    1.13    // for the call.  Return NULL if the call is not monomorphic in
    1.14    // its calling environment.
     2.1 --- a/src/share/vm/opto/callGenerator.cpp	Mon Jul 24 09:32:40 2017 -0700
     2.2 +++ b/src/share/vm/opto/callGenerator.cpp	Thu Nov 17 16:06:56 2016 +0000
     2.3 @@ -188,7 +188,10 @@
     2.4    // the call instruction will have a seemingly deficient out-count.
     2.5    // (The bailout says something misleading about an "infinite loop".)
     2.6    if (kit.gvn().type(receiver)->higher_equal(TypePtr::NULL_PTR)) {
     2.7 -    kit.inc_sp(method()->arg_size());  // restore arguments
     2.8 +    assert(Bytecodes::is_invoke(kit.java_bc()), err_msg("%d: %s", kit.java_bc(), Bytecodes::name(kit.java_bc())));
     2.9 +    ciMethod* declared_method = kit.method()->get_method_at_bci(kit.bci());
    2.10 +    int arg_size = declared_method->signature()->arg_size_for_bc(kit.java_bc());
    2.11 +    kit.inc_sp(arg_size);  // restore arguments
    2.12      kit.uncommon_trap(Deoptimization::Reason_null_check,
    2.13                        Deoptimization::Action_none,
    2.14                        NULL, "null receiver");
    2.15 @@ -1119,7 +1122,10 @@
    2.16  JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms) {
    2.17    GraphKit kit(jvms);
    2.18    // Take the trap with arguments pushed on the stack.  (Cf. null_check_receiver).
    2.19 -  int nargs = method()->arg_size();
    2.20 +  // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
    2.21 +  // Use callsite signature always.
    2.22 +  ciMethod* declared_method = kit.method()->get_method_at_bci(kit.bci());
    2.23 +  int nargs = declared_method->arg_size();
    2.24    kit.inc_sp(nargs);
    2.25    assert(nargs <= kit.sp() && kit.sp() <= jvms->stk_size(), "sane sp w/ args pushed");
    2.26    if (_reason == Deoptimization::Reason_class_check &&
     3.1 --- a/src/share/vm/opto/graphKit.hpp	Mon Jul 24 09:32:40 2017 -0700
     3.2 +++ b/src/share/vm/opto/graphKit.hpp	Thu Nov 17 16:06:56 2016 +0000
     3.3 @@ -656,7 +656,10 @@
     3.4    // callee (with all arguments still on the stack).
     3.5    Node* null_check_receiver_before_call(ciMethod* callee) {
     3.6      assert(!callee->is_static(), "must be a virtual method");
     3.7 -    const int nargs = callee->arg_size();
     3.8 +    // Callsite signature can be different from actual method being called (i.e _linkTo* sites).
     3.9 +    // Use callsite signature always.
    3.10 +    ciMethod* declared_method = method()->get_method_at_bci(bci());
    3.11 +    const int nargs = declared_method->arg_size();
    3.12      inc_sp(nargs);
    3.13      Node* n = null_check_receiver();
    3.14      dec_sp(nargs);
     4.1 --- a/test/compiler/jsr292/NullConstantReceiver.java	Mon Jul 24 09:32:40 2017 -0700
     4.2 +++ b/test/compiler/jsr292/NullConstantReceiver.java	Thu Nov 17 16:06:56 2016 +0000
     4.3 @@ -23,8 +23,10 @@
     4.4  
     4.5  /**
     4.6   * @test
     4.7 - * @bug 8059556
     4.8 + * @bug 8059556 8158639
     4.9 + *
    4.10   * @run main/othervm -Xbatch NullConstantReceiver
    4.11 + * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::run NullConstantReceiver
    4.12   */
    4.13  
    4.14  import java.lang.invoke.MethodHandle;

mercurial