--- old/src/hotspot/share/oops/method.cpp 2019-06-25 22:41:25.810942801 -0700 +++ new/src/hotspot/share/oops/method.cpp 2019-06-25 22:41:25.486930931 -0700 @@ -1218,12 +1218,22 @@ } } -address Method::from_compiled_entry_no_trampoline() const { +address Method::from_compiled_entry_no_trampoline(bool caller_is_c1) const { CompiledMethod *code = OrderAccess::load_acquire(&_code); - if (code) { - return code->verified_entry_point(); + if (caller_is_c1) { + // C1 - value arguments are passed as objects + if (code) { + return code->verified_value_entry_point(); + } else { + return adapter()->get_c2i_value_entry(); + } } else { - return adapter()->get_c2i_entry(); + // C2 - value arguments may be passed as unpacked fields + if (code) { + return code->verified_entry_point(); + } else { + return adapter()->get_c2i_entry(); + } } } --- old/src/hotspot/share/oops/method.hpp 2019-06-25 22:41:26.534969323 -0700 +++ new/src/hotspot/share/oops/method.hpp 2019-06-25 22:41:26.214957600 -0700 @@ -149,7 +149,7 @@ static address make_adapters(const methodHandle& mh, TRAPS); address from_compiled_entry() const; - address from_compiled_entry_no_trampoline() const; + address from_compiled_entry_no_trampoline(bool caller_is_c1) const; address from_interpreted_entry() const; // access flag --- old/src/hotspot/share/runtime/sharedRuntime.cpp 2019-06-25 22:41:27.294997163 -0700 +++ new/src/hotspot/share/runtime/sharedRuntime.cpp 2019-06-25 22:41:26.938984122 -0700 @@ -1964,8 +1964,6 @@ JRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc)) Method* moop(method); - address entry_point = moop->from_compiled_entry_no_trampoline(); - // It's possible that deoptimization can occur at a call site which hasn't // been resolved yet, in which case this function will be called from // an nmethod that has been patched for deopt and we can ignore the @@ -1977,7 +1975,11 @@ // ask me how I know this... CodeBlob* cb = CodeCache::find_blob(caller_pc); - if (cb == NULL || !cb->is_compiled() || entry_point == moop->get_c2i_entry()) { + if (cb == NULL || !cb->is_compiled()) { + return; + } + address entry_point = moop->from_compiled_entry_no_trampoline(cb->is_compiled_by_c1()); + if (entry_point == moop->get_c2i_entry()) { return; } --- old/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestCallingConventionC1.java 2019-06-25 22:41:28.039024419 -0700 +++ new/test/hotspot/jtreg/compiler/valhalla/valuetypes/TestCallingConventionC1.java 2019-06-25 22:41:27.719012696 -0700 @@ -44,22 +44,34 @@ @Override public int getNumScenarios() { - return 2; + return 4; } @Override public String[] getVMParameters(int scenario) { switch (scenario) { - - // Default: both C1 and C2 are enabled, tierd compilation enabled - case 0: return new String[] {"-XX:+EnableValhallaC1", "-XX:CICompilerCount=2" - // , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test78*" - //, "-XX:CompileCommand=print,*::func_c1" - }; - // Only C1. Tierd compilation disabled. - case 1: return new String[] {"-XX:+EnableValhallaC1", "-XX:TieredStopAtLevel=1" - // , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test76*" - }; + case 0: return new String[] { + // Default: both C1 and C2 are enabled, tierd compilation enabled + "-XX:+EnableValhallaC1", + "-XX:CICompilerCount=2" + }; + case 1: return new String[] { + // Same as above, but flip all the compLevel=C1 and compLevel=C2, so we test + // the compliment of the above scenario. + "-XX:+EnableValhallaC1", + "-XX:CICompilerCount=2", + "-DFlipC1C2=true" + }; + case 2: return new String[] { + // Only C1. Tierd compilation disabled. + "-XX:+EnableValhallaC1", + "-XX:TieredStopAtLevel=1", + }; + case 3: return new String[] { + // Only C2. + "-XX:-EnableValhallaC1", + "-XX:TieredStopAtLevel=4", + }; } return null; } @@ -1892,4 +1904,70 @@ Asserts.assertEQ(rp1.y.n, i); } } + + // C1->C1 - caller is compiled first. It invokes callee(test97) a few times while the + // callee is executed by the interpreter. Then, callee is compiled + // and SharedRuntime::fixup_callers_callsite is called to fix up the + // callsite from test97_verifier->test97. + @Test(compLevel = C1) + public int test97(Point p1, Point p2) { + return test97_helper(p1, p2); + } + + @DontInline @DontCompile + public int test97_helper(Point p1, Point p2) { + return p1.x + p1.y + p2.x + p2.y; + } + + @ForceCompile(compLevel = C1) + public void test97_verifier(boolean warmup) { + int count = warmup ? 1 : 20; + for (int i=0; iC2 - same as test97, except the callee is compiled by c2. + @Test(compLevel = C2) + public int test98(Point p1, Point p2) { + return test98_helper(p1, p2); + } + + @DontInline @DontCompile + public int test98_helper(Point p1, Point p2) { + return p1.x + p1.y + p2.x + p2.y; + } + + @ForceCompile(compLevel = C1) + public void test98_verifier(boolean warmup) { + int count = warmup ? 1 : 20; + for (int i=0; iC2 - same as test97, except the callee is a static method. + @Test(compLevel = C1) + public static int test99(Point p1, Point p2) { + return test99_helper(p1, p2); + } + + @DontInline @DontCompile + public static int test99_helper(Point p1, Point p2) { + return p1.x + p1.y + p2.x + p2.y; + } + + @ForceCompile(compLevel = C1) + public void test99_verifier(boolean warmup) { + int count = warmup ? 1 : 20; + for (int i=0; i (int)TieredStopAtLevel) { compLevel = (int)TieredStopAtLevel; }