Skip to content

Commit 17283cf

Browse files
DingliZhangRealFYang
authored andcommittedSep 1, 2022
8293011: riscv: Duplicated stubs to interpreter for static calls
Reviewed-by: fyang
1 parent 6076128 commit 17283cf

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed
 
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3+
* Copyright (c) 2022, Institute of Software, Chinese Academy of Sciences. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* version 2 for more details (a copy is included in the LICENSE file that
14+
* accompanied this code).
15+
*
16+
* You should have received a copy of the GNU General Public License version
17+
* 2 along with this work; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
* or visit www.oracle.com if you need additional information or have any
22+
* questions.
23+
*
24+
*/
25+
26+
#include "precompiled.hpp"
27+
#include "asm/codeBuffer.inline.hpp"
28+
#include "asm/macroAssembler.hpp"
29+
30+
bool CodeBuffer::pd_finalize_stubs() {
31+
return emit_shared_stubs_to_interp<MacroAssembler>(this, _shared_stub_to_interp_requests);
32+
}

‎src/hotspot/cpu/riscv/codeBuffer_riscv.hpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@
2929

3030
private:
3131
void pd_initialize() {}
32-
bool pd_finalize_stubs() {
33-
if (_finalize_stubs) {
34-
Unimplemented();
35-
}
36-
return true;
37-
}
32+
bool pd_finalize_stubs();
3833

3934
public:
4035
void flush_bundle(bool start_new_bundle) {}
41-
static constexpr bool supports_shared_stubs() { return false; }
36+
static constexpr bool supports_shared_stubs() { return true; }
4237

4338
#endif // CPU_RISCV_CODEBUFFER_RISCV_HPP

‎src/hotspot/cpu/riscv/riscv.ad

+11-5
Original file line numberDiff line numberDiff line change
@@ -2284,11 +2284,17 @@ encode %{
22842284
return;
22852285
}
22862286

2287-
// Emit stub for static call
2288-
address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
2289-
if (stub == NULL) {
2290-
ciEnv::current()->record_failure("CodeCache is full");
2291-
return;
2287+
if (CodeBuffer::supports_shared_stubs() && _method->can_be_statically_bound()) {
2288+
// Calls of the same statically bound method can share
2289+
// a stub to the interpreter.
2290+
cbuf.shared_stub_to_interp_for(_method, cbuf.insts()->mark_off());
2291+
} else {
2292+
// Emit stub for static call
2293+
address stub = CompiledStaticCall::emit_to_interp_stub(cbuf);
2294+
if (stub == NULL) {
2295+
ciEnv::current()->record_failure("CodeCache is full");
2296+
return;
2297+
}
22922298
}
22932299
}
22942300
%}

‎test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @bug 8280481
2929
* @library /test/lib
3030
*
31-
* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="i386" | os.arch=="x86" | os.arch=="aarch64"
31+
* @requires os.arch=="amd64" | os.arch=="x86_64" | os.arch=="i386" | os.arch=="x86" | os.arch=="aarch64" | os.arch=="riscv64"
3232
*
3333
* @run driver compiler.sharedstubs.SharedStubToInterpTest
3434
*/

0 commit comments

Comments
 (0)
Please sign in to comment.